@editora/core 1.0.23 → 1.0.25

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 (67) hide show
  1. package/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
  2. package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
  3. package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
  4. package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
  5. package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
  6. package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
  7. package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
  8. package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-CRpX2G93.mjs} +167 -113
  9. package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
  10. package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
  11. package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
  12. package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
  13. package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
  14. package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-CaBqCH-p.mjs} +21 -20
  15. package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
  16. package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
  17. package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
  18. package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
  19. package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
  20. package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
  21. package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
  22. package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
  23. package/dist/MediaManagerPlugin.native-0YFHZfsb.mjs +4823 -0
  24. package/dist/MediaManagerPlugin.native-mXWWARRX.mjs +4908 -0
  25. package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
  26. package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
  27. package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
  28. package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
  29. package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
  30. package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
  31. package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
  32. package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
  33. package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
  34. package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
  35. package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
  36. package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
  37. package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
  38. package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
  39. package/dist/confirmDialog-CNqPHT5x.mjs +92 -0
  40. package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
  41. package/dist/{documentManager-BWK_-KJp.mjs → documentManager-DHLCoWzw.mjs} +1963 -1969
  42. package/dist/editora.min.js +21 -21
  43. package/dist/editora.umd.js +10 -10
  44. package/dist/index-DHPPVQwx.js +12 -0
  45. package/dist/{index-DGMYWPLx.mjs → index-gI4djib2.mjs} +407 -327
  46. package/dist/index.cjs.js +1 -1
  47. package/dist/index.esm.js +2 -2
  48. package/dist/katex-DLIObQUm.mjs +11683 -0
  49. package/dist/katex.min--Ws3c9be.mjs +6 -0
  50. package/dist/notify-DCQGpmq-.mjs +60 -0
  51. package/dist/plugin-loader.js +54 -54
  52. package/dist/shared-config-DuA34Iii.mjs +26 -0
  53. package/dist/webcomponent-core.js +315 -235
  54. package/dist/webcomponent-core.min.css +1 -1
  55. package/dist/webcomponent-core.min.js +153 -80
  56. package/dist/webcomponent.cjs.js +1 -1
  57. package/dist/webcomponent.esm.js +1 -1
  58. package/dist/webcomponent.js +672 -592
  59. package/dist/webcomponent.min.css +1 -1
  60. package/dist/webcomponent.min.js +3099 -1532
  61. package/package.json +1 -1
  62. package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
  63. package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
  64. package/dist/MediaManagerPlugin.native-BT1NZIJS.mjs +0 -998
  65. package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
  66. package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
  67. package/dist/index-C1sO7DAC.js +0 -12
