@editora/core 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-B1_vtXRz.mjs +3910 -0
  48. package/dist/index-C6BoNR2t.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2039 -473
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2208 -641
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -1,13 +1,13 @@
1
- var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this.selection=t,this.schema=o}static create(e,t){const o=t||e.node("doc",{},[e.node("paragraph")]);return new v(o,{anchor:0,head:0},e)}apply(e,t){return new v(e,t||this.selection,this.schema)}}class D{constructor(e,t){this.nodes=new Map(Object.entries(e)),this.marks=new Map(Object.entries(t))}node(e,t,o){return{type:e,attrs:t,content:o}}text(e,t){return{type:"text",text:e,marks:t}}}class k{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(e,t){this.plugins.push(e),t&&this.pluginConfigs.set(e.name,t);const o=this.pluginConfigs.get(e.name)||e.config;if(e.initialize)try{e.initialize(o)}catch(i){console.error(`Failed to initialize plugin "${e.name}":`,i)}if(e.init&&e.init!==e.initialize)try{e.init(o)}catch(i){console.error(`Failed to run init hook for plugin "${e.name}":`,i)}}unregister(e){const t=this.plugins.findIndex(o=>o.name===e);if(t>-1){const o=this.plugins[t];o.destroy&&o.destroy(),this.plugins.splice(t,1),this.pluginConfigs.delete(e)}}getPlugin(e){return this.plugins.find(t=>t.name===e)}getPluginConfig(e){return this.pluginConfigs.get(e)}buildSchema(){const e={},t={};return this.plugins.forEach(o=>{o.nodes&&Object.assign(e,o.nodes),o.marks&&Object.assign(t,o.marks)}),new D(e,t)}getCommands(){const e={};return this.plugins.forEach(t=>{t.commands&&Object.assign(e,t.commands)}),e}getToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}async executePluginCommand(e,t,...o){const i=this.getPlugin(e);if(!i)throw new Error(`Plugin not found: ${e}`);const n=this.getPluginConfig(e)||i.config||{},a=n.mode||"local";try{switch(a){case"local":return i.executeLocal?i.executeLocal(t,...o):null;case"api":if(!i.executeAPI)throw new Error(`Plugin ${e} does not support API mode`);return await i.executeAPI(t,...o);case"hybrid":if(i.executeHybrid)return await i.executeHybrid(t,...o);try{if(i.executeAPI)return await i.executeAPI(t,...o)}catch(r){if(console.warn(`API execution failed for ${e}, falling back to local`,r),i.executeLocal&&n.fallbackToLocal!==!1)return i.executeLocal(t,...o);throw r}break;default:throw new Error(`Unknown plugin mode: ${a}`)}}catch(r){throw console.error(`Error executing command ${t} on plugin ${e}:`,r),r}}async destroyAll(){const e=this.plugins.filter(t=>t.destroy).map(t=>t.destroy());await Promise.all(e),this.plugins=[],this.pluginConfigs.clear()}}class J{constructor(e){if(this.listeners=[],e instanceof k)this.pluginManager=e;else{const o=e;this.pluginManager=new k,o.plugins&&Array.isArray(o.plugins)&&o.plugins.forEach(i=>{this.pluginManager.register(i)}),o.element&&(this.domElement=o.element,this.setupDOMElement(o))}const t=this.pluginManager.buildSchema();this.state=v.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(o=>{o.shortcut&&(t[o.shortcut.toLowerCase()]=o.command)}),document.addEventListener("keydown",o=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const i=[];(o.ctrlKey||o.metaKey)&&i.push("ctrl"),o.shiftKey&&i.push("shift"),o.altKey&&i.push("alt");const n=o.key.toLowerCase(),a=i.length>0?`${i.join("+")}+${n}`:n,r=t[a];r&&(o.preventDefault(),this.execCommand(r))})}handleToolbarCommand(e,t){const i=this.pluginManager.getToolbarItems().find(n=>n.id&&n.id===e||n.command===e);i!=null&&i.command&&(t!==void 0?this.execCommand(i.command,t):this.execCommand(i.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const o=this.commands[e];if(!o)return console.warn(`Command not found: ${e}`),!1;let i;return t!==void 0?i=o(this.state,t):i=o(this.state),i instanceof Promise?(i.then(n=>{n&&typeof n=="object"&&"doc"in n&&"selection"in n&&this.setState(n)}).catch(n=>{console.error(`Async command failed: ${e}`,n)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),!0):i!==!1&&i!=null}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class P{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,o;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(o=this.plugin.context)!=null&&o.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(i){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,i),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var o;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const i=(o=this.plugin.commands)==null?void 0:o[e];return i?i(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(i){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,i),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function Q(s){return new P(s)}class N{constructor(e){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(e==null?void 0:e.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),e!=null&&e.shortcuts&&e.shortcuts.forEach(t=>this.registerShortcut(t)),e!=null&&e.customShortcuts&&Object.values(e.customShortcuts).forEach(t=>{this.registerShortcut(t)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let e=1;e<=6;e++)this.registerShortcut({key:String(e),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${e}`,description:`Heading ${e}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.set(t,e)}unregisterShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.delete(t)}getShortcutKey(e){const t=[];return e.ctrl&&t.push("ctrl"),e.alt&&t.push("alt"),e.shift&&t.push("shift"),e.meta&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}getEventKey(e){const t=[];return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}handleKeyDown(e,t){if(!this.enabled)return!1;const o=this.getEventKey(e),i=this.shortcuts.get(o);return i?(i.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(i.command,i.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(e){return Array.from(this.shortcuts.values()).find(t=>t.command===e)}getShortcutDescription(e){const t=[];this.isMac?(e.meta&&t.push("⌘"),e.ctrl&&t.push("⌃"),e.alt&&t.push("⌥"),e.shift&&t.push("⇧")):(e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));const o=e.key.length===1?e.key.toUpperCase():e.key;return t.push(o),t.join("+")}getShortcutsHelp(){const e=this.getAllShortcuts(),t=new Map;e.forEach(i=>{const n=this.getShortcutCategory(i.command);t.has(n)||t.set(n,[]),t.get(n).push(i)});let o=`# Keyboard Shortcuts
1
+ var Editora=(function(b){"use strict";class lt{constructor(t,e,o){this.doc=t,this.selection=e,this.schema=o}static create(t,e){const o=e||t.node("doc",{},[t.node("paragraph")]);return new lt(o,{anchor:0,head:0},t)}apply(t,e){return new lt(t,e||this.selection,this.schema)}}class Ie{constructor(t,e){this.nodes=new Map(Object.entries(t)),this.marks=new Map(Object.entries(e))}node(t,e,o){return{type:t,attrs:e,content:o}}text(t,e){return{type:"text",text:t,marks:e}}}class Dt{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(t,e){this.plugins.push(t),e&&this.pluginConfigs.set(t.name,e);const o=this.pluginConfigs.get(t.name)||t.config;if(t.initialize)try{t.initialize(o)}catch(n){console.error(`Failed to initialize plugin "${t.name}":`,n)}if(t.init&&t.init!==t.initialize)try{t.init(o)}catch(n){console.error(`Failed to run init hook for plugin "${t.name}":`,n)}}unregister(t){const e=this.plugins.findIndex(o=>o.name===t);if(e>-1){const o=this.plugins[e];o.destroy&&o.destroy(),this.plugins.splice(e,1),this.pluginConfigs.delete(t)}}getPlugin(t){return this.plugins.find(e=>e.name===t)}getPluginConfig(t){return this.pluginConfigs.get(t)}buildSchema(){const t={},e={};return this.plugins.forEach(o=>{o.nodes&&Object.assign(t,o.nodes),o.marks&&Object.assign(e,o.marks)}),new Ie(t,e)}getCommands(){const t={};return this.plugins.forEach(e=>{e.commands&&Object.assign(t,e.commands)}),t}getToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}async executePluginCommand(t,e,...o){const n=this.getPlugin(t);if(!n)throw new Error(`Plugin not found: ${t}`);const r=this.getPluginConfig(t)||n.config||{},a=r.mode||"local";try{switch(a){case"local":return n.executeLocal?n.executeLocal(e,...o):null;case"api":if(!n.executeAPI)throw new Error(`Plugin ${t} does not support API mode`);return await n.executeAPI(e,...o);case"hybrid":if(n.executeHybrid)return await n.executeHybrid(e,...o);try{if(n.executeAPI)return await n.executeAPI(e,...o)}catch(c){if(console.warn(`API execution failed for ${t}, falling back to local`,c),n.executeLocal&&r.fallbackToLocal!==!1)return n.executeLocal(e,...o);throw c}break;default:throw new Error(`Unknown plugin mode: ${a}`)}}catch(c){throw console.error(`Error executing command ${e} on plugin ${t}:`,c),c}}async destroyAll(){const t=this.plugins.filter(e=>e.destroy).map(e=>e.destroy());await Promise.all(t),this.plugins=[],this.pluginConfigs.clear()}}class Zo{constructor(t){if(this.listeners=[],t instanceof Dt)this.pluginManager=t;else{const o=t;this.pluginManager=new Dt,o.plugins&&Array.isArray(o.plugins)&&o.plugins.forEach(n=>{this.pluginManager.register(n)}),o.element&&(this.domElement=o.element,this.setupDOMElement(o))}const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commands=this.pluginManager.getCommands()}setupDOMElement(t){this.domElement&&(t.enableToolbar!==!1&&t.toolbarElement?this.toolbarElement=t.toolbarElement:t.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",t.content&&(this.contentElement.innerHTML=t.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(e=>e(this.state))}))}setupKeyboardShortcuts(t){const e={};t.forEach(o=>{o.shortcut&&(e[o.shortcut.toLowerCase()]=o.command)}),document.addEventListener("keydown",o=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(o.ctrlKey||o.metaKey)&&n.push("ctrl"),o.shiftKey&&n.push("shift"),o.altKey&&n.push("alt");const r=o.key.toLowerCase(),a=n.length>0?`${n.join("+")}+${r}`:r,c=e[a];c&&(o.preventDefault(),this.execCommand(c))})}handleToolbarCommand(t,e){const n=this.pluginManager.getToolbarItems().find(r=>r.id&&r.id===t||r.command===t);n!=null&&n.command&&(e!==void 0?this.execCommand(n.command,e):this.execCommand(n.command))}setState(t){this.state=t,this.listeners.forEach(e=>e(t))}onChange(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}on(t,e){return t==="change"||t==="input"?this.onChange(e):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(t,e){const o=this.commands[t];if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e!==void 0?n=o(this.state,e):n=o(this.state),n instanceof Promise?(n.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&this.setState(r)}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=null}setContent(t){typeof t=="string"?this.contentElement&&(this.contentElement.innerHTML=t):this.setState(this.state.apply(t))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class _e{constructor(t){this.initialized=!1,this.plugin=t}initialize(t){var e,o;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=t,(e=this.plugin.context)!=null&&e.initialize&&this.plugin.context.initialize(),(o=this.plugin.context)!=null&&o.onEditorReady&&t.provider&&this.plugin.context.onEditorReady(t),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var t;if(!this.initialized)return!1;try{return(t=this.plugin.context)!=null&&t.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(e){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,e),!1}}executeCommand(t,...e){var o;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${t}"`),null;try{const n=(o=this.plugin.commands)==null?void 0:o[t];return n?n(...e):(console.warn(`Command "${t}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${t}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function Jo(s){return new _e(s)}class De{constructor(t){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(t==null?void 0:t.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),t!=null&&t.shortcuts&&t.shortcuts.forEach(e=>this.registerShortcut(e)),t!=null&&t.customShortcuts&&Object.values(t.customShortcuts).forEach(e=>{this.registerShortcut(e)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let t=1;t<=6;t++)this.registerShortcut({key:String(t),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${t}`,description:`Heading ${t}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.set(e,t)}unregisterShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.delete(e)}getShortcutKey(t){const e=[];return t.ctrl&&e.push("ctrl"),t.alt&&e.push("alt"),t.shift&&e.push("shift"),t.meta&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}getEventKey(t){const e=[];return t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}handleKeyDown(t,e){if(!this.enabled)return!1;const o=this.getEventKey(t),n=this.shortcuts.get(o);return n?(n.preventDefault!==!1&&(t.preventDefault(),t.stopPropagation()),e(n.command,n.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(t){return Array.from(this.shortcuts.values()).find(e=>e.command===t)}getShortcutDescription(t){const e=[];this.isMac?(t.meta&&e.push("⌘"),t.ctrl&&e.push("⌃"),t.alt&&e.push("⌥"),t.shift&&e.push("⇧")):(t.ctrl&&e.push("Ctrl"),t.alt&&e.push("Alt"),t.shift&&e.push("Shift"));const o=t.key.length===1?t.key.toUpperCase():t.key;return e.push(o),e.join("+")}getShortcutsHelp(){const t=this.getAllShortcuts(),e=new Map;t.forEach(n=>{const r=this.getShortcutCategory(n.command);e.has(r)||e.set(r,[]),e.get(r).push(n)});let o=`# Keyboard Shortcuts
2
2
 
3
- `;return t.forEach((i,n)=>{o+=`## ${n}
3
+ `;return e.forEach((n,r)=>{o+=`## ${r}
4
4
 
5
- `,i.forEach(a=>{const r=this.getShortcutDescription(a);o+=`- **${r}**: ${a.description||a.command}
5
+ `,n.forEach(a=>{const c=this.getShortcutDescription(a);o+=`- **${c}**: ${a.description||a.command}
6
6
  `}),o+=`
7
- `}),o}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}function Z(s={}){const{enabled:e=!1,provider:t="browser",apiUrl:o="",apiHeaders:i={},language:n="en",customDictionary:a=[],ignoreAllCaps:r=!0,ignoreNumbers:l=!0}=s;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:n}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:c=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:c=>(console.log("[Spellcheck] Add to dictionary:",c),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function ee(s={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:o=10485760,allowedTypes:i=["image/jpeg","image/png","image/gif","image/webp"],headers:n={},withCredentials:a=!1,chunkSize:r=1048576,enableChunking:l=!0,onProgress:c,onError:u,onSuccess:m}=s;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:o,allowedTypes:i}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:h=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async h=>{if(console.log("[Media] Insert image command (not implemented)",h),!h)return console.log("[Media] No file provided - should open picker"),null;if(!i.includes(h.type)){const p=new Error(`File type ${h.type} not allowed`);return u==null||u(p),null}if(h.size>o){const p=new Error(`File size ${h.size} exceeds max ${o}`);return u==null||u(p),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async h=>(console.log("[Media] Upload media (not implemented)",{name:h.name,size:h.size,type:h.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class z{constructor(e={}){this.commands=new Map,Object.entries(e).forEach(([t,o])=>{this.register(t,o)})}register(e,t){this.commands.has(e)&&console.warn(`Command ${e} is being overwritten`),this.commands.set(e,t)}unregister(e){this.commands.delete(e)}get(e){return this.commands.get(e)}has(e){return this.commands.has(e)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class x{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new k,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(o=>this.pluginManager.register(o));const t=this.pluginManager.buildSchema();this.state=v.create(t),this.commandRegistry=new z(this.pluginManager.getCommands())}execCommand(e,...t){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(e);if(!o)return console.warn(`Command not found: ${e}`),!1;let i;return t.length===0?i=o(this.state):t.length===1?i=o(this.state,t[0]):i=o(this.state,...t),i instanceof Promise?(i.then(n=>{n&&typeof n=="object"&&"doc"in n&&"selection"in n&&(this.setState(n),this.emit("change",this.state))}).catch(n=>{console.error(`Async command failed: ${e}`,n)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(e){this.isDestroyed||(this.state=e,this.emit("stateChange",e))}getState(){return this.state}setReadonly(e){this.isReadonly=e,this.emit("readonlyChange",e)}isReadOnly(){return this.isReadonly}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const o=this.listeners.get(e);if(o){const i=o.indexOf(t);i>-1&&o.splice(i,1)}}}emit(e,...t){const o=this.listeners.get(e);o&&o.forEach(i=>{try{i(...t)}catch(n){console.error(`Error in ${e} handler:`,n)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class w{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new w(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new w(this.doc,e)}update(e,t){return new w(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class C{setLastCommandTrigger(e,t){if(typeof window=="undefined"||!e)return;const o=t||e.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=e,window.__editoraLastCommand=o)}constructor(e,t,o){this.config=e,this.plugins=t,this.pluginLoader=o}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],o=e.split("|").map(r=>r.trim()),i=this.getAvailableToolbarItems(),n=new Map;i.forEach(r=>{r.command&&n.set(r.command,r),r.type==="group"&&r.label&&n.set(r.label,r)});const a={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(r=>{const l=[];r.split(/\s+/).filter(Boolean).forEach(u=>{if(u==="direction"){const p=n.get("setDirectionLTR"),g=n.get("setDirectionRTL");p&&l.push({id:"directionLTR",label:p.label,command:p.command,icon:p.icon,type:p.type||"button",options:p.options}),g&&l.push({id:"directionRTL",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}if(u==="comments"){const p=n.get("addComment"),g=n.get("toggleComments");p&&l.push({id:"addComment",label:p.label,command:p.command,icon:p.icon,type:p.type||"button",options:p.options}),g&&l.push({id:"toggleComments",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}const m=a[u]||u;let h=n.get(m);h||(h=n.get(u)),h&&l.push({id:u,label:h.label,command:h.command,icon:h.icon,type:h.type==="separator"?"separator":h.type||"button",options:h.options,items:h.items})}),l.length>0&&t.push(l)}),t}getAvailableToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}render(e){this.container=e,e.innerHTML="",e.className="editora-toolbar",this.config.sticky&&e.classList.add("editora-toolbar-sticky"),this.config.position&&e.classList.add(`editora-toolbar-${this.config.position}`);const t=this.config.items||this.getDefaultToolbarString(),o=this.parseToolbarString(t);o.forEach((i,n)=>{const a=document.createElement("div");if(a.className="editora-toolbar-group",i.forEach(r=>{this.appendToolbarButton(a,r)}),e.appendChild(a),n<o.length-1){const r=document.createElement("div");r.className="editora-toolbar-separator",e.appendChild(r)}})}appendToolbarButton(e,t){if(t.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",e.appendChild(o)}else if(t.type==="dropdown"){const o=this.createDropdown(t);e.appendChild(o)}else if(t.type==="inline-menu"){const o=this.createInlineMenu(t);e.appendChild(o)}else if(t.type==="group"&&t.items&&t.items.length){const o=this.createGroupButton(t);e.appendChild(o)}else if(t.type==="input"){const o=this.createInput(t);e.appendChild(o)}else{const o=this.createButton(t);e.appendChild(o)}}createGroupButton(e){const t=document.createElement("div"),o=e.label.toLowerCase().replace(/\s+/g,"-");if(t.className=`editora-toolbar-group-button ${o}`,t.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=e.icon,t.appendChild(i)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${o}`,e.items.forEach(n=>{this.appendToolbarButton(i,n)}),t.appendChild(i)}return t}createInput(e){const t=document.createElement("input");return t.className=`editora-toolbar-input ${e.label.toLowerCase().replace(/\s+/g,"-")}`,t.type="text",t.title=e.label,t.placeholder=e.placeholder||"",e.command&&t.setAttribute("data-command",e.command),e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(t,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createButton(e){const t=document.createElement("button");if(t.className="editora-toolbar-button",t.type="button",t.title=e.label,e.command&&t.setAttribute("data-command",e.command),e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=e.icon,t.appendChild(o)}else t.innerHTML=e.icon;else t.textContent=e.label;return e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createDropdown(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(r=>{const l=document.createElement("button");l.className="editora-toolbar-dropdown-item",l.type="button",l.textContent=r.label,l.setAttribute("data-value",r.value),l.addEventListener("click",c=>{c.preventDefault(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,r.value),i.style.display="none"}),i.appendChild(l)}),o.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.setLastCommandTrigger(o,e.command);const l=i.style.display==="block";i.style.display=l?"none":"block"});const n=r=>{t.contains(r.target)||(i.style.display="none")},a=r=>{r.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",n,!0),document.addEventListener("keydown",a),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",n,!0),document.removeEventListener("keydown",a)},t.appendChild(o),t.appendChild(i),t}createInlineMenu(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const r=document.createElement("span");r.className="editora-toolbar-icon",r.innerHTML=e.icon,o.appendChild(r)}else o.innerHTML=e.icon;else o.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(r=>{const l=document.createElement("button");l.className="editora-toolbar-dropdown-item",l.type="button",l.textContent=r.label,l.setAttribute("data-value",r.value),l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,r.value),i.style.display="none"}),i.appendChild(l)}),o.addEventListener("click",r=>{var c;r.preventDefault(),r.stopPropagation(),this.setLastCommandTrigger(o,e.command);const l=(c=this.container)==null?void 0:c.querySelectorAll(".editora-toolbar-dropdown-menu");l==null||l.forEach(u=>{u!==i&&(u.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const n=r=>{t.contains(r.target)||(i.style.display="none")},a=r=>{r.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",n,!0),document.addEventListener("keydown",a),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",n,!0),document.removeEventListener("keydown",a)},t.appendChild(o),t.appendChild(i),t}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(t=>t.command).join(" ")}updateButtonState(e,t){if(!this.container)return;const o=this.container.querySelector(`[data-command="${e}"]`);o&&(t.active!==void 0&&o.classList.toggle("active",t.active),t.disabled!==void 0&&(o.disabled=t.disabled))}destroy(){this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(t=>{const o=t._cleanupDropdown;o&&o()}),this.container.innerHTML=""),this.commandHandler=void 0}}class j{constructor(e){this.visible=!1,this.config=e}create(e){const t=document.createElement("div");return t.className="editora-floating-toolbar",t.style.display="none",t.style.position="absolute",t.style.zIndex="1000",this.container=t,e.appendChild(t),t}show(e,t){this.container&&(this.container.style.display="block",this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(e,t){!this.container||!this.visible||(this.container.style.left=`${e}px`,this.container.style.top=`${t}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class F{constructor(e={}){this.statusInfo={},this.config=e}create(e){const t=document.createElement("div");return t.className="editora-statusbar",this.config.position&&t.classList.add(`editora-statusbar-${this.config.position}`),this.container=t,e.appendChild(t),t}update(e){this.statusInfo={...this.statusInfo,...e},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="editora-statusbar-left";const t=document.createElement("div");t.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const n=this.statusInfo.selectionInfo;n.startLine===n.endLine&&n.startColumn===n.endColumn?o.push(`Ln ${n.startLine}, Col ${n.startColumn}`):(n.startLine===n.endLine?o.push(`Ln ${n.startLine}, Col ${n.startColumn}-${n.endColumn}`):o.push(`Ln ${n.startLine}:${n.startColumn} - ${n.endLine}:${n.endColumn}`),o.push(`${n.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const n=this.statusInfo.cursorPosition;o.push(`Ln ${n.line}, Col ${n.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const i=[];this.statusInfo.wordCount!==void 0&&i.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&i.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&i.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([n,a])=>{i.push(`${n}: ${a}`)}),o.forEach((n,a)=>{const r=document.createElement("span");if(r.className="editora-statusbar-item",r.textContent=n,e.appendChild(r),a<o.length-1){const l=document.createElement("span");l.className="editora-statusbar-separator",l.textContent="|",e.appendChild(l)}}),i.forEach((n,a)=>{const r=document.createElement("span");if(r.className="editora-statusbar-item",r.textContent=n,t.appendChild(r),a<i.length-1){const l=document.createElement("span");l.className="editora-statusbar-separator",l.textContent="|",t.appendChild(l)}}),this.container.appendChild(e),this.container.appendChild(t)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class y{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,i)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${i}">${o.label}</button>`).join(""):`
7
+ `}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}function Qo(s={}){const{enabled:t=!1,provider:e="browser",apiUrl:o="",apiHeaders:n={},language:r="en",customDictionary:a=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=s;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:r}),e){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:f=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:f=>(console.log("[Spellcheck] Add to dictionary:",f),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function tn(s={}){const{uploadUrl:t="",libraryUrl:e="",maxFileSize:o=10485760,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:r={},withCredentials:a=!1,chunkSize:c=1048576,enableChunking:u=!0,onProgress:f,onError:g,onSuccess:T}=s;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:o,allowedTypes:n}),t||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:w=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async w=>{if(console.log("[Media] Insert image command (not implemented)",w),!w)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(w.type)){const k=new Error(`File type ${w.type} not allowed`);return g==null||g(k),null}if(w.size>o){const k=new Error(`File size ${w.size} exceeds max ${o}`);return g==null||g(k),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async w=>(console.log("[Media] Upload media (not implemented)",{name:w.name,size:w.size,type:w.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Oe{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Ot{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new Dt,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commandRegistry=new Oe(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e.length===0?n=o(this.state):e.length===1?n=o(this.state,e[0]):n=o(this.state,...e),n instanceof Promise?(n.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&(this.setState(r),this.emit("change",this.state))}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const n=o.indexOf(e);n>-1&&o.splice(n,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(n=>{try{n(...e)}catch(r){console.error(`Error in ${t} handler:`,r)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class wt{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new wt(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new wt(this.doc,t)}update(t,e){return new wt(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Rt{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var a,c;if(!this.expandedOpen)return;const r=n.target;r&&((a=this.moreButton)!=null&&a.contains(r)||(c=this.expandedRow)!=null&&c.contains(r))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),r=new Map;n.forEach(c=>{c.command&&r.set(c.command,c),c.type==="group"&&c.label&&r.set(c.label,c)});const a={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(g=>{if(g==="direction"){const k=r.get("setDirectionLTR"),x=r.get("setDirectionRTL");k&&u.push({id:"directionLTR",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options}),x&&u.push({id:"directionRTL",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options});return}if(g==="comments"){const k=r.get("addComment"),x=r.get("toggleComments");k&&u.push({id:"addComment",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options}),x&&u.push({id:"toggleComments",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options});return}const T=a[g]||g;let w=r.get(T);w||(w=r.get(g)),w&&u.push({id:g,label:w.label,command:w.command,icon:w.icon,type:w.type==="separator"?"separator":w.type||"button",options:w.options,items:w.items})}),u.length>0&&e.push(u)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((r,a)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",r.forEach(u=>{this.appendToolbarButton(c,u);const f=c.lastElementChild;f instanceof HTMLElement&&(this.overflowUnits.push(f),this.overflowUnitHomes.set(f,c))}),e.appendChild(c),a<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",e.appendChild(u)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,t.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const r=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=t.clientWidth,f=16,g=40,T=4,w=Math.max(0,u-f-g-T);let k=0,x=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(k+z<=w)k+=z,x++;else break}x=Math.max(1,Math.min(x,c.length));const Z=x<c.length;o.style.display=Z?"":"none",o.classList.toggle("active",Z&&this.expandedOpen),!Z&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=x&&n.appendChild(R)})},a=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(r)};this.resizeObserver=new ResizeObserver(()=>a()),this.resizeObserver.observe(t),a()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=t.icon,e.appendChild(n)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,t.items.forEach(r=>{this.appendToolbarButton(n,r)}),e.appendChild(n)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const r=c=>{e.contains(c.target)||(n.style.display="none")},a=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",a),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",a)},e.appendChild(o),e.appendChild(n),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var f;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=(f=this.container)==null?void 0:f.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(g=>{g!==n&&(g.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const r=c=>{e.contains(c.target)||(n.style.display="none")},a=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",a),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",a)},e.appendChild(o),e.appendChild(n),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Re{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Pe{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const r=this.statusInfo.selectionInfo;r.startLine===r.endLine&&r.startColumn===r.endColumn?o.push(`Ln ${r.startLine}, Col ${r.startColumn}`):(r.startLine===r.endLine?o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`):o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`),o.push(`${r.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const r=this.statusInfo.cursorPosition;o.push(`Ln ${r.line}, Col ${r.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([r,a])=>{n.push(`${r}: ${a}`)}),o.forEach((r,a)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,t.appendChild(c),a<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),n.forEach((r,a)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,e.appendChild(c),a<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class et{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height);const e=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
8
8
  <button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
9
9
  <button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
10
- `;if(e.innerHTML=`
10
+ `;if(t.innerHTML=`
11
11
  <div class="editora-dialog-container">
12
12
  <div class="editora-dialog-header">
13
13
  <h3>${this.config.title}</h3>
@@ -17,29 +17,29 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
17
17
  ${typeof this.config.content=="string"?this.config.content:""}
18
18
  </div>
19
19
  <div class="editora-dialog-footer">
20
- ${t}
20
+ ${e}
21
21
  </div>
22
22
  </div>
23
- `,typeof this.config.content!="string"){const o=e.querySelector(".editora-dialog-body");o&&(o.innerHTML="",o.appendChild(this.config.content))}return e}attachEventListeners(){const e=this.element.querySelector(".editora-dialog-close");if(e==null||e.addEventListener("click",()=>this.close()),this.config.buttons&&this.config.buttons.length>0)this.element.querySelectorAll("[data-dialog-button]").forEach(o=>{o.addEventListener("click",()=>{var a,r;const i=Number(o.getAttribute("data-dialog-button")),n=(a=this.config.buttons)==null?void 0:a[i];(r=n==null?void 0:n.onClick)==null||r.call(n)})});else{const t=this.element.querySelector('[data-dialog-default="cancel"]');t==null||t.addEventListener("click",()=>{var i,n;(n=(i=this.config).onCancel)==null||n.call(i),this.close()});const o=this.element.querySelector('[data-dialog-default="ok"]');o==null||o.addEventListener("click",()=>this.handleSubmit())}this.config.closeOnEscape&&this.element.addEventListener("cancel",t=>{t.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",t=>{const o=this.element.getBoundingClientRect();(t.clientX<o.left||t.clientX>o.right||t.clientY<o.top||t.clientY>o.bottom)&&this.close()})}handleSubmit(){var t,o,i,n;const e=this.element.querySelector("form");if(e){const a=new FormData(e);(o=(t=this.config).onSubmit)==null||o.call(t,a)}else{const a=this.element.querySelectorAll("input, select, textarea"),r=new FormData;a.forEach(l=>{l.name&&r.append(l.name,l.value)}),(n=(i=this.config).onSubmit)==null||n.call(i,r)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class te{constructor(e){this.isOpen=!1,this.config=e,this.selectedValue=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("div");e.className="editora-dropdown",this.config.width&&(e.style.width=this.config.width);const t=this.config.options.find(i=>i.value===this.selectedValue),o=(t==null?void 0:t.label)||this.config.placeholder||"Select...";return e.innerHTML=`
23
+ `,typeof this.config.content!="string"){const o=t.querySelector(".editora-dialog-body");o&&(o.innerHTML="",o.appendChild(this.config.content))}return t}attachEventListeners(){const t=this.element.querySelector(".editora-dialog-close");if(t==null||t.addEventListener("click",()=>this.close()),this.config.buttons&&this.config.buttons.length>0)this.element.querySelectorAll("[data-dialog-button]").forEach(o=>{o.addEventListener("click",()=>{var a,c;const n=Number(o.getAttribute("data-dialog-button")),r=(a=this.config.buttons)==null?void 0:a[n];(c=r==null?void 0:r.onClick)==null||c.call(r)})});else{const e=this.element.querySelector('[data-dialog-default="cancel"]');e==null||e.addEventListener("click",()=>{var n,r;(r=(n=this.config).onCancel)==null||r.call(n),this.close()});const o=this.element.querySelector('[data-dialog-default="ok"]');o==null||o.addEventListener("click",()=>this.handleSubmit())}this.config.closeOnEscape&&this.element.addEventListener("cancel",e=>{e.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",e=>{const o=this.element.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&this.close()})}handleSubmit(){var e,o,n,r;const t=this.element.querySelector("form");if(t){const a=new FormData(t);(o=(e=this.config).onSubmit)==null||o.call(e,a)}else{const a=this.element.querySelectorAll("input, select, textarea"),c=new FormData;a.forEach(u=>{u.name&&c.append(u.name,u.value)}),(r=(n=this.config).onSubmit)==null||r.call(n,c)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class en{constructor(t){this.isOpen=!1,this.config=t,this.selectedValue=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("div");t.className="editora-dropdown",this.config.width&&(t.style.width=this.config.width);const e=this.config.options.find(n=>n.value===this.selectedValue),o=(e==null?void 0:e.label)||this.config.placeholder||"Select...";return t.innerHTML=`
24
24
  <button class="editora-dropdown-toggle" type="button">
25
25
  <span class="editora-dropdown-label">${o}</span>
26
26
  <span class="editora-dropdown-arrow">▼</span>
27
27
  </button>
28
28
  <div class="editora-dropdown-menu" style="display: none;">
29
- ${this.config.options.map(i=>`
30
- <div class="editora-dropdown-item" data-value="${i.value}">
31
- ${i.icon?`<span class="editora-dropdown-icon">${i.icon}</span>`:""}
32
- <span>${i.label}</span>
29
+ ${this.config.options.map(n=>`
30
+ <div class="editora-dropdown-item" data-value="${n.value}">
31
+ ${n.icon?`<span class="editora-dropdown-icon">${n.icon}</span>`:""}
32
+ <span>${n.label}</span>
33
33
  </div>
34
34
  `).join("")}
35
35
  </div>
36
- `,e}attachEventListeners(){const e=this.element.querySelector(".editora-dropdown-toggle"),t=this.element.querySelector(".editora-dropdown-menu");e.addEventListener("click",i=>{i.stopPropagation(),this.isOpen=!this.isOpen,t.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(i=>{i.addEventListener("click",()=>{var a,r;const n=i.getAttribute("data-value");n&&(this.setValue(n),(r=(a=this.config).onChange)==null||r.call(a,n),this.close())})}),document.addEventListener("click",i=>{this.element.contains(i.target)||this.close()})}setValue(e){this.selectedValue=e;const t=this.config.options.find(i=>i.value===e),o=this.element.querySelector(".editora-dropdown-label");o&&t&&(o.textContent=t.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const e=this.element.querySelector(".editora-dropdown-menu");e&&(e.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class oe{constructor(e){this.defaultPresets=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC"],this.config={presetColors:this.defaultPresets,...e},this.selectedColor=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var t;const e=document.createElement("div");return e.className="editora-color-picker",e.innerHTML=`
36
+ `,t}attachEventListeners(){const t=this.element.querySelector(".editora-dropdown-toggle"),e=this.element.querySelector(".editora-dropdown-menu");t.addEventListener("click",n=>{n.stopPropagation(),this.isOpen=!this.isOpen,e.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(n=>{n.addEventListener("click",()=>{var a,c;const r=n.getAttribute("data-value");r&&(this.setValue(r),(c=(a=this.config).onChange)==null||c.call(a,r),this.close())})}),document.addEventListener("click",n=>{this.element.contains(n.target)||this.close()})}setValue(t){this.selectedValue=t;const e=this.config.options.find(n=>n.value===t),o=this.element.querySelector(".editora-dropdown-label");o&&e&&(o.textContent=e.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const t=this.element.querySelector(".editora-dropdown-menu");t&&(t.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class on{constructor(t){this.defaultPresets=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC"],this.config={presetColors:this.defaultPresets,...t},this.selectedColor=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var e;const t=document.createElement("div");return t.className="editora-color-picker",t.innerHTML=`
37
37
  <div class="editora-color-picker-input">
38
38
  <input type="color" value="${this.selectedColor||"#000000"}" />
39
39
  <input type="text" value="${this.selectedColor||"#000000"}" placeholder="#000000" />
40
40
  </div>
41
41
  <div class="editora-color-picker-presets">
42
- ${(t=this.config.presetColors)==null?void 0:t.map(o=>`
42
+ ${(e=this.config.presetColors)==null?void 0:e.map(o=>`
43
43
  <button
44
44
  class="editora-color-preset"
45
45
  style="background-color: ${o};"
@@ -48,7 +48,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
48
48
  ></button>
49
49
  `).join("")}
50
50
  </div>
51
- `,e}attachEventListeners(){const e=this.element.querySelector('input[type="color"]'),t=this.element.querySelector('input[type="text"]');e.addEventListener("input",i=>{var a,r;const n=i.target.value;t.value=n,this.selectedColor=n,(r=(a=this.config).onChange)==null||r.call(a,n)}),t.addEventListener("input",i=>{var a,r;const n=i.target.value;/^#[0-9A-Fa-f]{6}$/.test(n)&&(e.value=n,this.selectedColor=n,(r=(a=this.config).onChange)==null||r.call(a,n))}),this.element.querySelectorAll(".editora-color-preset").forEach(i=>{i.addEventListener("click",()=>{var a,r;const n=i.getAttribute("data-color");n&&(e.value=n,t.value=n,this.selectedColor=n,(r=(a=this.config).onChange)==null||r.call(a,n))})})}getValue(){return this.selectedColor}setValue(e){this.selectedColor=e;const t=this.element.querySelector('input[type="color"]'),o=this.element.querySelector('input[type="text"]');t&&(t.value=e),o&&(o.value=e)}getElement(){return this.element}destroy(){this.element.remove()}}class ie{constructor(e){const{initialUrl:t="",initialText:o="",onSubmit:i,onCancel:n}=e;this.dialog=new y({title:"Insert/Edit Link",content:this.createFormHTML(t,o),onSubmit:a=>{const r=(a.get("url")||"").trim(),l=(a.get("text")||"").trim(),c=a.get("openInNewTab")==="on";if(!r){alert("Please enter a URL");return}i({url:r,text:l,openInNewTab:c}),this.dialog.close()},onCancel:()=>{n==null||n(),this.dialog.close()},width:"500px"})}createFormHTML(e,t){return`
51
+ `,t}attachEventListeners(){const t=this.element.querySelector('input[type="color"]'),e=this.element.querySelector('input[type="text"]');t.addEventListener("input",n=>{var a,c;const r=n.target.value;e.value=r,this.selectedColor=r,(c=(a=this.config).onChange)==null||c.call(a,r)}),e.addEventListener("input",n=>{var a,c;const r=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(t.value=r,this.selectedColor=r,(c=(a=this.config).onChange)==null||c.call(a,r))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var a,c;const r=n.getAttribute("data-color");r&&(t.value=r,e.value=r,this.selectedColor=r,(c=(a=this.config).onChange)==null||c.call(a,r))})})}getValue(){return this.selectedColor}setValue(t){this.selectedColor=t;const e=this.element.querySelector('input[type="color"]'),o=this.element.querySelector('input[type="text"]');e&&(e.value=t),o&&(o.value=t)}getElement(){return this.element}destroy(){this.element.remove()}}class nn{constructor(t){const{initialUrl:e="",initialText:o="",onSubmit:n,onCancel:r}=t;this.dialog=new et({title:"Insert/Edit Link",content:this.createFormHTML(e,o),onSubmit:a=>{const c=(a.get("url")||"").trim(),u=(a.get("text")||"").trim(),f=a.get("openInNewTab")==="on";if(!c){alert("Please enter a URL");return}n({url:c,text:u,openInNewTab:f}),this.dialog.close()},onCancel:()=>{r==null||r(),this.dialog.close()},width:"500px"})}createFormHTML(t,e){return`
52
52
  <form class="link-dialog-form">
53
53
  <div class="form-group">
54
54
  <label for="link-url">URL</label>
@@ -57,7 +57,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
57
57
  id="link-url"
58
58
  name="url"
59
59
  placeholder="https://example.com"
60
- value="${this.escapeHtml(e)}"
60
+ value="${this.escapeHtml(t)}"
61
61
  required
62
62
  autofocus
63
63
  />
@@ -71,7 +71,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
71
71
  id="link-text"
72
72
  name="text"
73
73
  placeholder="Click here"
74
- value="${this.escapeHtml(t)}"
74
+ value="${this.escapeHtml(e)}"
75
75
  />
76
76
  <small>Text to display for the link (leave empty to use URL)</small>
77
77
  </div>
@@ -96,7 +96,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
96
96
  </button>
97
97
  </div>
98
98
  </form>
99
- `}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class ne{constructor(e){const{onSubmit:t,onCancel:o}=e;this.dialog=new y({title:"Insert Table",content:this.createFormHTML(),onSubmit:i=>{const n=parseInt(i.get("rows"),10),a=parseInt(i.get("cols"),10),r=i.get("headerRow")==="on";if(n<1||n>100){alert("Please enter a valid number of rows (1-100)");return}if(a<1||a>20){alert("Please enter a valid number of columns (1-20)");return}t({rows:n,cols:a,headerRow:r}),this.dialog.close()},onCancel:()=>{o==null||o(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
99
+ `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class rn{constructor(t){const{onSubmit:e,onCancel:o}=t;this.dialog=new et({title:"Insert Table",content:this.createFormHTML(),onSubmit:n=>{const r=parseInt(n.get("rows"),10),a=parseInt(n.get("cols"),10),c=n.get("headerRow")==="on";if(r<1||r>100){alert("Please enter a valid number of rows (1-100)");return}if(a<1||a>20){alert("Please enter a valid number of columns (1-20)");return}e({rows:r,cols:a,headerRow:c}),this.dialog.close()},onCancel:()=>{o==null||o(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
100
100
  <form class="table-dialog-form">
101
101
  <div class="form-group">
102
102
  <label for="table-rows">Rows</label>
@@ -155,7 +155,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
155
155
  </button>
156
156
  </div>
157
157
  </form>
158
- `}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const e=document.querySelector(".table-dialog-form");if(!e)return;const t=e.querySelector("#table-rows"),o=e.querySelector("#table-cols"),i=e.querySelector("#table-header"),n=e.querySelector("#table-preview-content"),a=()=>{const r=parseInt((t==null?void 0:t.value)||"3",10),l=parseInt((o==null?void 0:o.value)||"3",10),c=i==null?void 0:i.checked;n&&(n.textContent=`${r} rows × ${l} columns${c?" with header":""}`)};t==null||t.addEventListener("input",a),o==null||o.addEventListener("input",a),i==null||i.addEventListener("change",a)}}class ae{constructor(e){this.config=e;const{onSubmit:t,onCancel:o}=e;this.dialog=new y({title:"Insert Image",content:this.createFormHTML(),onSubmit:i=>{const n=(i.get("src")||"").trim(),a=(i.get("alt")||"").trim(),r=(i.get("width")||"").trim(),l=(i.get("height")||"").trim();if(!n){alert("Please enter an image URL or upload an image");return}t({src:n,alt:a,width:r||void 0,height:l||void 0}),this.dialog.close()},onCancel:()=>{o==null||o(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
158
+ `}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const t=document.querySelector(".table-dialog-form");if(!t)return;const e=t.querySelector("#table-rows"),o=t.querySelector("#table-cols"),n=t.querySelector("#table-header"),r=t.querySelector("#table-preview-content"),a=()=>{const c=parseInt((e==null?void 0:e.value)||"3",10),u=parseInt((o==null?void 0:o.value)||"3",10),f=n==null?void 0:n.checked;r&&(r.textContent=`${c} rows × ${u} columns${f?" with header":""}`)};e==null||e.addEventListener("input",a),o==null||o.addEventListener("input",a),n==null||n.addEventListener("change",a)}}class an{constructor(t){this.config=t;const{onSubmit:e,onCancel:o}=t;this.dialog=new et({title:"Insert Image",content:this.createFormHTML(),onSubmit:n=>{const r=(n.get("src")||"").trim(),a=(n.get("alt")||"").trim(),c=(n.get("width")||"").trim(),u=(n.get("height")||"").trim();if(!r){alert("Please enter an image URL or upload an image");return}e({src:r,alt:a,width:c||void 0,height:u||void 0}),this.dialog.close()},onCancel:()=>{o==null||o(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
159
159
  <form class="image-dialog-form">
160
160
  ${this.config.allowUpload?`
161
161
  <div class="form-group">
@@ -229,7 +229,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
229
229
  </button>
230
230
  </div>
231
231
  </form>
232
- `}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-src"),o=e.querySelector("#image-preview"),i=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const n=t.value.trim();n&&this.isValidImageUrl(n)?(i.src=n,o.style.display="block",i.onerror=()=>{o.style.display="none"}):o.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-upload"),o=e.querySelector("#image-src");t==null||t.addEventListener("change",async i=>{var r;const n=(r=i.target.files)==null?void 0:r[0];if(!n)return;const a=new FileReader;a.onload=l=>{var u;const c=(u=l.target)==null?void 0:u.result;o.value=c,o.dispatchEvent(new Event("input"))},a.readAsDataURL(n)})}isValidImageUrl(e){try{return new URL(e),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(e)||e.startsWith("data:image/")}catch(t){return!1}}}class re{constructor(e){this.onSubmit=e.onSubmit;const t=this.createContent();this.dialog=new y({title:"Insert Math Equation",content:t,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=t.querySelector("#math-latex"),this.previewDiv=t.querySelector("#math-preview"),this.displayTypeSelect=t.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const e=document.createElement("div");return e.className="math-dialog-content",e.style.minWidth="500px",e.innerHTML=`
232
+ `}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-src"),o=t.querySelector("#image-preview"),n=t.querySelector("#preview-img");e==null||e.addEventListener("input",()=>{const r=e.value.trim();r&&this.isValidImageUrl(r)?(n.src=r,o.style.display="block",n.onerror=()=>{o.style.display="none"}):o.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-upload"),o=t.querySelector("#image-src");e==null||e.addEventListener("change",async n=>{var c;const r=(c=n.target.files)==null?void 0:c[0];if(!r)return;const a=new FileReader;a.onload=u=>{var g;const f=(g=u.target)==null?void 0:g.result;o.value=f,o.dispatchEvent(new Event("input"))},a.readAsDataURL(r)})}isValidImageUrl(t){try{return new URL(t),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(t)||t.startsWith("data:image/")}catch(e){return!1}}}class sn{constructor(t){this.onSubmit=t.onSubmit;const e=this.createContent();this.dialog=new et({title:"Insert Math Equation",content:e,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=e.querySelector("#math-latex"),this.previewDiv=e.querySelector("#math-preview"),this.displayTypeSelect=e.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const t=document.createElement("div");return t.className="math-dialog-content",t.style.minWidth="500px",t.innerHTML=`
233
233
  <style>
234
234
  .math-dialog-content {
235
235
  display: flex;
@@ -341,7 +341,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
341
341
  <option value="block">Block (centered, new line)</option>
342
342
  </select>
343
343
  </div>
344
- `,e.querySelectorAll(".math-symbol-btn").forEach(o=>{o.addEventListener("click",i=>{i.preventDefault();const n=o.getAttribute("data-symbol");if(n&&this.latexInput){const a=this.latexInput.selectionStart,r=this.latexInput.selectionEnd,l=this.latexInput.value;this.latexInput.value=l.substring(0,a)+n+l.substring(r),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=a+n.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}let t=e.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g,"($1)/($2)").replace(/\^\{([^}]+)\}/g,"^$1").replace(/\_\{([^}]+)\}/g,"_$1").replace(/\\sqrt\{([^}]+)\}/g,"√($1)").replace(/\\sum/g,"∑").replace(/\\int/g,"∫").replace(/\\pi/g,"π").replace(/\\alpha/g,"α").replace(/\\beta/g,"β").replace(/\\gamma/g,"γ").replace(/\\theta/g,"θ").replace(/\\lambda/g,"λ").replace(/\\infty/g,"∞").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠");this.previewDiv.textContent=t}handleSubmit(){const e=this.latexInput.value.trim();if(!e){alert("Please enter a LaTeX expression.");return}const t=this.displayTypeSelect.value;this.onSubmit({latex:e,display:t}),this.dialog.close()}show(){this.dialog.show(),this.latexInput.value="",this.previewDiv.textContent="",this.displayTypeSelect.value="inline",setTimeout(()=>this.latexInput.focus(),100)}close(){this.dialog.close()}}class se{constructor(e){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new y({title:"Insert Special Character",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#char-search"),this.categorySelect=t.querySelector("#char-category"),this.charactersGrid=t.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="character-dialog-content",e.style.minWidth="500px",e.innerHTML=`
344
+ `,t.querySelectorAll(".math-symbol-btn").forEach(o=>{o.addEventListener("click",n=>{n.preventDefault();const r=o.getAttribute("data-symbol");if(r&&this.latexInput){const a=this.latexInput.selectionStart,c=this.latexInput.selectionEnd,u=this.latexInput.value;this.latexInput.value=u.substring(0,a)+r+u.substring(c),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=a+r.length,this.updatePreview()}})}),t}updatePreview(){const t=this.latexInput.value.trim();if(!t){this.previewDiv.textContent="";return}const e=t.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g,"($1)/($2)").replace(/\^\{([^}]+)\}/g,"^$1").replace(/\_\{([^}]+)\}/g,"_$1").replace(/\\sqrt\{([^}]+)\}/g,"√($1)").replace(/\\sum/g,"∑").replace(/\\int/g,"∫").replace(/\\pi/g,"π").replace(/\\alpha/g,"α").replace(/\\beta/g,"β").replace(/\\gamma/g,"γ").replace(/\\theta/g,"θ").replace(/\\lambda/g,"λ").replace(/\\infty/g,"∞").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠");this.previewDiv.textContent=e}handleSubmit(){const t=this.latexInput.value.trim();if(!t){alert("Please enter a LaTeX expression.");return}const e=this.displayTypeSelect.value;this.onSubmit({latex:t,display:e}),this.dialog.close()}show(){this.dialog.show(),this.latexInput.value="",this.previewDiv.textContent="",this.displayTypeSelect.value="inline",setTimeout(()=>this.latexInput.focus(),100)}close(){this.dialog.close()}}class ln{constructor(t){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new et({title:"Insert Special Character",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#char-search"),this.categorySelect=e.querySelector("#char-category"),this.charactersGrid=e.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="character-dialog-content",t.style.minWidth="500px",t.innerHTML=`
345
345
  <style>
346
346
  .character-dialog-content {
347
347
  display: flex;
@@ -428,7 +428,7 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
428
428
  <div class="char-info">
429
429
  Click any character to insert it into your document.
430
430
  </div>
431
- `,e}updateGrid(){const e=this.categorySelect.value;this.charactersGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.characters).flat():t=this.characters[e]||[],t.forEach(o=>{const i=document.createElement("button");i.className="char-button",i.textContent=o,i.title=`Insert ${o} (U+${o.charCodeAt(0).toString(16).toUpperCase()})`,i.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(o)}),this.charactersGrid.appendChild(i)})}filterCharacters(){const e=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(o=>{const i=o.textContent||"",n=`u+${i.charCodeAt(0).toString(16)}`,a=!e||i.includes(e)||n.includes(e);o.style.display=a?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="all",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class le{constructor(e){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩‍⚕️","👨‍⚕️","👩‍🎓","👨‍🎓","👩‍🏫","👨‍🏫","👩‍⚖️","👨‍⚖️","👩‍🌾","👨‍🌾","👩‍🍳","👨‍🍳","👩‍🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new y({title:"Insert Emoji",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#emoji-search"),this.categorySelect=t.querySelector("#emoji-category"),this.emojisGrid=t.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="emoji-dialog-content",e.style.minWidth="500px",e.innerHTML=`
431
+ `,t}updateGrid(){const t=this.categorySelect.value;this.charactersGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.characters).flat():e=this.characters[t]||[],e.forEach(o=>{const n=document.createElement("button");n.className="char-button",n.textContent=o,n.title=`Insert ${o} (U+${o.charCodeAt(0).toString(16).toUpperCase()})`,n.addEventListener("click",r=>{r.preventDefault(),this.handleSelect(o)}),this.charactersGrid.appendChild(n)})}filterCharacters(){const t=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(o=>{const n=o.textContent||"",r=`u+${n.charCodeAt(0).toString(16)}`,a=!t||n.includes(t)||r.includes(t);o.style.display=a?"flex":"none"})}handleSelect(t){this.onSelect(t),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="all",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class cn{constructor(t){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩‍⚕️","👨‍⚕️","👩‍🎓","👨‍🎓","👩‍🏫","👨‍🏫","👩‍⚖️","👨‍⚖️","👩‍🌾","👨‍🌾","👩‍🍳","👨‍🍳","👩‍🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new et({title:"Insert Emoji",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#emoji-search"),this.categorySelect=e.querySelector("#emoji-category"),this.emojisGrid=e.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="emoji-dialog-content",t.style.minWidth="500px",t.innerHTML=`
432
432
  <style>
433
433
  .emoji-dialog-content {
434
434
  display: flex;
@@ -518,7 +518,9 @@ var Editora=(function(d){"use strict";class v{constructor(e,t,o){this.doc=e,this
518
518
  <div class="emoji-info">
519
519
  Click any emoji to insert it into your document.
520
520
  </div>
521
- `,e}updateGrid(){const e=this.categorySelect.value;this.emojisGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.emojis).flat():t=this.emojis[e]||[],t.forEach(o=>{const i=document.createElement("button");i.className="emoji-button",i.textContent=o,i.title=`Insert ${o}`,i.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(o)}),this.emojisGrid.appendChild(i)})}filterEmojis(){const e=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(o=>{const i=o.textContent||"",n=!e||i.includes(e);o.style.display=n?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="popular",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}function H(s,e){const t=s.textContent||"",o=R(s,e.startContainer,e.startOffset),n=t.substring(0,o).split(`
522
- `),a=n.length,r=n[n.length-1].length+1;return{line:a,column:r}}function R(s,e,t){var a;let o=0;const i=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);let n=i.firstChild();for(;n;){if(n===e){o+=t;break}else n.nodeType===Node.TEXT_NODE&&(o+=((a=n.textContent)==null?void 0:a.length)||0);n=i.nextNode()}return o}function O(s){var o,i;const e=s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let t=1;if(e.length>0){t=e.length;const n=e[e.length-1];(n.tagName==="BR"||((o=n.innerHTML)==null?void 0:o.trim())===""||((i=n.textContent)==null?void 0:i.trim())==="")&&t++}else{const a=(s.textContent||"").split(`
523
- `).length;t=Math.max(1,a)}return t}function B(s){const e=s.trim()?s.trim().split(/\s+/).length:0,t=s.length;return{words:e,chars:t}}function $(s,e){const t=s.toString();return{startLine:e.line,startColumn:e.column,endLine:e.line,endColumn:e.column+t.length,selectedChars:t.length,selectedWords:t.trim().split(/\s+/).filter(Boolean).length}}const I=class I{static resolve(e){const t={};if(Object.assign(t,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(t,e.pluginDefaults),e.attributes){const o=this.parseAttributes(e.attributes);Object.assign(t,o)}return e.jsConfig&&Object.assign(t,e.jsConfig),this.normalizeConfig(t)}static normalizeConfig(e){const t={...e};if(t.toolbarFloating!==void 0||t.toolbarSticky!==void 0){const a=typeof t.toolbar=="object"&&t.toolbar?{...t.toolbar}:typeof t.toolbar=="string"?{items:t.toolbar}:{};t.toolbarFloating!==void 0&&(a.floating=!!t.toolbarFloating),t.toolbarSticky!==void 0&&(a.sticky=!!t.toolbarSticky),t.toolbar=a}if(t.toolbarItems!==void 0&&typeof t.toolbar=="object"&&t.toolbar&&(t.toolbar.items=t.toolbarItems),t.autosaveEnabled!==void 0||t.autosaveIntervalMs!==void 0||t.autosaveStorageKey!==void 0||t.autosaveProvider!==void 0||t.autosaveApiUrl!==void 0){const a=typeof t.autosave=="object"&&t.autosave?{...t.autosave}:{};t.autosaveEnabled!==void 0&&(a.enabled=!!t.autosaveEnabled),t.autosaveIntervalMs!==void 0&&(a.intervalMs=Number(t.autosaveIntervalMs)),t.autosaveStorageKey!==void 0&&(a.storageKey=t.autosaveStorageKey),t.autosaveProvider!==void 0&&(a.provider=t.autosaveProvider),t.autosaveApiUrl!==void 0&&(a.apiUrl=t.autosaveApiUrl),t.autosave=a}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof t.autosave=="boolean")t.autosave={...o,enabled:t.autosave};else if(typeof t.autosave=="object"&&t.autosave){const a={...o,...t.autosave};a.intervalMs===void 0&&a.interval!==void 0&&(a.intervalMs=Number(a.interval)),a.enabled===void 0&&(a.enabled=!0),(!Number.isFinite(a.intervalMs)||a.intervalMs<=0)&&(a.intervalMs=o.intervalMs),t.autosave=a}else t.autosave=o;if(t.languageLocale!==void 0||t.languageDirection!==void 0){const a=typeof t.language=="object"&&t.language?{...t.language}:{};t.languageLocale!==void 0&&(a.locale=t.languageLocale),t.languageDirection!==void 0&&(a.direction=t.languageDirection),t.language=a}const i={locale:"en",direction:"ltr"};if(typeof t.language=="string"?t.language={locale:t.language,direction:i.direction}:typeof t.language=="object"&&t.language?t.language={...i,...t.language}:t.language=i,t.spellcheckEnabled!==void 0||t.spellcheckProvider!==void 0||t.spellcheckApiUrl!==void 0){const a=typeof t.spellcheck=="object"&&t.spellcheck?{...t.spellcheck}:{};t.spellcheckEnabled!==void 0&&(a.enabled=!!t.spellcheckEnabled),t.spellcheckProvider!==void 0&&(a.provider=t.spellcheckProvider),t.spellcheckApiUrl!==void 0&&(a.apiUrl=t.spellcheckApiUrl),t.spellcheck=a}const n={enabled:!1,provider:"browser",apiUrl:""};if(typeof t.spellcheck=="boolean")t.spellcheck={...n,enabled:t.spellcheck};else if(typeof t.spellcheck=="object"&&t.spellcheck){const a={...n,...t.spellcheck};!a.provider&&a.mode&&(a.provider=a.mode==="local"?"browser":"api"),a.enabled===void 0&&(a.enabled=!!(a.mode||a.provider||a.apiUrl)),t.spellcheck=a}else t.spellcheck=n;return t.contextMenuEnabled!==void 0&&(t.contextMenu={enabled:!!t.contextMenuEnabled}),typeof t.contextMenu=="boolean"?t.contextMenu={enabled:t.contextMenu}:typeof t.contextMenu=="object"&&t.contextMenu?t.contextMenu={enabled:t.contextMenu.enabled!==!1}:t.contextMenu={enabled:!0},(t.pasteClean!==void 0||t.pasteKeepFormatting!==void 0||t.pasteConvertWord!==void 0)&&(t.paste={...t.paste||{},...t.pasteClean!==void 0?{clean:!!t.pasteClean}:{},...t.pasteKeepFormatting!==void 0?{keepFormatting:!!t.pasteKeepFormatting}:{},...t.pasteConvertWord!==void 0?{convertWord:!!t.pasteConvertWord}:{}}),t.paste={clean:!0,keepFormatting:!1,convertWord:!0,...t.paste||{}},t.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...t.contentConfig||{}},(t.securitySanitizeOnPaste!==void 0||t.securitySanitizeOnInput!==void 0)&&(t.security={...t.security||{},...t.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!t.securitySanitizeOnPaste}:{},...t.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!t.securitySanitizeOnInput}:{}}),t.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...t.security||{}},(t.accessibilityEnableAria!==void 0||t.accessibilityKeyboardNavigation!==void 0||t.accessibilityChecker!==void 0)&&(t.accessibility={...t.accessibility||{},...t.accessibilityEnableAria!==void 0?{enableARIA:!!t.accessibilityEnableAria}:{},...t.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!t.accessibilityKeyboardNavigation}:{},...t.accessibilityChecker!==void 0?{checker:!!t.accessibilityChecker}:{}}),typeof t.accessibility=="boolean"&&(t.accessibility={enableARIA:t.accessibility,keyboardNavigation:t.accessibility,checker:!1}),t.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...t.accessibility||{}},(t.performanceDebounceInputMs!==void 0||t.performanceViewportOnlyScan!==void 0)&&(t.performance={...t.performance||{},...t.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(t.performanceDebounceInputMs)}:{},...t.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!t.performanceViewportOnlyScan}:{}}),typeof t.performance=="boolean"&&(t.performance={debounceInputMs:100,viewportOnlyScan:t.performance}),t.performance={debounceInputMs:100,viewportOnlyScan:!0,...t.performance||{}},(typeof t.performance.debounceInputMs!="number"||!Number.isFinite(t.performance.debounceInputMs)||t.performance.debounceInputMs<0)&&(t.performance.debounceInputMs=100),t}static parseAttributes(e){const t={};for(const[o,i]of Object.entries(e)){const n=this.kebabToCamel(o);t[n]=this.parseAttributeValue(i)}return t}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(t){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}static validate(e){const t=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&t.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&t.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&t.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&t.push("theme must be a string"),{valid:t.length===0,errors:t}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const t={};for(const o of e)for(const[i,n]of Object.entries(o))n!=null&&(typeof n=="object"&&!Array.isArray(n)&&t[i]?t[i]=this.merge(t[i],n):t[i]=n);return t}};I.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1};let S=I;class q{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(e,t){this.pluginRegistry.set(e,t)}async load(e,t){if(this.loadedPlugins.has(e))return this.loadedPlugins.get(e);const o=this.pluginRegistry.get(e);if(!o)return console.warn(`Plugin not found: ${e}`),null;const i=await o();return t&&this.applyPluginConfig(i,t),this.loadedPlugins.set(e,i),i}async loadMultiple(e,t){return(await Promise.all(e.map(i=>this.load(i,t)))).filter(i=>i!==null)}async parsePluginString(e,t){const o=e.split(/\s+/).filter(Boolean);return this.loadMultiple(o,t)}applyPluginConfig(e,t){e.__pluginConfig=t}unload(e){this.loadedPlugins.delete(e)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(e){return this.loadedPlugins.has(e)}}class U{constructor(e={}){this.changeListeners=[],this.options=e,this.engine=new x({content:e.content,plugins:e.plugins||[],readonly:e.readonly}),e.onChange&&this.onChange(e.onChange),this.engine.on("change",()=>{const t=this.getHTML();this.changeListeners.forEach(o=>o(t))})}mount(e,t){this.contentElement=e,this.toolbarElement=t,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new C({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((o,i)=>{this.execCommand(o,i)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const o=this.getHTML();this.changeListeners.forEach(i=>i(o))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setHTML(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){const o=this.engine.execCommand(e,t);return this.toolbar,o}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}onChange(e){return this.changeListeners.push(e),()=>{const t=this.changeListeners.indexOf(e);t>-1&&this.changeListeners.splice(t,1)}}registerCommand(e,t){if(typeof window!="undefined"){const o=window.__editorCommands||new Map;o.set(e,t),window.__editorCommands=o}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var e;return{getHTML:()=>this.getHTML(),setHTML:t=>this.setHTML(t),execCommand:(t,o)=>this.execCommand(t,o),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(t,o)=>this.registerCommand(t,o),onChange:t=>this.onChange(t),getState:()=>this.getState(),toolbar:{items:((e=this.options.plugins)==null?void 0:e.flatMap(t=>t.toolbar||[]))||[]}}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function ce(s){return new U(s)}class _{constructor(e){this.options=e,this.containerElement=e.element;const t=this.resolvePlugins(e.plugins);this.engine=new x({content:e.content,plugins:t,readonly:e.readonly}),this.initializeDOM()}resolvePlugins(e){return e?typeof e=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):e:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new C({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((e,t)=>{this.execCommand(e,t)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setContent(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){return this.engine.execCommand(e,t)}focus(){var e;(e=this.contentElement)==null||e.focus()}on(e,t){const o=i=>{t(i.detail)};return this.containerElement.addEventListener(e,o),()=>{this.containerElement.removeEventListener(e,o)}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.containerElement.innerHTML=""}}const de=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","iframe","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],ue={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],iframe:["src","width","height","name","title","longdesc","allow","allowfullscreen","frameborder","scrolling","loading","referrerpolicy"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"]};function W(s,e,t){if((e==null?void 0:e.sanitize)===!1)return s;const o=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:de,n=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:ue,a=document.createElement("div");return a.innerHTML=s,K(a,o,n),a.innerHTML}function K(s,e,t){const o=Array.from(s.childNodes);for(const i of o)if(i.nodeType===Node.ELEMENT_NODE){const n=i,a=n.tagName.toLowerCase();if(!e.includes(a)){for(;n.firstChild;)s.insertBefore(n.firstChild,n);s.removeChild(n);continue}he(n,t),K(n,e,t)}else i.nodeType!==Node.TEXT_NODE&&s.removeChild(i)}function he(s,e){const t=s.tagName.toLowerCase(),o=Array.from(s.attributes),i=e[t]||[],n=e["*"]||[],a=[...i,...n];for(const r of o){const l=r.name.toLowerCase();let c=!1;a.includes(l)&&(c=!0);for(const u of a)if(u.endsWith("*")){const m=u.slice(0,-1);if(l.startsWith(m)){c=!0;break}}(l.startsWith("on")||l==="javascript:"||l==="href"&&r.value.trim().toLowerCase().startsWith("javascript:")||l==="src"&&r.value.trim().toLowerCase().startsWith("javascript:"))&&(c=!1),l==="dir"&&!["ltr","rtl","auto"].includes(r.value.trim().toLowerCase())&&(c=!1),c||s.removeAttribute(r.name)}s.hasAttribute("href")&&(s.getAttribute("href")||"").trim().toLowerCase().startsWith("javascript:")&&s.removeAttribute("href"),s.hasAttribute("src")&&(s.getAttribute("src")||"").trim().toLowerCase().startsWith("javascript:")&&s.removeAttribute("src")}function pe(s,e,t){return(t==null?void 0:t.sanitizeOnPaste)===!1?s:W(s,e)}function me(s,e,t){return(t==null?void 0:t.sanitizeOnInput)===!1?s:W(s,e)}const ge='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor;fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let L;const fe="__editoraCommandEditorRoot",be="__editoraLastCommandButton",V="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",G=".rte-content, .editora-content",T=new Set;let f=null,X=!1,M=null,A=null;function Y(s){if(!(s instanceof HTMLElement))return!1;const e=s;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function ye(s){return s?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null}function E(s){if(!s)return null;if(Y(s))return s;const e=s.matches(V)?s:s.closest(V);return!e||!Y(e)?null:e}function ve(){var i;if(typeof window=="undefined")return null;const s=window[fe];if(s instanceof HTMLElement){const n=E(s);if(n)return n;const a=s.matches(G)?s:s.querySelector(G);if(a){const r=E(a);if(r)return r}}const e=window[be];if(e instanceof HTMLElement){const n=E(e);if(n)return n}const t=document.activeElement;if(t){const n=E(t);if(n)return n}const o=(i=window.getSelection)==null?void 0:i.call(window);if(o&&o.rangeCount>0){const n=E(ye(o.getRangeAt(0).startContainer));if(n)return n}if(f&&f.isConnected)return f;for(const n of T)if(n.isConnected)return n;return null}function we(){if(typeof window=="undefined"||X)return;M=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,A=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const s=(e,...t)=>{const o=ve();return o?o.execCommand(e,...t):M?M(e,...t):A?A(e,...t):!1};window.executeEditorCommand=s,window.execEditorCommand=s,X=!0}function Ee(){const s="editora-webcomponent-styles";if(!document.getElementById(s)){const e=document.createElement("style");e.id=s,e.textContent=ge,document.head.appendChild(e)}}function ke(){if(!L){const s=b.__globalPluginLoader;s?L=s:L=new q}return L}class b extends HTMLElement{constructor(){if(super(),this.pluginLoader=ke(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new N,this.lastAutosavedContent="",this.loadedPlugins=[],this.lastBeforeInputType=null,Ee(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(b.__globalPluginLoader){this.pluginLoader=b.__globalPluginLoader;return}return new Promise(e=>{const t=()=>{b.__globalPluginLoader?(this.pluginLoader=b.__globalPluginLoader,e()):setTimeout(t,0)};t()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,t,o){t!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,o))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var o;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),T.add(this),f||(f=this),we(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();this.loadedPlugins=e,e.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(n){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,n)}});const t=(o=this.restoreAutosavedContent())!=null?o:this.getAttribute("data-initial-content")||"";this.engine=new x({content:t,plugins:e,readonly:this.config.readonly}),this.createUI(e,t),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],t=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(t){if(typeof this.config.plugins=="string"){const n=this.config.plugins.split(/\s+/).filter(Boolean);i&&!n.includes("a11yChecker")&&n.push("a11yChecker");for(const a of n){const r=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));r&&e.push(r)}}else if(Array.isArray(this.config.plugins)){for(const n of this.config.plugins)if(typeof n=="string"){const a=await this.pluginLoader.load(n,this.getPluginLoadConfig(n));a&&e.push(a)}else e.push(n);if(i&&!e.some(n=>(n==null?void 0:n.name)==="a11yChecker")){const n=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));n&&e.push(n)}}}else{const n=this.pluginLoader.getRegisteredPluginNames();for(const a of n){const r=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));r&&e.push(r)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const t=this.config.toolbar;if(typeof t=="string")return t;if(!t||typeof t!="object")return;const o=t.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var t;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const o=Number((t=e.debounceInputMs)!=null?t:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const t=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";t?this.contentElement.setAttribute("aria-label",t):this.contentElement.removeAttribute("aria-label")}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const t=e.provider||"browser";return{enabled:!!e.enabled,provider:t,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),t=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=t,this.contentElement.setAttribute("spellcheck",t?"true":"false")}executeCommand(e,...t){var n;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(a=>a.commands&&a.commands[e]);if(i&&i.commands){const a=i.commands[e];if(typeof a=="function")try{return e==="toggleFullscreen"?a(this,o):a(...t,o),!0}catch(r){return console.error(`[RichTextEditor] Error executing native command ${e}:`,r),!1}}return((n=this.engine)==null?void 0:n.execCommand(e,...t))||!1}getPluginLoadConfig(e){const t=this.config.pluginConfig;if(t&&typeof t=="object"){const n=t[e];if(n&&typeof n=="object")return n}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[e,e.toLowerCase(),...o[e]||[]];for(const n of i){const a=this.config[n];if(a&&typeof a=="object"&&!Array.isArray(a))return a}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}getAutosaveConfig(){var t,o;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((o=(t=e.intervalMs)!=null?t:e.interval)!=null?o:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const t=this.getAutosaveConfig();if(t.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,t.provider==="localStorage"){try{localStorage.setItem(t.storageKey,e),localStorage.setItem(`${t.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}t.provider==="api"&&t.apiUrl&&fetch(t.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const t=localStorage.getItem(e.storageKey);if(t)return this.lastAutosavedContent=t,t}catch(t){console.error("[RichTextEditor] Failed to restore autosaved content:",t)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{var t;this.persistAutosave(((t=this.contentElement)==null?void 0:t.innerHTML)||"")},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const t=window.getSelection();if(t&&t.rangeCount>0){const o=t.getRangeAt(0);o.deleteContents();const i=document.createElement("div");i.innerHTML=e;const n=document.createDocumentFragment();for(;i.firstChild;)n.appendChild(i.firstChild);o.insertNode(n),o.collapse(!1),t.removeAllRanges(),t.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,t){const o=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new C({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((n,a)=>{var r;if(this.contentElement){this.contentElement.focus();const l=window.getSelection();if(!l||l.rangeCount===0||!this.contentElement.contains(l.anchorNode)){const c=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?c.setStart(u,((r=u.textContent)==null?void 0:r.length)||0):u.nodeType===Node.ELEMENT_NODE?(c.selectNodeContents(u),c.collapse(!1)):c.setStart(this.contentElement,0),c.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(c)}}return this.executeCommand(n,a)}),this.toolbar.render(this.toolbarElement)):o&&this.appendChild(o),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(n){console.warn("defaultParagraphSeparator not supported:",n)}if(t){const n=document.createElement("div");n.innerHTML=t.trim(),!Array.from(n.childNodes).some(r=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(l)}return!1})&&t.trim()?this.contentElement.innerHTML=`<p>${t.trim()}</p>`:this.contentElement.innerHTML=t}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new j({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new F({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var n;return(n=this.contentElement)==null?void 0:n.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{this.lastBeforeInputType=o.inputType||null}),this.contentElement.addEventListener("input",()=>{if(!this.contentElement)return;let o=this.contentElement.innerHTML;const i=this.getPerformanceConfig(),n=this.getContentSanitizeConfig(),a=this.getSecurityConfig(),r=this.lastBeforeInputType;if(this.lastBeforeInputType=null,a.sanitizeOnInput!==!1&&n.sanitize!==!1&&!r){const u=me(o,n,a);if(u!==o){const m=window.getSelection(),h=m&&m.rangeCount>0?m.getRangeAt(0):null;if(this.contentElement.innerHTML=u,h&&m)try{m.removeAllRanges(),m.addRange(h)}catch(p){}o=u}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const c=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:o},bubbles:!0}))};i.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(c,i.debounceInputMs):c(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var u,m;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const i=this.config.paste||{};let n=((u=o.clipboardData)==null?void 0:u.getData("text/html"))||"";const a=((m=o.clipboardData)==null?void 0:m.getData("text/plain"))||"",r=this.getContentSanitizeConfig(),l=this.getSecurityConfig(),c=!!n&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(n);if((i.clean||!i.keepFormatting)&&a){document.execCommand("insertText",!1,a);return}if(i.convertWord===!1&&c&&a){document.execCommand("insertText",!1,a);return}if(n){l.sanitizeOnPaste!==!1&&r.sanitize!==!1&&(n=pe(n,r,l)),this.insertHTMLAtSelection(n);return}a&&document.execCommand("insertText",!1,a)}),this.contentElement.addEventListener("focus",()=>{f=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:this.contentElement.innerHTML},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(o,(n,a)=>{this.executeCommand(n,a)})});const t=()=>{const o=this.getSelectionRangeInEditor(),i=document.activeElement,n=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!n||!o&&!n||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=t,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0),o=t.commonAncestorContainer;return this.contentElement.contains(o)?t:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const t=document.createRange();return t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.collapsed}catch(t){return!1}}getSelectionAnchorRect(e,t){const o=Array.from(t.getClientRects()).filter(n=>n.width>0||n.height>0);return o.length===0?t.getBoundingClientRect():this.isSelectionBackward(e)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.getAttribute("readonly")==="true"||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const t=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const n=window.getSelection();if(!n){this.floatingToolbar.hide();return}const a=this.getSelectionAnchorRect(n,i);if(!a){this.floatingToolbar.hide();return}this.floatingToolbar.show(a.left,a.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),t=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!t)return;const o=this.contentElement.textContent||"",{words:i,chars:n}=B(o),a=O(this.contentElement);let r,l;const c=this.getSelectionRangeInEditor();c&&(r=H(this.contentElement,c),c.collapsed||(l=$(c,r),r=void 0)),this.statusBar.update({wordCount:i,charCount:n,lineCount:a,cursorPosition:r,selectionInfo:l})}handleAttributeChange(e,t){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=t==="true"?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(t==="true");break;case"theme":this.classList.forEach(o=>{o.startsWith("editora-theme-")&&this.classList.remove(o)}),t&&this.classList.add(`editora-theme-${t}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",t),this.applyAccessibilitySettings());break;case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(o=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",o)})}));break}}resolveConfig(){const e={};for(let t=0;t<this.attributes.length;t++){const o=this.attributes[t];e[o.name]=o.value}return S.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>{var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""},setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=e)},execCommand:(e,t)=>this.executeCommand(e,t),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,t)=>(this.addEventListener(e,t),()=>this.removeEventListener(e,t)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,t,o,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.persistAutosave(this.contentElement.innerHTML||""),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(t=this.toolbar)==null||t.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,T.delete(this),f===this&&(f=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setContent(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,...t){return this.executeCommand(e,...t)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}function xe(s){return new _(s)}function Ce(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",b)}return d.CharacterDialog=se,d.ColorPicker=oe,d.CommandRegistry=z,d.ConfigResolver=S,d.Dialog=y,d.DocumentModel=w,d.Dropdown=te,d.Editor=J,d.EditorEngine=x,d.EditorState=v,d.EmojiDialog=le,d.FloatingToolbar=j,d.ImageDialog=ae,d.KeyboardShortcutManager=N,d.LinkDialog=ie,d.MathDialog=re,d.MediaPlugin=ee,d.PluginLoader=q,d.PluginManager=k,d.PluginRuntime=P,d.ReactAdapter=U,d.RichTextEditorElement=b,d.Schema=D,d.SpellcheckPlugin=Z,d.StatusBar=F,d.TableDialog=ne,d.ToolbarRenderer=C,d.VanillaAdapter=_,d.calculateTextStats=B,d.countLines=O,d.createEditor=xe,d.createPluginRuntime=Q,d.createReactAdapter=ce,d.getCursorPosition=H,d.getSelectionInfo=$,d.getTextOffset=R,d.initWebComponent=Ce,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}),d})({});
521
+ `,t}updateGrid(){const t=this.categorySelect.value;this.emojisGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.emojis).flat():e=this.emojis[t]||[],e.forEach(o=>{const n=document.createElement("button");n.className="emoji-button",n.textContent=o,n.title=`Insert ${o}`,n.addEventListener("click",r=>{r.preventDefault(),this.handleSelect(o)}),this.emojisGrid.appendChild(n)})}filterEmojis(){const t=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(o=>{const n=o.textContent||"",r=!t||n.includes(t);o.style.display=r?"flex":"none"})}handleSelect(t){this.onSelect(t),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="popular",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}function Ne(s,t){const e=s.textContent||"",o=ze(s,t.startContainer,t.startOffset),r=e.substring(0,o).split(`
522
+ `),a=r.length,c=r[r.length-1].length+1;return{line:a,column:c}}function ze(s,t,e){var a;let o=0;const n=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);let r=n.firstChild();for(;r;){if(r===t){o+=e;break}else r.nodeType===Node.TEXT_NODE&&(o+=((a=r.textContent)==null?void 0:a.length)||0);r=n.nextNode()}return o}function Fe(s){var o,n;const t=s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const r=t[t.length-1];(r.tagName==="BR"||((o=r.innerHTML)==null?void 0:o.trim())===""||((n=r.textContent)==null?void 0:n.trim())==="")&&e++}else{const a=(s.textContent||"").split(`
523
+ `).length;e=Math.max(1,a)}return e}function He(s){const t=s.trim()?s.trim().split(/\s+/).length:0,e=s.length;return{words:t,chars:e}}function Ue(s,t){const e=s.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function Be(s,t){(t==null||t>s.length)&&(t=s.length);for(var e=0,o=Array(t);e<t;e++)o[e]=s[e];return o}function dn(s){if(Array.isArray(s))return s}function un(s,t){var e=s==null?null:typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e!=null){var o,n,r,a,c=[],u=!0,f=!1;try{if(r=(e=e.call(s)).next,t!==0)for(;!(u=(o=r.call(e)).done)&&(c.push(o.value),c.length!==t);u=!0);}catch(g){f=!0,n=g}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(f)throw n}}return c}}function hn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
524
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pn(s,t){return dn(s)||un(s,t)||mn(s,t)||hn()}function mn(s,t){if(s){if(typeof s=="string")return Be(s,t);var e={}.toString.call(s).slice(8,-1);return e==="Object"&&s.constructor&&(e=s.constructor.name),e==="Map"||e==="Set"?Array.from(s):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Be(s,t):void 0}}const je=Object.entries,$e=Object.setPrototypeOf,fn=Object.isFrozen,gn=Object.getPrototypeOf,bn=Object.getOwnPropertyDescriptor;let _=Object.freeze,D=Object.seal,ct=Object.create,We=typeof Reflect!="undefined"&&Reflect,te=We.apply,ee=We.construct;_||(_=function(t){return t}),D||(D=function(t){return t}),te||(te=function(t,e){for(var o=arguments.length,n=new Array(o>2?o-2:0),r=2;r<o;r++)n[r-2]=arguments[r];return t.apply(e,n)}),ee||(ee=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;n<e;n++)o[n-1]=arguments[n];return new t(...o)});const ot=I(Array.prototype.forEach),yn=I(Array.prototype.lastIndexOf),qe=I(Array.prototype.pop),xt=I(Array.prototype.push),vn=I(Array.prototype.splice),dt=Array.isArray,kt=I(String.prototype.toLowerCase),oe=I(String.prototype.toString),Ge=I(String.prototype.match),Tt=I(String.prototype.replace),Ke=I(String.prototype.indexOf),En=I(String.prototype.trim),wn=I(Number.prototype.toString),xn=I(Boolean.prototype.toString),Ve=typeof BigInt=="undefined"?null:I(BigInt.prototype.toString),Ye=typeof Symbol=="undefined"?null:I(Symbol.prototype.toString),N=I(Object.prototype.hasOwnProperty),Ct=I(Object.prototype.toString),O=I(RegExp.prototype.test),K=kn(TypeError);function I(s){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;n<e;n++)o[n-1]=arguments[n];return te(s,t,o)}}function kn(s){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return ee(s,e)}}function E(s,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kt;if($e&&$e(s,null),!dt(t))return s;let o=t.length;for(;o--;){let n=t[o];if(typeof n=="string"){const r=e(n);r!==n&&(fn(t)||(t[o]=r),n=r)}s[n]=!0}return s}function Tn(s){for(let t=0;t<s.length;t++)N(s,t)||(s[t]=null);return s}function H(s){const t=ct(null);for(const o of je(s)){var e=pn(o,2);const n=e[0],r=e[1];N(s,n)&&(dt(r)?t[n]=Tn(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=H(r):t[n]=r)}return t}function Cn(s){switch(typeof s){case"string":return s;case"number":return wn(s);case"boolean":return xn(s);case"bigint":return Ve?Ve(s):"0";case"symbol":return Ye?Ye(s):"Symbol()";case"undefined":return Ct(s);case"function":case"object":{if(s===null)return Ct(s);const t=s,e=j(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:Ct(o)}return Ct(s)}default:return Ct(s)}}function j(s,t){for(;s!==null;){const o=bn(s,t);if(o){if(o.get)return I(o.get);if(typeof o.value=="function")return I(o.value)}s=gn(s)}function e(){return null}return e}function Sn(s){try{return O(s,""),!0}catch(t){return!1}}const Xe=_(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ne=_(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ie=_(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),An=_(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),re=_(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ln=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ze=_(["#text"]),Je=_(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ae=_(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Qe=_(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Pt=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Mn=D(/{{[\w\W]*|^[\w\W]*}}/g),In=D(/<%[\w\W]*|^[\w\W]*%>/g),_n=D(/\${[\w\W]*/g),Dn=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),On=D(/^aria-[\-\w]+$/),to=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Rn=D(/^(?:\w+script|data):/i),Pn=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nn=D(/^html$/i),zn=D(/^[a-z][.\w]*(-[.\w]+)+$/i),eo=D(/<[/\w!]/g),oo=D(/<[/\w]/g),Fn=D(/<\/no(script|embed|frames)/i),Hn=D(/\/>/i),U={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},no=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Un=_(E({},no)),Bn=(function(){const s={};return ot(no,t=>{s[t]=D(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),_(s)})(),jn=function(){return typeof window=="undefined"?null:window},$n=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(o=e.getAttribute(n));const r="dompurify"+(o?"#"+o:"");try{return t.createPolicy(r,{createHTML(a){return a},createScriptURL(a){return a}})}catch(a){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},io=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},V=function(t,e,o,n){return N(t,e)&&dt(t[e])?E(n.base?H(n.base):{},t[e],n.transform):o},se=function(t,e,o){const n=N(t,e)?t[e]:void 0;return n&&typeof n=="object"?H(n):o()};function ro(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:jn();const t=h=>ro(h);if(t.version="3.4.16",t.removed=[],!s||!s.document||s.document.nodeType!==U.document||!s.Element)return t.isSupported=!1,t;let e=s.document;const o=e,n=o.currentScript;s.DocumentFragment;const r=s.HTMLTemplateElement,a=s.Node,c=s.Element,u=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const f=s.DOMParser,g=s.trustedTypes,T=c.prototype,w=j(T,"cloneNode"),k=j(T,"remove"),x=j(T,"removeAttributeNode"),Z=j(T,"nextSibling"),R=j(T,"childNodes"),z=j(T,"parentNode"),yo=j(T,"shadowRoot"),ue=j(T,"attributes"),nt=a&&a.prototype?j(a.prototype,"nodeType"):null,ut=a&&a.prototype?j(a.prototype,"nodeName"):null,Ut=a&&a.prototype?j(a.prototype,"ownerDocument"):null,At=function(i){return nt?nt(i):i.nodeType},he=function(i){return ut?ut(i):i.nodeName};if(typeof r=="function"){const h=e.createElement("template");h.content&&h.content.ownerDocument&&(e=h.content.ownerDocument)}let F,it="",pe,vo=!1,Lt=0;const Eo=function(){if(Lt>0)throw K('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ht=function(i){Eo(),Lt++;try{return F.createHTML(i)}finally{Lt--}},ri=function(i){Eo(),Lt++;try{return F.createScriptURL(i)}finally{Lt--}},ai=function(){return vo||(pe=$n(g,n),vo=!0),pe},Bt=e,me=Bt.implementation,wo=Bt.createNodeIterator,si=Bt.createDocumentFragment,li=Bt.getElementsByTagName,ci=o.importNode;let C=io();t.isSupported=typeof je=="function"&&typeof z=="function"&&me&&me.createHTMLDocument!==void 0;const di=Mn,ui=In,hi=_n,pi=Dn,mi=On,fi=Rn,xo=Pn,gi=zn;let ko=to,S=null;const fe=E({},[...Xe,...ne,...ie,...re,...Ze]);let A=null;const ge=E({},[...Je,...ae,...Qe,...Pt]);let W=Object.seal(ct(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Mt=null,To=null;const J=Object.seal(ct(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Co=!0,be=!0,So=!1,Ao=!0,Q=!1,rt=!0,at=!1,ye=!1,jt=null,$t=null,ve=!1,pt=!1,Wt=!1,qt=!1,Lo=!0,Mo=!1;const Io="user-content-";let Ee=!0,we=!1,mt={},ft=null;const _o=E({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Do=null;const Oo=E({},["audio","video","img","source","image","track"]);let Ro=null;const Po=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Gt="http://www.w3.org/1998/Math/MathML",Kt="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xhtml";let gt=q,xe=!1,ke=null;const bi=E({},[Gt,Kt,q],oe),No=_(["mi","mo","mn","ms","mtext"]);let Te=E({},No);const zo=_(["annotation-xml"]);let Ce=E({},zo);const yi=E({},["title","style","font","a","script"]);let It=null;const vi=["application/xhtml+xml","text/html"],Ei="text/html";let M=null,bt=null;const wi=e.createElement("form"),Fo=function(i){return i instanceof RegExp||i instanceof Function},Se=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(bt&&bt===i)return;(!i||typeof i!="object")&&(i={}),i=H(i),It=vi.indexOf(i.PARSER_MEDIA_TYPE)===-1?Ei:i.PARSER_MEDIA_TYPE,M=It==="application/xhtml+xml"?oe:kt,S=V(i,"ALLOWED_TAGS",fe,{transform:M}),A=V(i,"ALLOWED_ATTR",ge,{transform:M}),ke=V(i,"ALLOWED_NAMESPACES",bi,{transform:oe}),Ro=V(i,"ADD_URI_SAFE_ATTR",Po,{transform:M,base:Po}),Do=V(i,"ADD_DATA_URI_TAGS",Oo,{transform:M,base:Oo}),ft=V(i,"FORBID_CONTENTS",_o,{transform:M}),Mt=V(i,"FORBID_TAGS",H({}),{transform:M}),To=V(i,"FORBID_ATTR",H({}),{transform:M}),mt=N(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?H(i.USE_PROFILES):i.USE_PROFILES:!1,Co=i.ALLOW_ARIA_ATTR!==!1,be=i.ALLOW_DATA_ATTR!==!1,So=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Ao=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=i.SAFE_FOR_TEMPLATES||!1,rt=i.SAFE_FOR_XML!==!1,at=i.WHOLE_DOCUMENT||!1,pt=i.RETURN_DOM||!1,Wt=i.RETURN_DOM_FRAGMENT||!1,qt=i.RETURN_TRUSTED_TYPE||!1,ve=i.FORCE_BODY||!1,Lo=i.SANITIZE_DOM!==!1,Mo=i.SANITIZE_NAMED_PROPS||!1,Ee=i.KEEP_CONTENT!==!1,we=i.IN_PLACE||!1,ko=Sn(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:to,gt=typeof i.NAMESPACE=="string"?i.NAMESPACE:q,Te=se(i,"MATHML_TEXT_INTEGRATION_POINTS",()=>E({},No)),Ce=se(i,"HTML_INTEGRATION_POINTS",()=>E({},zo));const l=se(i,"CUSTOM_ELEMENT_HANDLING",()=>ct(null));if(W=ct(null),N(l,"tagNameCheck")&&Fo(l.tagNameCheck)&&(W.tagNameCheck=l.tagNameCheck),N(l,"attributeNameCheck")&&Fo(l.attributeNameCheck)&&(W.attributeNameCheck=l.attributeNameCheck),N(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),D(W),Q&&(be=!1),Wt&&(pt=!0),mt&&(S=E({},Ze),A=ct(null),mt.html===!0&&(E(S,Xe),E(A,Je)),mt.svg===!0&&(E(S,ne),E(A,ae),E(A,Pt)),mt.svgFilters===!0&&(E(S,ie),E(A,ae),E(A,Pt)),mt.mathMl===!0&&(E(S,re),E(A,Qe),E(A,Pt))),J.tagCheck=null,J.attributeCheck=null,N(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?J.tagCheck=i.ADD_TAGS:dt(i.ADD_TAGS)&&(S===fe&&(S=H(S)),E(S,i.ADD_TAGS,M))),N(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?J.attributeCheck=i.ADD_ATTR:dt(i.ADD_ATTR)&&(A===ge&&(A=H(A)),E(A,i.ADD_ATTR,M))),N(i,"ADD_FORBID_CONTENTS")&&dt(i.ADD_FORBID_CONTENTS)&&(ft===_o&&(ft=H(ft)),E(ft,i.ADD_FORBID_CONTENTS,M)),Ee&&(S["#text"]=!0),at&&E(S,["html","head","body"]),S.table&&(E(S,["tbody"]),delete Mt.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw K('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw K('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=F;F=i.TRUSTED_TYPES_POLICY;try{it=ht("")}catch(p){throw F=d,p}}else i.TRUSTED_TYPES_POLICY===null?(F=void 0,it=""):(F===void 0&&(F=ai()),F&&typeof it=="string"&&(it=ht("")));_&&_(i),bt=i},Ho=E({},[...ne,...ie,...An]),Uo=E({},[...re,...Ln]),xi=function(i,l,d){return l.namespaceURI===q?i==="svg":l.namespaceURI===Gt?i==="svg"&&(d==="annotation-xml"||Te[d]):!!Ho[i]},ki=function(i,l,d){return l.namespaceURI===q?i==="math":l.namespaceURI===Kt?i==="math"&&Ce[d]:!!Uo[i]},Ti=function(i,l,d){return l.namespaceURI===Kt&&!Ce[d]||l.namespaceURI===Gt&&!Te[d]?!1:!Uo[i]&&(yi[i]||!Ho[i])},Ci=function(i){let l=z(i);(!l||!l.tagName)&&(l={namespaceURI:gt,tagName:"template"});const d=kt(i.tagName),p=kt(l.tagName);return ke[i.namespaceURI]?i.namespaceURI===Kt?xi(d,l,p):i.namespaceURI===Gt?ki(d,l,p):i.namespaceURI===q?Ti(d,l,p):!!(It==="application/xhtml+xml"&&ke[i.namespaceURI]):!1},tt=function(i){xt(t.removed,{element:i});try{z(i).removeChild(i)}catch(l){if(k(i),!z(i))throw K("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Bo=function(i,l,d){try{x(i,l)}catch(p){try{i.removeAttribute(d)}catch(m){}}},Vt=function(i){Yt(i);const l=R(i);if(l){const p=[];ot(l,m=>{xt(p,m)}),ot(p,m=>{try{k(m)}catch(y){}})}const d=ue(i);if(d)for(let p=d.length-1;p>=0;--p){const m=d[p],y=m&&m.name;typeof y=="string"&&Bo(i,m,y)}},st=function(i,l,d){if(!d)try{d=l.getAttributeNode(i)}catch(p){d=null}xt(t.removed,{attribute:d||null,from:l});try{d?x(l,d):l.removeAttribute(i)}catch(p){try{l.removeAttribute(i)}catch(m){}}if(i==="is")if(pt||Wt)try{tt(l)}catch(p){}else try{l.setAttribute(i,"")}catch(p){}},Si=function(i){const l=ue(i);if(l)for(let d=l.length-1;d>=0;--d){const p=l[d],m=p&&p.name;typeof m!="string"||A[M(m)]||Bo(i,p,m)}},Yt=function(i){const l=[i];for(;l.length>0;){const d=l.pop();At(d)===U.element&&Si(d);const p=R(d);if(p)for(let m=p.length-1;m>=0;--m)l.push(p[m])}},jo=function(i,l){return rt?i==="patchsrc"?!0:i==="for"&&l!=="label"&&l!=="output":!1},Ai=function(i){if(!rt)return;const l=[i];for(;l.length>0;){const d=l.pop(),p=At(d);if(p===U.processingInstruction||p===U.comment&&O(oo,d.data)){try{k(d)}catch(y){}continue}if(p===U.element){const y=d,v=M(he(d));try{y.hasAttribute&&y.hasAttribute("patchsrc")&&y.removeAttribute("patchsrc"),y.hasAttribute&&y.hasAttribute("for")&&jo("for",v)&&y.removeAttribute("for")}catch(L){}}const m=R(d);if(m)for(let y=m.length-1;y>=0;--y)l.push(m[y])}},$o=function(i){let l=null,d=null;if(ve)i="<remove></remove>"+i;else{const y=Ge(i,/^[\r\n\t ]+/);d=y&&y[0]}It==="application/xhtml+xml"&&gt===q&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const p=F?ht(i):i;if(gt===q)try{l=new f().parseFromString(p,It)}catch(y){}if(!l||!l.documentElement){l=me.createDocument(gt,"template",null);try{l.documentElement.innerHTML=xe?it:p}catch(y){}}const m=l.body||l.documentElement;return i&&d&&m.insertBefore(e.createTextNode(d),m.childNodes[0]||null),gt===q?li.call(l,at?"html":"body")[0]:at?l.documentElement:m},Wo=function(i){const l=Ut?Ut(i):i.ownerDocument;return wo.call(l||i,i,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Xt=function(i){return i=Tt(i,di," "),i=Tt(i,ui," "),i=Tt(i,hi," "),i},Ae=function(i){var l;i.normalize();const d=Ut?Ut(i):i.ownerDocument,p=wo.call(d||i,i,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let m=p.nextNode();for(;m;)m.data=Xt(m.data),m=p.nextNode();const y=(l=i.querySelectorAll)===null||l===void 0?void 0:l.call(i,"template");y&&ot(y,v=>{yt(v.content)&&Ae(v.content)})},Zt=function(i){const l=ut?ut(i):null;return typeof l!="string"||M(l)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==ue(i)||typeof i.removeAttribute!="function"||typeof i.removeAttributeNode!="function"||typeof i.getAttributeNode!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function"||i.nodeType!==nt(i)||i.childNodes!==R(i)},yt=function(i){if(!nt||typeof i!="object"||i===null)return!1;try{return nt(i)===U.documentFragment}catch(l){return!1}},_t=function(i){if(!nt||typeof i!="object"||i===null)return!1;try{return typeof nt(i)=="number"}catch(l){return!1}};function G(h,i,l){h.length!==0&&ot(h,d=>{d.call(t,i,l,bt)})}const Li=function(i,l){return!!(rt&&i.hasChildNodes()&&!_t(i.firstElementChild)&&O(eo,i.textContent)&&O(eo,i.innerHTML)||rt&&i.namespaceURI===q&&Un[l]&&(_t(i.firstElementChild)||typeof i.textContent=="string"&&O(Bn[l],i.textContent))||i.nodeType===U.processingInstruction||rt&&i.nodeType===U.comment&&O(oo,i.data))},Jt=function(i,l){if(i instanceof RegExp)return O(i,l);if(i instanceof Function){for(var d=arguments.length,p=new Array(d>2?d-2:0),m=2;m<d;m++)p[m-2]=arguments[m];return!!i(l,...p)}return!1},Mi=function(i,l,d){if(!Mt[l]&&Vo(l)&&Jt(W.tagNameCheck,l))return!1;if(Ee&&!ft[l]){const p=z(i),m=R(i);if(m&&p){const y=m.length;for(let v=y-1;v>=0;--v){const L=i===d?w(m[v],!0):m[v];p.insertBefore(L,Z(i))}}}return tt(i),!0},qo=function(i,l,d,p){return i.length===0?l:l===d||l===p?H(l):l},vt=function(i,l){return i===l||z(i)!==null?!1:(we&&Yt(i),!0)},Go=function(i,l){if(G(C.beforeSanitizeElements,i,null),vt(i,l))return!0;if(Zt(i))return tt(i),!0;const d=M(he(i));if(S=qo(C.uponSanitizeElement,S,fe,jt),G(C.uponSanitizeElement,i,{tagName:d,allowedTags:S}),vt(i,l))return!0;if(Li(i,d))return tt(i),!0;if(Mt[d]||!(J.tagCheck instanceof Function&&J.tagCheck(d))&&!S[d]){const p=Mi(i,d,l);return p===!1&&(G(C.afterSanitizeElements,i,null),vt(i,l))?!0:p}if(At(i)===U.element&&!Ci(i)||(d==="noscript"||d==="noembed"||d==="noframes")&&O(Fn,i.innerHTML))return tt(i),!0;if(Q&&i.nodeType===U.text){const p=Xt(i.textContent);i.textContent!==p&&(xt(t.removed,{element:i.cloneNode()}),i.textContent=p)}return G(C.afterSanitizeElements,i,null),vt(i,l)},Ko=function(i,l,d){if(To[l]||jo(l,i)||Lo&&(l==="id"||l==="name")&&(d in e||d in wi))return!1;const p=A[l]||J.attributeCheck instanceof Function&&J.attributeCheck(l,i);return be&&O(pi,l)||Co&&O(mi,l)?!0:p?Ro[l]||O(ko,Tt(d,xo,""))||(l==="src"||l==="xlink:href"||l==="href")&&i!=="script"&&Ke(d,"data:")===0&&Do[i]||So&&!O(fi,Tt(d,xo,""))?!0:!d:Vo(i)&&Jt(W.tagNameCheck,i)&&Jt(W.attributeNameCheck,l,i)||l==="is"&&W.allowCustomizedBuiltInElements&&Jt(W.tagNameCheck,d)},Ii=E({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Vo=function(i){return!Ii[kt(i)]&&O(gi,i)},_i=function(i,l,d,p){if(F&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!d)switch(g.getAttributeType(i,l)){case"TrustedHTML":return ht(p);case"TrustedScriptURL":return ri(p)}return p},Di=function(i,l,d,p){try{return d?i.setAttributeNS(d,l,p):i.setAttribute(l,p),Zt(i)?(tt(i),!1):!0}catch(m){return st(l,i),!1}},Yo=function(i,l){if(G(C.beforeSanitizeAttributes,i,null),vt(i,l))return;const d=i.attributes;if(!d||Zt(i))return;A=qo(C.uponSanitizeAttribute,A,ge,$t);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let m=d.length;const y=M(i.nodeName);for(;m--;){const v=d[m],L=v.name,$=v.namespaceURI,B=v.value,Et=M(L),Me=B;let P=L==="value"?Me:En(Me),Xo=!1;if(p.attrName=Et,p.attrValue=P,p.keepAttr=!0,p.forceKeepAttr=void 0,G(C.uponSanitizeAttribute,i,p),P=p.attrValue,Mo&&(Et==="id"||Et==="name")&&Ke(P,Io)!==0&&(st(L,i,v),P=Io+P,Xo=!0),rt&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,P)){st(L,i,v);continue}if(Et==="attributename"&&Ge(P,"href")){st(L,i,v);continue}if(!p.forceKeepAttr){if(!p.keepAttr){st(L,i,v);continue}if(!Ao&&O(Hn,P)){st(L,i,v);continue}if(Q&&(P=Xt(P)),!Ko(y,Et,P)){st(L,i,v);continue}P=_i(y,Et,$,P),P!==Me&&Di(i,L,$,P)&&Xo&&qe(t.removed)}}G(C.afterSanitizeAttributes,i,null),vt(i,l)},Qt=function(i){let l=null;const d=Wo(i);for(G(C.beforeSanitizeShadowDOM,i,null);l=d.nextNode();)if(G(C.uponSanitizeShadowNode,l,null),Go(l,i),Yo(l,i),yt(l.content)&&Qt(l.content),At(l)===U.element){const p=yo(l);yt(p)&&(Le(p),Qt(p))}G(C.afterSanitizeShadowDOM,i,null)},Le=function(i){const l=[{node:i,shadow:null}];for(;l.length>0;){const d=l.pop();if(d.shadow){Qt(d.shadow);continue}const p=d.node,m=At(p)===U.element,y=R(p);if(y)for(let v=y.length-1;v>=0;--v)l.push({node:y[v],shadow:null});if(m){const v=ut?ut(p):null;if(typeof v=="string"&&M(v)==="template"){const L=p.content;yt(L)&&l.push({node:L,shadow:null})}}if(m){const v=yo(p);yt(v)&&l.push({node:null,shadow:v},{node:v,shadow:null})}}};return t.sanitize=function(h){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,d=null,p=null,m=null;if(xe=!h,xe&&(h="<!-->"),typeof h!="string"&&!_t(h)&&(h=Cn(h),typeof h!="string"))throw K("dirty is not a string, aborting");if(!t.isSupported)return h;ye?(S=jt,A=$t):Se(i),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(S=H(S)),C.uponSanitizeAttribute.length>0&&(A=H(A)),t.removed=[];const y=we&&typeof h!="string"&&_t(h);if(y){Ai(h);const $=he(h);if(typeof $=="string"){const B=M($);if(!S[B]||Mt[B])throw Vt(h),K("root node is forbidden and cannot be sanitized in-place")}if(Zt(h))throw Vt(h),K("root node is clobbered and cannot be sanitized in-place");try{Le(h)}catch(B){throw Vt(h),B}}else if(_t(h))l=$o("<!---->"),d=l.ownerDocument.importNode(h,!0),d.nodeType===U.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?l=d:l.appendChild(d),Le(l);else{if(!pt&&!Q&&!at&&h.indexOf("<")===-1)return F&&qt?ht(h):h;if(l=$o(h),!l)return pt?null:qt?it:""}l&&ve&&tt(l.firstChild);const v=y?h:l;try{const $=Wo(v);for(;p=$.nextNode();)Go(p,v),Yo(p,v),yt(p.content)&&Qt(p.content)}catch($){throw y&&(Vt(h),ot(t.removed,B=>{B.element&&Yt(B.element)})),$}if(y){let $=!1;if(ot(t.removed,B=>{B.element&&(B.element===h&&($=!0),Yt(B.element))}),$)throw K("a node selected for removal could not be safely returned; refusing to sanitize in place");return Q&&Ae(h),h}if(pt){if(Q&&Ae(l),Wt)for(m=si.call(l.ownerDocument);l.firstChild;)m.appendChild(l.firstChild);else m=l;return(A.shadowroot||A.shadowrootmode)&&(m=ci.call(o,m,!0)),m}let L=at?l.outerHTML:l.innerHTML;return at&&S["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&O(Nn,l.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
525
+ `+L),Q&&(L=Xt(L)),F&&qt?ht(L):L},t.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Se(h),ye=!0,jt=S,$t=A},t.clearConfig=function(){bt=null,ye=!1,jt=null,$t=null,F=pe,it=""},t.isValidAttribute=function(h,i,l){bt||Se({});const d=M(h),p=M(i);return Ko(d,p,l)},t.addHook=function(h,i){typeof i=="function"&&N(C,h)&&xt(C[h],i)},t.removeHook=function(h,i){if(N(C,h)){if(i!==void 0){const l=yn(C[h],i);return l===-1?void 0:vn(C[h],l,1)[0]}return qe(C[h])}},t.removeHooks=function(h){N(C,h)&&(C[h]=[])},t.removeAllHooks=function(){C=io()},t}var Nt=ro();const Wn=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],qn={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},Gn="data-editora-embed";function Kn(s){if(!s||/\s/.test(s.trim()))return!1;try{const t=new URL(s.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function ao(s,t,e,o){if((t==null?void 0:t.sanitize)===!1)return s;const n=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:Wn,r=e!=null&&e.length?Array.from(new Set([...n,...e])):n,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:qn,u=new Set;for(const g of Object.values(c))for(const T of g)u.add(T);const f={ALLOWED_TAGS:r,ALLOWED_ATTR:Array.from(u)};if(!o)return Nt.sanitize(s,f);Nt.addHook("uponSanitizeElement",(g,T)=>{var w;T.tagName==="iframe"&&((w=g.getAttribute)==null?void 0:w.call(g,Gn))==="true"&&Kn(g.getAttribute("src"))&&(T.allowedTags.iframe=!0)});try{return Nt.sanitize(s,f)}finally{Nt.removeHook("uponSanitizeElement")}}function so(s,t,e,o){return ao(s,t,o,!1)}function lo(s,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?s:so(s,t)}function co(s,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?s:ao(s,t,o,!0)}const Ht=class Ht{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const o=this.parseAttributes(t.attributes);Object.assign(e,o)}return t.jsConfig&&Object.assign(e,t.jsConfig),this.normalizeConfig(e)}static normalizeConfig(t){const e={...t};if(e.toolbarFloating!==void 0||e.toolbarSticky!==void 0){const a=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(a.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(a.sticky=!!e.toolbarSticky),e.toolbar=a}if(e.toolbarItems!==void 0&&typeof e.toolbar=="object"&&e.toolbar&&(e.toolbar.items=e.toolbarItems),e.autosaveEnabled!==void 0||e.autosaveIntervalMs!==void 0||e.autosaveStorageKey!==void 0||e.autosaveProvider!==void 0||e.autosaveApiUrl!==void 0){const a=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(a.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(a.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(a.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(a.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(a.apiUrl=e.autosaveApiUrl),e.autosave=a}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof e.autosave=="boolean")e.autosave={...o,enabled:e.autosave};else if(typeof e.autosave=="object"&&e.autosave){const a={...o,...e.autosave};a.intervalMs===void 0&&a.interval!==void 0&&(a.intervalMs=Number(a.interval)),a.enabled===void 0&&(a.enabled=!0),(!Number.isFinite(a.intervalMs)||a.intervalMs<=0)&&(a.intervalMs=o.intervalMs),e.autosave=a}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const a=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(a.locale=e.languageLocale),e.languageDirection!==void 0&&(a.direction=e.languageDirection),e.language=a}const n={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:n.direction}:typeof e.language=="object"&&e.language?e.language={...n,...e.language}:e.language=n,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const a=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(a.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(a.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(a.apiUrl=e.spellcheckApiUrl),e.spellcheck=a}const r={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...r,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const a={...r,...e.spellcheck};!a.provider&&a.mode&&(a.provider=a.mode==="local"?"browser":"api"),a.enabled===void 0&&(a.enabled=!!(a.mode||a.provider||a.apiUrl)),e.spellcheck=a}else e.spellcheck=r;return e.contextMenuEnabled!==void 0&&(e.contextMenu={enabled:!!e.contextMenuEnabled}),typeof e.contextMenu=="boolean"?e.contextMenu={enabled:e.contextMenu}:typeof e.contextMenu=="object"&&e.contextMenu?e.contextMenu={enabled:e.contextMenu.enabled!==!1}:e.contextMenu={enabled:!0},(e.pasteClean!==void 0||e.pasteKeepFormatting!==void 0||e.pasteConvertWord!==void 0)&&(e.paste={...e.paste||{},...e.pasteClean!==void 0?{clean:!!e.pasteClean}:{},...e.pasteKeepFormatting!==void 0?{keepFormatting:!!e.pasteKeepFormatting}:{},...e.pasteConvertWord!==void 0?{convertWord:!!e.pasteConvertWord}:{}}),e.paste={clean:!0,keepFormatting:!1,convertWord:!0,...e.paste||{}},e.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...e.contentConfig||{}},(e.securitySanitizeOnPaste!==void 0||e.securitySanitizeOnInput!==void 0)&&(e.security={...e.security||{},...e.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!e.securitySanitizeOnPaste}:{},...e.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!e.securitySanitizeOnInput}:{}}),e.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...e.security||{}},(e.accessibilityEnableAria!==void 0||e.accessibilityKeyboardNavigation!==void 0||e.accessibilityChecker!==void 0)&&(e.accessibility={...e.accessibility||{},...e.accessibilityEnableAria!==void 0?{enableARIA:!!e.accessibilityEnableAria}:{},...e.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!e.accessibilityKeyboardNavigation}:{},...e.accessibilityChecker!==void 0?{checker:!!e.accessibilityChecker}:{}}),typeof e.accessibility=="boolean"&&(e.accessibility={enableARIA:e.accessibility,keyboardNavigation:e.accessibility,checker:!1}),e.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...e.accessibility||{}},(e.performanceDebounceInputMs!==void 0||e.performanceViewportOnlyScan!==void 0)&&(e.performance={...e.performance||{},...e.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(e.performanceDebounceInputMs)}:{},...e.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!e.performanceViewportOnlyScan}:{}}),typeof e.performance=="boolean"&&(e.performance={debounceInputMs:100,viewportOnlyScan:e.performance}),e.performance={debounceInputMs:100,viewportOnlyScan:!0,...e.performance||{}},(typeof e.performance.debounceInputMs!="number"||!Number.isFinite(e.performance.debounceInputMs)||e.performance.debounceInputMs<0)&&(e.performance.debounceInputMs=100),e}static parseAttributes(t){const e={};for(const[o,n]of Object.entries(t)){const r=this.kebabToCamel(o);e[r]=this.BOOLEAN_ATTRIBUTES.has(o)&&(n===""||n===o)?!0:this.parseAttributeValue(n)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const o of t)for(const[n,r]of Object.entries(o))r!=null&&(typeof r=="object"&&!Array.isArray(r)&&e[n]?e[n]=this.merge(e[n],r):e[n]=r);return e}};Ht.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},Ht.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let zt=Ht;class uo{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const o=this.pluginRegistry.get(t);if(!o)return console.warn(`Plugin not found: ${t}`),null;const n=await o();return e&&this.applyPluginConfig(n,e),this.loadedPlugins.set(t,n),n}async loadMultiple(t,e){return(await Promise.all(t.map(n=>this.load(n,e)))).filter(n=>n!==null)}async parsePluginString(t,e){const o=t.split(/\s+/).filter(Boolean);return this.loadMultiple(o,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}class ho{constructor(t={}){this.changeListeners=[],this.options=t,this.engine=new Ot({content:t.content,plugins:t.plugins||[],readonly:t.readonly}),t.onChange&&this.onChange(t.onChange),this.engine.on("change",()=>{const e=this.getHTML();this.changeListeners.forEach(o=>o(e))})}mount(t,e){this.contentElement=t,this.toolbarElement=e,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new Rt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((o,n)=>{this.execCommand(o,n)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const o=this.getHTML();this.changeListeners.forEach(n=>n(o))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setHTML(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){const o=this.engine.execCommand(t,e);return this.toolbar,o}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}onChange(t){return this.changeListeners.push(t),()=>{const e=this.changeListeners.indexOf(t);e>-1&&this.changeListeners.splice(e,1)}}registerCommand(t,e){if(typeof window!="undefined"){const o=window.__editorCommands||new Map;o.set(t,e),window.__editorCommands=o}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var t;return{getHTML:()=>this.getHTML(),setHTML:e=>this.setHTML(e),execCommand:(e,o)=>this.execCommand(e,o),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(e,o)=>this.registerCommand(e,o),onChange:e=>this.onChange(e),getState:()=>this.getState(),toolbar:{items:((t=this.options.plugins)==null?void 0:t.flatMap(e=>e.toolbar||[]))||[]}}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function Vn(s){return new ho(s)}class po{constructor(t){this.options=t,this.containerElement=t.element;const e=this.resolvePlugins(t.plugins);this.engine=new Ot({content:t.content,plugins:e,readonly:t.readonly}),this.initializeDOM()}resolvePlugins(t){return t?typeof t=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):t:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new Rt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((t,e)=>{this.execCommand(t,e)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){return this.engine.execCommand(t,e)}focus(){var t;(t=this.contentElement)==null||t.focus()}on(t,e){const o=n=>{e(n.detail)};return this.containerElement.addEventListener(t,o),()=>{this.containerElement.removeEventListener(t,o)}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.containerElement.innerHTML=""}}const Yn='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Ft;const Xn="__editoraCommandEditorRoot",Zn="__editoraLastCommandButton",mo="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",fo=".rte-content, .editora-content",le=new Set;let Y=null,go=!1,ce=null,de=null;function bo(s){if(!(s instanceof HTMLElement))return!1;const t=s;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function Jn(s){return s?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null}function St(s){if(!s)return null;if(bo(s))return s;const t=s.matches(mo)?s:s.closest(mo);return!t||!bo(t)?null:t}function Qn(){var n;if(typeof window=="undefined")return null;const s=window[Xn];if(s instanceof HTMLElement){const r=St(s);if(r)return r;const a=s.matches(fo)?s:s.querySelector(fo);if(a){const c=St(a);if(c)return c}}const t=window[Zn];if(t instanceof HTMLElement){const r=St(t);if(r)return r}const e=document.activeElement;if(e){const r=St(e);if(r)return r}const o=(n=window.getSelection)==null?void 0:n.call(window);if(o&&o.rangeCount>0){const r=St(Jn(o.getRangeAt(0).startContainer));if(r)return r}if(Y&&Y.isConnected)return Y;for(const r of le)if(r.isConnected)return r;return null}function ti(){if(typeof window=="undefined"||go)return;ce=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,de=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const s=(t,...e)=>{const o=Qn();return o?o.execCommand(t,...e):ce?ce(t,...e):de?de(t,...e):!1};window.executeEditorCommand=s,window.execEditorCommand=s,go=!0}function ei(){const s="editora-webcomponent-styles";if(!document.getElementById(s)){const t=document.createElement("style");t.id=s,t.textContent=Yn,document.head.appendChild(t)}}function oi(){if(!Ft){const s=X.__globalPluginLoader;s?Ft=s:Ft=new uo}return Ft}class X extends HTMLElement{constructor(){if(super(),this.pluginLoader=oi(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new De,this.lastAutosavedContent="",this.loadedPlugins=[],this.lastBeforeInputType=null,ei(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(X.__globalPluginLoader){this.pluginLoader=X.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{X.__globalPluginLoader?(this.pluginLoader=X.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,o){e!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,o))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var o;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),le.add(this),Y||(Y=this),ti(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const t=await this.loadPlugins();if(this.loadedPlugins=t,t.forEach(n=>{if(n.init&&typeof n.init=="function")try{n.init({editorElement:this})}catch(r){console.error(`[RichTextEditor] Error initializing plugin ${n.name}:`,r)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const n=this.innerHTML.trim();n&&this.setAttribute("data-initial-content",n)}const e=(o=this.restoreAutosavedContent())!=null?o:this.getAttribute("data-initial-content")||"";this.engine=new Ot({content:e,plugins:t,readonly:this.config.readonly}),this.createUI(t,e),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[],e=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),n=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const r=this.config.plugins.split(/\s+/).filter(Boolean);n&&!r.includes("a11yChecker")&&r.push("a11yChecker");for(const a of r){const c=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const r of this.config.plugins)if(typeof r=="string"){const a=await this.pluginLoader.load(r,this.getPluginLoadConfig(r));a&&t.push(a)}else t.push(r);if(n&&!t.some(r=>(r==null?void 0:r.name)==="a11yChecker")){const r=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));r&&t.push(r)}}}else{const r=this.pluginLoader.getRegisteredPluginNames();for(const a of r){const c=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));c&&t.push(c)}}return t}resolveToolbarItems(){const t=this.config.toolbarItems;if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");const e=this.config.toolbar;if(typeof e=="string")return e;if(!e||typeof e!="object")return;const o=e.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.sticky}isToolbarFloatingEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.floating}isStatusbarEnabled(){const t=this.config.statusbar;return typeof t=="boolean"?t:t&&typeof t=="object"?t.enabled!==!1:!1}getStatusbarPosition(){const t=this.config.statusbar;return t&&typeof t=="object"&&t.position==="top"?"top":"bottom"}getLanguageConfig(){const t=this.config.language;return typeof t=="string"?{locale:t,direction:"ltr"}:t&&typeof t=="object"?{locale:t.locale||"en",direction:t.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const t=this.config.accessibility;return typeof t=="boolean"?{enableARIA:t,keyboardNavigation:t,checker:!1}:t&&typeof t=="object"?{enableARIA:t.enableARIA!==!1,keyboardNavigation:t.keyboardNavigation!==!1,checker:!!t.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var e;const t=this.config.performance;if(typeof t=="boolean")return{debounceInputMs:100,viewportOnlyScan:t};if(t&&typeof t=="object"){const o=Number((e=t.debounceInputMs)!=null?e:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:t.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const t=this.contentElement.getBoundingClientRect();return t.bottom>=0&&t.top<=window.innerHeight}applyAccessibilitySettings(){if(!this.contentElement)return;const t=this.getAccessibilityConfig();if(t.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const e=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";e?this.contentElement.setAttribute("aria-label",e):this.contentElement.removeAttribute("aria-label")}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=t.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const t=this.getLanguageConfig();this.contentElement.setAttribute("lang",t.locale),this.contentElement.setAttribute("dir",t.direction)}getSpellcheckConfig(){const t=this.config.spellcheck;if(typeof t=="boolean")return{enabled:t,provider:"browser"};if(t&&typeof t=="object"){const e=t.provider||"browser";return{enabled:!!t.enabled,provider:e,mode:t.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const t=this.getSpellcheckConfig(),e=t.enabled&&t.provider==="browser";this.contentElement.spellcheck=e,this.contentElement.setAttribute("spellcheck",e?"true":"false")}executeCommand(t,...e){var r;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},n=this.loadedPlugins.find(a=>a.commands&&a.commands[t]);if(n&&n.commands){const a=n.commands[t];if(typeof a=="function")try{return t==="toggleFullscreen"?a(this,o):a(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((r=this.engine)==null?void 0:r.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const r=e[t];if(r&&typeof r=="object")return r}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},n=[t,t.toLowerCase(),...o[t]||[]];for(const r of n){const a=this.config[r];if(a&&typeof a=="object"&&!Array.isArray(a))return a}}getContentSanitizeConfig(){const t=this.config.contentConfig;return t&&typeof t=="object"?t:{sanitize:!0}}getSecurityConfig(){const t=this.config.security;return t&&typeof t=="object"?t:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}getAutosaveConfig(){var e,o;const t=this.config.autosave;if(typeof t=="boolean")return{enabled:t,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(t&&typeof t=="object"){const n=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(n)&&n>0?n:3e4,storageKey:String(t.storageKey||"rte-autosave"),provider:t.provider||"localStorage",apiUrl:t.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(t){const e=this.getAutosaveConfig();if(e.enabled&&t!==this.lastAutosavedContent){if(this.lastAutosavedContent=t,e.provider==="localStorage"){try{localStorage.setItem(e.storageKey,t),localStorage.setItem(`${e.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}e.provider==="api"&&e.apiUrl&&fetch(e.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const t=this.getAutosaveConfig();if(!t.enabled||t.provider!=="localStorage")return null;try{const e=localStorage.getItem(t.storageKey);if(e)return this.lastAutosavedContent=e,e}catch(e){console.error("[RichTextEditor] Failed to restore autosaved content:",e)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const t=this.getAutosaveConfig();!t.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{var e;this.persistAutosave(((e=this.contentElement)==null?void 0:e.innerHTML)||"")},t.intervalMs))}insertHTMLAtSelection(t){if(!this.contentElement)return;const e=window.getSelection();if(e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const n=document.createElement("div");n.innerHTML=t;const r=document.createDocumentFragment();for(;n.firstChild;)r.appendChild(n.firstChild);o.insertNode(r),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,t)}createUI(t,e){const o=this.querySelector('[slot="toolbar"]'),n=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Rt({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,a)=>{var c;if(this.contentElement){this.contentElement.focus();const u=window.getSelection();if(!u||u.rangeCount===0||!this.contentElement.contains(u.anchorNode)){const f=document.createRange(),g=this.contentElement.lastChild||this.contentElement;g.nodeType===Node.TEXT_NODE?f.setStart(g,((c=g.textContent)==null?void 0:c.length)||0):g.nodeType===Node.ELEMENT_NODE?(f.selectNodeContents(g),f.collapse(!1)):f.setStart(this.contentElement,0),f.collapse(!0),u==null||u.removeAllRanges(),u==null||u.addRange(f)}}return this.executeCommand(r,a)}),this.toolbar.render(this.toolbarElement)):o&&this.appendChild(o),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(r){console.warn("defaultParagraphSeparator not supported:",r)}if(e){const r=document.createElement("div");r.innerHTML=e.trim(),!Array.from(r.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const u=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(u)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Re({enabled:!0}),this.floatingToolbar.create(this)),n?this.appendChild(n):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Pe({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var r;return(r=this.contentElement)==null?void 0:r.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const t=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{this.lastBeforeInputType=o.inputType||null}),this.contentElement.addEventListener("input",o=>{var w;if(!this.contentElement)return;let n=this.contentElement.innerHTML;const r=(w=o==null?void 0:o.detail)==null?void 0:w.allowedTags,a=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=this.lastBeforeInputType;if(this.lastBeforeInputType=null,u.sanitizeOnInput!==!1&&c.sanitize!==!1&&!f){const k=co(n,c,u,r);if(k!==n){const x=window.getSelection(),Z=x&&x.rangeCount>0?x.getRangeAt(0):null;if(this.contentElement.innerHTML=k,Z&&x)try{x.removeAllRanges(),x.addRange(Z)}catch(R){}n=k}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:n},bubbles:!0}))};a.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,a.debounceInputMs):T(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const n=this.config.contextMenu;(n===!1||typeof n=="object"&&n!==null&&n.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var g,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const n=this.config.paste||{};let r=((g=o.clipboardData)==null?void 0:g.getData("text/html"))||"";const a=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=!!r&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);if((n.clean||!n.keepFormatting)&&a){document.execCommand("insertText",!1,a);return}if(n.convertWord===!1&&f&&a){document.execCommand("insertText",!1,a);return}if(r){u.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(r=lo(r,c,u)),this.insertHTMLAtSelection(r);return}a&&document.execCommand("insertText",!1,a)}),this.contentElement.addEventListener("focus",()=>{Y=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:this.contentElement.innerHTML},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{this.getAccessibilityConfig().keyboardNavigation&&t.handleKeyDown(o,(r,a)=>{this.executeCommand(r,a)})});const e=()=>{const o=this.getSelectionRangeInEditor(),n=document.activeElement,r=!!n&&!!this.contentElement&&(n===this.contentElement||this.contentElement.contains(n));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!r||!o&&!r||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=e,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),o=e.commonAncestorContainer;return this.contentElement.contains(o)?e:null}isSelectionBackward(t){if(!t.anchorNode||!t.focusNode)return!1;try{const e=document.createRange();return e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),e.collapsed}catch(e){return!1}}getSelectionAnchorRect(t,e){const o=Array.from(e.getClientRects()).filter(r=>r.width>0||r.height>0);return o.length===0?e.getBoundingClientRect():this.isSelectionBackward(t)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const e=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const n=this.getSelectionRangeInEditor();if(!n){this.floatingToolbar.hide();return}if(n.collapsed){this.floatingToolbar.hide();return}const r=window.getSelection();if(!r){this.floatingToolbar.hide();return}const a=this.getSelectionAnchorRect(r,n);if(!a){this.floatingToolbar.hide();return}this.floatingToolbar.show(a.left,a.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.getPerformanceConfig(),e=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!e)return;const o=this.contentElement.textContent||"",{words:n,chars:r}=He(o),a=Fe(this.contentElement);let c,u;const f=this.getSelectionRangeInEditor();f&&(c=Ne(this.contentElement,f),f.collapsed||(u=Ue(f,c),c=void 0)),this.statusBar.update({wordCount:n,charCount:r,lineCount:a,cursorPosition:c,selectionInfo:u})}isReadonlyAttribute(t){return t!==null&&t!=="false"}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(e)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(e));break;case"theme":this.classList.forEach(o=>{o.startsWith("editora-theme-")&&this.classList.remove(o)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",e),this.applyAccessibilitySettings());break;case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(o=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",o)})}));break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const o=this.attributes[e];t[o.name]=o.value}return zt.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>{var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""},setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=t)},execCommand:(t,e)=>this.executeCommand(t,e),focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,o,n;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.persistAutosave(this.contentElement.innerHTML||""),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(n=this.statusBar)==null||n.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,le.delete(this),Y===this&&(Y=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,...e){return this.executeCommand(t,...e)}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}function ni(s){return new po(s)}function ii(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",X)}return b.CharacterDialog=ln,b.ColorPicker=on,b.CommandRegistry=Oe,b.ConfigResolver=zt,b.Dialog=et,b.DocumentModel=wt,b.Dropdown=en,b.Editor=Zo,b.EditorEngine=Ot,b.EditorState=lt,b.EmojiDialog=cn,b.FloatingToolbar=Re,b.ImageDialog=an,b.KeyboardShortcutManager=De,b.LinkDialog=nn,b.MathDialog=sn,b.MediaPlugin=tn,b.PluginLoader=uo,b.PluginManager=Dt,b.PluginRuntime=_e,b.ReactAdapter=ho,b.RichTextEditorElement=X,b.Schema=Ie,b.SpellcheckPlugin=Qo,b.StatusBar=Pe,b.TableDialog=rn,b.ToolbarRenderer=Rt,b.VanillaAdapter=po,b.calculateTextStats=He,b.countLines=Fe,b.createEditor=ni,b.createPluginRuntime=Jo,b.createReactAdapter=Vn,b.getCursorPosition=Ne,b.getSelectionInfo=Ue,b.getTextOffset=ze,b.initWebComponent=ii,b.sanitizeHTML=so,b.sanitizeInputHTML=co,b.sanitizePastedHTML=lo,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b})({});
524
526
  //# sourceMappingURL=editora.min.js.map