@editora/core 1.0.33 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/core",
3
- "version": "1.0.33",
3
+ "version": "1.1.0",
4
4
  "description": "Framework-agnostic rich text editor (WYSIWYG) with a plugin system, an accessible toolbar and TypeScript types. Works in plain JavaScript, React and any other framework.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",
@@ -1,12 +0,0 @@
1
- "use strict";class It{constructor(t,e,o){this.doc=t,this.selection=e,this.schema=o}static create(t,e){const o=e||t.node("doc",{},[t.node("paragraph")]);return new It(o,{anchor:0,head:0},t)}apply(t,e){return new It(t,e||this.selection,this.schema)}}class Lo{constructor(t,e){this.nodes=new Map(Object.entries(t)),this.marks=new Map(Object.entries(e))}node(t,e,o){return{type:t,attrs:e,content:o}}text(t,e){return{type:"text",text:t,marks:e}}}class _e{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(t,e){this.plugins.push(t),e&&this.pluginConfigs.set(t.name,e);const o=this.pluginConfigs.get(t.name)||t.config;if(t.initialize)try{t.initialize(o)}catch(i){console.error(`Failed to initialize plugin "${t.name}":`,i)}if(t.init&&t.init!==t.initialize)try{t.init(o)}catch(i){console.error(`Failed to run init hook for plugin "${t.name}":`,i)}}unregister(t){const e=this.plugins.findIndex(o=>o.name===t);if(e>-1){const o=this.plugins[e];o.destroy&&o.destroy(),this.plugins.splice(e,1),this.pluginConfigs.delete(t)}}getPlugin(t){return this.plugins.find(e=>e.name===t)}getPluginConfig(t){return this.pluginConfigs.get(t)}buildSchema(){const t={},e={};return this.plugins.forEach(o=>{o.nodes&&Object.assign(t,o.nodes),o.marks&&Object.assign(e,o.marks)}),new Lo(t,e)}getCommands(){const t={};return this.plugins.forEach(e=>{e.commands&&Object.assign(t,e.commands)}),t}getToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}async executePluginCommand(t,e,...o){const i=this.getPlugin(t);if(!i)throw new Error(`Plugin not found: ${t}`);const r=this.getPluginConfig(t)||i.config||{},l=r.mode||"local";try{switch(l){case"local":return i.executeLocal?i.executeLocal(e,...o):null;case"api":if(!i.executeAPI)throw new Error(`Plugin ${t} does not support API mode`);return await i.executeAPI(e,...o);case"hybrid":if(i.executeHybrid)return await i.executeHybrid(e,...o);try{if(i.executeAPI)return await i.executeAPI(e,...o)}catch(c){if(console.warn(`API execution failed for ${t}, falling back to local`,c),i.executeLocal&&r.fallbackToLocal!==!1)return i.executeLocal(e,...o);throw c}break;default:throw new Error(`Unknown plugin mode: ${l}`)}}catch(c){throw console.error(`Error executing command ${e} on plugin ${t}:`,c),c}}async destroyAll(){const t=this.plugins.filter(e=>e.destroy).map(e=>e.destroy());await Promise.all(t),this.plugins=[],this.pluginConfigs.clear()}}function Cn(){return new _e}class Mo{constructor(t){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(t==null?void 0:t.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),t!=null&&t.shortcuts&&t.shortcuts.forEach(e=>this.registerShortcut(e)),t!=null&&t.customShortcuts&&Object.values(t.customShortcuts).forEach(e=>{this.registerShortcut(e)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let t=1;t<=6;t++)this.registerShortcut({key:String(t),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${t}`,description:`Heading ${t}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.set(e,t)}unregisterShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.delete(e)}getShortcutKey(t){const e=[];return t.ctrl&&e.push("ctrl"),t.alt&&e.push("alt"),t.shift&&e.push("shift"),t.meta&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}getEventKey(t){const e=[];return t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}handleKeyDown(t,e){if(!this.enabled)return!1;const o=this.getEventKey(t),i=this.shortcuts.get(o);return i?(i.preventDefault!==!1&&(t.preventDefault(),t.stopPropagation()),e(i.command,i.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(t){return Array.from(this.shortcuts.values()).find(e=>e.command===t)}getShortcutDescription(t){const e=[];this.isMac?(t.meta&&e.push("⌘"),t.ctrl&&e.push("⌃"),t.alt&&e.push("⌥"),t.shift&&e.push("⇧")):(t.ctrl&&e.push("Ctrl"),t.alt&&e.push("Alt"),t.shift&&e.push("Shift"));const o=t.key.length===1?t.key.toUpperCase():t.key;return e.push(o),e.join("+")}getShortcutsHelp(){const t=this.getAllShortcuts(),e=new Map;t.forEach(i=>{const r=this.getShortcutCategory(i.command);e.has(r)||e.set(r,[]),e.get(r).push(i)});let o=`# Keyboard Shortcuts
2
-
3
- `;return e.forEach((i,r)=>{o+=`## ${r}
4
-
5
- `,i.forEach(l=>{const c=this.getShortcutDescription(l);o+=`- **${c}**: ${l.description||l.command}
6
- `}),o+=`
7
- `}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}class Io{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Do{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new _e,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=It.create(e),this.commandRegistry=new Io(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let i;return e.length===0?i=o(this.state):e.length===1?i=o(this.state,e[0]):i=o(this.state,...e),i instanceof Promise?(i.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&(this.setState(r),this.emit("change",this.state))}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const i=o.indexOf(e);i>-1&&o.splice(i,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(i=>{try{i(...e)}catch(r){console.error(`Error in ${t} handler:`,r)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class Oo{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var l,c;if(!this.expandedOpen)return;const r=i.target;r&&((l=this.moreButton)!=null&&l.contains(r)||(c=this.expandedRow)!=null&&c.contains(r))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),i=this.getAvailableToolbarItems(),r=new Map;i.forEach(c=>{c.command&&r.set(c.command,c),c.type==="group"&&c.label&&r.set(c.label,c)});const l={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 f=[];c.split(/\s+/).filter(Boolean).forEach(g=>{if(g==="direction"){const v=r.get("setDirectionLTR"),k=r.get("setDirectionRTL");v&&f.push({id:"directionLTR",label:v.label,command:v.command,icon:v.icon,type:v.type||"button",options:v.options}),k&&f.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(g==="comments"){const v=r.get("addComment"),k=r.get("toggleComments");v&&f.push({id:"addComment",label:v.label,command:v.command,icon:v.icon,type:v.type||"button",options:v.options}),k&&f.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=l[g]||g;let w=r.get(T);w||(w=r.get(g)),w&&f.push({id:g,label:w.label,command:w.command,icon:w.icon,type:w.type==="separator"?"separator":w.type||"button",options:w.options,items:w.items})}),f.length>0&&e.push(f)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(o);i.forEach((r,l)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",r.forEach(f=>{this.appendToolbarButton(c,f);const m=c.lastElementChild;m instanceof HTMLElement&&(this.overflowUnits.push(m),this.overflowUnitHomes.set(m,c))}),e.appendChild(c),l<i.length-1){const f=document.createElement("div");f.className="editora-toolbar-separator",e.appendChild(f)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){const e=this.itemsContainer;if(!e||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,t.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const r=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(B=>{var O;B.parentElement===i&&((O=this.overflowUnitHomes.get(B))==null||O.appendChild(B))});const f=t.clientWidth,m=16,g=40,T=4,w=Math.max(0,f-m),v=Math.max(0,w-g-T),k=getComputedStyle(t).direction==="rtl",tt=e.getBoundingClientRect(),$=B=>{const O=B.getBoundingClientRect();return k?tt.right-O.left:O.right-tt.left};let z=0;if($(c[c.length-1])<=w)z=c.length;else for(const B of c)if($(B)<=v)z++;else break;z=Math.max(1,Math.min(z,c.length));const lt=z<c.length;o.style.display=lt?"":"none",o.classList.toggle("active",lt&&this.expandedOpen),!lt&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((B,O)=>{O>=z&&i.appendChild(B)})},l=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(r)};this.resizeObserver=new ResizeObserver(()=>l()),this.resizeObserver.observe(t),l()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${o}`,t.items.forEach(r=>{this.appendToolbarButton(i,r)}),e.appendChild(i)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.setAttribute("aria-label",t.label),e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}makeMenuAccessible(t,e,o,i){e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),o.setAttribute("role","menu"),o.setAttribute("aria-label",i),o.querySelectorAll(".editora-toolbar-dropdown-item").forEach(m=>{m.setAttribute("role","menuitem"),m.tabIndex=-1});const r=()=>Array.from(o.querySelectorAll('[role="menuitem"]')),l=()=>o.style.display==="block",c=new MutationObserver(()=>{e.setAttribute("aria-expanded",l()?"true":"false")});c.observe(o,{attributes:!0,attributeFilter:["style"]});const f=t._cleanupDropdown;t._cleanupDropdown=()=>{c.disconnect(),f==null||f()},e.addEventListener("click",m=>{var g;m.detail===0&&l()&&((g=r()[0])==null||g.focus())}),e.addEventListener("keydown",m=>{var T;if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;m.preventDefault(),l()||e.click();const g=r();(T=m.key==="ArrowUp"?g[g.length-1]:g[0])==null||T.focus()}),o.addEventListener("keydown",m=>{const g=r();if(g.length===0)return;const T=g.indexOf(document.activeElement),w=v=>{m.preventDefault(),g[(v+g.length)%g.length].focus()};switch(m.key){case"ArrowDown":return w(T+1);case"ArrowUp":return w(T<0?g.length-1:T-1);case"Home":return w(0);case"End":return w(g.length-1);case"Escape":m.preventDefault(),m.stopPropagation(),o.style.display="none",e.focus();return;case"Tab":o.style.display="none";return}})}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const f=document.createElement("button");f.className="editora-toolbar-dropdown-item",f.type="button",f.textContent=c.label,f.setAttribute("data-value",c.value),f.addEventListener("click",m=>{m.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(f)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const f=i.style.display==="block";i.style.display=f?"none":"block"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const f=document.createElement("button");f.className="editora-toolbar-dropdown-item",f.type="button",f.textContent=c.label,f.setAttribute("data-value",c.value),f.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(f)}),o.addEventListener("click",c=>{var m;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const f=(m=this.container)==null?void 0:m.querySelectorAll(".editora-toolbar-dropdown-menu");f==null||f.forEach(g=>{g!==i&&(g.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),this.makeMenuAccessible(e,o,i,t.label),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const i=o._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Ro{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class No{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const r=this.statusInfo.selectionInfo;r.startLine===r.endLine&&r.startColumn===r.endColumn?o.push(`Ln ${r.startLine}, Col ${r.startColumn}`):(r.startLine===r.endLine?o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`):o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`),o.push(`${r.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const r=this.statusInfo.cursorPosition;o.push(`Ln ${r.line}, Col ${r.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const i=[];this.statusInfo.wordCount!==void 0&&i.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&i.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&i.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([r,l])=>{i.push(`${r}: ${l}`)}),o.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,t.appendChild(c),l<o.length-1){const f=document.createElement("span");f.className="editora-statusbar-separator",f.textContent="|",t.appendChild(f)}}),i.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,e.appendChild(c),l<i.length-1){const f=document.createElement("span");f.className="editora-statusbar-separator",f.textContent="|",e.appendChild(f)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Po(a,t){const e=a.textContent||"",o=zo(a,t.startContainer,t.startOffset),r=e.substring(0,o).split(`
8
- `),l=r.length,c=r[r.length-1].length+1;return{line:l,column:c}}function zo(a,t,e){var l;let o=0;const i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let r=i.firstChild();for(;r;){if(r===t){o+=e;break}else r.nodeType===Node.TEXT_NODE&&(o+=((l=r.textContent)==null?void 0:l.length)||0);r=i.nextNode()}return o}function Bo(a){var o,i;const t=a.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const r=t[t.length-1];(r.tagName==="BR"||((o=r.innerHTML)==null?void 0:o.trim())===""||((i=r.textContent)==null?void 0:i.trim())==="")&&e++}else{const l=(a.textContent||"").split(`
9
- `).length;e=Math.max(1,l)}return e}function Ho(a){const t=a.trim()?a.trim().split(/\s+/).length:0,e=a.length;return{words:t,chars:e}}function Fo(a,t){const e=a.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function lo(a,t){(t==null||t>a.length)&&(t=a.length);for(var e=0,o=Array(t);e<t;e++)o[e]=a[e];return o}function An(a){if(Array.isArray(a))return a}function Sn(a,t){var e=a==null?null:typeof Symbol!="undefined"&&a[Symbol.iterator]||a["@@iterator"];if(e!=null){var o,i,r,l,c=[],f=!0,m=!1;try{if(r=(e=e.call(a)).next,t!==0)for(;!(f=(o=r.call(e)).done)&&(c.push(o.value),c.length!==t);f=!0);}catch(g){m=!0,i=g}finally{try{if(!f&&e.return!=null&&(l=e.return(),Object(l)!==l))return}finally{if(m)throw i}}return c}}function _n(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
10
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ln(a,t){return An(a)||Sn(a,t)||Mn(a,t)||_n()}function Mn(a,t){if(a){if(typeof a=="string")return lo(a,t);var e={}.toString.call(a).slice(8,-1);return e==="Object"&&a.constructor&&(e=a.constructor.name),e==="Map"||e==="Set"?Array.from(a):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?lo(a,t):void 0}}const Uo=Object.entries,co=Object.setPrototypeOf,In=Object.isFrozen,Dn=Object.getPrototypeOf,On=Object.getOwnPropertyDescriptor;let M=Object.freeze,I=Object.seal,Et=Object.create,jo=typeof Reflect!="undefined"&&Reflect,xe=jo.apply,Ce=jo.construct;M||(M=function(t){return t});I||(I=function(t){return t});xe||(xe=function(t,e){for(var o=arguments.length,i=new Array(o>2?o-2:0),r=2;r<o;r++)i[r-2]=arguments[r];return t.apply(e,i)});Ce||(Ce=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return new t(...o)});const rt=L(Array.prototype.forEach),Rn=L(Array.prototype.lastIndexOf),uo=L(Array.prototype.pop),At=L(Array.prototype.push),Nn=L(Array.prototype.splice),vt=Array.isArray,Mt=L(String.prototype.toLowerCase),me=L(String.prototype.toString),fo=L(String.prototype.match),St=L(String.prototype.replace),po=L(String.prototype.indexOf),Pn=L(String.prototype.trim),zn=L(Number.prototype.toString),Bn=L(Boolean.prototype.toString),ho=typeof BigInt=="undefined"?null:L(BigInt.prototype.toString),mo=typeof Symbol=="undefined"?null:L(Symbol.prototype.toString),P=L(Object.prototype.hasOwnProperty),_t=L(Object.prototype.toString),D=L(RegExp.prototype.test),Q=Hn(TypeError);function L(a){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return xe(a,t,o)}}function Hn(a){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return Ce(a,e)}}function E(a,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(co&&co(a,null),!vt(t))return a;let o=t.length;for(;o--;){let i=t[o];if(typeof i=="string"){const r=e(i);r!==i&&(In(t)||(t[o]=r),i=r)}a[i]=!0}return a}function Fn(a){for(let t=0;t<a.length;t++)P(a,t)||(a[t]=null);return a}function U(a){const t=Et(null);for(const o of Uo(a)){var e=Ln(o,2);const i=e[0],r=e[1];P(a,i)&&(vt(r)?t[i]=Fn(r):r&&typeof r=="object"&&r.constructor===Object?t[i]=U(r):t[i]=r)}return t}function Un(a){switch(typeof a){case"string":return a;case"number":return zn(a);case"boolean":return Bn(a);case"bigint":return ho?ho(a):"0";case"symbol":return mo?mo(a):"Symbol()";case"undefined":return _t(a);case"function":case"object":{if(a===null)return _t(a);const t=a,e=W(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:_t(o)}return _t(a)}default:return _t(a)}}function W(a,t){for(;a!==null;){const o=On(a,t);if(o){if(o.get)return L(o.get);if(typeof o.value=="function")return L(o.value)}a=Dn(a)}function e(){return null}return e}function jn(a){try{return D(a,""),!0}catch(t){return!1}}const go=M(["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"]),ge=M(["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"]),be=M(["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"]),Wn=M(["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"]),ye=M(["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"]),$n=M(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bo=M(["#text"]),yo=M(["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"]),Ee=M(["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"]),Eo=M(["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"]),Kt=M(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Gn=I(/{{[\w\W]*|^[\w\W]*}}/g),Kn=I(/<%[\w\W]*|^[\w\W]*%>/g),Yn=I(/\${[\w\W]*/g),qn=I(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vn=I(/^aria-[\-\w]+$/),vo=I(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xn=I(/^(?:\w+script|data):/i),Qn=I(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zn=I(/^html$/i),Jn=I(/^[a-z][.\w]*(-[.\w]+)+$/i),To=I(/<[/\w!]/g),wo=I(/<[/\w]/g),ti=I(/<\/no(script|embed|frames)/i),ei=I(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Wo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],oi=M(E({},Wo)),ni=(function(){const a={};return rt(Wo,t=>{a[t]=I(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),M(a)})(),ii=function(){return typeof window=="undefined"?null:window},ri=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(o=e.getAttribute(i));const r="dompurify"+(o?"#"+o:"");try{return t.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch(l){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ko=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Z=function(t,e,o,i){return P(t,e)&&vt(t[e])?E(i.base?U(i.base):{},t[e],i.transform):o},ve=function(t,e,o){const i=P(t,e)?t[e]:void 0;return i&&typeof i=="object"?U(i):o()};function $o(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ii();const t=u=>$o(u);if(t.version="3.4.16",t.removed=[],!a||!a.document||a.document.nodeType!==F.document||!a.Element)return t.isSupported=!1,t;let e=a.document;const o=e,i=o.currentScript;a.DocumentFragment;const r=a.HTMLTemplateElement,l=a.Node,c=a.Element,f=a.NodeFilter;a.NamedNodeMap===void 0&&(a.NamedNodeMap||a.MozNamedAttrMap),a.HTMLFormElement;const m=a.DOMParser,g=a.trustedTypes,T=c.prototype,w=W(T,"cloneNode"),v=W(T,"remove"),k=W(T,"removeAttributeNode"),tt=W(T,"nextSibling"),$=W(T,"childNodes"),z=W(T,"parentNode"),lt=W(T,"shadowRoot"),B=W(T,"attributes"),O=l&&l.prototype?W(l.prototype,"nodeType"):null,ct=l&&l.prototype?W(l.prototype,"nodeName"):null,Dt=l&&l.prototype?W(l.prototype,"ownerDocument"):null,Tt=function(n){return O?O(n):n.nodeType},Qt=function(n){return ct?ct(n):n.nodeName};if(typeof r=="function"){const u=e.createElement("template");u.content&&u.content.ownerDocument&&(e=u.content.ownerDocument)}let N,et="",Zt,Me=!1,wt=0;const Ie=function(){if(wt>0)throw Q('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.')},dt=function(n){Ie(),wt++;try{return N.createHTML(n)}finally{wt--}},Xo=function(n){Ie(),wt++;try{return N.createScriptURL(n)}finally{wt--}},Qo=function(){return Me||(Zt=ri(g,i),Me=!0),Zt},Ot=e,Jt=Ot.implementation,De=Ot.createNodeIterator,Zo=Ot.createDocumentFragment,Jo=Ot.getElementsByTagName,tn=o.importNode;let x=ko();t.isSupported=typeof Uo=="function"&&typeof z=="function"&&Jt&&Jt.createHTMLDocument!==void 0;const en=Gn,on=Kn,nn=Yn,rn=qn,an=Vn,sn=Xn,Oe=Qn,ln=Jn;let Re=vo,C=null;const te=E({},[...go,...ge,...be,...ye,...bo]);let A=null;const ee=E({},[...yo,...Ee,...Eo,...Kt]);let G=Object.seal(Et(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}})),kt=null,Ne=null;const q=Object.seal(Et(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pe=!0,oe=!0,ze=!1,Be=!0,V=!1,ot=!0,nt=!1,ne=!1,Rt=null,Nt=null,ie=!1,ut=!1,Pt=!1,zt=!1,He=!0,Fe=!1;const Ue="user-content-";let re=!0,ae=!1,ft={},pt=null;const je=E({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let We=null;const $e=E({},["audio","video","img","source","image","track"]);let Ge=null;const Ke=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Bt="http://www.w3.org/1998/Math/MathML",Ht="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let ht=K,se=!1,le=null;const cn=E({},[Bt,Ht,K],me),Ye=M(["mi","mo","mn","ms","mtext"]);let ce=E({},Ye);const qe=M(["annotation-xml"]);let de=E({},qe);const dn=E({},["title","style","font","a","script"]);let xt=null;const un=["application/xhtml+xml","text/html"],fn="text/html";let _=null,mt=null;const pn=e.createElement("form"),Ve=function(n){return n instanceof RegExp||n instanceof Function},ue=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(mt&&mt===n)return;(!n||typeof n!="object")&&(n={}),n=U(n),xt=un.indexOf(n.PARSER_MEDIA_TYPE)===-1?fn:n.PARSER_MEDIA_TYPE,_=xt==="application/xhtml+xml"?me:Mt,C=Z(n,"ALLOWED_TAGS",te,{transform:_}),A=Z(n,"ALLOWED_ATTR",ee,{transform:_}),le=Z(n,"ALLOWED_NAMESPACES",cn,{transform:me}),Ge=Z(n,"ADD_URI_SAFE_ATTR",Ke,{transform:_,base:Ke}),We=Z(n,"ADD_DATA_URI_TAGS",$e,{transform:_,base:$e}),pt=Z(n,"FORBID_CONTENTS",je,{transform:_}),kt=Z(n,"FORBID_TAGS",U({}),{transform:_}),Ne=Z(n,"FORBID_ATTR",U({}),{transform:_}),ft=P(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?U(n.USE_PROFILES):n.USE_PROFILES:!1,Pe=n.ALLOW_ARIA_ATTR!==!1,oe=n.ALLOW_DATA_ATTR!==!1,ze=n.ALLOW_UNKNOWN_PROTOCOLS||!1,Be=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,V=n.SAFE_FOR_TEMPLATES||!1,ot=n.SAFE_FOR_XML!==!1,nt=n.WHOLE_DOCUMENT||!1,ut=n.RETURN_DOM||!1,Pt=n.RETURN_DOM_FRAGMENT||!1,zt=n.RETURN_TRUSTED_TYPE||!1,ie=n.FORCE_BODY||!1,He=n.SANITIZE_DOM!==!1,Fe=n.SANITIZE_NAMED_PROPS||!1,re=n.KEEP_CONTENT!==!1,ae=n.IN_PLACE||!1,Re=jn(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:vo,ht=typeof n.NAMESPACE=="string"?n.NAMESPACE:K,ce=ve(n,"MATHML_TEXT_INTEGRATION_POINTS",()=>E({},Ye)),de=ve(n,"HTML_INTEGRATION_POINTS",()=>E({},qe));const s=ve(n,"CUSTOM_ELEMENT_HANDLING",()=>Et(null));if(G=Et(null),P(s,"tagNameCheck")&&Ve(s.tagNameCheck)&&(G.tagNameCheck=s.tagNameCheck),P(s,"attributeNameCheck")&&Ve(s.attributeNameCheck)&&(G.attributeNameCheck=s.attributeNameCheck),P(s,"allowCustomizedBuiltInElements")&&typeof s.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=s.allowCustomizedBuiltInElements),I(G),V&&(oe=!1),Pt&&(ut=!0),ft&&(C=E({},bo),A=Et(null),ft.html===!0&&(E(C,go),E(A,yo)),ft.svg===!0&&(E(C,ge),E(A,Ee),E(A,Kt)),ft.svgFilters===!0&&(E(C,be),E(A,Ee),E(A,Kt)),ft.mathMl===!0&&(E(C,ye),E(A,Eo),E(A,Kt))),q.tagCheck=null,q.attributeCheck=null,P(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?q.tagCheck=n.ADD_TAGS:vt(n.ADD_TAGS)&&(C===te&&(C=U(C)),E(C,n.ADD_TAGS,_))),P(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?q.attributeCheck=n.ADD_ATTR:vt(n.ADD_ATTR)&&(A===ee&&(A=U(A)),E(A,n.ADD_ATTR,_))),P(n,"ADD_FORBID_CONTENTS")&&vt(n.ADD_FORBID_CONTENTS)&&(pt===je&&(pt=U(pt)),E(pt,n.ADD_FORBID_CONTENTS,_)),re&&(C["#text"]=!0),nt&&E(C,["html","head","body"]),C.table&&(E(C,["tbody"]),delete kt.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw Q('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Q('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=N;N=n.TRUSTED_TYPES_POLICY;try{et=dt("")}catch(p){throw N=d,p}}else n.TRUSTED_TYPES_POLICY===null?(N=void 0,et=""):(N===void 0&&(N=Qo()),N&&typeof et=="string"&&(et=dt("")));M&&M(n),mt=n},Xe=E({},[...ge,...be,...Wn]),Qe=E({},[...ye,...$n]),hn=function(n,s,d){return s.namespaceURI===K?n==="svg":s.namespaceURI===Bt?n==="svg"&&(d==="annotation-xml"||ce[d]):!!Xe[n]},mn=function(n,s,d){return s.namespaceURI===K?n==="math":s.namespaceURI===Ht?n==="math"&&de[d]:!!Qe[n]},gn=function(n,s,d){return s.namespaceURI===Ht&&!de[d]||s.namespaceURI===Bt&&!ce[d]?!1:!Qe[n]&&(dn[n]||!Xe[n])},bn=function(n){let s=z(n);(!s||!s.tagName)&&(s={namespaceURI:ht,tagName:"template"});const d=Mt(n.tagName),p=Mt(s.tagName);return le[n.namespaceURI]?n.namespaceURI===Ht?hn(d,s,p):n.namespaceURI===Bt?mn(d,s,p):n.namespaceURI===K?gn(d,s,p):!!(xt==="application/xhtml+xml"&&le[n.namespaceURI]):!1},X=function(n){At(t.removed,{element:n});try{z(n).removeChild(n)}catch(s){if(v(n),!z(n))throw Q("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ze=function(n,s,d){try{k(n,s)}catch(p){try{n.removeAttribute(d)}catch(h){}}},Ft=function(n){Ut(n);const s=$(n);if(s){const p=[];rt(s,h=>{At(p,h)}),rt(p,h=>{try{v(h)}catch(b){}})}const d=B(n);if(d)for(let p=d.length-1;p>=0;--p){const h=d[p],b=h&&h.name;typeof b=="string"&&Ze(n,h,b)}},it=function(n,s,d){if(!d)try{d=s.getAttributeNode(n)}catch(p){d=null}At(t.removed,{attribute:d||null,from:s});try{d?k(s,d):s.removeAttribute(n)}catch(p){try{s.removeAttribute(n)}catch(h){}}if(n==="is")if(ut||Pt)try{X(s)}catch(p){}else try{s.setAttribute(n,"")}catch(p){}},yn=function(n){const s=B(n);if(s)for(let d=s.length-1;d>=0;--d){const p=s[d],h=p&&p.name;typeof h!="string"||A[_(h)]||Ze(n,p,h)}},Ut=function(n){const s=[n];for(;s.length>0;){const d=s.pop();Tt(d)===F.element&&yn(d);const p=$(d);if(p)for(let h=p.length-1;h>=0;--h)s.push(p[h])}},Je=function(n,s){return ot?n==="patchsrc"?!0:n==="for"&&s!=="label"&&s!=="output":!1},En=function(n){if(!ot)return;const s=[n];for(;s.length>0;){const d=s.pop(),p=Tt(d);if(p===F.processingInstruction||p===F.comment&&D(wo,d.data)){try{v(d)}catch(b){}continue}if(p===F.element){const b=d,y=_(Qt(d));try{b.hasAttribute&&b.hasAttribute("patchsrc")&&b.removeAttribute("patchsrc"),b.hasAttribute&&b.hasAttribute("for")&&Je("for",y)&&b.removeAttribute("for")}catch(S){}}const h=$(d);if(h)for(let b=h.length-1;b>=0;--b)s.push(h[b])}},to=function(n){let s=null,d=null;if(ie)n="<remove></remove>"+n;else{const b=fo(n,/^[\r\n\t ]+/);d=b&&b[0]}xt==="application/xhtml+xml"&&ht===K&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const p=N?dt(n):n;if(ht===K)try{s=new m().parseFromString(p,xt)}catch(b){}if(!s||!s.documentElement){s=Jt.createDocument(ht,"template",null);try{s.documentElement.innerHTML=se?et:p}catch(b){}}const h=s.body||s.documentElement;return n&&d&&h.insertBefore(e.createTextNode(d),h.childNodes[0]||null),ht===K?Jo.call(s,nt?"html":"body")[0]:nt?s.documentElement:h},eo=function(n){const s=Dt?Dt(n):n.ownerDocument;return De.call(s||n,n,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},jt=function(n){return n=St(n,en," "),n=St(n,on," "),n=St(n,nn," "),n},fe=function(n){var s;n.normalize();const d=Dt?Dt(n):n.ownerDocument,p=De.call(d||n,n,f.SHOW_TEXT|f.SHOW_COMMENT|f.SHOW_CDATA_SECTION|f.SHOW_PROCESSING_INSTRUCTION,null);let h=p.nextNode();for(;h;)h.data=jt(h.data),h=p.nextNode();const b=(s=n.querySelectorAll)===null||s===void 0?void 0:s.call(n,"template");b&&rt(b,y=>{gt(y.content)&&fe(y.content)})},Wt=function(n){const s=ct?ct(n):null;return typeof s!="string"||_(s)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==B(n)||typeof n.removeAttribute!="function"||typeof n.removeAttributeNode!="function"||typeof n.getAttributeNode!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==O(n)||n.childNodes!==$(n)},gt=function(n){if(!O||typeof n!="object"||n===null)return!1;try{return O(n)===F.documentFragment}catch(s){return!1}},Ct=function(n){if(!O||typeof n!="object"||n===null)return!1;try{return typeof O(n)=="number"}catch(s){return!1}};function Y(u,n,s){u.length!==0&&rt(u,d=>{d.call(t,n,s,mt)})}const vn=function(n,s){return!!(ot&&n.hasChildNodes()&&!Ct(n.firstElementChild)&&D(To,n.textContent)&&D(To,n.innerHTML)||ot&&n.namespaceURI===K&&oi[s]&&(Ct(n.firstElementChild)||typeof n.textContent=="string"&&D(ni[s],n.textContent))||n.nodeType===F.processingInstruction||ot&&n.nodeType===F.comment&&D(wo,n.data))},$t=function(n,s){if(n instanceof RegExp)return D(n,s);if(n instanceof Function){for(var d=arguments.length,p=new Array(d>2?d-2:0),h=2;h<d;h++)p[h-2]=arguments[h];return!!n(s,...p)}return!1},Tn=function(n,s,d){if(!kt[s]&&ro(s)&&$t(G.tagNameCheck,s))return!1;if(re&&!pt[s]){const p=z(n),h=$(n);if(h&&p){const b=h.length;for(let y=b-1;y>=0;--y){const S=n===d?w(h[y],!0):h[y];p.insertBefore(S,tt(n))}}}return X(n),!0},oo=function(n,s,d,p){return n.length===0?s:s===d||s===p?U(s):s},bt=function(n,s){return n===s||z(n)!==null?!1:(ae&&Ut(n),!0)},no=function(n,s){if(Y(x.beforeSanitizeElements,n,null),bt(n,s))return!0;if(Wt(n))return X(n),!0;const d=_(Qt(n));if(C=oo(x.uponSanitizeElement,C,te,Rt),Y(x.uponSanitizeElement,n,{tagName:d,allowedTags:C}),bt(n,s))return!0;if(vn(n,d))return X(n),!0;if(kt[d]||!(q.tagCheck instanceof Function&&q.tagCheck(d))&&!C[d]){const p=Tn(n,d,s);return p===!1&&(Y(x.afterSanitizeElements,n,null),bt(n,s))?!0:p}if(Tt(n)===F.element&&!bn(n)||(d==="noscript"||d==="noembed"||d==="noframes")&&D(ti,n.innerHTML))return X(n),!0;if(V&&n.nodeType===F.text){const p=jt(n.textContent);n.textContent!==p&&(At(t.removed,{element:n.cloneNode()}),n.textContent=p)}return Y(x.afterSanitizeElements,n,null),bt(n,s)},io=function(n,s,d){if(Ne[s]||Je(s,n)||He&&(s==="id"||s==="name")&&(d in e||d in pn))return!1;const p=A[s]||q.attributeCheck instanceof Function&&q.attributeCheck(s,n);return oe&&D(rn,s)||Pe&&D(an,s)?!0:p?Ge[s]||D(Re,St(d,Oe,""))||(s==="src"||s==="xlink:href"||s==="href")&&n!=="script"&&po(d,"data:")===0&&We[n]||ze&&!D(sn,St(d,Oe,""))?!0:!d:ro(n)&&$t(G.tagNameCheck,n)&&$t(G.attributeNameCheck,s,n)||s==="is"&&G.allowCustomizedBuiltInElements&&$t(G.tagNameCheck,d)},wn=E({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ro=function(n){return!wn[Mt(n)]&&D(ln,n)},kn=function(n,s,d,p){if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!d)switch(g.getAttributeType(n,s)){case"TrustedHTML":return dt(p);case"TrustedScriptURL":return Xo(p)}return p},xn=function(n,s,d,p){try{return d?n.setAttributeNS(d,s,p):n.setAttribute(s,p),Wt(n)?(X(n),!1):!0}catch(h){return it(s,n),!1}},ao=function(n,s){if(Y(x.beforeSanitizeAttributes,n,null),bt(n,s))return;const d=n.attributes;if(!d||Wt(n))return;A=oo(x.uponSanitizeAttribute,A,ee,Nt);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let h=d.length;const b=_(n.nodeName);for(;h--;){const y=d[h],S=y.name,j=y.namespaceURI,H=y.value,yt=_(S),he=H;let R=S==="value"?he:Pn(he),so=!1;if(p.attrName=yt,p.attrValue=R,p.keepAttr=!0,p.forceKeepAttr=void 0,Y(x.uponSanitizeAttribute,n,p),R=p.attrValue,Fe&&(yt==="id"||yt==="name")&&po(R,Ue)!==0&&(it(S,n,y),R=Ue+R,so=!0),ot&&D(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,R)){it(S,n,y);continue}if(yt==="attributename"&&fo(R,"href")){it(S,n,y);continue}if(!p.forceKeepAttr){if(!p.keepAttr){it(S,n,y);continue}if(!Be&&D(ei,R)){it(S,n,y);continue}if(V&&(R=jt(R)),!io(b,yt,R)){it(S,n,y);continue}R=kn(b,yt,j,R),R!==he&&xn(n,S,j,R)&&so&&uo(t.removed)}}Y(x.afterSanitizeAttributes,n,null),bt(n,s)},Gt=function(n){let s=null;const d=eo(n);for(Y(x.beforeSanitizeShadowDOM,n,null);s=d.nextNode();)if(Y(x.uponSanitizeShadowNode,s,null),no(s,n),ao(s,n),gt(s.content)&&Gt(s.content),Tt(s)===F.element){const p=lt(s);gt(p)&&(pe(p),Gt(p))}Y(x.afterSanitizeShadowDOM,n,null)},pe=function(n){const s=[{node:n,shadow:null}];for(;s.length>0;){const d=s.pop();if(d.shadow){Gt(d.shadow);continue}const p=d.node,h=Tt(p)===F.element,b=$(p);if(b)for(let y=b.length-1;y>=0;--y)s.push({node:b[y],shadow:null});if(h){const y=ct?ct(p):null;if(typeof y=="string"&&_(y)==="template"){const S=p.content;gt(S)&&s.push({node:S,shadow:null})}}if(h){const y=lt(p);gt(y)&&s.push({node:null,shadow:y},{node:y,shadow:null})}}};return t.sanitize=function(u){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=null,d=null,p=null,h=null;if(se=!u,se&&(u="<!-->"),typeof u!="string"&&!Ct(u)&&(u=Un(u),typeof u!="string"))throw Q("dirty is not a string, aborting");if(!t.isSupported)return u;ne?(C=Rt,A=Nt):ue(n),(x.uponSanitizeElement.length>0||x.uponSanitizeAttribute.length>0)&&(C=U(C)),x.uponSanitizeAttribute.length>0&&(A=U(A)),t.removed=[];const b=ae&&typeof u!="string"&&Ct(u);if(b){En(u);const j=Qt(u);if(typeof j=="string"){const H=_(j);if(!C[H]||kt[H])throw Ft(u),Q("root node is forbidden and cannot be sanitized in-place")}if(Wt(u))throw Ft(u),Q("root node is clobbered and cannot be sanitized in-place");try{pe(u)}catch(H){throw Ft(u),H}}else if(Ct(u))s=to("<!---->"),d=s.ownerDocument.importNode(u,!0),d.nodeType===F.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?s=d:s.appendChild(d),pe(s);else{if(!ut&&!V&&!nt&&u.indexOf("<")===-1)return N&&zt?dt(u):u;if(s=to(u),!s)return ut?null:zt?et:""}s&&ie&&X(s.firstChild);const y=b?u:s;try{const j=eo(y);for(;p=j.nextNode();)no(p,y),ao(p,y),gt(p.content)&&Gt(p.content)}catch(j){throw b&&(Ft(u),rt(t.removed,H=>{H.element&&Ut(H.element)})),j}if(b){let j=!1;if(rt(t.removed,H=>{H.element&&(H.element===u&&(j=!0),Ut(H.element))}),j)throw Q("a node selected for removal could not be safely returned; refusing to sanitize in place");return V&&fe(u),u}if(ut){if(V&&fe(s),Pt)for(h=Zo.call(s.ownerDocument);s.firstChild;)h.appendChild(s.firstChild);else h=s;return(A.shadowroot||A.shadowrootmode)&&(h=tn.call(o,h,!0)),h}let S=nt?s.outerHTML:s.innerHTML;return nt&&C["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&D(Zn,s.ownerDocument.doctype.name)&&(S="<!DOCTYPE "+s.ownerDocument.doctype.name+`>
11
- `+S),V&&(S=jt(S)),N&&zt?dt(S):S},t.setConfig=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ue(u),ne=!0,Rt=C,Nt=A},t.clearConfig=function(){mt=null,ne=!1,Rt=null,Nt=null,N=Zt,et=""},t.isValidAttribute=function(u,n,s){mt||ue({});const d=_(u),p=_(n);return io(d,p,s)},t.addHook=function(u,n){typeof n=="function"&&P(x,u)&&At(x[u],n)},t.removeHook=function(u,n){if(P(x,u)){if(n!==void 0){const s=Rn(x[u],n);return s===-1?void 0:Nn(x[u],s,1)[0]}return uo(x[u])}},t.removeHooks=function(u){P(x,u)&&(x[u]=[])},t.removeAllHooks=function(){x=ko()},t}var Yt=$o();const ai=["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"],si={"*":["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"]},li="data-editora-embed";function ci(a){if(!a||/\s/.test(a.trim()))return!1;try{const t=new URL(a.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function Go(a,t,e,o){if((t==null?void 0:t.sanitize)===!1)return a;const i=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:ai,r=e!=null&&e.length?Array.from(new Set([...i,...e])):i,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:si,f=new Set;for(const T of Object.values(c))for(const w of T)f.add(w);const m={ALLOWED_TAGS:r,ALLOWED_ATTR:Array.from(f)};if(!o)return Yt.sanitize(a,m);const g=r.includes("iframe");Yt.addHook("uponSanitizeElement",(T,w)=>{var k;if(w.tagName!=="iframe")return;const v=T;w.allowedTags.iframe=g||((k=v.getAttribute)==null?void 0:k.call(v,li))==="true"&&ci(v.getAttribute("src"))});try{return Yt.sanitize(a,m)}finally{Yt.removeHook("uponSanitizeElement")}}function Ko(a,t,e,o){return Go(a,t,o,!1)}function Yo(a,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?a:Ko(a,t)}function Ae(a,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?a:Go(a,t,o,!0)}const di=".resize-handle, .table-resize-handle, [data-rte-media-pending]",ui=/resize-handle|data-rte-media-pending|rte-media/;function Le(a){if(!a||!ui.test(a))return a;const t=document.createElement("template");t.innerHTML=a;const e=new Set;return t.content.querySelectorAll(di).forEach(o=>{const i=o.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&e.add(i),o.remove()}),e.forEach(o=>{var i;o.style.position==="relative"&&(o.style.removeProperty("position"),(i=o.getAttribute("style"))!=null&&i.trim()||o.removeAttribute("style"))}),t.content.querySelectorAll("figure.rte-media").forEach(o=>{var r;o.removeAttribute("contenteditable");const i=o.querySelector(":scope > figcaption");i&&(i.removeAttribute("contenteditable"),!((r=i.textContent)!=null&&r.trim())&&!i.querySelector("img, video, a")&&i.remove())}),t.innerHTML}function at(a){return a?Le(a.innerHTML):""}const Xt=class Xt{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const o=this.parseAttributes(t.attributes);Object.assign(e,o)}return t.jsConfig&&Object.assign(e,t.jsConfig),this.normalizeConfig(e)}static normalizeConfig(t){const e={...t};if(e.toolbarFloating!==void 0||e.toolbarSticky!==void 0){const l=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(l.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(l.sticky=!!e.toolbarSticky),e.toolbar=l}if(e.toolbarItems!==void 0&&typeof e.toolbar=="object"&&e.toolbar&&(e.toolbar.items=e.toolbarItems),e.autosaveEnabled!==void 0||e.autosaveIntervalMs!==void 0||e.autosaveStorageKey!==void 0||e.autosaveProvider!==void 0||e.autosaveApiUrl!==void 0){const l=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(l.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(l.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(l.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(l.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(l.apiUrl=e.autosaveApiUrl),e.autosave=l}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof e.autosave=="boolean")e.autosave={...o,enabled:e.autosave};else if(typeof e.autosave=="object"&&e.autosave){const l={...o,...e.autosave};l.intervalMs===void 0&&l.interval!==void 0&&(l.intervalMs=Number(l.interval)),l.enabled===void 0&&(l.enabled=!0),(!Number.isFinite(l.intervalMs)||l.intervalMs<=0)&&(l.intervalMs=o.intervalMs),e.autosave=l}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const l=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(l.locale=e.languageLocale),e.languageDirection!==void 0&&(l.direction=e.languageDirection),e.language=l}const i={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:i.direction}:typeof e.language=="object"&&e.language?e.language={...i,...e.language}:e.language=i,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const l=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(l.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(l.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(l.apiUrl=e.spellcheckApiUrl),e.spellcheck=l}const r={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...r,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const l={...r,...e.spellcheck};!l.provider&&l.mode&&(l.provider=l.mode==="local"?"browser":"api"),l.enabled===void 0&&(l.enabled=!!(l.mode||l.provider||l.apiUrl)),e.spellcheck=l}else e.spellcheck=r;return e.contextMenuEnabled!==void 0&&(e.contextMenu={enabled:!!e.contextMenuEnabled}),typeof e.contextMenu=="boolean"?e.contextMenu={enabled:e.contextMenu}:typeof e.contextMenu=="object"&&e.contextMenu?e.contextMenu={enabled:e.contextMenu.enabled!==!1}:e.contextMenu={enabled:!0},(e.pasteClean!==void 0||e.pasteKeepFormatting!==void 0||e.pasteConvertWord!==void 0)&&(e.paste={...e.paste||{},...e.pasteClean!==void 0?{clean:!!e.pasteClean}:{},...e.pasteKeepFormatting!==void 0?{keepFormatting:!!e.pasteKeepFormatting}:{},...e.pasteConvertWord!==void 0?{convertWord:!!e.pasteConvertWord}:{}}),e.paste={clean:!0,keepFormatting:!1,convertWord:!0,...e.paste||{}},e.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...e.contentConfig||{}},(e.securitySanitizeOnPaste!==void 0||e.securitySanitizeOnInput!==void 0)&&(e.security={...e.security||{},...e.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!e.securitySanitizeOnPaste}:{},...e.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!e.securitySanitizeOnInput}:{}}),e.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...e.security||{}},(e.accessibilityEnableAria!==void 0||e.accessibilityKeyboardNavigation!==void 0||e.accessibilityChecker!==void 0)&&(e.accessibility={...e.accessibility||{},...e.accessibilityEnableAria!==void 0?{enableARIA:!!e.accessibilityEnableAria}:{},...e.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!e.accessibilityKeyboardNavigation}:{},...e.accessibilityChecker!==void 0?{checker:!!e.accessibilityChecker}:{}}),typeof e.accessibility=="boolean"&&(e.accessibility={enableARIA:e.accessibility,keyboardNavigation:e.accessibility,checker:!1}),e.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...e.accessibility||{}},(e.performanceDebounceInputMs!==void 0||e.performanceViewportOnlyScan!==void 0)&&(e.performance={...e.performance||{},...e.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(e.performanceDebounceInputMs)}:{},...e.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!e.performanceViewportOnlyScan}:{}}),typeof e.performance=="boolean"&&(e.performance={debounceInputMs:100,viewportOnlyScan:e.performance}),e.performance={debounceInputMs:100,viewportOnlyScan:!0,...e.performance||{}},(typeof e.performance.debounceInputMs!="number"||!Number.isFinite(e.performance.debounceInputMs)||e.performance.debounceInputMs<0)&&(e.performance.debounceInputMs=100),e}static parseAttributes(t){const e={};for(const[o,i]of Object.entries(t)){const r=this.kebabToCamel(o);e[r]=this.BOOLEAN_ATTRIBUTES.has(o)&&(i===""||i===o)?!0:this.parseAttributeValue(i)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const o of t)for(const[i,r]of Object.entries(o))r!=null&&(typeof r=="object"&&!Array.isArray(r)&&e[i]?e[i]=this.merge(e[i],r):e[i]=r);return e}};Xt.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!1,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},Xt.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 Vt=Xt;class qo{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const o=await this.create(t,e);return o&&this.loadedPlugins.set(t,o),o}async create(t,e){const o=this.pluginRegistry.get(t);if(!o)return console.warn(`Plugin not found: ${t}`),null;const i=await o();return e&&this.applyPluginConfig(i,e),i}configure(t,e){this.applyPluginConfig(t,e)}async loadMultiple(t,e){return(await Promise.all(t.map(i=>this.load(i,e)))).filter(i=>i!==null)}async parsePluginString(t,e){const o=t.split(/\s+/).filter(Boolean);return this.loadMultiple(o,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}const xo=new Set;function fi(a,t){xo.has(a)||(xo.add(a),console.warn(`[Editora] The "${a}" option has no effect: ${t} It is still accepted so existing code keeps working, and will be removed in a future major release.`))}const pi='.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.editora-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}}editora-editor[data-loading]{display:block;position:relative;min-height:160px;border:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px);background:var(--ui-color-surface, #fff)}editora-editor[data-loading]:before{content:"";position:absolute;inset:0 0 auto;height:46px;border-bottom:1px solid var(--ui-color-border, #ddd);border-radius:var(--ui-radius, 4px) var(--ui-radius, 4px) 0 0;background:linear-gradient(90deg,var(--ui-color-surface-alt, #f5f5f5) 0%,color-mix(in srgb,var(--ui-color-surface-alt, #f5f5f5) 70%,var(--ui-color-border, #ddd)) 50%,var(--ui-color-surface-alt, #f5f5f5) 100%);background-size:220% 100%;animation:editora-loading-shimmer 1.2s linear infinite}editora-editor[data-loading]:after{content:"Loading editor…";position:absolute;top:62px;left:16px;font:14px/1.4 var(--ui-font-family, system-ui, sans-serif);color:var(--ui-color-muted, #6b7280)}editora-editor[data-loading]>*{visibility:hidden}@keyframes editora-loading-shimmer{to{background-position:-220% 0}}@media(prefers-reduced-motion:reduce){editora-editor[data-loading]:before{animation:none}}';let qt;const hi="__editoraCommandEditorRoot",mi="__editoraLastCommandButton",Co="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",Ao=".rte-content, .editora-content",gi="Rich text editor",bi=new Set(["collaboration"]),Te="data-editora-disabled-by-host",Se=new Set;let J=null,So=!1,we=null,ke=null;function _o(a){if(!(a instanceof HTMLElement))return!1;const t=a;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function yi(a){return a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null}function Lt(a){if(!a)return null;if(_o(a))return a;const t=a.matches(Co)?a:a.closest(Co);return!t||!_o(t)?null:t}function Ei(){var i;if(typeof window=="undefined")return null;const a=window[hi];if(a instanceof HTMLElement){const r=Lt(a);if(r)return r;const l=a.matches(Ao)?a:a.querySelector(Ao);if(l){const c=Lt(l);if(c)return c}}const t=window[mi];if(t instanceof HTMLElement){const r=Lt(t);if(r)return r}const e=document.activeElement;if(e){const r=Lt(e);if(r)return r}const o=(i=window.getSelection)==null?void 0:i.call(window);if(o&&o.rangeCount>0){const r=Lt(yi(o.getRangeAt(0).startContainer));if(r)return r}if(J&&J.isConnected)return J;for(const r of Se)if(r.isConnected)return r;return null}function vi(){if(typeof window=="undefined"||So)return;we=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,ke=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const a=(t,...e)=>{const o=Ei();return o?o.execCommand(t,...e):we?we(t,...e):ke?ke(t,...e):!1};window.executeEditorCommand=a,window.execEditorCommand=a,So=!0}function Ti(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const t=document.createElement("style");t.id=a,t.textContent=pi,document.head.appendChild(t)}}function Vo(){if(!qt){const a=st.__globalPluginLoader;a?qt=a:qt=new qo}return qt}function wi(a){const t=Vo();Object.entries(a).forEach(([e,o])=>{t.register(e,o)})}const ki=typeof HTMLElement=="undefined"?class{}:HTMLElement;class st extends ki{constructor(){if(super(),this.pluginLoader=Vo(),this.config={},this.isInitialized=!1,this.buildGeneration=0,this.keyboardShortcutManager=new Mo,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.pluginInstances=new Map,this.lastBeforeInputType=null,this.pendingHistorySnapshot=null,this.hasConnected=!1,this.reinitializeQueued=!1,this.lastReportedContent=null,Ti(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","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.hasConnected=!0,this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(st.__globalPluginLoader){this.pluginLoader=st.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{st.__globalPluginLoader?(this.pluginLoader=st.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,o){e!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,o))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected?(this.destroy(),this.adoptConfiguredContent(t),await this.waitForPluginLoader(),await this.initialize()):this.adoptConfiguredContent(t)}adoptConfiguredContent(t){typeof t.content=="string"&&(this.preservedContent=t.content)}applyThemeClass(t){Array.from(this.classList).forEach(e=>{e.startsWith("editora-theme-")&&this.classList.remove(e)}),t&&this.classList.add(`editora-theme-${t}`)}async initialize(){var r;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;const t=++this.buildGeneration;this.setAttribute("data-editora-editor","true"),Se.add(this),J||(J=this),vi(),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.classList.toggle("editora-disabled",this.isEditorDisabled()),this.applyThemeClass(this.config.theme),this.isMenubarRequested()&&fi("menubar","<editora-editor> does not render a menu bar."),this.setAttribute("data-loading","true"),this.setAttribute("aria-busy","true");const e=await this.loadPlugins();if(t!==this.buildGeneration||!this.isConnected)return;if(this.loadedPlugins=e,e.forEach(l=>{if(l.init&&typeof l.init=="function")try{l.init({editorElement:this})}catch(c){console.error(`[RichTextEditor] Error initializing plugin ${l.name}:`,c)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const l=this.innerHTML.trim();l&&this.setAttribute("data-initial-content",l)}const o=this.preservedContent;this.preservedContent=null;const i=this.sanitizeLoadedContent((r=o!=null?o:this.restoreAutosavedContent())!=null?r:this.getAttribute("data-initial-content")||"");this.engine=new Do({content:i,plugins:e,readonly:!!this.config.readonly||this.isEditorDisabled()}),this.createUI(e,i),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"),this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[],e=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const r=this.config.plugins.split(/\s+/).filter(Boolean);i&&!r.includes("a11yChecker")&&r.push("a11yChecker");for(const l of r){const c=await this.loadPlugin(l,this.getPluginLoadConfig(l));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const r of this.config.plugins)if(typeof r=="string"){const l=await this.loadPlugin(r,this.getPluginLoadConfig(r));l&&t.push(l)}else t.push(r);if(i&&!t.some(r=>(r==null?void 0:r.name)==="a11yChecker")){const r=await this.loadPlugin("a11yChecker",this.getPluginLoadConfig("a11yChecker"));r&&t.push(r)}}}else{const r=this.pluginLoader.getRegisteredPluginNames();for(const l of r){const c=this.getPluginLoadConfig(l);if(bi.has(l)&&!c)continue;const f=await this.loadPlugin(l,c);f&&t.push(f)}}return t}async loadPlugin(t,e){const o=this.pluginInstances.get(t);if(o)return e&&this.pluginLoader.configure(o,e),o;const i=await this.pluginLoader.create(t,e);return i&&this.pluginInstances.set(t,i),i}resolveToolbarItems(){const t=this.config.toolbarItems;if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");const e=this.config.toolbar;if(typeof e=="string")return e;if(!e||typeof e!="object")return;const o=e.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.sticky}isToolbarFloatingEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.floating}isStatusbarEnabled(){const t=this.config.statusbar;return typeof t=="boolean"?t:t&&typeof t=="object"?t.enabled!==!1:!1}getStatusbarPosition(){const t=this.config.statusbar;return t&&typeof t=="object"&&t.position==="top"?"top":"bottom"}getLanguageConfig(){const t=this.config.language;return typeof t=="string"?{locale:t,direction:"ltr"}:t&&typeof t=="object"?{locale:t.locale||"en",direction:t.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const t=this.config.accessibility;return typeof t=="boolean"?{enableARIA:t,keyboardNavigation:t,checker:!1}:t&&typeof t=="object"?{enableARIA:t.enableARIA!==!1,keyboardNavigation:t.keyboardNavigation!==!1,checker:!!t.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var e;const t=this.config.performance;if(typeof t=="boolean")return{debounceInputMs:100,viewportOnlyScan:t};if(t&&typeof t=="object"){const o=Number((e=t.debounceInputMs)!=null?e:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:t.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const t=this.contentElement.getBoundingClientRect();return t.bottom>=0&&t.top<=window.innerHeight}applyAccessibilitySettings(){var e;if(!this.contentElement)return;const t=this.getAccessibilityConfig();if(t.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly||this.isEditorDisabled()?"true":"false");const o=(e=this.getAttribute("aria-label"))==null?void 0:e.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||i||gi)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=t.keyboardNavigation&&!this.isEditorDisabled()?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const t=this.getLanguageConfig();this.contentElement.setAttribute("lang",t.locale),this.contentElement.setAttribute("dir",t.direction)}getSpellcheckConfig(){const t=this.config.spellcheck;if(typeof t=="boolean")return{enabled:t,provider:"browser"};if(t&&typeof t=="object"){const e=t.provider||"browser";return{enabled:!!t.enabled,provider:e,mode:t.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const t=this.getSpellcheckConfig(),e=t.enabled&&t.provider==="browser";this.contentElement.spellcheck=e,this.contentElement.setAttribute("spellcheck",e?"true":"false")}executeCommand(t,...e){var r;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(l=>l.commands&&l.commands[t]);if(i&&i.commands){const l=i.commands[t];if(typeof l=="function")try{return t==="toggleFullscreen"?l(this,o):l(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((r=this.engine)==null?void 0:r.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const r=e[t];if(r&&typeof r=="object")return r}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[t,t.toLowerCase(),...o[t]||[]];for(const r of i){const l=this.config[r];if(l&&typeof l=="object"&&!Array.isArray(l))return l}}getContentSanitizeConfig(){const t=this.config.contentConfig;return t&&typeof t=="object"?t:{sanitize:!0}}getSecurityConfig(){const t=this.config.security;return t&&typeof t=="object"?t:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(t){return Ae(t,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var e,o;const t=this.config.autosave;if(typeof t=="boolean")return{enabled:t,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(t&&typeof t=="object"){const i=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(t.storageKey||"rte-autosave"),provider:t.provider||"localStorage",apiUrl:t.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(t){const e=this.getAutosaveConfig();if(e.enabled&&t!==this.lastAutosavedContent){if(this.lastAutosavedContent=t,e.provider==="localStorage"){try{localStorage.setItem(e.storageKey,t),localStorage.setItem(`${e.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}e.provider==="api"&&e.apiUrl&&fetch(e.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const t=this.getAutosaveConfig();if(!t.enabled||t.provider!=="localStorage")return null;try{const e=localStorage.getItem(t.storageKey);if(e)return this.lastAutosavedContent=e,e}catch(e){console.error("[RichTextEditor] Failed to restore autosaved content:",e)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const t=this.getAutosaveConfig();!t.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(at(this.contentElement))},t.intervalMs))}insertHTMLAtSelection(t){if(!this.contentElement)return;const e=window.getSelection();if(e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const i=document.createElement("div");i.innerHTML=t;const r=document.createDocumentFragment();for(;i.firstChild;)r.appendChild(i.firstChild);o.insertNode(r),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,t)}createUI(t,e){const o=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Oo({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,l)=>{var c;if(this.isEditorDisabled())return!1;if(this.contentElement){this.contentElement.focus();const f=window.getSelection();if(!f||f.rangeCount===0||!this.contentElement.contains(f.anchorNode)){const m=document.createRange(),g=this.contentElement.lastChild||this.contentElement;g.nodeType===Node.TEXT_NODE?m.setStart(g,((c=g.textContent)==null?void 0:c.length)||0):g.nodeType===Node.ELEMENT_NODE?(m.selectNodeContents(g),m.collapse(!1)):m.setStart(this.contentElement,0),m.collapse(!0),f==null||f.removeAllRanges(),f==null||f.addRange(m)}}return this.executeCommand(r,l)}),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||this.isEditorDisabled()?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(r){console.warn("defaultParagraphSeparator not supported:",r)}if(e){const r=document.createElement("div");r.innerHTML=e.trim(),!Array.from(r.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const f=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(f)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Ro({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new No({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.setToolbarControlsDisabled(this.isEditorDisabled()),this.lastReportedContent=at(this.contentElement),this.config.autofocus&&!this.isEditorDisabled()&&setTimeout(()=>{var r;return(r=this.contentElement)==null?void 0:r.focus()},0)}isMenubarRequested(){var o;const t=(o=this.jsConfig)==null?void 0:o.menubar;if(t!==void 0)return t===!0||typeof t=="object"&&t!==null&&t.enabled!==!1;const e=this.getAttribute("menubar");return e!==null&&e!=="false"}recordInputHistory(t){const e=this.pendingHistorySnapshot;if(this.pendingHistorySnapshot=null,!e||!this.contentElement||e.beforeHTML===t)return;const o=window.execEditorCommand;typeof o=="function"&&o("recordDomTransaction",this.contentElement,e.beforeHTML,t,{inputType:e.inputType,data:e.data,selectionCollapsed:e.selectionCollapsed})}isEditorDisabled(){return this.config.disabled===!0}applyDisabledState(){var e,o;const t=this.isEditorDisabled();this.classList.toggle("editora-disabled",t),t&&((e=this.floatingToolbar)==null||e.hide()),this.contentElement&&(this.contentElement.contentEditable=t||this.config.readonly?"false":"true",this.applyAccessibilitySettings()),(o=this.engine)==null||o.setReadonly(t||!!this.config.readonly),this.setToolbarControlsDisabled(t)}setToolbarControlsDisabled(t){if(!this.toolbarElement)return;this.toolbarElement.querySelectorAll("button, input, select, textarea").forEach(o=>{t?o.disabled||(o.disabled=!0,o.setAttribute(Te,"")):o.hasAttribute(Te)&&(o.disabled=!1,o.removeAttribute(Te))})}setupEventListeners(){if(!this.contentElement||!this.engine)return;const t=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{var i,r;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:(r=(i=window.getSelection())==null?void 0:i.isCollapsed)!=null?r:!0})}),this.contentElement.addEventListener("input",o=>{var w;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const r=(w=o==null?void 0:o.detail)==null?void 0:w.allowedTags,l=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),f=this.getSecurityConfig(),m=this.lastBeforeInputType;if(this.lastBeforeInputType=null,f.sanitizeOnInput!==!1&&c.sanitize!==!1&&!m){const v=Ae(i,c,f,r);if(v!==i){const k=window.getSelection(),tt=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=v,tt&&k)try{k.removeAllRanges(),k.addRange(tt)}catch($){}i=v}}this.recordInputHistory(i),this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.emitContentChange(Le(i))};l.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,l.debounceInputMs):T(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var g,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const i=this.config.paste||{};let r=((g=o.clipboardData)==null?void 0:g.getData("text/html"))||"";const l=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),f=this.getSecurityConfig(),m=!!r&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);if((i.clean||!i.keepFormatting)&&l){document.execCommand("insertText",!1,l);return}if(i.convertWord===!1&&m&&l){document.execCommand("insertText",!1,l);return}if(r){f.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(r=Yo(r,c,f)),this.insertHTMLAtSelection(r);return}l&&document.execCommand("insertText",!1,l)}),this.contentElement.addEventListener("focus",()=>{J=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{if(this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement){const o=at(this.contentElement);o!==this.lastReportedContent&&this.emitContentChange(o)}this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{!this.getAccessibilityConfig().keyboardNavigation||this.isEditorDisabled()||t.handleKeyDown(o,(r,l)=>{this.executeCommand(r,l)})});const e=()=>{const o=this.getSelectionRangeInEditor(),i=document.activeElement,r=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!r||!o&&!r||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=e,document.addEventListener("selectionchange",this.selectionChangeHandler)}emitContentChange(t){this.lastReportedContent=t,this.dispatchEvent(new CustomEvent("content-change",{detail:{html:t},bubbles:!0}))}getSelectionRangeInEditor(){if(!this.contentElement)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),o=e.commonAncestorContainer;return this.contentElement.contains(o)?e:null}isSelectionBackward(t){if(!t.anchorNode||!t.focusNode)return!1;try{const e=document.createRange();return e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),e.collapsed}catch(e){return!1}}getSelectionAnchorRect(t,e){const o=Array.from(e.getClientRects()).filter(r=>r.width>0||r.height>0);return o.length===0?e.getBoundingClientRect():this.isSelectionBackward(t)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const e=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const r=window.getSelection();if(!r){this.floatingToolbar.hide();return}const l=this.getSelectionAnchorRect(r,i);if(!l){this.floatingToolbar.hide();return}this.floatingToolbar.show(l.left,l.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.getPerformanceConfig(),e=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!e)return;const o=this.contentElement.textContent||"",{words:i,chars:r}=Ho(o),l=Bo(this.contentElement);let c,f;const m=this.getSelectionRangeInEditor();m&&(c=Po(this.contentElement,m),m.collapsed||(f=Fo(m,c),c=void 0)),this.statusBar.update({wordCount:i,charCount:r,lineCount:l,cursorPosition:c,selectionInfo:f})}isReadonlyAttribute(t){return t!==null&&t!=="false"}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(e)||this.isEditorDisabled()?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(e)||this.isEditorDisabled());break;case"disabled":this.applyDisabledState();break;case"theme":this.applyThemeClass(e);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",e),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.hasConnected&&this.scheduleReinitialize();break}}scheduleReinitialize(){this.reinitializeQueued||(this.reinitializeQueued=!0,queueMicrotask(()=>{this.reinitializeQueued=!1,this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(t=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",t)})}))}))}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const o=this.attributes[e];t[o.name]=o.value}return Vt.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>at(this.contentElement),setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))},execCommand:(t,e)=>this.executeCommand(t,e),focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,o,i;this.buildGeneration+=1,this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=at(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.lastReportedContent=null,this.isInitialized=!1,Se.delete(this),J===this&&(J=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return at(this.contentElement)}setContent(t){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))}execCommand(t,...e){return this.executeCommand(t,...e)}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}exports.CommandRegistry=Io;exports.ConfigResolver=Vt;exports.EditorEngine=Do;exports.EditorState=It;exports.FloatingToolbar=Ro;exports.KeyboardShortcutManager=Mo;exports.PluginLoader=qo;exports.PluginManager=_e;exports.RichTextEditorElement=st;exports.Schema=Lo;exports.StatusBar=No;exports.ToolbarRenderer=Oo;exports.calculateTextStats=Ho;exports.countLines=Bo;exports.createPluginManager=Cn;exports.getCleanEditorHTML=at;exports.getCursorPosition=Po;exports.getSelectionInfo=Fo;exports.getTextOffset=zo;exports.initWebComponent=wi;exports.sanitizeHTML=Ko;exports.sanitizeInputHTML=Ae;exports.sanitizePastedHTML=Yo;exports.stripEditorUiArtifacts=Le;
12
- //# sourceMappingURL=index-BahpGXyw.js.map