@@ -1,10 +1,10 @@
1
- (function(f,W){typeof exports=="object"&&typeof module!="undefined"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(f=typeof globalThis!="undefined"?globalThis:f||self,W(f.Editora={}))})(this,(function(f){"use strict";class W{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 W(o,{anchor:0,head:0},e)}apply(e,t){return new W(e,t||this.selection,this.schema)}}class Ot{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 xe{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(n){console.error(`Failed to initialize plugin "${e.name}":`,n)}if(e.init&&e.init!==e.initialize)try{e.init(o)}catch(n){console.error(`Failed to run init hook for plugin "${e.name}":`,n)}}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 Ot(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 n=this.getPlugin(e);if(!n)throw new Error(`Plugin not found: ${e}`);const i=this.getPluginConfig(e)||n.config||{},s=i.mode||"local";try{switch(s){case"local":return n.executeLocal?n.executeLocal(t,...o):null;case"api":if(!n.executeAPI)throw new Error(`Plugin ${e} does not support API mode`);return await n.executeAPI(t,...o);case"hybrid":if(n.executeHybrid)return await n.executeHybrid(t,...o);try{if(n.executeAPI)return await n.executeAPI(t,...o)}catch(c){if(console.warn(`API execution failed for ${e}, falling back to local`,c),n.executeLocal&&i.fallbackToLocal!==!1)return n.executeLocal(t,...o);throw c}break;default:throw new Error(`Unknown plugin mode: ${s}`)}}catch(c){throw console.error(`Error executing command ${t} on plugin ${e}:`,c),c}}async destroyAll(){const e=this.plugins.filter(t=>t.destroy).map(t=>t.destroy());await Promise.all(e),this.plugins=[],this.pluginConfigs.clear()}}function tn(){return new xe}class on{constructor(e){if(this.listeners=[],e instanceof xe)this.pluginManager=e;else{const o=e;this.pluginManager=new xe,o.plugins&&Array.isArray(o.plugins)&&o.plugins.forEach(n=>{this.pluginManager.register(n)}),o.element&&(this.domElement=o.element,this.setupDOMElement(o))}const t=this.pluginManager.buildSchema();this.state=W.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 n=[];(o.ctrlKey||o.metaKey)&&n.push("ctrl"),o.shiftKey&&n.push("shift"),o.altKey&&n.push("alt");const i=o.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${i}`:i,c=t[s];c&&(o.preventDefault(),this.execCommand(c))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(i=>i.id&&i.id===e||i.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.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 n;return t!==void 0?n=o(this.state,t):n=o(this.state),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&this.setState(i)}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=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 Rt{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(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!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 n=(o=this.plugin.commands)==null?void 0:o[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" 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 nn(a){return new Rt(a)}class Pt{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),n=this.shortcuts.get(o);return n?(n.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(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(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(n=>{const i=this.getShortcutCategory(n.command);t.has(i)||t.set(i,[]),t.get(i).push(n)});let o=`# Keyboard Shortcuts
1
+ (function(b,W){typeof exports=="object"&&typeof module!="undefined"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(b=typeof globalThis!="undefined"?globalThis:b||self,W(b.Editora={}))})(this,(function(b){"use strict";class W{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 W(o,{anchor:0,head:0},e)}apply(e,t){return new W(e,t||this.selection,this.schema)}}class Ot{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 xe{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(n){console.error(`Failed to initialize plugin "${e.name}":`,n)}if(e.init&&e.init!==e.initialize)try{e.init(o)}catch(n){console.error(`Failed to run init hook for plugin "${e.name}":`,n)}}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 Ot(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 n=this.getPlugin(e);if(!n)throw new Error(`Plugin not found: ${e}`);const i=this.getPluginConfig(e)||n.config||{},s=i.mode||"local";try{switch(s){case"local":return n.executeLocal?n.executeLocal(t,...o):null;case"api":if(!n.executeAPI)throw new Error(`Plugin ${e} does not support API mode`);return await n.executeAPI(t,...o);case"hybrid":if(n.executeHybrid)return await n.executeHybrid(t,...o);try{if(n.executeAPI)return await n.executeAPI(t,...o)}catch(c){if(console.warn(`API execution failed for ${e}, falling back to local`,c),n.executeLocal&&i.fallbackToLocal!==!1)return n.executeLocal(t,...o);throw c}break;default:throw new Error(`Unknown plugin mode: ${s}`)}}catch(c){throw console.error(`Error executing command ${t} on plugin ${e}:`,c),c}}async destroyAll(){const e=this.plugins.filter(t=>t.destroy).map(t=>t.destroy());await Promise.all(e),this.plugins=[],this.pluginConfigs.clear()}}function tn(){return new xe}class on{constructor(e){if(this.listeners=[],e instanceof xe)this.pluginManager=e;else{const o=e;this.pluginManager=new xe,o.plugins&&Array.isArray(o.plugins)&&o.plugins.forEach(n=>{this.pluginManager.register(n)}),o.element&&(this.domElement=o.element,this.setupDOMElement(o))}const t=this.pluginManager.buildSchema();this.state=W.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 n=[];(o.ctrlKey||o.metaKey)&&n.push("ctrl"),o.shiftKey&&n.push("shift"),o.altKey&&n.push("alt");const i=o.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${i}`:i,c=t[s];c&&(o.preventDefault(),this.execCommand(c))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(i=>i.id&&i.id===e||i.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.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 n;return t!==void 0?n=o(this.state,t):n=o(this.state),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&this.setState(i)}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=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 Rt{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(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!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 n=(o=this.plugin.commands)==null?void 0:o[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" 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 nn(a){return new Rt(a)}class Pt{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),n=this.shortcuts.get(o);return n?(n.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(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(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(n=>{const i=this.getShortcutCategory(n.command);t.has(i)||t.set(i,[]),t.get(i).push(n)});let o=`# Keyboard Shortcuts
2
2
 
3
3
  `;return t.forEach((n,i)=>{o+=`## ${i}
4
4
 
5
5
  `,n.forEach(s=>{const c=this.getShortcutDescription(s);o+=`- **${c}**: ${s.description||s.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"}}const Nt=new Set;function zt(a,e){Nt.has(a)||(Nt.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`))}function rn(a={}){zt("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:e=!1,provider:t="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:i}),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:g=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:g=>(console.log("[Spellcheck] Add to dictionary:",g),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){zt("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:e="",libraryUrl:t="",maxFileSize:o=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1024*1024,enableChunking:u=!0,onProgress:g,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:o,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Ft{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 Re{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new xe,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(o=>this.pluginManager.register(o));const t=this.pluginManager.buildSchema();this.state=W.create(t),this.commandRegistry=new Ft(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 n;return t.length===0?n=o(this.state):t.length===1?n=o(this.state,t[0]):n=o(this.state,...t),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!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(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 n=o.indexOf(t);n>-1&&o.splice(n,1)}}}emit(e,...t){const o=this.listeners.get(e);o&&o.forEach(n=>{try{n(...t)}catch(i){console.error(`Error in ${e} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class ke{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new ke(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new ke(this.doc,e)}update(e,t){return new ke(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pe{constructor(e,t,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=o}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)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],o=e.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={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(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&t.push(u)}),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=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const g=c.lastElementChild;g instanceof HTMLElement&&(this.overflowUnits.push(g),this.overflowUnitHomes.set(g,c))}),t.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",t.appendChild(u)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){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,e.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,e.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{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=e.clientWidth,g=16,b=40,T=4,v=Math.max(0,u-g-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const J=k<c.length;o.style.display=J?"":"none",o.classList.toggle("active",J&&this.expandedOpen),!J&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,o;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(o=this.moreButton)==null||o.classList.toggle("active",e)}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 n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,e.items.forEach(i=>{this.appendToolbarButton(n,i)}),t.appendChild(n)}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.setAttribute("aria-label",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 n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.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",g=>{g.preventDefault(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),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 c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=e.icon,o.appendChild(c)}else o.innerHTML=e.icon;else o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.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",g=>{g.preventDefault(),g.stopPropagation(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var g;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=(g=this.container)==null?void 0:g.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),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(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.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 Ht{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 Ut{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 i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.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(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),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 oe{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,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(""):`
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"}}const Nt=new Set;function zt(a,e){Nt.has(a)||(Nt.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`))}function rn(a={}){zt("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:e=!1,provider:t="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:d=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:i}),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:m=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:m=>(console.log("[Spellcheck] Add to dictionary:",m),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){zt("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:e="",libraryUrl:t="",maxFileSize:o=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1024*1024,enableChunking:d=!0,onProgress:m,onError:f,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:o,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:y=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async y=>{if(console.log("[Media] Insert image command (not implemented)",y),!y)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(y.type)){const E=new Error(`File type ${y.type} not allowed`);return f==null||f(E),null}if(y.size>o){const E=new Error(`File size ${y.size} exceeds max ${o}`);return f==null||f(E),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async y=>(console.log("[Media] Upload media (not implemented)",{name:y.name,size:y.size,type:y.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Ft{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 Re{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new xe,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(o=>this.pluginManager.register(o));const t=this.pluginManager.buildSchema();this.state=W.create(t),this.commandRegistry=new Ft(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 n;return t.length===0?n=o(this.state):t.length===1?n=o(this.state,t[0]):n=o(this.state,...t),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!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(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 n=o.indexOf(t);n>-1&&o.splice(n,1)}}}emit(e,...t){const o=this.listeners.get(e);o&&o.forEach(n=>{try{n(...t)}catch(i){console.error(`Error in ${e} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class ke{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new ke(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new ke(this.doc,e)}update(e,t){return new ke(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pe{constructor(e,t,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=o}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)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],o=e.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={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",insertAudio:"insertAudio",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const d=[];c.split(/\s+/).filter(Boolean).forEach(f=>{if(f==="direction"){const E=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");E&&d.push({id:"directionLTR",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options}),k&&d.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(f==="comments"){const E=i.get("addComment"),k=i.get("toggleComments");E&&d.push({id:"addComment",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options}),k&&d.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[f]||f;let y=i.get(T);y||(y=i.get(f)),y&&d.push({id:f,label:y.label,command:y.command,icon:y.icon,type:y.type==="separator"?"separator":y.type||"button",options:y.options,items:y.items})}),d.length>0&&t.push(d)}),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=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(d=>{this.appendToolbarButton(c,d);const m=c.lastElementChild;m instanceof HTMLElement&&(this.overflowUnits.push(m),this.overflowUnitHomes.set(m,c))}),t.appendChild(c),s<n.length-1){const d=document.createElement("div");d.className="editora-toolbar-separator",t.appendChild(d)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){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,e.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,e.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{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 d=e.clientWidth,m=16,f=40,T=4,y=Math.max(0,d-m-f-T);let E=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(E+z<=y)E+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const J=k<c.length;o.style.display=J?"":"none",o.classList.toggle("active",J&&this.expandedOpen),!J&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,o;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(o=this.moreButton)==null||o.classList.toggle("active",e)}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 n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,e.items.forEach(i=>{this.appendToolbarButton(n,i)}),t.appendChild(n)}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.setAttribute("aria-label",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}makeMenuAccessible(e,t,o,n){t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-label",n),o.querySelectorAll(".editora-toolbar-dropdown-item").forEach(m=>{m.setAttribute("role","menuitem"),m.tabIndex=-1});const i=()=>Array.from(o.querySelectorAll('[role="menuitem"]')),s=()=>o.style.display==="block",c=new MutationObserver(()=>{t.setAttribute("aria-expanded",s()?"true":"false")});c.observe(o,{attributes:!0,attributeFilter:["style"]});const d=e._cleanupDropdown;e._cleanupDropdown=()=>{c.disconnect(),d==null||d()},t.addEventListener("click",m=>{var f;m.detail===0&&s()&&((f=i()[0])==null||f.focus())}),t.addEventListener("keydown",m=>{var T;if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;m.preventDefault(),s()||t.click();const f=i();(T=m.key==="ArrowUp"?f[f.length-1]:f[0])==null||T.focus()}),o.addEventListener("keydown",m=>{const f=i();if(f.length===0)return;const T=f.indexOf(document.activeElement),y=E=>{m.preventDefault(),f[(E+f.length)%f.length].focus()};switch(m.key){case"ArrowDown":return y(T+1);case"ArrowUp":return y(T<0?f.length-1:T-1);case"Home":return y(0);case"End":return y(f.length-1);case"Escape":m.preventDefault(),m.stopPropagation(),o.style.display="none",t.focus();return;case"Tab":o.style.display="none";return}})}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 n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const d=document.createElement("button");d.className="editora-toolbar-dropdown-item",d.type="button",d.textContent=c.label,d.setAttribute("data-value",c.value),d.addEventListener("click",m=>{m.preventDefault(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(d)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const d=n.style.display==="block";n.style.display=d?"none":"block"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),this.makeMenuAccessible(t,o,n,e.label),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 c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=e.icon,o.appendChild(c)}else o.innerHTML=e.icon;else o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const d=document.createElement("button");d.className="editora-toolbar-dropdown-item",d.type="button",d.textContent=c.label,d.setAttribute("data-value",c.value),d.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(d)}),o.addEventListener("click",c=>{var m;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const d=(m=this.container)==null?void 0:m.querySelectorAll(".editora-toolbar-dropdown-menu");d==null||d.forEach(f=>{f!==n&&(f.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),this.makeMenuAccessible(t,o,n,e.label),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(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.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 Ht{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 Ut{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 i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.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(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<o.length-1){const d=document.createElement("span");d.className="editora-statusbar-separator",d.textContent="|",e.appendChild(d)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<n.length-1){const d=document.createElement("span");d.className="editora-statusbar-separator",d.textContent="|",t.appendChild(d)}}),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 oe{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,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
10
  `;if(e.innerHTML=`
@@ -20,7 +20,7 @@
20
20
  ${t}
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 s,c;const n=Number(o.getAttribute("data-dialog-button")),i=(s=this.config.buttons)==null?void 0:s[n];(c=i==null?void 0:i.onClick)==null||c.call(i)})});else{const t=this.element.querySelector('[data-dialog-default="cancel"]');t==null||t.addEventListener("click",()=>{var n,i;(i=(n=this.config).onCancel)==null||i.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",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,n,i;const e=this.element.querySelector("form");if(e){const s=new FormData(e);(o=(t=this.config).onSubmit)==null||o.call(t,s)}else{const s=this.element.querySelectorAll("input, select, textarea"),c=new FormData;s.forEach(u=>{u.name&&c.append(u.name,u.value)}),(i=(n=this.config).onSubmit)==null||i.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 sn{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(n=>n.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=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 s,c;const n=Number(o.getAttribute("data-dialog-button")),i=(s=this.config.buttons)==null?void 0:s[n];(c=i==null?void 0:i.onClick)==null||c.call(i)})});else{const t=this.element.querySelector('[data-dialog-default="cancel"]');t==null||t.addEventListener("click",()=>{var n,i;(i=(n=this.config).onCancel)==null||i.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",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,n,i;const e=this.element.querySelector("form");if(e){const s=new FormData(e);(o=(t=this.config).onSubmit)==null||o.call(t,s)}else{const s=this.element.querySelectorAll("input, select, textarea"),c=new FormData;s.forEach(d=>{d.name&&c.append(d.name,d.value)}),(i=(n=this.config).onSubmit)==null||i.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 sn{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(n=>n.value===this.selectedValue),o=(t==null?void 0:t.label)||this.config.placeholder||"Select...";return e.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>
@@ -48,7 +48,7 @@
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",n=>{var s,c;const i=n.target.value;t.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i)}),t.addEventListener("input",n=>{var s,c;const i=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(i)&&(e.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var s,c;const i=n.getAttribute("data-color");i&&(e.value=i,t.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i))})})}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 cn{constructor(e){const{initialUrl:t="",initialText:o="",onSubmit:n,onCancel:i}=e;this.dialog=new oe({title:"Insert/Edit Link",content:this.createFormHTML(t,o),onSubmit:s=>{const c=(s.get("url")||"").trim(),u=(s.get("text")||"").trim(),g=s.get("openInNewTab")==="on";if(!c){alert("Please enter a URL");return}n({url:c,text:u,openInNewTab:g}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(e,t){return`
51
+ `,e}attachEventListeners(){const e=this.element.querySelector('input[type="color"]'),t=this.element.querySelector('input[type="text"]');e.addEventListener("input",n=>{var s,c;const i=n.target.value;t.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i)}),t.addEventListener("input",n=>{var s,c;const i=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(i)&&(e.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var s,c;const i=n.getAttribute("data-color");i&&(e.value=i,t.value=i,this.selectedColor=i,(c=(s=this.config).onChange)==null||c.call(s,i))})})}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 cn{constructor(e){const{initialUrl:t="",initialText:o="",onSubmit:n,onCancel:i}=e;this.dialog=new oe({title:"Insert/Edit Link",content:this.createFormHTML(t,o),onSubmit:s=>{const c=(s.get("url")||"").trim(),d=(s.get("text")||"").trim(),m=s.get("openInNewTab")==="on";if(!c){alert("Please enter a URL");return}n({url:c,text:d,openInNewTab:m}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(e,t){return`
52
52
  <form class="link-dialog-form">
53
53
  <div class="form-group">
54
54
  <label for="link-url">URL</label>
@@ -155,7 +155,7 @@
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"),n=e.querySelector("#table-header"),i=e.querySelector("#table-preview-content"),s=()=>{const c=parseInt((t==null?void 0:t.value)||"3",10),u=parseInt((o==null?void 0:o.value)||"3",10),g=n==null?void 0:n.checked;i&&(i.textContent=`${c} rows × ${u} columns${g?" with header":""}`)};t==null||t.addEventListener("input",s),o==null||o.addEventListener("input",s),n==null||n.addEventListener("change",s)}}class un{constructor(e){this.config=e;const{onSubmit:t,onCancel:o}=e;this.dialog=new oe({title:"Insert Image",content:this.createFormHTML(),onSubmit:n=>{const i=(n.get("src")||"").trim(),s=(n.get("alt")||"").trim(),c=(n.get("width")||"").trim(),u=(n.get("height")||"").trim();if(!i){alert("Please enter an image URL or upload an image");return}t({src:i,alt:s,width:c||void 0,height:u||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 e=document.querySelector(".table-dialog-form");if(!e)return;const t=e.querySelector("#table-rows"),o=e.querySelector("#table-cols"),n=e.querySelector("#table-header"),i=e.querySelector("#table-preview-content"),s=()=>{const c=parseInt((t==null?void 0:t.value)||"3",10),d=parseInt((o==null?void 0:o.value)||"3",10),m=n==null?void 0:n.checked;i&&(i.textContent=`${c} rows × ${d} columns${m?" with header":""}`)};t==null||t.addEventListener("input",s),o==null||o.addEventListener("input",s),n==null||n.addEventListener("change",s)}}class un{constructor(e){this.config=e;const{onSubmit:t,onCancel:o}=e;this.dialog=new oe({title:"Insert Image",content:this.createFormHTML(),onSubmit:n=>{const i=(n.get("src")||"").trim(),s=(n.get("alt")||"").trim(),c=(n.get("width")||"").trim(),d=(n.get("height")||"").trim();if(!i){alert("Please enter an image URL or upload an image");return}t({src:i,alt:s,width:c||void 0,height:d||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 @@
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"),n=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const i=t.value.trim();i&&this.isValidImageUrl(i)?(n.src=i,o.style.display="block",n.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 n=>{var c;const i=(c=n.target.files)==null?void 0:c[0];if(!i)return;const s=new FileReader;s.onload=u=>{var b;const g=(b=u.target)==null?void 0:b.result;o.value=g,o.dispatchEvent(new Event("input"))},s.readAsDataURL(i)})}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 hn{constructor(e){this.onSubmit=e.onSubmit;const t=this.createContent();this.dialog=new oe({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 e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-src"),o=e.querySelector("#image-preview"),n=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const i=t.value.trim();i&&this.isValidImageUrl(i)?(n.src=i,o.style.display="block",n.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 n=>{var c;const i=(c=n.target.files)==null?void 0:c[0];if(!i)return;const s=new FileReader;s.onload=d=>{var f;const m=(f=d.target)==null?void 0:f.result;o.value=m,o.dispatchEvent(new Event("input"))},s.readAsDataURL(i)})}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 hn{constructor(e){this.onSubmit=e.onSubmit;const t=this.createContent();this.dialog=new oe({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=`
233
233
  <style>
234
234
  .math-dialog-content {
235
235
  display: flex;
@@ -341,7 +341,7 @@
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",n=>{n.preventDefault();const i=o.getAttribute("data-symbol");if(i&&this.latexInput){const s=this.latexInput.selectionStart,c=this.latexInput.selectionEnd,u=this.latexInput.value;this.latexInput.value=u.substring(0,s)+i+u.substring(c),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=s+i.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}const 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 pn{constructor(e){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new oe({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
+ `,e.querySelectorAll(".math-symbol-btn").forEach(o=>{o.addEventListener("click",n=>{n.preventDefault();const i=o.getAttribute("data-symbol");if(i&&this.latexInput){const s=this.latexInput.selectionStart,c=this.latexInput.selectionEnd,d=this.latexInput.value;this.latexInput.value=d.substring(0,s)+i+d.substring(c),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=s+i.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}const 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 pn{constructor(e){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new oe({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=`
345
345
  <style>
346
346
  .character-dialog-content {
347
347
  display: flex;
@@ -520,7 +520,7 @@
520
520
  </div>
521
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 n=document.createElement("button");n.className="emoji-button",n.textContent=o,n.title=`Insert ${o}`,n.addEventListener("click",i=>{i.preventDefault(),this.handleSelect(o)}),this.emojisGrid.appendChild(n)})}filterEmojis(){const e=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(o=>{const n=o.textContent||"",i=!e||n.includes(e);o.style.display=i?"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 Bt(a,e){const t=a.textContent||"",o=jt(a,e.startContainer,e.startOffset),i=t.substring(0,o).split(`
522
522
  `),s=i.length,c=i[i.length-1].length+1;return{line:s,column:c}}function jt(a,e,t){var s;let o=0;const n=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let i=n.firstChild();for(;i;){if(i===e){o+=t;break}else i.nodeType===Node.TEXT_NODE&&(o+=((s=i.textContent)==null?void 0:s.length)||0);i=n.nextNode()}return o}function $t(a){var o,n;const e=a.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let t=1;if(e.length>0){t=e.length;const i=e[e.length-1];(i.tagName==="BR"||((o=i.innerHTML)==null?void 0:o.trim())===""||((n=i.textContent)==null?void 0:n.trim())==="")&&t++}else{const s=(a.textContent||"").split(`
523
- `).length;t=Math.max(1,s)}return t}function Wt(a){const e=a.trim()?a.trim().split(/\s+/).length:0,t=a.length;return{words:e,chars:t}}function qt(a,e){const t=a.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}}function Gt(a,e){(e==null||e>a.length)&&(e=a.length);for(var t=0,o=Array(e);t<e;t++)o[t]=a[t];return o}function fn(a){if(Array.isArray(a))return a}function gn(a,e){var t=a==null?null:typeof Symbol!="undefined"&&a[Symbol.iterator]||a["@@iterator"];if(t!=null){var o,n,i,s,c=[],u=!0,g=!1;try{if(i=(t=t.call(a)).next,e!==0)for(;!(u=(o=i.call(t)).done)&&(c.push(o.value),c.length!==e);u=!0);}catch(b){g=!0,n=b}finally{try{if(!u&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(g)throw n}}return c}}function bn(){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 yn(a,e){return fn(a)||gn(a,e)||vn(a,e)||bn()}function vn(a,e){if(a){if(typeof a=="string")return Gt(a,e);var t={}.toString.call(a).slice(8,-1);return t==="Object"&&a.constructor&&(t=a.constructor.name),t==="Map"||t==="Set"?Array.from(a):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Gt(a,e):void 0}}const Kt=Object.entries,Vt=Object.setPrototypeOf,En=Object.isFrozen,wn=Object.getPrototypeOf,xn=Object.getOwnPropertyDescriptor;let _=Object.freeze,D=Object.seal,ce=Object.create,Yt=typeof Reflect!="undefined"&&Reflect,tt=Yt.apply,ot=Yt.construct;_||(_=function(e){return e}),D||(D=function(e){return e}),tt||(tt=function(e,t){for(var o=arguments.length,n=new Array(o>2?o-2:0),i=2;i<o;i++)n[i-2]=arguments[i];return e.apply(t,n)}),ot||(ot=function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return new e(...o)});const ne=I(Array.prototype.forEach),kn=I(Array.prototype.lastIndexOf),Xt=I(Array.prototype.pop),Te=I(Array.prototype.push),Tn=I(Array.prototype.splice),de=Array.isArray,Ce=I(String.prototype.toLowerCase),nt=I(String.prototype.toString),Zt=I(String.prototype.match),Se=I(String.prototype.replace),Jt=I(String.prototype.indexOf),Cn=I(String.prototype.trim),Sn=I(Number.prototype.toString),An=I(Boolean.prototype.toString),Qt=typeof BigInt=="undefined"?null:I(BigInt.prototype.toString),eo=typeof Symbol=="undefined"?null:I(Symbol.prototype.toString),N=I(Object.prototype.hasOwnProperty),Ae=I(Object.prototype.toString),O=I(RegExp.prototype.test),V=Ln(TypeError);function I(a){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return tt(a,e,o)}}function Ln(a){return function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return ot(a,t)}}function w(a,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ce;if(Vt&&Vt(a,null),!de(e))return a;let o=e.length;for(;o--;){let n=e[o];if(typeof n=="string"){const i=t(n);i!==n&&(En(e)||(e[o]=i),n=i)}a[n]=!0}return a}function Mn(a){for(let e=0;e<a.length;e++)N(a,e)||(a[e]=null);return a}function H(a){const e=ce(null);for(const o of Kt(a)){var t=yn(o,2);const n=t[0],i=t[1];N(a,n)&&(de(i)?e[n]=Mn(i):i&&typeof i=="object"&&i.constructor===Object?e[n]=H(i):e[n]=i)}return e}function In(a){switch(typeof a){case"string":return a;case"number":return Sn(a);case"boolean":return An(a);case"bigint":return Qt?Qt(a):"0";case"symbol":return eo?eo(a):"Symbol()";case"undefined":return Ae(a);case"function":case"object":{if(a===null)return Ae(a);const e=a,t=j(e,"toString");if(typeof t=="function"){const o=t(e);return typeof o=="string"?o:Ae(o)}return Ae(a)}default:return Ae(a)}}function j(a,e){for(;a!==null;){const o=xn(a,e);if(o){if(o.get)return I(o.get);if(typeof o.value=="function")return I(o.value)}a=wn(a)}function t(){return null}return t}function _n(a){try{return O(a,""),!0}catch(e){return!1}}const to=_(["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"]),it=_(["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"]),rt=_(["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"]),Dn=_(["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"]),at=_(["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"]),On=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),oo=_(["#text"]),no=_(["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"]),st=_(["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"]),io=_(["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"]),Ne=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Rn=D(/{{[\w\W]*|^[\w\W]*}}/g),Pn=D(/<%[\w\W]*|^[\w\W]*%>/g),Nn=D(/\${[\w\W]*/g),zn=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fn=D(/^aria-[\-\w]+$/),ro=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Hn=D(/^(?:\w+script|data):/i),Un=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Bn=D(/^html$/i),jn=D(/^[a-z][.\w]*(-[.\w]+)+$/i),ao=D(/<[/\w!]/g),so=D(/<[/\w]/g),$n=D(/<\/no(script|embed|frames)/i),Wn=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},lo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],qn=_(w({},lo)),Gn=(function(){const a={};return ne(lo,e=>{a[e]=D(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),_(a)})(),Kn=function(){return typeof window=="undefined"?null:window},Vn=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const i="dompurify"+(o?"#"+o:"");try{return e.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}},co=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Y=function(e,t,o,n){return N(e,t)&&de(e[t])?w(n.base?H(n.base):{},e[t],n.transform):o},lt=function(e,t,o){const n=N(e,t)?e[t]:void 0;return n&&typeof n=="object"?H(n):o()};function uo(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Kn();const e=h=>uo(h);if(e.version="3.4.16",e.removed=[],!a||!a.document||a.document.nodeType!==U.document||!a.Element)return e.isSupported=!1,e;let t=a.document;const o=t,n=o.currentScript;a.DocumentFragment;const i=a.HTMLTemplateElement,s=a.Node,c=a.Element,u=a.NodeFilter;a.NamedNodeMap===void 0&&(a.NamedNodeMap||a.MozNamedAttrMap),a.HTMLFormElement;const g=a.DOMParser,b=a.trustedTypes,T=c.prototype,v=j(T,"cloneNode"),x=j(T,"remove"),k=j(T,"removeAttributeNode"),J=j(T,"nextSibling"),R=j(T,"childNodes"),z=j(T,"parentNode"),xo=j(T,"shadowRoot"),mt=j(T,"attributes"),ie=s&&s.prototype?j(s.prototype,"nodeType"):null,he=s&&s.prototype?j(s.prototype,"nodeName"):null,Be=s&&s.prototype?j(s.prototype,"ownerDocument"):null,Me=function(r){return ie?ie(r):r.nodeType},ft=function(r){return he?he(r):r.nodeName};if(typeof i=="function"){const h=t.createElement("template");h.content&&h.content.ownerDocument&&(t=h.content.ownerDocument)}let F,re="",gt,ko=!1,Ie=0;const To=function(){if(Ie>0)throw V('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.')},pe=function(r){To(),Ie++;try{return F.createHTML(r)}finally{Ie--}},pi=function(r){To(),Ie++;try{return F.createScriptURL(r)}finally{Ie--}},mi=function(){return ko||(gt=Vn(b,n),ko=!0),gt},je=t,bt=je.implementation,Co=je.createNodeIterator,fi=je.createDocumentFragment,gi=je.getElementsByTagName,bi=o.importNode;let C=co();e.isSupported=typeof Kt=="function"&&typeof z=="function"&&bt&&bt.createHTMLDocument!==void 0;const yi=Rn,vi=Pn,Ei=Nn,wi=zn,xi=Fn,ki=Hn,So=Un,Ti=jn;let Ao=ro,S=null;const yt=w({},[...to,...it,...rt,...at,...oo]);let A=null;const vt=w({},[...no,...st,...io,...Ne]);let q=Object.seal(ce(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}})),_e=null,Lo=null;const Q=Object.seal(ce(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mo=!0,Et=!0,Io=!1,_o=!0,ee=!1,ae=!0,se=!1,wt=!1,$e=null,We=null,xt=!1,me=!1,qe=!1,Ge=!1,Do=!0,Oo=!1;const Ro="user-content-";let kt=!0,Tt=!1,fe={},ge=null;const Po=w({},["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 No=null;const zo=w({},["audio","video","img","source","image","track"]);let Fo=null;const Ho=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml";let be=G,Ct=!1,St=null;const Ci=w({},[Ke,Ve,G],nt),Uo=_(["mi","mo","mn","ms","mtext"]);let At=w({},Uo);const Bo=_(["annotation-xml"]);let Lt=w({},Bo);const Si=w({},["title","style","font","a","script"]);let De=null;const Ai=["application/xhtml+xml","text/html"],Li="text/html";let M=null,ye=null;const Mi=t.createElement("form"),jo=function(r){return r instanceof RegExp||r instanceof Function},Mt=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ye&&ye===r)return;(!r||typeof r!="object")&&(r={}),r=H(r),De=Ai.indexOf(r.PARSER_MEDIA_TYPE)===-1?Li:r.PARSER_MEDIA_TYPE,M=De==="application/xhtml+xml"?nt:Ce,S=Y(r,"ALLOWED_TAGS",yt,{transform:M}),A=Y(r,"ALLOWED_ATTR",vt,{transform:M}),St=Y(r,"ALLOWED_NAMESPACES",Ci,{transform:nt}),Fo=Y(r,"ADD_URI_SAFE_ATTR",Ho,{transform:M,base:Ho}),No=Y(r,"ADD_DATA_URI_TAGS",zo,{transform:M,base:zo}),ge=Y(r,"FORBID_CONTENTS",Po,{transform:M}),_e=Y(r,"FORBID_TAGS",H({}),{transform:M}),Lo=Y(r,"FORBID_ATTR",H({}),{transform:M}),fe=N(r,"USE_PROFILES")?r.USE_PROFILES&&typeof r.USE_PROFILES=="object"?H(r.USE_PROFILES):r.USE_PROFILES:!1,Mo=r.ALLOW_ARIA_ATTR!==!1,Et=r.ALLOW_DATA_ATTR!==!1,Io=r.ALLOW_UNKNOWN_PROTOCOLS||!1,_o=r.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ee=r.SAFE_FOR_TEMPLATES||!1,ae=r.SAFE_FOR_XML!==!1,se=r.WHOLE_DOCUMENT||!1,me=r.RETURN_DOM||!1,qe=r.RETURN_DOM_FRAGMENT||!1,Ge=r.RETURN_TRUSTED_TYPE||!1,xt=r.FORCE_BODY||!1,Do=r.SANITIZE_DOM!==!1,Oo=r.SANITIZE_NAMED_PROPS||!1,kt=r.KEEP_CONTENT!==!1,Tt=r.IN_PLACE||!1,Ao=_n(r.ALLOWED_URI_REGEXP)?r.ALLOWED_URI_REGEXP:ro,be=typeof r.NAMESPACE=="string"?r.NAMESPACE:G,At=lt(r,"MATHML_TEXT_INTEGRATION_POINTS",()=>w({},Uo)),Lt=lt(r,"HTML_INTEGRATION_POINTS",()=>w({},Bo));const l=lt(r,"CUSTOM_ELEMENT_HANDLING",()=>ce(null));if(q=ce(null),N(l,"tagNameCheck")&&jo(l.tagNameCheck)&&(q.tagNameCheck=l.tagNameCheck),N(l,"attributeNameCheck")&&jo(l.attributeNameCheck)&&(q.attributeNameCheck=l.attributeNameCheck),N(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),D(q),ee&&(Et=!1),qe&&(me=!0),fe&&(S=w({},oo),A=ce(null),fe.html===!0&&(w(S,to),w(A,no)),fe.svg===!0&&(w(S,it),w(A,st),w(A,Ne)),fe.svgFilters===!0&&(w(S,rt),w(A,st),w(A,Ne)),fe.mathMl===!0&&(w(S,at),w(A,io),w(A,Ne))),Q.tagCheck=null,Q.attributeCheck=null,N(r,"ADD_TAGS")&&(typeof r.ADD_TAGS=="function"?Q.tagCheck=r.ADD_TAGS:de(r.ADD_TAGS)&&(S===yt&&(S=H(S)),w(S,r.ADD_TAGS,M))),N(r,"ADD_ATTR")&&(typeof r.ADD_ATTR=="function"?Q.attributeCheck=r.ADD_ATTR:de(r.ADD_ATTR)&&(A===vt&&(A=H(A)),w(A,r.ADD_ATTR,M))),N(r,"ADD_FORBID_CONTENTS")&&de(r.ADD_FORBID_CONTENTS)&&(ge===Po&&(ge=H(ge)),w(ge,r.ADD_FORBID_CONTENTS,M)),kt&&(S["#text"]=!0),se&&w(S,["html","head","body"]),S.table&&(w(S,["tbody"]),delete _e.tbody),r.TRUSTED_TYPES_POLICY){if(typeof r.TRUSTED_TYPES_POLICY.createHTML!="function")throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof r.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=F;F=r.TRUSTED_TYPES_POLICY;try{re=pe("")}catch(p){throw F=d,p}}else r.TRUSTED_TYPES_POLICY===null?(F=void 0,re=""):(F===void 0&&(F=mi()),F&&typeof re=="string"&&(re=pe("")));_&&_(r),ye=r},$o=w({},[...it,...rt,...Dn]),Wo=w({},[...at,...On]),Ii=function(r,l,d){return l.namespaceURI===G?r==="svg":l.namespaceURI===Ke?r==="svg"&&(d==="annotation-xml"||At[d]):!!$o[r]},_i=function(r,l,d){return l.namespaceURI===G?r==="math":l.namespaceURI===Ve?r==="math"&&Lt[d]:!!Wo[r]},Di=function(r,l,d){return l.namespaceURI===Ve&&!Lt[d]||l.namespaceURI===Ke&&!At[d]?!1:!Wo[r]&&(Si[r]||!$o[r])},Oi=function(r){let l=z(r);(!l||!l.tagName)&&(l={namespaceURI:be,tagName:"template"});const d=Ce(r.tagName),p=Ce(l.tagName);return St[r.namespaceURI]?r.namespaceURI===Ve?Ii(d,l,p):r.namespaceURI===Ke?_i(d,l,p):r.namespaceURI===G?Di(d,l,p):!!(De==="application/xhtml+xml"&&St[r.namespaceURI]):!1},te=function(r){Te(e.removed,{element:r});try{z(r).removeChild(r)}catch(l){if(x(r),!z(r))throw V("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},qo=function(r,l,d){try{k(r,l)}catch(p){try{r.removeAttribute(d)}catch(m){}}},Ye=function(r){Xe(r);const l=R(r);if(l){const p=[];ne(l,m=>{Te(p,m)}),ne(p,m=>{try{x(m)}catch(y){}})}const d=mt(r);if(d)for(let p=d.length-1;p>=0;--p){const m=d[p],y=m&&m.name;typeof y=="string"&&qo(r,m,y)}},le=function(r,l,d){if(!d)try{d=l.getAttributeNode(r)}catch(p){d=null}Te(e.removed,{attribute:d||null,from:l});try{d?k(l,d):l.removeAttribute(r)}catch(p){try{l.removeAttribute(r)}catch(m){}}if(r==="is")if(me||qe)try{te(l)}catch(p){}else try{l.setAttribute(r,"")}catch(p){}},Ri=function(r){const l=mt(r);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)]||qo(r,p,m)}},Xe=function(r){const l=[r];for(;l.length>0;){const d=l.pop();Me(d)===U.element&&Ri(d);const p=R(d);if(p)for(let m=p.length-1;m>=0;--m)l.push(p[m])}},Go=function(r,l){return ae?r==="patchsrc"?!0:r==="for"&&l!=="label"&&l!=="output":!1},Pi=function(r){if(!ae)return;const l=[r];for(;l.length>0;){const d=l.pop(),p=Me(d);if(p===U.processingInstruction||p===U.comment&&O(so,d.data)){try{x(d)}catch(y){}continue}if(p===U.element){const y=d,E=M(ft(d));try{y.hasAttribute&&y.hasAttribute("patchsrc")&&y.removeAttribute("patchsrc"),y.hasAttribute&&y.hasAttribute("for")&&Go("for",E)&&y.removeAttribute("for")}catch(L){}}const m=R(d);if(m)for(let y=m.length-1;y>=0;--y)l.push(m[y])}},Ko=function(r){let l=null,d=null;if(xt)r="<remove></remove>"+r;else{const y=Zt(r,/^[\r\n\t ]+/);d=y&&y[0]}De==="application/xhtml+xml"&&be===G&&(r='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+r+"</body></html>");const p=F?pe(r):r;if(be===G)try{l=new g().parseFromString(p,De)}catch(y){}if(!l||!l.documentElement){l=bt.createDocument(be,"template",null);try{l.documentElement.innerHTML=Ct?re:p}catch(y){}}const m=l.body||l.documentElement;return r&&d&&m.insertBefore(t.createTextNode(d),m.childNodes[0]||null),be===G?gi.call(l,se?"html":"body")[0]:se?l.documentElement:m},Vo=function(r){const l=Be?Be(r):r.ownerDocument;return Co.call(l||r,r,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ze=function(r){return r=Se(r,yi," "),r=Se(r,vi," "),r=Se(r,Ei," "),r},It=function(r){var l;r.normalize();const d=Be?Be(r):r.ownerDocument,p=Co.call(d||r,r,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let m=p.nextNode();for(;m;)m.data=Ze(m.data),m=p.nextNode();const y=(l=r.querySelectorAll)===null||l===void 0?void 0:l.call(r,"template");y&&ne(y,E=>{ve(E.content)&&It(E.content)})},Je=function(r){const l=he?he(r):null;return typeof l!="string"||M(l)!=="form"?!1:typeof r.nodeName!="string"||typeof r.textContent!="string"||typeof r.removeChild!="function"||r.attributes!==mt(r)||typeof r.removeAttribute!="function"||typeof r.removeAttributeNode!="function"||typeof r.getAttributeNode!="function"||typeof r.setAttribute!="function"||typeof r.namespaceURI!="string"||typeof r.insertBefore!="function"||typeof r.hasChildNodes!="function"||r.nodeType!==ie(r)||r.childNodes!==R(r)},ve=function(r){if(!ie||typeof r!="object"||r===null)return!1;try{return ie(r)===U.documentFragment}catch(l){return!1}},Oe=function(r){if(!ie||typeof r!="object"||r===null)return!1;try{return typeof ie(r)=="number"}catch(l){return!1}};function K(h,r,l){h.length!==0&&ne(h,d=>{d.call(e,r,l,ye)})}const Ni=function(r,l){return!!(ae&&r.hasChildNodes()&&!Oe(r.firstElementChild)&&O(ao,r.textContent)&&O(ao,r.innerHTML)||ae&&r.namespaceURI===G&&qn[l]&&(Oe(r.firstElementChild)||typeof r.textContent=="string"&&O(Gn[l],r.textContent))||r.nodeType===U.processingInstruction||ae&&r.nodeType===U.comment&&O(so,r.data))},Qe=function(r,l){if(r instanceof RegExp)return O(r,l);if(r 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!!r(l,...p)}return!1},zi=function(r,l,d){if(!_e[l]&&Jo(l)&&Qe(q.tagNameCheck,l))return!1;if(kt&&!ge[l]){const p=z(r),m=R(r);if(m&&p){const y=m.length;for(let E=y-1;E>=0;--E){const L=r===d?v(m[E],!0):m[E];p.insertBefore(L,J(r))}}}return te(r),!0},Yo=function(r,l,d,p){return r.length===0?l:l===d||l===p?H(l):l},Ee=function(r,l){return r===l||z(r)!==null?!1:(Tt&&Xe(r),!0)},Xo=function(r,l){if(K(C.beforeSanitizeElements,r,null),Ee(r,l))return!0;if(Je(r))return te(r),!0;const d=M(ft(r));if(S=Yo(C.uponSanitizeElement,S,yt,$e),K(C.uponSanitizeElement,r,{tagName:d,allowedTags:S}),Ee(r,l))return!0;if(Ni(r,d))return te(r),!0;if(_e[d]||!(Q.tagCheck instanceof Function&&Q.tagCheck(d))&&!S[d]){const p=zi(r,d,l);return p===!1&&(K(C.afterSanitizeElements,r,null),Ee(r,l))?!0:p}if(Me(r)===U.element&&!Oi(r)||(d==="noscript"||d==="noembed"||d==="noframes")&&O($n,r.innerHTML))return te(r),!0;if(ee&&r.nodeType===U.text){const p=Ze(r.textContent);r.textContent!==p&&(Te(e.removed,{element:r.cloneNode()}),r.textContent=p)}return K(C.afterSanitizeElements,r,null),Ee(r,l)},Zo=function(r,l,d){if(Lo[l]||Go(l,r)||Do&&(l==="id"||l==="name")&&(d in t||d in Mi))return!1;const p=A[l]||Q.attributeCheck instanceof Function&&Q.attributeCheck(l,r);return Et&&O(wi,l)||Mo&&O(xi,l)?!0:p?Fo[l]||O(Ao,Se(d,So,""))||(l==="src"||l==="xlink:href"||l==="href")&&r!=="script"&&Jt(d,"data:")===0&&No[r]||Io&&!O(ki,Se(d,So,""))?!0:!d:Jo(r)&&Qe(q.tagNameCheck,r)&&Qe(q.attributeNameCheck,l,r)||l==="is"&&q.allowCustomizedBuiltInElements&&Qe(q.tagNameCheck,d)},Fi=w({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Jo=function(r){return!Fi[Ce(r)]&&O(Ti,r)},Hi=function(r,l,d,p){if(F&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!d)switch(b.getAttributeType(r,l)){case"TrustedHTML":return pe(p);case"TrustedScriptURL":return pi(p)}return p},Ui=function(r,l,d,p){try{return d?r.setAttributeNS(d,l,p):r.setAttribute(l,p),Je(r)?(te(r),!1):!0}catch(m){return le(l,r),!1}},Qo=function(r,l){if(K(C.beforeSanitizeAttributes,r,null),Ee(r,l))return;const d=r.attributes;if(!d||Je(r))return;A=Yo(C.uponSanitizeAttribute,A,vt,We);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let m=d.length;const y=M(r.nodeName);for(;m--;){const E=d[m],L=E.name,$=E.namespaceURI,B=E.value,we=M(L),Dt=B;let P=L==="value"?Dt:Cn(Dt),en=!1;if(p.attrName=we,p.attrValue=P,p.keepAttr=!0,p.forceKeepAttr=void 0,K(C.uponSanitizeAttribute,r,p),P=p.attrValue,Oo&&(we==="id"||we==="name")&&Jt(P,Ro)!==0&&(le(L,r,E),P=Ro+P,en=!0),ae&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,P)){le(L,r,E);continue}if(we==="attributename"&&Zt(P,"href")){le(L,r,E);continue}if(!p.forceKeepAttr){if(!p.keepAttr){le(L,r,E);continue}if(!_o&&O(Wn,P)){le(L,r,E);continue}if(ee&&(P=Ze(P)),!Zo(y,we,P)){le(L,r,E);continue}P=Hi(y,we,$,P),P!==Dt&&Ui(r,L,$,P)&&en&&Xt(e.removed)}}K(C.afterSanitizeAttributes,r,null),Ee(r,l)},et=function(r){let l=null;const d=Vo(r);for(K(C.beforeSanitizeShadowDOM,r,null);l=d.nextNode();)if(K(C.uponSanitizeShadowNode,l,null),Xo(l,r),Qo(l,r),ve(l.content)&&et(l.content),Me(l)===U.element){const p=xo(l);ve(p)&&(_t(p),et(p))}K(C.afterSanitizeShadowDOM,r,null)},_t=function(r){const l=[{node:r,shadow:null}];for(;l.length>0;){const d=l.pop();if(d.shadow){et(d.shadow);continue}const p=d.node,m=Me(p)===U.element,y=R(p);if(y)for(let E=y.length-1;E>=0;--E)l.push({node:y[E],shadow:null});if(m){const E=he?he(p):null;if(typeof E=="string"&&M(E)==="template"){const L=p.content;ve(L)&&l.push({node:L,shadow:null})}}if(m){const E=xo(p);ve(E)&&l.push({node:null,shadow:E},{node:E,shadow:null})}}};return e.sanitize=function(h){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,d=null,p=null,m=null;if(Ct=!h,Ct&&(h="<!-->"),typeof h!="string"&&!Oe(h)&&(h=In(h),typeof h!="string"))throw V("dirty is not a string, aborting");if(!e.isSupported)return h;wt?(S=$e,A=We):Mt(r),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(S=H(S)),C.uponSanitizeAttribute.length>0&&(A=H(A)),e.removed=[];const y=Tt&&typeof h!="string"&&Oe(h);if(y){Pi(h);const $=ft(h);if(typeof $=="string"){const B=M($);if(!S[B]||_e[B])throw Ye(h),V("root node is forbidden and cannot be sanitized in-place")}if(Je(h))throw Ye(h),V("root node is clobbered and cannot be sanitized in-place");try{_t(h)}catch(B){throw Ye(h),B}}else if(Oe(h))l=Ko("<!---->"),d=l.ownerDocument.importNode(h,!0),d.nodeType===U.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?l=d:l.appendChild(d),_t(l);else{if(!me&&!ee&&!se&&h.indexOf("<")===-1)return F&&Ge?pe(h):h;if(l=Ko(h),!l)return me?null:Ge?re:""}l&&xt&&te(l.firstChild);const E=y?h:l;try{const $=Vo(E);for(;p=$.nextNode();)Xo(p,E),Qo(p,E),ve(p.content)&&et(p.content)}catch($){throw y&&(Ye(h),ne(e.removed,B=>{B.element&&Xe(B.element)})),$}if(y){let $=!1;if(ne(e.removed,B=>{B.element&&(B.element===h&&($=!0),Xe(B.element))}),$)throw V("a node selected for removal could not be safely returned; refusing to sanitize in place");return ee&&It(h),h}if(me){if(ee&&It(l),qe)for(m=fi.call(l.ownerDocument);l.firstChild;)m.appendChild(l.firstChild);else m=l;return(A.shadowroot||A.shadowrootmode)&&(m=bi.call(o,m,!0)),m}let L=se?l.outerHTML:l.innerHTML;return se&&S["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&O(Bn,l.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
525
- `+L),ee&&(L=Ze(L)),F&&Ge?pe(L):L},e.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Mt(h),wt=!0,$e=S,We=A},e.clearConfig=function(){ye=null,wt=!1,$e=null,We=null,F=gt,re=""},e.isValidAttribute=function(h,r,l){ye||Mt({});const d=M(h),p=M(r);return Zo(d,p,l)},e.addHook=function(h,r){typeof r=="function"&&N(C,h)&&Te(C[h],r)},e.removeHook=function(h,r){if(N(C,h)){if(r!==void 0){const l=kn(C[h],r);return l===-1?void 0:Tn(C[h],l,1)[0]}return Xt(C[h])}},e.removeHooks=function(h){N(C,h)&&(C[h]=[])},e.removeAllHooks=function(){C=co()},e}var ze=uo();const Yn=["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"],Xn={"*":["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"],ol:["start","reversed"],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"]},Zn="data-editora-embed";function Jn(a){if(!a||/\s/.test(a.trim()))return!1;try{const e=new URL(a.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function ho(a,e,t,o){if((e==null?void 0:e.sanitize)===!1)return a;const n=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:Yn,i=t!=null&&t.length?Array.from(new Set([...n,...t])):n,c=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:Xn,u=new Set;for(const T of Object.values(c))for(const v of T)u.add(v);const g={ALLOWED_TAGS:i,ALLOWED_ATTR:Array.from(u)};if(!o)return ze.sanitize(a,g);const b=i.includes("iframe");ze.addHook("uponSanitizeElement",(T,v)=>{var k;if(v.tagName!=="iframe")return;const x=T;v.allowedTags.iframe=b||((k=x.getAttribute)==null?void 0:k.call(x,Zn))==="true"&&Jn(x.getAttribute("src"))});try{return ze.sanitize(a,g)}finally{ze.removeHook("uponSanitizeElement")}}function po(a,e,t,o){return ho(a,e,o,!1)}function mo(a,e,t){return(t==null?void 0:t.sanitizeOnPaste)===!1?a:po(a,e)}function ct(a,e,t,o){return(t==null?void 0:t.sanitizeOnInput)===!1?a:ho(a,e,o,!0)}const Qn=".resize-handle, .table-resize-handle",ei=/resize-handle/;function dt(a){if(!a||!ei.test(a))return a;const e=document.createElement("template");e.innerHTML=a;const t=new Set;return e.content.querySelectorAll(Qn).forEach(o=>{const n=o.parentElement;n&&(n.tagName==="TD"||n.tagName==="TH")&&t.add(n),o.remove()}),t.forEach(o=>{var n;o.style.position==="relative"&&(o.style.removeProperty("position"),(n=o.getAttribute("style"))!=null&&n.trim()||o.removeAttribute("style"))}),e.innerHTML}function ue(a){return a?dt(a.innerHTML):""}const Ue=class Ue{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 s=typeof t.toolbar=="object"&&t.toolbar?{...t.toolbar}:typeof t.toolbar=="string"?{items:t.toolbar}:{};t.toolbarFloating!==void 0&&(s.floating=!!t.toolbarFloating),t.toolbarSticky!==void 0&&(s.sticky=!!t.toolbarSticky),t.toolbar=s}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 s=typeof t.autosave=="object"&&t.autosave?{...t.autosave}:{};t.autosaveEnabled!==void 0&&(s.enabled=!!t.autosaveEnabled),t.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(t.autosaveIntervalMs)),t.autosaveStorageKey!==void 0&&(s.storageKey=t.autosaveStorageKey),t.autosaveProvider!==void 0&&(s.provider=t.autosaveProvider),t.autosaveApiUrl!==void 0&&(s.apiUrl=t.autosaveApiUrl),t.autosave=s}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 s={...o,...t.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=o.intervalMs),t.autosave=s}else t.autosave=o;if(t.languageLocale!==void 0||t.languageDirection!==void 0){const s=typeof t.language=="object"&&t.language?{...t.language}:{};t.languageLocale!==void 0&&(s.locale=t.languageLocale),t.languageDirection!==void 0&&(s.direction=t.languageDirection),t.language=s}const n={locale:"en",direction:"ltr"};if(typeof t.language=="string"?t.language={locale:t.language,direction:n.direction}:typeof t.language=="object"&&t.language?t.language={...n,...t.language}:t.language=n,t.spellcheckEnabled!==void 0||t.spellcheckProvider!==void 0||t.spellcheckApiUrl!==void 0){const s=typeof t.spellcheck=="object"&&t.spellcheck?{...t.spellcheck}:{};t.spellcheckEnabled!==void 0&&(s.enabled=!!t.spellcheckEnabled),t.spellcheckProvider!==void 0&&(s.provider=t.spellcheckProvider),t.spellcheckApiUrl!==void 0&&(s.apiUrl=t.spellcheckApiUrl),t.spellcheck=s}const i={enabled:!1,provider:"browser",apiUrl:""};if(typeof t.spellcheck=="boolean")t.spellcheck={...i,enabled:t.spellcheck};else if(typeof t.spellcheck=="object"&&t.spellcheck){const s={...i,...t.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),t.spellcheck=s}else t.spellcheck=i;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,n]of Object.entries(e)){const i=this.kebabToCamel(o);t[i]=this.BOOLEAN_ATTRIBUTES.has(o)&&(n===""||n===o)?!0:this.parseAttributeValue(n)}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[n,i]of Object.entries(o))i!=null&&(typeof i=="object"&&!Array.isArray(i)&&t[n]?t[n]=this.merge(t[n],i):t[n]=i);return t}};Ue.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},Ue.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 Fe=Ue;class fo{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 n=await o();return t&&this.applyPluginConfig(n,t),this.loadedPlugins.set(e,n),n}async loadMultiple(e,t){return(await Promise.all(e.map(n=>this.load(n,t)))).filter(n=>n!==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 go{constructor(e={}){this.changeListeners=[],this.options=e,this.engine=new Re({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 Pe({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 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 ti(a){return new go(a)}class bo{constructor(e){this.options=e,this.containerElement=e.element;const t=this.resolvePlugins(e.plugins);this.engine=new Re({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 Pe({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=n=>{t(n.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 oi='.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 He;const ni="__editoraCommandEditorRoot",ii="__editoraLastCommandButton",yo="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",vo=".rte-content, .editora-content",ri="Rich text editor",ut=new Set;let X=null,Eo=!1,ht=null,pt=null;function wo(a){if(!(a instanceof HTMLElement))return!1;const e=a;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function ai(a){return a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null}function Le(a){if(!a)return null;if(wo(a))return a;const e=a.matches(yo)?a:a.closest(yo);return!e||!wo(e)?null:e}function si(){var n;if(typeof window=="undefined")return null;const a=window[ni];if(a instanceof HTMLElement){const i=Le(a);if(i)return i;const s=a.matches(vo)?a:a.querySelector(vo);if(s){const c=Le(s);if(c)return c}}const e=window[ii];if(e instanceof HTMLElement){const i=Le(e);if(i)return i}const t=document.activeElement;if(t){const i=Le(t);if(i)return i}const o=(n=window.getSelection)==null?void 0:n.call(window);if(o&&o.rangeCount>0){const i=Le(ai(o.getRangeAt(0).startContainer));if(i)return i}if(X&&X.isConnected)return X;for(const i of ut)if(i.isConnected)return i;return null}function li(){if(typeof window=="undefined"||Eo)return;ht=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,pt=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const a=(e,...t)=>{const o=si();return o?o.execCommand(e,...t):ht?ht(e,...t):pt?pt(e,...t):!1};window.executeEditorCommand=a,window.execEditorCommand=a,Eo=!0}function ci(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const e=document.createElement("style");e.id=a,e.textContent=oi,document.head.appendChild(e)}}function di(){if(!He){const a=Z.__globalPluginLoader;a?He=a:He=new fo}return He}class Z extends HTMLElement{constructor(){if(super(),this.pluginLoader=di(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Pt,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,ci(),!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","aria-label","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(Z.__globalPluginLoader){this.pluginLoader=Z.__globalPluginLoader;return}return new Promise(e=>{const t=()=>{Z.__globalPluginLoader?(this.pluginLoader=Z.__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 n;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),ut.add(this),X||(X=this),li(),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();if(this.loadedPlugins=e,e.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const i=this.innerHTML.trim();i&&this.setAttribute("data-initial-content",i)}const t=this.preservedContent;this.preservedContent=null;const o=this.sanitizeLoadedContent((n=t!=null?t:this.restoreAutosavedContent())!=null?n:this.getAttribute("data-initial-content")||"");this.engine=new Re({content:o,plugins:e,readonly:this.config.readonly}),this.createUI(e,o),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),n=this.getAccessibilityConfig().checker===!0;if(t){if(typeof this.config.plugins=="string"){const i=this.config.plugins.split(/\s+/).filter(Boolean);n&&!i.includes("a11yChecker")&&i.push("a11yChecker");for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&e.push(c)}}else if(Array.isArray(this.config.plugins)){for(const i of this.config.plugins)if(typeof i=="string"){const s=await this.pluginLoader.load(i,this.getPluginLoadConfig(i));s&&e.push(s)}else e.push(i);if(n&&!e.some(i=>(i==null?void 0:i.name)==="a11yChecker")){const i=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));i&&e.push(i)}}}else{const i=this.pluginLoader.getRegisteredPluginNames();for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&e.push(c)}}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(){var t;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 o=(t=this.getAttribute("aria-label"))==null?void 0:t.trim(),n=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||n||ri)}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 i;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},n=this.loadedPlugins.find(s=>s.commands&&s.commands[e]);if(n&&n.commands){const s=n.commands[e];if(typeof s=="function")try{return e==="toggleFullscreen"?s(this,o):s(...t,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${e}:`,c),!1}}return((i=this.engine)==null?void 0:i.execCommand(e,...t))||!1}getPluginLoadConfig(e){const t=this.config.pluginConfig;if(t&&typeof t=="object"){const i=t[e];if(i&&typeof i=="object")return i}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=[e,e.toLowerCase(),...o[e]||[]];for(const i of n){const s=this.config[i];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}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}}sanitizeLoadedContent(e){return ct(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}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 n=Number((o=(t=e.intervalMs)!=null?t:e.interval)!=null?o:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(n)&&n>0?n: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(()=>{this.persistAutosave(ue(this.contentElement))},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 n=document.createElement("div");n.innerHTML=e;const i=document.createDocumentFragment();for(;n.firstChild;)i.appendChild(n.firstChild);o.insertNode(i),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"]'),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 Pe({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((i,s)=>{var c;if(this.contentElement){this.contentElement.focus();const u=window.getSelection();if(!u||u.rangeCount===0||!this.contentElement.contains(u.anchorNode)){const g=document.createRange(),b=this.contentElement.lastChild||this.contentElement;b.nodeType===Node.TEXT_NODE?g.setStart(b,((c=b.textContent)==null?void 0:c.length)||0):b.nodeType===Node.ELEMENT_NODE?(g.selectNodeContents(b),g.collapse(!1)):g.setStart(this.contentElement,0),g.collapse(!0),u==null||u.removeAllRanges(),u==null||u.addRange(g)}}return this.executeCommand(i,s)}),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(i){console.warn("defaultParagraphSeparator not supported:",i)}if(t){const i=document.createElement("div");i.innerHTML=t.trim(),!Array.from(i.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})&&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 Ht({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 Ut({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var i;return(i=this.contentElement)==null?void 0:i.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",o=>{var v;if(!this.contentElement)return;let n=this.contentElement.innerHTML;const i=(v=o==null?void 0:o.detail)==null?void 0:v.allowedTags,s=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),g=this.lastBeforeInputType;if(this.lastBeforeInputType=null,u.sanitizeOnInput!==!1&&c.sanitize!==!1&&!g){const x=ct(n,c,u,i);if(x!==n){const k=window.getSelection(),J=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=x,J&&k)try{k.removeAllRanges(),k.addRange(J)}catch(R){}n=x}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:dt(n)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,s.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 b,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const n=this.config.paste||{};let i=((b=o.clipboardData)==null?void 0:b.getData("text/html"))||"";const s=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),g=!!i&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);if((n.clean||!n.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(n.convertWord===!1&&g&&s){document.execCommand("insertText",!1,s);return}if(i){u.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(i=mo(i,c,u)),this.insertHTMLAtSelection(i);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{X=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:ue(this.contentElement)},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,(i,s)=>{this.executeCommand(i,s)})});const t=()=>{const o=this.getSelectionRangeInEditor(),n=document.activeElement,i=!!n&&!!this.contentElement&&(n===this.contentElement||this.contentElement.contains(n));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!i||!o&&!i||(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(i=>i.width>0||i.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.isReadonlyAttribute(this.getAttribute("readonly"))||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 n=this.getSelectionRangeInEditor();if(!n){this.floatingToolbar.hide();return}if(n.collapsed){this.floatingToolbar.hide();return}const i=window.getSelection();if(!i){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(i,n);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.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:n,chars:i}=Wt(o),s=$t(this.contentElement);let c,u;const g=this.getSelectionRangeInEditor();g&&(c=Bt(this.contentElement,g),g.collapsed||(u=qt(g,c),c=void 0)),this.statusBar.update({wordCount:n,charCount:i,lineCount:s,cursorPosition:c,selectionInfo:u})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,t){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(t)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(t));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"aria-label":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 Fe.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>ue(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(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,n;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=ue(this.contentElement),this.persistAutosave(this.preservedContent)),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(),(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,ut.delete(this),X===this&&(X=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return ue(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(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 ui(a){return new bo(a)}function hi(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",Z)}f.CharacterDialog=pn,f.ColorPicker=ln,f.CommandRegistry=Ft,f.ConfigResolver=Fe,f.Dialog=oe,f.DocumentModel=ke,f.Dropdown=sn,f.Editor=on,f.EditorEngine=Re,f.EditorState=W,f.EmojiDialog=mn,f.FloatingToolbar=Ht,f.ImageDialog=un,f.KeyboardShortcutManager=Pt,f.LinkDialog=cn,f.MathDialog=hn,f.MediaPlugin=an,f.PluginLoader=fo,f.PluginManager=xe,f.PluginRuntime=Rt,f.ReactAdapter=go,f.RichTextEditorElement=Z,f.Schema=Ot,f.SpellcheckPlugin=rn,f.StatusBar=Ut,f.TableDialog=dn,f.ToolbarRenderer=Pe,f.VanillaAdapter=bo,f.calculateTextStats=Wt,f.countLines=$t,f.createEditor=ui,f.createPluginManager=tn,f.createPluginRuntime=nn,f.createReactAdapter=ti,f.getCleanEditorHTML=ue,f.getCursorPosition=Bt,f.getSelectionInfo=qt,f.getTextOffset=jt,f.initWebComponent=hi,f.sanitizeHTML=po,f.sanitizeInputHTML=ct,f.sanitizePastedHTML=mo,f.stripEditorUiArtifacts=dt,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
523
+ `).length;t=Math.max(1,s)}return t}function Wt(a){const e=a.trim()?a.trim().split(/\s+/).length:0,t=a.length;return{words:e,chars:t}}function qt(a,e){const t=a.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}}function Gt(a,e){(e==null||e>a.length)&&(e=a.length);for(var t=0,o=Array(e);t<e;t++)o[t]=a[t];return o}function fn(a){if(Array.isArray(a))return a}function gn(a,e){var t=a==null?null:typeof Symbol!="undefined"&&a[Symbol.iterator]||a["@@iterator"];if(t!=null){var o,n,i,s,c=[],d=!0,m=!1;try{if(i=(t=t.call(a)).next,e!==0)for(;!(d=(o=i.call(t)).done)&&(c.push(o.value),c.length!==e);d=!0);}catch(f){m=!0,n=f}finally{try{if(!d&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(m)throw n}}return c}}function bn(){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 yn(a,e){return fn(a)||gn(a,e)||vn(a,e)||bn()}function vn(a,e){if(a){if(typeof a=="string")return Gt(a,e);var t={}.toString.call(a).slice(8,-1);return t==="Object"&&a.constructor&&(t=a.constructor.name),t==="Map"||t==="Set"?Array.from(a):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Gt(a,e):void 0}}const Kt=Object.entries,Vt=Object.setPrototypeOf,En=Object.isFrozen,wn=Object.getPrototypeOf,xn=Object.getOwnPropertyDescriptor;let _=Object.freeze,D=Object.seal,ce=Object.create,Yt=typeof Reflect!="undefined"&&Reflect,tt=Yt.apply,ot=Yt.construct;_||(_=function(e){return e}),D||(D=function(e){return e}),tt||(tt=function(e,t){for(var o=arguments.length,n=new Array(o>2?o-2:0),i=2;i<o;i++)n[i-2]=arguments[i];return e.apply(t,n)}),ot||(ot=function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return new e(...o)});const ne=I(Array.prototype.forEach),kn=I(Array.prototype.lastIndexOf),Xt=I(Array.prototype.pop),Te=I(Array.prototype.push),Tn=I(Array.prototype.splice),de=Array.isArray,Ce=I(String.prototype.toLowerCase),nt=I(String.prototype.toString),Zt=I(String.prototype.match),Se=I(String.prototype.replace),Jt=I(String.prototype.indexOf),Cn=I(String.prototype.trim),Sn=I(Number.prototype.toString),An=I(Boolean.prototype.toString),Qt=typeof BigInt=="undefined"?null:I(BigInt.prototype.toString),eo=typeof Symbol=="undefined"?null:I(Symbol.prototype.toString),N=I(Object.prototype.hasOwnProperty),Ae=I(Object.prototype.toString),O=I(RegExp.prototype.test),V=Ln(TypeError);function I(a){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return tt(a,e,o)}}function Ln(a){return function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return ot(a,t)}}function x(a,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ce;if(Vt&&Vt(a,null),!de(e))return a;let o=e.length;for(;o--;){let n=e[o];if(typeof n=="string"){const i=t(n);i!==n&&(En(e)||(e[o]=i),n=i)}a[n]=!0}return a}function Mn(a){for(let e=0;e<a.length;e++)N(a,e)||(a[e]=null);return a}function H(a){const e=ce(null);for(const o of Kt(a)){var t=yn(o,2);const n=t[0],i=t[1];N(a,n)&&(de(i)?e[n]=Mn(i):i&&typeof i=="object"&&i.constructor===Object?e[n]=H(i):e[n]=i)}return e}function In(a){switch(typeof a){case"string":return a;case"number":return Sn(a);case"boolean":return An(a);case"bigint":return Qt?Qt(a):"0";case"symbol":return eo?eo(a):"Symbol()";case"undefined":return Ae(a);case"function":case"object":{if(a===null)return Ae(a);const e=a,t=j(e,"toString");if(typeof t=="function"){const o=t(e);return typeof o=="string"?o:Ae(o)}return Ae(a)}default:return Ae(a)}}function j(a,e){for(;a!==null;){const o=xn(a,e);if(o){if(o.get)return I(o.get);if(typeof o.value=="function")return I(o.value)}a=wn(a)}function t(){return null}return t}function _n(a){try{return O(a,""),!0}catch(e){return!1}}const to=_(["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"]),it=_(["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"]),rt=_(["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"]),Dn=_(["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"]),at=_(["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"]),On=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),oo=_(["#text"]),no=_(["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"]),st=_(["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"]),io=_(["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"]),Ne=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Rn=D(/{{[\w\W]*|^[\w\W]*}}/g),Pn=D(/<%[\w\W]*|^[\w\W]*%>/g),Nn=D(/\${[\w\W]*/g),zn=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fn=D(/^aria-[\-\w]+$/),ro=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Hn=D(/^(?:\w+script|data):/i),Un=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Bn=D(/^html$/i),jn=D(/^[a-z][.\w]*(-[.\w]+)+$/i),ao=D(/<[/\w!]/g),so=D(/<[/\w]/g),$n=D(/<\/no(script|embed|frames)/i),Wn=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},lo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],qn=_(x({},lo)),Gn=(function(){const a={};return ne(lo,e=>{a[e]=D(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),_(a)})(),Kn=function(){return typeof window=="undefined"?null:window},Vn=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const i="dompurify"+(o?"#"+o:"");try{return e.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}},co=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Y=function(e,t,o,n){return N(e,t)&&de(e[t])?x(n.base?H(n.base):{},e[t],n.transform):o},lt=function(e,t,o){const n=N(e,t)?e[t]:void 0;return n&&typeof n=="object"?H(n):o()};function uo(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Kn();const e=h=>uo(h);if(e.version="3.4.16",e.removed=[],!a||!a.document||a.document.nodeType!==U.document||!a.Element)return e.isSupported=!1,e;let t=a.document;const o=t,n=o.currentScript;a.DocumentFragment;const i=a.HTMLTemplateElement,s=a.Node,c=a.Element,d=a.NodeFilter;a.NamedNodeMap===void 0&&(a.NamedNodeMap||a.MozNamedAttrMap),a.HTMLFormElement;const m=a.DOMParser,f=a.trustedTypes,T=c.prototype,y=j(T,"cloneNode"),E=j(T,"remove"),k=j(T,"removeAttributeNode"),J=j(T,"nextSibling"),R=j(T,"childNodes"),z=j(T,"parentNode"),xo=j(T,"shadowRoot"),mt=j(T,"attributes"),ie=s&&s.prototype?j(s.prototype,"nodeType"):null,he=s&&s.prototype?j(s.prototype,"nodeName"):null,Be=s&&s.prototype?j(s.prototype,"ownerDocument"):null,Me=function(r){return ie?ie(r):r.nodeType},ft=function(r){return he?he(r):r.nodeName};if(typeof i=="function"){const h=t.createElement("template");h.content&&h.content.ownerDocument&&(t=h.content.ownerDocument)}let F,re="",gt,ko=!1,Ie=0;const To=function(){if(Ie>0)throw V('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.')},pe=function(r){To(),Ie++;try{return F.createHTML(r)}finally{Ie--}},pi=function(r){To(),Ie++;try{return F.createScriptURL(r)}finally{Ie--}},mi=function(){return ko||(gt=Vn(f,n),ko=!0),gt},je=t,bt=je.implementation,Co=je.createNodeIterator,fi=je.createDocumentFragment,gi=je.getElementsByTagName,bi=o.importNode;let C=co();e.isSupported=typeof Kt=="function"&&typeof z=="function"&&bt&&bt.createHTMLDocument!==void 0;const yi=Rn,vi=Pn,Ei=Nn,wi=zn,xi=Fn,ki=Hn,So=Un,Ti=jn;let Ao=ro,S=null;const yt=x({},[...to,...it,...rt,...at,...oo]);let A=null;const vt=x({},[...no,...st,...io,...Ne]);let q=Object.seal(ce(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}})),_e=null,Lo=null;const Q=Object.seal(ce(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mo=!0,Et=!0,Io=!1,_o=!0,ee=!1,ae=!0,se=!1,wt=!1,$e=null,We=null,xt=!1,me=!1,qe=!1,Ge=!1,Do=!0,Oo=!1;const Ro="user-content-";let kt=!0,Tt=!1,fe={},ge=null;const Po=x({},["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 No=null;const zo=x({},["audio","video","img","source","image","track"]);let Fo=null;const Ho=x({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml";let be=G,Ct=!1,St=null;const Ci=x({},[Ke,Ve,G],nt),Uo=_(["mi","mo","mn","ms","mtext"]);let At=x({},Uo);const Bo=_(["annotation-xml"]);let Lt=x({},Bo);const Si=x({},["title","style","font","a","script"]);let De=null;const Ai=["application/xhtml+xml","text/html"],Li="text/html";let M=null,ye=null;const Mi=t.createElement("form"),jo=function(r){return r instanceof RegExp||r instanceof Function},Mt=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ye&&ye===r)return;(!r||typeof r!="object")&&(r={}),r=H(r),De=Ai.indexOf(r.PARSER_MEDIA_TYPE)===-1?Li:r.PARSER_MEDIA_TYPE,M=De==="application/xhtml+xml"?nt:Ce,S=Y(r,"ALLOWED_TAGS",yt,{transform:M}),A=Y(r,"ALLOWED_ATTR",vt,{transform:M}),St=Y(r,"ALLOWED_NAMESPACES",Ci,{transform:nt}),Fo=Y(r,"ADD_URI_SAFE_ATTR",Ho,{transform:M,base:Ho}),No=Y(r,"ADD_DATA_URI_TAGS",zo,{transform:M,base:zo}),ge=Y(r,"FORBID_CONTENTS",Po,{transform:M}),_e=Y(r,"FORBID_TAGS",H({}),{transform:M}),Lo=Y(r,"FORBID_ATTR",H({}),{transform:M}),fe=N(r,"USE_PROFILES")?r.USE_PROFILES&&typeof r.USE_PROFILES=="object"?H(r.USE_PROFILES):r.USE_PROFILES:!1,Mo=r.ALLOW_ARIA_ATTR!==!1,Et=r.ALLOW_DATA_ATTR!==!1,Io=r.ALLOW_UNKNOWN_PROTOCOLS||!1,_o=r.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ee=r.SAFE_FOR_TEMPLATES||!1,ae=r.SAFE_FOR_XML!==!1,se=r.WHOLE_DOCUMENT||!1,me=r.RETURN_DOM||!1,qe=r.RETURN_DOM_FRAGMENT||!1,Ge=r.RETURN_TRUSTED_TYPE||!1,xt=r.FORCE_BODY||!1,Do=r.SANITIZE_DOM!==!1,Oo=r.SANITIZE_NAMED_PROPS||!1,kt=r.KEEP_CONTENT!==!1,Tt=r.IN_PLACE||!1,Ao=_n(r.ALLOWED_URI_REGEXP)?r.ALLOWED_URI_REGEXP:ro,be=typeof r.NAMESPACE=="string"?r.NAMESPACE:G,At=lt(r,"MATHML_TEXT_INTEGRATION_POINTS",()=>x({},Uo)),Lt=lt(r,"HTML_INTEGRATION_POINTS",()=>x({},Bo));const l=lt(r,"CUSTOM_ELEMENT_HANDLING",()=>ce(null));if(q=ce(null),N(l,"tagNameCheck")&&jo(l.tagNameCheck)&&(q.tagNameCheck=l.tagNameCheck),N(l,"attributeNameCheck")&&jo(l.attributeNameCheck)&&(q.attributeNameCheck=l.attributeNameCheck),N(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),D(q),ee&&(Et=!1),qe&&(me=!0),fe&&(S=x({},oo),A=ce(null),fe.html===!0&&(x(S,to),x(A,no)),fe.svg===!0&&(x(S,it),x(A,st),x(A,Ne)),fe.svgFilters===!0&&(x(S,rt),x(A,st),x(A,Ne)),fe.mathMl===!0&&(x(S,at),x(A,io),x(A,Ne))),Q.tagCheck=null,Q.attributeCheck=null,N(r,"ADD_TAGS")&&(typeof r.ADD_TAGS=="function"?Q.tagCheck=r.ADD_TAGS:de(r.ADD_TAGS)&&(S===yt&&(S=H(S)),x(S,r.ADD_TAGS,M))),N(r,"ADD_ATTR")&&(typeof r.ADD_ATTR=="function"?Q.attributeCheck=r.ADD_ATTR:de(r.ADD_ATTR)&&(A===vt&&(A=H(A)),x(A,r.ADD_ATTR,M))),N(r,"ADD_FORBID_CONTENTS")&&de(r.ADD_FORBID_CONTENTS)&&(ge===Po&&(ge=H(ge)),x(ge,r.ADD_FORBID_CONTENTS,M)),kt&&(S["#text"]=!0),se&&x(S,["html","head","body"]),S.table&&(x(S,["tbody"]),delete _e.tbody),r.TRUSTED_TYPES_POLICY){if(typeof r.TRUSTED_TYPES_POLICY.createHTML!="function")throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof r.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw V('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const u=F;F=r.TRUSTED_TYPES_POLICY;try{re=pe("")}catch(p){throw F=u,p}}else r.TRUSTED_TYPES_POLICY===null?(F=void 0,re=""):(F===void 0&&(F=mi()),F&&typeof re=="string"&&(re=pe("")));_&&_(r),ye=r},$o=x({},[...it,...rt,...Dn]),Wo=x({},[...at,...On]),Ii=function(r,l,u){return l.namespaceURI===G?r==="svg":l.namespaceURI===Ke?r==="svg"&&(u==="annotation-xml"||At[u]):!!$o[r]},_i=function(r,l,u){return l.namespaceURI===G?r==="math":l.namespaceURI===Ve?r==="math"&&Lt[u]:!!Wo[r]},Di=function(r,l,u){return l.namespaceURI===Ve&&!Lt[u]||l.namespaceURI===Ke&&!At[u]?!1:!Wo[r]&&(Si[r]||!$o[r])},Oi=function(r){let l=z(r);(!l||!l.tagName)&&(l={namespaceURI:be,tagName:"template"});const u=Ce(r.tagName),p=Ce(l.tagName);return St[r.namespaceURI]?r.namespaceURI===Ve?Ii(u,l,p):r.namespaceURI===Ke?_i(u,l,p):r.namespaceURI===G?Di(u,l,p):!!(De==="application/xhtml+xml"&&St[r.namespaceURI]):!1},te=function(r){Te(e.removed,{element:r});try{z(r).removeChild(r)}catch(l){if(E(r),!z(r))throw V("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},qo=function(r,l,u){try{k(r,l)}catch(p){try{r.removeAttribute(u)}catch(g){}}},Ye=function(r){Xe(r);const l=R(r);if(l){const p=[];ne(l,g=>{Te(p,g)}),ne(p,g=>{try{E(g)}catch(v){}})}const u=mt(r);if(u)for(let p=u.length-1;p>=0;--p){const g=u[p],v=g&&g.name;typeof v=="string"&&qo(r,g,v)}},le=function(r,l,u){if(!u)try{u=l.getAttributeNode(r)}catch(p){u=null}Te(e.removed,{attribute:u||null,from:l});try{u?k(l,u):l.removeAttribute(r)}catch(p){try{l.removeAttribute(r)}catch(g){}}if(r==="is")if(me||qe)try{te(l)}catch(p){}else try{l.setAttribute(r,"")}catch(p){}},Ri=function(r){const l=mt(r);if(l)for(let u=l.length-1;u>=0;--u){const p=l[u],g=p&&p.name;typeof g!="string"||A[M(g)]||qo(r,p,g)}},Xe=function(r){const l=[r];for(;l.length>0;){const u=l.pop();Me(u)===U.element&&Ri(u);const p=R(u);if(p)for(let g=p.length-1;g>=0;--g)l.push(p[g])}},Go=function(r,l){return ae?r==="patchsrc"?!0:r==="for"&&l!=="label"&&l!=="output":!1},Pi=function(r){if(!ae)return;const l=[r];for(;l.length>0;){const u=l.pop(),p=Me(u);if(p===U.processingInstruction||p===U.comment&&O(so,u.data)){try{E(u)}catch(v){}continue}if(p===U.element){const v=u,w=M(ft(u));try{v.hasAttribute&&v.hasAttribute("patchsrc")&&v.removeAttribute("patchsrc"),v.hasAttribute&&v.hasAttribute("for")&&Go("for",w)&&v.removeAttribute("for")}catch(L){}}const g=R(u);if(g)for(let v=g.length-1;v>=0;--v)l.push(g[v])}},Ko=function(r){let l=null,u=null;if(xt)r="<remove></remove>"+r;else{const v=Zt(r,/^[\r\n\t ]+/);u=v&&v[0]}De==="application/xhtml+xml"&&be===G&&(r='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+r+"</body></html>");const p=F?pe(r):r;if(be===G)try{l=new m().parseFromString(p,De)}catch(v){}if(!l||!l.documentElement){l=bt.createDocument(be,"template",null);try{l.documentElement.innerHTML=Ct?re:p}catch(v){}}const g=l.body||l.documentElement;return r&&u&&g.insertBefore(t.createTextNode(u),g.childNodes[0]||null),be===G?gi.call(l,se?"html":"body")[0]:se?l.documentElement:g},Vo=function(r){const l=Be?Be(r):r.ownerDocument;return Co.call(l||r,r,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Ze=function(r){return r=Se(r,yi," "),r=Se(r,vi," "),r=Se(r,Ei," "),r},It=function(r){var l;r.normalize();const u=Be?Be(r):r.ownerDocument,p=Co.call(u||r,r,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let g=p.nextNode();for(;g;)g.data=Ze(g.data),g=p.nextNode();const v=(l=r.querySelectorAll)===null||l===void 0?void 0:l.call(r,"template");v&&ne(v,w=>{ve(w.content)&&It(w.content)})},Je=function(r){const l=he?he(r):null;return typeof l!="string"||M(l)!=="form"?!1:typeof r.nodeName!="string"||typeof r.textContent!="string"||typeof r.removeChild!="function"||r.attributes!==mt(r)||typeof r.removeAttribute!="function"||typeof r.removeAttributeNode!="function"||typeof r.getAttributeNode!="function"||typeof r.setAttribute!="function"||typeof r.namespaceURI!="string"||typeof r.insertBefore!="function"||typeof r.hasChildNodes!="function"||r.nodeType!==ie(r)||r.childNodes!==R(r)},ve=function(r){if(!ie||typeof r!="object"||r===null)return!1;try{return ie(r)===U.documentFragment}catch(l){return!1}},Oe=function(r){if(!ie||typeof r!="object"||r===null)return!1;try{return typeof ie(r)=="number"}catch(l){return!1}};function K(h,r,l){h.length!==0&&ne(h,u=>{u.call(e,r,l,ye)})}const Ni=function(r,l){return!!(ae&&r.hasChildNodes()&&!Oe(r.firstElementChild)&&O(ao,r.textContent)&&O(ao,r.innerHTML)||ae&&r.namespaceURI===G&&qn[l]&&(Oe(r.firstElementChild)||typeof r.textContent=="string"&&O(Gn[l],r.textContent))||r.nodeType===U.processingInstruction||ae&&r.nodeType===U.comment&&O(so,r.data))},Qe=function(r,l){if(r instanceof RegExp)return O(r,l);if(r instanceof Function){for(var u=arguments.length,p=new Array(u>2?u-2:0),g=2;g<u;g++)p[g-2]=arguments[g];return!!r(l,...p)}return!1},zi=function(r,l,u){if(!_e[l]&&Jo(l)&&Qe(q.tagNameCheck,l))return!1;if(kt&&!ge[l]){const p=z(r),g=R(r);if(g&&p){const v=g.length;for(let w=v-1;w>=0;--w){const L=r===u?y(g[w],!0):g[w];p.insertBefore(L,J(r))}}}return te(r),!0},Yo=function(r,l,u,p){return r.length===0?l:l===u||l===p?H(l):l},Ee=function(r,l){return r===l||z(r)!==null?!1:(Tt&&Xe(r),!0)},Xo=function(r,l){if(K(C.beforeSanitizeElements,r,null),Ee(r,l))return!0;if(Je(r))return te(r),!0;const u=M(ft(r));if(S=Yo(C.uponSanitizeElement,S,yt,$e),K(C.uponSanitizeElement,r,{tagName:u,allowedTags:S}),Ee(r,l))return!0;if(Ni(r,u))return te(r),!0;if(_e[u]||!(Q.tagCheck instanceof Function&&Q.tagCheck(u))&&!S[u]){const p=zi(r,u,l);return p===!1&&(K(C.afterSanitizeElements,r,null),Ee(r,l))?!0:p}if(Me(r)===U.element&&!Oi(r)||(u==="noscript"||u==="noembed"||u==="noframes")&&O($n,r.innerHTML))return te(r),!0;if(ee&&r.nodeType===U.text){const p=Ze(r.textContent);r.textContent!==p&&(Te(e.removed,{element:r.cloneNode()}),r.textContent=p)}return K(C.afterSanitizeElements,r,null),Ee(r,l)},Zo=function(r,l,u){if(Lo[l]||Go(l,r)||Do&&(l==="id"||l==="name")&&(u in t||u in Mi))return!1;const p=A[l]||Q.attributeCheck instanceof Function&&Q.attributeCheck(l,r);return Et&&O(wi,l)||Mo&&O(xi,l)?!0:p?Fo[l]||O(Ao,Se(u,So,""))||(l==="src"||l==="xlink:href"||l==="href")&&r!=="script"&&Jt(u,"data:")===0&&No[r]||Io&&!O(ki,Se(u,So,""))?!0:!u:Jo(r)&&Qe(q.tagNameCheck,r)&&Qe(q.attributeNameCheck,l,r)||l==="is"&&q.allowCustomizedBuiltInElements&&Qe(q.tagNameCheck,u)},Fi=x({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Jo=function(r){return!Fi[Ce(r)]&&O(Ti,r)},Hi=function(r,l,u,p){if(F&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!u)switch(f.getAttributeType(r,l)){case"TrustedHTML":return pe(p);case"TrustedScriptURL":return pi(p)}return p},Ui=function(r,l,u,p){try{return u?r.setAttributeNS(u,l,p):r.setAttribute(l,p),Je(r)?(te(r),!1):!0}catch(g){return le(l,r),!1}},Qo=function(r,l){if(K(C.beforeSanitizeAttributes,r,null),Ee(r,l))return;const u=r.attributes;if(!u||Je(r))return;A=Yo(C.uponSanitizeAttribute,A,vt,We);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let g=u.length;const v=M(r.nodeName);for(;g--;){const w=u[g],L=w.name,$=w.namespaceURI,B=w.value,we=M(L),Dt=B;let P=L==="value"?Dt:Cn(Dt),en=!1;if(p.attrName=we,p.attrValue=P,p.keepAttr=!0,p.forceKeepAttr=void 0,K(C.uponSanitizeAttribute,r,p),P=p.attrValue,Oo&&(we==="id"||we==="name")&&Jt(P,Ro)!==0&&(le(L,r,w),P=Ro+P,en=!0),ae&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,P)){le(L,r,w);continue}if(we==="attributename"&&Zt(P,"href")){le(L,r,w);continue}if(!p.forceKeepAttr){if(!p.keepAttr){le(L,r,w);continue}if(!_o&&O(Wn,P)){le(L,r,w);continue}if(ee&&(P=Ze(P)),!Zo(v,we,P)){le(L,r,w);continue}P=Hi(v,we,$,P),P!==Dt&&Ui(r,L,$,P)&&en&&Xt(e.removed)}}K(C.afterSanitizeAttributes,r,null),Ee(r,l)},et=function(r){let l=null;const u=Vo(r);for(K(C.beforeSanitizeShadowDOM,r,null);l=u.nextNode();)if(K(C.uponSanitizeShadowNode,l,null),Xo(l,r),Qo(l,r),ve(l.content)&&et(l.content),Me(l)===U.element){const p=xo(l);ve(p)&&(_t(p),et(p))}K(C.afterSanitizeShadowDOM,r,null)},_t=function(r){const l=[{node:r,shadow:null}];for(;l.length>0;){const u=l.pop();if(u.shadow){et(u.shadow);continue}const p=u.node,g=Me(p)===U.element,v=R(p);if(v)for(let w=v.length-1;w>=0;--w)l.push({node:v[w],shadow:null});if(g){const w=he?he(p):null;if(typeof w=="string"&&M(w)==="template"){const L=p.content;ve(L)&&l.push({node:L,shadow:null})}}if(g){const w=xo(p);ve(w)&&l.push({node:null,shadow:w},{node:w,shadow:null})}}};return e.sanitize=function(h){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,u=null,p=null,g=null;if(Ct=!h,Ct&&(h="<!-->"),typeof h!="string"&&!Oe(h)&&(h=In(h),typeof h!="string"))throw V("dirty is not a string, aborting");if(!e.isSupported)return h;wt?(S=$e,A=We):Mt(r),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(S=H(S)),C.uponSanitizeAttribute.length>0&&(A=H(A)),e.removed=[];const v=Tt&&typeof h!="string"&&Oe(h);if(v){Pi(h);const $=ft(h);if(typeof $=="string"){const B=M($);if(!S[B]||_e[B])throw Ye(h),V("root node is forbidden and cannot be sanitized in-place")}if(Je(h))throw Ye(h),V("root node is clobbered and cannot be sanitized in-place");try{_t(h)}catch(B){throw Ye(h),B}}else if(Oe(h))l=Ko("<!---->"),u=l.ownerDocument.importNode(h,!0),u.nodeType===U.element&&u.nodeName==="BODY"||u.nodeName==="HTML"?l=u:l.appendChild(u),_t(l);else{if(!me&&!ee&&!se&&h.indexOf("<")===-1)return F&&Ge?pe(h):h;if(l=Ko(h),!l)return me?null:Ge?re:""}l&&xt&&te(l.firstChild);const w=v?h:l;try{const $=Vo(w);for(;p=$.nextNode();)Xo(p,w),Qo(p,w),ve(p.content)&&et(p.content)}catch($){throw v&&(Ye(h),ne(e.removed,B=>{B.element&&Xe(B.element)})),$}if(v){let $=!1;if(ne(e.removed,B=>{B.element&&(B.element===h&&($=!0),Xe(B.element))}),$)throw V("a node selected for removal could not be safely returned; refusing to sanitize in place");return ee&&It(h),h}if(me){if(ee&&It(l),qe)for(g=fi.call(l.ownerDocument);l.firstChild;)g.appendChild(l.firstChild);else g=l;return(A.shadowroot||A.shadowrootmode)&&(g=bi.call(o,g,!0)),g}let L=se?l.outerHTML:l.innerHTML;return se&&S["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&O(Bn,l.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
525
+ `+L),ee&&(L=Ze(L)),F&&Ge?pe(L):L},e.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Mt(h),wt=!0,$e=S,We=A},e.clearConfig=function(){ye=null,wt=!1,$e=null,We=null,F=gt,re=""},e.isValidAttribute=function(h,r,l){ye||Mt({});const u=M(h),p=M(r);return Zo(u,p,l)},e.addHook=function(h,r){typeof r=="function"&&N(C,h)&&Te(C[h],r)},e.removeHook=function(h,r){if(N(C,h)){if(r!==void 0){const l=kn(C[h],r);return l===-1?void 0:Tn(C[h],l,1)[0]}return Xt(C[h])}},e.removeHooks=function(h){N(C,h)&&(C[h]=[])},e.removeAllHooks=function(){C=co()},e}var ze=uo();const Yn=["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","figure","figcaption","sup","sub","hr"],Xn={"*":["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"],ol:["start","reversed"],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"]},Zn="data-editora-embed";function Jn(a){if(!a||/\s/.test(a.trim()))return!1;try{const e=new URL(a.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function ho(a,e,t,o){if((e==null?void 0:e.sanitize)===!1)return a;const n=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:Yn,i=t!=null&&t.length?Array.from(new Set([...n,...t])):n,c=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:Xn,d=new Set;for(const T of Object.values(c))for(const y of T)d.add(y);const m={ALLOWED_TAGS:i,ALLOWED_ATTR:Array.from(d)};if(!o)return ze.sanitize(a,m);const f=i.includes("iframe");ze.addHook("uponSanitizeElement",(T,y)=>{var k;if(y.tagName!=="iframe")return;const E=T;y.allowedTags.iframe=f||((k=E.getAttribute)==null?void 0:k.call(E,Zn))==="true"&&Jn(E.getAttribute("src"))});try{return ze.sanitize(a,m)}finally{ze.removeHook("uponSanitizeElement")}}function po(a,e,t,o){return ho(a,e,o,!1)}function mo(a,e,t){return(t==null?void 0:t.sanitizeOnPaste)===!1?a:po(a,e)}function ct(a,e,t,o){return(t==null?void 0:t.sanitizeOnInput)===!1?a:ho(a,e,o,!0)}const Qn=".resize-handle, .table-resize-handle, [data-rte-media-pending]",ei=/resize-handle|data-rte-media-pending|rte-media/;function dt(a){if(!a||!ei.test(a))return a;const e=document.createElement("template");e.innerHTML=a;const t=new Set;return e.content.querySelectorAll(Qn).forEach(o=>{const n=o.parentElement;n&&(n.tagName==="TD"||n.tagName==="TH")&&t.add(n),o.remove()}),t.forEach(o=>{var n;o.style.position==="relative"&&(o.style.removeProperty("position"),(n=o.getAttribute("style"))!=null&&n.trim()||o.removeAttribute("style"))}),e.content.querySelectorAll("figure.rte-media").forEach(o=>{var i;o.removeAttribute("contenteditable");const n=o.querySelector(":scope > figcaption");n&&(n.removeAttribute("contenteditable"),!((i=n.textContent)!=null&&i.trim())&&!n.querySelector("img, video, a")&&n.remove())}),e.innerHTML}function ue(a){return a?dt(a.innerHTML):""}const Ue=class Ue{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 s=typeof t.toolbar=="object"&&t.toolbar?{...t.toolbar}:typeof t.toolbar=="string"?{items:t.toolbar}:{};t.toolbarFloating!==void 0&&(s.floating=!!t.toolbarFloating),t.toolbarSticky!==void 0&&(s.sticky=!!t.toolbarSticky),t.toolbar=s}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 s=typeof t.autosave=="object"&&t.autosave?{...t.autosave}:{};t.autosaveEnabled!==void 0&&(s.enabled=!!t.autosaveEnabled),t.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(t.autosaveIntervalMs)),t.autosaveStorageKey!==void 0&&(s.storageKey=t.autosaveStorageKey),t.autosaveProvider!==void 0&&(s.provider=t.autosaveProvider),t.autosaveApiUrl!==void 0&&(s.apiUrl=t.autosaveApiUrl),t.autosave=s}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 s={...o,...t.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=o.intervalMs),t.autosave=s}else t.autosave=o;if(t.languageLocale!==void 0||t.languageDirection!==void 0){const s=typeof t.language=="object"&&t.language?{...t.language}:{};t.languageLocale!==void 0&&(s.locale=t.languageLocale),t.languageDirection!==void 0&&(s.direction=t.languageDirection),t.language=s}const n={locale:"en",direction:"ltr"};if(typeof t.language=="string"?t.language={locale:t.language,direction:n.direction}:typeof t.language=="object"&&t.language?t.language={...n,...t.language}:t.language=n,t.spellcheckEnabled!==void 0||t.spellcheckProvider!==void 0||t.spellcheckApiUrl!==void 0){const s=typeof t.spellcheck=="object"&&t.spellcheck?{...t.spellcheck}:{};t.spellcheckEnabled!==void 0&&(s.enabled=!!t.spellcheckEnabled),t.spellcheckProvider!==void 0&&(s.provider=t.spellcheckProvider),t.spellcheckApiUrl!==void 0&&(s.apiUrl=t.spellcheckApiUrl),t.spellcheck=s}const i={enabled:!1,provider:"browser",apiUrl:""};if(typeof t.spellcheck=="boolean")t.spellcheck={...i,enabled:t.spellcheck};else if(typeof t.spellcheck=="object"&&t.spellcheck){const s={...i,...t.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),t.spellcheck=s}else t.spellcheck=i;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,n]of Object.entries(e)){const i=this.kebabToCamel(o);t[i]=this.BOOLEAN_ATTRIBUTES.has(o)&&(n===""||n===o)?!0:this.parseAttributeValue(n)}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[n,i]of Object.entries(o))i!=null&&(typeof i=="object"&&!Array.isArray(i)&&t[n]?t[n]=this.merge(t[n],i):t[n]=i);return t}};Ue.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},Ue.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 Fe=Ue;class fo{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 n=await o();return t&&this.applyPluginConfig(n,t),this.loadedPlugins.set(e,n),n}async loadMultiple(e,t){return(await Promise.all(e.map(n=>this.load(n,t)))).filter(n=>n!==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 go{constructor(e={}){this.changeListeners=[],this.options=e,this.engine=new Re({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 Pe({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 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 ti(a){return new go(a)}class bo{constructor(e){this.options=e,this.containerElement=e.element;const t=this.resolvePlugins(e.plugins);this.engine=new Re({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 Pe({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=n=>{t(n.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 oi='.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 He;const ni="__editoraCommandEditorRoot",ii="__editoraLastCommandButton",yo="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",vo=".rte-content, .editora-content",ri="Rich text editor",ut=new Set;let X=null,Eo=!1,ht=null,pt=null;function wo(a){if(!(a instanceof HTMLElement))return!1;const e=a;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function ai(a){return a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null}function Le(a){if(!a)return null;if(wo(a))return a;const e=a.matches(yo)?a:a.closest(yo);return!e||!wo(e)?null:e}function si(){var n;if(typeof window=="undefined")return null;const a=window[ni];if(a instanceof HTMLElement){const i=Le(a);if(i)return i;const s=a.matches(vo)?a:a.querySelector(vo);if(s){const c=Le(s);if(c)return c}}const e=window[ii];if(e instanceof HTMLElement){const i=Le(e);if(i)return i}const t=document.activeElement;if(t){const i=Le(t);if(i)return i}const o=(n=window.getSelection)==null?void 0:n.call(window);if(o&&o.rangeCount>0){const i=Le(ai(o.getRangeAt(0).startContainer));if(i)return i}if(X&&X.isConnected)return X;for(const i of ut)if(i.isConnected)return i;return null}function li(){if(typeof window=="undefined"||Eo)return;ht=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,pt=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const a=(e,...t)=>{const o=si();return o?o.execCommand(e,...t):ht?ht(e,...t):pt?pt(e,...t):!1};window.executeEditorCommand=a,window.execEditorCommand=a,Eo=!0}function ci(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const e=document.createElement("style");e.id=a,e.textContent=oi,document.head.appendChild(e)}}function di(){if(!He){const a=Z.__globalPluginLoader;a?He=a:He=new fo}return He}class Z extends HTMLElement{constructor(){if(super(),this.pluginLoader=di(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Pt,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,this.pendingHistorySnapshot=null,ci(),!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","aria-label","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(Z.__globalPluginLoader){this.pluginLoader=Z.__globalPluginLoader;return}return new Promise(e=>{const t=()=>{Z.__globalPluginLoader?(this.pluginLoader=Z.__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 n;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),ut.add(this),X||(X=this),li(),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();if(this.loadedPlugins=e,e.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const i=this.innerHTML.trim();i&&this.setAttribute("data-initial-content",i)}const t=this.preservedContent;this.preservedContent=null;const o=this.sanitizeLoadedContent((n=t!=null?t:this.restoreAutosavedContent())!=null?n:this.getAttribute("data-initial-content")||"");this.engine=new Re({content:o,plugins:e,readonly:this.config.readonly}),this.createUI(e,o),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),n=this.getAccessibilityConfig().checker===!0;if(t){if(typeof this.config.plugins=="string"){const i=this.config.plugins.split(/\s+/).filter(Boolean);n&&!i.includes("a11yChecker")&&i.push("a11yChecker");for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&e.push(c)}}else if(Array.isArray(this.config.plugins)){for(const i of this.config.plugins)if(typeof i=="string"){const s=await this.pluginLoader.load(i,this.getPluginLoadConfig(i));s&&e.push(s)}else e.push(i);if(n&&!e.some(i=>(i==null?void 0:i.name)==="a11yChecker")){const i=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));i&&e.push(i)}}}else{const i=this.pluginLoader.getRegisteredPluginNames();for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&e.push(c)}}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(){var t;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 o=(t=this.getAttribute("aria-label"))==null?void 0:t.trim(),n=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||n||ri)}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 i;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},n=this.loadedPlugins.find(s=>s.commands&&s.commands[e]);if(n&&n.commands){const s=n.commands[e];if(typeof s=="function")try{return e==="toggleFullscreen"?s(this,o):s(...t,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${e}:`,c),!1}}return((i=this.engine)==null?void 0:i.execCommand(e,...t))||!1}getPluginLoadConfig(e){const t=this.config.pluginConfig;if(t&&typeof t=="object"){const i=t[e];if(i&&typeof i=="object")return i}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=[e,e.toLowerCase(),...o[e]||[]];for(const i of n){const s=this.config[i];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}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}}sanitizeLoadedContent(e){return ct(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}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 n=Number((o=(t=e.intervalMs)!=null?t:e.interval)!=null?o:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(n)&&n>0?n: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(()=>{this.persistAutosave(ue(this.contentElement))},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 n=document.createElement("div");n.innerHTML=e;const i=document.createDocumentFragment();for(;n.firstChild;)i.appendChild(n.firstChild);o.insertNode(i),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"]'),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 Pe({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((i,s)=>{var c;if(this.contentElement){this.contentElement.focus();const d=window.getSelection();if(!d||d.rangeCount===0||!this.contentElement.contains(d.anchorNode)){const m=document.createRange(),f=this.contentElement.lastChild||this.contentElement;f.nodeType===Node.TEXT_NODE?m.setStart(f,((c=f.textContent)==null?void 0:c.length)||0):f.nodeType===Node.ELEMENT_NODE?(m.selectNodeContents(f),m.collapse(!1)):m.setStart(this.contentElement,0),m.collapse(!0),d==null||d.removeAllRanges(),d==null||d.addRange(m)}}return this.executeCommand(i,s)}),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(i){console.warn("defaultParagraphSeparator not supported:",i)}if(t){const i=document.createElement("div");i.innerHTML=t.trim(),!Array.from(i.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const d=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(d)}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 Ht({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 Ut({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var i;return(i=this.contentElement)==null?void 0:i.focus()},0)}recordInputHistory(e){const t=this.pendingHistorySnapshot;if(this.pendingHistorySnapshot=null,!t||!this.contentElement||t.beforeHTML===e)return;const o=window.execEditorCommand;typeof o=="function"&&o("recordDomTransaction",this.contentElement,t.beforeHTML,e,{inputType:t.inputType,data:t.data,selectionCollapsed:t.selectionCollapsed})}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{var n,i;this.lastBeforeInputType=o.inputType||null,o.inputType==="historyUndo"||o.inputType==="historyRedo"?this.pendingHistorySnapshot=null:this.contentElement&&(this.pendingHistorySnapshot={beforeHTML:this.contentElement.innerHTML,inputType:o.inputType||null,data:typeof o.data=="string"?o.data:null,selectionCollapsed:(i=(n=window.getSelection())==null?void 0:n.isCollapsed)!=null?i:!0})}),this.contentElement.addEventListener("input",o=>{var y;if(!this.contentElement)return;let n=this.contentElement.innerHTML;const i=(y=o==null?void 0:o.detail)==null?void 0:y.allowedTags,s=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),d=this.getSecurityConfig(),m=this.lastBeforeInputType;if(this.lastBeforeInputType=null,d.sanitizeOnInput!==!1&&c.sanitize!==!1&&!m){const E=ct(n,c,d,i);if(E!==n){const k=window.getSelection(),J=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=E,J&&k)try{k.removeAllRanges(),k.addRange(J)}catch(R){}n=E}}this.recordInputHistory(n),this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:dt(n)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,s.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 f,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const n=this.config.paste||{};let i=((f=o.clipboardData)==null?void 0:f.getData("text/html"))||"";const s=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),d=this.getSecurityConfig(),m=!!i&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);if((n.clean||!n.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(n.convertWord===!1&&m&&s){document.execCommand("insertText",!1,s);return}if(i){d.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(i=mo(i,c,d)),this.insertHTMLAtSelection(i);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{X=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:ue(this.contentElement)},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,(i,s)=>{this.executeCommand(i,s)})});const t=()=>{const o=this.getSelectionRangeInEditor(),n=document.activeElement,i=!!n&&!!this.contentElement&&(n===this.contentElement||this.contentElement.contains(n));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!i||!o&&!i||(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(i=>i.width>0||i.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.isReadonlyAttribute(this.getAttribute("readonly"))||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 n=this.getSelectionRangeInEditor();if(!n){this.floatingToolbar.hide();return}if(n.collapsed){this.floatingToolbar.hide();return}const i=window.getSelection();if(!i){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(i,n);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.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:n,chars:i}=Wt(o),s=$t(this.contentElement);let c,d;const m=this.getSelectionRangeInEditor();m&&(c=Bt(this.contentElement,m),m.collapsed||(d=qt(m,c),c=void 0)),this.statusBar.update({wordCount:n,charCount:i,lineCount:s,cursorPosition:c,selectionInfo:d})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,t){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(t)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(t));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"aria-label":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 Fe.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>ue(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(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,n;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=ue(this.contentElement),this.persistAutosave(this.preservedContent)),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(),(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,ut.delete(this),X===this&&(X=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return ue(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(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 ui(a){return new bo(a)}function hi(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",Z)}b.CharacterDialog=pn,b.ColorPicker=ln,b.CommandRegistry=Ft,b.ConfigResolver=Fe,b.Dialog=oe,b.DocumentModel=ke,b.Dropdown=sn,b.Editor=on,b.EditorEngine=Re,b.EditorState=W,b.EmojiDialog=mn,b.FloatingToolbar=Ht,b.ImageDialog=un,b.KeyboardShortcutManager=Pt,b.LinkDialog=cn,b.MathDialog=hn,b.MediaPlugin=an,b.PluginLoader=fo,b.PluginManager=xe,b.PluginRuntime=Rt,b.ReactAdapter=go,b.RichTextEditorElement=Z,b.Schema=Ot,b.SpellcheckPlugin=rn,b.StatusBar=Ut,b.TableDialog=dn,b.ToolbarRenderer=Pe,b.VanillaAdapter=bo,b.calculateTextStats=Wt,b.countLines=$t,b.createEditor=ui,b.createPluginManager=tn,b.createPluginRuntime=nn,b.createReactAdapter=ti,b.getCleanEditorHTML=ue,b.getCursorPosition=Bt,b.getSelectionInfo=qt,b.getTextOffset=jt,b.initWebComponent=hi,b.sanitizeHTML=po,b.sanitizeInputHTML=ct,b.sanitizePastedHTML=mo,b.stripEditorUiArtifacts=dt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
526
526
  //# sourceMappingURL=editora.umd.js.map