@editora/core 1.0.22 → 1.0.24
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/README.md +247 -243
- package/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
- package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
- package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
- package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
- package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
- package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
- package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-BRBEIqY7.mjs} +167 -113
- package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
- package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
- package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
- package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
- package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
- package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
- package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-tZqIa9o5.mjs} +21 -20
- package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
- package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
- package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
- package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
- package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
- package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
- package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
- package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
- package/dist/MediaManagerPlugin.native-BjrEarV6.mjs +1161 -0
- package/dist/{MediaManagerPlugin.native-BT1NZIJS.mjs → MediaManagerPlugin.native-CRi24Mrb.mjs} +340 -281
- package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
- package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
- package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
- package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
- package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
- package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
- package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
- package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
- package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
- package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
- package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
- package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
- package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
- package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
- package/dist/confirmDialog-BP8hZPpX.mjs +112 -0
- package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
- package/dist/{documentManager-BWK_-KJp.mjs → documentManager-8gnG-uG_.mjs} +1728 -1715
- package/dist/editora.min.js +21 -21
- package/dist/editora.umd.js +10 -10
- package/dist/{index-C1sO7DAC.js → index--wO0CZVN.js} +6 -6
- package/dist/{index-DGMYWPLx.mjs → index-BICrB5kg.mjs} +397 -326
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/katex-DLIObQUm.mjs +11683 -0
- package/dist/katex.min--Ws3c9be.mjs +6 -0
- package/dist/notify-DCQGpmq-.mjs +60 -0
- package/dist/plugin-loader.js +54 -54
- package/dist/webcomponent-core.js +305 -234
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +153 -80
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +631 -560
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1677 -1328
- package/package.json +1 -1
- package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
- package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
- package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
- package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(wt,xt){typeof exports=="object"&&typeof module!="undefined"?xt(exports):typeof define=="function"&&define.amd?define(["exports"],xt):(wt=typeof globalThis!="undefined"?globalThis:wt||self,xt(wt.EditoraCore={}))})(this,(function(wt){"use strict";class xt{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(e,t){this.pluginRegistry.set(e,t)}async load(e,t){if(this.loadedPlugins.has(e))return this.loadedPlugins.get(e);const n=this.pluginRegistry.get(e);if(!n)return console.warn(`Plugin not found: ${e}`),null;const i=await n();return t&&this.applyPluginConfig(i,t),this.loadedPlugins.set(e,i),i}async loadMultiple(e,t){return(await Promise.all(e.map(i=>this.load(i,t)))).filter(i=>i!==null)}async parsePluginString(e,t){const n=e.split(/\s+/).filter(Boolean);return this.loadMultiple(n,t)}applyPluginConfig(e,t){e.__pluginConfig=t}unload(e){this.loadedPlugins.delete(e)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(e){return this.loadedPlugins.has(e)}}class An{constructor(e,t,n){this.doc=e,this.selection=t,this.schema=n}static create(e,t){const n=t||e.node("doc",{},[e.node("paragraph")]);return new An(n,{anchor:0,head:0},e)}apply(e,t){return new An(e,t||this.selection,this.schema)}}class wr{constructor(e,t){this.nodes=new Map(Object.entries(e)),this.marks=new Map(Object.entries(t))}node(e,t,n){return{type:e,attrs:t,content:n}}text(e,t){return{type:"text",text:e,marks:t}}}class xr{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(e,t){this.plugins.push(e),t&&this.pluginConfigs.set(e.name,t);const n=this.pluginConfigs.get(e.name)||e.config;if(e.initialize)try{e.initialize(n)}catch(i){console.error(`Failed to initialize plugin "${e.name}":`,i)}if(e.init&&e.init!==e.initialize)try{e.init(n)}catch(i){console.error(`Failed to run init hook for plugin "${e.name}":`,i)}}unregister(e){const t=this.plugins.findIndex(n=>n.name===e);if(t>-1){const n=this.plugins[t];n.destroy&&n.destroy(),this.plugins.splice(t,1),this.pluginConfigs.delete(e)}}getPlugin(e){return this.plugins.find(t=>t.name===e)}getPluginConfig(e){return this.pluginConfigs.get(e)}buildSchema(){const e={},t={};return this.plugins.forEach(n=>{n.nodes&&Object.assign(e,n.nodes),n.marks&&Object.assign(t,n.marks)}),new wr(e,t)}getCommands(){const e={};return this.plugins.forEach(t=>{t.commands&&Object.assign(e,t.commands)}),e}getToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}async executePluginCommand(e,t,...n){const i=this.getPlugin(e);if(!i)throw new Error(`Plugin not found: ${e}`);const o=this.getPluginConfig(e)||i.config||{},s=o.mode||"local";try{switch(s){case"local":return i.executeLocal?i.executeLocal(t,...n):null;case"api":if(!i.executeAPI)throw new Error(`Plugin ${e} does not support API mode`);return await i.executeAPI(t,...n);case"hybrid":if(i.executeHybrid)return await i.executeHybrid(t,...n);try{if(i.executeAPI)return await i.executeAPI(t,...n)}catch(l){if(console.warn(`API execution failed for ${e}, falling back to local`,l),i.executeLocal&&o.fallbackToLocal!==!1)return i.executeLocal(t,...n);throw l}break;default:throw new Error(`Unknown plugin mode: ${s}`)}}catch(l){throw console.error(`Error executing command ${t} on plugin ${e}:`,l),l}}async destroyAll(){const e=this.plugins.filter(t=>t.destroy).map(t=>t.destroy());await Promise.all(e),this.plugins=[],this.pluginConfigs.clear()}}class Cr{constructor(e={}){this.commands=new Map,Object.entries(e).forEach(([t,n])=>{this.register(t,n)})}register(e,t){this.commands.has(e)&&console.warn(`Command ${e} is being overwritten`),this.commands.set(e,t)}unregister(e){this.commands.delete(e)}get(e){return this.commands.get(e)}has(e){return this.commands.has(e)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Ar{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new xr,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(n=>this.pluginManager.register(n));const t=this.pluginManager.buildSchema();this.state=An.create(t),this.commandRegistry=new Cr(this.pluginManager.getCommands())}execCommand(e,...t){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const n=this.commandRegistry.get(e);if(!n)return console.warn(`Command not found: ${e}`),!1;let i;return t.length===0?i=n(this.state):t.length===1?i=n(this.state,t[0]):i=n(this.state,...t),i instanceof Promise?(i.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&(this.setState(o),this.emit("change",this.state))}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(e){this.isDestroyed||(this.state=e,this.emit("stateChange",e))}getState(){return this.state}setReadonly(e){this.isReadonly=e,this.emit("readonlyChange",e)}isReadOnly(){return this.isReadonly}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(n){const i=n.indexOf(t);i>-1&&n.splice(i,1)}}}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(...t)}catch(o){console.error(`Error in ${e} handler:`,o)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class kr{constructor(e,t,n){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var s,l;if(!this.expandedOpen)return;const o=i.target;o&&((s=this.moreButton)!=null&&s.contains(o)||(l=this.expandedRow)!=null&&l.contains(o))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=n}setLastCommandTrigger(e,t){if(typeof window=="undefined"||!e)return;const n=t||e.getAttribute("data-command")||void 0;n&&(window.__editoraLastCommandButton=e,window.__editoraLastCommand=n)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],n=e.split("|").map(l=>l.trim()),i=this.getAvailableToolbarItems(),o=new Map;i.forEach(l=>{l.command&&o.set(l.command,l),l.type==="group"&&l.label&&o.set(l.label,l)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return n.forEach(l=>{const c=[];l.split(/\s+/).filter(Boolean).forEach(u=>{if(u==="direction"){const T=o.get("setDirectionLTR"),b=o.get("setDirectionRTL");T&&c.push({id:"directionLTR",label:T.label,command:T.command,icon:T.icon,type:T.type||"button",options:T.options}),b&&c.push({id:"directionRTL",label:b.label,command:b.command,icon:b.icon,type:b.type||"button",options:b.options});return}if(u==="comments"){const T=o.get("addComment"),b=o.get("toggleComments");T&&c.push({id:"addComment",label:T.label,command:T.command,icon:T.icon,type:T.type||"button",options:T.options}),b&&c.push({id:"toggleComments",label:b.label,command:b.command,icon:b.icon,type:b.type||"button",options:b.options});return}const p=s[u]||u;let g=o.get(p);g||(g=o.get(u)),g&&c.push({id:u,label:g.label,command:g.command,icon:g.icon,type:g.type==="separator"?"separator":g.type||"button",options:g.options,items:g.items})}),c.length>0&&t.push(c)}),t}getAvailableToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}render(e){this.container=e,e.innerHTML="",e.className="editora-toolbar",this.config.sticky&&e.classList.add("editora-toolbar-sticky"),this.config.position&&e.classList.add(`editora-toolbar-${this.config.position}`);const t=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const n=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(n);i.forEach((o,s)=>{const l=document.createElement("div");if(l.className="editora-toolbar-group",o.forEach(c=>{this.appendToolbarButton(l,c);const h=l.lastElementChild;h instanceof HTMLElement&&(this.overflowUnits.push(h),this.overflowUnitHomes.set(h,l))}),t.appendChild(l),s<i.length-1){const c=document.createElement("div");c.className="editora-toolbar-separator",t.appendChild(c)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const n=document.createElement("button");n.type="button",n.className="editora-toolbar-more-button",n.title="Show more options",n.setAttribute("aria-label","More toolbar options"),n.textContent="☰",n.style.display="none",n.addEventListener("click",l=>{l.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=n,e.appendChild(n);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,e.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const o=()=>{const l=this.overflowUnits;if(l.length===0)return;l.forEach(v=>{var w;v.parentElement===i&&((w=this.overflowUnitHomes.get(v))==null||w.appendChild(v))});const c=e.clientWidth,h=16,u=40,p=4,g=Math.max(0,c-h-u-p);let T=0,b=0;for(const v of l){const w=v.getBoundingClientRect().width+p;if(T+w<=g)T+=w,b++;else break}b=Math.max(1,Math.min(b,l.length));const E=b<l.length;n.style.display=E?"":"none",n.classList.toggle("active",E&&this.expandedOpen),!E&&this.expandedOpen&&this.setExpandedOpen(!1),l.forEach((v,w)=>{w>=b&&i.appendChild(v)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(o)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,n;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(n=this.moreButton)==null||n.classList.toggle("active",e)}appendToolbarButton(e,t){if(t.type==="separator"){const n=document.createElement("div");n.className="editora-toolbar-separator",e.appendChild(n)}else if(t.type==="dropdown"){const n=this.createDropdown(t);e.appendChild(n)}else if(t.type==="inline-menu"){const n=this.createInlineMenu(t);e.appendChild(n)}else if(t.type==="group"&&t.items&&t.items.length){const n=this.createGroupButton(t);e.appendChild(n)}else if(t.type==="input"){const n=this.createInput(t);e.appendChild(n)}else{const n=this.createButton(t);e.appendChild(n)}}createGroupButton(e){const t=document.createElement("div"),n=e.label.toLowerCase().replace(/\s+/g,"-");if(t.className=`editora-toolbar-group-button ${n}`,t.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=e.icon,t.appendChild(i)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${n}`,e.items.forEach(o=>{this.appendToolbarButton(i,o)}),t.appendChild(i)}return t}createInput(e){const t=document.createElement("input");return t.className=`editora-toolbar-input ${e.label.toLowerCase().replace(/\s+/g,"-")}`,t.type="text",t.title=e.label,t.setAttribute("aria-label",e.label),t.placeholder=e.placeholder||"",e.command&&t.setAttribute("data-command",e.command),e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",n=>{n.preventDefault(),this.setLastCommandTrigger(t,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createButton(e){const t=document.createElement("button");if(t.className="editora-toolbar-button",t.type="button",t.title=e.label,e.command&&t.setAttribute("data-command",e.command),e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;else t.textContent=e.label;return e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",n=>{n.preventDefault(),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createDropdown(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown";const n=document.createElement("button");n.className="editora-toolbar-button editora-toolbar-dropdown-trigger",n.type="button",n.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(l=>{const c=document.createElement("button");c.className="editora-toolbar-dropdown-item",c.type="button",c.textContent=l.label,c.setAttribute("data-value",l.value),c.addEventListener("click",h=>{h.preventDefault(),this.setLastCommandTrigger(n,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,l.value),i.style.display="none"}),i.appendChild(c)}),n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),this.setLastCommandTrigger(n,e.command);const c=i.style.display==="block";i.style.display=c?"none":"block"});const o=l=>{t.contains(l.target)||(i.style.display="none")},s=l=>{l.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",o,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("keydown",s)},t.appendChild(n),t.appendChild(i),t}createInlineMenu(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const n=document.createElement("button");if(n.className="editora-toolbar-button",n.type="button",n.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const l=document.createElement("span");l.className="editora-toolbar-icon",l.innerHTML=e.icon,n.appendChild(l)}else n.innerHTML=e.icon;else n.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(l=>{const c=document.createElement("button");c.className="editora-toolbar-dropdown-item",c.type="button",c.textContent=l.label,c.setAttribute("data-value",l.value),c.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),this.setLastCommandTrigger(n,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,l.value),i.style.display="none"}),i.appendChild(c)}),n.addEventListener("click",l=>{var h;l.preventDefault(),l.stopPropagation(),this.setLastCommandTrigger(n,e.command);const c=(h=this.container)==null?void 0:h.querySelectorAll(".editora-toolbar-dropdown-menu");c==null||c.forEach(u=>{u!==i&&(u.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const o=l=>{t.contains(l.target)||(i.style.display="none")},s=l=>{l.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",o,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("keydown",s)},t.appendChild(n),t.appendChild(i),t}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(t=>t.command).join(" ")}updateButtonState(e,t){if(!this.container)return;const n=this.container.querySelector(`[data-command="${e}"]`);n&&(t.active!==void 0&&n.classList.toggle("active",t.active),t.disabled!==void 0&&(n.disabled=t.disabled))}destroy(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(n=>{const i=n._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Mr{constructor(e){this.visible=!1,this.config=e}create(e){const t=document.createElement("div");return t.className="editora-floating-toolbar",t.style.display="none",t.style.position="absolute",t.style.zIndex="1000",this.container=t,e.appendChild(t),t}show(e,t){this.container&&(this.container.style.display="block",this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(e,t){!this.container||!this.visible||(this.container.style.left=`${e}px`,this.container.style.top=`${t}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Lr{constructor(e={}){this.statusInfo={},this.config=e}create(e){const t=document.createElement("div");return t.className="editora-statusbar",this.config.position&&t.classList.add(`editora-statusbar-${this.config.position}`),this.container=t,e.appendChild(t),t}update(e){this.statusInfo={...this.statusInfo,...e},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="editora-statusbar-left";const t=document.createElement("div");t.className="editora-statusbar-right";const n=[];if(this.statusInfo.selectionInfo){const o=this.statusInfo.selectionInfo;o.startLine===o.endLine&&o.startColumn===o.endColumn?n.push(`Ln ${o.startLine}, Col ${o.startColumn}`):(o.startLine===o.endLine?n.push(`Ln ${o.startLine}, Col ${o.startColumn}-${o.endColumn}`):n.push(`Ln ${o.startLine}:${o.startColumn} - ${o.endLine}:${o.endColumn}`),n.push(`${o.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const o=this.statusInfo.cursorPosition;n.push(`Ln ${o.line}, Col ${o.column}`)}this.statusInfo.language&&n.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(([o,s])=>{i.push(`${o}: ${s}`)}),n.forEach((o,s)=>{const l=document.createElement("span");if(l.className="editora-statusbar-item",l.textContent=o,e.appendChild(l),s<n.length-1){const c=document.createElement("span");c.className="editora-statusbar-separator",c.textContent="|",e.appendChild(c)}}),i.forEach((o,s)=>{const l=document.createElement("span");if(l.className="editora-statusbar-item",l.textContent=o,t.appendChild(l),s<i.length-1){const c=document.createElement("span");c.className="editora-statusbar-separator",c.textContent="|",t.appendChild(c)}}),this.container.appendChild(e),this.container.appendChild(t)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Rr(r,e){const t=r.textContent||"",n=Or(r,e.startContainer,e.startOffset),o=t.substring(0,n).split(`
|
|
2
|
-
`),s=o.length,l=o[o.length-1].length+1;return{line:s,column:l}}function
|
|
3
|
-
`).length;t=Math.max(1,s)}return t}function
|
|
1
|
+
(function(Ct,At){typeof exports=="object"&&typeof module!="undefined"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(Ct=typeof globalThis!="undefined"?globalThis:Ct||self,At(Ct.EditoraCore={}))})(this,(function(Ct){"use strict";class At{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(e,t){this.pluginRegistry.set(e,t)}async load(e,t){if(this.loadedPlugins.has(e))return this.loadedPlugins.get(e);const n=this.pluginRegistry.get(e);if(!n)return console.warn(`Plugin not found: ${e}`),null;const i=await n();return t&&this.applyPluginConfig(i,t),this.loadedPlugins.set(e,i),i}async loadMultiple(e,t){return(await Promise.all(e.map(i=>this.load(i,t)))).filter(i=>i!==null)}async parsePluginString(e,t){const n=e.split(/\s+/).filter(Boolean);return this.loadMultiple(n,t)}applyPluginConfig(e,t){e.__pluginConfig=t}unload(e){this.loadedPlugins.delete(e)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(e){return this.loadedPlugins.has(e)}}class kn{constructor(e,t,n){this.doc=e,this.selection=t,this.schema=n}static create(e,t){const n=t||e.node("doc",{},[e.node("paragraph")]);return new kn(n,{anchor:0,head:0},e)}apply(e,t){return new kn(e,t||this.selection,this.schema)}}class Nr{constructor(e,t){this.nodes=new Map(Object.entries(e)),this.marks=new Map(Object.entries(t))}node(e,t,n){return{type:e,attrs:t,content:n}}text(e,t){return{type:"text",text:e,marks:t}}}class Hr{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(e,t){this.plugins.push(e),t&&this.pluginConfigs.set(e.name,t);const n=this.pluginConfigs.get(e.name)||e.config;if(e.initialize)try{e.initialize(n)}catch(i){console.error(`Failed to initialize plugin "${e.name}":`,i)}if(e.init&&e.init!==e.initialize)try{e.init(n)}catch(i){console.error(`Failed to run init hook for plugin "${e.name}":`,i)}}unregister(e){const t=this.plugins.findIndex(n=>n.name===e);if(t>-1){const n=this.plugins[t];n.destroy&&n.destroy(),this.plugins.splice(t,1),this.pluginConfigs.delete(e)}}getPlugin(e){return this.plugins.find(t=>t.name===e)}getPluginConfig(e){return this.pluginConfigs.get(e)}buildSchema(){const e={},t={};return this.plugins.forEach(n=>{n.nodes&&Object.assign(e,n.nodes),n.marks&&Object.assign(t,n.marks)}),new Nr(e,t)}getCommands(){const e={};return this.plugins.forEach(t=>{t.commands&&Object.assign(e,t.commands)}),e}getToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}async executePluginCommand(e,t,...n){const i=this.getPlugin(e);if(!i)throw new Error(`Plugin not found: ${e}`);const o=this.getPluginConfig(e)||i.config||{},s=o.mode||"local";try{switch(s){case"local":return i.executeLocal?i.executeLocal(t,...n):null;case"api":if(!i.executeAPI)throw new Error(`Plugin ${e} does not support API mode`);return await i.executeAPI(t,...n);case"hybrid":if(i.executeHybrid)return await i.executeHybrid(t,...n);try{if(i.executeAPI)return await i.executeAPI(t,...n)}catch(l){if(console.warn(`API execution failed for ${e}, falling back to local`,l),i.executeLocal&&o.fallbackToLocal!==!1)return i.executeLocal(t,...n);throw l}break;default:throw new Error(`Unknown plugin mode: ${s}`)}}catch(l){throw console.error(`Error executing command ${t} on plugin ${e}:`,l),l}}async destroyAll(){const e=this.plugins.filter(t=>t.destroy).map(t=>t.destroy());await Promise.all(e),this.plugins=[],this.pluginConfigs.clear()}}class Pr{constructor(e={}){this.commands=new Map,Object.entries(e).forEach(([t,n])=>{this.register(t,n)})}register(e,t){this.commands.has(e)&&console.warn(`Command ${e} is being overwritten`),this.commands.set(e,t)}unregister(e){this.commands.delete(e)}get(e){return this.commands.get(e)}has(e){return this.commands.has(e)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class $r{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new Hr,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(n=>this.pluginManager.register(n));const t=this.pluginManager.buildSchema();this.state=kn.create(t),this.commandRegistry=new Pr(this.pluginManager.getCommands())}execCommand(e,...t){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const n=this.commandRegistry.get(e);if(!n)return console.warn(`Command not found: ${e}`),!1;let i;return t.length===0?i=n(this.state):t.length===1?i=n(this.state,t[0]):i=n(this.state,...t),i instanceof Promise?(i.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&(this.setState(o),this.emit("change",this.state))}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(e){this.isDestroyed||(this.state=e,this.emit("stateChange",e))}getState(){return this.state}setReadonly(e){this.isReadonly=e,this.emit("readonlyChange",e)}isReadOnly(){return this.isReadonly}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const n=this.listeners.get(e);if(n){const i=n.indexOf(t);i>-1&&n.splice(i,1)}}}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(...t)}catch(o){console.error(`Error in ${e} handler:`,o)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class Fr{constructor(e,t,n){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var s,l;if(!this.expandedOpen)return;const o=i.target;o&&((s=this.moreButton)!=null&&s.contains(o)||(l=this.expandedRow)!=null&&l.contains(o))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=n}setLastCommandTrigger(e,t){if(typeof window=="undefined"||!e)return;const n=t||e.getAttribute("data-command")||void 0;n&&(window.__editoraLastCommandButton=e,window.__editoraLastCommand=n)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],n=e.split("|").map(l=>l.trim()),i=this.getAvailableToolbarItems(),o=new Map;i.forEach(l=>{l.command&&o.set(l.command,l),l.type==="group"&&l.label&&o.set(l.label,l)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return n.forEach(l=>{const c=[];l.split(/\s+/).filter(Boolean).forEach(u=>{if(u==="direction"){const y=o.get("setDirectionLTR"),m=o.get("setDirectionRTL");y&&c.push({id:"directionLTR",label:y.label,command:y.command,icon:y.icon,type:y.type||"button",options:y.options}),m&&c.push({id:"directionRTL",label:m.label,command:m.command,icon:m.icon,type:m.type||"button",options:m.options});return}if(u==="comments"){const y=o.get("addComment"),m=o.get("toggleComments");y&&c.push({id:"addComment",label:y.label,command:y.command,icon:y.icon,type:y.type||"button",options:y.options}),m&&c.push({id:"toggleComments",label:m.label,command:m.command,icon:m.icon,type:m.type||"button",options:m.options});return}const f=s[u]||u;let p=o.get(f);p||(p=o.get(u)),p&&c.push({id:u,label:p.label,command:p.command,icon:p.icon,type:p.type==="separator"?"separator":p.type||"button",options:p.options,items:p.items})}),c.length>0&&t.push(c)}),t}getAvailableToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}render(e){this.container=e,e.innerHTML="",e.className="editora-toolbar",this.config.sticky&&e.classList.add("editora-toolbar-sticky"),this.config.position&&e.classList.add(`editora-toolbar-${this.config.position}`);const t=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const n=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(n);i.forEach((o,s)=>{const l=document.createElement("div");if(l.className="editora-toolbar-group",o.forEach(c=>{this.appendToolbarButton(l,c);const d=l.lastElementChild;d instanceof HTMLElement&&(this.overflowUnits.push(d),this.overflowUnitHomes.set(d,l))}),t.appendChild(l),s<i.length-1){const c=document.createElement("div");c.className="editora-toolbar-separator",t.appendChild(c)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const n=document.createElement("button");n.type="button",n.className="editora-toolbar-more-button",n.title="Show more options",n.setAttribute("aria-label","More toolbar options"),n.textContent="☰",n.style.display="none",n.addEventListener("click",l=>{l.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=n,e.appendChild(n);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,e.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const o=()=>{const l=this.overflowUnits;if(l.length===0)return;l.forEach(v=>{var w;v.parentElement===i&&((w=this.overflowUnitHomes.get(v))==null||w.appendChild(v))});const c=e.clientWidth,d=16,u=40,f=4,p=Math.max(0,c-d-u-f);let y=0,m=0;for(const v of l){const w=v.getBoundingClientRect().width+f;if(y+w<=p)y+=w,m++;else break}m=Math.max(1,Math.min(m,l.length));const E=m<l.length;n.style.display=E?"":"none",n.classList.toggle("active",E&&this.expandedOpen),!E&&this.expandedOpen&&this.setExpandedOpen(!1),l.forEach((v,w)=>{w>=m&&i.appendChild(v)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(o)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,n;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(n=this.moreButton)==null||n.classList.toggle("active",e)}appendToolbarButton(e,t){if(t.type==="separator"){const n=document.createElement("div");n.className="editora-toolbar-separator",e.appendChild(n)}else if(t.type==="dropdown"){const n=this.createDropdown(t);e.appendChild(n)}else if(t.type==="inline-menu"){const n=this.createInlineMenu(t);e.appendChild(n)}else if(t.type==="group"&&t.items&&t.items.length){const n=this.createGroupButton(t);e.appendChild(n)}else if(t.type==="input"){const n=this.createInput(t);e.appendChild(n)}else{const n=this.createButton(t);e.appendChild(n)}}createGroupButton(e){const t=document.createElement("div"),n=e.label.toLowerCase().replace(/\s+/g,"-");if(t.className=`editora-toolbar-group-button ${n}`,t.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=e.icon,t.appendChild(i)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${n}`,e.items.forEach(o=>{this.appendToolbarButton(i,o)}),t.appendChild(i)}return t}createInput(e){const t=document.createElement("input");return t.className=`editora-toolbar-input ${e.label.toLowerCase().replace(/\s+/g,"-")}`,t.type="text",t.title=e.label,t.setAttribute("aria-label",e.label),t.placeholder=e.placeholder||"",e.command&&t.setAttribute("data-command",e.command),e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",n=>{n.preventDefault(),this.setLastCommandTrigger(t,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createButton(e){const t=document.createElement("button");if(t.className="editora-toolbar-button",t.type="button",t.title=e.label,e.command&&t.setAttribute("data-command",e.command),e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;else t.textContent=e.label;return e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",n=>{n.preventDefault(),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}makeMenuAccessible(e,t,n,i){t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false"),n.setAttribute("role","menu"),n.setAttribute("aria-label",i),n.querySelectorAll(".editora-toolbar-dropdown-item").forEach(d=>{d.setAttribute("role","menuitem"),d.tabIndex=-1});const o=()=>Array.from(n.querySelectorAll('[role="menuitem"]')),s=()=>n.style.display==="block",l=new MutationObserver(()=>{t.setAttribute("aria-expanded",s()?"true":"false")});l.observe(n,{attributes:!0,attributeFilter:["style"]});const c=e._cleanupDropdown;e._cleanupDropdown=()=>{l.disconnect(),c==null||c()},t.addEventListener("click",d=>{var u;d.detail===0&&s()&&((u=o()[0])==null||u.focus())}),t.addEventListener("keydown",d=>{var f;if(d.key!=="ArrowDown"&&d.key!=="ArrowUp")return;d.preventDefault(),s()||t.click();const u=o();(f=d.key==="ArrowUp"?u[u.length-1]:u[0])==null||f.focus()}),n.addEventListener("keydown",d=>{const u=o();if(u.length===0)return;const f=u.indexOf(document.activeElement),p=y=>{d.preventDefault(),u[(y+u.length)%u.length].focus()};switch(d.key){case"ArrowDown":return p(f+1);case"ArrowUp":return p(f<0?u.length-1:f-1);case"Home":return p(0);case"End":return p(u.length-1);case"Escape":d.preventDefault(),d.stopPropagation(),n.style.display="none",t.focus();return;case"Tab":n.style.display="none";return}})}createDropdown(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown";const n=document.createElement("button");n.className="editora-toolbar-button editora-toolbar-dropdown-trigger",n.type="button",n.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(l=>{const c=document.createElement("button");c.className="editora-toolbar-dropdown-item",c.type="button",c.textContent=l.label,c.setAttribute("data-value",l.value),c.addEventListener("click",d=>{d.preventDefault(),this.setLastCommandTrigger(n,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,l.value),i.style.display="none"}),i.appendChild(c)}),n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),this.setLastCommandTrigger(n,e.command);const c=i.style.display==="block";i.style.display=c?"none":"block"});const o=l=>{t.contains(l.target)||(i.style.display="none")},s=l=>{l.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",o,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("keydown",s)},t.appendChild(n),t.appendChild(i),this.makeMenuAccessible(t,n,i,e.label),t}createInlineMenu(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const n=document.createElement("button");if(n.className="editora-toolbar-button",n.type="button",n.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const l=document.createElement("span");l.className="editora-toolbar-icon",l.innerHTML=e.icon,n.appendChild(l)}else n.innerHTML=e.icon;else n.textContent=e.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",e.options&&e.options.forEach(l=>{const c=document.createElement("button");c.className="editora-toolbar-dropdown-item",c.type="button",c.textContent=l.label,c.setAttribute("data-value",l.value),c.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),this.setLastCommandTrigger(n,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,l.value),i.style.display="none"}),i.appendChild(c)}),n.addEventListener("click",l=>{var d;l.preventDefault(),l.stopPropagation(),this.setLastCommandTrigger(n,e.command);const c=(d=this.container)==null?void 0:d.querySelectorAll(".editora-toolbar-dropdown-menu");c==null||c.forEach(u=>{u!==i&&(u.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const o=l=>{t.contains(l.target)||(i.style.display="none")},s=l=>{l.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",o,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",o,!0),document.removeEventListener("keydown",s)},t.appendChild(n),t.appendChild(i),this.makeMenuAccessible(t,n,i,e.label),t}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(t=>t.command).join(" ")}updateButtonState(e,t){if(!this.container)return;const n=this.container.querySelector(`[data-command="${e}"]`);n&&(t.active!==void 0&&n.classList.toggle("active",t.active),t.disabled!==void 0&&(n.disabled=t.disabled))}destroy(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(n=>{const i=n._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Br{constructor(e){this.visible=!1,this.config=e}create(e){const t=document.createElement("div");return t.className="editora-floating-toolbar",t.style.display="none",t.style.position="absolute",t.style.zIndex="1000",this.container=t,e.appendChild(t),t}show(e,t){this.container&&(this.container.style.display="block",this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(e,t){!this.container||!this.visible||(this.container.style.left=`${e}px`,this.container.style.top=`${t}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class zr{constructor(e={}){this.statusInfo={},this.config=e}create(e){const t=document.createElement("div");return t.className="editora-statusbar",this.config.position&&t.classList.add(`editora-statusbar-${this.config.position}`),this.container=t,e.appendChild(t),t}update(e){this.statusInfo={...this.statusInfo,...e},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="editora-statusbar-left";const t=document.createElement("div");t.className="editora-statusbar-right";const n=[];if(this.statusInfo.selectionInfo){const o=this.statusInfo.selectionInfo;o.startLine===o.endLine&&o.startColumn===o.endColumn?n.push(`Ln ${o.startLine}, Col ${o.startColumn}`):(o.startLine===o.endLine?n.push(`Ln ${o.startLine}, Col ${o.startColumn}-${o.endColumn}`):n.push(`Ln ${o.startLine}:${o.startColumn} - ${o.endLine}:${o.endColumn}`),n.push(`${o.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const o=this.statusInfo.cursorPosition;n.push(`Ln ${o.line}, Col ${o.column}`)}this.statusInfo.language&&n.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(([o,s])=>{i.push(`${o}: ${s}`)}),n.forEach((o,s)=>{const l=document.createElement("span");if(l.className="editora-statusbar-item",l.textContent=o,e.appendChild(l),s<n.length-1){const c=document.createElement("span");c.className="editora-statusbar-separator",c.textContent="|",e.appendChild(c)}}),i.forEach((o,s)=>{const l=document.createElement("span");if(l.className="editora-statusbar-item",l.textContent=o,t.appendChild(l),s<i.length-1){const c=document.createElement("span");c.className="editora-statusbar-separator",c.textContent="|",t.appendChild(c)}}),this.container.appendChild(e),this.container.appendChild(t)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Ur(r,e){const t=r.textContent||"",n=Wr(r,e.startContainer,e.startOffset),o=t.substring(0,n).split(`
|
|
2
|
+
`),s=o.length,l=o[o.length-1].length+1;return{line:s,column:l}}function Wr(r,e,t){var s;let n=0;const i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null);let o=i.firstChild();for(;o;){if(o===e){n+=t;break}else o.nodeType===Node.TEXT_NODE&&(n+=((s=o.textContent)==null?void 0:s.length)||0);o=i.nextNode()}return n}function jr(r){var n,i;const e=r.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let t=1;if(e.length>0){t=e.length;const o=e[e.length-1];(o.tagName==="BR"||((n=o.innerHTML)==null?void 0:n.trim())===""||((i=o.textContent)==null?void 0:i.trim())==="")&&t++}else{const s=(r.textContent||"").split(`
|
|
3
|
+
`).length;t=Math.max(1,s)}return t}function Kr(r){const e=r.trim()?r.trim().split(/\s+/).length:0,t=r.length;return{words:e,chars:t}}function Vr(r,e){const t=r.toString();return{startLine:e.line,startColumn:e.column,endLine:e.line,endColumn:e.column+t.length,selectedChars:t.length,selectedWords:t.trim().split(/\s+/).filter(Boolean).length}}class Gr{constructor(e){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(e==null?void 0:e.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),e!=null&&e.shortcuts&&e.shortcuts.forEach(t=>this.registerShortcut(t)),e!=null&&e.customShortcuts&&Object.values(e.customShortcuts).forEach(t=>{this.registerShortcut(t)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let e=1;e<=6;e++)this.registerShortcut({key:String(e),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${e}`,description:`Heading ${e}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.set(t,e)}unregisterShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.delete(t)}getShortcutKey(e){const t=[];return e.ctrl&&t.push("ctrl"),e.alt&&t.push("alt"),e.shift&&t.push("shift"),e.meta&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}getEventKey(e){const t=[];return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}handleKeyDown(e,t){if(!this.enabled)return!1;const n=this.getEventKey(e),i=this.shortcuts.get(n);return i?(i.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(i.command,i.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(e){return Array.from(this.shortcuts.values()).find(t=>t.command===e)}getShortcutDescription(e){const t=[];this.isMac?(e.meta&&t.push("⌘"),e.ctrl&&t.push("⌃"),e.alt&&t.push("⌥"),e.shift&&t.push("⇧")):(e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));const n=e.key.length===1?e.key.toUpperCase():e.key;return t.push(n),t.join("+")}getShortcutsHelp(){const e=this.getAllShortcuts(),t=new Map;e.forEach(i=>{const o=this.getShortcutCategory(i.command);t.has(o)||t.set(o,[]),t.get(o).push(i)});let n=`# Keyboard Shortcuts
|
|
4
4
|
|
|
5
5
|
`;return t.forEach((i,o)=>{n+=`## ${o}
|
|
6
6
|
|
|
7
7
|
`,i.forEach(s=>{const l=this.getShortcutDescription(s);n+=`- **${l}**: ${s.description||s.command}
|
|
8
8
|
`}),n+=`
|
|
9
|
-
`}),n}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}function
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $r(r,e){return Pr(r)||Hr(r,e)||zr(r,e)||Fr()}function zr(r,e){if(r){if(typeof r=="string")return Zi(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Zi(r,e):void 0}}const Xi=Object.entries,Qi=Object.setPrototypeOf,Br=Object.isFrozen,Ur=Object.getPrototypeOf,Wr=Object.getOwnPropertyDescriptor;let Z=Object.freeze,ee=Object.seal,Ct=Object.create,Ji=typeof Reflect!="undefined"&&Reflect,zn=Ji.apply,Bn=Ji.construct;Z||(Z=function(e){return e}),ee||(ee=function(e){return e}),zn||(zn=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),Bn||(Bn=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const rt=q(Array.prototype.forEach),jr=q(Array.prototype.lastIndexOf),eo=q(Array.prototype.pop),Ot=q(Array.prototype.push),Vr=q(Array.prototype.splice),At=Array.isArray,_t=q(String.prototype.toLowerCase),Un=q(String.prototype.toString),to=q(String.prototype.match),It=q(String.prototype.replace),no=q(String.prototype.indexOf),Kr=q(String.prototype.trim),Gr=q(Number.prototype.toString),qr=q(Boolean.prototype.toString),io=typeof BigInt=="undefined"?null:q(BigInt.prototype.toString),oo=typeof Symbol=="undefined"?null:q(Symbol.prototype.toString),pe=q(Object.prototype.hasOwnProperty),Dt=q(Object.prototype.toString),ae=q(RegExp.prototype.test),Je=Yr(TypeError);function q(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return zn(r,e,n)}}function Yr(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Bn(r,t)}}function N(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(Qi&&Qi(r,null),!At(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(Br(e)||(e[n]=o),i=o)}r[i]=!0}return r}function Zr(r){for(let e=0;e<r.length;e++)pe(r,e)||(r[e]=null);return r}function be(r){const e=Ct(null);for(const n of Xi(r)){var t=$r(n,2);const i=t[0],o=t[1];pe(r,i)&&(At(o)?e[i]=Zr(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=be(o):e[i]=o)}return e}function Xr(r){switch(typeof r){case"string":return r;case"number":return Gr(r);case"boolean":return qr(r);case"bigint":return io?io(r):"0";case"symbol":return oo?oo(r):"Symbol()";case"undefined":return Dt(r);case"function":case"object":{if(r===null)return Dt(r);const e=r,t=Re(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:Dt(n)}return Dt(r)}default:return Dt(r)}}function Re(r,e){for(;r!==null;){const n=Wr(r,e);if(n){if(n.get)return q(n.get);if(typeof n.value=="function")return q(n.value)}r=Ur(r)}function t(){return null}return t}function Qr(r){try{return ae(r,""),!0}catch(e){return!1}}const ro=Z(["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"]),Wn=Z(["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"]),jn=Z(["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"]),Jr=Z(["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"]),Vn=Z(["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"]),es=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),so=Z(["#text"]),ao=Z(["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"]),Kn=Z(["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"]),lo=Z(["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"]),kn=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ts=ee(/{{[\w\W]*|^[\w\W]*}}/g),ns=ee(/<%[\w\W]*|^[\w\W]*%>/g),is=ee(/\${[\w\W]*/g),os=ee(/^data-[\-\w.\u00B7-\uFFFF]+$/),rs=ee(/^aria-[\-\w]+$/),co=ee(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ss=ee(/^(?:\w+script|data):/i),as=ee(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ls=ee(/^html$/i),cs=ee(/^[a-z][.\w]*(-[.\w]+)+$/i),ho=ee(/<[/\w!]/g),uo=ee(/<[/\w]/g),ds=ee(/<\/no(script|embed|frames)/i),hs=ee(/\/>/i),ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},fo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],us=Z(N({},fo)),fs=(function(){const r={};return rt(fo,e=>{r[e]=ee(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Z(r)})(),ps=function(){return typeof window=="undefined"?null:window},gs=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},po=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},et=function(e,t,n,i){return pe(e,t)&&At(e[t])?N(i.base?be(i.base):{},e[t],i.transform):n},Gn=function(e,t,n){const i=pe(e,t)?e[t]:void 0;return i&&typeof i=="object"?be(i):n()};function go(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ps();const e=m=>go(m);if(e.version="3.4.16",e.removed=[],!r||!r.document||r.document.nodeType!==ye.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,l=r.Element,c=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const h=r.DOMParser,u=r.trustedTypes,p=l.prototype,g=Re(p,"cloneNode"),T=Re(p,"remove"),b=Re(p,"removeAttributeNode"),E=Re(p,"nextSibling"),v=Re(p,"childNodes"),w=Re(p,"parentNode"),A=Re(p,"shadowRoot"),U=Re(p,"attributes"),I=s&&s.prototype?Re(s.prototype,"nodeType"):null,H=s&&s.prototype?Re(s.prototype,"nodeName"):null,W=s&&s.prototype?Re(s.prototype,"ownerDocument"):null,Q=function(a){return I?I(a):a.nodeType},me=function(a){return H?H(a):a.nodeName};if(typeof o=="function"){const m=t.createElement("template");m.content&&m.content.ownerDocument&&(t=m.content.ownerDocument)}let D,z="",J,_e=!1,ce=0;const de=function(){if(ce>0)throw Je('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.')},ne=function(a){de(),ce++;try{return D.createHTML(a)}finally{ce--}},Ie=function(a){de(),ce++;try{return D.createScriptURL(a)}finally{ce--}},qt=function(){return _e||(J=gs(u,i),_e=!0),J},De=t,ze=De.implementation,at=De.createNodeIterator,Yt=De.createDocumentFragment,F=De.getElementsByTagName,$e=n.importNode;let k=po();e.isSupported=typeof Xi=="function"&&typeof w=="function"&&ze&&ze.createHTMLDocument!==void 0;const Rt=ts,Mi=ns,Li=is,Ri=os,Oi=rs,_i=ss,Zt=as,Ii=cs;let Xt=co,M=null;const lt=N({},[...ro,...Wn,...jn,...Vn,...so]);let L=null;const ct=N({},[...ao,...Kn,...lo,...kn]);let V=Object.seal(Ct(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ne=null,Qt=null;const oe=Object.seal(Ct(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Jt=!0,dt=!0,en=!1,tn=!0,re=!1,he=!0,ue=!1,ht=!1,Be=null,Ue=null,ut=!1,Se=!1,We=!1,je=!1,nn=!0,on=!1;const rn="user-content-";let ft=!0,pt=!1,we={},xe=null;const sn=N({},["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 an=null;const ln=N({},["audio","video","img","source","image","track"]);let cn=null;const dn=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Ke="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let Ce=K,gt=!1,mt=null;const Di=N({},[Ve,Ke,K],Un),hn=Z(["mi","mo","mn","ms","mtext"]);let bt=N({},hn);const un=Z(["annotation-xml"]);let yt=N({},un);const Ni=N({},["title","style","font","a","script"]);let Pe=null;const Pi=["application/xhtml+xml","text/html"],Hi="text/html";let O=null,Ae=null;const Fi=t.createElement("form"),fn=function(a){return a instanceof RegExp||a instanceof Function},Tt=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ae&&Ae===a)return;(!a||typeof a!="object")&&(a={}),a=be(a),Pe=Pi.indexOf(a.PARSER_MEDIA_TYPE)===-1?Hi:a.PARSER_MEDIA_TYPE,O=Pe==="application/xhtml+xml"?Un:_t,M=et(a,"ALLOWED_TAGS",lt,{transform:O}),L=et(a,"ALLOWED_ATTR",ct,{transform:O}),mt=et(a,"ALLOWED_NAMESPACES",Di,{transform:Un}),cn=et(a,"ADD_URI_SAFE_ATTR",dn,{transform:O,base:dn}),an=et(a,"ADD_DATA_URI_TAGS",ln,{transform:O,base:ln}),xe=et(a,"FORBID_CONTENTS",sn,{transform:O}),Ne=et(a,"FORBID_TAGS",be({}),{transform:O}),Qt=et(a,"FORBID_ATTR",be({}),{transform:O}),we=pe(a,"USE_PROFILES")?a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?be(a.USE_PROFILES):a.USE_PROFILES:!1,Jt=a.ALLOW_ARIA_ATTR!==!1,dt=a.ALLOW_DATA_ATTR!==!1,en=a.ALLOW_UNKNOWN_PROTOCOLS||!1,tn=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=a.SAFE_FOR_TEMPLATES||!1,he=a.SAFE_FOR_XML!==!1,ue=a.WHOLE_DOCUMENT||!1,Se=a.RETURN_DOM||!1,We=a.RETURN_DOM_FRAGMENT||!1,je=a.RETURN_TRUSTED_TYPE||!1,ut=a.FORCE_BODY||!1,nn=a.SANITIZE_DOM!==!1,on=a.SANITIZE_NAMED_PROPS||!1,ft=a.KEEP_CONTENT!==!1,pt=a.IN_PLACE||!1,Xt=Qr(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:co,Ce=typeof a.NAMESPACE=="string"?a.NAMESPACE:K,bt=Gn(a,"MATHML_TEXT_INTEGRATION_POINTS",()=>N({},hn)),yt=Gn(a,"HTML_INTEGRATION_POINTS",()=>N({},un));const d=Gn(a,"CUSTOM_ELEMENT_HANDLING",()=>Ct(null));if(V=Ct(null),pe(d,"tagNameCheck")&&fn(d.tagNameCheck)&&(V.tagNameCheck=d.tagNameCheck),pe(d,"attributeNameCheck")&&fn(d.attributeNameCheck)&&(V.attributeNameCheck=d.attributeNameCheck),pe(d,"allowCustomizedBuiltInElements")&&typeof d.allowCustomizedBuiltInElements=="boolean"&&(V.allowCustomizedBuiltInElements=d.allowCustomizedBuiltInElements),ee(V),re&&(dt=!1),We&&(Se=!0),we&&(M=N({},so),L=Ct(null),we.html===!0&&(N(M,ro),N(L,ao)),we.svg===!0&&(N(M,Wn),N(L,Kn),N(L,kn)),we.svgFilters===!0&&(N(M,jn),N(L,Kn),N(L,kn)),we.mathMl===!0&&(N(M,Vn),N(L,lo),N(L,kn))),oe.tagCheck=null,oe.attributeCheck=null,pe(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?oe.tagCheck=a.ADD_TAGS:At(a.ADD_TAGS)&&(M===lt&&(M=be(M)),N(M,a.ADD_TAGS,O))),pe(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?oe.attributeCheck=a.ADD_ATTR:At(a.ADD_ATTR)&&(L===ct&&(L=be(L)),N(L,a.ADD_ATTR,O))),pe(a,"ADD_FORBID_CONTENTS")&&At(a.ADD_FORBID_CONTENTS)&&(xe===sn&&(xe=be(xe)),N(xe,a.ADD_FORBID_CONTENTS,O)),ft&&(M["#text"]=!0),ue&&N(M,["html","head","body"]),M.table&&(N(M,["tbody"]),delete Ne.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=D;D=a.TRUSTED_TYPES_POLICY;try{z=ne("")}catch(y){throw D=f,y}}else a.TRUSTED_TYPES_POLICY===null?(D=void 0,z=""):(D===void 0&&(D=qt()),D&&typeof z=="string"&&(z=ne("")));Z&&Z(a),Ae=a},pn=N({},[...Wn,...jn,...Jr]),gn=N({},[...Vn,...es]),$i=function(a,d,f){return d.namespaceURI===K?a==="svg":d.namespaceURI===Ve?a==="svg"&&(f==="annotation-xml"||bt[f]):!!pn[a]},zi=function(a,d,f){return d.namespaceURI===K?a==="math":d.namespaceURI===Ke?a==="math"&&yt[f]:!!gn[a]},Bi=function(a,d,f){return d.namespaceURI===Ke&&!yt[f]||d.namespaceURI===Ve&&!bt[f]?!1:!gn[a]&&(Ni[a]||!pn[a])},Ui=function(a){let d=w(a);(!d||!d.tagName)&&(d={namespaceURI:Ce,tagName:"template"});const f=_t(a.tagName),y=_t(d.tagName);return mt[a.namespaceURI]?a.namespaceURI===Ke?$i(f,d,y):a.namespaceURI===Ve?zi(f,d,y):a.namespaceURI===K?Bi(f,d,y):!!(Pe==="application/xhtml+xml"&&mt[a.namespaceURI]):!1},se=function(a){Ot(e.removed,{element:a});try{w(a).removeChild(a)}catch(d){if(T(a),!w(a))throw Je("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},mn=function(a,d,f){try{b(a,d)}catch(y){try{a.removeAttribute(f)}catch(S){}}},Ge=function(a){qe(a);const d=v(a);if(d){const y=[];rt(d,S=>{Ot(y,S)}),rt(y,S=>{try{T(S)}catch(x){}})}const f=U(a);if(f)for(let y=f.length-1;y>=0;--y){const S=f[y],x=S&&S.name;typeof x=="string"&&mn(a,S,x)}},fe=function(a,d,f){if(!f)try{f=d.getAttributeNode(a)}catch(y){f=null}Ot(e.removed,{attribute:f||null,from:d});try{f?b(d,f):d.removeAttribute(a)}catch(y){try{d.removeAttribute(a)}catch(S){}}if(a==="is")if(Se||We)try{se(d)}catch(y){}else try{d.setAttribute(a,"")}catch(y){}},Wi=function(a){const d=U(a);if(d)for(let f=d.length-1;f>=0;--f){const y=d[f],S=y&&y.name;typeof S!="string"||L[O(S)]||mn(a,y,S)}},qe=function(a){const d=[a];for(;d.length>0;){const f=d.pop();Q(f)===ye.element&&Wi(f);const y=v(f);if(y)for(let S=y.length-1;S>=0;--S)d.push(y[S])}},bn=function(a,d){return he?a==="patchsrc"?!0:a==="for"&&d!=="label"&&d!=="output":!1},ji=function(a){if(!he)return;const d=[a];for(;d.length>0;){const f=d.pop(),y=Q(f);if(y===ye.processingInstruction||y===ye.comment&&ae(uo,f.data)){try{T(f)}catch(x){}continue}if(y===ye.element){const x=f,C=O(me(f));try{x.hasAttribute&&x.hasAttribute("patchsrc")&&x.removeAttribute("patchsrc"),x.hasAttribute&&x.hasAttribute("for")&&bn("for",C)&&x.removeAttribute("for")}catch(R){}}const S=v(f);if(S)for(let x=S.length-1;x>=0;--x)d.push(S[x])}},yn=function(a){let d=null,f=null;if(ut)a="<remove></remove>"+a;else{const x=to(a,/^[\r\n\t ]+/);f=x&&x[0]}Pe==="application/xhtml+xml"&&Ce===K&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const y=D?ne(a):a;if(Ce===K)try{d=new h().parseFromString(y,Pe)}catch(x){}if(!d||!d.documentElement){d=ze.createDocument(Ce,"template",null);try{d.documentElement.innerHTML=gt?z:y}catch(x){}}const S=d.body||d.documentElement;return a&&f&&S.insertBefore(t.createTextNode(f),S.childNodes[0]||null),Ce===K?F.call(d,ue?"html":"body")[0]:ue?d.documentElement:S},Tn=function(a){const d=W?W(a):a.ownerDocument;return at.call(d||a,a,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ye=function(a){return a=It(a,Rt," "),a=It(a,Mi," "),a=It(a,Li," "),a},Et=function(a){var d;a.normalize();const f=W?W(a):a.ownerDocument,y=at.call(f||a,a,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let S=y.nextNode();for(;S;)S.data=Ye(S.data),S=y.nextNode();const x=(d=a.querySelectorAll)===null||d===void 0?void 0:d.call(a,"template");x&&rt(x,C=>{ke(C.content)&&Et(C.content)})},Ze=function(a){const d=H?H(a):null;return typeof d!="string"||O(d)!=="form"?!1:typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||a.attributes!==U(a)||typeof a.removeAttribute!="function"||typeof a.removeAttributeNode!="function"||typeof a.getAttributeNode!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function"||a.nodeType!==I(a)||a.childNodes!==v(a)},ke=function(a){if(!I||typeof a!="object"||a===null)return!1;try{return I(a)===ye.documentFragment}catch(d){return!1}},He=function(a){if(!I||typeof a!="object"||a===null)return!1;try{return typeof I(a)=="number"}catch(d){return!1}};function G(m,a,d){m.length!==0&&rt(m,f=>{f.call(e,a,d,Ae)})}const Vi=function(a,d){return!!(he&&a.hasChildNodes()&&!He(a.firstElementChild)&&ae(ho,a.textContent)&&ae(ho,a.innerHTML)||he&&a.namespaceURI===K&&us[d]&&(He(a.firstElementChild)||typeof a.textContent=="string"&&ae(fs[d],a.textContent))||a.nodeType===ye.processingInstruction||he&&a.nodeType===ye.comment&&ae(uo,a.data))},Xe=function(a,d){if(a instanceof RegExp)return ae(a,d);if(a instanceof Function){for(var f=arguments.length,y=new Array(f>2?f-2:0),S=2;S<f;S++)y[S-2]=arguments[S];return!!a(d,...y)}return!1},Ki=function(a,d,f){if(!Ne[d]&&wn(d)&&Xe(V.tagNameCheck,d))return!1;if(ft&&!xe[d]){const y=w(a),S=v(a);if(S&&y){const x=S.length;for(let C=x-1;C>=0;--C){const R=a===f?g(S[C],!0):S[C];y.insertBefore(R,E(a))}}}return se(a),!0},En=function(a,d,f,y){return a.length===0?d:d===f||d===y?be(d):d},Me=function(a,d){return a===d||w(a)!==null?!1:(pt&&qe(a),!0)},vn=function(a,d){if(G(k.beforeSanitizeElements,a,null),Me(a,d))return!0;if(Ze(a))return se(a),!0;const f=O(me(a));if(M=En(k.uponSanitizeElement,M,lt,Be),G(k.uponSanitizeElement,a,{tagName:f,allowedTags:M}),Me(a,d))return!0;if(Vi(a,f))return se(a),!0;if(Ne[f]||!(oe.tagCheck instanceof Function&&oe.tagCheck(f))&&!M[f]){const y=Ki(a,f,d);return y===!1&&(G(k.afterSanitizeElements,a,null),Me(a,d))?!0:y}if(Q(a)===ye.element&&!Ui(a)||(f==="noscript"||f==="noembed"||f==="noframes")&&ae(ds,a.innerHTML))return se(a),!0;if(re&&a.nodeType===ye.text){const y=Ye(a.textContent);a.textContent!==y&&(Ot(e.removed,{element:a.cloneNode()}),a.textContent=y)}return G(k.afterSanitizeElements,a,null),Me(a,d)},Sn=function(a,d,f){if(Qt[d]||bn(d,a)||nn&&(d==="id"||d==="name")&&(f in t||f in Fi))return!1;const y=L[d]||oe.attributeCheck instanceof Function&&oe.attributeCheck(d,a);return dt&&ae(Ri,d)||Jt&&ae(Oi,d)?!0:y?cn[d]||ae(Xt,It(f,Zt,""))||(d==="src"||d==="xlink:href"||d==="href")&&a!=="script"&&no(f,"data:")===0&&an[a]||en&&!ae(_i,It(f,Zt,""))?!0:!f:wn(a)&&Xe(V.tagNameCheck,a)&&Xe(V.attributeNameCheck,d,a)||d==="is"&&V.allowCustomizedBuiltInElements&&Xe(V.tagNameCheck,f)},Gi=N({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),wn=function(a){return!Gi[_t(a)]&&ae(Ii,a)},qi=function(a,d,f,y){if(D&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!f)switch(u.getAttributeType(a,d)){case"TrustedHTML":return ne(y);case"TrustedScriptURL":return Ie(y)}return y},Yi=function(a,d,f,y){try{return f?a.setAttributeNS(f,d,y):a.setAttribute(d,y),Ze(a)?(se(a),!1):!0}catch(S){return fe(d,a),!1}},xn=function(a,d){if(G(k.beforeSanitizeAttributes,a,null),Me(a,d))return;const f=a.attributes;if(!f||Ze(a))return;L=En(k.uponSanitizeAttribute,L,ct,Ue);const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0};let S=f.length;const x=O(a.nodeName);for(;S--;){const C=f[S],R=C.name,j=C.namespaceURI,B=C.value,Le=O(R),St=B;let $=R==="value"?St:Kr(St),Cn=!1;if(y.attrName=Le,y.attrValue=$,y.keepAttr=!0,y.forceKeepAttr=void 0,G(k.uponSanitizeAttribute,a,y),$=y.attrValue,on&&(Le==="id"||Le==="name")&&no($,rn)!==0&&(fe(R,a,C),$=rn+$,Cn=!0),he&&ae(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$)){fe(R,a,C);continue}if(Le==="attributename"&&to($,"href")){fe(R,a,C);continue}if(!y.forceKeepAttr){if(!y.keepAttr){fe(R,a,C);continue}if(!tn&&ae(hs,$)){fe(R,a,C);continue}if(re&&($=Ye($)),!Sn(x,Le,$)){fe(R,a,C);continue}$=qi(x,Le,j,$),$!==St&&Yi(a,R,j,$)&&Cn&&eo(e.removed)}}G(k.afterSanitizeAttributes,a,null),Me(a,d)},Qe=function(a){let d=null;const f=Tn(a);for(G(k.beforeSanitizeShadowDOM,a,null);d=f.nextNode();)if(G(k.uponSanitizeShadowNode,d,null),vn(d,a),xn(d,a),ke(d.content)&&Qe(d.content),Q(d)===ye.element){const y=A(d);ke(y)&&(vt(y),Qe(y))}G(k.afterSanitizeShadowDOM,a,null)},vt=function(a){const d=[{node:a,shadow:null}];for(;d.length>0;){const f=d.pop();if(f.shadow){Qe(f.shadow);continue}const y=f.node,S=Q(y)===ye.element,x=v(y);if(x)for(let C=x.length-1;C>=0;--C)d.push({node:x[C],shadow:null});if(S){const C=H?H(y):null;if(typeof C=="string"&&O(C)==="template"){const R=y.content;ke(R)&&d.push({node:R,shadow:null})}}if(S){const C=A(y);ke(C)&&d.push({node:null,shadow:C},{node:C,shadow:null})}}};return e.sanitize=function(m){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=null,f=null,y=null,S=null;if(gt=!m,gt&&(m="<!-->"),typeof m!="string"&&!He(m)&&(m=Xr(m),typeof m!="string"))throw Je("dirty is not a string, aborting");if(!e.isSupported)return m;ht?(M=Be,L=Ue):Tt(a),(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&(M=be(M)),k.uponSanitizeAttribute.length>0&&(L=be(L)),e.removed=[];const x=pt&&typeof m!="string"&&He(m);if(x){ji(m);const j=me(m);if(typeof j=="string"){const B=O(j);if(!M[B]||Ne[B])throw Ge(m),Je("root node is forbidden and cannot be sanitized in-place")}if(Ze(m))throw Ge(m),Je("root node is clobbered and cannot be sanitized in-place");try{vt(m)}catch(B){throw Ge(m),B}}else if(He(m))d=yn("<!---->"),f=d.ownerDocument.importNode(m,!0),f.nodeType===ye.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?d=f:d.appendChild(f),vt(d);else{if(!Se&&!re&&!ue&&m.indexOf("<")===-1)return D&&je?ne(m):m;if(d=yn(m),!d)return Se?null:je?z:""}d&&ut&&se(d.firstChild);const C=x?m:d;try{const j=Tn(C);for(;y=j.nextNode();)vn(y,C),xn(y,C),ke(y.content)&&Qe(y.content)}catch(j){throw x&&(Ge(m),rt(e.removed,B=>{B.element&&qe(B.element)})),j}if(x){let j=!1;if(rt(e.removed,B=>{B.element&&(B.element===m&&(j=!0),qe(B.element))}),j)throw Je("a node selected for removal could not be safely returned; refusing to sanitize in place");return re&&Et(m),m}if(Se){if(re&&Et(d),We)for(S=Yt.call(d.ownerDocument);d.firstChild;)S.appendChild(d.firstChild);else S=d;return(L.shadowroot||L.shadowrootmode)&&(S=$e.call(n,S,!0)),S}let R=ue?d.outerHTML:d.innerHTML;return ue&&M["!doctype"]&&d.ownerDocument&&d.ownerDocument.doctype&&d.ownerDocument.doctype.name&&ae(ls,d.ownerDocument.doctype.name)&&(R="<!DOCTYPE "+d.ownerDocument.doctype.name+`>
|
|
11
|
-
`+R),re&&(R=Ye(R)),D&&je?ne(R):R},e.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Tt(m),ht=!0,Be=M,Ue=L},e.clearConfig=function(){Ae=null,ht=!1,Be=null,Ue=null,D=J,z=""},e.isValidAttribute=function(m,a,d){Ae||Tt({});const f=O(m),y=O(a);return Sn(f,y,d)},e.addHook=function(m,a){typeof a=="function"&&pe(k,m)&&Ot(k[m],a)},e.removeHook=function(m,a){if(pe(k,m)){if(a!==void 0){const d=jr(k[m],a);return d===-1?void 0:Vr(k[m],d,1)[0]}return eo(k[m])}},e.removeHooks=function(m){pe(k,m)&&(k[m]=[])},e.removeAllHooks=function(){k=po()},e}var Mn=go();const ms=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],bs={"*":["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"]},ys="data-editora-embed";function Ts(r){if(!r||/\s/.test(r.trim()))return!1;try{const e=new URL(r.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function mo(r,e,t,n){if((e==null?void 0:e.sanitize)===!1)return r;const i=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:ms,o=t!=null&&t.length?Array.from(new Set([...i,...t])):i,l=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:bs,c=new Set;for(const p of Object.values(l))for(const g of p)c.add(g);const h={ALLOWED_TAGS:o,ALLOWED_ATTR:Array.from(c)};if(!n)return Mn.sanitize(r,h);const u=o.includes("iframe");Mn.addHook("uponSanitizeElement",(p,g)=>{var b;if(g.tagName!=="iframe")return;const T=p;g.allowedTags.iframe=u||((b=T.getAttribute)==null?void 0:b.call(T,ys))==="true"&&Ts(T.getAttribute("src"))});try{return Mn.sanitize(r,h)}finally{Mn.removeHook("uponSanitizeElement")}}function Es(r,e,t,n){return mo(r,e,n,!1)}function vs(r,e,t){return(t==null?void 0:t.sanitizeOnPaste)===!1?r:Es(r,e)}function bo(r,e,t,n){return(t==null?void 0:t.sanitizeOnInput)===!1?r:mo(r,e,n,!0)}const Ss=".resize-handle, .table-resize-handle",ws=/resize-handle/;function yo(r){if(!r||!ws.test(r))return r;const e=document.createElement("template");e.innerHTML=r;const t=new Set;return e.content.querySelectorAll(Ss).forEach(n=>{const i=n.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&t.add(i),n.remove()}),t.forEach(n=>{var i;n.style.position==="relative"&&(n.style.removeProperty("position"),(i=n.getAttribute("style"))!=null&&i.trim()||n.removeAttribute("style"))}),e.innerHTML}function Nt(r){return r?yo(r.innerHTML):""}const $n=class $n{static resolve(e){const t={};if(Object.assign(t,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(t,e.pluginDefaults),e.attributes){const n=this.parseAttributes(e.attributes);Object.assign(t,n)}return e.jsConfig&&Object.assign(t,e.jsConfig),this.normalizeConfig(t)}static normalizeConfig(e){const t={...e};if(t.toolbarFloating!==void 0||t.toolbarSticky!==void 0){const s=typeof t.toolbar=="object"&&t.toolbar?{...t.toolbar}:typeof t.toolbar=="string"?{items:t.toolbar}:{};t.toolbarFloating!==void 0&&(s.floating=!!t.toolbarFloating),t.toolbarSticky!==void 0&&(s.sticky=!!t.toolbarSticky),t.toolbar=s}if(t.toolbarItems!==void 0&&typeof t.toolbar=="object"&&t.toolbar&&(t.toolbar.items=t.toolbarItems),t.autosaveEnabled!==void 0||t.autosaveIntervalMs!==void 0||t.autosaveStorageKey!==void 0||t.autosaveProvider!==void 0||t.autosaveApiUrl!==void 0){const s=typeof t.autosave=="object"&&t.autosave?{...t.autosave}:{};t.autosaveEnabled!==void 0&&(s.enabled=!!t.autosaveEnabled),t.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(t.autosaveIntervalMs)),t.autosaveStorageKey!==void 0&&(s.storageKey=t.autosaveStorageKey),t.autosaveProvider!==void 0&&(s.provider=t.autosaveProvider),t.autosaveApiUrl!==void 0&&(s.apiUrl=t.autosaveApiUrl),t.autosave=s}const n={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof t.autosave=="boolean")t.autosave={...n,enabled:t.autosave};else if(typeof t.autosave=="object"&&t.autosave){const s={...n,...t.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=n.intervalMs),t.autosave=s}else t.autosave=n;if(t.languageLocale!==void 0||t.languageDirection!==void 0){const s=typeof t.language=="object"&&t.language?{...t.language}:{};t.languageLocale!==void 0&&(s.locale=t.languageLocale),t.languageDirection!==void 0&&(s.direction=t.languageDirection),t.language=s}const i={locale:"en",direction:"ltr"};if(typeof t.language=="string"?t.language={locale:t.language,direction:i.direction}:typeof t.language=="object"&&t.language?t.language={...i,...t.language}:t.language=i,t.spellcheckEnabled!==void 0||t.spellcheckProvider!==void 0||t.spellcheckApiUrl!==void 0){const s=typeof t.spellcheck=="object"&&t.spellcheck?{...t.spellcheck}:{};t.spellcheckEnabled!==void 0&&(s.enabled=!!t.spellcheckEnabled),t.spellcheckProvider!==void 0&&(s.provider=t.spellcheckProvider),t.spellcheckApiUrl!==void 0&&(s.apiUrl=t.spellcheckApiUrl),t.spellcheck=s}const o={enabled:!1,provider:"browser",apiUrl:""};if(typeof t.spellcheck=="boolean")t.spellcheck={...o,enabled:t.spellcheck};else if(typeof t.spellcheck=="object"&&t.spellcheck){const s={...o,...t.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),t.spellcheck=s}else t.spellcheck=o;return t.contextMenuEnabled!==void 0&&(t.contextMenu={enabled:!!t.contextMenuEnabled}),typeof t.contextMenu=="boolean"?t.contextMenu={enabled:t.contextMenu}:typeof t.contextMenu=="object"&&t.contextMenu?t.contextMenu={enabled:t.contextMenu.enabled!==!1}:t.contextMenu={enabled:!0},(t.pasteClean!==void 0||t.pasteKeepFormatting!==void 0||t.pasteConvertWord!==void 0)&&(t.paste={...t.paste||{},...t.pasteClean!==void 0?{clean:!!t.pasteClean}:{},...t.pasteKeepFormatting!==void 0?{keepFormatting:!!t.pasteKeepFormatting}:{},...t.pasteConvertWord!==void 0?{convertWord:!!t.pasteConvertWord}:{}}),t.paste={clean:!0,keepFormatting:!1,convertWord:!0,...t.paste||{}},t.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...t.contentConfig||{}},(t.securitySanitizeOnPaste!==void 0||t.securitySanitizeOnInput!==void 0)&&(t.security={...t.security||{},...t.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!t.securitySanitizeOnPaste}:{},...t.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!t.securitySanitizeOnInput}:{}}),t.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...t.security||{}},(t.accessibilityEnableAria!==void 0||t.accessibilityKeyboardNavigation!==void 0||t.accessibilityChecker!==void 0)&&(t.accessibility={...t.accessibility||{},...t.accessibilityEnableAria!==void 0?{enableARIA:!!t.accessibilityEnableAria}:{},...t.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!t.accessibilityKeyboardNavigation}:{},...t.accessibilityChecker!==void 0?{checker:!!t.accessibilityChecker}:{}}),typeof t.accessibility=="boolean"&&(t.accessibility={enableARIA:t.accessibility,keyboardNavigation:t.accessibility,checker:!1}),t.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...t.accessibility||{}},(t.performanceDebounceInputMs!==void 0||t.performanceViewportOnlyScan!==void 0)&&(t.performance={...t.performance||{},...t.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(t.performanceDebounceInputMs)}:{},...t.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!t.performanceViewportOnlyScan}:{}}),typeof t.performance=="boolean"&&(t.performance={debounceInputMs:100,viewportOnlyScan:t.performance}),t.performance={debounceInputMs:100,viewportOnlyScan:!0,...t.performance||{}},(typeof t.performance.debounceInputMs!="number"||!Number.isFinite(t.performance.debounceInputMs)||t.performance.debounceInputMs<0)&&(t.performance.debounceInputMs=100),t}static parseAttributes(e){const t={};for(const[n,i]of Object.entries(e)){const o=this.kebabToCamel(n);t[o]=this.BOOLEAN_ATTRIBUTES.has(n)&&(i===""||i===n)?!0:this.parseAttributeValue(i)}return t}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(t){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}static validate(e){const t=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&t.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&t.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&t.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&t.push("theme must be a string"),{valid:t.length===0,errors:t}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const t={};for(const n of e)for(const[i,o]of Object.entries(n))o!=null&&(typeof o=="object"&&!Array.isArray(o)&&t[i]?t[i]=this.merge(t[i],o):t[i]=o);return t}};$n.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},$n.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 qn=$n;const xs='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Ln;const Cs="__editoraCommandEditorRoot",As="__editoraLastCommandButton",To="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",Eo=".rte-content, .editora-content",ks="Rich text editor",Yn=new Set;let tt=null,vo=!1,Zn=null,Xn=null;function So(r){if(!(r instanceof HTMLElement))return!1;const e=r;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function Ms(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function Pt(r){if(!r)return null;if(So(r))return r;const e=r.matches(To)?r:r.closest(To);return!e||!So(e)?null:e}function Ls(){var i;if(typeof window=="undefined")return null;const r=window[Cs];if(r instanceof HTMLElement){const o=Pt(r);if(o)return o;const s=r.matches(Eo)?r:r.querySelector(Eo);if(s){const l=Pt(s);if(l)return l}}const e=window[As];if(e instanceof HTMLElement){const o=Pt(e);if(o)return o}const t=document.activeElement;if(t){const o=Pt(t);if(o)return o}const n=(i=window.getSelection)==null?void 0:i.call(window);if(n&&n.rangeCount>0){const o=Pt(Ms(n.getRangeAt(0).startContainer));if(o)return o}if(tt&&tt.isConnected)return tt;for(const o of Yn)if(o.isConnected)return o;return null}function Rs(){if(typeof window=="undefined"||vo)return;Zn=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,Xn=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const r=(e,...t)=>{const n=Ls();return n?n.execCommand(e,...t):Zn?Zn(e,...t):Xn?Xn(e,...t):!1};window.executeEditorCommand=r,window.execEditorCommand=r,vo=!0}function Os(){const r="editora-webcomponent-styles";if(!document.getElementById(r)){const e=document.createElement("style");e.id=r,e.textContent=xs,document.head.appendChild(e)}}function _s(){if(!Ln){const r=Fe.__globalPluginLoader;r?Ln=r:Ln=new xt}return Ln}class Fe extends HTMLElement{constructor(){if(super(),this.pluginLoader=_s(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Nr,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,Os(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(Fe.__globalPluginLoader){this.pluginLoader=Fe.__globalPluginLoader;return}return new Promise(e=>{const t=()=>{Fe.__globalPluginLoader?(this.pluginLoader=Fe.__globalPluginLoader,e()):setTimeout(t,0)};t()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,t,n){t!==n&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,n))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var i;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),Yn.add(this),tt||(tt=this),Rs(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();if(this.loadedPlugins=e,e.forEach(o=>{if(o.init&&typeof o.init=="function")try{o.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${o.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const o=this.innerHTML.trim();o&&this.setAttribute("data-initial-content",o)}const t=this.preservedContent;this.preservedContent=null;const n=this.sanitizeLoadedContent((i=t!=null?t:this.restoreAutosavedContent())!=null?i:this.getAttribute("data-initial-content")||"");this.engine=new Ar({content:n,plugins:e,readonly:this.config.readonly}),this.createUI(e,n),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(n=>n.nodeType===Node.TEXT_NODE?n.textContent:n.nodeType===Node.ELEMENT_NODE?n.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],t=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(t){if(typeof this.config.plugins=="string"){const o=this.config.plugins.split(/\s+/).filter(Boolean);i&&!o.includes("a11yChecker")&&o.push("a11yChecker");for(const s of o){const l=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));l&&e.push(l)}}else if(Array.isArray(this.config.plugins)){for(const o of this.config.plugins)if(typeof o=="string"){const s=await this.pluginLoader.load(o,this.getPluginLoadConfig(o));s&&e.push(s)}else e.push(o);if(i&&!e.some(o=>(o==null?void 0:o.name)==="a11yChecker")){const o=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));o&&e.push(o)}}}else{const o=this.pluginLoader.getRegisteredPluginNames();for(const s of o){const l=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));l&&e.push(l)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const t=this.config.toolbar;if(typeof t=="string")return t;if(!t||typeof t!="object")return;const n=t.items;if(typeof n=="string")return n;if(Array.isArray(n))return n.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var t;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const n=Number((t=e.debounceInputMs)!=null?t:100);return{debounceInputMs:Number.isFinite(n)&&n>=0?n:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){var t;if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const n=(t=this.getAttribute("aria-label"))==null?void 0:t.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",n||i||ks)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const t=e.provider||"browser";return{enabled:!!e.enabled,provider:t,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),t=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=t,this.contentElement.setAttribute("spellcheck",t?"true":"false")}executeCommand(e,...t){var o;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const n={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(s=>s.commands&&s.commands[e]);if(i&&i.commands){const s=i.commands[e];if(typeof s=="function")try{return e==="toggleFullscreen"?s(this,n):s(...t,n),!0}catch(l){return console.error(`[RichTextEditor] Error executing native command ${e}:`,l),!1}}return((o=this.engine)==null?void 0:o.execCommand(e,...t))||!1}getPluginLoadConfig(e){const t=this.config.pluginConfig;if(t&&typeof t=="object"){const o=t[e];if(o&&typeof o=="object")return o}const n={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[e,e.toLowerCase(),...n[e]||[]];for(const o of i){const s=this.config[o];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(e){return bo(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var t,n;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((n=(t=e.intervalMs)!=null?t:e.interval)!=null?n:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const t=this.getAutosaveConfig();if(t.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,t.provider==="localStorage"){try{localStorage.setItem(t.storageKey,e),localStorage.setItem(`${t.storageKey}-timestamp`,Date.now().toString())}catch(n){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",n)}return}t.provider==="api"&&t.apiUrl&&fetch(t.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(n=>{console.error("[RichTextEditor] Failed to save autosave content to API:",n)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const t=localStorage.getItem(e.storageKey);if(t)return this.lastAutosavedContent=t,t}catch(t){console.error("[RichTextEditor] Failed to restore autosaved content:",t)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(Nt(this.contentElement))},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0);n.deleteContents();const i=document.createElement("div");i.innerHTML=e;const o=document.createDocumentFragment();for(;i.firstChild;)o.appendChild(i.firstChild);n.insertNode(o),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,t){const n=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!n?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new kr({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((o,s)=>{var l;if(this.contentElement){this.contentElement.focus();const c=window.getSelection();if(!c||c.rangeCount===0||!this.contentElement.contains(c.anchorNode)){const h=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?h.setStart(u,((l=u.textContent)==null?void 0:l.length)||0):u.nodeType===Node.ELEMENT_NODE?(h.selectNodeContents(u),h.collapse(!1)):h.setStart(this.contentElement,0),h.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(h)}}return this.executeCommand(o,s)}),this.toolbar.render(this.toolbarElement)):n&&this.appendChild(n),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(o){console.warn("defaultParagraphSeparator not supported:",o)}if(t){const o=document.createElement("div");o.innerHTML=t.trim(),!Array.from(o.childNodes).some(l=>{if(l.nodeType===Node.ELEMENT_NODE){const c=l.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(c)}return!1})&&t.trim()?this.contentElement.innerHTML=`<p>${t.trim()}</p>`:this.contentElement.innerHTML=t}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Mr({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 Lr({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var o;return(o=this.contentElement)==null?void 0:o.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",n=>{this.lastBeforeInputType=n.inputType||null}),this.contentElement.addEventListener("input",n=>{var g;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const o=(g=n==null?void 0:n.detail)==null?void 0:g.allowedTags,s=this.getPerformanceConfig(),l=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),h=this.lastBeforeInputType;if(this.lastBeforeInputType=null,c.sanitizeOnInput!==!1&&l.sanitize!==!1&&!h){const T=bo(i,l,c,o);if(T!==i){const b=window.getSelection(),E=b&&b.rangeCount>0?b.getRangeAt(0):null;if(this.contentElement.innerHTML=T,E&&b)try{b.removeAllRanges(),b.addRange(E)}catch(v){}i=T}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const p=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:yo(i)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(p,s.debounceInputMs):p(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",n=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&n.preventDefault()}),this.contentElement.addEventListener("paste",n=>{var u,p;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented)return;n.preventDefault();const i=this.config.paste||{};let o=((u=n.clipboardData)==null?void 0:u.getData("text/html"))||"";const s=((p=n.clipboardData)==null?void 0:p.getData("text/plain"))||"",l=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),h=!!o&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(o);if((i.clean||!i.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(i.convertWord===!1&&h&&s){document.execCommand("insertText",!1,s);return}if(o){c.sanitizeOnPaste!==!1&&l.sanitize!==!1&&(o=vs(o,l,c)),this.insertHTMLAtSelection(o);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{tt=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Nt(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",n=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(n,(o,s)=>{this.executeCommand(o,s)})});const t=()=>{const n=this.getSelectionRangeInEditor(),i=document.activeElement,o=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!o||!n&&!o||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=t,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0),n=t.commonAncestorContainer;return this.contentElement.contains(n)?t:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const t=document.createRange();return t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.collapsed}catch(t){return!1}}getSelectionAnchorRect(e,t){const n=Array.from(t.getClientRects()).filter(o=>o.width>0||o.height>0);return n.length===0?t.getBoundingClientRect():this.isSelectionBackward(e)?n[0]:n[n.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const t=this.getPerformanceConfig(),n=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!n){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const o=window.getSelection();if(!o){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(o,i);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),t=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!t)return;const n=this.contentElement.textContent||"",{words:i,chars:o}=Ir(n),s=_r(this.contentElement);let l,c;const h=this.getSelectionRangeInEditor();h&&(l=Rr(this.contentElement,h),h.collapsed||(c=Dr(h,l),l=void 0)),this.statusBar.update({wordCount:i,charCount:o,lineCount:s,cursorPosition:l,selectionInfo:c})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,t){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(t)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(t));break;case"theme":this.classList.forEach(n=>{n.startsWith("editora-theme-")&&this.classList.remove(n)}),t&&this.classList.add(`editora-theme-${t}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",t),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(n=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",n)})}));break}}resolveConfig(){const e={};for(let t=0;t<this.attributes.length;t++){const n=this.attributes[t];e[n.name]=n.value}return qn.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>Nt(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))},execCommand:(e,t)=>this.executeCommand(e,t),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,t)=>(this.addEventListener(e,t),()=>this.removeEventListener(e,t)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,t,n,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=Nt(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(t=this.toolbar)==null||t.destroy(),(n=this.floatingToolbar)==null||n.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,Yn.delete(this),tt===this&&(tt=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return Nt(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))}execCommand(e,...t){return this.executeCommand(e,...t)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}const Qn=new xt;Fe.__globalPluginLoader=Qn;const Is={bold:()=>Promise.resolve().then(()=>$s).then(r=>r.BoldPlugin()),italic:()=>Promise.resolve().then(()=>Bs).then(r=>r.ItalicPlugin()),underline:()=>Promise.resolve().then(()=>Us).then(r=>r.UnderlinePlugin()),strikethrough:()=>Promise.resolve().then(()=>Vs).then(r=>r.StrikethroughPlugin()),clearFormatting:()=>Promise.resolve().then(()=>oa).then(r=>r.ClearFormattingPlugin()),heading:()=>Promise.resolve().then(()=>Ta).then(r=>r.HeadingPlugin()),blockquote:()=>Promise.resolve().then(()=>Oa).then(r=>r.BlockquotePlugin()),code:()=>Promise.resolve().then(()=>Rl).then(r=>r.CodePlugin()),list:()=>Promise.resolve().then(()=>Nl).then(r=>r.ListPlugin()),history:()=>Promise.resolve().then(()=>$l).then(r=>r.HistoryPlugin())};async function wo(){return Object.entries(Is).forEach(([r,e])=>{Qn.register(r,e)}),Qn}typeof window!="undefined"&&wo().then(r=>{Fe.__globalPluginLoader=r,customElements.get("editora-editor")||customElements.define("editora-editor",Fe);const e=document.querySelectorAll("editora-editor:not([data-initial-content])"),t=[];e.forEach(n=>{const i=n.innerHTML.trim();i&&(t.push(i),n.setAttribute("data-initial-content",i),n.innerHTML="")}),e.forEach((n,i)=>{n instanceof Fe&&!n.isInitialized&&t[i]&&n.setAttribute("content",t[i])})});const Rn="data-editora-selection-marker";function Ds(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function xo(r){return r?r.getAttribute("contenteditable")==="true"?r:r.querySelector('[contenteditable="true"]'):null}function Ns(r){var s;if((r==null?void 0:r.contentElement)instanceof HTMLElement)return r.contentElement;const e=xo((s=r==null?void 0:r.editorElement)!=null?s:null);if(e)return e;const t=typeof window!="undefined"?window.__editoraCommandEditorRoot:null,n=t instanceof HTMLElement?xo(t):null;if(n)return n;const i=window.getSelection();if(i&&i.rangeCount>0){const l=Ds(i.getRangeAt(0).startContainer),c=l==null?void 0:l.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}const o=document.activeElement;if(o instanceof HTMLElement){const l=o.closest('.rte-content, .editora-content, [contenteditable="true"]');if(l instanceof HTMLElement)return l}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function Ps(r){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);return r.contains(t.startContainer)&&r.contains(t.endContainer)}function Co(r){const e=document.createElement("span");return e.setAttribute(Rn,r),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function Hs(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);if(!r.contains(t.startContainer)||!r.contains(t.endContainer))return null;const n=t.collapsed,i=Co("start"),o=n?null:Co("end"),s=t.cloneRange();if(o){const c=s.cloneRange();c.collapse(!1),c.insertNode(o)}const l=s.cloneRange();return l.collapse(!0),l.insertNode(i),()=>{const c=window.getSelection(),h=document.createRange(),u=r.querySelector(`[${Rn}="start"]`),p=r.querySelector(`[${Rn}="end"]`);if(!c||!u){r.querySelectorAll(`[${Rn}]`).forEach(g=>g.remove());return}n||!p?(h.setStartBefore(u),h.collapse(!0)):(h.setStartAfter(u),h.setEndBefore(p)),c.removeAllRanges(),c.addRange(h),u.remove(),p==null||p.remove()}}function Fs(r,e,t){if(e!==t){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",r,e,t);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}catch(n){}}}function On(r){const e=Ns(r.context);if(!e)return!1;const t=e.innerHTML;Ps(e)&&e.focus({preventScroll:!0});let n=!1;try{n=document.execCommand(r.command,!1)}catch(s){n=!1}const i=e.innerHTML;if(r.normalize&&i!==t){const s=Hs(e);r.normalize(e),s==null||s()}const o=e.innerHTML;return t!==o&&(Fs(e,t,o),e.dispatchEvent(new Event("input",{bubbles:!0}))),n!==!1||t!==o}const $s=Object.freeze(Object.defineProperty({__proto__:null,BoldPlugin:()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:r=>{const e=typeof r=="string"?r:r.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(r,e)=>On({command:"bold",context:e})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}})},Symbol.toStringTag,{value:"Module"})),Jn=(r,e)=>On({command:"italic",context:e}),zs=(r,e)=>{var t;typeof window!="undefined"&&((t=window.registerEditorCommand)==null||t.call(window,r,e))},Ao=()=>{zs("toggleItalic",Jn)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ao):Ao());const Bs=Object.freeze(Object.defineProperty({__proto__:null,ItalicPlugin:()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:Jn},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),toggleItalic:Jn},Symbol.toStringTag,{value:"Module"})),Us=Object.freeze(Object.defineProperty({__proto__:null,UnderlinePlugin:()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(r,e)=>On({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}})},Symbol.toStringTag,{value:"Module"})),Ws=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:r=>(typeof r=="string"?r:r.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(r,e)=>On({command:"strikeThrough",context:e,normalize:js})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function js(r){r.querySelectorAll("strike, del").forEach(t=>{var i;const n=document.createElement("s");for(const o of Array.from(t.attributes))o.name!=="style"&&n.setAttribute(o.name,o.value);for(;t.firstChild;)n.appendChild(t.firstChild);(i=t.parentNode)==null||i.replaceChild(n,t)})}const Vs=Object.freeze(Object.defineProperty({__proto__:null,StrikethroughPlugin:Ws},Symbol.toStringTag,{value:"Module"}));function ko(r,e,t=r==null?void 0:r.innerHTML){if(!r||typeof t!="string"||e===t)return!1;try{if(typeof window.execEditorCommand=="function")return window.execEditorCommand("recordDomTransaction",r,e,t)!==!1;if(typeof window.executeEditorCommand=="function")return window.executeEditorCommand("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})!==!1}catch(n){}return!1}const Ks=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const r=Zs();if(!r)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!r.contains(t.commonAncestorContainer))return!1;const n=t.cloneRange(),i=r.innerHTML;return r.focus({preventScroll:!0}),ia(r,n),na(r,n),ko(r,i),r.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),Gs=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),qs=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),Ys=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function Zs(){const r=window.getSelection();if(r&&r.rangeCount>0){const t=r.getRangeAt(0).startContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement,i=n==null?void 0:n.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function Mo(r,e){try{if(typeof r.intersectsNode=="function")return r.intersectsNode(e)}catch(n){}const t=document.createRange();return e.nodeType===Node.ELEMENT_NODE?t.selectNodeContents(e):t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)>0&&r.compareBoundaryPoints(Range.START_TO_END,t)<0}function _n(r){let e=0,t=r;for(;t&&t.parentNode;)e+=1,t=t.parentNode;return e}function Xs(r){Ys.forEach(e=>{r.style.removeProperty(e)}),(!r.getAttribute("style")||r.style.length===0)&&r.removeAttribute("style"),r.classList.contains("rte-text-color")&&r.classList.remove("rte-text-color"),r.classList.contains("rte-bg-color")&&r.classList.remove("rte-bg-color"),r.classList.contains("rte-format-painted")&&r.classList.remove("rte-format-painted"),r.classList.length===0&&r.removeAttribute("class")}function ei(r){const e=r.parentNode;if(e){for(;r.firstChild;)e.insertBefore(r.firstChild,r);e.removeChild(r)}}function Qs(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Lo(r){Array.from(r.children).forEach(e=>{Qs(e)&&e.remove()})}function Ro(r){Lo(r),ei(r)}function Oo(r){var t;const e=document.createElement("p");for(Array.from(r.attributes).forEach(n=>{e.setAttribute(n.name,n.value)});r.firstChild;)e.appendChild(r.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),(t=r.parentNode)==null||t.replaceChild(e,r)}function Js(r){return!/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(r.tagName)||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, svg, math")}function ea(r){Array.from(r.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((t,n)=>_n(n)-_n(t)).forEach(t=>{t.isConnected&&Js(t)&&t.remove()})}function ta(r){if(Lo(r),r.parentElement instanceof HTMLLIElement){Ro(r);return}if(Array.from(r.childNodes).filter(i=>i.nodeType!==Node.TEXT_NODE||(i.textContent||"").trim()!=="").some(i=>i instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(i.tagName))){Ro(r);return}Oo(r)}function na(r,e){Array.from(r.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(Mo(e,n)&&qs.has(n.tagName)){if(n.tagName==="BLOCKQUOTE"){ta(n);return}Oo(n)}})}function ia(r,e){const t=Array.from(r.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));t.sort((n,i)=>_n(i)-_n(n)),t.forEach(n=>{if(n.isConnected&&Mo(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(Xs(n),Gs.has(n.tagName)){ei(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&ei(n)}}),ea(r)}const oa=Object.freeze(Object.defineProperty({__proto__:null,ClearFormattingPlugin:Ks},Symbol.toStringTag,{value:"Module"})),Ht='.rte-content, .editora-content, [contenteditable="true"]',ra="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",_o=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),Io="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",sa=new Set(["p","h1","h2","h3","h4","h5","h6"]);function Do(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function aa(r){const e=r==null?void 0:r.contentElement;if(e instanceof HTMLElement)return e;const t=r==null?void 0:r.editorElement;if(t instanceof HTMLElement){const s=t.querySelector(Ht);if(s instanceof HTMLElement)return s;if(t.getAttribute("contenteditable")==="true")return t}const n=window.getSelection();if(n&&n.rangeCount>0){const s=Do(n.getRangeAt(0).startContainer),l=s==null?void 0:s.closest(Ht);if(l instanceof HTMLElement)return l;const c=s==null?void 0:s.closest(ra),h=c==null?void 0:c.querySelector(Ht);if(h instanceof HTMLElement)return h}const i=document.activeElement,o=i==null?void 0:i.closest(Ht);return o instanceof HTMLElement?o:document.querySelector(Ht)}function la(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);return!r.contains(t.startContainer)||!r.contains(t.endContainer)?null:t}function No(r,e){let t=Do(e);if(!t||t===r||!r.contains(t))return null;for(;t.parentElement&&t.parentElement!==r;)t=t.parentElement;if(t.parentElement!==r)return null;if(t.matches(Io))return t;const n=t.closest(Io);return n instanceof HTMLElement&&n.parentElement===r?n:t}function Po(r,e){if(typeof r.intersectsNode=="function")try{return r.intersectsNode(e)}catch(n){return!1}const t=document.createRange();return t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0}function ca(r,e){const t=No(r,e.startContainer),n=No(r,e.endContainer);if(!t)return[];if(!n||t===n)return[t];const o=Array.from(r.children).filter(s=>s instanceof HTMLElement).filter(s=>Po(e,s));return o.length>0?o:[t]}function da(r,e){Array.from(r.attributes).forEach(t=>{e.setAttribute(t.name,t.value)})}function ti(r,e){for(;r.firstChild;)e.appendChild(r.firstChild)}function ha(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function In(r,e){const t=document.createElement(r);return e&&da(e,t),t}function Ho(r,e){const t=In(e,r);return ti(r,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function ua(r){const e=r.cloneNode(!1);return e instanceof HTMLElement?e:document.createElement(r.tagName.toLowerCase())}function Fo(r,e,t){const n=r.parentNode;if(!n)return[];const i=document.createDocumentFragment(),o=[];let s=null;const l=()=>{s&&s.children.length>0&&i.appendChild(s),s=null};return Array.from(r.children).forEach(c=>{if(c instanceof HTMLLIElement){if(e.has(c)){l();const h=Ho(c,t);i.appendChild(h),o.push(h);return}s||(s=ua(r)),s.appendChild(c)}}),l(),n.insertBefore(i,r),n.removeChild(r),o}function fa(r,e){var n;if(r.tagName.toLowerCase()===e)return[r];const t=In(e,r);return ti(r,t),t.innerHTML.trim()||(t.innerHTML="<br>"),(n=r.parentNode)==null||n.replaceChild(t,r),[t]}function pa(r,e){const t=r.parentNode;if(!t)return[];const n=document.createDocumentFragment(),i=[];return Array.from(r.childNodes).forEach(o=>{if(o instanceof HTMLElement&&ha(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(l=>{if(!(l instanceof HTMLLIElement))return;const c=Ho(l,e);n.appendChild(c),i.push(c)}),o.remove();return}if(o instanceof HTMLElement&&_o.has(o.tagName)){const l=In(e,o);ti(o,l),n.appendChild(l),i.push(l);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const s=In(e,r);s.appendChild(o),n.appendChild(s),i.push(s)}),t.insertBefore(n,r),t.removeChild(r),i}function ga(r){const e=window.getSelection();if(!e)return;const t=document.createRange(),n=r instanceof HTMLElement&&r.querySelector("p,li,h1,h2,h3,h4,h5,h6")||r;t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}function ma(r){r.dispatchEvent(new Event("input",{bubbles:!0}))}function ba(r,e,t){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",r,e,t);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}function ya(r,e){const t=new Map;return Array.from(r.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&Po(e,i)).forEach(i=>{var s;const o=i.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===r&&(t.has(o)||t.set(o,new Set),(s=t.get(o))==null||s.add(i))}),t}function Ft(r,e){const t=r.toLowerCase();if(!sa.has(t))return!1;const n=aa(e);if(!n)return!1;const i=la(n);if(!i)return!1;const o=n.innerHTML,s=[],l=ya(n,i);l.size>0?l.forEach((h,u)=>{s.push(...Fo(u,h,t))}):ca(n,i).forEach(u=>{if(u instanceof HTMLUListElement||u instanceof HTMLOListElement){const p=new Set(Array.from(u.children).filter(g=>g instanceof HTMLLIElement));s.push(...Fo(u,p,t));return}if(_o.has(u.tagName)){const p=u.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");s.push(...p?pa(u,t):fa(u,t))}});const c=n.innerHTML;return o===c||s.length===0?!1:(ba(n,o,c),ma(n),ga(s[0]),!0)}const Ta=Object.freeze(Object.defineProperty({__proto__:null,HeadingPlugin:()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(r,e)=>r?Ft(r,e):!1,setHeading1:(r,e)=>Ft("h1",e),setHeading2:(r,e)=>Ft("h2",e),setHeading3:(r,e)=>Ft("h3",e),setParagraph:(r,e)=>Ft("p",e)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}})},Symbol.toStringTag,{value:"Module"})),$t='.rte-content, .editora-content, [contenteditable="true"]',Ea="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",$o=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function ni(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function va(r){const e=r==null?void 0:r.contentElement;if(e instanceof HTMLElement)return e;const t=r==null?void 0:r.editorElement;if(t instanceof HTMLElement){const s=t.querySelector($t);if(s instanceof HTMLElement)return s;if(t.getAttribute("contenteditable")==="true")return t}const n=window.getSelection();if(n&&n.rangeCount>0){const s=ni(n.getRangeAt(0).startContainer),l=s==null?void 0:s.closest($t);if(l instanceof HTMLElement)return l;const c=s==null?void 0:s.closest(Ea),h=c==null?void 0:c.querySelector($t);if(h instanceof HTMLElement)return h}const i=document.activeElement,o=i==null?void 0:i.closest($t);return o instanceof HTMLElement?o:document.querySelector($t)}function Sa(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);return!r.contains(t.startContainer)||!r.contains(t.endContainer)?null:t}function zo(r,e){let t=ni(e);if(!t||t===r||!r.contains(t))return null;for(;t.parentElement&&t.parentElement!==r;)t=t.parentElement;if(t.parentElement!==r)return null;if(t.matches($o))return t;const n=t.closest($o);return n instanceof HTMLElement&&n.parentElement===r?n:t}function Bo(r,e){if(typeof r.intersectsNode=="function")try{return r.intersectsNode(e)}catch(n){return!1}const t=document.createRange();return t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0}function wa(r,e){const t=zo(r,e.startContainer),n=zo(r,e.endContainer);if(!t)return[];if(!n||t===n)return[t];const o=Array.from(r.children).filter(s=>s instanceof HTMLElement).filter(s=>Bo(e,s));return o.length>0?o:[t]}function Uo(r,e){const t=ni(e),n=t==null?void 0:t.closest("blockquote");return n instanceof HTMLQuoteElement&&r.contains(n)?n:null}function xa(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Ca(r){Array.from(r.children).forEach(e=>{xa(e)&&e.remove()})}function ii(r){Ca(r);const e=r.parentNode;if(!e)return;Array.from(r.childNodes).forEach(n=>{e.insertBefore(n,r)}),e.removeChild(r)}function Wo(r){return r.nodeType===Node.TEXT_NODE&&(r.textContent||"").trim()===""}function jo(r){const e=Array.from(r.childNodes).filter(n=>!Wo(n));if(e.length!==1)return null;const t=e[0];return t instanceof HTMLQuoteElement?t:null}function Aa(r){const e=document.createElement("blockquote");return Array.from(r.childNodes).filter(n=>!Wo(n)).forEach(n=>{e.appendChild(n)}),e.childNodes.length||(e.innerHTML="<br>"),r.appendChild(e),e}function ka(r,e){const t=Array.from(r.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&Bo(e,i)),n=new Set(t);return t.filter(i=>{var s,l;let o=(s=i.parentElement)==null?void 0:s.closest("li");for(;o;){if(n.has(o))return!1;o=(l=o.parentElement)==null?void 0:l.closest("li")}return!0})}function zt(r){const e=window.getSelection();if(!e)return;const t=document.createRange(),n=r instanceof HTMLElement&&r.querySelector("p,li,h1,h2,h3,h4,h5,h6")||r;t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}function Ma(r){r.dispatchEvent(new Event("input",{bubbles:!0}))}function La(r,e,t){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",r,e,t);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}function Ra(r){var u,p;const e=va(r);if(!e)return!1;const t=Sa(e);if(!t)return!1;const n=e.innerHTML,i=Uo(e,t.startContainer),o=Uo(e,t.endContainer),s=ka(e,t),l=wa(e,t),c=l.length>0&&l.every(g=>g.tagName==="BLOCKQUOTE");if(i&&i===o){const g=i.firstChild||i;ii(i),zt(g)}else if(s.length>0){const g=s.map(jo);if(g.every(Boolean)){const b=((u=g[0])==null?void 0:u.firstChild)||s[0];g.forEach(E=>{E&&ii(E)}),zt(b)}else{const b=s[0];s.forEach(E=>{jo(E)||Aa(E)}),zt(b)}}else if(c){const g=l[0].firstChild||l[0];l.forEach(ii),zt(g)}else{const g=l.filter(E=>E.tagName!=="BLOCKQUOTE");if(g.length===0)return!1;const T=document.createElement("blockquote"),b=g[0];(p=b.parentNode)==null||p.insertBefore(T,b),g.forEach(E=>{T.appendChild(E)}),zt(T)}const h=e.innerHTML;return n===h?!1:(La(e,n,h),Ma(e),!0)}const Oa=Object.freeze(Object.defineProperty({__proto__:null,BlockquotePlugin:()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(r,e)=>Ra(e)},keymap:{"Mod-Shift-9":"toggleBlockquote"}})},Symbol.toStringTag,{value:"Module"}));function _a(r){let e=!1;r.addEventListener("pointerdown",t=>{e=t.target!==r},!0),r.addEventListener("click",t=>{t.target===r&&e&&t.stopImmediatePropagation(),e=!1},!0)}const Vo="rte-dialog-base-styles";function Ia(){if(typeof document=="undefined"||document.getElementById(Vo))return;const r=document.createElement("style");r.id=Vo,r.textContent=`
|
|
9
|
+
`}),n}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}function Ji(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function qr(r){if(Array.isArray(r))return r}function Yr(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,o,s,l=[],c=!0,d=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(c=(n=o.call(t)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(u){d=!0,i=u}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(d)throw i}}return l}}function Xr(){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 Zr(r,e){return qr(r)||Yr(r,e)||Qr(r,e)||Xr()}function Qr(r,e){if(r){if(typeof r=="string")return Ji(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ji(r,e):void 0}}const eo=Object.entries,to=Object.setPrototypeOf,Jr=Object.isFrozen,es=Object.getPrototypeOf,ts=Object.getOwnPropertyDescriptor;let X=Object.freeze,te=Object.seal,kt=Object.create,no=typeof Reflect!="undefined"&&Reflect,Wn=no.apply,jn=no.construct;X||(X=function(e){return e}),te||(te=function(e){return e}),Wn||(Wn=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),jn||(jn=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const rt=q(Array.prototype.forEach),ns=q(Array.prototype.lastIndexOf),io=q(Array.prototype.pop),It=q(Array.prototype.push),is=q(Array.prototype.splice),Mt=Array.isArray,Dt=q(String.prototype.toLowerCase),Kn=q(String.prototype.toString),oo=q(String.prototype.match),Nt=q(String.prototype.replace),ro=q(String.prototype.indexOf),os=q(String.prototype.trim),rs=q(Number.prototype.toString),ss=q(Boolean.prototype.toString),so=typeof BigInt=="undefined"?null:q(BigInt.prototype.toString),ao=typeof Symbol=="undefined"?null:q(Symbol.prototype.toString),pe=q(Object.prototype.hasOwnProperty),Ht=q(Object.prototype.toString),ae=q(RegExp.prototype.test),Je=as(TypeError);function q(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return Wn(r,e,n)}}function as(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return jn(r,t)}}function H(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dt;if(to&&to(r,null),!Mt(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(Jr(e)||(e[n]=o),i=o)}r[i]=!0}return r}function ls(r){for(let e=0;e<r.length;e++)pe(r,e)||(r[e]=null);return r}function ye(r){const e=kt(null);for(const n of eo(r)){var t=Zr(n,2);const i=t[0],o=t[1];pe(r,i)&&(Mt(o)?e[i]=ls(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=ye(o):e[i]=o)}return e}function cs(r){switch(typeof r){case"string":return r;case"number":return rs(r);case"boolean":return ss(r);case"bigint":return so?so(r):"0";case"symbol":return ao?ao(r):"Symbol()";case"undefined":return Ht(r);case"function":case"object":{if(r===null)return Ht(r);const e=r,t=Re(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:Ht(n)}return Ht(r)}default:return Ht(r)}}function Re(r,e){for(;r!==null;){const n=ts(r,e);if(n){if(n.get)return q(n.get);if(typeof n.value=="function")return q(n.value)}r=es(r)}function t(){return null}return t}function ds(r){try{return ae(r,""),!0}catch(e){return!1}}const lo=X(["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"]),Vn=X(["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"]),Gn=X(["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"]),us=X(["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"]),qn=X(["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"]),hs=X(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),co=X(["#text"]),uo=X(["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"]),Yn=X(["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"]),ho=X(["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"]),Mn=X(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fs=te(/{{[\w\W]*|^[\w\W]*}}/g),ps=te(/<%[\w\W]*|^[\w\W]*%>/g),gs=te(/\${[\w\W]*/g),ms=te(/^data-[\-\w.\u00B7-\uFFFF]+$/),bs=te(/^aria-[\-\w]+$/),fo=te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ys=te(/^(?:\w+script|data):/i),Ts=te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Es=te(/^html$/i),vs=te(/^[a-z][.\w]*(-[.\w]+)+$/i),po=te(/<[/\w!]/g),go=te(/<[/\w]/g),Ss=te(/<\/no(script|embed|frames)/i),ws=te(/\/>/i),Te={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],xs=X(H({},mo)),Cs=(function(){const r={};return rt(mo,e=>{r[e]=te(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),X(r)})(),As=function(){return typeof window=="undefined"?null:window},ks=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},bo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},et=function(e,t,n,i){return pe(e,t)&&Mt(e[t])?H(i.base?ye(i.base):{},e[t],i.transform):n},Xn=function(e,t,n){const i=pe(e,t)?e[t]:void 0;return i&&typeof i=="object"?ye(i):n()};function yo(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:As();const e=b=>yo(b);if(e.version="3.4.16",e.removed=[],!r||!r.document||r.document.nodeType!==Te.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,l=r.Element,c=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const d=r.DOMParser,u=r.trustedTypes,f=l.prototype,p=Re(f,"cloneNode"),y=Re(f,"remove"),m=Re(f,"removeAttributeNode"),E=Re(f,"nextSibling"),v=Re(f,"childNodes"),w=Re(f,"parentNode"),A=Re(f,"shadowRoot"),B=Re(f,"attributes"),R=s&&s.prototype?Re(s.prototype,"nodeType"):null,D=s&&s.prototype?Re(s.prototype,"nodeName"):null,z=s&&s.prototype?Re(s.prototype,"ownerDocument"):null,J=function(a){return R?R(a):a.nodeType},be=function(a){return D?D(a):a.nodeName};if(typeof o=="function"){const b=t.createElement("template");b.content&&b.content.ownerDocument&&(t=b.content.ownerDocument)}let N,U="",ee,_e=!1,ce=0;const de=function(){if(ce>0)throw Je('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.')},ie=function(a){de(),ce++;try{return N.createHTML(a)}finally{ce--}},Ie=function(a){de(),ce++;try{return N.createScriptURL(a)}finally{ce--}},Yt=function(){return _e||(ee=ks(u,i),_e=!0),ee},De=t,Be=De.implementation,ct=De.createNodeIterator,Xt=De.createDocumentFragment,$=De.getElementsByTagName,Fe=n.importNode;let k=bo();e.isSupported=typeof eo=="function"&&typeof w=="function"&&Be&&Be.createHTMLDocument!==void 0;const _t=fs,Oi=ps,_i=gs,Ii=ms,Di=bs,Ni=ys,Zt=Ts,Hi=vs;let Qt=fo,M=null;const dt=H({},[...lo,...Vn,...Gn,...qn,...co]);let L=null;const ut=H({},[...uo,...Yn,...ho,...Mn]);let K=Object.seal(kt(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}})),Ne=null,Jt=null;const oe=Object.seal(kt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let en=!0,ht=!0,tn=!1,nn=!0,re=!1,ue=!0,he=!1,ft=!1,ze=null,Ue=null,pt=!1,Se=!1,We=!1,je=!1,on=!0,rn=!1;const sn="user-content-";let gt=!0,mt=!1,we={},xe=null;const an=H({},["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 ln=null;const cn=H({},["audio","video","img","source","image","track"]);let dn=null;const un=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",V="http://www.w3.org/1999/xhtml";let Ce=V,bt=!1,yt=null;const Pi=H({},[Ke,Ve,V],Kn),hn=X(["mi","mo","mn","ms","mtext"]);let Tt=H({},hn);const fn=X(["annotation-xml"]);let Et=H({},fn);const $i=H({},["title","style","font","a","script"]);let He=null;const Fi=["application/xhtml+xml","text/html"],Bi="text/html";let _=null,Ae=null;const zi=t.createElement("form"),pn=function(a){return a instanceof RegExp||a instanceof Function},vt=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ae&&Ae===a)return;(!a||typeof a!="object")&&(a={}),a=ye(a),He=Fi.indexOf(a.PARSER_MEDIA_TYPE)===-1?Bi:a.PARSER_MEDIA_TYPE,_=He==="application/xhtml+xml"?Kn:Dt,M=et(a,"ALLOWED_TAGS",dt,{transform:_}),L=et(a,"ALLOWED_ATTR",ut,{transform:_}),yt=et(a,"ALLOWED_NAMESPACES",Pi,{transform:Kn}),dn=et(a,"ADD_URI_SAFE_ATTR",un,{transform:_,base:un}),ln=et(a,"ADD_DATA_URI_TAGS",cn,{transform:_,base:cn}),xe=et(a,"FORBID_CONTENTS",an,{transform:_}),Ne=et(a,"FORBID_TAGS",ye({}),{transform:_}),Jt=et(a,"FORBID_ATTR",ye({}),{transform:_}),we=pe(a,"USE_PROFILES")?a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?ye(a.USE_PROFILES):a.USE_PROFILES:!1,en=a.ALLOW_ARIA_ATTR!==!1,ht=a.ALLOW_DATA_ATTR!==!1,tn=a.ALLOW_UNKNOWN_PROTOCOLS||!1,nn=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=a.SAFE_FOR_TEMPLATES||!1,ue=a.SAFE_FOR_XML!==!1,he=a.WHOLE_DOCUMENT||!1,Se=a.RETURN_DOM||!1,We=a.RETURN_DOM_FRAGMENT||!1,je=a.RETURN_TRUSTED_TYPE||!1,pt=a.FORCE_BODY||!1,on=a.SANITIZE_DOM!==!1,rn=a.SANITIZE_NAMED_PROPS||!1,gt=a.KEEP_CONTENT!==!1,mt=a.IN_PLACE||!1,Qt=ds(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:fo,Ce=typeof a.NAMESPACE=="string"?a.NAMESPACE:V,Tt=Xn(a,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},hn)),Et=Xn(a,"HTML_INTEGRATION_POINTS",()=>H({},fn));const h=Xn(a,"CUSTOM_ELEMENT_HANDLING",()=>kt(null));if(K=kt(null),pe(h,"tagNameCheck")&&pn(h.tagNameCheck)&&(K.tagNameCheck=h.tagNameCheck),pe(h,"attributeNameCheck")&&pn(h.attributeNameCheck)&&(K.attributeNameCheck=h.attributeNameCheck),pe(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(K.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),te(K),re&&(ht=!1),We&&(Se=!0),we&&(M=H({},co),L=kt(null),we.html===!0&&(H(M,lo),H(L,uo)),we.svg===!0&&(H(M,Vn),H(L,Yn),H(L,Mn)),we.svgFilters===!0&&(H(M,Gn),H(L,Yn),H(L,Mn)),we.mathMl===!0&&(H(M,qn),H(L,ho),H(L,Mn))),oe.tagCheck=null,oe.attributeCheck=null,pe(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?oe.tagCheck=a.ADD_TAGS:Mt(a.ADD_TAGS)&&(M===dt&&(M=ye(M)),H(M,a.ADD_TAGS,_))),pe(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?oe.attributeCheck=a.ADD_ATTR:Mt(a.ADD_ATTR)&&(L===ut&&(L=ye(L)),H(L,a.ADD_ATTR,_))),pe(a,"ADD_FORBID_CONTENTS")&&Mt(a.ADD_FORBID_CONTENTS)&&(xe===an&&(xe=ye(xe)),H(xe,a.ADD_FORBID_CONTENTS,_)),gt&&(M["#text"]=!0),he&&H(M,["html","head","body"]),M.table&&(H(M,["tbody"]),delete Ne.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const g=N;N=a.TRUSTED_TYPES_POLICY;try{U=ie("")}catch(T){throw N=g,T}}else a.TRUSTED_TYPES_POLICY===null?(N=void 0,U=""):(N===void 0&&(N=Yt()),N&&typeof U=="string"&&(U=ie("")));X&&X(a),Ae=a},gn=H({},[...Vn,...Gn,...us]),mn=H({},[...qn,...hs]),Ui=function(a,h,g){return h.namespaceURI===V?a==="svg":h.namespaceURI===Ke?a==="svg"&&(g==="annotation-xml"||Tt[g]):!!gn[a]},Wi=function(a,h,g){return h.namespaceURI===V?a==="math":h.namespaceURI===Ve?a==="math"&&Et[g]:!!mn[a]},ji=function(a,h,g){return h.namespaceURI===Ve&&!Et[g]||h.namespaceURI===Ke&&!Tt[g]?!1:!mn[a]&&($i[a]||!gn[a])},Ki=function(a){let h=w(a);(!h||!h.tagName)&&(h={namespaceURI:Ce,tagName:"template"});const g=Dt(a.tagName),T=Dt(h.tagName);return yt[a.namespaceURI]?a.namespaceURI===Ve?Ui(g,h,T):a.namespaceURI===Ke?Wi(g,h,T):a.namespaceURI===V?ji(g,h,T):!!(He==="application/xhtml+xml"&&yt[a.namespaceURI]):!1},se=function(a){It(e.removed,{element:a});try{w(a).removeChild(a)}catch(h){if(y(a),!w(a))throw Je("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},bn=function(a,h,g){try{m(a,h)}catch(T){try{a.removeAttribute(g)}catch(S){}}},Ge=function(a){qe(a);const h=v(a);if(h){const T=[];rt(h,S=>{It(T,S)}),rt(T,S=>{try{y(S)}catch(x){}})}const g=B(a);if(g)for(let T=g.length-1;T>=0;--T){const S=g[T],x=S&&S.name;typeof x=="string"&&bn(a,S,x)}},fe=function(a,h,g){if(!g)try{g=h.getAttributeNode(a)}catch(T){g=null}It(e.removed,{attribute:g||null,from:h});try{g?m(h,g):h.removeAttribute(a)}catch(T){try{h.removeAttribute(a)}catch(S){}}if(a==="is")if(Se||We)try{se(h)}catch(T){}else try{h.setAttribute(a,"")}catch(T){}},Vi=function(a){const h=B(a);if(h)for(let g=h.length-1;g>=0;--g){const T=h[g],S=T&&T.name;typeof S!="string"||L[_(S)]||bn(a,T,S)}},qe=function(a){const h=[a];for(;h.length>0;){const g=h.pop();J(g)===Te.element&&Vi(g);const T=v(g);if(T)for(let S=T.length-1;S>=0;--S)h.push(T[S])}},yn=function(a,h){return ue?a==="patchsrc"?!0:a==="for"&&h!=="label"&&h!=="output":!1},Gi=function(a){if(!ue)return;const h=[a];for(;h.length>0;){const g=h.pop(),T=J(g);if(T===Te.processingInstruction||T===Te.comment&&ae(go,g.data)){try{y(g)}catch(x){}continue}if(T===Te.element){const x=g,C=_(be(g));try{x.hasAttribute&&x.hasAttribute("patchsrc")&&x.removeAttribute("patchsrc"),x.hasAttribute&&x.hasAttribute("for")&&yn("for",C)&&x.removeAttribute("for")}catch(O){}}const S=v(g);if(S)for(let x=S.length-1;x>=0;--x)h.push(S[x])}},Tn=function(a){let h=null,g=null;if(pt)a="<remove></remove>"+a;else{const x=oo(a,/^[\r\n\t ]+/);g=x&&x[0]}He==="application/xhtml+xml"&&Ce===V&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const T=N?ie(a):a;if(Ce===V)try{h=new d().parseFromString(T,He)}catch(x){}if(!h||!h.documentElement){h=Be.createDocument(Ce,"template",null);try{h.documentElement.innerHTML=bt?U:T}catch(x){}}const S=h.body||h.documentElement;return a&&g&&S.insertBefore(t.createTextNode(g),S.childNodes[0]||null),Ce===V?$.call(h,he?"html":"body")[0]:he?h.documentElement:S},En=function(a){const h=z?z(a):a.ownerDocument;return ct.call(h||a,a,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ye=function(a){return a=Nt(a,_t," "),a=Nt(a,Oi," "),a=Nt(a,_i," "),a},St=function(a){var h;a.normalize();const g=z?z(a):a.ownerDocument,T=ct.call(g||a,a,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let S=T.nextNode();for(;S;)S.data=Ye(S.data),S=T.nextNode();const x=(h=a.querySelectorAll)===null||h===void 0?void 0:h.call(a,"template");x&&rt(x,C=>{ke(C.content)&&St(C.content)})},Xe=function(a){const h=D?D(a):null;return typeof h!="string"||_(h)!=="form"?!1:typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||a.attributes!==B(a)||typeof a.removeAttribute!="function"||typeof a.removeAttributeNode!="function"||typeof a.getAttributeNode!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function"||a.nodeType!==R(a)||a.childNodes!==v(a)},ke=function(a){if(!R||typeof a!="object"||a===null)return!1;try{return R(a)===Te.documentFragment}catch(h){return!1}},Pe=function(a){if(!R||typeof a!="object"||a===null)return!1;try{return typeof R(a)=="number"}catch(h){return!1}};function G(b,a,h){b.length!==0&&rt(b,g=>{g.call(e,a,h,Ae)})}const qi=function(a,h){return!!(ue&&a.hasChildNodes()&&!Pe(a.firstElementChild)&&ae(po,a.textContent)&&ae(po,a.innerHTML)||ue&&a.namespaceURI===V&&xs[h]&&(Pe(a.firstElementChild)||typeof a.textContent=="string"&&ae(Cs[h],a.textContent))||a.nodeType===Te.processingInstruction||ue&&a.nodeType===Te.comment&&ae(go,a.data))},Ze=function(a,h){if(a instanceof RegExp)return ae(a,h);if(a instanceof Function){for(var g=arguments.length,T=new Array(g>2?g-2:0),S=2;S<g;S++)T[S-2]=arguments[S];return!!a(h,...T)}return!1},Yi=function(a,h,g){if(!Ne[h]&&xn(h)&&Ze(K.tagNameCheck,h))return!1;if(gt&&!xe[h]){const T=w(a),S=v(a);if(S&&T){const x=S.length;for(let C=x-1;C>=0;--C){const O=a===g?p(S[C],!0):S[C];T.insertBefore(O,E(a))}}}return se(a),!0},vn=function(a,h,g,T){return a.length===0?h:h===g||h===T?ye(h):h},Me=function(a,h){return a===h||w(a)!==null?!1:(mt&&qe(a),!0)},Sn=function(a,h){if(G(k.beforeSanitizeElements,a,null),Me(a,h))return!0;if(Xe(a))return se(a),!0;const g=_(be(a));if(M=vn(k.uponSanitizeElement,M,dt,ze),G(k.uponSanitizeElement,a,{tagName:g,allowedTags:M}),Me(a,h))return!0;if(qi(a,g))return se(a),!0;if(Ne[g]||!(oe.tagCheck instanceof Function&&oe.tagCheck(g))&&!M[g]){const T=Yi(a,g,h);return T===!1&&(G(k.afterSanitizeElements,a,null),Me(a,h))?!0:T}if(J(a)===Te.element&&!Ki(a)||(g==="noscript"||g==="noembed"||g==="noframes")&&ae(Ss,a.innerHTML))return se(a),!0;if(re&&a.nodeType===Te.text){const T=Ye(a.textContent);a.textContent!==T&&(It(e.removed,{element:a.cloneNode()}),a.textContent=T)}return G(k.afterSanitizeElements,a,null),Me(a,h)},wn=function(a,h,g){if(Jt[h]||yn(h,a)||on&&(h==="id"||h==="name")&&(g in t||g in zi))return!1;const T=L[h]||oe.attributeCheck instanceof Function&&oe.attributeCheck(h,a);return ht&&ae(Ii,h)||en&&ae(Di,h)?!0:T?dn[h]||ae(Qt,Nt(g,Zt,""))||(h==="src"||h==="xlink:href"||h==="href")&&a!=="script"&&ro(g,"data:")===0&&ln[a]||tn&&!ae(Ni,Nt(g,Zt,""))?!0:!g:xn(a)&&Ze(K.tagNameCheck,a)&&Ze(K.attributeNameCheck,h,a)||h==="is"&&K.allowCustomizedBuiltInElements&&Ze(K.tagNameCheck,g)},Xi=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),xn=function(a){return!Xi[Dt(a)]&&ae(Hi,a)},Zi=function(a,h,g,T){if(N&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!g)switch(u.getAttributeType(a,h)){case"TrustedHTML":return ie(T);case"TrustedScriptURL":return Ie(T)}return T},Qi=function(a,h,g,T){try{return g?a.setAttributeNS(g,h,T):a.setAttribute(h,T),Xe(a)?(se(a),!1):!0}catch(S){return fe(h,a),!1}},Cn=function(a,h){if(G(k.beforeSanitizeAttributes,a,null),Me(a,h))return;const g=a.attributes;if(!g||Xe(a))return;L=vn(k.uponSanitizeAttribute,L,ut,Ue);const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0};let S=g.length;const x=_(a.nodeName);for(;S--;){const C=g[S],O=C.name,j=C.namespaceURI,W=C.value,Le=_(O),xt=W;let F=O==="value"?xt:os(xt),An=!1;if(T.attrName=Le,T.attrValue=F,T.keepAttr=!0,T.forceKeepAttr=void 0,G(k.uponSanitizeAttribute,a,T),F=T.attrValue,rn&&(Le==="id"||Le==="name")&&ro(F,sn)!==0&&(fe(O,a,C),F=sn+F,An=!0),ue&&ae(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,F)){fe(O,a,C);continue}if(Le==="attributename"&&oo(F,"href")){fe(O,a,C);continue}if(!T.forceKeepAttr){if(!T.keepAttr){fe(O,a,C);continue}if(!nn&&ae(ws,F)){fe(O,a,C);continue}if(re&&(F=Ye(F)),!wn(x,Le,F)){fe(O,a,C);continue}F=Zi(x,Le,j,F),F!==xt&&Qi(a,O,j,F)&&An&&io(e.removed)}}G(k.afterSanitizeAttributes,a,null),Me(a,h)},Qe=function(a){let h=null;const g=En(a);for(G(k.beforeSanitizeShadowDOM,a,null);h=g.nextNode();)if(G(k.uponSanitizeShadowNode,h,null),Sn(h,a),Cn(h,a),ke(h.content)&&Qe(h.content),J(h)===Te.element){const T=A(h);ke(T)&&(wt(T),Qe(T))}G(k.afterSanitizeShadowDOM,a,null)},wt=function(a){const h=[{node:a,shadow:null}];for(;h.length>0;){const g=h.pop();if(g.shadow){Qe(g.shadow);continue}const T=g.node,S=J(T)===Te.element,x=v(T);if(x)for(let C=x.length-1;C>=0;--C)h.push({node:x[C],shadow:null});if(S){const C=D?D(T):null;if(typeof C=="string"&&_(C)==="template"){const O=T.content;ke(O)&&h.push({node:O,shadow:null})}}if(S){const C=A(T);ke(C)&&h.push({node:null,shadow:C},{node:C,shadow:null})}}};return e.sanitize=function(b){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,g=null,T=null,S=null;if(bt=!b,bt&&(b="<!-->"),typeof b!="string"&&!Pe(b)&&(b=cs(b),typeof b!="string"))throw Je("dirty is not a string, aborting");if(!e.isSupported)return b;ft?(M=ze,L=Ue):vt(a),(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&(M=ye(M)),k.uponSanitizeAttribute.length>0&&(L=ye(L)),e.removed=[];const x=mt&&typeof b!="string"&&Pe(b);if(x){Gi(b);const j=be(b);if(typeof j=="string"){const W=_(j);if(!M[W]||Ne[W])throw Ge(b),Je("root node is forbidden and cannot be sanitized in-place")}if(Xe(b))throw Ge(b),Je("root node is clobbered and cannot be sanitized in-place");try{wt(b)}catch(W){throw Ge(b),W}}else if(Pe(b))h=Tn("<!---->"),g=h.ownerDocument.importNode(b,!0),g.nodeType===Te.element&&g.nodeName==="BODY"||g.nodeName==="HTML"?h=g:h.appendChild(g),wt(h);else{if(!Se&&!re&&!he&&b.indexOf("<")===-1)return N&&je?ie(b):b;if(h=Tn(b),!h)return Se?null:je?U:""}h&&pt&&se(h.firstChild);const C=x?b:h;try{const j=En(C);for(;T=j.nextNode();)Sn(T,C),Cn(T,C),ke(T.content)&&Qe(T.content)}catch(j){throw x&&(Ge(b),rt(e.removed,W=>{W.element&&qe(W.element)})),j}if(x){let j=!1;if(rt(e.removed,W=>{W.element&&(W.element===b&&(j=!0),qe(W.element))}),j)throw Je("a node selected for removal could not be safely returned; refusing to sanitize in place");return re&&St(b),b}if(Se){if(re&&St(h),We)for(S=Xt.call(h.ownerDocument);h.firstChild;)S.appendChild(h.firstChild);else S=h;return(L.shadowroot||L.shadowrootmode)&&(S=Fe.call(n,S,!0)),S}let O=he?h.outerHTML:h.innerHTML;return he&&M["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&ae(Es,h.ownerDocument.doctype.name)&&(O="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
|
|
11
|
+
`+O),re&&(O=Ye(O)),N&&je?ie(O):O},e.setConfig=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(b),ft=!0,ze=M,Ue=L},e.clearConfig=function(){Ae=null,ft=!1,ze=null,Ue=null,N=ee,U=""},e.isValidAttribute=function(b,a,h){Ae||vt({});const g=_(b),T=_(a);return wn(g,T,h)},e.addHook=function(b,a){typeof a=="function"&&pe(k,b)&&It(k[b],a)},e.removeHook=function(b,a){if(pe(k,b)){if(a!==void 0){const h=ns(k[b],a);return h===-1?void 0:is(k[b],h,1)[0]}return io(k[b])}},e.removeHooks=function(b){pe(k,b)&&(k[b]=[])},e.removeAllHooks=function(){k=bo()},e}var Ln=yo();const Ms=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],Ls={"*":["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"]},Rs="data-editora-embed";function Os(r){if(!r||/\s/.test(r.trim()))return!1;try{const e=new URL(r.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function To(r,e,t,n){if((e==null?void 0:e.sanitize)===!1)return r;const i=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:Ms,o=t!=null&&t.length?Array.from(new Set([...i,...t])):i,l=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:Ls,c=new Set;for(const f of Object.values(l))for(const p of f)c.add(p);const d={ALLOWED_TAGS:o,ALLOWED_ATTR:Array.from(c)};if(!n)return Ln.sanitize(r,d);const u=o.includes("iframe");Ln.addHook("uponSanitizeElement",(f,p)=>{var m;if(p.tagName!=="iframe")return;const y=f;p.allowedTags.iframe=u||((m=y.getAttribute)==null?void 0:m.call(y,Rs))==="true"&&Os(y.getAttribute("src"))});try{return Ln.sanitize(r,d)}finally{Ln.removeHook("uponSanitizeElement")}}function _s(r,e,t,n){return To(r,e,n,!1)}function Is(r,e,t){return(t==null?void 0:t.sanitizeOnPaste)===!1?r:_s(r,e)}function Eo(r,e,t,n){return(t==null?void 0:t.sanitizeOnInput)===!1?r:To(r,e,n,!0)}const Ds=".resize-handle, .table-resize-handle",Ns=/resize-handle/;function vo(r){if(!r||!Ns.test(r))return r;const e=document.createElement("template");e.innerHTML=r;const t=new Set;return e.content.querySelectorAll(Ds).forEach(n=>{const i=n.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&t.add(i),n.remove()}),t.forEach(n=>{var i;n.style.position==="relative"&&(n.style.removeProperty("position"),(i=n.getAttribute("style"))!=null&&i.trim()||n.removeAttribute("style"))}),e.innerHTML}function Pt(r){return r?vo(r.innerHTML):""}const Un=class Un{static resolve(e){const t={};if(Object.assign(t,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(t,e.pluginDefaults),e.attributes){const n=this.parseAttributes(e.attributes);Object.assign(t,n)}return e.jsConfig&&Object.assign(t,e.jsConfig),this.normalizeConfig(t)}static normalizeConfig(e){const t={...e};if(t.toolbarFloating!==void 0||t.toolbarSticky!==void 0){const s=typeof t.toolbar=="object"&&t.toolbar?{...t.toolbar}:typeof t.toolbar=="string"?{items:t.toolbar}:{};t.toolbarFloating!==void 0&&(s.floating=!!t.toolbarFloating),t.toolbarSticky!==void 0&&(s.sticky=!!t.toolbarSticky),t.toolbar=s}if(t.toolbarItems!==void 0&&typeof t.toolbar=="object"&&t.toolbar&&(t.toolbar.items=t.toolbarItems),t.autosaveEnabled!==void 0||t.autosaveIntervalMs!==void 0||t.autosaveStorageKey!==void 0||t.autosaveProvider!==void 0||t.autosaveApiUrl!==void 0){const s=typeof t.autosave=="object"&&t.autosave?{...t.autosave}:{};t.autosaveEnabled!==void 0&&(s.enabled=!!t.autosaveEnabled),t.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(t.autosaveIntervalMs)),t.autosaveStorageKey!==void 0&&(s.storageKey=t.autosaveStorageKey),t.autosaveProvider!==void 0&&(s.provider=t.autosaveProvider),t.autosaveApiUrl!==void 0&&(s.apiUrl=t.autosaveApiUrl),t.autosave=s}const n={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof t.autosave=="boolean")t.autosave={...n,enabled:t.autosave};else if(typeof t.autosave=="object"&&t.autosave){const s={...n,...t.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=n.intervalMs),t.autosave=s}else t.autosave=n;if(t.languageLocale!==void 0||t.languageDirection!==void 0){const s=typeof t.language=="object"&&t.language?{...t.language}:{};t.languageLocale!==void 0&&(s.locale=t.languageLocale),t.languageDirection!==void 0&&(s.direction=t.languageDirection),t.language=s}const i={locale:"en",direction:"ltr"};if(typeof t.language=="string"?t.language={locale:t.language,direction:i.direction}:typeof t.language=="object"&&t.language?t.language={...i,...t.language}:t.language=i,t.spellcheckEnabled!==void 0||t.spellcheckProvider!==void 0||t.spellcheckApiUrl!==void 0){const s=typeof t.spellcheck=="object"&&t.spellcheck?{...t.spellcheck}:{};t.spellcheckEnabled!==void 0&&(s.enabled=!!t.spellcheckEnabled),t.spellcheckProvider!==void 0&&(s.provider=t.spellcheckProvider),t.spellcheckApiUrl!==void 0&&(s.apiUrl=t.spellcheckApiUrl),t.spellcheck=s}const o={enabled:!1,provider:"browser",apiUrl:""};if(typeof t.spellcheck=="boolean")t.spellcheck={...o,enabled:t.spellcheck};else if(typeof t.spellcheck=="object"&&t.spellcheck){const s={...o,...t.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),t.spellcheck=s}else t.spellcheck=o;return t.contextMenuEnabled!==void 0&&(t.contextMenu={enabled:!!t.contextMenuEnabled}),typeof t.contextMenu=="boolean"?t.contextMenu={enabled:t.contextMenu}:typeof t.contextMenu=="object"&&t.contextMenu?t.contextMenu={enabled:t.contextMenu.enabled!==!1}:t.contextMenu={enabled:!0},(t.pasteClean!==void 0||t.pasteKeepFormatting!==void 0||t.pasteConvertWord!==void 0)&&(t.paste={...t.paste||{},...t.pasteClean!==void 0?{clean:!!t.pasteClean}:{},...t.pasteKeepFormatting!==void 0?{keepFormatting:!!t.pasteKeepFormatting}:{},...t.pasteConvertWord!==void 0?{convertWord:!!t.pasteConvertWord}:{}}),t.paste={clean:!0,keepFormatting:!1,convertWord:!0,...t.paste||{}},t.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...t.contentConfig||{}},(t.securitySanitizeOnPaste!==void 0||t.securitySanitizeOnInput!==void 0)&&(t.security={...t.security||{},...t.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!t.securitySanitizeOnPaste}:{},...t.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!t.securitySanitizeOnInput}:{}}),t.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...t.security||{}},(t.accessibilityEnableAria!==void 0||t.accessibilityKeyboardNavigation!==void 0||t.accessibilityChecker!==void 0)&&(t.accessibility={...t.accessibility||{},...t.accessibilityEnableAria!==void 0?{enableARIA:!!t.accessibilityEnableAria}:{},...t.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!t.accessibilityKeyboardNavigation}:{},...t.accessibilityChecker!==void 0?{checker:!!t.accessibilityChecker}:{}}),typeof t.accessibility=="boolean"&&(t.accessibility={enableARIA:t.accessibility,keyboardNavigation:t.accessibility,checker:!1}),t.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...t.accessibility||{}},(t.performanceDebounceInputMs!==void 0||t.performanceViewportOnlyScan!==void 0)&&(t.performance={...t.performance||{},...t.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(t.performanceDebounceInputMs)}:{},...t.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!t.performanceViewportOnlyScan}:{}}),typeof t.performance=="boolean"&&(t.performance={debounceInputMs:100,viewportOnlyScan:t.performance}),t.performance={debounceInputMs:100,viewportOnlyScan:!0,...t.performance||{}},(typeof t.performance.debounceInputMs!="number"||!Number.isFinite(t.performance.debounceInputMs)||t.performance.debounceInputMs<0)&&(t.performance.debounceInputMs=100),t}static parseAttributes(e){const t={};for(const[n,i]of Object.entries(e)){const o=this.kebabToCamel(n);t[o]=this.BOOLEAN_ATTRIBUTES.has(n)&&(i===""||i===n)?!0:this.parseAttributeValue(i)}return t}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(t){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}static validate(e){const t=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&t.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&t.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&t.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&t.push("theme must be a string"),{valid:t.length===0,errors:t}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const t={};for(const n of e)for(const[i,o]of Object.entries(n))o!=null&&(typeof o=="object"&&!Array.isArray(o)&&t[i]?t[i]=this.merge(t[i],o):t[i]=o);return t}};Un.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},Un.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 Zn=Un;const Hs='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Rn;const Ps="__editoraCommandEditorRoot",$s="__editoraLastCommandButton",So="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",wo=".rte-content, .editora-content",Fs="Rich text editor",Qn=new Set;let tt=null,xo=!1,Jn=null,ei=null;function Co(r){if(!(r instanceof HTMLElement))return!1;const e=r;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function Bs(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function $t(r){if(!r)return null;if(Co(r))return r;const e=r.matches(So)?r:r.closest(So);return!e||!Co(e)?null:e}function zs(){var i;if(typeof window=="undefined")return null;const r=window[Ps];if(r instanceof HTMLElement){const o=$t(r);if(o)return o;const s=r.matches(wo)?r:r.querySelector(wo);if(s){const l=$t(s);if(l)return l}}const e=window[$s];if(e instanceof HTMLElement){const o=$t(e);if(o)return o}const t=document.activeElement;if(t){const o=$t(t);if(o)return o}const n=(i=window.getSelection)==null?void 0:i.call(window);if(n&&n.rangeCount>0){const o=$t(Bs(n.getRangeAt(0).startContainer));if(o)return o}if(tt&&tt.isConnected)return tt;for(const o of Qn)if(o.isConnected)return o;return null}function Us(){if(typeof window=="undefined"||xo)return;Jn=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,ei=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const r=(e,...t)=>{const n=zs();return n?n.execCommand(e,...t):Jn?Jn(e,...t):ei?ei(e,...t):!1};window.executeEditorCommand=r,window.execEditorCommand=r,xo=!0}function Ws(){const r="editora-webcomponent-styles";if(!document.getElementById(r)){const e=document.createElement("style");e.id=r,e.textContent=Hs,document.head.appendChild(e)}}function js(){if(!Rn){const r=$e.__globalPluginLoader;r?Rn=r:Rn=new At}return Rn}class $e extends HTMLElement{constructor(){if(super(),this.pluginLoader=js(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Gr,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,this.pendingHistorySnapshot=null,Ws(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if($e.__globalPluginLoader){this.pluginLoader=$e.__globalPluginLoader;return}return new Promise(e=>{const t=()=>{$e.__globalPluginLoader?(this.pluginLoader=$e.__globalPluginLoader,e()):setTimeout(t,0)};t()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,t,n){t!==n&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,n))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var i;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),Qn.add(this),tt||(tt=this),Us(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();if(this.loadedPlugins=e,e.forEach(o=>{if(o.init&&typeof o.init=="function")try{o.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${o.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const o=this.innerHTML.trim();o&&this.setAttribute("data-initial-content",o)}const t=this.preservedContent;this.preservedContent=null;const n=this.sanitizeLoadedContent((i=t!=null?t:this.restoreAutosavedContent())!=null?i:this.getAttribute("data-initial-content")||"");this.engine=new $r({content:n,plugins:e,readonly:this.config.readonly}),this.createUI(e,n),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(n=>n.nodeType===Node.TEXT_NODE?n.textContent:n.nodeType===Node.ELEMENT_NODE?n.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],t=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(t){if(typeof this.config.plugins=="string"){const o=this.config.plugins.split(/\s+/).filter(Boolean);i&&!o.includes("a11yChecker")&&o.push("a11yChecker");for(const s of o){const l=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));l&&e.push(l)}}else if(Array.isArray(this.config.plugins)){for(const o of this.config.plugins)if(typeof o=="string"){const s=await this.pluginLoader.load(o,this.getPluginLoadConfig(o));s&&e.push(s)}else e.push(o);if(i&&!e.some(o=>(o==null?void 0:o.name)==="a11yChecker")){const o=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));o&&e.push(o)}}}else{const o=this.pluginLoader.getRegisteredPluginNames();for(const s of o){const l=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));l&&e.push(l)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const t=this.config.toolbar;if(typeof t=="string")return t;if(!t||typeof t!="object")return;const n=t.items;if(typeof n=="string")return n;if(Array.isArray(n))return n.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var t;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const n=Number((t=e.debounceInputMs)!=null?t:100);return{debounceInputMs:Number.isFinite(n)&&n>=0?n:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){var t;if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const n=(t=this.getAttribute("aria-label"))==null?void 0:t.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",n||i||Fs)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const t=e.provider||"browser";return{enabled:!!e.enabled,provider:t,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),t=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=t,this.contentElement.setAttribute("spellcheck",t?"true":"false")}executeCommand(e,...t){var o;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const n={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(s=>s.commands&&s.commands[e]);if(i&&i.commands){const s=i.commands[e];if(typeof s=="function")try{return e==="toggleFullscreen"?s(this,n):s(...t,n),!0}catch(l){return console.error(`[RichTextEditor] Error executing native command ${e}:`,l),!1}}return((o=this.engine)==null?void 0:o.execCommand(e,...t))||!1}getPluginLoadConfig(e){const t=this.config.pluginConfig;if(t&&typeof t=="object"){const o=t[e];if(o&&typeof o=="object")return o}const n={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[e,e.toLowerCase(),...n[e]||[]];for(const o of i){const s=this.config[o];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(e){return Eo(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var t,n;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((n=(t=e.intervalMs)!=null?t:e.interval)!=null?n:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const t=this.getAutosaveConfig();if(t.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,t.provider==="localStorage"){try{localStorage.setItem(t.storageKey,e),localStorage.setItem(`${t.storageKey}-timestamp`,Date.now().toString())}catch(n){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",n)}return}t.provider==="api"&&t.apiUrl&&fetch(t.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(n=>{console.error("[RichTextEditor] Failed to save autosave content to API:",n)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const t=localStorage.getItem(e.storageKey);if(t)return this.lastAutosavedContent=t,t}catch(t){console.error("[RichTextEditor] Failed to restore autosaved content:",t)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(Pt(this.contentElement))},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0);n.deleteContents();const i=document.createElement("div");i.innerHTML=e;const o=document.createDocumentFragment();for(;i.firstChild;)o.appendChild(i.firstChild);n.insertNode(o),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,t){const n=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!n?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Fr({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((o,s)=>{var l;if(this.contentElement){this.contentElement.focus();const c=window.getSelection();if(!c||c.rangeCount===0||!this.contentElement.contains(c.anchorNode)){const d=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?d.setStart(u,((l=u.textContent)==null?void 0:l.length)||0):u.nodeType===Node.ELEMENT_NODE?(d.selectNodeContents(u),d.collapse(!1)):d.setStart(this.contentElement,0),d.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(d)}}return this.executeCommand(o,s)}),this.toolbar.render(this.toolbarElement)):n&&this.appendChild(n),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(o){console.warn("defaultParagraphSeparator not supported:",o)}if(t){const o=document.createElement("div");o.innerHTML=t.trim(),!Array.from(o.childNodes).some(l=>{if(l.nodeType===Node.ELEMENT_NODE){const c=l.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(c)}return!1})&&t.trim()?this.contentElement.innerHTML=`<p>${t.trim()}</p>`:this.contentElement.innerHTML=t}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Br({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 zr({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var o;return(o=this.contentElement)==null?void 0:o.focus()},0)}recordInputHistory(e){const t=this.pendingHistorySnapshot;if(this.pendingHistorySnapshot=null,!t||!this.contentElement||t.beforeHTML===e)return;const n=window.execEditorCommand;typeof n=="function"&&n("recordDomTransaction",this.contentElement,t.beforeHTML,e,{inputType:t.inputType,data:t.data,selectionCollapsed:t.selectionCollapsed})}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",n=>{var i,o;this.lastBeforeInputType=n.inputType||null,n.inputType==="historyUndo"||n.inputType==="historyRedo"?this.pendingHistorySnapshot=null:this.contentElement&&(this.pendingHistorySnapshot={beforeHTML:this.contentElement.innerHTML,inputType:n.inputType||null,data:typeof n.data=="string"?n.data:null,selectionCollapsed:(o=(i=window.getSelection())==null?void 0:i.isCollapsed)!=null?o:!0})}),this.contentElement.addEventListener("input",n=>{var p;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const o=(p=n==null?void 0:n.detail)==null?void 0:p.allowedTags,s=this.getPerformanceConfig(),l=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),d=this.lastBeforeInputType;if(this.lastBeforeInputType=null,c.sanitizeOnInput!==!1&&l.sanitize!==!1&&!d){const y=Eo(i,l,c,o);if(y!==i){const m=window.getSelection(),E=m&&m.rangeCount>0?m.getRangeAt(0):null;if(this.contentElement.innerHTML=y,E&&m)try{m.removeAllRanges(),m.addRange(E)}catch(v){}i=y}}this.recordInputHistory(i),this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const f=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:vo(i)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(f,s.debounceInputMs):f(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",n=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&n.preventDefault()}),this.contentElement.addEventListener("paste",n=>{var u,f;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented)return;n.preventDefault();const i=this.config.paste||{};let o=((u=n.clipboardData)==null?void 0:u.getData("text/html"))||"";const s=((f=n.clipboardData)==null?void 0:f.getData("text/plain"))||"",l=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),d=!!o&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(o);if((i.clean||!i.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(i.convertWord===!1&&d&&s){document.execCommand("insertText",!1,s);return}if(o){c.sanitizeOnPaste!==!1&&l.sanitize!==!1&&(o=Is(o,l,c)),this.insertHTMLAtSelection(o);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{tt=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Pt(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",n=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(n,(o,s)=>{this.executeCommand(o,s)})});const t=()=>{const n=this.getSelectionRangeInEditor(),i=document.activeElement,o=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!o||!n&&!o||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=t,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0),n=t.commonAncestorContainer;return this.contentElement.contains(n)?t:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const t=document.createRange();return t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.collapsed}catch(t){return!1}}getSelectionAnchorRect(e,t){const n=Array.from(t.getClientRects()).filter(o=>o.width>0||o.height>0);return n.length===0?t.getBoundingClientRect():this.isSelectionBackward(e)?n[0]:n[n.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const t=this.getPerformanceConfig(),n=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!n){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const o=window.getSelection();if(!o){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(o,i);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),t=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!t)return;const n=this.contentElement.textContent||"",{words:i,chars:o}=Kr(n),s=jr(this.contentElement);let l,c;const d=this.getSelectionRangeInEditor();d&&(l=Ur(this.contentElement,d),d.collapsed||(c=Vr(d,l),l=void 0)),this.statusBar.update({wordCount:i,charCount:o,lineCount:s,cursorPosition:l,selectionInfo:c})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,t){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(t)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(t));break;case"theme":this.classList.forEach(n=>{n.startsWith("editora-theme-")&&this.classList.remove(n)}),t&&this.classList.add(`editora-theme-${t}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",t),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(n=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",n)})}));break}}resolveConfig(){const e={};for(let t=0;t<this.attributes.length;t++){const n=this.attributes[t];e[n.name]=n.value}return Zn.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>Pt(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))},execCommand:(e,t)=>this.executeCommand(e,t),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,t)=>(this.addEventListener(e,t),()=>this.removeEventListener(e,t)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,t,n,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=Pt(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(t=this.toolbar)==null||t.destroy(),(n=this.floatingToolbar)==null||n.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,Qn.delete(this),tt===this&&(tt=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return Pt(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))}execCommand(e,...t){return this.executeCommand(e,...t)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}const ti=new At;$e.__globalPluginLoader=ti;const Ks={bold:()=>Promise.resolve().then(()=>Zs).then(r=>r.BoldPlugin()),italic:()=>Promise.resolve().then(()=>Js).then(r=>r.ItalicPlugin()),underline:()=>Promise.resolve().then(()=>ea).then(r=>r.UnderlinePlugin()),strikethrough:()=>Promise.resolve().then(()=>ia).then(r=>r.StrikethroughPlugin()),clearFormatting:()=>Promise.resolve().then(()=>ma).then(r=>r.ClearFormattingPlugin()),heading:()=>Promise.resolve().then(()=>Oa).then(r=>r.HeadingPlugin()),blockquote:()=>Promise.resolve().then(()=>Wa).then(r=>r.BlockquotePlugin()),code:()=>Promise.resolve().then(()=>rc).then(r=>r.CodePlugin()),list:()=>Promise.resolve().then(()=>mc).then(r=>r.ListPlugin()),history:()=>Promise.resolve().then(()=>kc).then(r=>r.HistoryPlugin())};async function Ao(){return Object.entries(Ks).forEach(([r,e])=>{ti.register(r,e)}),ti}typeof window!="undefined"&&Ao().then(r=>{$e.__globalPluginLoader=r,customElements.get("editora-editor")||customElements.define("editora-editor",$e);const e=document.querySelectorAll("editora-editor:not([data-initial-content])"),t=[];e.forEach(n=>{const i=n.innerHTML.trim();i&&(t.push(i),n.setAttribute("data-initial-content",i),n.innerHTML="")}),e.forEach((n,i)=>{n instanceof $e&&!n.isInitialized&&t[i]&&n.setAttribute("content",t[i])})});const On="data-editora-selection-marker";function Vs(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function ko(r){return r?r.getAttribute("contenteditable")==="true"?r:r.querySelector('[contenteditable="true"]'):null}function Gs(r){var s;if((r==null?void 0:r.contentElement)instanceof HTMLElement)return r.contentElement;const e=ko((s=r==null?void 0:r.editorElement)!=null?s:null);if(e)return e;const t=typeof window!="undefined"?window.__editoraCommandEditorRoot:null,n=t instanceof HTMLElement?ko(t):null;if(n)return n;const i=window.getSelection();if(i&&i.rangeCount>0){const l=Vs(i.getRangeAt(0).startContainer),c=l==null?void 0:l.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}const o=document.activeElement;if(o instanceof HTMLElement){const l=o.closest('.rte-content, .editora-content, [contenteditable="true"]');if(l instanceof HTMLElement)return l}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function qs(r){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);return r.contains(t.startContainer)&&r.contains(t.endContainer)}function Mo(r){const e=document.createElement("span");return e.setAttribute(On,r),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function Ys(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);if(!r.contains(t.startContainer)||!r.contains(t.endContainer))return null;const n=t.collapsed,i=Mo("start"),o=n?null:Mo("end"),s=t.cloneRange();if(o){const c=s.cloneRange();c.collapse(!1),c.insertNode(o)}const l=s.cloneRange();return l.collapse(!0),l.insertNode(i),()=>{const c=window.getSelection(),d=document.createRange(),u=r.querySelector(`[${On}="start"]`),f=r.querySelector(`[${On}="end"]`);if(!c||!u){r.querySelectorAll(`[${On}]`).forEach(p=>p.remove());return}n||!f?(d.setStartBefore(u),d.collapse(!0)):(d.setStartAfter(u),d.setEndBefore(f)),c.removeAllRanges(),c.addRange(d),u.remove(),f==null||f.remove()}}function Xs(r,e,t){if(e!==t){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",r,e,t);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}catch(n){}}}function _n(r){const e=Gs(r.context);if(!e)return!1;const t=e.innerHTML;qs(e)&&e.focus({preventScroll:!0});let n=!1;try{n=document.execCommand(r.command,!1)}catch(s){n=!1}const i=e.innerHTML;if(r.normalize&&i!==t){const s=Ys(e);r.normalize(e),s==null||s()}const o=e.innerHTML;return t!==o&&(Xs(e,t,o),e.dispatchEvent(new Event("input",{bubbles:!0}))),n!==!1||t!==o}const Zs=Object.freeze(Object.defineProperty({__proto__:null,BoldPlugin:()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:r=>{const e=typeof r=="string"?r:r.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(r,e)=>_n({command:"bold",context:e})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}})},Symbol.toStringTag,{value:"Module"})),ni=(r,e)=>_n({command:"italic",context:e}),Qs=(r,e)=>{var t;typeof window!="undefined"&&((t=window.registerEditorCommand)==null||t.call(window,r,e))},Lo=()=>{Qs("toggleItalic",ni)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Lo):Lo());const Js=Object.freeze(Object.defineProperty({__proto__:null,ItalicPlugin:()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:ni},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),toggleItalic:ni},Symbol.toStringTag,{value:"Module"})),ea=Object.freeze(Object.defineProperty({__proto__:null,UnderlinePlugin:()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(r,e)=>_n({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}})},Symbol.toStringTag,{value:"Module"})),ta=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:r=>(typeof r=="string"?r:r.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(r,e)=>_n({command:"strikeThrough",context:e,normalize:na})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function na(r){r.querySelectorAll("strike, del").forEach(t=>{var i;const n=document.createElement("s");for(const o of Array.from(t.attributes))o.name!=="style"&&n.setAttribute(o.name,o.value);for(;t.firstChild;)n.appendChild(t.firstChild);(i=t.parentNode)==null||i.replaceChild(n,t)})}const ia=Object.freeze(Object.defineProperty({__proto__:null,StrikethroughPlugin:ta},Symbol.toStringTag,{value:"Module"}));function Ro(r,e,t=r==null?void 0:r.innerHTML){if(!r||typeof t!="string"||e===t)return!1;try{if(typeof window.execEditorCommand=="function")return window.execEditorCommand("recordDomTransaction",r,e,t)!==!1;if(typeof window.executeEditorCommand=="function")return window.executeEditorCommand("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})!==!1}catch(n){}return!1}const oa=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const r=la();if(!r)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!r.contains(t.commonAncestorContainer))return!1;const n=t.cloneRange(),i=r.innerHTML;return r.focus({preventScroll:!0}),ga(r,n),pa(r,n),Ro(r,i),r.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),ra=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),sa=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),aa=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function la(){const r=window.getSelection();if(r&&r.rangeCount>0){const t=r.getRangeAt(0).startContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement,i=n==null?void 0:n.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function Oo(r,e){try{if(typeof r.intersectsNode=="function")return r.intersectsNode(e)}catch(n){}const t=document.createRange();return e.nodeType===Node.ELEMENT_NODE?t.selectNodeContents(e):t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)>0&&r.compareBoundaryPoints(Range.START_TO_END,t)<0}function In(r){let e=0,t=r;for(;t&&t.parentNode;)e+=1,t=t.parentNode;return e}function ca(r){aa.forEach(e=>{r.style.removeProperty(e)}),(!r.getAttribute("style")||r.style.length===0)&&r.removeAttribute("style"),r.classList.contains("rte-text-color")&&r.classList.remove("rte-text-color"),r.classList.contains("rte-bg-color")&&r.classList.remove("rte-bg-color"),r.classList.contains("rte-format-painted")&&r.classList.remove("rte-format-painted"),r.classList.length===0&&r.removeAttribute("class")}function ii(r){const e=r.parentNode;if(e){for(;r.firstChild;)e.insertBefore(r.firstChild,r);e.removeChild(r)}}function da(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function _o(r){Array.from(r.children).forEach(e=>{da(e)&&e.remove()})}function Io(r){_o(r),ii(r)}function Do(r){var t;const e=document.createElement("p");for(Array.from(r.attributes).forEach(n=>{e.setAttribute(n.name,n.value)});r.firstChild;)e.appendChild(r.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),(t=r.parentNode)==null||t.replaceChild(e,r)}function ua(r){return!/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(r.tagName)||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, svg, math")}function ha(r){Array.from(r.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((t,n)=>In(n)-In(t)).forEach(t=>{t.isConnected&&ua(t)&&t.remove()})}function fa(r){if(_o(r),r.parentElement instanceof HTMLLIElement){Io(r);return}if(Array.from(r.childNodes).filter(i=>i.nodeType!==Node.TEXT_NODE||(i.textContent||"").trim()!=="").some(i=>i instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(i.tagName))){Io(r);return}Do(r)}function pa(r,e){Array.from(r.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(Oo(e,n)&&sa.has(n.tagName)){if(n.tagName==="BLOCKQUOTE"){fa(n);return}Do(n)}})}function ga(r,e){const t=Array.from(r.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));t.sort((n,i)=>In(i)-In(n)),t.forEach(n=>{if(n.isConnected&&Oo(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(ca(n),ra.has(n.tagName)){ii(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&ii(n)}}),ha(r)}const ma=Object.freeze(Object.defineProperty({__proto__:null,ClearFormattingPlugin:oa},Symbol.toStringTag,{value:"Module"})),Ft='.rte-content, .editora-content, [contenteditable="true"]',ba="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",No=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),Ho="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",ya=new Set(["p","h1","h2","h3","h4","h5","h6"]);function Po(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function Ta(r){const e=r==null?void 0:r.contentElement;if(e instanceof HTMLElement)return e;const t=r==null?void 0:r.editorElement;if(t instanceof HTMLElement){const s=t.querySelector(Ft);if(s instanceof HTMLElement)return s;if(t.getAttribute("contenteditable")==="true")return t}const n=window.getSelection();if(n&&n.rangeCount>0){const s=Po(n.getRangeAt(0).startContainer),l=s==null?void 0:s.closest(Ft);if(l instanceof HTMLElement)return l;const c=s==null?void 0:s.closest(ba),d=c==null?void 0:c.querySelector(Ft);if(d instanceof HTMLElement)return d}const i=document.activeElement,o=i==null?void 0:i.closest(Ft);return o instanceof HTMLElement?o:document.querySelector(Ft)}function Ea(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);return!r.contains(t.startContainer)||!r.contains(t.endContainer)?null:t}function $o(r,e){let t=Po(e);if(!t||t===r||!r.contains(t))return null;for(;t.parentElement&&t.parentElement!==r;)t=t.parentElement;if(t.parentElement!==r)return null;if(t.matches(Ho))return t;const n=t.closest(Ho);return n instanceof HTMLElement&&n.parentElement===r?n:t}function Fo(r,e){if(typeof r.intersectsNode=="function")try{return r.intersectsNode(e)}catch(n){return!1}const t=document.createRange();return t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0}function va(r,e){const t=$o(r,e.startContainer),n=$o(r,e.endContainer);if(!t)return[];if(!n||t===n)return[t];const o=Array.from(r.children).filter(s=>s instanceof HTMLElement).filter(s=>Fo(e,s));return o.length>0?o:[t]}function Sa(r,e){Array.from(r.attributes).forEach(t=>{e.setAttribute(t.name,t.value)})}function oi(r,e){for(;r.firstChild;)e.appendChild(r.firstChild)}function wa(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Dn(r,e){const t=document.createElement(r);return e&&Sa(e,t),t}function Bo(r,e){const t=Dn(e,r);return oi(r,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function xa(r){const e=r.cloneNode(!1);return e instanceof HTMLElement?e:document.createElement(r.tagName.toLowerCase())}function zo(r,e,t){const n=r.parentNode;if(!n)return[];const i=document.createDocumentFragment(),o=[];let s=null;const l=()=>{s&&s.children.length>0&&i.appendChild(s),s=null};return Array.from(r.children).forEach(c=>{if(c instanceof HTMLLIElement){if(e.has(c)){l();const d=Bo(c,t);i.appendChild(d),o.push(d);return}s||(s=xa(r)),s.appendChild(c)}}),l(),n.insertBefore(i,r),n.removeChild(r),o}function Ca(r,e){var n;if(r.tagName.toLowerCase()===e)return[r];const t=Dn(e,r);return oi(r,t),t.innerHTML.trim()||(t.innerHTML="<br>"),(n=r.parentNode)==null||n.replaceChild(t,r),[t]}function Aa(r,e){const t=r.parentNode;if(!t)return[];const n=document.createDocumentFragment(),i=[];return Array.from(r.childNodes).forEach(o=>{if(o instanceof HTMLElement&&wa(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(l=>{if(!(l instanceof HTMLLIElement))return;const c=Bo(l,e);n.appendChild(c),i.push(c)}),o.remove();return}if(o instanceof HTMLElement&&No.has(o.tagName)){const l=Dn(e,o);oi(o,l),n.appendChild(l),i.push(l);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const s=Dn(e,r);s.appendChild(o),n.appendChild(s),i.push(s)}),t.insertBefore(n,r),t.removeChild(r),i}function ka(r){const e=window.getSelection();if(!e)return;const t=document.createRange(),n=r instanceof HTMLElement&&r.querySelector("p,li,h1,h2,h3,h4,h5,h6")||r;t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}function Ma(r){r.dispatchEvent(new Event("input",{bubbles:!0}))}function La(r,e,t){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",r,e,t);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}function Ra(r,e){const t=new Map;return Array.from(r.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&Fo(e,i)).forEach(i=>{var s;const o=i.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===r&&(t.has(o)||t.set(o,new Set),(s=t.get(o))==null||s.add(i))}),t}function Bt(r,e){const t=r.toLowerCase();if(!ya.has(t))return!1;const n=Ta(e);if(!n)return!1;const i=Ea(n);if(!i)return!1;const o=n.innerHTML,s=[],l=Ra(n,i),c={startContainer:i.startContainer,startOffset:i.startOffset,endContainer:i.endContainer,endOffset:i.endOffset};l.size>0?l.forEach((u,f)=>{s.push(...zo(f,u,t))}):va(n,i).forEach(f=>{if(f instanceof HTMLUListElement||f instanceof HTMLOListElement){const p=new Set(Array.from(f.children).filter(y=>y instanceof HTMLLIElement));s.push(...zo(f,p,t));return}if(No.has(f.tagName)){const p=f.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");s.push(...p?Aa(f,t):Ca(f,t))}});const d=n.innerHTML;if(o===d||s.length===0)return!1;if(La(n,o,d),Ma(n),n.contains(c.startContainer)&&n.contains(c.endContainer)){const u=document.createRange();u.setStart(c.startContainer,c.startOffset),u.setEnd(c.endContainer,c.endOffset);const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(u)}else ka(s[0]);return!0}const Oa=Object.freeze(Object.defineProperty({__proto__:null,HeadingPlugin:()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(r,e)=>r?Bt(r,e):!1,setHeading1:(r,e)=>Bt("h1",e),setHeading2:(r,e)=>Bt("h2",e),setHeading3:(r,e)=>Bt("h3",e),setParagraph:(r,e)=>Bt("p",e)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}})},Symbol.toStringTag,{value:"Module"})),zt='.rte-content, .editora-content, [contenteditable="true"]',_a="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",Uo=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function ri(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function Ia(r){const e=r==null?void 0:r.contentElement;if(e instanceof HTMLElement)return e;const t=r==null?void 0:r.editorElement;if(t instanceof HTMLElement){const s=t.querySelector(zt);if(s instanceof HTMLElement)return s;if(t.getAttribute("contenteditable")==="true")return t}const n=window.getSelection();if(n&&n.rangeCount>0){const s=ri(n.getRangeAt(0).startContainer),l=s==null?void 0:s.closest(zt);if(l instanceof HTMLElement)return l;const c=s==null?void 0:s.closest(_a),d=c==null?void 0:c.querySelector(zt);if(d instanceof HTMLElement)return d}const i=document.activeElement,o=i==null?void 0:i.closest(zt);return o instanceof HTMLElement?o:document.querySelector(zt)}function Da(r){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0);return!r.contains(t.startContainer)||!r.contains(t.endContainer)?null:t}function Wo(r,e){let t=ri(e);if(!t||t===r||!r.contains(t))return null;for(;t.parentElement&&t.parentElement!==r;)t=t.parentElement;if(t.parentElement!==r)return null;if(t.matches(Uo))return t;const n=t.closest(Uo);return n instanceof HTMLElement&&n.parentElement===r?n:t}function jo(r,e){if(typeof r.intersectsNode=="function")try{return r.intersectsNode(e)}catch(n){return!1}const t=document.createRange();return t.selectNode(e),r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0}function Na(r,e){const t=Wo(r,e.startContainer),n=Wo(r,e.endContainer);if(!t)return[];if(!n||t===n)return[t];const o=Array.from(r.children).filter(s=>s instanceof HTMLElement).filter(s=>jo(e,s));return o.length>0?o:[t]}function Ko(r,e){const t=ri(e),n=t==null?void 0:t.closest("blockquote");return n instanceof HTMLQuoteElement&&r.contains(n)?n:null}function Ha(r){return r.tagName!=="P"||r.attributes.length>0||(r.textContent||"").trim()!==""?!1:!r.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Pa(r){Array.from(r.children).forEach(e=>{Ha(e)&&e.remove()})}function si(r){Pa(r);const e=r.parentNode;if(!e)return;Array.from(r.childNodes).forEach(n=>{e.insertBefore(n,r)}),e.removeChild(r)}function Vo(r){return r.nodeType===Node.TEXT_NODE&&(r.textContent||"").trim()===""}function Go(r){const e=Array.from(r.childNodes).filter(n=>!Vo(n));if(e.length!==1)return null;const t=e[0];return t instanceof HTMLQuoteElement?t:null}function $a(r){const e=document.createElement("blockquote");return Array.from(r.childNodes).filter(n=>!Vo(n)).forEach(n=>{e.appendChild(n)}),e.childNodes.length||(e.innerHTML="<br>"),r.appendChild(e),e}function Fa(r,e){const t=Array.from(r.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&jo(e,i)),n=new Set(t);return t.filter(i=>{var s,l;let o=(s=i.parentElement)==null?void 0:s.closest("li");for(;o;){if(n.has(o))return!1;o=(l=o.parentElement)==null?void 0:l.closest("li")}return!0})}function Ut(r){const e=window.getSelection();if(!e)return;const t=document.createRange(),n=r instanceof HTMLElement&&r.querySelector("p,li,h1,h2,h3,h4,h5,h6")||r;t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}function Ba(r){r.dispatchEvent(new Event("input",{bubbles:!0}))}function za(r,e,t){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",r,e,t);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:r,beforeHTML:e,afterHTML:t})}function Ua(r){var u,f;const e=Ia(r);if(!e)return!1;const t=Da(e);if(!t)return!1;const n=e.innerHTML,i=Ko(e,t.startContainer),o=Ko(e,t.endContainer),s=Fa(e,t),l=Na(e,t),c=l.length>0&&l.every(p=>p.tagName==="BLOCKQUOTE");if(i&&i===o){const p=i.firstChild||i;si(i),Ut(p)}else if(s.length>0){const p=s.map(Go);if(p.every(Boolean)){const m=((u=p[0])==null?void 0:u.firstChild)||s[0];p.forEach(E=>{E&&si(E)}),Ut(m)}else{const m=s[0];s.forEach(E=>{Go(E)||$a(E)}),Ut(m)}}else if(c){const p=l[0].firstChild||l[0];l.forEach(si),Ut(p)}else{const p=l.filter(E=>E.tagName!=="BLOCKQUOTE");if(p.length===0)return!1;const y=document.createElement("blockquote"),m=p[0];(f=m.parentNode)==null||f.insertBefore(y,m),p.forEach(E=>{y.appendChild(E)}),Ut(y)}const d=e.innerHTML;return n===d?!1:(za(e,n,d),Ba(e),!0)}const Wa=Object.freeze(Object.defineProperty({__proto__:null,BlockquotePlugin:()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(r,e)=>Ua(e)},keymap:{"Mod-Shift-9":"toggleBlockquote"}})},Symbol.toStringTag,{value:"Module"}));function ja(r){let e=!1;r.addEventListener("pointerdown",t=>{e=t.target!==r},!0),r.addEventListener("click",t=>{t.target===r&&e&&t.stopImmediatePropagation(),e=!1},!0)}const qo="rte-dialog-base-styles";function Ka(){if(typeof document=="undefined"||document.getElementById(qo))return;const r=document.createElement("style");r.id=qo,r.textContent=`
|
|
12
12
|
[data-rte-dialog] {
|
|
13
13
|
font-family: var(--rte-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
|
|
14
14
|
}
|
|
@@ -19,10 +19,82 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
19
19
|
:where([data-rte-dialog]) :where(button, input, select, textarea) {
|
|
20
20
|
font-family: inherit;
|
|
21
21
|
}
|
|
22
|
-
`,document.head.appendChild(r)}function
|
|
22
|
+
`,document.head.appendChild(r)}function Yo(r){r.setAttribute("data-rte-dialog",""),Ka(),ja(r),Za(r)}const Va='a[href], button, input:not([type="hidden"]), select, textarea, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';function Ga(r,e){for(let t=r;t;t=t.parentElement){if(t.hidden||t.getAttribute("aria-hidden")==="true")return!1;const n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return!1;if(t===e)break}return!0}function Xo(r){return Array.from(r.querySelectorAll(Va)).filter(e=>!e.disabled&&e.getAttribute("tabindex")!=="-1"&&Ga(e,r))}function qa(r){const e=Xo(r);return e.filter(t=>{var o;if(!(t instanceof HTMLInputElement)||t.type!=="radio"||!t.name)return!0;const n=e.filter(s=>s instanceof HTMLInputElement&&s.type==="radio"&&s.name===t.name),i=(o=n.find(s=>s.checked))!=null?o:n[0];return t===i})}function Ya(r){var n,i,o,s;const e=`${(n=r.getAttribute("aria-label"))!=null?n:""} ${(o=(i=r.className)==null?void 0:i.toString())!=null?o:""}`.toLowerCase(),t=((s=r.textContent)!=null?s:"").trim();return/close|dismiss/.test(e)||/^[\u00d7\u2715\u2716x]$/i.test(t)}function Xa(r){var n;const e=r.querySelector('h1, h2, h3, h4, [class*="title"], [class*="header"], header, [role="heading"]');if(!e)return"";const t=e.cloneNode(!0);return t.querySelectorAll('button, [role="button"], [aria-label*="lose"], [class*="close"]').forEach(i=>i.remove()),((n=t.textContent)!=null?n:"").replace(/\s+/g," ").trim()}function Za(r){var d,u;const e=document.activeElement instanceof HTMLElement?document.activeElement:null,t=window.getSelection(),n=t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null,i=n&&(u=(d=n.commonAncestorContainer instanceof HTMLElement?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)==null?void 0:d.closest('[contenteditable="true"]'))!=null?u:null,o=i?i.innerHTML:null;r.addEventListener("keydown",f=>{if(f.key!=="Tab"||f.defaultPrevented)return;const p=qa(r);if(p.length===0){f.preventDefault();return}const y=p.indexOf(document.activeElement),m=f.shiftKey?-1:1,E=y===-1?f.shiftKey?p[p.length-1]:p[0]:p[(y+m+p.length)%p.length];f.preventDefault(),E.focus()});let s=!1;const l=f=>{var v,w,A,B;if(!r.isConnected){f<3&&window.setTimeout(()=>l(f+1),50);return}s=!0;const y=(A=(w=(v=(R=>{var D;return["dialog","alertdialog"].includes((D=R.getAttribute("role"))!=null?D:"")})(r)?r:null)!=null?v:r.querySelector('[role="dialog"], [role="alertdialog"]'))!=null?w:r.firstElementChild instanceof HTMLElement?r.firstElementChild:null)!=null?A:r;y.getAttribute("role")||y.setAttribute("role","dialog"),y.hasAttribute("aria-modal")||y.setAttribute("aria-modal","true");const m=y.getAttribute("aria-labelledby");if(!(!!y.getAttribute("aria-label")||!!m&&!!document.getElementById(m.split(/\s+/)[0]))){const R=Xa(y);R&&(y.removeAttribute("aria-labelledby"),y.setAttribute("aria-label",R))}if(!r.contains(document.activeElement)){const R=Xo(r),D=(B=R.find(z=>!Ya(z)))!=null?B:R[0];D?D.focus({preventScroll:!0}):(y.setAttribute("tabindex","-1"),y.focus({preventScroll:!0}))}};window.setTimeout(()=>l(0),0);const c=new MutationObserver(()=>{if(r.isConnected&&(s=!0),r.isConnected||!s)return;c.disconnect();const f=document.activeElement;if(!f||f===document.body||r.contains(f)){const y=i!=null&&i.isConnected?i:e;y&&y.isConnected&&y.focus({preventScroll:!0})}if(n&&i&&i.isConnected&&i.innerHTML===o&&t){const y=t.rangeCount>0?t.getRangeAt(0):null;!(y&&y.compareBoundaryPoints(Range.START_TO_START,n)===0&&y.compareBoundaryPoints(Range.END_TO_END,n)===0)&&i.contains(n.startContainer)&&i.contains(n.endContainer)&&(t.removeAllRanges(),t.addRange(n))}});c.observe(document.body,{childList:!0,subtree:!0})}const Lt="data-rte-notices",Zo="rte-notice-styles",Qa={info:5e3,error:8e3};function Ja(){if(document.getElementById(Zo))return;const r=document.createElement("style");r.id=Zo,r.textContent=`
|
|
23
|
+
[${Lt}] {
|
|
24
|
+
position: fixed;
|
|
25
|
+
left: 50%;
|
|
26
|
+
bottom: 24px;
|
|
27
|
+
transform: translateX(-50%);
|
|
28
|
+
z-index: 100001;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 8px;
|
|
33
|
+
max-width: min(92vw, 480px);
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
[${Lt}] .rte-notice {
|
|
37
|
+
pointer-events: auto;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
padding: 10px 16px;
|
|
40
|
+
border-radius: 8px;
|
|
41
|
+
font: 14px/1.4 var(--rte-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
|
|
42
|
+
color: #fff;
|
|
43
|
+
background: #1f2937;
|
|
44
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
|
|
45
|
+
}
|
|
46
|
+
[${Lt}] .rte-notice[data-kind="error"] {
|
|
47
|
+
background: #b91c1c;
|
|
48
|
+
}
|
|
49
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
50
|
+
[${Lt}] .rte-notice { animation: rte-notice-in 160ms ease-out; }
|
|
51
|
+
@keyframes rte-notice-in { from { opacity: 0; transform: translateY(8px); } }
|
|
52
|
+
}
|
|
53
|
+
`,document.head.appendChild(r)}function el(r){const e=r==="error"?"assertive":"polite";let t=document.querySelector(`[${Lt}="${e}"]`);return t||(t=document.createElement("div"),t.setAttribute(Lt,e),t.setAttribute("aria-live",e),t.setAttribute("role",r==="error"?"alert":"status"),t.setAttribute("aria-atomic","false"),document.body.appendChild(t)),t}function Qo(r,e="info"){if(typeof document=="undefined"||!document.body)return;Ja();const t=el(e);Array.from(t.children).forEach(s=>{s.textContent===r&&s.remove()});const n=document.createElement("div");n.className="rte-notice",n.setAttribute("data-kind",e),n.textContent=r,n.title="Dismiss";const i=()=>{window.clearTimeout(o),n.remove(),t.children.length||t.remove()},o=window.setTimeout(i,Qa[e]);n.addEventListener("click",i),t.appendChild(n)}function Nn(r){return String(r!=null?r:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Jo="rte-confirm-styles",tl='[data-theme="dark"], .dark, .editora-theme-dark';let nl=0;function il(){if(document.getElementById(Jo))return;const r=document.createElement("style");r.id=Jo,r.textContent=`
|
|
54
|
+
.rte-confirm-overlay {
|
|
55
|
+
position: fixed; inset: 0; z-index: 100002; display: flex; align-items: center; justify-content: center;
|
|
56
|
+
padding: 16px; background: rgba(15, 23, 36, 0.56);
|
|
57
|
+
--rte-confirm-bg: #ffffff; --rte-confirm-text: #101828; --rte-confirm-muted: #5f6b7d; --rte-confirm-border: #d6dbe4;
|
|
58
|
+
--rte-confirm-accent: #1f75fe; --rte-confirm-danger: #c62828;
|
|
59
|
+
}
|
|
60
|
+
.rte-confirm-overlay.rte-confirm-dark {
|
|
61
|
+
--rte-confirm-bg: #1f2937; --rte-confirm-text: #e5e7eb; --rte-confirm-muted: #9ca3af; --rte-confirm-border: #3b4657;
|
|
62
|
+
--rte-confirm-accent: #3b82f6; --rte-confirm-danger: #ef4444;
|
|
63
|
+
}
|
|
64
|
+
.rte-confirm-dialog {
|
|
65
|
+
box-sizing: border-box; width: min(100%, 420px); padding: 20px; border-radius: 10px;
|
|
66
|
+
background: var(--rte-confirm-bg); color: var(--rte-confirm-text); border: 1px solid var(--rte-confirm-border);
|
|
67
|
+
box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35); font-size: 14px; line-height: 1.45;
|
|
68
|
+
}
|
|
69
|
+
.rte-confirm-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
|
|
70
|
+
.rte-confirm-message { margin: 0 0 14px; color: var(--rte-confirm-muted); }
|
|
71
|
+
.rte-confirm-field { display: block; margin: 0 0 6px; }
|
|
72
|
+
.rte-confirm-input {
|
|
73
|
+
box-sizing: border-box; width: 100%; padding: 8px 10px; border-radius: 6px; font: inherit;
|
|
74
|
+
border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
|
|
75
|
+
}
|
|
76
|
+
.rte-confirm-input[aria-invalid="true"] { border-color: var(--rte-confirm-danger); }
|
|
77
|
+
.rte-confirm-error { margin: 6px 0 0; color: var(--rte-confirm-danger); font-size: 13px; }
|
|
78
|
+
.rte-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
|
|
79
|
+
.rte-confirm-button {
|
|
80
|
+
padding: 8px 14px; border-radius: 6px; font: inherit; cursor: pointer;
|
|
81
|
+
border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
|
|
82
|
+
}
|
|
83
|
+
.rte-confirm-button.primary { background: var(--rte-confirm-accent); border-color: var(--rte-confirm-accent); color: #fff; }
|
|
84
|
+
.rte-confirm-button.danger { background: var(--rte-confirm-danger); border-color: var(--rte-confirm-danger); color: #fff; }
|
|
85
|
+
.rte-confirm-button:focus-visible, .rte-confirm-input:focus-visible { outline: 2px solid var(--rte-confirm-accent); outline-offset: 2px; }
|
|
86
|
+
`,document.head.appendChild(r)}function ol(r,e,t){var f,p,y,m;il();const n=`rte-confirm-${++nl}`,i=document.createElement("div");Yo(i),i.className="rte-confirm-overlay";const o=(f=e.context)!=null?f:document.activeElement instanceof Element?document.activeElement:null;o!=null&&o.closest(tl)&&i.classList.add("rte-confirm-dark");const s=(p=e.title)!=null?p:"Please confirm",l=(y=e.confirmText)!=null?y:"Confirm",c=(m=e.cancelText)!=null?m:"Cancel",d=e.danger===!0,u=document.createElement("div");return u.className="rte-confirm-dialog",u.setAttribute("role","alertdialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-labelledby",`${n}-title`),u.setAttribute("aria-describedby",`${n}-message`),u.innerHTML=`
|
|
87
|
+
<h2 class="rte-confirm-title" id="${n}-title">${Nn(s)}</h2>
|
|
88
|
+
<p class="rte-confirm-message" id="${n}-message">${Nn(r)}</p>
|
|
89
|
+
|
|
90
|
+
<div class="rte-confirm-actions">
|
|
91
|
+
<button type="button" class="rte-confirm-button" data-action="cancel">${Nn(c)}</button>
|
|
92
|
+
<button type="button" class="rte-confirm-button ${d?"danger":"primary"}" data-action="confirm">${Nn(l)}</button>
|
|
93
|
+
</div>
|
|
94
|
+
`,i.appendChild(u),{overlay:i,confirmButton:u.querySelector('[data-action="confirm"]'),cancelButton:u.querySelector('[data-action="cancel"]'),input:u.querySelector("input"),error:u.querySelector(".rte-confirm-error")}}function rl(r,e){return new Promise(t=>{var d;const{overlay:n,confirmButton:i,cancelButton:o}=r;let s=!1;const l=u=>{const f=e(u);f!==void 0&&(s||(s=!0,window.removeEventListener("keydown",c,!0),n.remove(),t(f)))},c=u=>{u.key!=="Escape"||!n.isConnected||(u.preventDefault(),u.stopPropagation(),l(!1))};window.addEventListener("keydown",c,!0),o.addEventListener("click",()=>l(!1)),i.addEventListener("click",()=>l(!0)),n.addEventListener("click",u=>{u.target===n&&l(!1)}),(d=r.input)==null||d.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l(!0))}),document.body.appendChild(n)})}function sl(r,e={}){const t=ol(r,e);return rl(t,n=>n)}class ai{constructor(e=""){this._lines=[],this._version=0,this.setText(e)}getLine(e){return this._lines[e]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
|
|
23
95
|
`)}setText(e){this._lines=e.split(`
|
|
24
96
|
`),this._version++}getTextInRange(e){if(e.start.line===e.end.line)return this.getLine(e.start.line).substring(e.start.column,e.end.column);const t=[];t.push(this.getLine(e.start.line).substring(e.start.column));for(let n=e.start.line+1;n<e.end.line;n++)t.push(this.getLine(n));return e.end.line<this.getLineCount()&&t.push(this.getLine(e.end.line).substring(0,e.end.column)),t.join(`
|
|
25
|
-
`)}replaceRange(e,t){const n=this.normalizeRange(e),i=this.getTextInRange(n),o=this.getText(),s=this.positionToOffset(n.start),l=this.positionToOffset(n.end),c=o.slice(0,s)+t+o.slice(l);return this.setText(c),{range:n,text:t,oldText:i}}insertText(e,t){const n={start:e,end:e};return this.replaceRange(n,t)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let t=0;for(let n=0;n<e.line;n++)t+=this.getLine(n).length+1;return t+=e.column,t}offsetToPosition(e){let t=e;for(let n=0;n<this.getLineCount();n++){const i=this.getLine(n).length;if(t<=i)return{line:n,column:t};t-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new
|
|
97
|
+
`)}replaceRange(e,t){const n=this.normalizeRange(e),i=this.getTextInRange(n),o=this.getText(),s=this.positionToOffset(n.start),l=this.positionToOffset(n.end),c=o.slice(0,s)+t+o.slice(l);return this.setText(c),{range:n,text:t,oldText:i}}insertText(e,t){const n={start:e,end:e};return this.replaceRange(n,t)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let t=0;for(let n=0;n<e.line;n++)t+=this.getLine(n).length+1;return t+=e.column,t}offsetToPosition(e){let t=e;for(let n=0;n<this.getLineCount();n++){const i=this.getLine(n).length;if(t<=i)return{line:n,column:t};t-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new ai;return e._lines=[...this._lines],e._version=this._version,e}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}}class al{constructor(e){this.gutterWidth=50,this.gutterFoldColumnWidth=24,this.gutterFoldColumnGap=4,this.gutterLineNumberPaddingLeft=8,this.gutterLineNumberPaddingRight=4,this.gutterDigitWidth=9,this.lineHeight=24,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.foldPlaceholderAttr="data-lce-fold-placeholder",this.virtualMarkerRegex=/[\u200B\uE000]/,this.virtualMarkerGlobalRegex=/[\u200B\uE000]/g,this.lastLineCount=0,this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.lineDecorations=[],this.gutterDecorations=[],this.lineWrapping=!1,this.measuredHeights=null,this.measuredTops=[],this.measuredLines=null,this.measuredSignature="",this.measureQueued=!1,this.measurer=null,this.resizeObserver=null,this.destroyed=!1,this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.setAttribute("data-lce-editor-container","true"),e.style.cssText=`
|
|
26
98
|
position: relative;
|
|
27
99
|
display: flex;
|
|
28
100
|
width: 100%;
|
|
@@ -115,86 +187,87 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
115
187
|
min-width: 100%;
|
|
116
188
|
height: 100%;
|
|
117
189
|
`,this.lineNumbersElement.appendChild(this.lineNumbersContentElement),this.lineNumbersElement.appendChild(this.gutterDecorationsElement),n.appendChild(this.lineNumbersElement),t.appendChild(this.lineDecorationsElement),t.appendChild(this.highlightElement),t.appendChild(this.contentElement),n.appendChild(t),e.appendChild(n),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){this.updateGutterWidth(e),this.queueWrapMeasure(),e!==this.lastLineCount&&(this.lastLineCount=e,this.syncGutterRows(Math.max(e,1)))}syncGutterRows(e){const t=this.lineNumbersContentElement;for(;t.children.length>e;)t.lastElementChild.remove();let n="";for(let i=t.children.length+1;i<=e;i+=1)n+=`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${i}</div>`;n&&t.insertAdjacentHTML("beforeend",n)}lineTop(e){var t;return(t=this.measuredTops[e])!=null?t:e*this.lineHeight}lineHeightAt(e){var t,n;return(n=(t=this.measuredHeights)==null?void 0:t[e])!=null?n:this.lineHeight}queueWrapMeasure(){!this.lineWrapping||this.measureQueued||this.destroyed||(this.measureQueued=!0,Promise.resolve().then(()=>{this.measureQueued=!1,this.measureWrappedLines()}))}measureWrappedLines(){if(!this.lineWrapping||this.destroyed||!this.contentElement.isConnected)return;const e=this.contentElement.__lceFoldPlaceholderSources,t=this.lineNumbersContentElement.children,n=(this.contentElement.textContent||"").split(`
|
|
118
|
-
`),i=this.contentElement.clientWidth;if(e&&e.size>0||t.length!==n.length||i===0){this.applyMeasuredHeights(null);return}const o=this.wrapSignature(i),s=this.measuredLines,l=this.measuredHeights;let c;if(s&&l&&l.length===s.length&&o===this.measuredSignature){const
|
|
190
|
+
`),i=this.contentElement.clientWidth;if(e&&e.size>0||t.length!==n.length||i===0){this.applyMeasuredHeights(null);return}const o=this.wrapSignature(i),s=this.measuredLines,l=this.measuredHeights;let c;if(s&&l&&l.length===s.length&&o===this.measuredSignature){const d=Math.min(s.length,n.length);let u=0;for(;u<d&&s[u]===n[u];)u+=1;let f=0;for(;f<d-u&&s[s.length-1-f]===n[n.length-1-f];)f+=1;c=l.slice(0,u).concat(this.measureLines(n.slice(u,n.length-f),i),l.slice(l.length-f))}else c=this.measureLines(n,i);this.measuredLines=n,this.measuredSignature=o,this.applyMeasuredHeights(c)}measureLines(e,t){if(e.length===0)return[];const n=this.ensureMeasurer(t);n.innerHTML=e.map(o=>`<div>${o===""?"​":o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</div>`).join("");const i=Array.from(n.children,o=>o.offsetHeight);return n.textContent="",i}wrapSignature(e){const t=getComputedStyle(this.contentElement);return[e,t.fontFamily,t.fontSize,t.fontWeight,t.letterSpacing,t.tabSize,t.paddingLeft,t.paddingRight,t.whiteSpace,t.overflowWrap,t.wordBreak].join("|")}ensureMeasurer(e){if(!this.measurer){const t=document.createElement("div");t.setAttribute("aria-hidden","true"),t.setAttribute("data-editor-measurer","true"),this.contentSurface.appendChild(t),this.measurer=t}return this.measurer.style.cssText=this.contentElement.style.cssText,Object.assign(this.measurer.style,{position:"absolute",top:"0",left:"0",zIndex:"-1",visibility:"hidden",pointerEvents:"none",width:`${e}px`,minWidth:"0",minHeight:"0",height:"auto"}),this.measurer}applyMeasuredHeights(e){var o,s;const t=this.measuredHeights;if(t===e||t!==null&&e!==null&&t.length===e.length&&t.every((l,c)=>l===e[c]))return;if(this.measuredHeights=e,this.measuredTops=[],e){let l=0;for(const c of e)this.measuredTops.push(l),l+=c}else this.measuredLines=null;const i=this.lineNumbersContentElement.children;for(let l=0;l<i.length;l+=1){const c=(o=t==null?void 0:t[l])!=null?o:this.lineHeight,d=(s=e==null?void 0:e[l])!=null?s:this.lineHeight;c!==d&&(i[l].style.height=`${d}px`)}this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.renderLineDecorations(this.lineDecorations),this.renderGutterDecorations(this.gutterDecorations)}updateGutterWidth(e){const n=String(Math.max(e,1)).length*this.gutterDigitWidth+this.gutterLineNumberPaddingLeft+this.gutterLineNumberPaddingRight,i=Math.ceil(n+this.gutterFoldColumnGap+this.gutterFoldColumnWidth);i!==this.gutterWidth&&(this.gutterWidth=i,this.lineNumbersElement.style.display!=="none"&&(this.lineNumbersElement.style.width=`${this.gutterWidth}px`,this.lineNumbersElement.style.minWidth=`${this.gutterWidth}px`))}setDecorations(e,t){this.lineDecorations=e,this.gutterDecorations=t,this.renderLineDecorations(e),this.renderGutterDecorations(t)}clearDecorations(){this.lastLineDecorationSnapshot&&(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=""),this.lastGutterDecorationSnapshot&&(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot="")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.serializeContentToSource()}setText(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map),this.contentElement.textContent!==e&&(this.contentElement.textContent=e),this.syncTrailingNewlineMarker(e.endsWith(`
|
|
119
191
|
`));const t=e.split(`
|
|
120
192
|
`).length;this.updateLineNumbers(t)}setHTML(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map);const t=/\n$/.test(e),n=/<|>/.test(e),i=/<span\b/i.test(e),o=/<[^>]+>/.test(e);n&&i?this.contentElement.innerHTML=e:o&&!n?this.contentElement.textContent=e:this.contentElement.innerHTML=e,this.syncTrailingNewlineMarker(t);const l=(this.contentElement.textContent||"").split(`
|
|
121
193
|
`).length;this.updateLineNumbers(l)}setHighlightHTML(e){e!==this.lastHighlightHTML&&(this.highlightElement.innerHTML=e,this.lastHighlightHTML=e),this.highlightElement.style.visibility="visible",this.highlightOverlayActive=!0,this.contentElement.style.color="transparent",this.contentElement.style.WebkitTextFillColor="transparent";const n=(this.contentElement.textContent||"").split(`
|
|
122
194
|
`).length;this.updateLineNumbers(n)}setLineWrapping(e){var t;this.lineWrapping=e,e?(!this.resizeObserver&&typeof ResizeObserver!="undefined"&&(this.resizeObserver=new ResizeObserver(()=>this.queueWrapMeasure()),this.resizeObserver.observe(this.contentElement)),this.queueWrapMeasure()):((t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,this.applyMeasuredHeights(null)),this.contentElement.style.whiteSpace=e?"pre-wrap":"pre",this.contentElement.style.overflow="visible",this.contentElement.style.minWidth=e?"100%":"max-content",this.contentSurface.style.minWidth=e?"100%":"max-content",this.contentElement.style.wordBreak="normal",this.contentElement.style.overflowWrap=e?"anywhere":"normal",this.highlightElement.style.whiteSpace=e?"pre-wrap":"pre",this.highlightElement.style.wordBreak="normal",this.highlightElement.style.overflowWrap=e?"anywhere":"normal"}setLineNumbersVisible(e){this.lineNumbersElement.style.display=e?"table-cell":"none",this.lineNumbersElement.style.width=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.minWidth=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.borderRightWidth=e?"1px":"0",this.scrollWrapper.style.width="100%",this.scrollWrapper.style.minWidth="100%"}setTabSize(e){const t=Math.max(1,Math.floor(e)||2);this.contentElement.style.tabSize=String(t),this.contentElement.style.MozTabSize=String(t),this.highlightElement.style.tabSize=String(t),this.highlightElement.style.MozTabSize=String(t)}syncTrailingNewlineMarkerForText(e){this.syncTrailingNewlineMarker(e.endsWith(`
|
|
123
|
-
`))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const t=this.getText(),n=this.positionToTextOffset(e,t),i=window.getSelection(),o=this.createDomRangeFromOffsets(n);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(s){console.warn("Could not set cursor position:",s)}else{const s=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),l=document.createRange();try{s&&s.parentNode===this.contentElement?l.setStartBefore(s):(l.selectNodeContents(this.contentElement),l.collapse(!1)),l.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(l),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const t=e.getRangeAt(0);if(!this.isNodeInsideContent(t.startContainer)||!this.isNodeInsideContent(t.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const n=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(t.startContainer,t.startOffset),endOffset:this.sourceOffsetFromBoundary(t.endContainer,t.endOffset),anchorOffset:n,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const t=e.getRangeAt(0);if(!this.isNodeInsideContent(t.startContainer)||!this.isNodeInsideContent(t.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const n=this.getText(),i=this.sourceOffsetFromBoundary(t.startContainer,t.startOffset),o=this.sourceOffsetFromBoundary(t.endContainer,t.endOffset),s=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,l=this.offsetToPositionInText(i,n),c=this.offsetToPositionInText(o,n),
|
|
195
|
+
`))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const t=this.getText(),n=this.positionToTextOffset(e,t),i=window.getSelection(),o=this.createDomRangeFromOffsets(n);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(s){console.warn("Could not set cursor position:",s)}else{const s=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),l=document.createRange();try{s&&s.parentNode===this.contentElement?l.setStartBefore(s):(l.selectNodeContents(this.contentElement),l.collapse(!1)),l.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(l),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const t=e.getRangeAt(0);if(!this.isNodeInsideContent(t.startContainer)||!this.isNodeInsideContent(t.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const n=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(t.startContainer,t.startOffset),endOffset:this.sourceOffsetFromBoundary(t.endContainer,t.endOffset),anchorOffset:n,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const t=e.getRangeAt(0);if(!this.isNodeInsideContent(t.startContainer)||!this.isNodeInsideContent(t.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const n=this.getText(),i=this.sourceOffsetFromBoundary(t.startContainer,t.startOffset),o=this.sourceOffsetFromBoundary(t.endContainer,t.endOffset),s=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,l=this.offsetToPositionInText(i,n),c=this.offsetToPositionInText(o,n),d=this.offsetToPositionInText(s,n);return{isInEditor:!0,isCollapsed:e.isCollapsed,cursor:d,range:e.isCollapsed?void 0:{start:l,end:c}}}setSelectionRange(e){const t=this.createDomRangeFromRange(e);if(t)try{const n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(t),this.ensureCaretVisible()}catch(n){console.warn("Could not set selection range:",n)}}createDomRangeFromOffsets(e,t=e){const[n,i]=e<=t?[e,t]:[t,e],o=this.resolveOffsetToDomPoint(n),s=this.resolveOffsetToDomPoint(i);if(!o||!s)return null;const l=document.createRange();try{return l.setStart(o.node,o.offset),l.setEnd(s.node,s.offset),l}catch(c){return null}}createDomRangeFromRange(e){const t=this.getText();return this.createDomRangeFromOffsets(this.positionToTextOffset(e.start,t),this.positionToTextOffset(e.end,t))}getPositionFromClientPoint(e,t){const n=this.getDomRangeFromClientPoint(e,t);if(!n||!this.isNodeInsideContent(n.startContainer))return null;const i=this.sourceOffsetFromBoundary(n.startContainer,n.startOffset);return this.offsetToPositionInText(i,this.getText())}setSelectionOffsets(e,t=e){const n=this.createDomRangeFromOffsets(e,t);if(n)try{const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(n),this.ensureCaretVisible()}catch(i){console.warn("Could not set selection offsets:",i)}}setSelectionBoundaryOffsets(e,t){const n=this.resolveOffsetToDomPoint(e),i=this.resolveOffsetToDomPoint(t),o=window.getSelection();if(!n||!i||!o){this.setSelectionOffsets(e,t);return}try{if(o.removeAllRanges(),e===t){const l=document.createRange();l.setStart(n.node,n.offset),l.collapse(!0),o.addRange(l),this.ensureCaretVisible();return}if(typeof o.extend=="function"){const l=document.createRange();l.setStart(n.node,n.offset),l.collapse(!0),o.addRange(l),o.extend(i.node,i.offset),this.ensureCaretVisible();return}const s=this.createDomRangeFromOffsets(e,t);if(!s)return;o.addRange(s),this.ensureCaretVisible()}catch(s){console.warn("Could not set selection boundary offsets:",s),this.setSelectionOffsets(e,t)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([t,n])=>{this.container.style.setProperty(`--${t}`,n)})}scrollToPosition(e){const t=Math.max(0,Math.floor(e.line)||0),i=this.lineTop(t)-this.editorContainer.clientHeight/2+this.lineHeight/2;this.editorContainer.scrollTop=Math.max(0,i)}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(e){this.editorContainer.scrollTop=e}syncTrailingNewlineMarker(e){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(n=>n.remove()),!e)return;const t=document.createElement("span");t.setAttribute(this.trailingNewlineMarkerAttr,"true"),t.setAttribute("aria-hidden","true"),t.contentEditable="false",t.style.cssText=`
|
|
124
196
|
display: inline-block;
|
|
125
197
|
width: 0;
|
|
126
198
|
overflow: hidden;
|
|
127
199
|
pointer-events: none;
|
|
128
200
|
user-select: none;
|
|
129
|
-
`,t.appendChild(document.createTextNode("")),this.contentElement.appendChild(t)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=this.getCaretClientRect(e);if(!t)return;const n=this.editorContainer.getBoundingClientRect(),i=12;t.bottom>n.bottom-i?this.editorContainer.scrollTop+=t.bottom-(n.bottom-i):t.top<n.top+i&&(this.editorContainer.scrollTop-=n.top+i-t.top),t.right>n.right-i?this.editorContainer.scrollLeft+=t.right-(n.right-i):t.left<n.left+i&&(this.editorContainer.scrollLeft-=n.left+i-t.left)}destroy(){var e;this.destroyed=!0,(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const t=Math.max(0,e);let n=0;const i=Array.from(this.contentElement.childNodes);for(let s=0;s<i.length;s++){const l=i[s];if(l instanceof Text){const c=l.textContent||"",
|
|
201
|
+
`,t.appendChild(document.createTextNode("")),this.contentElement.appendChild(t)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=this.getCaretClientRect(e);if(!t)return;const n=this.editorContainer.getBoundingClientRect(),i=12;t.bottom>n.bottom-i?this.editorContainer.scrollTop+=t.bottom-(n.bottom-i):t.top<n.top+i&&(this.editorContainer.scrollTop-=n.top+i-t.top),t.right>n.right-i?this.editorContainer.scrollLeft+=t.right-(n.right-i):t.left<n.left+i&&(this.editorContainer.scrollLeft-=n.left+i-t.left)}destroy(){var e;this.destroyed=!0,(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const t=Math.max(0,e);let n=0;const i=Array.from(this.contentElement.childNodes);for(let s=0;s<i.length;s++){const l=i[s];if(l instanceof Text){const c=l.textContent||"",d=this.buildVisibleToDomMap(c),u=Math.max(0,d.length-1);if(n+u>=t){const f=Math.max(0,t-n),p=(o=d[f])!=null?o:c.length;return{node:l,offset:p}}n+=u;continue}if(l instanceof HTMLElement&&!l.hasAttribute(this.trailingNewlineMarkerAttr)&&l.hasAttribute(this.foldPlaceholderAttr)){const d=this.getFoldPlaceholderSource(l).length;if(n+d>=t){const u=t-n;return{node:this.contentElement,offset:u<=d/2?s:s+1}}n+=d}}return{node:this.contentElement,offset:this.contentElement.childNodes.length}}getDomRangeFromClientPoint(e,t){const n=document;if(typeof n.caretPositionFromPoint=="function"){const i=n.caretPositionFromPoint(e,t);if(i!=null&&i.offsetNode){const o=document.createRange();try{return o.setStart(i.offsetNode,i.offset),o.collapse(!0),o}catch(s){return null}}}return typeof n.caretRangeFromPoint=="function"?n.caretRangeFromPoint(e,t):null}buildVisibleToDomMap(e){const t=[0];let n=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(n+=1,t[n]=i+1)}return t}isNodeInsideContent(e){return e===this.contentElement||this.contentElement.contains(e)}getCaretClientRect(e){var l,c,d;const t=e.getRangeAt(0).cloneRange();t.collapse(!1);const n=this.getUsableRangeRect(t);if(n)return n;const i=e.focusNode,o=e.focusOffset;if(i instanceof Text){const u=(c=(l=i.textContent)==null?void 0:l.length)!=null?c:0,f=document.createRange();if(o<u){f.setStart(i,o),f.setEnd(i,Math.min(u,o+1));const p=this.getUsableRangeRect(f);if(p)return p}if(o>0){f.setStart(i,o-1),f.setEnd(i,o);const p=this.getUsableRangeRect(f);if(p)return p}}const s=i instanceof Element?i:(d=i==null?void 0:i.parentElement)!=null?d:null;if(s&&s!==this.contentElement&&s!==this.editorContainer&&this.contentElement.contains(s)){const u=s.getBoundingClientRect();if(this.isUsableRect(u))return u}return null}getUsableRangeRect(e){const t=Array.from(e.getClientRects());for(let i=0;i<t.length;i++)if(this.isUsableRect(t[i]))return t[i];const n=e.getBoundingClientRect();return this.isUsableRect(n)?n:null}isUsableRect(e){return!!e&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&(e.width>0||e.height>0)}stripVirtualMarkers(e){return e.replace(this.virtualMarkerGlobalRegex,"")}clearHighlightOverlay(){!this.highlightOverlayActive&&!this.lastHighlightHTML||(this.highlightElement.innerHTML="",this.highlightElement.style.visibility="hidden",this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.contentElement.style.color="inherit",this.contentElement.style.WebkitTextFillColor="currentcolor")}serializeContentToSource(){let e="";const t=Array.from(this.contentElement.childNodes);for(const n of t){if(n instanceof Text){e+=this.stripVirtualMarkers(n.textContent||"");continue}if(n instanceof HTMLElement&&!n.hasAttribute(this.trailingNewlineMarkerAttr)){if(n.hasAttribute(this.foldPlaceholderAttr)){e+=this.getFoldPlaceholderSource(n);continue}e+=this.stripVirtualMarkers(n.textContent||"")}}return e}sourceOffsetFromBoundary(e,t){let n=0;const i=Array.from(this.contentElement.childNodes);if(e===this.contentElement){for(let o=0;o<Math.min(t,i.length);o++)n+=this.getSourceLength(i[o]);return n}for(let o=0;o<i.length;o++){const s=i[o];if(s===e){if(s instanceof Text)return n+this.stripVirtualMarkers((s.textContent||"").slice(0,t)).length;if(s instanceof HTMLElement){if(s.hasAttribute(this.foldPlaceholderAttr))return n+this.getFoldPlaceholderBoundaryOffset(s,s,t);const l=Array.from(s.childNodes);for(let c=0;c<Math.min(t,l.length);c++)n+=this.getSourceLength(l[c]);return n}}if(s instanceof HTMLElement&&s.contains(e))return s.hasAttribute(this.foldPlaceholderAttr)?n+this.getFoldPlaceholderBoundaryOffset(s,e,t):n+this.sourceOffsetWithinNode(s,e,t);n+=this.getSourceLength(s)}return n}sourceOffsetWithinNode(e,t,n){let i=0;const o=Array.from(e.childNodes);if(t===e){for(let s=0;s<Math.min(n,o.length);s++)i+=this.getSourceLength(o[s]);return i}for(let s=0;s<o.length;s++){const l=o[s];if(l===t){if(l instanceof Text)return i+this.stripVirtualMarkers((l.textContent||"").slice(0,n)).length;if(l instanceof HTMLElement){if(l.hasAttribute(this.foldPlaceholderAttr))return i+this.getFoldPlaceholderBoundaryOffset(l,l,n);const c=Array.from(l.childNodes);for(let d=0;d<Math.min(n,c.length);d++)i+=this.getSourceLength(c[d]);return i}}if(l instanceof HTMLElement&&l.contains(t))return l.hasAttribute(this.foldPlaceholderAttr)?i+this.getFoldPlaceholderBoundaryOffset(l,t,n):i+this.sourceOffsetWithinNode(l,t,n);i+=this.getSourceLength(l)}return i}getSourceLength(e){if(e instanceof Text)return this.stripVirtualMarkers(e.textContent||"").length;if(!(e instanceof HTMLElement)||e.hasAttribute(this.trailingNewlineMarkerAttr))return 0;if(e.hasAttribute(this.foldPlaceholderAttr))return this.getFoldPlaceholderSource(e).length;let t=0;return e.childNodes.forEach(n=>{t+=this.getSourceLength(n)}),t}renderLineDecorations(e){const t=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,s)=>o.line-s.line||o.id.localeCompare(s.id)),n=t.map(o=>`${o.id}:${o.line}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastLineDecorationSnapshot||(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=n,t.length===0))return;const i=document.createDocumentFragment();for(const o of t){const s=document.createElement("div");s.className=this.joinClassNames("lce-decoration lce-decoration-line",o.className),s.setAttribute("data-decoration-id",o.id),s.setAttribute("data-decoration-line",String(o.line)),s.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${this.lineTop(o.line)}px`,`height: ${this.lineHeightAt(o.line)}px`,"left: 12px","right: 12px","border-radius: 3px",this.serializeStyleObject(o.style)]),i.appendChild(s)}this.lineDecorationsElement.appendChild(i)}renderGutterDecorations(e){const t=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,s)=>o.line-s.line||o.id.localeCompare(s.id)),n=t.map(o=>`${o.id}:${o.line}:${o.label||""}:${o.title||""}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastGutterDecorationSnapshot||(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot=n,t.length===0))return;const i=document.createDocumentFragment();for(const o of t){const s=document.createElement("div");s.className=this.joinClassNames("lce-decoration lce-decoration-gutter",o.className),s.setAttribute("data-decoration-id",o.id),s.setAttribute("data-decoration-line",String(o.line)),s.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${this.lineTop(o.line)}px`,`height: ${this.lineHeightAt(o.line)}px`,"left: 0","right: 0","display: flex","align-items: center","justify-content: flex-end","padding-right: 4px","box-sizing: border-box",this.serializeStyleObject(o.style)]),o.title&&(s.title=o.title),s.textContent=o.label||"",i.appendChild(s)}this.gutterDecorationsElement.appendChild(i)}joinClassNames(...e){return e.filter(Boolean).join(" ").trim()}joinStyleFragments(e){return e.filter(t=>!!t&&t.trim().length>0).map(t=>{const n=t.trim();return n.endsWith(";")?n:`${n};`}).join(" ")}serializeStyleObject(e){return e?Object.entries(e).filter(([,t])=>typeof t=="string"&&t.length>0).map(([t,n])=>`${this.toKebabCase(t)}: ${n}`).join("; "):""}toKebabCase(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}offsetToPositionInText(e,t){const n=Math.max(0,Math.min(e,t.length)),o=t.slice(0,n).split(`
|
|
130
202
|
`);return{line:o.length-1,column:o[o.length-1].length}}positionToTextOffset(e,t){var l;const n=t.split(`
|
|
131
|
-
`),i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((l=n[i])==null?void 0:l.length)||0));let s=0;for(let c=0;c<i;c++)s+=n[c].length+1;return s+o}getFoldPlaceholderSource(e){const t=e.getAttribute(this.foldPlaceholderAttr),n=this.getFoldPlaceholderSources();return t&&n.has(t)?n.get(t)||"":e.__lceFoldHiddenText||""}getFoldPlaceholderSources(){return this.contentElement.__lceFoldPlaceholderSources||new Map}getFoldPlaceholderBoundaryOffset(e,t,n){const i=this.getFoldPlaceholderSource(e).length,o=this.stripVirtualMarkers(e.textContent||"").length;if(i===0||o===0)return 0;const s=document.createRange();s.selectNodeContents(e);try{s.setEnd(t,n)}catch(c){return 0}return this.stripVirtualMarkers(s.toString()).length<=o/2?0:i}setFoldPlaceholderSources(e){this.contentElement.__lceFoldPlaceholderSources=e}}let Pa=0;const ie=class ie{constructor(e,t={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.undoStack=[],this.redoStack=[],this.suppressHistory=!1,this.highlightTimeout=null,this.expectingProgrammaticCursor=!1,this.lastKnownCursor={line:0,column:0},this.editorInstanceId=++Pa,this.decorationHighlightStyleId=`editora-decoration-style-${this.editorInstanceId}`,this.decorationHighlightLimit=1e3,this.decorationLayers=new Map,this.inlineDecorationHighlightNames=new Set,this.decorationRenderRaf=null,this.decorationMutationObserver=null,this.hasCustomDecorationHighlightSupport=!1,this.lastProgrammaticClipboardInsertAt=0,this.tabReleased=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...t},this.textModel=new oi(this.config.value),this.view=new Na(e),this.view.setTabSize(this.config.tabSize||2),this.view.setLineWrapping(!!this.config.lineWrapping),this.view.setLineNumbersVisible(this.config.lineNumbers!==!1),this.hasCustomDecorationHighlightSupport=this.detectCustomHighlightSupport(),this.observeDecorationRelevantMutations(),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(n=>this.addExtension(n)),this.setTheme(this.config.theme),this.view.setReadOnly(this.config.readOnly||!1),this.renderTextWithHighlight(this.textModel.getText()),this.registerBuiltInCommands()}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}registerBuiltInCommands(){this.registerCommand("undo",()=>this.undo()),this.registerCommand("redo",()=>this.redo()),this.registerCommand("insertTab",()=>this.insertTab()),this.registerCommand("outdent",()=>{this.shiftSelectedLines(!0)}),this.registerCommand("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("beforeinput",t=>{if(this.suppressHistory||this.config.readOnly){this.pendingInputSnapshot=void 0;return}if(t.inputType==="insertFromPaste"||t.inputType==="insertFromPasteAsQuotation"||t.inputType==="insertFromDrop"){const n=t.dataTransfer,i=this.getPlainTextFromDataTransfer(n);if(i.length===0||(t.preventDefault(),this.pendingInputSnapshot=void 0,Date.now()-this.lastProgrammaticClipboardInsertAt<80))return;this.insertClipboardText(i);return}if(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak"){t.preventDefault(),this.pendingInputSnapshot=void 0,this.insertNewLine();return}if(!t.isComposing){const n=ie.deletionUnit(t.inputType,"Backward");if(n){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteBackward(n);return}const i=ie.deletionUnit(t.inputType,"Forward");if(i){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteForward(i);return}}if(t.inputType==="deleteByCut"){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteSelection();return}if(t.inputType==="insertText"&&typeof t.data=="string"&&!t.isComposing){t.preventDefault(),this.pendingInputSnapshot=void 0,this.replaceSelectionWithText(t.data);return}this.pendingInputSnapshot=this.captureHistorySnapshot()}),e.addEventListener("paste",t=>{if(this.config.readOnly){t.preventDefault();return}if(Date.now()-this.lastProgrammaticClipboardInsertAt<80){t.preventDefault();return}const n=this.getPlainTextFromDataTransfer(t.clipboardData);n.length!==0&&(t.preventDefault(),this.insertClipboardText(n))}),e.addEventListener("input",()=>{var i;const t=this.view.getText(),n=this.textModel.getText();t!==n?(this.suppressHistory||this.pushUndoSnapshot((i=this.pendingInputSnapshot)!=null?i:this.captureHistorySnapshot(n)),this.pendingInputSnapshot=void 0,this.textModel.setText(t),this.view.syncTrailingNewlineMarkerForText(t),this.hasRenderedFoldPlaceholders()?this.clearPendingHighlightRender():(this.clearPendingHighlightRender(),this.highlightTimeout=setTimeout(()=>{const o=this.view.getText();o!==this.textModel.getText()&&this.textModel.setText(o),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300)),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:t,oldText:n}])):this.pendingInputSnapshot=void 0}),this.documentSelectionChangeHandler=()=>{var i,o,s;const t=this.syncSelectionCacheFromView();if(!t.isInEditor)return;const n=(i=t.cursor)!=null?i:this.lastKnownCursor;this.emit("cursor",{position:n,anchor:(s=(o=t.range)==null?void 0:o.start)!=null?s:n}),this.emit("selection",t.isCollapsed?void 0:t.range)},document.addEventListener("selectionchange",this.documentSelectionChangeHandler),e.addEventListener("blur",()=>{this.tabReleased=!1}),e.addEventListener("keydown",t=>{if(this.emit("keydown",t),t.key==="Tab"&&this.tabReleased&&!t.ctrlKey&&!t.metaKey&&!t.altKey){this.tabReleased=!1;return}t.key!=="Escape"&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&(this.tabReleased=!1);const n=Array.from(this.extensions.values()).reverse();for(const s of n)if(s.onKeyDown&&s.onKeyDown(t)===!1){t.preventDefault(),t.stopPropagation();return}if(t.key==="Escape"&&!t.defaultPrevented&&(this.tabReleased=!0),t.key==="Tab"&&!this.config.readOnly){t.shiftKey?this.shiftSelectedLines(!0):this.insertTab(),t.preventDefault(),t.stopPropagation();return}const i=t.altKey||t.ctrlKey||t.metaKey,o=t.isComposing||t.keyCode===229;if(t.key==="Backspace"&&!this.config.readOnly&&!i&&!o){this.deleteBackward(),t.preventDefault(),t.stopPropagation();return}if(t.key==="Delete"&&!this.config.readOnly&&!i&&!o){this.deleteForward(),t.preventDefault(),t.stopPropagation();return}if(t.key==="Enter"&&!this.config.readOnly){this.insertNewLine(),t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("mousedown",t=>{this.emit("mousedown",t);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onMouseDown&&i.onMouseDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("contextmenu",t=>{this.emit("contextmenu",t);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onContextMenu&&i.onContextMenu(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...t){const n=this.eventListeners.get(e);n&&n.forEach(i=>i(...t))}getValue(){return this.textModel.getText()}setValue(e){const t=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:t}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){var n,i,o;const e=this.syncSelectionCacheFromView(),t=(n=e.cursor)!=null?n:this.lastKnownCursor;return{position:t,anchor:(o=(i=e.range)==null?void 0:i.start)!=null?o:t}}setCursor(e){const t=this.textModel.getText(),n=this.clampPositionToText(e,t),i=this.positionToOffsetInText(n,t);this.lastKnownCursor=n,this.lastKnownSelection=void 0,this.view.setSelectionOffsets(i),this.emit("cursor",this.getCursor())}getSelection(){const e=this.syncSelectionCacheFromView();if(!(!e.isInEditor||e.isCollapsed))return e.range}setSelection(e){const t=this.textModel.getText(),n=this.normalizeRange({start:this.clampPositionToText(e.start,t),end:this.clampPositionToText(e.end,t)}),i=this.positionToOffsetInText(n.start,t),o=this.positionToOffsetInText(n.end,t);this.lastKnownSelection=n,this.lastKnownCursor=n.end,this.view.setSelectionOffsets(i,o),this.emit("selection",n)}setTheme(e){this.currentTheme=e;const t={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(t);const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.setTheme=="function")try{n.setTheme(e==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this),e.name==="syntax-highlighting"&&typeof e.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(e){const t=this.extensions.get(e);t&&t.destroy&&t.destroy(),this.extensions.delete(e)}executeCommand(e,...t){const n=this.commands.get(e);n?n(...t):console.warn(`Command '${e}' not found`)}registerCommand(e,t){this.commands.set(e,t)}setDecorations(e,t){const n=e.trim();if(!n)throw new Error("Decoration layer name must not be empty");if(!Array.isArray(t)||t.length===0){this.decorationLayers.delete(n),this.scheduleDecorationRender();return}this.decorationLayers.set(n,t.map(i=>this.cloneDecoration(i))),this.scheduleDecorationRender()}clearDecorations(e){typeof e=="string"?this.decorationLayers.delete(e.trim()):this.decorationLayers.clear(),this.scheduleDecorationRender()}getDecorations(e){if(typeof e=="string")return(this.decorationLayers.get(e.trim())||[]).map(n=>this.cloneDecoration(n));const t=[];for(const n of this.decorationLayers.values())t.push(...n.map(i=>this.cloneDecoration(i)));return t}search(e,t={}){var u;if(!e)return[];const n={query:e,caseSensitive:!1,wholeWord:!1,regex:!1,...t},i=[],o=this.textModel.getText(),{normalizedText:s,normalizedToRawOffsets:l}=this.buildSearchTextAndOffsetMap(o),c=n.caseSensitive?s:s.toLowerCase(),h=n.caseSensitive?e:e.toLowerCase();if(n.regex){let p;try{p=new RegExp(e,n.caseSensitive?"g":"gi")}catch(T){return[]}let g;for(;(g=p.exec(s))!==null;){const T=(u=g[0])!=null?u:"";if(T.length===0){p.lastIndex=g.index+1;continue}const b=g.index,E=g.index+T.length;n.wholeWord&&!this.isWholeWordBoundary(s,b,E)||this.pushSearchResultFromOffsets(i,b,E,s,l)}}else{let p=0,g=c.indexOf(h,p);for(;g!==-1;){const T=g+h.length;!n.wholeWord||this.isWholeWordBoundary(s,g,T)?(this.pushSearchResultFromOffsets(i,g,T,s,l),p=T):p=g+1,g=c.indexOf(h,p)}}return i}pushSearchResultFromOffsets(e,t,n,i,o){var u,p;const s=(u=o[t])!=null?u:t,l=(p=o[n])!=null?p:s,c=this.textModel.offsetToPosition(s),h=this.textModel.offsetToPosition(l);e.push({range:{start:c,end:h},match:i.substring(t,n)})}isWholeWordBoundary(e,t,n){const i=t>0?e[t-1]:"",o=n<e.length?e[n]:"";return!this.isWordChar(i)&&!this.isWordChar(o)}isWordChar(e){return/^[A-Za-z0-9_]$/.test(e)}buildSearchTextAndOffsetMap(e){const t=[],n=[0];let i=0;for(let o=0;o<e.length;o++){const s=e[o];s===""||s===ie.CURSOR_SENTINEL||(t.push(s),i+=1,n[i]=o+1)}return n[i]=e.length,{normalizedText:t.join(""),normalizedToRawOffsets:n}}replace(e,t){const n=this.getValue();this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(n));const i=this.textModel.replaceRange(e,t);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(e,t,n={}){const i=this.search(e,n);if(i.length===0)return 0;this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));const o=[];for(let s=i.length-1;s>=0;s--)o.push(this.textModel.replaceRange(i[s].range,t));return this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",o),i.length}fold(e){this.clearPendingHighlightRender();const t=this.normalizeRange(e);if(t.start.line===t.end.line&&t.start.column===t.end.column)return;const n=this.folds.findIndex(o=>this.isSameFoldRange(o,t)),i={start:t.start,end:t.end,collapsed:!0,level:0};n!==-1?this.folds[n]=i:(this.folds.push(i),this.folds.sort((o,s)=>this.comparePositions(o.start,s.start)))}unfold(e){this.clearPendingHighlightRender();const t=this.normalizeRange(e);this.folds=this.folds.filter(n=>!this.isSameFoldRange(n,t))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(e,t=!0){const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.highlightHTML=="function")try{if(typeof this.view.setHighlightHTML=="function"){const E=this.view.getContentElement();(E.querySelector("[data-lce-fold-placeholder]")||E.textContent!==e)&&this.view.setText(e);const w=typeof n.highlight=="function"?n.highlight(e):n.highlightHTML(e);this.view.setHighlightHTML(w),this.view.syncTrailingNewlineMarkerForText(e),this.scheduleDecorationRender();return}const o=!t&&!this.expectingProgrammaticCursor;let s,l,c,h;const u=this.view.getSelectionState(),p=u.isInEditor&&!!u.cursor;(t||o)&&p&&(s=u.isCollapsed?void 0:u.range,l=this.textModel.positionToOffset(u.cursor),s&&(c=this.textModel.positionToOffset(s.start),h=this.textModel.positionToOffset(s.end)));const g=p&&(t||o)&&!s&&l!==void 0&&this.hasCollapsedSelectionInEditor(),T=g?this.insertSentinelAtOffset(e,l):e,b=typeof n.highlight=="function"?n.highlight(T):n.highlightHTML(T);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(b):this.view.setHTML(b),this.view.syncTrailingNewlineMarkerForText(e),(t||o)&&p&&requestAnimationFrame(()=>{try{if(g&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(s&&(c!==void 0||h!==void 0)){const E=c!==void 0?c:l,v=h!==void 0?h:l,w=Math.min(E,v),A=Math.max(E,v),U=this.textModel.offsetToPosition(w),I=this.textModel.offsetToPosition(A);this.view.setSelectionRange({start:U,end:I})}else if(l!==void 0){const E=this.textModel.offsetToPosition(l);this.view.setCursorPosition(E)}}catch(E){}}),this.scheduleDecorationRender();return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e),this.scheduleDecorationRender()}hasCollapsedSelectionInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return!1;const t=e.getRangeAt(0);return this.view.getContentElement().contains(t.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return;const t=e.getRangeAt(0),n=this.view.getContentElement();if(!n.contains(t.commonAncestorContainer))return;const i=t.cloneRange();return i.selectNodeContents(n),i.setEnd(t.endContainer,t.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(e){return e.replace(/\u200B/g,"").split(ie.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(e,t){const n=Math.max(0,Math.min(t,e.length));return e.slice(0,n)+ie.CURSOR_SENTINEL+e.slice(n)}restoreCursorFromSentinel(){var l;const e=this.view.getContentElement(),t=window.getSelection(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=n.nextNode(),o=null,s=0;for(;i;){const c=(l=i.textContent)!=null?l:"",h=c.indexOf(ie.CURSOR_SENTINEL);h!==-1&&(o||(o=i,s=h),i.textContent=c.split(ie.CURSOR_SENTINEL).join("")),i=n.nextNode()}if(!o||!t)return!1;try{const c=document.createRange();return c.setStart(o,s),c.collapse(!0),t.removeAllRanges(),t.addRange(c),!0}catch(c){return!1}}destroy(){var e;if(!this.isDestroyed){this.isDestroyed=!0,this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null),this.pendingInputSnapshot=void 0,this.documentSelectionChangeHandler&&(document.removeEventListener("selectionchange",this.documentSelectionChangeHandler),this.documentSelectionChangeHandler=void 0),this.decorationRenderRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.decorationRenderRaf),this.decorationRenderRaf=null),(e=this.decorationMutationObserver)==null||e.disconnect(),this.decorationMutationObserver=null,this.clearInlineDecorationHighlights(!0),this.decorationLayers.clear(),this.view.clearDecorations();for(const t of this.extensions.values())t.destroy&&t.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}undo(){if(this.undoStack.length===0)return;const e=this.undoStack.pop(),t=this.captureHistorySnapshot();this.pushSnapshot(this.redoStack,t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop(),t=this.captureHistorySnapshot();this.pushSnapshot(this.undoStack,t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly||this.shiftSelectedLines(!1))return;const e=" ".repeat(this.config.tabSize||2);this.replaceSelectionWithText(e)}shiftSelectedLines(e){if(this.config.readOnly)return!1;const t=this.textModel.getText(),{startOffset:n,endOffset:i}=this.getActiveSelectionOffsets(t),o=Math.min(n,i),s=Math.max(n,i);if(!e&&!t.slice(o,s).includes(`
|
|
203
|
+
`),i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((l=n[i])==null?void 0:l.length)||0));let s=0;for(let c=0;c<i;c++)s+=n[c].length+1;return s+o}getFoldPlaceholderSource(e){const t=e.getAttribute(this.foldPlaceholderAttr),n=this.getFoldPlaceholderSources();return t&&n.has(t)?n.get(t)||"":e.__lceFoldHiddenText||""}getFoldPlaceholderSources(){return this.contentElement.__lceFoldPlaceholderSources||new Map}getFoldPlaceholderBoundaryOffset(e,t,n){const i=this.getFoldPlaceholderSource(e).length,o=this.stripVirtualMarkers(e.textContent||"").length;if(i===0||o===0)return 0;const s=document.createRange();s.selectNodeContents(e);try{s.setEnd(t,n)}catch(c){return 0}return this.stripVirtualMarkers(s.toString()).length<=o/2?0:i}setFoldPlaceholderSources(e){this.contentElement.__lceFoldPlaceholderSources=e}}let ll=0;const cl=200,dl=1e3,ul=8e3,Q=class Q{constructor(e,t={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.undoStack=[],this.redoStack=[],this.suppressHistory=!1,this.highlightTimeout=null,this.expectingProgrammaticCursor=!1,this.lastKnownCursor={line:0,column:0},this.typingRun=null,this.editorInstanceId=++ll,this.decorationHighlightStyleId=`editora-decoration-style-${this.editorInstanceId}`,this.decorationHighlightLimit=1e3,this.decorationLayers=new Map,this.inlineDecorationHighlightNames=new Set,this.decorationRenderRaf=null,this.decorationMutationObserver=null,this.hasCustomDecorationHighlightSupport=!1,this.lastProgrammaticClipboardInsertAt=0,this.tabReleased=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...t},this.textModel=new ai(this.config.value),this.view=new al(e),this.view.setTabSize(this.config.tabSize||2),this.view.setLineWrapping(!!this.config.lineWrapping),this.view.setLineNumbersVisible(this.config.lineNumbers!==!1),this.hasCustomDecorationHighlightSupport=this.detectCustomHighlightSupport(),this.observeDecorationRelevantMutations(),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(n=>this.addExtension(n)),this.setTheme(this.config.theme),this.view.setReadOnly(this.config.readOnly||!1),this.renderTextWithHighlight(this.textModel.getText()),this.registerBuiltInCommands()}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}registerBuiltInCommands(){this.registerCommand("undo",()=>this.undo()),this.registerCommand("redo",()=>this.redo()),this.registerCommand("insertTab",()=>this.insertTab()),this.registerCommand("outdent",()=>{this.shiftSelectedLines(!0)}),this.registerCommand("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("beforeinput",t=>{if(this.suppressHistory||this.config.readOnly){this.pendingInputSnapshot=void 0;return}if(t.inputType==="insertFromPaste"||t.inputType==="insertFromPasteAsQuotation"||t.inputType==="insertFromDrop"){const n=t.dataTransfer,i=this.getPlainTextFromDataTransfer(n);if(i.length===0||(t.preventDefault(),this.pendingInputSnapshot=void 0,Date.now()-this.lastProgrammaticClipboardInsertAt<80))return;this.insertClipboardText(i);return}if(t.inputType==="insertParagraph"||t.inputType==="insertLineBreak"){t.preventDefault(),this.pendingInputSnapshot=void 0,this.insertNewLine();return}if(!t.isComposing){const n=Q.deletionUnit(t.inputType,"Backward");if(n){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteBackward(n);return}const i=Q.deletionUnit(t.inputType,"Forward");if(i){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteForward(i);return}}if(t.inputType==="deleteByCut"){t.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteSelection();return}if(t.inputType==="insertText"&&typeof t.data=="string"&&!t.isComposing){t.preventDefault(),this.pendingInputSnapshot=void 0,this.replaceSelectionWithText(t.data);return}this.pendingInputSnapshot=this.captureHistorySnapshot()}),e.addEventListener("paste",t=>{if(this.config.readOnly){t.preventDefault();return}if(Date.now()-this.lastProgrammaticClipboardInsertAt<80){t.preventDefault();return}const n=this.getPlainTextFromDataTransfer(t.clipboardData);n.length!==0&&(t.preventDefault(),this.insertClipboardText(n))}),e.addEventListener("input",()=>{var i;const t=this.view.getText(),n=this.textModel.getText();if(t!==n){if(!this.suppressHistory){const o=Q.describeEdit(n,t);this.recordUndoStep((i=this.pendingInputSnapshot)!=null?i:this.captureHistorySnapshot(n),o.removedLength,o.inserted,t)}this.pendingInputSnapshot=void 0,this.textModel.setText(t),this.view.syncTrailingNewlineMarkerForText(t),this.hasRenderedFoldPlaceholders()?this.clearPendingHighlightRender():(this.clearPendingHighlightRender(),this.highlightTimeout=setTimeout(()=>{const o=this.view.getText();o!==this.textModel.getText()&&this.textModel.setText(o),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300)),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:t,oldText:n}])}else this.pendingInputSnapshot=void 0}),this.documentSelectionChangeHandler=()=>{var i,o,s;const t=this.syncSelectionCacheFromView();if(!t.isInEditor)return;const n=(i=t.cursor)!=null?i:this.lastKnownCursor;this.emit("cursor",{position:n,anchor:(s=(o=t.range)==null?void 0:o.start)!=null?s:n}),this.emit("selection",t.isCollapsed?void 0:t.range)},document.addEventListener("selectionchange",this.documentSelectionChangeHandler),e.addEventListener("blur",()=>{this.tabReleased=!1}),e.addEventListener("keydown",t=>{if(/^(Arrow(Left|Right|Up|Down)|Home|End|Page(Up|Down))$/.test(t.key)&&this.closeTypingRun(),this.emit("keydown",t),t.key==="Tab"&&this.tabReleased&&!t.ctrlKey&&!t.metaKey&&!t.altKey){this.tabReleased=!1;return}t.key!=="Escape"&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&(this.tabReleased=!1);const n=Array.from(this.extensions.values()).reverse();for(const s of n)if(s.onKeyDown&&s.onKeyDown(t)===!1){t.preventDefault(),t.stopPropagation();return}if(t.key==="Escape"&&!t.defaultPrevented&&(this.tabReleased=!0),t.key==="Tab"&&!this.config.readOnly){t.shiftKey?this.shiftSelectedLines(!0):this.insertTab(),t.preventDefault(),t.stopPropagation();return}const i=t.altKey||t.ctrlKey||t.metaKey,o=t.isComposing||t.keyCode===229;if(t.key==="Backspace"&&!this.config.readOnly&&!i&&!o){this.deleteBackward(),t.preventDefault(),t.stopPropagation();return}if(t.key==="Delete"&&!this.config.readOnly&&!i&&!o){this.deleteForward(),t.preventDefault(),t.stopPropagation();return}if(t.key==="Enter"&&!this.config.readOnly){this.insertNewLine(),t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("mousedown",t=>{this.closeTypingRun(),this.emit("mousedown",t);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onMouseDown&&i.onMouseDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("contextmenu",t=>{this.emit("contextmenu",t);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onContextMenu&&i.onContextMenu(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...t){const n=this.eventListeners.get(e);n&&n.forEach(i=>i(...t))}getValue(){return this.textModel.getText()}setValue(e){const t=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:t}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){var n,i,o;const e=this.syncSelectionCacheFromView(),t=(n=e.cursor)!=null?n:this.lastKnownCursor;return{position:t,anchor:(o=(i=e.range)==null?void 0:i.start)!=null?o:t}}setCursor(e){const t=this.textModel.getText(),n=this.clampPositionToText(e,t),i=this.positionToOffsetInText(n,t);this.lastKnownCursor=n,this.lastKnownSelection=void 0,this.view.setSelectionOffsets(i),this.emit("cursor",this.getCursor())}getSelection(){const e=this.syncSelectionCacheFromView();if(!(!e.isInEditor||e.isCollapsed))return e.range}setSelection(e){const t=this.textModel.getText(),n=this.normalizeRange({start:this.clampPositionToText(e.start,t),end:this.clampPositionToText(e.end,t)}),i=this.positionToOffsetInText(n.start,t),o=this.positionToOffsetInText(n.end,t);this.lastKnownSelection=n,this.lastKnownCursor=n.end,this.view.setSelectionOffsets(i,o),this.emit("selection",n)}setTheme(e){this.currentTheme=e;const t={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(t);const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.setTheme=="function")try{n.setTheme(e==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this),e.name==="syntax-highlighting"&&typeof e.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(e){const t=this.extensions.get(e);t&&t.destroy&&t.destroy(),this.extensions.delete(e)}executeCommand(e,...t){const n=this.commands.get(e);n?n(...t):console.warn(`Command '${e}' not found`)}registerCommand(e,t){this.commands.set(e,t)}setDecorations(e,t){const n=e.trim();if(!n)throw new Error("Decoration layer name must not be empty");if(!Array.isArray(t)||t.length===0){this.decorationLayers.delete(n),this.scheduleDecorationRender();return}this.decorationLayers.set(n,t.map(i=>this.cloneDecoration(i))),this.scheduleDecorationRender()}clearDecorations(e){typeof e=="string"?this.decorationLayers.delete(e.trim()):this.decorationLayers.clear(),this.scheduleDecorationRender()}getDecorations(e){if(typeof e=="string")return(this.decorationLayers.get(e.trim())||[]).map(n=>this.cloneDecoration(n));const t=[];for(const n of this.decorationLayers.values())t.push(...n.map(i=>this.cloneDecoration(i)));return t}search(e,t={}){var u;if(!e)return[];const n={query:e,caseSensitive:!1,wholeWord:!1,regex:!1,...t},i=[],o=this.textModel.getText(),{normalizedText:s,normalizedToRawOffsets:l}=this.buildSearchTextAndOffsetMap(o),c=n.caseSensitive?s:s.toLowerCase(),d=n.caseSensitive?e:e.toLowerCase();if(n.regex){let f;try{f=new RegExp(e,n.caseSensitive?"g":"gi")}catch(y){return[]}let p;for(;(p=f.exec(s))!==null;){const y=(u=p[0])!=null?u:"";if(y.length===0){f.lastIndex=p.index+1;continue}const m=p.index,E=p.index+y.length;n.wholeWord&&!this.isWholeWordBoundary(s,m,E)||this.pushSearchResultFromOffsets(i,m,E,s,l)}}else{let f=0,p=c.indexOf(d,f);for(;p!==-1;){const y=p+d.length;!n.wholeWord||this.isWholeWordBoundary(s,p,y)?(this.pushSearchResultFromOffsets(i,p,y,s,l),f=y):f=p+1,p=c.indexOf(d,f)}}return i}pushSearchResultFromOffsets(e,t,n,i,o){var u,f;const s=(u=o[t])!=null?u:t,l=(f=o[n])!=null?f:s,c=this.textModel.offsetToPosition(s),d=this.textModel.offsetToPosition(l);e.push({range:{start:c,end:d},match:i.substring(t,n)})}isWholeWordBoundary(e,t,n){const i=t>0?e[t-1]:"",o=n<e.length?e[n]:"";return!this.isWordChar(i)&&!this.isWordChar(o)}isWordChar(e){return/^[A-Za-z0-9_]$/.test(e)}buildSearchTextAndOffsetMap(e){const t=[],n=[0];let i=0;for(let o=0;o<e.length;o++){const s=e[o];s===""||s===Q.CURSOR_SENTINEL||(t.push(s),i+=1,n[i]=o+1)}return n[i]=e.length,{normalizedText:t.join(""),normalizedToRawOffsets:n}}replace(e,t){const n=this.getValue();this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(n));const i=this.textModel.replaceRange(e,t);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(e,t,n={}){const i=this.search(e,n);if(i.length===0)return 0;this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));const o=[];for(let s=i.length-1;s>=0;s--)o.push(this.textModel.replaceRange(i[s].range,t));return this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",o),i.length}fold(e){this.clearPendingHighlightRender();const t=this.normalizeRange(e);if(t.start.line===t.end.line&&t.start.column===t.end.column)return;const n=this.folds.findIndex(o=>this.isSameFoldRange(o,t)),i={start:t.start,end:t.end,collapsed:!0,level:0};n!==-1?this.folds[n]=i:(this.folds.push(i),this.folds.sort((o,s)=>this.comparePositions(o.start,s.start)))}unfold(e){this.clearPendingHighlightRender();const t=this.normalizeRange(e);this.folds=this.folds.filter(n=>!this.isSameFoldRange(n,t))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(e,t=!0){const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.highlightHTML=="function")try{if(typeof this.view.setHighlightHTML=="function"){const E=this.view.getContentElement();(E.querySelector("[data-lce-fold-placeholder]")||E.textContent!==e)&&this.view.setText(e);const w=typeof n.highlight=="function"?n.highlight(e):n.highlightHTML(e);this.view.setHighlightHTML(w),this.view.syncTrailingNewlineMarkerForText(e),this.scheduleDecorationRender();return}const o=!t&&!this.expectingProgrammaticCursor;let s,l,c,d;const u=this.view.getSelectionState(),f=u.isInEditor&&!!u.cursor;(t||o)&&f&&(s=u.isCollapsed?void 0:u.range,l=this.textModel.positionToOffset(u.cursor),s&&(c=this.textModel.positionToOffset(s.start),d=this.textModel.positionToOffset(s.end)));const p=f&&(t||o)&&!s&&l!==void 0&&this.hasCollapsedSelectionInEditor(),y=p?this.insertSentinelAtOffset(e,l):e,m=typeof n.highlight=="function"?n.highlight(y):n.highlightHTML(y);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(m):this.view.setHTML(m),this.view.syncTrailingNewlineMarkerForText(e),(t||o)&&f&&requestAnimationFrame(()=>{try{if(p&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(s&&(c!==void 0||d!==void 0)){const E=c!==void 0?c:l,v=d!==void 0?d:l,w=Math.min(E,v),A=Math.max(E,v),B=this.textModel.offsetToPosition(w),R=this.textModel.offsetToPosition(A);this.view.setSelectionRange({start:B,end:R})}else if(l!==void 0){const E=this.textModel.offsetToPosition(l);this.view.setCursorPosition(E)}}catch(E){}}),this.scheduleDecorationRender();return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e),this.scheduleDecorationRender()}hasCollapsedSelectionInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return!1;const t=e.getRangeAt(0);return this.view.getContentElement().contains(t.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return;const t=e.getRangeAt(0),n=this.view.getContentElement();if(!n.contains(t.commonAncestorContainer))return;const i=t.cloneRange();return i.selectNodeContents(n),i.setEnd(t.endContainer,t.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(e){return e.replace(/\u200B/g,"").split(Q.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(e,t){const n=Math.max(0,Math.min(t,e.length));return e.slice(0,n)+Q.CURSOR_SENTINEL+e.slice(n)}restoreCursorFromSentinel(){var l;const e=this.view.getContentElement(),t=window.getSelection(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=n.nextNode(),o=null,s=0;for(;i;){const c=(l=i.textContent)!=null?l:"",d=c.indexOf(Q.CURSOR_SENTINEL);d!==-1&&(o||(o=i,s=d),i.textContent=c.split(Q.CURSOR_SENTINEL).join("")),i=n.nextNode()}if(!o||!t)return!1;try{const c=document.createRange();return c.setStart(o,s),c.collapse(!0),t.removeAllRanges(),t.addRange(c),!0}catch(c){return!1}}destroy(){var e;if(!this.isDestroyed){this.isDestroyed=!0,this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null),this.pendingInputSnapshot=void 0,this.documentSelectionChangeHandler&&(document.removeEventListener("selectionchange",this.documentSelectionChangeHandler),this.documentSelectionChangeHandler=void 0),this.decorationRenderRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.decorationRenderRaf),this.decorationRenderRaf=null),(e=this.decorationMutationObserver)==null||e.disconnect(),this.decorationMutationObserver=null,this.clearInlineDecorationHighlights(!0),this.decorationLayers.clear(),this.view.clearDecorations();for(const t of this.extensions.values())t.destroy&&t.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}undo(){if(this.undoStack.length===0)return;const e=this.undoStack.pop();this.closeTypingRun();const t=this.captureHistorySnapshot();this.pushSnapshot(this.redoStack,t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop();this.closeTypingRun();const t=this.captureHistorySnapshot();this.pushSnapshot(this.undoStack,t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly||this.shiftSelectedLines(!1))return;const e=" ".repeat(this.config.tabSize||2);this.replaceSelectionWithText(e)}shiftSelectedLines(e){if(this.config.readOnly)return!1;const t=this.textModel.getText(),{startOffset:n,endOffset:i}=this.getActiveSelectionOffsets(t),o=Math.min(n,i),s=Math.max(n,i);if(!e&&!t.slice(o,s).includes(`
|
|
132
204
|
`))return!1;const l=" ".repeat(this.config.tabSize||2),c=t.lastIndexOf(`
|
|
133
|
-
`,o-1)+1,
|
|
205
|
+
`,o-1)+1,d=s>o&&t[s-1]===`
|
|
134
206
|
`?s-1:s,u=t.indexOf(`
|
|
135
|
-
`,
|
|
136
|
-
`);let
|
|
137
|
-
`));const v=Math.max(c,o+
|
|
138
|
-
`)}deleteBackward(e="char"){this.config.readOnly||this.deleteUsingDirection("backward",e)}deleteForward(e="char"){this.config.readOnly||this.deleteUsingDirection("forward",e)}static deletionUnit(e,t){return e===`deleteContent${t}`?"char":e===`deleteWord${t}`?"word":e===`deleteSoftLine${t}`||e===`deleteHardLine${t}`?"line":null}deleteSelection(){if(this.config.readOnly)return;const e=this.textModel.getText(),{startOffset:t,endOffset:n}=this.getActiveSelectionOffsets(e),i=Math.min(t,n),o=Math.max(t,n);i!==o&&this.replaceOffsetsWithText(i,o,"")}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}off(e,t){if(!this.eventListeners.has(e))return;const n=this.eventListeners.get(e);if(t){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n.length=0}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}captureHistorySnapshot(e=this.textModel.getText()){const t=this.view.getSelectionState(),n=t.isInEditor&&!t.isCollapsed?t.range:void 0,i=t.isInEditor&&t.cursor?t.cursor:void 0,o=n!=null?n:this.lastKnownSelection,s=i!=null?i:this.lastKnownCursor,l=this.clampPositionToText(s,e),c={text:e,cursorOffset:this.positionToOffsetInText(l,e)};if(o){const
|
|
207
|
+
`,d),f=u===-1?t.length:u,p=t.slice(c,f).split(`
|
|
208
|
+
`);let y=0,m=0;const E=p.map((A,B)=>{let R=A;if(!e)R=A.length===0?A:l+A;else if(A.startsWith(" "))R=A.slice(1);else{const z=/^ */.exec(A)[0].length;R=A.slice(Math.min(z,l.length))}const D=R.length-A.length;return B===0&&(y=D),m+=D,R});if(m===0)return!0;this.replaceOffsetsWithText(c,f,E.join(`
|
|
209
|
+
`));const v=Math.max(c,o+y),w=Math.max(v,s+m);return o===s?this.setCursor(this.textModel.offsetToPosition(v)):this.setSelection({start:this.textModel.offsetToPosition(v),end:this.textModel.offsetToPosition(w)}),!0}insertNewLine(){this.config.readOnly||this.replaceSelectionWithText(`
|
|
210
|
+
`)}deleteBackward(e="char"){this.config.readOnly||this.deleteUsingDirection("backward",e)}deleteForward(e="char"){this.config.readOnly||this.deleteUsingDirection("forward",e)}static deletionUnit(e,t){return e===`deleteContent${t}`?"char":e===`deleteWord${t}`?"word":e===`deleteSoftLine${t}`||e===`deleteHardLine${t}`?"line":null}deleteSelection(){if(this.config.readOnly)return;const e=this.textModel.getText(),{startOffset:t,endOffset:n}=this.getActiveSelectionOffsets(e),i=Math.min(t,n),o=Math.max(t,n);i!==o&&this.replaceOffsetsWithText(i,o,"")}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}off(e,t){if(!this.eventListeners.has(e))return;const n=this.eventListeners.get(e);if(t){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n.length=0}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}captureHistorySnapshot(e=this.textModel.getText()){const t=this.view.getSelectionState(),n=t.isInEditor&&!t.isCollapsed?t.range:void 0,i=t.isInEditor&&t.cursor?t.cursor:void 0,o=n!=null?n:this.lastKnownSelection,s=i!=null?i:this.lastKnownCursor,l=this.clampPositionToText(s,e),c={text:e,cursorOffset:this.positionToOffsetInText(l,e)};if(o){const d=this.clampPositionToText(o.start,e),u=this.clampPositionToText(o.end,e);c.anchorOffset=this.positionToOffsetInText(d,e),c.focusOffset=this.positionToOffsetInText(u,e)}return c}restoreHistorySnapshot(e){this.setValue(e.text),requestAnimationFrame(()=>{try{if(e.anchorOffset!==void 0&&e.focusOffset!==void 0&&e.anchorOffset!==e.focusOffset){const n=Math.min(e.anchorOffset,e.focusOffset),i=Math.max(e.anchorOffset,e.focusOffset);this.setSelection({start:this.textModel.offsetToPosition(n),end:this.textModel.offsetToPosition(i)});return}this.setCursor(this.textModel.offsetToPosition(e.cursorOffset))}catch(t){}})}pushUndoSnapshot(e){this.pushSnapshot(this.undoStack,e),this.redoStack.length=0}static typingKind(e,t){return e===0&&t.length>0&&t.length<=2&&!t.includes(`
|
|
211
|
+
`)?"insert":e>0&&e<=2&&t.length===0?"delete":null}static describeEdit(e,t){const n=Math.min(e.length,t.length);let i=0;for(;i<n&&e.charCodeAt(i)===t.charCodeAt(i);)i++;let o=0;for(;o<n-i&&e.charCodeAt(e.length-1-o)===t.charCodeAt(t.length-1-o);)o++;return{removedLength:e.length-i-o,inserted:t.slice(i,t.length-o)}}recordUndoStep(e,t,n,i){const o=Q.typingKind(t,n),s=Date.now(),l=o==="insert"&&/\s/.test(n),c=this.typingRun;if(o&&c&&c.kind===o&&!c.closed&&c.endText===e.text&&s-c.updatedAt<=dl&&s-c.startedAt<=ul){c.endText=i,c.updatedAt=s,l&&(c.closed=!0);return}this.pushUndoSnapshot(e),this.typingRun=o?{kind:o,startedAt:s,updatedAt:s,endText:i,closed:l}:null}closeTypingRun(){this.typingRun&&(this.typingRun.closed=!0)}pushSnapshot(e,t){e.push(t),e.length>cl&&e.shift()}clampPositionToText(e,t){var s,l;const n=t.split(`
|
|
139
212
|
`),i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,(l=(s=n[i])==null?void 0:s.length)!=null?l:0));return{line:i,column:o}}positionToOffsetInText(e,t){var s,l;const n=t.split(`
|
|
140
213
|
`),i=this.clampPositionToText(e,t);let o=0;for(let c=0;c<i.line;c++)o+=((l=(s=n[c])==null?void 0:s.length)!=null?l:0)+1;return o+i.column}clearPendingHighlightRender(){this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null)}hasRenderedFoldPlaceholders(){return!!this.view.getContentElement().querySelector("[data-lce-fold-placeholder]")}replaceSelectionWithText(e){const t=e.replace(/\r\n?/g,`
|
|
141
214
|
`),n=this.textModel.getText(),{startOffset:i,endOffset:o}=this.getActiveSelectionOffsets(n),s=Math.max(0,Math.min(i,o)),l=Math.max(0,Math.max(i,o));return this.replaceOffsetsWithText(s,l,t)}insertClipboardText(e){this.pendingInputSnapshot=this.captureHistorySnapshot(),this.lastProgrammaticClipboardInsertAt=Date.now(),this.replaceSelectionWithText(this.normalizeClipboardText(e))}normalizeClipboardText(e){return e.replace(/\r\n?/g,`
|
|
142
|
-
`).replace(/\u00a0/g," ")}getPlainTextFromDataTransfer(e){if(!e)return"";const t=e.getData("text/plain");if(t)return t;const n=e.getData("text/html");return n?this.htmlClipboardToPlainText(n):""}htmlClipboardToPlainText(e){const t=document.implementation.createHTMLDocument("");t.body.innerHTML=e;const n=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","BR","DD","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","TABLE","TR","UL"]),i=l=>{var c;for(let
|
|
215
|
+
`).replace(/\u00a0/g," ")}getPlainTextFromDataTransfer(e){if(!e)return"";const t=e.getData("text/plain");if(t)return t;const n=e.getData("text/html");return n?this.htmlClipboardToPlainText(n):""}htmlClipboardToPlainText(e){const t=document.implementation.createHTMLDocument("");t.body.innerHTML=e;const n=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","BR","DD","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","TABLE","TR","UL"]),i=l=>{var c;for(let d=l.length-1;d>=0;d--){const u=(c=l[d])!=null?c:"";if(u.length!==0)return u.endsWith(`
|
|
143
216
|
`)}return!1},o=(l,c)=>{if(l instanceof Text){c.push(l.data);return}if(!(l instanceof HTMLElement)){l.childNodes.forEach(u=>o(u,c));return}if(l.tagName==="BR"){c.push(`
|
|
144
|
-
`);return}const
|
|
145
|
-
`),l.childNodes.forEach(u=>o(u,c)),
|
|
217
|
+
`);return}const d=n.has(l.tagName);d&&c.length>0&&!i(c)&&c.push(`
|
|
218
|
+
`),l.childNodes.forEach(u=>o(u,c)),d&&!i(c)&&c.push(`
|
|
146
219
|
`)},s=[];return t.body.childNodes.forEach(l=>o(l,s)),s.join("").replace(/\n{3,}/g,`
|
|
147
220
|
|
|
148
221
|
`).replace(/[ \t]+\n/g,`
|
|
149
|
-
`).trimEnd()}getActiveSelectionOffsets(e){const t=this.view.getSelectionOffsets();if(t.isInEditor)return{startOffset:t.startOffset,endOffset:t.endOffset};if(this.lastKnownSelection)return{startOffset:this.positionToOffsetInText(this.lastKnownSelection.start,e),endOffset:this.positionToOffsetInText(this.lastKnownSelection.end,e)};const n=this.positionToOffsetInText(this.lastKnownCursor,e);return{startOffset:n,endOffset:n}}deleteUsingDirection(e,t="char"){const n=this.textModel.getText(),{startOffset:i,endOffset:o}=this.getActiveSelectionOffsets(n),s=Math.min(i,o),l=Math.max(i,o);if(s!==l){this.replaceOffsetsWithText(s,l,"");return}if(e==="backward"){if(s===0)return;const
|
|
150
|
-
`,t-1)+1;return
|
|
151
|
-
`,t),
|
|
152
|
-
`)return
|
|
153
|
-
`){const
|
|
154
|
-
`&&!s(e[
|
|
155
|
-
`)return
|
|
156
|
-
`){const
|
|
157
|
-
`&&!s(e[
|
|
158
|
-
`,t-1)+1;if(
|
|
222
|
+
`).trimEnd()}getActiveSelectionOffsets(e){const t=this.view.getSelectionOffsets();if(t.isInEditor)return{startOffset:t.startOffset,endOffset:t.endOffset};if(this.lastKnownSelection)return{startOffset:this.positionToOffsetInText(this.lastKnownSelection.start,e),endOffset:this.positionToOffsetInText(this.lastKnownSelection.end,e)};const n=this.positionToOffsetInText(this.lastKnownCursor,e);return{startOffset:n,endOffset:n}}deleteUsingDirection(e,t="char"){const n=this.textModel.getText(),{startOffset:i,endOffset:o}=this.getActiveSelectionOffsets(n),s=Math.min(i,o),l=Math.max(i,o);if(s!==l){this.replaceOffsetsWithText(s,l,"");return}if(e==="backward"){if(s===0)return;const d=Q.deletionBoundary(n,s,"backward",t);this.replaceOffsetsWithText(d,s,"");return}if(l>=n.length)return;const c=Q.deletionBoundary(n,l,"forward",t);this.replaceOffsetsWithText(l,c,"")}static getGraphemeSegmenter(){if(Q.graphemeSegmenter===void 0){const e=Intl.Segmenter;Q.graphemeSegmenter=e?new e(void 0,{granularity:"grapheme"}):null}return Q.graphemeSegmenter}static deletionBoundary(e,t,n,i){const o=p=>/[A-Za-z0-9_]/.test(p),s=p=>p===" "||p===" ";if(i==="line"){if(n==="backward"){const m=e.lastIndexOf(`
|
|
223
|
+
`,t-1)+1;return m===t?t-1:m}const p=e.indexOf(`
|
|
224
|
+
`,t),y=p===-1?e.length:p;return y===t?Math.min(e.length,t+1):y}if(i==="word"){let p=t;if(n==="backward"){if(e[p-1]===`
|
|
225
|
+
`)return p-1;for(;p>0&&s(e[p-1]);)p--;if(p>0&&e[p-1]!==`
|
|
226
|
+
`){const y=o(e[p-1]);for(;p>0&&e[p-1]!==`
|
|
227
|
+
`&&!s(e[p-1])&&o(e[p-1])===y;)p--}return p}if(e[p]===`
|
|
228
|
+
`)return p+1;for(;p<e.length&&s(e[p]);)p++;if(p<e.length&&e[p]!==`
|
|
229
|
+
`){const y=o(e[p]);for(;p<e.length&&e[p]!==`
|
|
230
|
+
`&&!s(e[p])&&o(e[p])===y;)p++}return p}if(n==="backward"){const p=e.lastIndexOf(`
|
|
231
|
+
`,t-1)+1;if(p===t)return t-1;const y=Q.getGraphemeSegmenter();if(y){let v=1;for(const{segment:w}of y.segment(e.slice(p,t)))v=w.length;return t-v}const m=e.charCodeAt(t-1),E=t>=2?e.charCodeAt(t-2):0;return m>=56320&&m<=57343&&E>=55296&&E<=56319?t-2:t-1}if(e[t]===`
|
|
159
232
|
`)return t+1;const l=e.indexOf(`
|
|
160
|
-
`,t),c=l===-1?e.length:l,
|
|
161
|
-
`),o=this.textModel.getText(),s=(
|
|
162
|
-
::highlight(${
|
|
163
|
-
${this.serializeInlineDecorationStyle(
|
|
233
|
+
`,t),c=l===-1?e.length:l,d=Q.getGraphemeSegmenter();if(d){for(const{segment:p}of d.segment(e.slice(t,c)))return t+p.length;return t+1}const u=e.charCodeAt(t),f=t+1<e.length?e.charCodeAt(t+1):0;return u>=55296&&u<=56319&&f>=56320&&f<=57343?t+2:t+1}replaceOffsetsWithText(e,t,n){var y;this.ensureEditableSurfaceIsUnfolded();const i=n.replace(/\r\n?/g,`
|
|
234
|
+
`),o=this.textModel.getText(),s=(y=this.pendingInputSnapshot)!=null?y:this.captureHistorySnapshot(o),l=Math.max(0,Math.min(e,o.length)),c=Math.max(0,Math.min(t,o.length)),d=Math.min(l,c),u=Math.max(l,c),f=this.textModel.replaceRange({start:this.textModel.offsetToPosition(d),end:this.textModel.offsetToPosition(u)},i);this.pendingInputSnapshot=void 0,this.suppressHistory||this.recordUndoStep(s,u-d,i,this.textModel.getText());const p=d+i.length;return this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.textModel.getText(),!1),this.setCursor(this.textModel.offsetToPosition(p)),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[f]),f}ensureEditableSurfaceIsUnfolded(){!this.hasRenderedFoldPlaceholders()&&this.folds.length===0||(this.clearPendingHighlightRender(),this.folds=[],this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.textModel.getText(),!1),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20))}syncSelectionCacheFromView(){const e=this.view.getSelectionState();return e.isInEditor&&e.cursor&&(this.lastKnownCursor=e.cursor,this.lastKnownSelection=e.isCollapsed?void 0:e.range),e}isSameFoldRange(e,t){return e.start.line===t.start.line&&e.start.column===t.start.column&&e.end.line===t.end.line&&e.end.column===t.end.column}scheduleDecorationRender(){if(!this.isDestroyed){if(typeof requestAnimationFrame!="function"){this.applyDecorations();return}this.decorationRenderRaf===null&&(this.decorationRenderRaf=requestAnimationFrame(()=>{this.decorationRenderRaf=null,this.applyDecorations()}))}}applyDecorations(){if(this.isDestroyed)return;if(this.decorationLayers.size===0){this.view.clearDecorations(),this.clearInlineDecorationHighlights();return}const e=[],t=[],n=[];for(const[i,o]of this.decorationLayers.entries())for(const s of o){const l=`${i}::${s.id}`;if(s.type==="line"){e.push({...s,id:l});continue}if(s.type==="gutter"){t.push({...s,id:l});continue}n.push({...s,id:l})}this.view.setDecorations(this.normalizeLineDecorations(e),this.normalizeGutterDecorations(t)),this.renderInlineDecorations(n)}normalizeLineDecorations(e){const t=Math.max(0,this.textModel.getLineCount()-1);return e.filter(n=>Number.isFinite(n.line)).map(n=>({...n,line:Math.max(0,Math.min(t,Math.floor(n.line))),style:n.style?{...n.style}:void 0}))}normalizeGutterDecorations(e){const t=Math.max(0,this.textModel.getLineCount()-1);return e.filter(n=>Number.isFinite(n.line)).map(n=>({...n,line:Math.max(0,Math.min(t,Math.floor(n.line))),style:n.style?{...n.style}:void 0}))}renderInlineDecorations(e){if(!this.hasCustomDecorationHighlightSupport){this.clearInlineDecorationHighlights();return}const t=CSS,n=window.Highlight;if(!t.highlights||!n){this.clearInlineDecorationHighlights();return}if(this.clearInlineDecorationHighlights(),e.length===0)return;const i=this.textModel.getText(),o=[];let s=0;for(const c of e){if(s>=this.decorationHighlightLimit)break;const d=this.normalizeInlineDecoration(c,i);if(!d)continue;const u=this.view.createDomRangeFromRange(d.range);if(!u)continue;const f=this.buildInlineDecorationHighlightName(d.id);t.highlights.set(f,new n(u)),this.inlineDecorationHighlightNames.add(f),o.push(`
|
|
235
|
+
::highlight(${f}) {
|
|
236
|
+
${this.serializeInlineDecorationStyle(d.style)}
|
|
164
237
|
}
|
|
165
238
|
`),s+=1}const l=this.ensureDecorationHighlightStyleNode();l.textContent=o.join(`
|
|
166
|
-
`)}normalizeInlineDecoration(e,t){const n=this.normalizeRange({start:this.clampPositionToText(e.range.start,t),end:this.clampPositionToText(e.range.end,t)});return n.start.line===n.end.line&&n.start.column===n.end.column?null:{...e,range:n,style:e.style?{...e.style}:void 0}}clearInlineDecorationHighlights(e=!1){try{const n=CSS;if(n.highlights)for(const i of this.inlineDecorationHighlightNames)n.highlights.delete(i)}catch(n){}if(this.inlineDecorationHighlightNames.clear(),typeof document=="undefined")return;const t=document.getElementById(this.decorationHighlightStyleId);if(e){t!=null&&t.parentNode&&t.parentNode.removeChild(t);return}t&&(t.textContent="")}ensureDecorationHighlightStyleNode(){let e=document.getElementById(this.decorationHighlightStyleId);return e||(e=document.createElement("style"),e.id=this.decorationHighlightStyleId,document.head.appendChild(e),e)}observeDecorationRelevantMutations(){typeof MutationObserver!="undefined"&&(this.decorationMutationObserver=new MutationObserver(()=>{this.decorationLayers.size!==0&&this.scheduleDecorationRender()}),this.decorationMutationObserver.observe(this.view.getContentElement(),{childList:!0,subtree:!0,characterData:!0}))}detectCustomHighlightSupport(){try{if(typeof CSS=="undefined"||typeof window=="undefined")return!1;const e=CSS,t=window.Highlight;return!!e.highlights&&!!t}catch(e){return!1}}buildInlineDecorationHighlightName(e){return`editora-decoration-${this.editorInstanceId}-${this.sanitizeHighlightIdentifier(e)}`}sanitizeHighlightIdentifier(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-")}serializeInlineDecorationStyle(e){const t=this.serializeStyleObject(e);return t||"background-color: var(--lce-inline-decoration-bg, rgba(86, 156, 214, 0.18)); border-radius: 2px;"}serializeStyleObject(e){return e?Object.entries(e).filter(([,t])=>typeof t=="string"&&t.length>0).map(([t,n])=>`${this.toKebabCase(t)}: ${n};`).join(" "):""}toKebabCase(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}cloneDecoration(e){return e.type==="inline"?{...e,range:{start:{...e.range.start},end:{...e.range.end}},style:e.style?{...e.style}:void 0}:{...e,style:e.style?{...e.style}:void 0}}};
|
|
167
|
-
`).length;this.editor.getView().updateLineNumbers(e)}toggle(){this.editor&&(this.isEnabled=!this.isEnabled,this.editor.getView().setLineNumbersVisible(this.isEnabled),this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"table-cell":"none"),this.updateLineNumbers())}destroy(){this.lineNumbersElement=null,this.editor=null}}class
|
|
168
|
-
<div class="${
|
|
169
|
-
<input type="text" class="${
|
|
170
|
-
<button class="${
|
|
171
|
-
<button class="${
|
|
172
|
-
<button class="${
|
|
239
|
+
`)}normalizeInlineDecoration(e,t){const n=this.normalizeRange({start:this.clampPositionToText(e.range.start,t),end:this.clampPositionToText(e.range.end,t)});return n.start.line===n.end.line&&n.start.column===n.end.column?null:{...e,range:n,style:e.style?{...e.style}:void 0}}clearInlineDecorationHighlights(e=!1){try{const n=CSS;if(n.highlights)for(const i of this.inlineDecorationHighlightNames)n.highlights.delete(i)}catch(n){}if(this.inlineDecorationHighlightNames.clear(),typeof document=="undefined")return;const t=document.getElementById(this.decorationHighlightStyleId);if(e){t!=null&&t.parentNode&&t.parentNode.removeChild(t);return}t&&(t.textContent="")}ensureDecorationHighlightStyleNode(){let e=document.getElementById(this.decorationHighlightStyleId);return e||(e=document.createElement("style"),e.id=this.decorationHighlightStyleId,document.head.appendChild(e),e)}observeDecorationRelevantMutations(){typeof MutationObserver!="undefined"&&(this.decorationMutationObserver=new MutationObserver(()=>{this.decorationLayers.size!==0&&this.scheduleDecorationRender()}),this.decorationMutationObserver.observe(this.view.getContentElement(),{childList:!0,subtree:!0,characterData:!0}))}detectCustomHighlightSupport(){try{if(typeof CSS=="undefined"||typeof window=="undefined")return!1;const e=CSS,t=window.Highlight;return!!e.highlights&&!!t}catch(e){return!1}}buildInlineDecorationHighlightName(e){return`editora-decoration-${this.editorInstanceId}-${this.sanitizeHighlightIdentifier(e)}`}sanitizeHighlightIdentifier(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-")}serializeInlineDecorationStyle(e){const t=this.serializeStyleObject(e);return t||"background-color: var(--lce-inline-decoration-bg, rgba(86, 156, 214, 0.18)); border-radius: 2px;"}serializeStyleObject(e){return e?Object.entries(e).filter(([,t])=>typeof t=="string"&&t.length>0).map(([t,n])=>`${this.toKebabCase(t)}: ${n};`).join(" "):""}toKebabCase(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}cloneDecoration(e){return e.type==="inline"?{...e,range:{start:{...e.range.start},end:{...e.range.end}},style:e.style?{...e.style}:void 0}:{...e,style:e.style?{...e.style}:void 0}}};Q.CURSOR_SENTINEL="";let li=Q;class hl{constructor(e){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=e||this.getDefaultKeymap()}setup(e){this.editor=e}handleKeyDown(e){if(!this.editor)return;const t=this.findMatchingBinding(e);if(t)return this.editor.executeCommand(t.command),e.preventDefault(),e.stopPropagation(),!1}findMatchingBinding(e){const{key:t,ctrlKey:n,altKey:i,shiftKey:o,metaKey:s}=e,l=String(t).toLowerCase(),c=this.keymap[l];if(!c)return null;for(const d of c){const u=d.ctrlKey===void 0||d.ctrlKey===n,f=d.altKey===void 0||d.altKey===i,p=d.shiftKey===void 0||d.shiftKey===o,y=d.metaKey===void 0||d.metaKey===s;if(u&&f&&p&&y)return d}return null}onKeyDown(e){return this.handleKeyDown(e)}getDefaultKeymap(){const e={};return this.addBinding(e,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(e,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(e,"f3",{},"findNext"),this.addBinding(e,"f3",{shiftKey:!0},"findPrev"),this.addBinding(e,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(e,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(e,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(e,"s",{ctrlKey:!0},"save"),this.addBinding(e,"s",{metaKey:!0},"save"),this.addBinding(e,"z",{ctrlKey:!0,shiftKey:!1},"undo"),this.addBinding(e,"z",{metaKey:!0,shiftKey:!1},"undo"),this.addBinding(e,"y",{ctrlKey:!0},"redo"),this.addBinding(e,"y",{metaKey:!0},"redo"),this.addBinding(e,"z",{ctrlKey:!0,shiftKey:!0},"redo"),this.addBinding(e,"z",{metaKey:!0,shiftKey:!0},"redo"),this.addBinding(e,"tab",{shiftKey:!0},"outdent"),this.addBinding(e,"tab",{shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1},"insertTab"),this.addBinding(e,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),this.addBinding(e,"f",{altKey:!0,shiftKey:!0},"formatDocument"),e}addBinding(e,t,n,i){const o=t.toLowerCase();e[o]||(e[o]=[]),e[o].push({key:o,command:i,...n})}setKeymap(e){this.keymap={...e}}addKeyBinding(e){const t=e.key.toLowerCase();this.keymap[t]||(this.keymap[t]=[]),this.keymap[t]=this.keymap[t].filter(n=>n.command!==e.command),this.keymap[t].push({...e,key:t})}removeKeyBinding(e,t){const n=e.toLowerCase();t?this.keymap[n]&&(this.keymap[n]=this.keymap[n].filter(i=>i.command!==t),this.keymap[n].length===0&&delete this.keymap[n]):delete this.keymap[n]}getKeymap(){return{...this.keymap}}getBindingsForCommand(e){const t=[];for(const n in this.keymap)for(const i of this.keymap[n])i.command===e&&t.push({...i});return t}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}const qt=class qt{constructor(){this.name="transaction",this.transactions=[]}setup(e){e.on("change",t=>{const n={changes:t,selection:e.getSelection(),effects:[],annotations:[]};this.transactions.push(n),this.transactions.length>qt.MAX_TRANSACTIONS&&this.transactions.splice(0,this.transactions.length-qt.MAX_TRANSACTIONS)})}getTransactions(){return this.transactions}destroy(){this.transactions=[]}};qt.MAX_TRANSACTIONS=200;let ci=qt;class fl{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(e){this.editor=e,this.isEnabled=e.getConfig().lineNumbers!==!1,this.createLineNumbers(),e.registerCommand("toggleLineNumbers",()=>{this.toggle()}),e.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView(),t=e.getLineNumbersElement();t&&(this.lineNumbersElement=t,e.setLineNumbersVisible(this.isEnabled))}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const e=this.editor.getValue().split(`
|
|
240
|
+
`).length;this.editor.getView().updateLineNumbers(e)}toggle(){this.editor&&(this.isEnabled=!this.isEnabled,this.editor.getView().setLineNumbersVisible(this.isEnabled),this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"table-cell":"none"),this.updateLineNumbers())}destroy(){this.lineNumbersElement=null,this.editor=null}}class pl{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(e){this.editor=e,e.registerCommand("setTheme",t=>{this.setTheme(t)}),e.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(e){this.editor&&(this.currentTheme=e,this.editor.setTheme(e))}toggleTheme(){const e=this.currentTheme==="dark"?"light":"dark";this.setTheme(e)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class gl{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(e){this.editor=e,e.registerCommand("setReadOnly",t=>{this.setReadOnly(t)}),e.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),e.on("keydown",t=>{if(t.ctrlKey&&t.key==="r")return t.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(e){this.editor&&(this.isReadOnly=e,this.editor.setReadOnly(e))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}let ml=0;const I=class I{constructor(e={}){this.name="search",this.editor=null,this.searchUI=null,this.isVisible=!1,this.currentResults=[],this.currentIndex=-1,this.searchDebounceTimer=null,this.liveRefreshTimer=null,this.statusResetTimer=null,this.statusFreezeUntil=0,this.findInput=null,this.replaceInputEl=null,this.statusDiv=null,this.modeDiv=null,this.caseSensitiveInput=null,this.wholeWordInput=null,this.regexInput=null,this.currentQuery="",this.savedCursor=null,this.editorChangeHandler=null,this.searchOptions={caseSensitive:!1,wholeWord:!1,regex:!1},this.trailingMarkerAttr="data-lce-trailing-newline-marker",this.editorContainerSelector='[data-lce-editor-container="true"]',this.highlightId=++ml,this.highlightMatchName=`editora-search-match-${this.highlightId}`,this.highlightActiveName=`editora-search-active-${this.highlightId}`,this.highlightStyleId=`editora-search-highlight-style-${this.highlightId}`,this.maxCustomHighlightRanges=2e3,this.virtualMarkerRegex=/[\u200B\uE000]/,this.hasCustomHighlightSupport=!1,this.config={replaceAndFindNext:!0,...e}}setup(e){this.editor=e,this.hasCustomHighlightSupport=this.detectCustomHighlightSupport(),this.hasCustomHighlightSupport&&this.ensureHighlightStyles(),e.registerCommand("find",()=>{this.showSearch()}),e.registerCommand("findNext",()=>{this.findNext()}),e.registerCommand("findPrev",()=>{this.findPrev()}),e.registerCommand("replace",()=>{this.showReplace()}),e.registerCommand("replaceAll",(t,n)=>{this.replaceAll(t,n)}),this.editorChangeHandler=()=>{!this.isVisible||!this.currentQuery||this.scheduleLiveRefresh(!0)},e.on("change",this.editorChangeHandler)}showSearch(){this.editor&&(this.searchUI||this.createSearchUI(),this.isVisible||this.captureSelectionState(),this.isVisible=!0,this.searchUI&&(this.searchUI.style.display="block",this.updateModeHint(!1),this.findInput&&(this.findInput.focus(),this.findInput.select())),this.currentQuery&&this.performSearch(this.currentQuery,!0,!1))}showReplace(){this.showSearch(),this.replaceInputEl&&(this.replaceInputEl.style.display="block",this.replaceInputEl.focus()),this.updateModeHint(!0),this.currentQuery&&this.performSearch(this.currentQuery,!1,!0)}hideSearch(){this.isVisible=!1,this.searchUI&&(this.searchUI.style.display="none"),this.replaceInputEl&&(this.replaceInputEl.style.display="none",this.replaceInputEl.value=""),this.updateModeHint(!1),this.clearHighlights(),this.restoreSelectionState()}createSearchUI(){if(!this.editor)return;const e=this.editor.getView().getContentElement(),t=e.closest(this.editorContainerSelector),n=t==null?void 0:t.parentElement,i=e.closest(".rte-source-editor-modal")||n||t||e.parentElement;if(!i)return;window.getComputedStyle(i).position==="static"&&(i.style.position="relative"),this.searchUI=document.createElement("div"),this.searchUI.className=I.css.root,this.searchUI.style.display="none",this.searchUI.innerHTML=`
|
|
241
|
+
<div class="${I.css.row}">
|
|
242
|
+
<input type="text" class="${I.css.findInput} ${I.css.inputBase}" placeholder="Find..." />
|
|
243
|
+
<button class="${I.css.prevButton} ${I.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
|
|
244
|
+
<button class="${I.css.nextButton} ${I.css.buttonBase}" type="button" aria-label="Next match">↓</button>
|
|
245
|
+
<button class="${I.css.closeButton} ${I.css.buttonBase}" type="button" aria-label="Close search">×</button>
|
|
173
246
|
</div>
|
|
174
|
-
<div class="${
|
|
175
|
-
<label class="${
|
|
176
|
-
<input type="checkbox" class="${
|
|
247
|
+
<div class="${I.css.options}">
|
|
248
|
+
<label class="${I.css.optionLabel}" title="Case sensitive">
|
|
249
|
+
<input type="checkbox" class="${I.css.optionInput} ${I.css.caseSensitive}" />
|
|
177
250
|
<span>Aa</span>
|
|
178
251
|
</label>
|
|
179
|
-
<label class="${
|
|
180
|
-
<input type="checkbox" class="${
|
|
252
|
+
<label class="${I.css.optionLabel}" title="Whole word">
|
|
253
|
+
<input type="checkbox" class="${I.css.optionInput} ${I.css.wholeWord}" />
|
|
181
254
|
<span>Whole</span>
|
|
182
255
|
</label>
|
|
183
|
-
<label class="${
|
|
184
|
-
<input type="checkbox" class="${
|
|
256
|
+
<label class="${I.css.optionLabel}" title="Regular expression">
|
|
257
|
+
<input type="checkbox" class="${I.css.optionInput} ${I.css.regex}" />
|
|
185
258
|
<span>.*</span>
|
|
186
259
|
</label>
|
|
187
260
|
</div>
|
|
188
|
-
<div class="${
|
|
189
|
-
<div class="${
|
|
190
|
-
<div class="${
|
|
261
|
+
<div class="${I.css.meta}">
|
|
262
|
+
<div class="${I.css.status} ${I.css.statusLayout}"></div>
|
|
263
|
+
<div class="${I.css.mode} ${I.css.modeLayout}" aria-live="polite"></div>
|
|
191
264
|
</div>
|
|
192
|
-
<input type="text" class="${
|
|
193
|
-
`;const o=this.searchUI.querySelector(`.${
|
|
265
|
+
<input type="text" class="${I.css.replaceInput} ${I.css.inputBase} ${I.css.replaceInputLayout}" placeholder="Replace with..." />
|
|
266
|
+
`;const o=this.searchUI.querySelector(`.${I.css.findInput}`),s=this.searchUI.querySelector(`.${I.css.replaceInput}`),l=this.searchUI.querySelector(`.${I.css.prevButton}`),c=this.searchUI.querySelector(`.${I.css.nextButton}`),d=this.searchUI.querySelector(`.${I.css.closeButton}`),u=this.searchUI.querySelector(`.${I.css.status}`),f=this.searchUI.querySelector(`.${I.css.mode}`),p=this.searchUI.querySelector(`.${I.css.caseSensitive}`),y=this.searchUI.querySelector(`.${I.css.wholeWord}`),m=this.searchUI.querySelector(`.${I.css.regex}`);this.findInput=o,this.replaceInputEl=s,this.statusDiv=u,this.modeDiv=f,this.caseSensitiveInput=p,this.wholeWordInput=y,this.regexInput=m,p.checked=!!this.searchOptions.caseSensitive,y.checked=!!this.searchOptions.wholeWord,m.checked=!!this.searchOptions.regex,o.addEventListener("input",()=>{this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer);const v=o.value;this.searchDebounceTimer=setTimeout(()=>{this.performSearch(v,!1,!1)},120)});const E=()=>{this.searchOptions.caseSensitive=p.checked,this.searchOptions.wholeWord=y.checked,this.searchOptions.regex=m.checked;const v=o.value;v.trim()?this.performSearch(v,!1,!1):this.performSearch("",!1,!1)};p.addEventListener("change",E),y.addEventListener("change",E),m.addEventListener("change",E),o.addEventListener("keydown",v=>{v.key==="Enter"?(v.preventDefault(),v.shiftKey?this.findPrev():this.findNext()):v.key==="Escape"&&(v.preventDefault(),this.hideSearch())}),s.addEventListener("keydown",v=>{v.key==="Enter"?(v.preventDefault(),v.shiftKey?this.replaceAll(o.value,s.value):this.replaceCurrent(o.value,s.value)):v.key==="Escape"&&(v.preventDefault(),this.hideSearch())}),l.addEventListener("click",()=>this.findPrev()),c.addEventListener("click",()=>this.findNext()),d.addEventListener("click",()=>this.hideSearch()),i.appendChild(this.searchUI)}updateModeHint(e){this.modeDiv&&(this.modeDiv.textContent=e?`Replace: move next ${this.config.replaceAndFindNext?"ON":"OFF"}`:"Find mode")}performSearch(e,t,n){if(!this.editor||!e.trim()){this.currentQuery="",this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("");return}if(this.searchOptions.regex&&!this.isValidRegex(e)){this.currentQuery=e,this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Invalid regular expression");return}this.currentQuery=e;const i=this.currentIndex,o=this.editor.search(e,this.searchOptions);if(this.currentResults=o,o.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("No matches");return}t&&i>=0?this.currentIndex=Math.min(i,o.length-1):this.currentIndex=0,this.updateHighlights(n)}findNext(){if(this.currentResults.length===0){this.currentQuery&&this.performSearch(this.currentQuery,!0,!0);return}this.currentIndex=(this.currentIndex+1)%this.currentResults.length,this.updateHighlights(!0)}findPrev(){if(this.currentResults.length===0){this.currentQuery&&this.performSearch(this.currentQuery,!0,!0);return}this.currentIndex=this.currentIndex<=0?this.currentResults.length-1:this.currentIndex-1,this.updateHighlights(!0)}replaceCurrent(e,t){if(!this.editor||!e.trim()||((this.currentQuery!==e||this.currentResults.length===0)&&this.performSearch(e,!1,!0),this.currentIndex<0||this.currentResults.length===0))return;const n=this.currentResults[this.currentIndex];if(!n)return;const i=this.computeReplacementRange(n.range.start,t);if(this.editor.replace(n.range,t),this.config.replaceAndFindNext){this.currentQuery=e;const o=this.editor.search(e,this.searchOptions);if(this.currentResults=o,o.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Replaced current occurrence"),this.restoreReplaceInputFocus();return}this.currentIndex=this.findNextResultIndexAfter(i.end,o),this.updateHighlights(!0)}else this.scrollLogicalRangeIntoView(i,!0),this.performSearch(e,!0,!1);this.currentResults.length>0||this.showTransientStatus("Replaced current occurrence"),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}replaceAll(e,t){if(!this.editor||!e.trim())return;const n=this.editor.replaceAll(e,t,this.searchOptions);this.performSearch(e,!1,!1),this.showTransientStatus(`Replaced ${n} occurrence${n===1?"":"s"}`),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}updateHighlights(e){if(this.clearHighlights(),this.currentResults.length===0||this.currentIndex===-1||!this.editor)return;this.applyCustomHighlights();const t=this.currentResults[this.currentIndex];t&&((e||!this.hasCustomHighlightSupport)&&this.navigateToResult(t,!this.hasCustomHighlightSupport),this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}navigateToResult(e,t){if(!this.editor)return;const n=document.activeElement,i=!!n&&(n===this.findInput||n===this.replaceInputEl);t?(this.editor.setSelection(e.range),this.centerCurrentSelectionInView()):this.scrollResultIntoView(e);const o=this.editor.getView();t&&typeof o.ensureCaretVisible=="function"&&o.ensureCaretVisible(),t&&i&&n&&requestAnimationFrame(()=>{this.focusWithoutScrolling(n)})}clearHighlights(){var e,t;if(this.hasCustomHighlightSupport)try{const n=CSS;(e=n.highlights)==null||e.delete(this.highlightMatchName),(t=n.highlights)==null||t.delete(this.highlightActiveName)}catch(n){}}scrollResultIntoView(e){this.scrollLogicalRangeIntoView(e.range,!0)}scrollLogicalRangeIntoView(e,t){if(!this.editor)return;const n=this.editor.getView().getContentElement(),i=this.editor.getValue(),{lineStarts:o,lines:s}=this.buildLineStarts(i),l=this.buildTextNodeIndex(n);if(l.length===0)return;const c=this.toDomRange(e,o,s,l);if(!c)return;const d=c.startContainer.nodeType===Node.TEXT_NODE?c.startContainer.parentElement:c.startContainer,u=this.resolveScrollContainer(n);if(u){const f=c.getClientRects()[0]||c.getBoundingClientRect(),p=u.getBoundingClientRect(),m=u.scrollTop+(f.top-p.top)-p.height/2+f.height/2,E=18;let v=t?m:u.scrollTop,w=u.scrollLeft;const A=u.scrollLeft+(f.left-p.left),B=A+f.width;f.right>p.right-E?w=B-p.width+E:f.left<p.left+E&&(w=Math.max(0,A-E));const R=Math.max(0,u.scrollHeight-u.clientHeight),D=Math.max(0,u.scrollWidth-u.clientWidth);if(v=Math.min(R,Math.max(0,v)),w=Math.min(D,Math.max(0,w)),R===0&&D===0){d==null||d.scrollIntoView({block:t?"center":"nearest",inline:"nearest",behavior:"smooth"});return}(v!==u.scrollTop||w!==u.scrollLeft)&&u.scrollTo({top:v,left:w,behavior:"smooth"});return}d==null||d.scrollIntoView({block:t?"center":"nearest",inline:"nearest",behavior:"smooth"})}restoreReplaceInputFocus(){const e=this.replaceInputEl;!e||e.style.display==="none"||requestAnimationFrame(()=>{this.focusWithoutScrolling(e);const t=e.value.length;try{e.setSelectionRange(t,t)}catch(n){}})}centerCurrentSelectionInView(){if(!this.editor)return;const e=this.editor.getView().getContentElement(),t=this.resolveScrollContainer(e);if(!t)return;const n=window.getSelection();if(!n||n.rangeCount===0)return;const i=n.getRangeAt(0).cloneRange(),o=i.getClientRects()[0]||i.getBoundingClientRect();if(!o)return;const s=t.getBoundingClientRect(),c=t.scrollTop+(o.top-s.top)-s.height/2+o.height/2,d=Math.max(0,t.scrollHeight-t.clientHeight),u=Math.min(d,Math.max(0,c));u!==t.scrollTop&&t.scrollTo({top:u,behavior:"smooth"})}computeReplacementRange(e,t){const n=t.replace(/\r\n?/g,`
|
|
194
267
|
`),i=n.split(`
|
|
195
|
-
`);let o;return i.length<=1?(o={start:e,end:{line:e.line,column:e.column+n.length}},this.clampRangeToDocument(o)):(o={start:e,end:{line:e.line+i.length-1,column:i[i.length-1].length}},this.clampRangeToDocument(o))}findNextResultIndexAfter(e,t){for(let n=0;n<t.length;n++)if(this.comparePositions(t[n].range.start,e)>=0)return n;return 0}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}clampRangeToDocument(e){var
|
|
196
|
-
`),i=Math.max(0,n.length-1),o=Math.max(0,Math.min(e.start.line,i)),s=Math.max(0,Math.min(e.end.line,i)),l=Math.max(0,Math.min(e.start.column,((
|
|
197
|
-
`),n=new Array(t.length);let i=0;for(let o=0;o<t.length;o++)n[o]=i,i+=t[o].length+1;return{lineStarts:n,lines:t}}positionToOffset(e,t,n){var s;const i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((s=n[i])==null?void 0:s.length)||0));return t[i]+o}buildTextNodeIndex(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),n=[];let i=0,o;for(;o=t.nextNode();){const s=o,l=s.parentElement;if(l!=null&&l.hasAttribute(this.trailingMarkerAttr))continue;const c=s.textContent||"",
|
|
268
|
+
`);let o;return i.length<=1?(o={start:e,end:{line:e.line,column:e.column+n.length}},this.clampRangeToDocument(o)):(o={start:e,end:{line:e.line+i.length-1,column:i[i.length-1].length}},this.clampRangeToDocument(o))}findNextResultIndexAfter(e,t){for(let n=0;n<t.length;n++)if(this.comparePositions(t[n].range.start,e)>=0)return n;return 0}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}clampRangeToDocument(e){var d,u;const t=this.editor;if(!t)return e;const n=t.getValue().split(`
|
|
269
|
+
`),i=Math.max(0,n.length-1),o=Math.max(0,Math.min(e.start.line,i)),s=Math.max(0,Math.min(e.end.line,i)),l=Math.max(0,Math.min(e.start.column,((d=n[o])==null?void 0:d.length)||0)),c=Math.max(0,Math.min(e.end.column,((u=n[s])==null?void 0:u.length)||0));return{start:{line:o,column:l},end:{line:s,column:c}}}focusWithoutScrolling(e){try{e.focus({preventScroll:!0})}catch(t){const n=[];let i=e.parentElement;for(;i;)this.canScroll(i)&&n.push({el:i,top:i.scrollTop,left:i.scrollLeft}),i=i.parentElement;const o=window.scrollX,s=window.scrollY;e.focus();for(let l=0;l<n.length;l++){const c=n[l];c.el.scrollTop=c.top,c.el.scrollLeft=c.left}window.scrollTo(o,s)}}findScrollContainer(e){let t=e;for(;t;){const i=window.getComputedStyle(t).overflowY;if((i==="auto"||i==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}resolveScrollContainer(e){var i,o;const t=(i=this.editor)==null?void 0:i.getView(),n=((o=t==null?void 0:t.getScrollElement)==null?void 0:o.call(t))||null;return n&&this.canScroll(n)?n:this.findScrollContainer(e)}canScroll(e){return e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth}revealActiveResultAfterFocusRestore(){!this.currentResults.length||this.currentIndex<0||requestAnimationFrame(()=>{const e=this.currentResults[this.currentIndex];e&&this.scrollResultIntoView(e)})}applyCustomHighlights(){if(!this.editor||!this.hasCustomHighlightSupport||this.currentResults.length===0)return;const e=this.editor.getView().getContentElement(),t=this.editor.getValue(),{lineStarts:n,lines:i}=this.buildLineStarts(t),o=this.buildTextNodeIndex(e);if(o.length===0)return;const s=this.buildVisibleDocumentText(o),l=[];let c=null;const d=Math.min(this.currentResults.length,this.maxCustomHighlightRanges);for(let u=0;u<d;u++){const f=this.currentResults[u],p=this.searchOptions.regex?f.match||this.currentQuery:this.currentQuery||f.match,y=this.toDomRange(f.range,n,i,o,s,p);y&&(l.push(y),u===this.currentIndex&&(c=y))}if(l.length!==0)try{const u=CSS,f=window.Highlight;if(!u.highlights||!f)return;u.highlights.set(this.highlightMatchName,new f(...l)),c&&u.highlights.set(this.highlightActiveName,new f(c))}catch(u){}}buildLineStarts(e){const t=e.split(`
|
|
270
|
+
`),n=new Array(t.length);let i=0;for(let o=0;o<t.length;o++)n[o]=i,i+=t[o].length+1;return{lineStarts:n,lines:t}}positionToOffset(e,t,n){var s;const i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((s=n[i])==null?void 0:s.length)||0));return t[i]+o}buildTextNodeIndex(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),n=[];let i=0,o;for(;o=t.nextNode();){const s=o,l=s.parentElement;if(l!=null&&l.hasAttribute(this.trailingMarkerAttr))continue;const c=s.textContent||"",d=this.buildVisibleToDomMap(c),u=Math.max(0,d.length-1);u===0&&c.length===0||(n.push({node:s,start:i,end:i+u,visibleToDom:d}),i+=u)}return n}resolveDomPoint(e,t){var o,s,l,c,d,u;const n=Math.max(0,e);for(let f=0;f<t.length;f++){const p=t[f];if(n<=p.end){const y=Math.max(0,n-p.start),m=(l=(s=p.visibleToDom[y])!=null?s:(o=p.node.textContent)==null?void 0:o.length)!=null?l:0;return{node:p.node,offset:m}}}const i=t[t.length-1];return i?{node:i.node,offset:(u=(d=i.visibleToDom[i.visibleToDom.length-1])!=null?d:(c=i.node.textContent)==null?void 0:c.length)!=null?u:0}:null}toDomRange(e,t,n,i,o,s){const l=this.positionToOffset(e.start,t,n),c=this.positionToOffset(e.end,t,n);let d=Math.min(l,c),u=Math.max(l,c);if(o&&s){const m=s,E=o.slice(d,u);if(E.length===m.length&&E.toLowerCase()!==m.toLowerCase()){const v=this.findNearestMatchOffset(o,m,d);v!==-1&&(d=v,u=v+m.length)}}const f=this.resolveDomPoint(d,i),p=this.resolveDomPoint(u,i);if(!f||!p)return null;const y=document.createRange();try{return y.setStart(f.node,f.offset),y.setEnd(p.node,p.offset),y}catch(m){return null}}buildVisibleDocumentText(e){let t="";for(let n=0;n<e.length;n++){const i=e[n].node.textContent||"";for(let o=0;o<i.length;o++){const s=i[o];this.virtualMarkerRegex.test(s)||(t+=s)}}return t}findNearestMatchOffset(e,t,n){const i=t.toLowerCase();let o=e.toLowerCase().indexOf(i);if(o===-1)return-1;let s=o,l=Math.abs(o-n);for(;o!==-1;){const c=Math.abs(o-n);if(c<l&&(l=c,s=o),c===0)return o;o=e.toLowerCase().indexOf(i,o+1)}return s}scheduleLiveRefresh(e){this.liveRefreshTimer&&clearTimeout(this.liveRefreshTimer);const t=this.currentQuery;this.liveRefreshTimer=setTimeout(()=>{!this.isVisible||!t||this.performSearch(t,e,!1)},90)}updateStatus(e,t=!1){if(this.statusDiv){if(!t&&Date.now()<this.statusFreezeUntil)return;this.statusDiv.textContent=e}}showTransientStatus(e,t=900){this.statusFreezeUntil=Date.now()+t,this.updateStatus(e,!0),this.statusResetTimer&&clearTimeout(this.statusResetTimer),this.statusResetTimer=setTimeout(()=>{this.statusFreezeUntil=0,this.syncMatchStatus()},t)}syncMatchStatus(){if(!this.currentQuery){this.updateStatus("",!0);return}if(this.currentResults.length===0||this.currentIndex<0){this.updateStatus("No matches",!0);return}this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`,!0)}isValidRegex(e){try{const t=this.searchOptions.caseSensitive?"g":"gi";return new RegExp(e,t),!0}catch(t){return!1}}captureSelectionState(){this.editor&&(this.savedSelection=this.editor.getSelection(),this.savedCursor=this.editor.getCursor().position)}restoreSelectionState(){this.editor&&(this.savedSelection?this.editor.setSelection(this.savedSelection):this.savedCursor&&this.editor.setCursor(this.savedCursor),this.savedSelection=void 0,this.savedCursor=null)}detectCustomHighlightSupport(){try{const e=CSS,t=window.Highlight;return!!e.highlights&&!!t}catch(e){return!1}}buildVisibleToDomMap(e){const t=[0];let n=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(n+=1,t[n]=i+1)}return t}ensureHighlightStyles(){if(document.getElementById(this.highlightStyleId))return;const e=document.createElement("style");e.id=this.highlightStyleId,e.textContent=`
|
|
198
271
|
::highlight(${this.highlightMatchName}) {
|
|
199
272
|
background: var(--lce-search-match-bg, rgba(255, 214, 10, 0.34));
|
|
200
273
|
border-radius: 2px;
|
|
@@ -203,14 +276,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
203
276
|
background: var(--lce-search-active-bg, rgba(255, 154, 0, 0.45));
|
|
204
277
|
border-radius: 2px;
|
|
205
278
|
}
|
|
206
|
-
`,document.head.appendChild(e)}destroy(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=null),this.liveRefreshTimer&&(clearTimeout(this.liveRefreshTimer),this.liveRefreshTimer=null),this.statusResetTimer&&(clearTimeout(this.statusResetTimer),this.statusResetTimer=null),this.clearHighlights(),this.searchUI&&this.searchUI.parentNode&&this.searchUI.parentNode.removeChild(this.searchUI),this.editor&&this.editorChangeHandler&&this.editor.off("change",this.editorChangeHandler),this.editorChangeHandler=null,this.findInput=null,this.replaceInputEl=null,this.statusDiv=null,this.modeDiv=null,this.caseSensitiveInput=null,this.wholeWordInput=null,this.regexInput=null,this.searchUI=null;const e=document.getElementById(this.highlightStyleId);e!=null&&e.parentNode&&e.parentNode.removeChild(e),this.editor=null}};
|
|
279
|
+
`,document.head.appendChild(e)}destroy(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=null),this.liveRefreshTimer&&(clearTimeout(this.liveRefreshTimer),this.liveRefreshTimer=null),this.statusResetTimer&&(clearTimeout(this.statusResetTimer),this.statusResetTimer=null),this.clearHighlights(),this.searchUI&&this.searchUI.parentNode&&this.searchUI.parentNode.removeChild(this.searchUI),this.editor&&this.editorChangeHandler&&this.editor.off("change",this.editorChangeHandler),this.editorChangeHandler=null,this.findInput=null,this.replaceInputEl=null,this.statusDiv=null,this.modeDiv=null,this.caseSensitiveInput=null,this.wholeWordInput=null,this.regexInput=null,this.searchUI=null;const e=document.getElementById(this.highlightStyleId);e!=null&&e.parentNode&&e.parentNode.removeChild(e),this.editor=null}};I.css={root:"lce-search-ui",row:"lce-search-row",options:"lce-search-options",optionLabel:"lce-search-option",optionInput:"lce-search-option-input",caseSensitive:"search-case-sensitive",wholeWord:"search-whole-word",regex:"search-regex",meta:"lce-search-meta",findInput:"search-find-input",replaceInput:"search-replace-input",inputBase:"lce-search-input",replaceInputLayout:"lce-search-replace",prevButton:"search-prev",nextButton:"search-next",closeButton:"search-close",buttonBase:"lce-search-btn",status:"search-status",statusLayout:"lce-search-status",mode:"search-mode",modeLayout:"lce-search-mode"};let di=I,bl=0;class yl{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.highlightId=++bl,this.highlightName=`editora-bracket-match-${this.highlightId}`,this.highlightStyleId=`editora-bracket-match-style-${this.highlightId}`,this.currentMatch=null,this.hasCustomHighlightSupport=!1,this.observer=null,this.pendingUpdateRaf=null,this.updateRequestVersion=0,this.cursorHandler=null,this.changeHandler=null}setup(e){this.editor=e,this.hasCustomHighlightSupport=this.detectCustomHighlightSupport(),this.hasCustomHighlightSupport&&(this.ensureHighlightStyles(),this.observeContentMutations()),this.cursorHandler=()=>{this.scheduleBracketUpdate()},this.changeHandler=()=>{this.scheduleBracketUpdate()},e.on("cursor",this.cursorHandler),e.on("change",this.changeHandler),this.scheduleBracketUpdate()}scheduleBracketUpdate(){this.updateRequestVersion+=1;const e=this.updateRequestVersion;this.pendingUpdateRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null);const t=()=>{e===this.updateRequestVersion&&(this.pendingUpdateRaf=null,this.updateBracketMatching())};if(typeof requestAnimationFrame=="function"){this.pendingUpdateRaf=requestAnimationFrame(()=>{this.pendingUpdateRaf=requestAnimationFrame(t)});return}t()}updateBracketMatching(){if(!this.editor)return;const e=this.editor.getCursor(),t=this.editor.getValue();this.clearBracketHighlighting();const n=this.getBracketNearPosition(t,e.position);if(!n)return;const i=this.findMatchingBracket(t,n);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketNearPosition(e,t){const n=e.split(`
|
|
207
280
|
`);if(t.line<0||t.line>=n.length)return null;const i=[{line:t.line,column:t.column}];t.column>0&&i.push({line:t.line,column:t.column-1});for(const o of i){const s=this.getBracketAtPosition(n,o);if(s)return s}return null}getBracketAtPosition(e,t){if(t.line<0||t.line>=e.length)return null;const n=e[t.line];if(t.column<0||t.column>=n.length)return null;const i=n[t.column];return this.bracketPairs[i]||this.reverseBracketPairs[i]?{char:i,position:t}:null}findMatchingBracket(e,t){const n=e.split(`
|
|
208
|
-
`),i=t.position.line,o=t.position.column,s=t.char;return this.bracketPairs[s]?this.findClosingBracket(n,i,o,s):this.reverseBracketPairs[s]?this.findOpeningBracket(n,i,o,s):null}findClosingBracket(e,t,n,i){const o=this.bracketPairs[i];let s=0;for(let l=t;l<e.length;l++){const c=e[l],
|
|
281
|
+
`),i=t.position.line,o=t.position.column,s=t.char;return this.bracketPairs[s]?this.findClosingBracket(n,i,o,s):this.reverseBracketPairs[s]?this.findOpeningBracket(n,i,o,s):null}findClosingBracket(e,t,n,i){const o=this.bracketPairs[i];let s=0;for(let l=t;l<e.length;l++){const c=e[l],d=l===t?n:0;for(let u=d;u<c.length;u++){const f=c[u];if(f===i)s++;else if(f===o&&(s--,s===0))return{open:{start:{line:t,column:n},end:{line:t,column:n+1}},close:{start:{line:l,column:u},end:{line:l,column:u+1}},type:i}}}return null}findOpeningBracket(e,t,n,i){const o=this.reverseBracketPairs[i];let s=0;for(let l=t;l>=0;l--){const c=e[l],d=l===t?n:c.length-1;for(let u=d;u>=0;u--){const f=c[u];if(f===i)s++;else if(f===o&&(s--,s===0))return{open:{start:{line:l,column:u},end:{line:l,column:u+1}},close:{start:{line:t,column:n},end:{line:t,column:n+1}},type:o}}}return null}highlightBrackets(e){if(!this.editor||!this.hasCustomHighlightSupport)return;const t=this.editor.getView(),n=t.createDomRangeFromRange(e.open),i=t.createDomRangeFromRange(e.close);if(!(!n||!i))try{const o=CSS,s=window.Highlight;if(!o.highlights||!s)return;o.highlights.set(this.highlightName,new s(n,i))}catch(o){}}clearBracketHighlighting(){var e;if(this.currentMatch=null,!!this.hasCustomHighlightSupport)try{(e=CSS.highlights)==null||e.delete(this.highlightName)}catch(t){}}observeContentMutations(){if(!this.editor||typeof MutationObserver=="undefined")return;const e=this.editor.getView().getContentElement();this.observer=new MutationObserver(()=>{this.clearBracketHighlighting(),this.scheduleBracketUpdate()}),this.observer.observe(e,{childList:!0,subtree:!0,characterData:!0})}detectCustomHighlightSupport(){try{if(typeof CSS=="undefined"||typeof window=="undefined")return!1;const e=CSS,t=window.Highlight;return!!e.highlights&&!!t}catch(e){return!1}}ensureHighlightStyles(){if(typeof document=="undefined"||document.getElementById(this.highlightStyleId))return;const e=document.createElement("style");e.id=this.highlightStyleId,e.textContent=`
|
|
209
282
|
::highlight(${this.highlightName}) {
|
|
210
283
|
background-color: var(--lce-bracket-match-bg, rgba(86, 156, 214, 0.4));
|
|
211
284
|
text-decoration: underline solid var(--lce-bracket-match-border, rgba(156, 220, 254, 0.95)) 2px;
|
|
212
285
|
}
|
|
213
|
-
`,document.head.appendChild(e)}getCurrentMatch(){return this.currentMatch}destroy(){var e;if(this.pendingUpdateRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.clearBracketHighlighting(),(e=this.observer)==null||e.disconnect(),this.observer=null,this.editor&&this.cursorHandler&&this.editor.off("cursor",this.cursorHandler),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),typeof document!="undefined"){const t=document.getElementById(this.highlightStyleId);t!=null&&t.parentNode&&t.parentNode.removeChild(t)}this.cursorHandler=null,this.changeHandler=null,this.editor=null}}class
|
|
286
|
+
`,document.head.appendChild(e)}getCurrentMatch(){return this.currentMatch}destroy(){var e;if(this.pendingUpdateRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.clearBracketHighlighting(),(e=this.observer)==null||e.disconnect(),this.observer=null,this.editor&&this.cursorHandler&&this.editor.off("cursor",this.cursorHandler),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),typeof document!="undefined"){const t=document.getElementById(this.highlightStyleId);t!=null&&t.parentNode&&t.parentNode.removeChild(t)}this.cursorHandler=null,this.changeHandler=null,this.editor=null}}class Tl{constructor(){this.name="code-folding",this.lineHeight=24,this.voidMarkupTags=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),this.nonFoldableInlineMarkupTags=new Set(["a","abbr","b","bdi","bdo","button","cite","code","data","del","dfn","em","i","ins","kbd","label","mark","output","q","ruby","s","samp","small","span","strong","sub","sup","time","u","var"]),this.rawTextMarkupTags=new Set(["script","style","textarea","title"]),this.editor=null,this.foldingUI=null,this.pendingUpdateRaf=null,this.lastSnapshot="",this.lastParsedText=null,this.changeHandler=null,this.foldRegions=[],this.foldSnapshots=new Map,this.isDisplayingFolded=!1,this.cachedLineInfo=null}setup(e){this.editor=e,e.registerCommand("fold",()=>{this.foldAtCursor()}),e.registerCommand("unfold",()=>{this.unfoldAtCursor()}),e.registerCommand("foldAll",()=>{this.foldAll()}),e.registerCommand("unfoldAll",()=>{this.unfoldAll()}),this.changeHandler=()=>{this.syncFoldingState()},e.on("change",this.changeHandler),this.createFoldingUI(),this.syncFoldingState()}onKeyDown(e){}onMouseDown(e){}createFoldingUI(){if(!this.editor)return;const e=this.editor.getView().getLineNumbersElement();e&&(this.foldingUI=document.createElement("div"),this.foldingUI.setAttribute("data-lce-folding-ui","true"),this.foldingUI.style.cssText=`
|
|
214
287
|
position: absolute;
|
|
215
288
|
right: 0;
|
|
216
289
|
top: 0;
|
|
@@ -218,8 +291,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
218
291
|
width: 24px;
|
|
219
292
|
pointer-events: none;
|
|
220
293
|
z-index: 3;
|
|
221
|
-
`,e.appendChild(this.foldingUI))}syncFoldingState(){if(!this.editor)return;const e=this.editor.getValue(),t=this.foldSnapshots;e!==this.lastParsedText&&(this.foldRegions=this.buildFoldRegions(e),this.pruneInvalidFolds(e,t),this.lastParsedText=e),this.hasActiveFolds()?this.applyFoldedDisplay():this.restoreFullDisplay(),this.rememberActiveFoldSnapshots(e),this.scheduleFoldIndicatorUpdate()}scheduleFoldIndicatorUpdate(){this.pendingUpdateRaf===null&&(this.pendingUpdateRaf=requestAnimationFrame(()=>{this.pendingUpdateRaf=null,this.updateFoldIndicators()}))}updateFoldIndicators(){if(!this.editor||!this.foldingUI)return;const e=this.editor.getValue(),t=this.getActiveFolds().map(s=>this.getFoldKey(s)).join("|"),n=`${e}::${t}`;if(n===this.lastSnapshot)return;this.lastSnapshot=n,this.foldingUI.innerHTML="";const i=this.getRenderableActiveFolds(),o=document.createDocumentFragment();for(const s of this.foldRegions){const l=this.toDisplayLine(s,i);if(l===null)continue;const c=this.isFoldActive(s),
|
|
222
|
-
`),n=[],i=[],o={"{":"}","[":"]","(":")"},s={"}":"{","]":"[",")":"("};for(let c=0;c<t.length;c++){const
|
|
294
|
+
`,e.appendChild(this.foldingUI))}syncFoldingState(){if(!this.editor)return;const e=this.editor.getValue(),t=this.foldSnapshots;e!==this.lastParsedText&&(this.foldRegions=this.buildFoldRegions(e),this.pruneInvalidFolds(e,t),this.lastParsedText=e),this.hasActiveFolds()?this.applyFoldedDisplay():this.restoreFullDisplay(),this.rememberActiveFoldSnapshots(e),this.scheduleFoldIndicatorUpdate()}scheduleFoldIndicatorUpdate(){this.pendingUpdateRaf===null&&(this.pendingUpdateRaf=requestAnimationFrame(()=>{this.pendingUpdateRaf=null,this.updateFoldIndicators()}))}updateFoldIndicators(){if(!this.editor||!this.foldingUI)return;const e=this.editor.getValue(),t=this.getActiveFolds().map(s=>this.getFoldKey(s)).join("|"),n=`${e}::${t}`;if(n===this.lastSnapshot)return;this.lastSnapshot=n,this.foldingUI.innerHTML="";const i=this.getRenderableActiveFolds(),o=document.createDocumentFragment();for(const s of this.foldRegions){const l=this.toDisplayLine(s,i);if(l===null)continue;const c=this.isFoldActive(s),d=this.createFoldIndicator(s,l,c);o.appendChild(d)}this.foldingUI.appendChild(o)}buildFoldRegions(e){const t=this.buildBracketFoldRegions(e),n=this.shouldIncludeMarkupFolds(e)?this.buildMarkupFoldRegions(e):[];return this.mergeFoldRegions([...t,...n])}buildBracketFoldRegions(e){var l;const t=e.split(`
|
|
295
|
+
`),n=[],i=[],o={"{":"}","[":"]","(":")"},s={"}":"{","]":"[",")":"("};for(let c=0;c<t.length;c++){const d=t[c];for(let u=0;u<d.length;u++){const f=d[u];if(o[f]){n.push({char:f,line:c,column:u});continue}const p=s[f];if(!p)continue;let y=-1;for(let w=n.length-1;w>=0;w--)if(n[w].char===p){y=w;break}if(y===-1)continue;const m=n.splice(y,1)[0];if(m.line>=c)continue;const E=((l=t[m.line])==null?void 0:l.length)||0,v={start:{line:m.line,column:E},end:{line:c,column:0},collapsed:!1,level:y};this.isValidFoldRegion(v)&&i.push(v)}}return i.sort((c,d)=>c.start.line!==d.start.line?c.start.line-d.start.line:c.end.line!==d.end.line?c.end.line-d.end.line:c.start.column-d.start.column),i}shouldIncludeMarkupFolds(e){return/<!DOCTYPE\b/i.test(e)||/<[A-Za-z][\w:-]*(?:\s|>)/.test(e)&&/<\/[A-Za-z][\w:-]*\s*>/.test(e)}buildMarkupFoldRegions(e){const{lineStarts:t,lines:n}=this.buildLineStarts(e),i=[],o=[];let s=0;for(;s<e.length;){if(e[s]!=="<"){s+=1;continue}if(e.startsWith("<!--",s)){const c=e.indexOf("-->",s+4);s=c===-1?e.length:c+3;continue}if(e.startsWith("<![CDATA[",s)){const c=e.indexOf("]]>",s+9);s=c===-1?e.length:c+3;continue}const l=this.parseMarkupTag(e,s,t,n);if(!l){s+=1;continue}if(s=l.endOffset,l.isClosing){const c=o.findIndex(f=>f.name===l.name);if(c===-1)continue;const d=o.splice(c,1)[0],u=this.createMarkupFoldRegion(d.openEndLine,l.startLine,n);u&&i.push(u);continue}if(!(l.isSelfClosing||this.voidMarkupTags.has(l.name))){if(this.rawTextMarkupTags.has(l.name)){const c=this.findClosingMarkupTag(e,l.endOffset,l.name,t,n);if(c){const d=this.createMarkupFoldRegion(l.endLine,c.startLine,n);d&&i.push(d),s=c.endOffset}continue}this.nonFoldableInlineMarkupTags.has(l.name)||o.unshift({name:l.name,openEndLine:l.endLine})}}return i}parseMarkupTag(e,t,n,i){if(e[t]!=="<")return null;const o=e[t+1];if(!o||o!=="/"&&!/[A-Za-z]/.test(o))return null;const s=o==="/";let l=t+(s?2:1);const c=l;for(;l<e.length&&/[A-Za-z0-9:-]/.test(e[l]);)l+=1;const d=l;if(l===c)return null;let u=null;for(;l<e.length;){const E=e[l];if(u){E===u&&(u=null),l+=1;continue}if(E==='"'||E==="'"){u=E,l+=1;continue}if(E===">")break;l+=1}if(l>=e.length||e[l]!==">")return null;const f=e.slice(c,d).toLowerCase();if(!f)return null;const p=e.slice(t,l+1),y=this.offsetToLine(t,n,i),m=this.offsetToLine(l,n,i);return{name:f,isClosing:s,isSelfClosing:!s&&/\/\s*>$/.test(p),startLine:y,endLine:m,endOffset:l+1}}findClosingMarkupTag(e,t,n,i,o){const s=`</${n}`,l=e.toLowerCase();let c=l.indexOf(s,t);for(;c!==-1;){const d=this.parseMarkupTag(e,c,i,o);if(d&&d.isClosing&&d.name===n)return{startLine:d.startLine,endOffset:d.endOffset};c=l.indexOf(s,c+s.length)}return null}createMarkupFoldRegion(e,t,n){var l;if(e>=t)return null;const i=Math.max(0,Math.min(e,n.length-1)),o=Math.max(0,Math.min(t,n.length-1)),s={start:{line:i,column:((l=n[i])==null?void 0:l.length)||0},end:{line:o,column:0},collapsed:!1,level:0};return this.isValidFoldRegion(s)?s:null}mergeFoldRegions(e){const t=new Map;for(const n of e)this.isValidFoldRegion(n)&&t.set(this.getFoldKey(n),n);return[...t.values()].sort((n,i)=>n.start.line!==i.start.line?n.start.line-i.start.line:n.end.line!==i.end.line?n.end.line-i.end.line:n.start.column-i.start.column)}createFoldIndicator(e,t,n){const i=document.createElement("button");return i.type="button",i.style.cssText=`
|
|
223
296
|
position: absolute;
|
|
224
297
|
left: 0;
|
|
225
298
|
top: ${t*this.lineHeight}px;
|
|
@@ -236,19 +309,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
236
309
|
padding: 0;
|
|
237
310
|
font-size: 10px;
|
|
238
311
|
user-select: none;
|
|
239
|
-
`,i.textContent=n?"▶":"▼",i.title=n?"Expand folded region":"Collapse region",i.setAttribute("aria-label",i.title),i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.toggleFold(e)}),i}toggleFold(e){this.editor&&(this.isFoldActive(e)?this.editor.unfold(e):this.editor.fold(e),this.syncFoldingStatePreservingScroll())}foldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,t=this.findBestRegionForLine(e,!1);t&&(this.editor.fold(t),this.syncFoldingStatePreservingScroll())}unfoldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,t=this.findBestRegionForLine(e,!0);t&&(this.editor.unfold(t),this.syncFoldingStatePreservingScroll())}foldAll(){if(!this.editor)return;const e=this.getTopLevelFoldRegions(this.foldRegions);for(const t of e)this.editor.fold(t);this.syncFoldingStatePreservingScroll()}unfoldAll(){if(!this.editor)return;const e=this.getActiveFolds();for(const t of e)this.editor.unfold(t);this.syncFoldingStatePreservingScroll()}syncFoldingStatePreservingScroll(){this.withPreservedScroll(()=>{this.syncFoldingState()})}withPreservedScroll(e){var o;const t=(o=this.editor)==null?void 0:o.getView().getScrollElement();if(!t){e();return}const n=t.scrollLeft,i=t.scrollTop;e(),this.restoreScrollPosition(t,n,i)}restoreScrollPosition(e,t,n){e.scrollLeft=t,e.scrollTop=n,requestAnimationFrame(()=>{e.isConnected&&(e.scrollLeft=t,e.scrollTop=n)})}applyFoldedDisplay(){if(!this.editor)return;const e=this.getRenderableActiveFolds();if(e.length===0){this.restoreFullDisplay();return}const t=this.buildFoldedProjection(this.editor.getValue(),e);this.withPreservedSelection(()=>{this.renderEditorText(t.text),this.renderFoldPlaceholders(t),this.isDisplayingFolded=!0})}restoreFullDisplay(){this.editor&&(this.isDisplayingFolded&&this.withPreservedSelection(()=>{this.renderEditorText(this.editor.getValue())}),this.isDisplayingFolded=!1)}renderEditorText(e){if(!this.editor)return;const t=this.editor;if(typeof t.renderTextWithHighlight=="function"){t.expectingProgrammaticCursor=!0,t.renderTextWithHighlight(e,!1),t.expectingProgrammaticCursor=!1;return}this.editor.getView().setText(e)}buildFoldedProjection(e,t){const{lineStarts:n,lines:i}=this.buildLineStarts(e),o=[...t].sort((u,
|
|
312
|
+
`,i.textContent=n?"▶":"▼",i.title=n?"Expand folded region":"Collapse region",i.setAttribute("aria-label",i.title),i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.toggleFold(e)}),i}toggleFold(e){this.editor&&(this.isFoldActive(e)?this.editor.unfold(e):this.editor.fold(e),this.syncFoldingStatePreservingScroll())}foldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,t=this.findBestRegionForLine(e,!1);t&&(this.editor.fold(t),this.syncFoldingStatePreservingScroll())}unfoldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,t=this.findBestRegionForLine(e,!0);t&&(this.editor.unfold(t),this.syncFoldingStatePreservingScroll())}foldAll(){if(!this.editor)return;const e=this.getTopLevelFoldRegions(this.foldRegions);for(const t of e)this.editor.fold(t);this.syncFoldingStatePreservingScroll()}unfoldAll(){if(!this.editor)return;const e=this.getActiveFolds();for(const t of e)this.editor.unfold(t);this.syncFoldingStatePreservingScroll()}syncFoldingStatePreservingScroll(){this.withPreservedScroll(()=>{this.syncFoldingState()})}withPreservedScroll(e){var o;const t=(o=this.editor)==null?void 0:o.getView().getScrollElement();if(!t){e();return}const n=t.scrollLeft,i=t.scrollTop;e(),this.restoreScrollPosition(t,n,i)}restoreScrollPosition(e,t,n){e.scrollLeft=t,e.scrollTop=n,requestAnimationFrame(()=>{e.isConnected&&(e.scrollLeft=t,e.scrollTop=n)})}applyFoldedDisplay(){if(!this.editor)return;const e=this.getRenderableActiveFolds();if(e.length===0){this.restoreFullDisplay();return}const t=this.buildFoldedProjection(this.editor.getValue(),e);this.withPreservedSelection(()=>{this.renderEditorText(t.text),this.renderFoldPlaceholders(t),this.isDisplayingFolded=!0})}restoreFullDisplay(){this.editor&&(this.isDisplayingFolded&&this.withPreservedSelection(()=>{this.renderEditorText(this.editor.getValue())}),this.isDisplayingFolded=!1)}renderEditorText(e){if(!this.editor)return;const t=this.editor;if(typeof t.renderTextWithHighlight=="function"){t.expectingProgrammaticCursor=!0,t.renderTextWithHighlight(e,!1),t.expectingProgrammaticCursor=!1;return}this.editor.getView().setText(e)}buildFoldedProjection(e,t){const{lineStarts:n,lines:i}=this.buildLineStarts(e),o=[...t].sort((u,f)=>this.comparePositions(u.start,f.start));let s="";const l=[];let c=0;for(const u of o){const f=this.positionToOffset(u.start,n,i),p=this.positionToOffset(u.end,n,i),y=e.slice(c,f),m=this.getFoldPlaceholder(u),E=e.slice(f,p);s+=y,s+=m,y&&l.push({type:"text",text:y}),l.push({type:"placeholder",text:m,fold:u,hiddenText:E}),c=p}const d=e.slice(c);return s+=d,d&&l.push({type:"text",text:d}),{text:s,segments:l}}renderFoldPlaceholders(e){if(!this.editor)return;const t=this.editor.getView().getContentElement(),n=new Map,i=document.createDocumentFragment();for(const o of e.segments){if(o.type==="text"){i.appendChild(document.createTextNode(o.text));continue}const s=document.createElement("span"),l=this.getFoldKey(o.fold);s.setAttribute("data-lce-fold-placeholder",l),s.setAttribute("aria-label","Folded region"),s.contentEditable="false",n.set(l,o.hiddenText),s.style.cssText=`
|
|
240
313
|
cursor: text;
|
|
241
314
|
user-select: text;
|
|
242
315
|
pointer-events: auto;
|
|
243
316
|
white-space: pre;
|
|
244
|
-
`,s.textContent=o.text,i.appendChild(s)}t.replaceChildren(i),t.__lceFoldPlaceholderSources=n,this.editor.getView().syncTrailingNewlineMarkerForText(e.text)}getFoldPlaceholder(e){const t=Math.max(1,e.end.line-e.start.line);return` … ${t} ${t===1?"line":"lines"} … `}pruneInvalidFolds(e,t){if(!this.editor)return;const n=this.editor.getFolds().filter(
|
|
245
|
-
`),n=new Array(t.length);let i=0;for(let o=0;o<t.length;o++)n[o]=i,i+=t[o].length+1;return{lineStarts:n,lines:t}}getLineInfo(e){var n;if(((n=this.cachedLineInfo)==null?void 0:n.text)===e)return this.cachedLineInfo;const t={text:e,...this.buildLineStarts(e)};return this.cachedLineInfo=t,t}offsetToLine(e,t,n){var c;const i=t.length>0?t[t.length-1]+(((c=n[n.length-1])==null?void 0:c.length)||0):0,o=Math.max(0,Math.min(e,i));let s=0,l=t.length-1;for(;s<=l;){const h=Math.floor((s+l)/2),u=t[h],p=h+1<t.length?t[h+1]:Number.POSITIVE_INFINITY;if(o<u){l=h-1;continue}if(o>=p){s=h+1;continue}return h}return Math.max(0,Math.min(s,t.length-1))}positionToOffset(e,t,n){var s;const i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((s=n[i])==null?void 0:s.length)||0));return t[i]+o}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}containsRange(e,t){return this.comparePositions(e.start,t.start)<=0&&this.comparePositions(e.end,t.end)>=0&&!this.isSameRange(e,t)}isSameRange(e,t){return e.start.line===t.start.line&&e.start.column===t.start.column&&e.end.line===t.end.line&&e.end.column===t.end.column}isFoldActive(e){return this.getActiveFolds().some(t=>this.isSameRange(t,e))}isValidFoldRegion(e){return e.start.line<e.end.line&&(e.start.line!==e.end.line||e.start.column!==e.end.column)}getFoldKey(e){return`${e.start.line}:${e.start.column}-${e.end.line}:${e.end.column}`}destroy(){this.pendingUpdateRaf!==null&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),this.foldingUI&&this.foldingUI.parentNode&&this.foldingUI.parentNode.removeChild(this.foldingUI),this.restoreFullDisplay(),this.changeHandler=null,this.lastSnapshot="",this.lastParsedText=null,this.foldingUI=null,this.foldRegions=[],this.cachedLineInfo=null,this.editor=null}}class Va{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(e){this.editor=e,this.registerMode("html",{name:"html",highlight:(t,n)=>this._highlightHTML(t,n)}),this.registerMode("css",{name:"css",highlight:(t,n)=>this._highlightCSS(t,n)}),this.registerMode("javascript",{name:"javascript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("js",{name:"javascript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("jsx",{name:"jsx",highlight:(t,n)=>this._highlightJSX(t,n)}),this.registerMode("typescript",{name:"typescript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("ts",{name:"typescript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("tsx",{name:"tsx",highlight:(t,n)=>this._highlightJSX(t,n)}),this.registerMode("json",{name:"json",highlight:(t,n)=>this._highlightJSON(t,n)}),this.registerMode("markdown",{name:"markdown",highlight:(t,n)=>this._highlightMarkdown(t,n)}),this.registerMode("md",{name:"markdown",highlight:(t,n)=>this._highlightMarkdown(t,n)}),this.registerMode("bash",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("shell",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("sh",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("zsh",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("python",{name:"python",highlight:(t,n)=>this._highlightGenericCode(t,n,"python")}),this.registerMode("py",{name:"python",highlight:(t,n)=>this._highlightGenericCode(t,n,"python")}),this.registerMode("go",{name:"go",highlight:(t,n)=>this._highlightGenericCode(t,n,"go")}),this.registerMode("golang",{name:"go",highlight:(t,n)=>this._highlightGenericCode(t,n,"go")}),this.registerMode("c",{name:"c",highlight:(t,n)=>this._highlightGenericCode(t,n,"c")}),this.registerMode("cpp",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("c++",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("cc",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("cxx",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("java",{name:"java",highlight:(t,n)=>this._highlightGenericCode(t,n,"java")}),this.registerMode("csharp",{name:"csharp",highlight:(t,n)=>this._highlightGenericCode(t,n,"csharp")}),this.registerMode("cs",{name:"csharp",highlight:(t,n)=>this._highlightGenericCode(t,n,"csharp")}),this.registerMode("rust",{name:"rust",highlight:(t,n)=>this._highlightGenericCode(t,n,"rust")}),this.registerMode("rs",{name:"rust",highlight:(t,n)=>this._highlightGenericCode(t,n,"rust")}),this.registerMode("ruby",{name:"ruby",highlight:(t,n)=>this._highlightGenericCode(t,n,"ruby")}),this.registerMode("rb",{name:"ruby",highlight:(t,n)=>this._highlightGenericCode(t,n,"ruby")}),this.registerMode("sql",{name:"sql",highlight:(t,n)=>this._highlightGenericCode(t,n,"sql")}),this.registerMode("yaml",{name:"yaml",highlight:(t,n)=>this._highlightYAML(t,n)}),this.registerMode("yml",{name:"yaml",highlight:(t,n)=>this._highlightYAML(t,n)}),this.registerMode("xml",{name:"xml",highlight:(t,n)=>this._highlightXML(t,n)}),this.registerMode("svg",{name:"xml",highlight:(t,n)=>this._highlightXML(t,n)}),this.registerMode("vue",{name:"vue",highlight:(t,n)=>this._highlightHTML(t,n)}),this.registerMode("ejs",{name:"ejs",highlight:(t,n)=>this._highlightEJS(t,n)}),this.registerMode("dockerfile",{name:"dockerfile",highlight:(t,n)=>this._highlightDockerfile(t,n)}),this.registerMode("docker",{name:"dockerfile",highlight:(t,n)=>this._highlightDockerfile(t,n)}),this.registerMode("php",{name:"php",highlight:(t,n)=>this._highlightPHP(t,n)}),e.registerCommand("setSyntaxLanguage",t=>{this.setLanguage(t),this.refreshEditorHighlight()})}setTheme(e){this.currentTheme=e}setLanguage(e){this.currentLanguage=e}registerMode(e,t){this.modes.set(e.toLowerCase(),t)}getSyntaxColors(){return this.currentTheme==="dark"?{tag:"#569cd6",comment:"#6a9955",attrName:"#9cdcfe",attrValue:"#ce9178",styleProp:"#c586c0",styleVal:"#dcdcaa",doctype:"#808080",text:"#d4d4d4",keyword:"#c586c0",string:"#ce9178",number:"#b5cea8",variable:"#9cdcfe"}:{tag:"#0000ff",comment:"#008000",attrName:"#001080",attrValue:"#a31515",styleProp:"#6a00a8",styleVal:"#804000",doctype:"#444444",text:"#000000",keyword:"#000080",string:"#a31515",number:"#0086b3",variable:"#001080"}}highlight(e,t){const n=this.getSyntaxColors(),i=this.normalizeLanguageId(t||this.currentLanguage||this.detectLanguage(e)||"html");return(this.modes.get(i)||this.modes.get("html")).highlight(e,n)}highlightHTML(e){return this.highlight(e,"html")}escapeHTML(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\"/g,""").replace(/'/g,"'")}normalizeLanguageId(e){const t=e.trim().toLowerCase().replace(/^\./,"");return{cjs:"javascript",js:"javascript",javascriptreact:"javascript",jsx:"jsx",mjs:"javascript",mts:"typescript",ts:"typescript",tsx:"tsx",typescriptreact:"tsx",md:"markdown",mdx:"markdown",shell:"bash",sh:"bash",zsh:"bash",console:"bash",terminal:"bash",docker:"dockerfile",dockerfile:"dockerfile",golang:"go",py:"python",cxx:"cpp",cc:"cpp","c++":"cpp",cs:"csharp",rs:"rust",rb:"ruby",yml:"yaml",svg:"xml",vue:"vue",ejs:"ejs"}[t]||t||"html"}restoreHighlightTokens(e,t){return e.replace(/\u0000([a-z]+)\u0000/g,(n,i)=>{let o=0;for(let s=0;s<i.length;s++)o=o*26+(i.charCodeAt(s)-97+1);return o=o-1,t[o]||""})}createTokenStore(e){const t=n=>{let i="",o=n;do i=String.fromCharCode(97+o%26)+i,o=Math.floor(o/26)-1;while(o>=0);return i||"a"};return n=>{const i=e.length;return e.push(n),`\0${t(i)}\0`}}refreshEditorHighlight(){const e=this.editor;e!=null&&e.renderTextWithHighlight&&e.renderTextWithHighlight(e.getValue(),!0)}unescapeEntitiesRepeated(e){let t=e||"";for(let n=0;n<5;n++){const i=t;if(t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),t===i)break}return t}detectLanguage(e){const t=e.trim();if(!t)return null;if(/^<\?(?:php\b|=)/i.test(t)||/^\?php\b/i.test(t))return"php";if(/^[\[{]/.test(t)&&/[\]}]$/.test(t)||/"[^"]+"\s*:/.test(t))try{return JSON.parse(t),"json"}catch(h){}const n=/<\/?[A-Za-z][\w:-]*(?:\s|>|\/>)/.test(t),i=/^<!DOCTYPE\s+html\b/i.test(t)||/<\/?(html|head|body|meta|title|style|script)\b/i.test(t);if([/^---\s*\n[\s\S]*?\n---\s*(?:\n|$)/.test(t),/^#{1,6}\s+\S/m.test(t),/^\s*```/m.test(t),/^\s*~~~/m.test(t),/^\s{0,3}>\s+/m.test(t),/^\s{0,3}(?:[-*+]|\d+\.)\s+\S/m.test(t),/^\s{0,3}[-*+]\s+\[[ xX]\]\s+\S/m.test(t),/\[[^\]\n]+\]\([^)]+\)/.test(t),/!\[[^\]\n]*\]\([^)]+\)/.test(t),/(^|\n)\s*\|.+\|\s*\n\s*\|[\s:-]+\|/m.test(t),/(^|\s)(?:\*\*|__)[^*_]+(?:\*\*|__)(?=\s|$|[.,;:!?])/m.test(t)].filter(Boolean).length>=(n?2:1))return"markdown";if(i)return"html";const l=this.detectProgrammingLanguage(t);if(l)return l;const c=/[{][\s\S]*[}]/.test(t)&&/[A-Za-z_-][\w-]*\s*:\s*[^;{}]+;?/.test(t)&&!/\b(function|const|let|var|return|class|interface|type)\b/.test(t);return!n&&c?"css":null}detectProgrammingLanguage(e){const t={php:0,python:0,go:0,cpp:0,c:0,java:0,csharp:0,rust:0,ruby:0,sql:0,yaml:0,dockerfile:0},n=(s,l,c=1)=>{l.test(e)&&(t[s]+=c)};n("python",/^\s*(from\s+\w+\s+import|import\s+\w+|def\s+\w+\s*\(|class\s+\w+|for\s+\w+\s+in\s+.+:|if\s+.+:|while\s+.+:|print\s*\()/m,2),n("python",/^\s*[A-Za-z_]\w*\s*=\s*(?:\[|\{|\(|["']|\d)/m),n("python",/\b(True|False|None|self|elif|lambda|yield)\b/),n("go",/^\s*package\s+\w+/m,3),n("go",/\bfunc\s+\w+\s*\(/,2),n("go",/\b(import|defer|goroutine|chan|struct|interface)\b/),n("cpp",/^\s*#include\s*<[^>]+>/m,2),n("cpp",/\b(std::|template\s*<|namespace\s+\w+|cout\s*<<|cin\s*>>)\b/,2),n("cpp",/\b(class|public|private|protected|virtual|typename)\b/),n("c",/^\s*#include\s*[<"][^>"]+[>"]/m),n("c",/\b(int|char|float|double|void)\s+\w+\s*\(/),n("c",/\bprintf\s*\(/),n("java",/^\s*(package|import)\s+[\w.]+;/m,2),n("java",/\b(public|private|protected)\s+(class|interface|enum)\s+\w+/,2),n("java",/\bSystem\.out\.println\s*\(/),n("csharp",/^\s*using\s+[\w.]+;/m,2),n("csharp",/\b(namespace|record|var|string|Console\.WriteLine)\b/),n("csharp",/\b(public|private|protected)\s+(class|interface|struct)\s+\w+/),n("rust",/\bfn\s+\w+\s*\(/,2),n("rust",/\b(let\s+mut|impl\s+\w+|use\s+[\w:]+|println!\s*\()/),n("rust",/\b(crate|trait|enum|match|Some|None|Ok|Err)\b/),n("ruby",/^\s*(def|class|module)\s+\w+/m,2),n("ruby",/\b(puts|require|attr_reader|elsif|end)\b/),n("sql",/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)\b/im,3),n("sql",/\bFROM\s+\w+|\bWHERE\s+/i),n("yaml",/^---\s*$/m),n("yaml",/^\s*[A-Za-z0-9_.-]+\s*:\s+\S/m,2),n("yaml",/^\s*-\s+[A-Za-z0-9_.-]+\s*:/m),n("dockerfile",/^\s*FROM\s+\S+/im,3),n("dockerfile",/^\s*(RUN|COPY|ADD|CMD|ENTRYPOINT|WORKDIR|ENV|ARG)\b/im,2),n("php",/^<\?(?:php\b|=)/i,3),n("php",/^\?php\b/i,3),n("php",/\$[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*\s*=/,2),n("php",/\b(echo|foreach|function|namespace|use|PHP_EOL)\b/,2);const[i,o]=Object.entries(t).sort((s,l)=>l[1]-s[1])[0]||["",0];return o>=2?i:null}_highlightHTML(e,t){const n=t,i=g=>this.escapeHTML(g),o=[],s=this.createTokenStore(o),l=[],c=g=>{const T=l.length;return l.push(g),`ht${T}`};let h=i(e);h=h.replace(/<\/?(?:(?!>)[^\n\r<])*?(?=$|[\n\r])/g,g=>c(g));const u=[];try{e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(g,T,b)=>(u.push({attrs:String(T||""),inner:String(b||"")}),g))}catch(g){}let p=0;return h=h.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi,(g,T,b,E,v)=>{var U,I,H;const w=(I=(U=u[p++])==null?void 0:U.inner)!=null?I:this.unescapeEntitiesRepeated(E||"");(((H=u[p-1])==null?void 0:H.attrs)||b||"").toLowerCase();const A=this._highlightJS(w,n);return`${T}${A}${v}`}),h=h.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi,(g,T,b,E)=>{const v=this._highlightCSS(this.unescapeEntitiesRepeated(b),n);return`${T}${v}${E}`}),h=h.replace(/(<!--[\s\S]*?-->)/g,g=>s(`<span style="color: ${n.comment};">${g}</span>`)),h=h.replace(/(<!DOCTYPE[\s\S]*?>)/i,g=>s(`<span style="color: ${n.doctype};">${g}</span>`)),h=h.replace(/(<\/?\s*)([^\s&>\/]+)([^<]*?)(\/?>)/g,(g,T,b,E,v)=>{const w=`<span style="color: ${n.tag};">${b}</span>`;let A=E;return A=A.replace(/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g,(U,I,H,W)=>{const Q=String(I).toLowerCase(),me=`<span style="color: ${n.attrName};">${I}</span>`;let D=W,z="";W.startsWith(""")&&W.endsWith(""")?(D=W.slice(6,-6),z="""):W.startsWith("'")&&W.endsWith("'")&&(D=W.slice(5,-5),z="'");let J=W;if(Q==="style"){const _e=D.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(ce,de,ne,Ie)=>`<span style="color: ${n.styleProp};">${de}</span>:<span style="color: ${n.styleVal};">${ne}</span>${Ie}`);z?J=`${z}${_e}${z}`:J=_e,J=`<span style="color: ${n.attrValue};">${J}</span>`}else z&&(J=`${z}${D}${z}`),J=`<span style="color: ${n.attrValue};">${J}</span>`;return`${me}${H}${J}`}),`${T}${w}${A}${v}`}),h=h.replace(/\u0002ht(\d+)\u0002/g,(g,T)=>l[Number(T)]||""),this.restoreHighlightTokens(h,o)}_highlightCSS(e,t){const n=this.unescapeEntitiesRepeated(e),i=[],o=this.createTokenStore(i),s=/(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;let l=0,c="",h;for(;h=s.exec(n);){l<h.index&&(c+=this.escapeHTML(n.slice(l,h.index)));const u=h[0],p=u.startsWith("/*")?t.comment:t.string;c+=o(`<span style="color: ${p};">${this.escapeHTML(u)}</span>`),l=s.lastIndex}return l<n.length&&(c+=this.escapeHTML(n.slice(l))),c=c.replace(/(@[\w-]+)/g,u=>o(`<span style="color: ${t.keyword};">${u}</span>`)),c=c.replace(/([A-Za-z_-][\w-]*)(\s*:)/g,(u,p,g)=>`${o(`<span style="color: ${t.styleProp};">${p}</span>`)}${g}`),c=c.replace(/(#(?:[0-9a-fA-F]{3,8})\b)/g,u=>o(`<span style="color: ${t.number};">${u}</span>`)),c=c.replace(/\b(-?\d*\.?\d+(?:px|em|rem|vh|vw|vmin|vmax|%|s|ms|deg|turn|fr)?)\b/g,u=>o(`<span style="color: ${t.number};">${u}</span>`)),c=c.replace(/\b(important|inherit|initial|unset|revert|auto|none|block|inline|flex|grid|absolute|relative|fixed|sticky)\b/g,u=>o(`<span style="color: ${t.styleVal};">${u}</span>`)),this.restoreHighlightTokens(c,i)}_highlightJSON(e,t){const n=this.unescapeEntitiesRepeated(e),i=/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}\[\],:]/g;let o=0,s="",l;for(;l=i.exec(n);){o<l.index&&(s+=this.escapeHTML(n.slice(o,l.index)));const c=l[0],h=l[1],u=l[2]||"",p=l[3];if(h){const g=u?t.attrName:t.string;s+=`<span style="color: ${g};">${this.escapeHTML(h)}</span>${this.escapeHTML(u)}`}else p?s+=`<span style="color: ${t.keyword};">${c}</span>`:/^-?\d/.test(c)?s+=`<span style="color: ${t.number};">${c}</span>`:s+=`<span style="color: ${t.tag};">${this.escapeHTML(c)}</span>`;o=i.lastIndex}return o<n.length&&(s+=this.escapeHTML(n.slice(o))),s}_highlightMarkdown(e,t){var h;const i=this.unescapeEntitiesRepeated(e).split(`
|
|
246
|
-
`);let o=!1,s="",l="",c=((
|
|
247
|
-
`)}extractMarkdownFenceLanguage(e){var n;const t=((n=e.trim().match(/^([A-Za-z0-9_+.#-]+)/))==null?void 0:n[1])||"";return t?this.normalizeLanguageId(t):""}highlightMarkdownFenceLine(e,t,n){const i=t?this.modes.get(t):void 0;return!i||i.name==="markdown"?`<span style="color: ${n.text};">${this.escapeHTML(e)}</span>`:i.highlight(e,n)}_highlightShell(e,t){const n=this.unescapeEntitiesRepeated(e),i=[],o=this.createTokenStore(i),s=/(#[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|(\$\{?[A-Za-z_][\w]*\}?|\$[0-9@#?$*!])/g;let l=0,c="",
|
|
248
|
-
`).map(i=>{const o=this.escapeHTML(i);return/^\s*#/.test(i)?`<span style="color: ${t.comment};">${o}</span>`:o.replace(/^(\s*)(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)(\b)/i,(s,l,c,
|
|
249
|
-
`)}_highlightJS(e,t){const n=this.unescapeEntitiesRepeated(e);this.escapeHTML(n);const i=[],o=
|
|
250
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Za(r,e){return Ga(r)||qa(r,e)||Xa(r,e)||Ya()}function Xa(r,e){if(r){if(typeof r=="string")return Ko(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ko(r,e):void 0}}const Go=Object.entries,qo=Object.setPrototypeOf,Qa=Object.isFrozen,Ja=Object.getPrototypeOf,el=Object.getOwnPropertyDescriptor;let X=Object.freeze,te=Object.seal,kt=Object.create,Yo=typeof Reflect!="undefined"&&Reflect,li=Yo.apply,ci=Yo.construct;X||(X=function(e){return e}),te||(te=function(e){return e}),li||(li=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),ci||(ci=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const st=Y(Array.prototype.forEach),tl=Y(Array.prototype.lastIndexOf),Zo=Y(Array.prototype.pop),Bt=Y(Array.prototype.push),nl=Y(Array.prototype.splice),Mt=Array.isArray,Ut=Y(String.prototype.toLowerCase),di=Y(String.prototype.toString),Xo=Y(String.prototype.match),Wt=Y(String.prototype.replace),Qo=Y(String.prototype.indexOf),il=Y(String.prototype.trim),ol=Y(Number.prototype.toString),rl=Y(Boolean.prototype.toString),Jo=typeof BigInt=="undefined"?null:Y(BigInt.prototype.toString),er=typeof Symbol=="undefined"?null:Y(Symbol.prototype.toString),ge=Y(Object.prototype.hasOwnProperty),jt=Y(Object.prototype.toString),le=Y(RegExp.prototype.test),nt=sl(TypeError);function Y(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return li(r,e,n)}}function sl(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ci(r,t)}}function P(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ut;if(qo&&qo(r,null),!Mt(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(Qa(e)||(e[n]=o),i=o)}r[i]=!0}return r}function al(r){for(let e=0;e<r.length;e++)ge(r,e)||(r[e]=null);return r}function Te(r){const e=kt(null);for(const n of Go(r)){var t=Za(n,2);const i=t[0],o=t[1];ge(r,i)&&(Mt(o)?e[i]=al(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Te(o):e[i]=o)}return e}function ll(r){switch(typeof r){case"string":return r;case"number":return ol(r);case"boolean":return rl(r);case"bigint":return Jo?Jo(r):"0";case"symbol":return er?er(r):"Symbol()";case"undefined":return jt(r);case"function":case"object":{if(r===null)return jt(r);const e=r,t=Oe(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:jt(n)}return jt(r)}default:return jt(r)}}function Oe(r,e){for(;r!==null;){const n=el(r,e);if(n){if(n.get)return Y(n.get);if(typeof n.value=="function")return Y(n.value)}r=Ja(r)}function t(){return null}return t}function cl(r){try{return le(r,""),!0}catch(e){return!1}}const tr=X(["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"]),hi=X(["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"]),ui=X(["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"]),dl=X(["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"]),fi=X(["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"]),hl=X(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),nr=X(["#text"]),ir=X(["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"]),pi=X(["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"]),or=X(["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"]),Dn=X(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ul=te(/{{[\w\W]*|^[\w\W]*}}/g),fl=te(/<%[\w\W]*|^[\w\W]*%>/g),pl=te(/\${[\w\W]*/g),gl=te(/^data-[\-\w.\u00B7-\uFFFF]+$/),ml=te(/^aria-[\-\w]+$/),rr=te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),bl=te(/^(?:\w+script|data):/i),yl=te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Tl=te(/^html$/i),El=te(/^[a-z][.\w]*(-[.\w]+)+$/i),sr=te(/<[/\w!]/g),ar=te(/<[/\w]/g),vl=te(/<\/no(script|embed|frames)/i),Sl=te(/\/>/i),Ee={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},lr=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],wl=X(P({},lr)),xl=(function(){const r={};return st(lr,e=>{r[e]=te(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),X(r)})(),Cl=function(){return typeof window=="undefined"?null:window},Al=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},cr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},it=function(e,t,n,i){return ge(e,t)&&Mt(e[t])?P(i.base?Te(i.base):{},e[t],i.transform):n},gi=function(e,t,n){const i=ge(e,t)?e[t]:void 0;return i&&typeof i=="object"?Te(i):n()};function dr(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Cl();const e=m=>dr(m);if(e.version="3.4.16",e.removed=[],!r||!r.document||r.document.nodeType!==Ee.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,l=r.Element,c=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const h=r.DOMParser,u=r.trustedTypes,p=l.prototype,g=Oe(p,"cloneNode"),T=Oe(p,"remove"),b=Oe(p,"removeAttributeNode"),E=Oe(p,"nextSibling"),v=Oe(p,"childNodes"),w=Oe(p,"parentNode"),A=Oe(p,"shadowRoot"),U=Oe(p,"attributes"),I=s&&s.prototype?Oe(s.prototype,"nodeType"):null,H=s&&s.prototype?Oe(s.prototype,"nodeName"):null,W=s&&s.prototype?Oe(s.prototype,"ownerDocument"):null,Q=function(a){return I?I(a):a.nodeType},me=function(a){return H?H(a):a.nodeName};if(typeof o=="function"){const m=t.createElement("template");m.content&&m.content.ownerDocument&&(t=m.content.ownerDocument)}let D,z="",J,_e=!1,ce=0;const de=function(){if(ce>0)throw nt('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.')},ne=function(a){de(),ce++;try{return D.createHTML(a)}finally{ce--}},Ie=function(a){de(),ce++;try{return D.createScriptURL(a)}finally{ce--}},qt=function(){return _e||(J=Al(u,i),_e=!0),J},De=t,ze=De.implementation,at=De.createNodeIterator,Yt=De.createDocumentFragment,F=De.getElementsByTagName,$e=n.importNode;let k=cr();e.isSupported=typeof Go=="function"&&typeof w=="function"&&ze&&ze.createHTMLDocument!==void 0;const Rt=ul,Mi=fl,Li=pl,Ri=gl,Oi=ml,_i=bl,Zt=yl,Ii=El;let Xt=rr,M=null;const lt=P({},[...tr,...hi,...ui,...fi,...nr]);let L=null;const ct=P({},[...ir,...pi,...or,...Dn]);let V=Object.seal(kt(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}})),Ne=null,Qt=null;const oe=Object.seal(kt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Jt=!0,dt=!0,en=!1,tn=!0,re=!1,he=!0,ue=!1,ht=!1,Be=null,Ue=null,ut=!1,Se=!1,We=!1,je=!1,nn=!0,on=!1;const rn="user-content-";let ft=!0,pt=!1,we={},xe=null;const sn=P({},["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 an=null;const ln=P({},["audio","video","img","source","image","track"]);let cn=null;const dn=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Ke="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let Ce=K,gt=!1,mt=null;const Di=P({},[Ve,Ke,K],di),hn=X(["mi","mo","mn","ms","mtext"]);let bt=P({},hn);const un=X(["annotation-xml"]);let yt=P({},un);const Ni=P({},["title","style","font","a","script"]);let Pe=null;const Pi=["application/xhtml+xml","text/html"],Hi="text/html";let O=null,Ae=null;const Fi=t.createElement("form"),fn=function(a){return a instanceof RegExp||a instanceof Function},Tt=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ae&&Ae===a)return;(!a||typeof a!="object")&&(a={}),a=Te(a),Pe=Pi.indexOf(a.PARSER_MEDIA_TYPE)===-1?Hi:a.PARSER_MEDIA_TYPE,O=Pe==="application/xhtml+xml"?di:Ut,M=it(a,"ALLOWED_TAGS",lt,{transform:O}),L=it(a,"ALLOWED_ATTR",ct,{transform:O}),mt=it(a,"ALLOWED_NAMESPACES",Di,{transform:di}),cn=it(a,"ADD_URI_SAFE_ATTR",dn,{transform:O,base:dn}),an=it(a,"ADD_DATA_URI_TAGS",ln,{transform:O,base:ln}),xe=it(a,"FORBID_CONTENTS",sn,{transform:O}),Ne=it(a,"FORBID_TAGS",Te({}),{transform:O}),Qt=it(a,"FORBID_ATTR",Te({}),{transform:O}),we=ge(a,"USE_PROFILES")?a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?Te(a.USE_PROFILES):a.USE_PROFILES:!1,Jt=a.ALLOW_ARIA_ATTR!==!1,dt=a.ALLOW_DATA_ATTR!==!1,en=a.ALLOW_UNKNOWN_PROTOCOLS||!1,tn=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=a.SAFE_FOR_TEMPLATES||!1,he=a.SAFE_FOR_XML!==!1,ue=a.WHOLE_DOCUMENT||!1,Se=a.RETURN_DOM||!1,We=a.RETURN_DOM_FRAGMENT||!1,je=a.RETURN_TRUSTED_TYPE||!1,ut=a.FORCE_BODY||!1,nn=a.SANITIZE_DOM!==!1,on=a.SANITIZE_NAMED_PROPS||!1,ft=a.KEEP_CONTENT!==!1,pt=a.IN_PLACE||!1,Xt=cl(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:rr,Ce=typeof a.NAMESPACE=="string"?a.NAMESPACE:K,bt=gi(a,"MATHML_TEXT_INTEGRATION_POINTS",()=>P({},hn)),yt=gi(a,"HTML_INTEGRATION_POINTS",()=>P({},un));const d=gi(a,"CUSTOM_ELEMENT_HANDLING",()=>kt(null));if(V=kt(null),ge(d,"tagNameCheck")&&fn(d.tagNameCheck)&&(V.tagNameCheck=d.tagNameCheck),ge(d,"attributeNameCheck")&&fn(d.attributeNameCheck)&&(V.attributeNameCheck=d.attributeNameCheck),ge(d,"allowCustomizedBuiltInElements")&&typeof d.allowCustomizedBuiltInElements=="boolean"&&(V.allowCustomizedBuiltInElements=d.allowCustomizedBuiltInElements),te(V),re&&(dt=!1),We&&(Se=!0),we&&(M=P({},nr),L=kt(null),we.html===!0&&(P(M,tr),P(L,ir)),we.svg===!0&&(P(M,hi),P(L,pi),P(L,Dn)),we.svgFilters===!0&&(P(M,ui),P(L,pi),P(L,Dn)),we.mathMl===!0&&(P(M,fi),P(L,or),P(L,Dn))),oe.tagCheck=null,oe.attributeCheck=null,ge(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?oe.tagCheck=a.ADD_TAGS:Mt(a.ADD_TAGS)&&(M===lt&&(M=Te(M)),P(M,a.ADD_TAGS,O))),ge(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?oe.attributeCheck=a.ADD_ATTR:Mt(a.ADD_ATTR)&&(L===ct&&(L=Te(L)),P(L,a.ADD_ATTR,O))),ge(a,"ADD_FORBID_CONTENTS")&&Mt(a.ADD_FORBID_CONTENTS)&&(xe===sn&&(xe=Te(xe)),P(xe,a.ADD_FORBID_CONTENTS,O)),ft&&(M["#text"]=!0),ue&&P(M,["html","head","body"]),M.table&&(P(M,["tbody"]),delete Ne.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=D;D=a.TRUSTED_TYPES_POLICY;try{z=ne("")}catch(y){throw D=f,y}}else a.TRUSTED_TYPES_POLICY===null?(D=void 0,z=""):(D===void 0&&(D=qt()),D&&typeof z=="string"&&(z=ne("")));X&&X(a),Ae=a},pn=P({},[...hi,...ui,...dl]),gn=P({},[...fi,...hl]),$i=function(a,d,f){return d.namespaceURI===K?a==="svg":d.namespaceURI===Ve?a==="svg"&&(f==="annotation-xml"||bt[f]):!!pn[a]},zi=function(a,d,f){return d.namespaceURI===K?a==="math":d.namespaceURI===Ke?a==="math"&&yt[f]:!!gn[a]},Bi=function(a,d,f){return d.namespaceURI===Ke&&!yt[f]||d.namespaceURI===Ve&&!bt[f]?!1:!gn[a]&&(Ni[a]||!pn[a])},Ui=function(a){let d=w(a);(!d||!d.tagName)&&(d={namespaceURI:Ce,tagName:"template"});const f=Ut(a.tagName),y=Ut(d.tagName);return mt[a.namespaceURI]?a.namespaceURI===Ke?$i(f,d,y):a.namespaceURI===Ve?zi(f,d,y):a.namespaceURI===K?Bi(f,d,y):!!(Pe==="application/xhtml+xml"&&mt[a.namespaceURI]):!1},se=function(a){Bt(e.removed,{element:a});try{w(a).removeChild(a)}catch(d){if(T(a),!w(a))throw nt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},mn=function(a,d,f){try{b(a,d)}catch(y){try{a.removeAttribute(f)}catch(S){}}},Ge=function(a){qe(a);const d=v(a);if(d){const y=[];st(d,S=>{Bt(y,S)}),st(y,S=>{try{T(S)}catch(x){}})}const f=U(a);if(f)for(let y=f.length-1;y>=0;--y){const S=f[y],x=S&&S.name;typeof x=="string"&&mn(a,S,x)}},fe=function(a,d,f){if(!f)try{f=d.getAttributeNode(a)}catch(y){f=null}Bt(e.removed,{attribute:f||null,from:d});try{f?b(d,f):d.removeAttribute(a)}catch(y){try{d.removeAttribute(a)}catch(S){}}if(a==="is")if(Se||We)try{se(d)}catch(y){}else try{d.setAttribute(a,"")}catch(y){}},Wi=function(a){const d=U(a);if(d)for(let f=d.length-1;f>=0;--f){const y=d[f],S=y&&y.name;typeof S!="string"||L[O(S)]||mn(a,y,S)}},qe=function(a){const d=[a];for(;d.length>0;){const f=d.pop();Q(f)===Ee.element&&Wi(f);const y=v(f);if(y)for(let S=y.length-1;S>=0;--S)d.push(y[S])}},bn=function(a,d){return he?a==="patchsrc"?!0:a==="for"&&d!=="label"&&d!=="output":!1},ji=function(a){if(!he)return;const d=[a];for(;d.length>0;){const f=d.pop(),y=Q(f);if(y===Ee.processingInstruction||y===Ee.comment&&le(ar,f.data)){try{T(f)}catch(x){}continue}if(y===Ee.element){const x=f,C=O(me(f));try{x.hasAttribute&&x.hasAttribute("patchsrc")&&x.removeAttribute("patchsrc"),x.hasAttribute&&x.hasAttribute("for")&&bn("for",C)&&x.removeAttribute("for")}catch(R){}}const S=v(f);if(S)for(let x=S.length-1;x>=0;--x)d.push(S[x])}},yn=function(a){let d=null,f=null;if(ut)a="<remove></remove>"+a;else{const x=Xo(a,/^[\r\n\t ]+/);f=x&&x[0]}Pe==="application/xhtml+xml"&&Ce===K&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const y=D?ne(a):a;if(Ce===K)try{d=new h().parseFromString(y,Pe)}catch(x){}if(!d||!d.documentElement){d=ze.createDocument(Ce,"template",null);try{d.documentElement.innerHTML=gt?z:y}catch(x){}}const S=d.body||d.documentElement;return a&&f&&S.insertBefore(t.createTextNode(f),S.childNodes[0]||null),Ce===K?F.call(d,ue?"html":"body")[0]:ue?d.documentElement:S},Tn=function(a){const d=W?W(a):a.ownerDocument;return at.call(d||a,a,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ye=function(a){return a=Wt(a,Rt," "),a=Wt(a,Mi," "),a=Wt(a,Li," "),a},Et=function(a){var d;a.normalize();const f=W?W(a):a.ownerDocument,y=at.call(f||a,a,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let S=y.nextNode();for(;S;)S.data=Ye(S.data),S=y.nextNode();const x=(d=a.querySelectorAll)===null||d===void 0?void 0:d.call(a,"template");x&&st(x,C=>{ke(C.content)&&Et(C.content)})},Ze=function(a){const d=H?H(a):null;return typeof d!="string"||O(d)!=="form"?!1:typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||a.attributes!==U(a)||typeof a.removeAttribute!="function"||typeof a.removeAttributeNode!="function"||typeof a.getAttributeNode!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function"||a.nodeType!==I(a)||a.childNodes!==v(a)},ke=function(a){if(!I||typeof a!="object"||a===null)return!1;try{return I(a)===Ee.documentFragment}catch(d){return!1}},He=function(a){if(!I||typeof a!="object"||a===null)return!1;try{return typeof I(a)=="number"}catch(d){return!1}};function G(m,a,d){m.length!==0&&st(m,f=>{f.call(e,a,d,Ae)})}const Vi=function(a,d){return!!(he&&a.hasChildNodes()&&!He(a.firstElementChild)&&le(sr,a.textContent)&&le(sr,a.innerHTML)||he&&a.namespaceURI===K&&wl[d]&&(He(a.firstElementChild)||typeof a.textContent=="string"&&le(xl[d],a.textContent))||a.nodeType===Ee.processingInstruction||he&&a.nodeType===Ee.comment&&le(ar,a.data))},Xe=function(a,d){if(a instanceof RegExp)return le(a,d);if(a instanceof Function){for(var f=arguments.length,y=new Array(f>2?f-2:0),S=2;S<f;S++)y[S-2]=arguments[S];return!!a(d,...y)}return!1},Ki=function(a,d,f){if(!Ne[d]&&wn(d)&&Xe(V.tagNameCheck,d))return!1;if(ft&&!xe[d]){const y=w(a),S=v(a);if(S&&y){const x=S.length;for(let C=x-1;C>=0;--C){const R=a===f?g(S[C],!0):S[C];y.insertBefore(R,E(a))}}}return se(a),!0},En=function(a,d,f,y){return a.length===0?d:d===f||d===y?Te(d):d},Me=function(a,d){return a===d||w(a)!==null?!1:(pt&&qe(a),!0)},vn=function(a,d){if(G(k.beforeSanitizeElements,a,null),Me(a,d))return!0;if(Ze(a))return se(a),!0;const f=O(me(a));if(M=En(k.uponSanitizeElement,M,lt,Be),G(k.uponSanitizeElement,a,{tagName:f,allowedTags:M}),Me(a,d))return!0;if(Vi(a,f))return se(a),!0;if(Ne[f]||!(oe.tagCheck instanceof Function&&oe.tagCheck(f))&&!M[f]){const y=Ki(a,f,d);return y===!1&&(G(k.afterSanitizeElements,a,null),Me(a,d))?!0:y}if(Q(a)===Ee.element&&!Ui(a)||(f==="noscript"||f==="noembed"||f==="noframes")&&le(vl,a.innerHTML))return se(a),!0;if(re&&a.nodeType===Ee.text){const y=Ye(a.textContent);a.textContent!==y&&(Bt(e.removed,{element:a.cloneNode()}),a.textContent=y)}return G(k.afterSanitizeElements,a,null),Me(a,d)},Sn=function(a,d,f){if(Qt[d]||bn(d,a)||nn&&(d==="id"||d==="name")&&(f in t||f in Fi))return!1;const y=L[d]||oe.attributeCheck instanceof Function&&oe.attributeCheck(d,a);return dt&&le(Ri,d)||Jt&&le(Oi,d)?!0:y?cn[d]||le(Xt,Wt(f,Zt,""))||(d==="src"||d==="xlink:href"||d==="href")&&a!=="script"&&Qo(f,"data:")===0&&an[a]||en&&!le(_i,Wt(f,Zt,""))?!0:!f:wn(a)&&Xe(V.tagNameCheck,a)&&Xe(V.attributeNameCheck,d,a)||d==="is"&&V.allowCustomizedBuiltInElements&&Xe(V.tagNameCheck,f)},Gi=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),wn=function(a){return!Gi[Ut(a)]&&le(Ii,a)},qi=function(a,d,f,y){if(D&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!f)switch(u.getAttributeType(a,d)){case"TrustedHTML":return ne(y);case"TrustedScriptURL":return Ie(y)}return y},Yi=function(a,d,f,y){try{return f?a.setAttributeNS(f,d,y):a.setAttribute(d,y),Ze(a)?(se(a),!1):!0}catch(S){return fe(d,a),!1}},xn=function(a,d){if(G(k.beforeSanitizeAttributes,a,null),Me(a,d))return;const f=a.attributes;if(!f||Ze(a))return;L=En(k.uponSanitizeAttribute,L,ct,Ue);const y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0};let S=f.length;const x=O(a.nodeName);for(;S--;){const C=f[S],R=C.name,j=C.namespaceURI,B=C.value,Le=O(R),St=B;let $=R==="value"?St:il(St),Cn=!1;if(y.attrName=Le,y.attrValue=$,y.keepAttr=!0,y.forceKeepAttr=void 0,G(k.uponSanitizeAttribute,a,y),$=y.attrValue,on&&(Le==="id"||Le==="name")&&Qo($,rn)!==0&&(fe(R,a,C),$=rn+$,Cn=!0),he&&le(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$)){fe(R,a,C);continue}if(Le==="attributename"&&Xo($,"href")){fe(R,a,C);continue}if(!y.forceKeepAttr){if(!y.keepAttr){fe(R,a,C);continue}if(!tn&&le(Sl,$)){fe(R,a,C);continue}if(re&&($=Ye($)),!Sn(x,Le,$)){fe(R,a,C);continue}$=qi(x,Le,j,$),$!==St&&Yi(a,R,j,$)&&Cn&&Zo(e.removed)}}G(k.afterSanitizeAttributes,a,null),Me(a,d)},Qe=function(a){let d=null;const f=Tn(a);for(G(k.beforeSanitizeShadowDOM,a,null);d=f.nextNode();)if(G(k.uponSanitizeShadowNode,d,null),vn(d,a),xn(d,a),ke(d.content)&&Qe(d.content),Q(d)===Ee.element){const y=A(d);ke(y)&&(vt(y),Qe(y))}G(k.afterSanitizeShadowDOM,a,null)},vt=function(a){const d=[{node:a,shadow:null}];for(;d.length>0;){const f=d.pop();if(f.shadow){Qe(f.shadow);continue}const y=f.node,S=Q(y)===Ee.element,x=v(y);if(x)for(let C=x.length-1;C>=0;--C)d.push({node:x[C],shadow:null});if(S){const C=H?H(y):null;if(typeof C=="string"&&O(C)==="template"){const R=y.content;ke(R)&&d.push({node:R,shadow:null})}}if(S){const C=A(y);ke(C)&&d.push({node:null,shadow:C},{node:C,shadow:null})}}};return e.sanitize=function(m){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=null,f=null,y=null,S=null;if(gt=!m,gt&&(m="<!-->"),typeof m!="string"&&!He(m)&&(m=ll(m),typeof m!="string"))throw nt("dirty is not a string, aborting");if(!e.isSupported)return m;ht?(M=Be,L=Ue):Tt(a),(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&(M=Te(M)),k.uponSanitizeAttribute.length>0&&(L=Te(L)),e.removed=[];const x=pt&&typeof m!="string"&&He(m);if(x){ji(m);const j=me(m);if(typeof j=="string"){const B=O(j);if(!M[B]||Ne[B])throw Ge(m),nt("root node is forbidden and cannot be sanitized in-place")}if(Ze(m))throw Ge(m),nt("root node is clobbered and cannot be sanitized in-place");try{vt(m)}catch(B){throw Ge(m),B}}else if(He(m))d=yn("<!---->"),f=d.ownerDocument.importNode(m,!0),f.nodeType===Ee.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?d=f:d.appendChild(f),vt(d);else{if(!Se&&!re&&!ue&&m.indexOf("<")===-1)return D&&je?ne(m):m;if(d=yn(m),!d)return Se?null:je?z:""}d&&ut&&se(d.firstChild);const C=x?m:d;try{const j=Tn(C);for(;y=j.nextNode();)vn(y,C),xn(y,C),ke(y.content)&&Qe(y.content)}catch(j){throw x&&(Ge(m),st(e.removed,B=>{B.element&&qe(B.element)})),j}if(x){let j=!1;if(st(e.removed,B=>{B.element&&(B.element===m&&(j=!0),qe(B.element))}),j)throw nt("a node selected for removal could not be safely returned; refusing to sanitize in place");return re&&Et(m),m}if(Se){if(re&&Et(d),We)for(S=Yt.call(d.ownerDocument);d.firstChild;)S.appendChild(d.firstChild);else S=d;return(L.shadowroot||L.shadowrootmode)&&(S=$e.call(n,S,!0)),S}let R=ue?d.outerHTML:d.innerHTML;return ue&&M["!doctype"]&&d.ownerDocument&&d.ownerDocument.doctype&&d.ownerDocument.doctype.name&&le(Tl,d.ownerDocument.doctype.name)&&(R="<!DOCTYPE "+d.ownerDocument.doctype.name+`>
|
|
251
|
-
`+
|
|
317
|
+
`,s.textContent=o.text,i.appendChild(s)}t.replaceChildren(i),t.__lceFoldPlaceholderSources=n,this.editor.getView().syncTrailingNewlineMarkerForText(e.text)}getFoldPlaceholder(e){const t=Math.max(1,e.end.line-e.start.line);return` … ${t} ${t===1?"line":"lines"} … `}pruneInvalidFolds(e,t){if(!this.editor)return;const n=this.editor.getFolds().filter(d=>d.collapsed!==!1),i=new Set(n.map(d=>this.getFoldKey(d))),o=[],s=new Set,l=this.getLineInfo(e);for(const d of n){const u=this.findReplacementFold(d,t.get(this.getFoldKey(d)),s,e,l);if(!u)continue;const f=this.getFoldKey(u);o.push(u),s.add(f)}const c=new Set(o.map(d=>this.getFoldKey(d)));for(const d of n)c.has(this.getFoldKey(d))||this.editor.unfold(d);for(const d of o)i.has(this.getFoldKey(d))||this.editor.fold(d)}getActiveFolds(){return this.editor?this.editor.getFolds().filter(e=>e.collapsed!==!1):[]}hasActiveFolds(){return this.getActiveFolds().length>0}getRenderableActiveFolds(){return this.getTopLevelFoldRegions(this.getActiveFolds())}getTopLevelFoldRegions(e){const t=[...e].sort((i,o)=>this.comparePositions(i.start,o.start)),n=[];for(const i of t){const o=n[n.length-1];o&&this.containsRange(o,i)||n.push(i)}return n}toDisplayLine(e,t){let n=0;for(const i of t){if(this.isSameRange(i,e))break;if(this.containsRange(i,e))return null;i.end.line<=e.start.line&&(n+=i.end.line-i.start.line)}return e.start.line-n}findBestRegionForLine(e,t){const i=(t?this.getActiveFolds():this.foldRegions).filter(o=>o.start.line<=e&&o.end.line>=e);return i.length===0?null:(i.sort((o,s)=>{const l=o.end.line-o.start.line,c=s.end.line-s.start.line;return l!==c?l-c:this.comparePositions(o.start,s.start)}),i[0])}findReplacementFold(e,t,n,i,o){const s=this.getFoldKey(e),l=this.foldRegions.find(m=>this.getFoldKey(m)===s&&!n.has(s));if(l)return l;const c=e.end.line-e.start.line,d=t!=null?t:this.createFoldSnapshot(e,i,o),f=this.foldRegions.filter(m=>!n.has(this.getFoldKey(m))).map(m=>{const E=this.createFoldSnapshot(m,i,o),v=d&&(E==null?void 0:E.startLineText)===d.startLineText?1:0,w=d&&(E==null?void 0:E.endLineText)===d.endLineText?1:0,A=d&&(E==null?void 0:E.lineSpan)===d.lineSpan?1:0;return{region:m,overlaps:this.lineRangeOverlap(e,m),lineDistance:Math.abs(m.start.line-e.start.line)+Math.abs(m.end.line-e.end.line),spanDistance:Math.abs(m.end.line-m.start.line-c),columnDistance:Math.abs(m.start.column-e.start.column)+Math.abs(m.end.column-e.end.column),hiddenTextMatch:d&&(E==null?void 0:E.hiddenText)===d.hiddenText?1:0,boundaryMatchScore:v+w+A}}).sort((m,E)=>m.hiddenTextMatch!==E.hiddenTextMatch?E.hiddenTextMatch-m.hiddenTextMatch:m.boundaryMatchScore!==E.boundaryMatchScore?E.boundaryMatchScore-m.boundaryMatchScore:m.overlaps!==E.overlaps?E.overlaps-m.overlaps:m.lineDistance!==E.lineDistance?m.lineDistance-E.lineDistance:m.spanDistance!==E.spanDistance?m.spanDistance-E.spanDistance:m.columnDistance-E.columnDistance)[0];if(!f)return null;const p=f.lineDistance<=2&&f.spanDistance<=1;return!(f.hiddenTextMatch===1||f.boundaryMatchScore>=2)&&!p?null:f.region}lineRangeOverlap(e,t){const n=Math.max(e.start.line,t.start.line),i=Math.min(e.end.line,t.end.line);return Math.max(0,i-n)}rememberActiveFoldSnapshots(e){const t=new Map,n=this.getLineInfo(e);for(const i of this.getActiveFolds()){const o=this.createFoldSnapshot(i,e,n);o&&t.set(this.getFoldKey(i),o)}this.foldSnapshots=t}createFoldSnapshot(e,t,n=this.getLineInfo(t)){var u,f;const{lineStarts:i,lines:o}=n;if(o.length===0)return null;const s=this.positionToOffset(e.start,i,o),l=this.positionToOffset(e.end,i,o),c=Math.max(0,Math.min(e.start.line,o.length-1)),d=Math.max(0,Math.min(e.end.line,o.length-1));return{hiddenText:t.slice(s,l),startLineText:(u=o[c])!=null?u:"",endLineText:(f=o[d])!=null?f:"",lineSpan:e.end.line-e.start.line}}withPreservedSelection(e){var c,d;if(!this.editor){e();return}const t=this.editor.getView(),n=t.getContentElement(),i=document.activeElement===n,o=t.getSelectionOffsets(),s=o.isInEditor;if(e(),!s)return;const l=this.remapSelectionOffsetsForVisibleDisplay((c=o.anchorOffset)!=null?c:o.startOffset,(d=o.focusOffset)!=null?d:o.endOffset);t.setSelectionBoundaryOffsets(l.startOffset,l.endOffset),(i||o.isInEditor)&&this.editor.focus()}remapSelectionOffsetsForVisibleDisplay(e,t){if(!this.editor)return{startOffset:e,endOffset:t};const n=this.editor.getValue(),{lineStarts:i,lines:o}=this.getLineInfo(n),s=this.getRenderableActiveFolds();if(s.length===0){const l=n.length;return{startOffset:Math.max(0,Math.min(e,l)),endOffset:Math.max(0,Math.min(t,l))}}return{startOffset:this.remapOffsetToVisibleBoundary(e,s,i,o,n.length),endOffset:this.remapOffsetToVisibleBoundary(t,s,i,o,n.length)}}remapOffsetToVisibleBoundary(e,t,n,i,o){const s=Math.max(0,Math.min(e,o));for(const l of t){const c=this.positionToOffset(l.start,n,i),d=this.positionToOffset(l.end,n,i);if(s<=c||s>=d)continue;const u=s-c,f=d-s;return u<=f?c:d}return s}buildLineStarts(e){const t=e.split(`
|
|
318
|
+
`),n=new Array(t.length);let i=0;for(let o=0;o<t.length;o++)n[o]=i,i+=t[o].length+1;return{lineStarts:n,lines:t}}getLineInfo(e){var n;if(((n=this.cachedLineInfo)==null?void 0:n.text)===e)return this.cachedLineInfo;const t={text:e,...this.buildLineStarts(e)};return this.cachedLineInfo=t,t}offsetToLine(e,t,n){var c;const i=t.length>0?t[t.length-1]+(((c=n[n.length-1])==null?void 0:c.length)||0):0,o=Math.max(0,Math.min(e,i));let s=0,l=t.length-1;for(;s<=l;){const d=Math.floor((s+l)/2),u=t[d],f=d+1<t.length?t[d+1]:Number.POSITIVE_INFINITY;if(o<u){l=d-1;continue}if(o>=f){s=d+1;continue}return d}return Math.max(0,Math.min(s,t.length-1))}positionToOffset(e,t,n){var s;const i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((s=n[i])==null?void 0:s.length)||0));return t[i]+o}comparePositions(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}containsRange(e,t){return this.comparePositions(e.start,t.start)<=0&&this.comparePositions(e.end,t.end)>=0&&!this.isSameRange(e,t)}isSameRange(e,t){return e.start.line===t.start.line&&e.start.column===t.start.column&&e.end.line===t.end.line&&e.end.column===t.end.column}isFoldActive(e){return this.getActiveFolds().some(t=>this.isSameRange(t,e))}isValidFoldRegion(e){return e.start.line<e.end.line&&(e.start.line!==e.end.line||e.start.column!==e.end.column)}getFoldKey(e){return`${e.start.line}:${e.start.column}-${e.end.line}:${e.end.column}`}destroy(){this.pendingUpdateRaf!==null&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),this.foldingUI&&this.foldingUI.parentNode&&this.foldingUI.parentNode.removeChild(this.foldingUI),this.restoreFullDisplay(),this.changeHandler=null,this.lastSnapshot="",this.lastParsedText=null,this.foldingUI=null,this.foldRegions=[],this.cachedLineInfo=null,this.editor=null}}class El{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(e){this.editor=e,this.registerMode("html",{name:"html",highlight:(t,n)=>this._highlightHTML(t,n)}),this.registerMode("css",{name:"css",highlight:(t,n)=>this._highlightCSS(t,n)}),this.registerMode("javascript",{name:"javascript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("js",{name:"javascript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("jsx",{name:"jsx",highlight:(t,n)=>this._highlightJSX(t,n)}),this.registerMode("typescript",{name:"typescript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("ts",{name:"typescript",highlight:(t,n)=>this._highlightJS(t,n)}),this.registerMode("tsx",{name:"tsx",highlight:(t,n)=>this._highlightJSX(t,n)}),this.registerMode("json",{name:"json",highlight:(t,n)=>this._highlightJSON(t,n)}),this.registerMode("markdown",{name:"markdown",highlight:(t,n)=>this._highlightMarkdown(t,n)}),this.registerMode("md",{name:"markdown",highlight:(t,n)=>this._highlightMarkdown(t,n)}),this.registerMode("bash",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("shell",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("sh",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("zsh",{name:"bash",highlight:(t,n)=>this._highlightShell(t,n)}),this.registerMode("python",{name:"python",highlight:(t,n)=>this._highlightGenericCode(t,n,"python")}),this.registerMode("py",{name:"python",highlight:(t,n)=>this._highlightGenericCode(t,n,"python")}),this.registerMode("go",{name:"go",highlight:(t,n)=>this._highlightGenericCode(t,n,"go")}),this.registerMode("golang",{name:"go",highlight:(t,n)=>this._highlightGenericCode(t,n,"go")}),this.registerMode("c",{name:"c",highlight:(t,n)=>this._highlightGenericCode(t,n,"c")}),this.registerMode("cpp",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("c++",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("cc",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("cxx",{name:"cpp",highlight:(t,n)=>this._highlightGenericCode(t,n,"cpp")}),this.registerMode("java",{name:"java",highlight:(t,n)=>this._highlightGenericCode(t,n,"java")}),this.registerMode("csharp",{name:"csharp",highlight:(t,n)=>this._highlightGenericCode(t,n,"csharp")}),this.registerMode("cs",{name:"csharp",highlight:(t,n)=>this._highlightGenericCode(t,n,"csharp")}),this.registerMode("rust",{name:"rust",highlight:(t,n)=>this._highlightGenericCode(t,n,"rust")}),this.registerMode("rs",{name:"rust",highlight:(t,n)=>this._highlightGenericCode(t,n,"rust")}),this.registerMode("ruby",{name:"ruby",highlight:(t,n)=>this._highlightGenericCode(t,n,"ruby")}),this.registerMode("rb",{name:"ruby",highlight:(t,n)=>this._highlightGenericCode(t,n,"ruby")}),this.registerMode("sql",{name:"sql",highlight:(t,n)=>this._highlightGenericCode(t,n,"sql")}),this.registerMode("yaml",{name:"yaml",highlight:(t,n)=>this._highlightYAML(t,n)}),this.registerMode("yml",{name:"yaml",highlight:(t,n)=>this._highlightYAML(t,n)}),this.registerMode("xml",{name:"xml",highlight:(t,n)=>this._highlightXML(t,n)}),this.registerMode("svg",{name:"xml",highlight:(t,n)=>this._highlightXML(t,n)}),this.registerMode("vue",{name:"vue",highlight:(t,n)=>this._highlightHTML(t,n)}),this.registerMode("ejs",{name:"ejs",highlight:(t,n)=>this._highlightEJS(t,n)}),this.registerMode("dockerfile",{name:"dockerfile",highlight:(t,n)=>this._highlightDockerfile(t,n)}),this.registerMode("docker",{name:"dockerfile",highlight:(t,n)=>this._highlightDockerfile(t,n)}),this.registerMode("php",{name:"php",highlight:(t,n)=>this._highlightPHP(t,n)}),e.registerCommand("setSyntaxLanguage",t=>{this.setLanguage(t),this.refreshEditorHighlight()})}setTheme(e){this.currentTheme=e}setLanguage(e){this.currentLanguage=e}registerMode(e,t){this.modes.set(e.toLowerCase(),t)}getSyntaxColors(){return this.currentTheme==="dark"?{tag:"#569cd6",comment:"#6a9955",attrName:"#9cdcfe",attrValue:"#ce9178",styleProp:"#c586c0",styleVal:"#dcdcaa",doctype:"#808080",text:"#d4d4d4",keyword:"#c586c0",string:"#ce9178",number:"#b5cea8",variable:"#9cdcfe"}:{tag:"#0000ff",comment:"#008000",attrName:"#001080",attrValue:"#a31515",styleProp:"#6a00a8",styleVal:"#804000",doctype:"#444444",text:"#000000",keyword:"#000080",string:"#a31515",number:"#0086b3",variable:"#001080"}}highlight(e,t){const n=this.getSyntaxColors(),i=this.normalizeLanguageId(t||this.currentLanguage||this.detectLanguage(e)||"html");return(this.modes.get(i)||this.modes.get("html")).highlight(e,n)}highlightHTML(e){return this.highlight(e,"html")}escapeHTML(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\"/g,""").replace(/'/g,"'")}normalizeLanguageId(e){const t=e.trim().toLowerCase().replace(/^\./,"");return{cjs:"javascript",js:"javascript",javascriptreact:"javascript",jsx:"jsx",mjs:"javascript",mts:"typescript",ts:"typescript",tsx:"tsx",typescriptreact:"tsx",md:"markdown",mdx:"markdown",shell:"bash",sh:"bash",zsh:"bash",console:"bash",terminal:"bash",docker:"dockerfile",dockerfile:"dockerfile",golang:"go",py:"python",cxx:"cpp",cc:"cpp","c++":"cpp",cs:"csharp",rs:"rust",rb:"ruby",yml:"yaml",svg:"xml",vue:"vue",ejs:"ejs"}[t]||t||"html"}restoreHighlightTokens(e,t){return e.replace(/\u0000([a-z]+)\u0000/g,(n,i)=>{let o=0;for(let s=0;s<i.length;s++)o=o*26+(i.charCodeAt(s)-97+1);return o=o-1,t[o]||""})}createTokenStore(e){const t=n=>{let i="",o=n;do i=String.fromCharCode(97+o%26)+i,o=Math.floor(o/26)-1;while(o>=0);return i||"a"};return n=>{const i=e.length;return e.push(n),`\0${t(i)}\0`}}refreshEditorHighlight(){const e=this.editor;e!=null&&e.renderTextWithHighlight&&e.renderTextWithHighlight(e.getValue(),!0)}unescapeEntitiesRepeated(e){let t=e||"";for(let n=0;n<5;n++){const i=t;if(t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),t===i)break}return t}detectLanguage(e){const t=e.trim();if(!t)return null;if(/^<\?(?:php\b|=)/i.test(t)||/^\?php\b/i.test(t))return"php";if(/^[\[{]/.test(t)&&/[\]}]$/.test(t)||/"[^"]+"\s*:/.test(t))try{return JSON.parse(t),"json"}catch(d){}const n=/<\/?[A-Za-z][\w:-]*(?:\s|>|\/>)/.test(t),i=/^<!DOCTYPE\s+html\b/i.test(t)||/<\/?(html|head|body|meta|title|style|script)\b/i.test(t);if([/^---\s*\n[\s\S]*?\n---\s*(?:\n|$)/.test(t),/^#{1,6}\s+\S/m.test(t),/^\s*```/m.test(t),/^\s*~~~/m.test(t),/^\s{0,3}>\s+/m.test(t),/^\s{0,3}(?:[-*+]|\d+\.)\s+\S/m.test(t),/^\s{0,3}[-*+]\s+\[[ xX]\]\s+\S/m.test(t),/\[[^\]\n]+\]\([^)]+\)/.test(t),/!\[[^\]\n]*\]\([^)]+\)/.test(t),/(^|\n)\s*\|.+\|\s*\n\s*\|[\s:-]+\|/m.test(t),/(^|\s)(?:\*\*|__)[^*_]+(?:\*\*|__)(?=\s|$|[.,;:!?])/m.test(t)].filter(Boolean).length>=(n?2:1))return"markdown";if(i)return"html";const l=this.detectProgrammingLanguage(t);if(l)return l;const c=/[{][\s\S]*[}]/.test(t)&&/[A-Za-z_-][\w-]*\s*:\s*[^;{}]+;?/.test(t)&&!/\b(function|const|let|var|return|class|interface|type)\b/.test(t);return!n&&c?"css":null}detectProgrammingLanguage(e){const t={php:0,python:0,go:0,cpp:0,c:0,java:0,csharp:0,rust:0,ruby:0,sql:0,yaml:0,dockerfile:0},n=(s,l,c=1)=>{l.test(e)&&(t[s]+=c)};n("python",/^\s*(from\s+\w+\s+import|import\s+\w+|def\s+\w+\s*\(|class\s+\w+|for\s+\w+\s+in\s+.+:|if\s+.+:|while\s+.+:|print\s*\()/m,2),n("python",/^\s*[A-Za-z_]\w*\s*=\s*(?:\[|\{|\(|["']|\d)/m),n("python",/\b(True|False|None|self|elif|lambda|yield)\b/),n("go",/^\s*package\s+\w+/m,3),n("go",/\bfunc\s+\w+\s*\(/,2),n("go",/\b(import|defer|goroutine|chan|struct|interface)\b/),n("cpp",/^\s*#include\s*<[^>]+>/m,2),n("cpp",/\b(std::|template\s*<|namespace\s+\w+|cout\s*<<|cin\s*>>)\b/,2),n("cpp",/\b(class|public|private|protected|virtual|typename)\b/),n("c",/^\s*#include\s*[<"][^>"]+[>"]/m),n("c",/\b(int|char|float|double|void)\s+\w+\s*\(/),n("c",/\bprintf\s*\(/),n("java",/^\s*(package|import)\s+[\w.]+;/m,2),n("java",/\b(public|private|protected)\s+(class|interface|enum)\s+\w+/,2),n("java",/\bSystem\.out\.println\s*\(/),n("csharp",/^\s*using\s+[\w.]+;/m,2),n("csharp",/\b(namespace|record|var|string|Console\.WriteLine)\b/),n("csharp",/\b(public|private|protected)\s+(class|interface|struct)\s+\w+/),n("rust",/\bfn\s+\w+\s*\(/,2),n("rust",/\b(let\s+mut|impl\s+\w+|use\s+[\w:]+|println!\s*\()/),n("rust",/\b(crate|trait|enum|match|Some|None|Ok|Err)\b/),n("ruby",/^\s*(def|class|module)\s+\w+/m,2),n("ruby",/\b(puts|require|attr_reader|elsif|end)\b/),n("sql",/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)\b/im,3),n("sql",/\bFROM\s+\w+|\bWHERE\s+/i),n("yaml",/^---\s*$/m),n("yaml",/^\s*[A-Za-z0-9_.-]+\s*:\s+\S/m,2),n("yaml",/^\s*-\s+[A-Za-z0-9_.-]+\s*:/m),n("dockerfile",/^\s*FROM\s+\S+/im,3),n("dockerfile",/^\s*(RUN|COPY|ADD|CMD|ENTRYPOINT|WORKDIR|ENV|ARG)\b/im,2),n("php",/^<\?(?:php\b|=)/i,3),n("php",/^\?php\b/i,3),n("php",/\$[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*\s*=/,2),n("php",/\b(echo|foreach|function|namespace|use|PHP_EOL)\b/,2);const[i,o]=Object.entries(t).sort((s,l)=>l[1]-s[1])[0]||["",0];return o>=2?i:null}_highlightHTML(e,t){const n=t,i=p=>this.escapeHTML(p),o=[],s=this.createTokenStore(o),l=[],c=p=>{const y=l.length;return l.push(p),`ht${y}`};let d=i(e);d=d.replace(/<\/?(?:(?!>)[^\n\r<])*?(?=$|[\n\r])/g,p=>c(p));const u=[];try{e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(p,y,m)=>(u.push({attrs:String(y||""),inner:String(m||"")}),p))}catch(p){}let f=0;return d=d.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi,(p,y,m,E,v)=>{var B,R,D;const w=(R=(B=u[f++])==null?void 0:B.inner)!=null?R:this.unescapeEntitiesRepeated(E||"");(((D=u[f-1])==null?void 0:D.attrs)||m||"").toLowerCase();const A=this._highlightJS(w,n);return`${y}${A}${v}`}),d=d.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi,(p,y,m,E)=>{const v=this._highlightCSS(this.unescapeEntitiesRepeated(m),n);return`${y}${v}${E}`}),d=d.replace(/(<!--[\s\S]*?-->)/g,p=>s(`<span style="color: ${n.comment};">${p}</span>`)),d=d.replace(/(<!DOCTYPE[\s\S]*?>)/i,p=>s(`<span style="color: ${n.doctype};">${p}</span>`)),d=d.replace(/(<\/?\s*)([^\s&>\/]+)([^<]*?)(\/?>)/g,(p,y,m,E,v)=>{const w=`<span style="color: ${n.tag};">${m}</span>`;let A=E;return A=A.replace(/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g,(B,R,D,z)=>{const J=String(R).toLowerCase(),be=`<span style="color: ${n.attrName};">${R}</span>`;let N=z,U="";z.startsWith(""")&&z.endsWith(""")?(N=z.slice(6,-6),U="""):z.startsWith("'")&&z.endsWith("'")&&(N=z.slice(5,-5),U="'");let ee=z;if(J==="style"){const _e=N.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(ce,de,ie,Ie)=>`<span style="color: ${n.styleProp};">${de}</span>:<span style="color: ${n.styleVal};">${ie}</span>${Ie}`);U?ee=`${U}${_e}${U}`:ee=_e,ee=`<span style="color: ${n.attrValue};">${ee}</span>`}else U&&(ee=`${U}${N}${U}`),ee=`<span style="color: ${n.attrValue};">${ee}</span>`;return`${be}${D}${ee}`}),`${y}${w}${A}${v}`}),d=d.replace(/\u0002ht(\d+)\u0002/g,(p,y)=>l[Number(y)]||""),this.restoreHighlightTokens(d,o)}_highlightCSS(e,t){const n=this.unescapeEntitiesRepeated(e),i=[],o=this.createTokenStore(i),s=/(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;let l=0,c="",d;for(;d=s.exec(n);){l<d.index&&(c+=this.escapeHTML(n.slice(l,d.index)));const u=d[0],f=u.startsWith("/*")?t.comment:t.string;c+=o(`<span style="color: ${f};">${this.escapeHTML(u)}</span>`),l=s.lastIndex}return l<n.length&&(c+=this.escapeHTML(n.slice(l))),c=c.replace(/(@[\w-]+)/g,u=>o(`<span style="color: ${t.keyword};">${u}</span>`)),c=c.replace(/([A-Za-z_-][\w-]*)(\s*:)/g,(u,f,p)=>`${o(`<span style="color: ${t.styleProp};">${f}</span>`)}${p}`),c=c.replace(/(#(?:[0-9a-fA-F]{3,8})\b)/g,u=>o(`<span style="color: ${t.number};">${u}</span>`)),c=c.replace(/\b(-?\d*\.?\d+(?:px|em|rem|vh|vw|vmin|vmax|%|s|ms|deg|turn|fr)?)\b/g,u=>o(`<span style="color: ${t.number};">${u}</span>`)),c=c.replace(/\b(important|inherit|initial|unset|revert|auto|none|block|inline|flex|grid|absolute|relative|fixed|sticky)\b/g,u=>o(`<span style="color: ${t.styleVal};">${u}</span>`)),this.restoreHighlightTokens(c,i)}_highlightJSON(e,t){const n=this.unescapeEntitiesRepeated(e),i=/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|[{}\[\],:]/g;let o=0,s="",l;for(;l=i.exec(n);){o<l.index&&(s+=this.escapeHTML(n.slice(o,l.index)));const c=l[0],d=l[1],u=l[2]||"",f=l[3];if(d){const p=u?t.attrName:t.string;s+=`<span style="color: ${p};">${this.escapeHTML(d)}</span>${this.escapeHTML(u)}`}else f?s+=`<span style="color: ${t.keyword};">${c}</span>`:/^-?\d/.test(c)?s+=`<span style="color: ${t.number};">${c}</span>`:s+=`<span style="color: ${t.tag};">${this.escapeHTML(c)}</span>`;o=i.lastIndex}return o<n.length&&(s+=this.escapeHTML(n.slice(o))),s}_highlightMarkdown(e,t){var d;const i=this.unescapeEntitiesRepeated(e).split(`
|
|
319
|
+
`);let o=!1,s="",l="",c=((d=i[0])==null?void 0:d.trim())==="---";return i.map((u,f)=>{const p=[],y=this.createTokenStore(p);if(c){const v=u.trim()==="---",A=`<span style="color: ${v?t.keyword:t.attrName};">${this.escapeHTML(u)}</span>`;return f>0&&v&&(c=!1),A}const m=u.match(/^(\s*)(`{3,}|~{3,})(.*)$/);if(m){const v=m[2];return o=!(o&&v[0]===s[0]),s=o?v:"",l=o?this.extractMarkdownFenceLanguage(m[3]||""):"",[this.escapeHTML(m[1]),`<span style="color: ${t.keyword}; font-weight: 700;">${this.escapeHTML(v)}</span>`,`<span style="color: ${t.string};">${this.escapeHTML(m[3]||"")}</span>`].join("")}if(o)return this.highlightMarkdownFenceLine(u,l,t);let E=this.escapeHTML(u).replace(/(`[^`]+`)/g,v=>y(`<span style="color: ${t.string}; background: rgba(148, 163, 184, 0.16); border-radius: 3px;">${v}</span>`)).replace(/(!?\[[^\]\n]*\])(\([^)]+\))/g,(v,w,A)=>y(`<span style="color: ${t.attrName};">${w}</span><span style="color: ${t.attrValue};">${A}</span>`)).replace(/(\*\*|__)(.+?)\1/g,(v,w,A)=>y(`<span style="color: ${t.keyword};">${w}</span><span style="color: ${t.tag}; font-weight: 700;">${A}</span><span style="color: ${t.keyword};">${w}</span>`)).replace(/(~~)(.+?)\1/g,(v,w,A)=>y(`<span style="color: ${t.keyword};">${w}</span><span style="color: ${t.comment}; text-decoration: line-through;">${A}</span><span style="color: ${t.keyword};">${w}</span>`)).replace(/(\*|_)([^*_]+?)\1/g,(v,w,A)=>y(`<span style="color: ${t.keyword};">${w}</span><span style="color: ${t.styleVal}; font-style: italic;">${A}</span><span style="color: ${t.keyword};">${w}</span>`));return E=E.replace(/^(\s{0,3}#{1,6})(\s+.*)?$/,(v,w,A="")=>`<span style="color: ${t.keyword}; font-weight: 700;">${w}</span><span style="color: ${t.tag}; font-weight: 700;">${A}</span>`),E=E.replace(/^(\s{0,3})((?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,(v,w,A)=>`${w}<span style="color: ${t.comment};">${A}</span>`),E=E.replace(/^(\s{0,3}>)(.*)$/,(v,w,A)=>`<span style="color: ${t.comment};">${w}</span>${A}`),E=E.replace(/^(\s*)([-*+])(\s+\[[ xX]\])(\s+)/,(v,w,A,B,R)=>`${w}<span style="color: ${t.keyword};">${A}</span><span style="color: ${t.attrName};">${B}</span>${R}`),E=E.replace(/^(\s*)([-*+]|\d+\.)(\s+)/,(v,w,A,B)=>`${w}<span style="color: ${t.keyword};">${A}</span>${B}`),E=E.replace(/^(\s*\|.*\|\s*)$/,v=>v.replace(/\|/g,w=>`<span style="color: ${t.keyword};">${w}</span>`)),this.restoreHighlightTokens(E,p)}).join(`
|
|
320
|
+
`)}extractMarkdownFenceLanguage(e){var n;const t=((n=e.trim().match(/^([A-Za-z0-9_+.#-]+)/))==null?void 0:n[1])||"";return t?this.normalizeLanguageId(t):""}highlightMarkdownFenceLine(e,t,n){const i=t?this.modes.get(t):void 0;return!i||i.name==="markdown"?`<span style="color: ${n.text};">${this.escapeHTML(e)}</span>`:i.highlight(e,n)}_highlightShell(e,t){const n=this.unescapeEntitiesRepeated(e),i=[],o=this.createTokenStore(i),s=/(#[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|(\$\{?[A-Za-z_][\w]*\}?|\$[0-9@#?$*!])/g;let l=0,c="",d;for(;d=s.exec(n);){l<d.index&&(c+=this.escapeHTML(n.slice(l,d.index)));const u=d[0],f=u.startsWith("#")?t.comment:u.startsWith("$")?t.variable:t.string;c+=o(`<span style="color: ${f};">${this.escapeHTML(u)}</span>`),l=s.lastIndex}return l<n.length&&(c+=this.escapeHTML(n.slice(l))),c=c.replace(/(^|\s)(--?[A-Za-z0-9][\w-]*)(?=\s|=|$)/g,(u,f,p)=>`${f}${o(`<span style="color: ${t.attrName};">${p}</span>`)}`),c=c.replace(/\b(if|then|else|elif|fi|for|while|until|do|done|case|esac|function|export|unset|alias|source|return|in)\b/g,u=>o(`<span style="color: ${t.keyword};">${u}</span>`)),c=c.replace(/(^|\s)(npm|npx|pnpm|yarn|bun|node|git|cd|mkdir|touch|cp|mv|rm|cat|grep|rg|find|curl|wget|echo|printf|sudo|chmod|chown|docker|kubectl)(?=\s|$)/g,(u,f,p)=>`${f}${o(`<span style="color: ${t.tag};">${p}</span>`)}`),this.restoreHighlightTokens(c,i)}getLanguageKeywords(e){const t=["true","false","null","nil","none"];return[...{python:["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","self","True","False","None"],go:["break","case","chan","const","continue","defer","default","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],c:["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while"],cpp:["alignas","alignof","auto","bool","break","case","catch","char","class","concept","const","constexpr","continue","decltype","default","delete","do","double","else","enum","explicit","export","extern","false","float","for","friend","if","inline","int","long","namespace","new","noexcept","nullptr","operator","private","protected","public","requires","return","short","signed","sizeof","static","struct","switch","template","this","throw","true","try","typedef","typename","union","unsigned","using","virtual","void","volatile","while"],java:["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","if","implements","import","instanceof","int","interface","long","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"],csharp:["abstract","as","async","await","base","bool","break","case","catch","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","get","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","out","override","params","private","protected","public","readonly","record","ref","return","sealed","set","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","using","var","virtual","void","volatile","while","yield"],rust:["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while"],ruby:["BEGIN","END","alias","and","begin","break","case","class","def","defined?","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield"],sql:["ADD","ALTER","AND","AS","ASC","BETWEEN","BY","CASE","CREATE","DELETE","DESC","DISTINCT","DROP","ELSE","END","EXISTS","FROM","GROUP","HAVING","IN","INDEX","INNER","INSERT","INTO","IS","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","ON","OR","ORDER","OUTER","PRIMARY","RIGHT","SELECT","SET","TABLE","THEN","UNION","UPDATE","VALUES","WHEN","WHERE"]}[e]||[],...t]}_highlightGenericCode(e,t,n){const i=this.unescapeEntitiesRepeated(e),o=[],s=this.createTokenStore(o),l=n==="python"||n==="ruby"||n==="sql"?"#[^\\n\\r]*|--[^\\n\\r]*":"\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\n\\r]*",c=new RegExp(`(${l})|("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`)`,"g");let d=0,u="",f;for(;f=c.exec(i);){d<f.index&&(u+=this.escapeHTML(i.slice(d,f.index)));const y=f[0],m=y.startsWith("//")||y.startsWith("/*")||y.startsWith("#")||y.startsWith("--")?t.comment:t.string;u+=s(`<span style="color: ${m};">${this.escapeHTML(y)}</span>`),d=c.lastIndex}d<i.length&&(u+=this.escapeHTML(i.slice(d)));const p=Array.from(new Set(this.getLanguageKeywords(n)));if(p.length>0){const y=new RegExp(`\\b(${p.map(m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\b`,n==="sql"?"gi":"g");u=u.replace(y,m=>s(`<span style="color: ${t.keyword};">${m}</span>`))}return u=u.replace(/\b([A-Z][A-Za-z0-9_]*|[A-Za-z_][\w]*(?=\s*\())\b/g,y=>s(`<span style="color: ${t.tag};">${y}</span>`)),u=u.replace(/\b(-?0x[0-9a-fA-F]+|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)(?:[uUlLfFdD]*)\b/g,y=>s(`<span style="color: ${t.number};">${y}</span>`)),u=u.replace(/(@[A-Za-z_][\w]*|#[A-Za-z_][\w]*|::[A-Za-z_][\w]*)/g,y=>s(`<span style="color: ${t.attrName};">${y}</span>`)),this.restoreHighlightTokens(u,o)}_highlightYAML(e,t){const n=this.unescapeEntitiesRepeated(e),i=[],o=this.createTokenStore(i);let s=this.escapeHTML(n).replace(/(#.*)$/gm,l=>o(`<span style="color: ${t.comment};">${l}</span>`)).replace(/^(\s*[-?]?\s*)([A-Za-z0-9_.-]+)(\s*:)/gm,(l,c,d,u)=>`${c}${o(`<span style="color: ${t.attrName};">${d}</span>`)}${u}`).replace(/\b(true|false|null|yes|no|on|off)\b/gi,l=>o(`<span style="color: ${t.keyword};">${l}</span>`)).replace(/\b(-?\d+(?:\.\d+)?)\b/g,l=>o(`<span style="color: ${t.number};">${l}</span>`));return s=s.replace(/("[^&]*?"|'[^&]*?')/g,l=>o(`<span style="color: ${t.string};">${l}</span>`)),this.restoreHighlightTokens(s,i)}_highlightXML(e,t){return this._highlightHTML(e,t)}_highlightJSX(e,t){const n=[],i=e.replace(/<\/?[A-Za-z][\w.:-]*(?:\s+[^<>]*?)?\/?>/g,o=>{const s=n.length,l=this.escapeHTML(o).replace(/(<\/?)([A-Za-z][\w.:-]*)([\s\S]*?)(\/?>)/,(c,d,u,f,p)=>{const y=String(f||"").replace(/([A-Za-z_:][\w:.-]*)(\s*=\s*)/g,`<span style="color: ${t.attrName};">$1</span>$2`);return`${d}<span style="color: ${t.tag};">${u}</span>${y}${p}`});return n.push(l),`jsx${s}`});return this._highlightJS(i,t).replace(/\u0004jsx(\d+)\u0004/g,(o,s)=>n[Number(s)]||"")}_highlightEJS(e,t){const n=[],i=e.replace(/<%[\s\S]*?%>/g,o=>{const s=n.length;return n.push(`<span style="color: ${t.keyword};">${this.escapeHTML(o)}</span>`),`ejs${s}`});return this._highlightHTML(i,t).replace(/\u0003ejs(\d+)\u0003/g,(o,s)=>n[Number(s)]||"")}_highlightDockerfile(e,t){return this.unescapeEntitiesRepeated(e).split(`
|
|
321
|
+
`).map(i=>{const o=this.escapeHTML(i);return/^\s*#/.test(i)?`<span style="color: ${t.comment};">${o}</span>`:o.replace(/^(\s*)(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)(\b)/i,(s,l,c,d)=>`${l}<span style="color: ${t.keyword};">${c}</span>${d}`)}).join(`
|
|
322
|
+
`)}_highlightJS(e,t){const n=this.unescapeEntitiesRepeated(e);this.escapeHTML(n);const i=[],o=y=>{let m="",E=y;do m=String.fromCharCode(97+E%26)+m,E=Math.floor(E/26)-1;while(E>=0);return m||"a"},s=y=>`\0${o(y)}\0`,l=y=>{const m=i.length;return i.push(y),s(m)};let c;const d=/(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;let u=0,f="";for(;c=d.exec(n);){const y=c.index;u<y&&(f+=this.escapeHTML(n.slice(u,y)));const m=c[0];/^\/\*/.test(m)||/^\/\//.test(m)?f+=l(`<span style="color: ${t.comment};">${this.escapeHTML(m)}</span>`):f+=l(`<span style="color: ${t.string};">${this.escapeHTML(m)}</span>`),u=d.lastIndex}return u<n.length&&(f+=this.escapeHTML(n.slice(u))),f=f.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g,(y,m,E)=>{const v=f[E-1]||"",w=f[E+y.length]||"";return v==="&"||v==="#"||w===";"||w==="#"?y:`<span style="color: ${t.number};">${y}</span>`}),f=f.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g,`<span style="color: ${t.keyword};">$1</span>`),f.replace(/\u0000([a-z]+)\u0000/g,(y,m)=>{let E=0;for(let v=0;v<m.length;v++)E=E*26+(m.charCodeAt(v)-97+1);return E=E-1,i[E]||""})}_highlightPHP(e,t){const n=this.unescapeEntitiesRepeated(e);let i=this.escapeHTML(n);const o=[],s=m=>{let E="",v=m;do E=String.fromCharCode(97+v%26)+E,v=Math.floor(v/26)-1;while(v>=0);return E||"a"},l=m=>{const E=o.length;return o.push(m),`\0${s(E)}\0`},c=(m,E)=>{const v=i.indexOf(m);return v===-1?!1:(i=i.slice(0,v)+E+i.slice(v+m.length),!0)};let d;const u=/\/\*[\s\S]*?\*\//g,f=/\/\/[^\n\r]*/g,p=/\#([^\n\r]*)/g,y=/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;for(;d=u.exec(n);){const m=d[0];c(this.escapeHTML(m),l(`<span style="color: ${t.comment};">${this.escapeHTML(m)}</span>`))}for(;d=f.exec(n);){const m=d[0];c(this.escapeHTML(m),l(`<span style="color: ${t.comment};">${this.escapeHTML(m)}</span>`))}for(;d=p.exec(n);){const m=d[0];c(this.escapeHTML(m),l(`<span style="color: ${t.comment};">${this.escapeHTML(m)}</span>`))}for(;d=y.exec(n);){const m=d[0];c(this.escapeHTML(m),l(`<span style="color: ${t.string};">${this.escapeHTML(m)}</span>`))}return i=i.replace(/(<\?(?:php\b|=)?|\?>)/gi,m=>l(`<span style="color: ${t.keyword};">${m}</span>`)),i=i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g,`<span style="color: ${t.variable};">$1</span>`),i=i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g,`<span style="color: ${t.keyword};">$1</span>`),i=i.replace(/\u0000([a-z]+)\u0000/g,(m,E)=>{let v=0;for(let w=0;w<E.length;w++)v=v*26+(E.charCodeAt(w)-97+1);return v=v-1,o[v]||""}),i}shouldHighlight(e){return/<\/?[\w:-]+|<!--/.test(e)}destroy(){this.editor=null,this.modes.clear()}}function vl(r,e){const t={...e};return t.extensions||(t.extensions=[]),t.extensions.some(o=>o.name==="keymap")||t.extensions.unshift(new hl(t.keymap)),t.extensions.some(o=>o.name==="transaction")||t.extensions.unshift(new ci),new li(r,t)}function er(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Sl(r){if(Array.isArray(r))return r}function wl(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,o,s,l=[],c=!0,d=!1;try{if(o=(t=t.call(r)).next,e!==0)for(;!(c=(n=o.call(t)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(u){d=!0,i=u}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(d)throw i}}return l}}function xl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
323
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cl(r,e){return Sl(r)||wl(r,e)||Al(r,e)||xl()}function Al(r,e){if(r){if(typeof r=="string")return er(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?er(r,e):void 0}}const tr=Object.entries,nr=Object.setPrototypeOf,kl=Object.isFrozen,Ml=Object.getPrototypeOf,Ll=Object.getOwnPropertyDescriptor;let Z=Object.freeze,ne=Object.seal,Rt=Object.create,ir=typeof Reflect!="undefined"&&Reflect,ui=ir.apply,hi=ir.construct;Z||(Z=function(e){return e}),ne||(ne=function(e){return e}),ui||(ui=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),hi||(hi=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const st=Y(Array.prototype.forEach),Rl=Y(Array.prototype.lastIndexOf),or=Y(Array.prototype.pop),Wt=Y(Array.prototype.push),Ol=Y(Array.prototype.splice),Ot=Array.isArray,jt=Y(String.prototype.toLowerCase),fi=Y(String.prototype.toString),rr=Y(String.prototype.match),Kt=Y(String.prototype.replace),sr=Y(String.prototype.indexOf),_l=Y(String.prototype.trim),Il=Y(Number.prototype.toString),Dl=Y(Boolean.prototype.toString),ar=typeof BigInt=="undefined"?null:Y(BigInt.prototype.toString),lr=typeof Symbol=="undefined"?null:Y(Symbol.prototype.toString),ge=Y(Object.prototype.hasOwnProperty),Vt=Y(Object.prototype.toString),le=Y(RegExp.prototype.test),nt=Nl(TypeError);function Y(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return ui(r,e,n)}}function Nl(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return hi(r,t)}}function P(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:jt;if(nr&&nr(r,null),!Ot(e))return r;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(kl(e)||(e[n]=o),i=o)}r[i]=!0}return r}function Hl(r){for(let e=0;e<r.length;e++)ge(r,e)||(r[e]=null);return r}function Ee(r){const e=Rt(null);for(const n of tr(r)){var t=Cl(n,2);const i=t[0],o=t[1];ge(r,i)&&(Ot(o)?e[i]=Hl(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ee(o):e[i]=o)}return e}function Pl(r){switch(typeof r){case"string":return r;case"number":return Il(r);case"boolean":return Dl(r);case"bigint":return ar?ar(r):"0";case"symbol":return lr?lr(r):"Symbol()";case"undefined":return Vt(r);case"function":case"object":{if(r===null)return Vt(r);const e=r,t=Oe(e,"toString");if(typeof t=="function"){const n=t(e);return typeof n=="string"?n:Vt(n)}return Vt(r)}default:return Vt(r)}}function Oe(r,e){for(;r!==null;){const n=Ll(r,e);if(n){if(n.get)return Y(n.get);if(typeof n.value=="function")return Y(n.value)}r=Ml(r)}function t(){return null}return t}function $l(r){try{return le(r,""),!0}catch(e){return!1}}const cr=Z(["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"]),pi=Z(["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"]),gi=Z(["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"]),Fl=Z(["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"]),mi=Z(["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"]),Bl=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),dr=Z(["#text"]),ur=Z(["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"]),bi=Z(["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"]),hr=Z(["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"]),Hn=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),zl=ne(/{{[\w\W]*|^[\w\W]*}}/g),Ul=ne(/<%[\w\W]*|^[\w\W]*%>/g),Wl=ne(/\${[\w\W]*/g),jl=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),Kl=ne(/^aria-[\-\w]+$/),fr=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vl=ne(/^(?:\w+script|data):/i),Gl=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ql=ne(/^html$/i),Yl=ne(/^[a-z][.\w]*(-[.\w]+)+$/i),pr=ne(/<[/\w!]/g),gr=ne(/<[/\w]/g),Xl=ne(/<\/no(script|embed|frames)/i),Zl=ne(/\/>/i),ve={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mr=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Ql=Z(P({},mr)),Jl=(function(){const r={};return st(mr,e=>{r[e]=ne(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Z(r)})(),ec=function(){return typeof window=="undefined"?null:window},tc=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},br=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},it=function(e,t,n,i){return ge(e,t)&&Ot(e[t])?P(i.base?Ee(i.base):{},e[t],i.transform):n},yi=function(e,t,n){const i=ge(e,t)?e[t]:void 0;return i&&typeof i=="object"?Ee(i):n()};function yr(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ec();const e=b=>yr(b);if(e.version="3.4.16",e.removed=[],!r||!r.document||r.document.nodeType!==ve.document||!r.Element)return e.isSupported=!1,e;let t=r.document;const n=t,i=n.currentScript;r.DocumentFragment;const o=r.HTMLTemplateElement,s=r.Node,l=r.Element,c=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const d=r.DOMParser,u=r.trustedTypes,f=l.prototype,p=Oe(f,"cloneNode"),y=Oe(f,"remove"),m=Oe(f,"removeAttributeNode"),E=Oe(f,"nextSibling"),v=Oe(f,"childNodes"),w=Oe(f,"parentNode"),A=Oe(f,"shadowRoot"),B=Oe(f,"attributes"),R=s&&s.prototype?Oe(s.prototype,"nodeType"):null,D=s&&s.prototype?Oe(s.prototype,"nodeName"):null,z=s&&s.prototype?Oe(s.prototype,"ownerDocument"):null,J=function(a){return R?R(a):a.nodeType},be=function(a){return D?D(a):a.nodeName};if(typeof o=="function"){const b=t.createElement("template");b.content&&b.content.ownerDocument&&(t=b.content.ownerDocument)}let N,U="",ee,_e=!1,ce=0;const de=function(){if(ce>0)throw nt('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.')},ie=function(a){de(),ce++;try{return N.createHTML(a)}finally{ce--}},Ie=function(a){de(),ce++;try{return N.createScriptURL(a)}finally{ce--}},Yt=function(){return _e||(ee=tc(u,i),_e=!0),ee},De=t,Be=De.implementation,ct=De.createNodeIterator,Xt=De.createDocumentFragment,$=De.getElementsByTagName,Fe=n.importNode;let k=br();e.isSupported=typeof tr=="function"&&typeof w=="function"&&Be&&Be.createHTMLDocument!==void 0;const _t=zl,Oi=Ul,_i=Wl,Ii=jl,Di=Kl,Ni=Vl,Zt=Gl,Hi=Yl;let Qt=fr,M=null;const dt=P({},[...cr,...pi,...gi,...mi,...dr]);let L=null;const ut=P({},[...ur,...bi,...hr,...Hn]);let K=Object.seal(Rt(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}})),Ne=null,Jt=null;const oe=Object.seal(Rt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let en=!0,ht=!0,tn=!1,nn=!0,re=!1,ue=!0,he=!1,ft=!1,ze=null,Ue=null,pt=!1,Se=!1,We=!1,je=!1,on=!0,rn=!1;const sn="user-content-";let gt=!0,mt=!1,we={},xe=null;const an=P({},["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 ln=null;const cn=P({},["audio","video","img","source","image","track"]);let dn=null;const un=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",V="http://www.w3.org/1999/xhtml";let Ce=V,bt=!1,yt=null;const Pi=P({},[Ke,Ve,V],fi),hn=Z(["mi","mo","mn","ms","mtext"]);let Tt=P({},hn);const fn=Z(["annotation-xml"]);let Et=P({},fn);const $i=P({},["title","style","font","a","script"]);let He=null;const Fi=["application/xhtml+xml","text/html"],Bi="text/html";let _=null,Ae=null;const zi=t.createElement("form"),pn=function(a){return a instanceof RegExp||a instanceof Function},vt=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ae&&Ae===a)return;(!a||typeof a!="object")&&(a={}),a=Ee(a),He=Fi.indexOf(a.PARSER_MEDIA_TYPE)===-1?Bi:a.PARSER_MEDIA_TYPE,_=He==="application/xhtml+xml"?fi:jt,M=it(a,"ALLOWED_TAGS",dt,{transform:_}),L=it(a,"ALLOWED_ATTR",ut,{transform:_}),yt=it(a,"ALLOWED_NAMESPACES",Pi,{transform:fi}),dn=it(a,"ADD_URI_SAFE_ATTR",un,{transform:_,base:un}),ln=it(a,"ADD_DATA_URI_TAGS",cn,{transform:_,base:cn}),xe=it(a,"FORBID_CONTENTS",an,{transform:_}),Ne=it(a,"FORBID_TAGS",Ee({}),{transform:_}),Jt=it(a,"FORBID_ATTR",Ee({}),{transform:_}),we=ge(a,"USE_PROFILES")?a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?Ee(a.USE_PROFILES):a.USE_PROFILES:!1,en=a.ALLOW_ARIA_ATTR!==!1,ht=a.ALLOW_DATA_ATTR!==!1,tn=a.ALLOW_UNKNOWN_PROTOCOLS||!1,nn=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=a.SAFE_FOR_TEMPLATES||!1,ue=a.SAFE_FOR_XML!==!1,he=a.WHOLE_DOCUMENT||!1,Se=a.RETURN_DOM||!1,We=a.RETURN_DOM_FRAGMENT||!1,je=a.RETURN_TRUSTED_TYPE||!1,pt=a.FORCE_BODY||!1,on=a.SANITIZE_DOM!==!1,rn=a.SANITIZE_NAMED_PROPS||!1,gt=a.KEEP_CONTENT!==!1,mt=a.IN_PLACE||!1,Qt=$l(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:fr,Ce=typeof a.NAMESPACE=="string"?a.NAMESPACE:V,Tt=yi(a,"MATHML_TEXT_INTEGRATION_POINTS",()=>P({},hn)),Et=yi(a,"HTML_INTEGRATION_POINTS",()=>P({},fn));const h=yi(a,"CUSTOM_ELEMENT_HANDLING",()=>Rt(null));if(K=Rt(null),ge(h,"tagNameCheck")&&pn(h.tagNameCheck)&&(K.tagNameCheck=h.tagNameCheck),ge(h,"attributeNameCheck")&&pn(h.attributeNameCheck)&&(K.attributeNameCheck=h.attributeNameCheck),ge(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(K.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),ne(K),re&&(ht=!1),We&&(Se=!0),we&&(M=P({},dr),L=Rt(null),we.html===!0&&(P(M,cr),P(L,ur)),we.svg===!0&&(P(M,pi),P(L,bi),P(L,Hn)),we.svgFilters===!0&&(P(M,gi),P(L,bi),P(L,Hn)),we.mathMl===!0&&(P(M,mi),P(L,hr),P(L,Hn))),oe.tagCheck=null,oe.attributeCheck=null,ge(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?oe.tagCheck=a.ADD_TAGS:Ot(a.ADD_TAGS)&&(M===dt&&(M=Ee(M)),P(M,a.ADD_TAGS,_))),ge(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?oe.attributeCheck=a.ADD_ATTR:Ot(a.ADD_ATTR)&&(L===ut&&(L=Ee(L)),P(L,a.ADD_ATTR,_))),ge(a,"ADD_FORBID_CONTENTS")&&Ot(a.ADD_FORBID_CONTENTS)&&(xe===an&&(xe=Ee(xe)),P(xe,a.ADD_FORBID_CONTENTS,_)),gt&&(M["#text"]=!0),he&&P(M,["html","head","body"]),M.table&&(P(M,["tbody"]),delete Ne.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const g=N;N=a.TRUSTED_TYPES_POLICY;try{U=ie("")}catch(T){throw N=g,T}}else a.TRUSTED_TYPES_POLICY===null?(N=void 0,U=""):(N===void 0&&(N=Yt()),N&&typeof U=="string"&&(U=ie("")));Z&&Z(a),Ae=a},gn=P({},[...pi,...gi,...Fl]),mn=P({},[...mi,...Bl]),Ui=function(a,h,g){return h.namespaceURI===V?a==="svg":h.namespaceURI===Ke?a==="svg"&&(g==="annotation-xml"||Tt[g]):!!gn[a]},Wi=function(a,h,g){return h.namespaceURI===V?a==="math":h.namespaceURI===Ve?a==="math"&&Et[g]:!!mn[a]},ji=function(a,h,g){return h.namespaceURI===Ve&&!Et[g]||h.namespaceURI===Ke&&!Tt[g]?!1:!mn[a]&&($i[a]||!gn[a])},Ki=function(a){let h=w(a);(!h||!h.tagName)&&(h={namespaceURI:Ce,tagName:"template"});const g=jt(a.tagName),T=jt(h.tagName);return yt[a.namespaceURI]?a.namespaceURI===Ve?Ui(g,h,T):a.namespaceURI===Ke?Wi(g,h,T):a.namespaceURI===V?ji(g,h,T):!!(He==="application/xhtml+xml"&&yt[a.namespaceURI]):!1},se=function(a){Wt(e.removed,{element:a});try{w(a).removeChild(a)}catch(h){if(y(a),!w(a))throw nt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},bn=function(a,h,g){try{m(a,h)}catch(T){try{a.removeAttribute(g)}catch(S){}}},Ge=function(a){qe(a);const h=v(a);if(h){const T=[];st(h,S=>{Wt(T,S)}),st(T,S=>{try{y(S)}catch(x){}})}const g=B(a);if(g)for(let T=g.length-1;T>=0;--T){const S=g[T],x=S&&S.name;typeof x=="string"&&bn(a,S,x)}},fe=function(a,h,g){if(!g)try{g=h.getAttributeNode(a)}catch(T){g=null}Wt(e.removed,{attribute:g||null,from:h});try{g?m(h,g):h.removeAttribute(a)}catch(T){try{h.removeAttribute(a)}catch(S){}}if(a==="is")if(Se||We)try{se(h)}catch(T){}else try{h.setAttribute(a,"")}catch(T){}},Vi=function(a){const h=B(a);if(h)for(let g=h.length-1;g>=0;--g){const T=h[g],S=T&&T.name;typeof S!="string"||L[_(S)]||bn(a,T,S)}},qe=function(a){const h=[a];for(;h.length>0;){const g=h.pop();J(g)===ve.element&&Vi(g);const T=v(g);if(T)for(let S=T.length-1;S>=0;--S)h.push(T[S])}},yn=function(a,h){return ue?a==="patchsrc"?!0:a==="for"&&h!=="label"&&h!=="output":!1},Gi=function(a){if(!ue)return;const h=[a];for(;h.length>0;){const g=h.pop(),T=J(g);if(T===ve.processingInstruction||T===ve.comment&&le(gr,g.data)){try{y(g)}catch(x){}continue}if(T===ve.element){const x=g,C=_(be(g));try{x.hasAttribute&&x.hasAttribute("patchsrc")&&x.removeAttribute("patchsrc"),x.hasAttribute&&x.hasAttribute("for")&&yn("for",C)&&x.removeAttribute("for")}catch(O){}}const S=v(g);if(S)for(let x=S.length-1;x>=0;--x)h.push(S[x])}},Tn=function(a){let h=null,g=null;if(pt)a="<remove></remove>"+a;else{const x=rr(a,/^[\r\n\t ]+/);g=x&&x[0]}He==="application/xhtml+xml"&&Ce===V&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const T=N?ie(a):a;if(Ce===V)try{h=new d().parseFromString(T,He)}catch(x){}if(!h||!h.documentElement){h=Be.createDocument(Ce,"template",null);try{h.documentElement.innerHTML=bt?U:T}catch(x){}}const S=h.body||h.documentElement;return a&&g&&S.insertBefore(t.createTextNode(g),S.childNodes[0]||null),Ce===V?$.call(h,he?"html":"body")[0]:he?h.documentElement:S},En=function(a){const h=z?z(a):a.ownerDocument;return ct.call(h||a,a,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ye=function(a){return a=Kt(a,_t," "),a=Kt(a,Oi," "),a=Kt(a,_i," "),a},St=function(a){var h;a.normalize();const g=z?z(a):a.ownerDocument,T=ct.call(g||a,a,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let S=T.nextNode();for(;S;)S.data=Ye(S.data),S=T.nextNode();const x=(h=a.querySelectorAll)===null||h===void 0?void 0:h.call(a,"template");x&&st(x,C=>{ke(C.content)&&St(C.content)})},Xe=function(a){const h=D?D(a):null;return typeof h!="string"||_(h)!=="form"?!1:typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||a.attributes!==B(a)||typeof a.removeAttribute!="function"||typeof a.removeAttributeNode!="function"||typeof a.getAttributeNode!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function"||a.nodeType!==R(a)||a.childNodes!==v(a)},ke=function(a){if(!R||typeof a!="object"||a===null)return!1;try{return R(a)===ve.documentFragment}catch(h){return!1}},Pe=function(a){if(!R||typeof a!="object"||a===null)return!1;try{return typeof R(a)=="number"}catch(h){return!1}};function G(b,a,h){b.length!==0&&st(b,g=>{g.call(e,a,h,Ae)})}const qi=function(a,h){return!!(ue&&a.hasChildNodes()&&!Pe(a.firstElementChild)&&le(pr,a.textContent)&&le(pr,a.innerHTML)||ue&&a.namespaceURI===V&&Ql[h]&&(Pe(a.firstElementChild)||typeof a.textContent=="string"&&le(Jl[h],a.textContent))||a.nodeType===ve.processingInstruction||ue&&a.nodeType===ve.comment&&le(gr,a.data))},Ze=function(a,h){if(a instanceof RegExp)return le(a,h);if(a instanceof Function){for(var g=arguments.length,T=new Array(g>2?g-2:0),S=2;S<g;S++)T[S-2]=arguments[S];return!!a(h,...T)}return!1},Yi=function(a,h,g){if(!Ne[h]&&xn(h)&&Ze(K.tagNameCheck,h))return!1;if(gt&&!xe[h]){const T=w(a),S=v(a);if(S&&T){const x=S.length;for(let C=x-1;C>=0;--C){const O=a===g?p(S[C],!0):S[C];T.insertBefore(O,E(a))}}}return se(a),!0},vn=function(a,h,g,T){return a.length===0?h:h===g||h===T?Ee(h):h},Me=function(a,h){return a===h||w(a)!==null?!1:(mt&&qe(a),!0)},Sn=function(a,h){if(G(k.beforeSanitizeElements,a,null),Me(a,h))return!0;if(Xe(a))return se(a),!0;const g=_(be(a));if(M=vn(k.uponSanitizeElement,M,dt,ze),G(k.uponSanitizeElement,a,{tagName:g,allowedTags:M}),Me(a,h))return!0;if(qi(a,g))return se(a),!0;if(Ne[g]||!(oe.tagCheck instanceof Function&&oe.tagCheck(g))&&!M[g]){const T=Yi(a,g,h);return T===!1&&(G(k.afterSanitizeElements,a,null),Me(a,h))?!0:T}if(J(a)===ve.element&&!Ki(a)||(g==="noscript"||g==="noembed"||g==="noframes")&&le(Xl,a.innerHTML))return se(a),!0;if(re&&a.nodeType===ve.text){const T=Ye(a.textContent);a.textContent!==T&&(Wt(e.removed,{element:a.cloneNode()}),a.textContent=T)}return G(k.afterSanitizeElements,a,null),Me(a,h)},wn=function(a,h,g){if(Jt[h]||yn(h,a)||on&&(h==="id"||h==="name")&&(g in t||g in zi))return!1;const T=L[h]||oe.attributeCheck instanceof Function&&oe.attributeCheck(h,a);return ht&&le(Ii,h)||en&&le(Di,h)?!0:T?dn[h]||le(Qt,Kt(g,Zt,""))||(h==="src"||h==="xlink:href"||h==="href")&&a!=="script"&&sr(g,"data:")===0&&ln[a]||tn&&!le(Ni,Kt(g,Zt,""))?!0:!g:xn(a)&&Ze(K.tagNameCheck,a)&&Ze(K.attributeNameCheck,h,a)||h==="is"&&K.allowCustomizedBuiltInElements&&Ze(K.tagNameCheck,g)},Xi=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),xn=function(a){return!Xi[jt(a)]&&le(Hi,a)},Zi=function(a,h,g,T){if(N&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!g)switch(u.getAttributeType(a,h)){case"TrustedHTML":return ie(T);case"TrustedScriptURL":return Ie(T)}return T},Qi=function(a,h,g,T){try{return g?a.setAttributeNS(g,h,T):a.setAttribute(h,T),Xe(a)?(se(a),!1):!0}catch(S){return fe(h,a),!1}},Cn=function(a,h){if(G(k.beforeSanitizeAttributes,a,null),Me(a,h))return;const g=a.attributes;if(!g||Xe(a))return;L=vn(k.uponSanitizeAttribute,L,ut,Ue);const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0};let S=g.length;const x=_(a.nodeName);for(;S--;){const C=g[S],O=C.name,j=C.namespaceURI,W=C.value,Le=_(O),xt=W;let F=O==="value"?xt:_l(xt),An=!1;if(T.attrName=Le,T.attrValue=F,T.keepAttr=!0,T.forceKeepAttr=void 0,G(k.uponSanitizeAttribute,a,T),F=T.attrValue,rn&&(Le==="id"||Le==="name")&&sr(F,sn)!==0&&(fe(O,a,C),F=sn+F,An=!0),ue&&le(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,F)){fe(O,a,C);continue}if(Le==="attributename"&&rr(F,"href")){fe(O,a,C);continue}if(!T.forceKeepAttr){if(!T.keepAttr){fe(O,a,C);continue}if(!nn&&le(Zl,F)){fe(O,a,C);continue}if(re&&(F=Ye(F)),!wn(x,Le,F)){fe(O,a,C);continue}F=Zi(x,Le,j,F),F!==xt&&Qi(a,O,j,F)&&An&&or(e.removed)}}G(k.afterSanitizeAttributes,a,null),Me(a,h)},Qe=function(a){let h=null;const g=En(a);for(G(k.beforeSanitizeShadowDOM,a,null);h=g.nextNode();)if(G(k.uponSanitizeShadowNode,h,null),Sn(h,a),Cn(h,a),ke(h.content)&&Qe(h.content),J(h)===ve.element){const T=A(h);ke(T)&&(wt(T),Qe(T))}G(k.afterSanitizeShadowDOM,a,null)},wt=function(a){const h=[{node:a,shadow:null}];for(;h.length>0;){const g=h.pop();if(g.shadow){Qe(g.shadow);continue}const T=g.node,S=J(T)===ve.element,x=v(T);if(x)for(let C=x.length-1;C>=0;--C)h.push({node:x[C],shadow:null});if(S){const C=D?D(T):null;if(typeof C=="string"&&_(C)==="template"){const O=T.content;ke(O)&&h.push({node:O,shadow:null})}}if(S){const C=A(T);ke(C)&&h.push({node:null,shadow:C},{node:C,shadow:null})}}};return e.sanitize=function(b){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,g=null,T=null,S=null;if(bt=!b,bt&&(b="<!-->"),typeof b!="string"&&!Pe(b)&&(b=Pl(b),typeof b!="string"))throw nt("dirty is not a string, aborting");if(!e.isSupported)return b;ft?(M=ze,L=Ue):vt(a),(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&(M=Ee(M)),k.uponSanitizeAttribute.length>0&&(L=Ee(L)),e.removed=[];const x=mt&&typeof b!="string"&&Pe(b);if(x){Gi(b);const j=be(b);if(typeof j=="string"){const W=_(j);if(!M[W]||Ne[W])throw Ge(b),nt("root node is forbidden and cannot be sanitized in-place")}if(Xe(b))throw Ge(b),nt("root node is clobbered and cannot be sanitized in-place");try{wt(b)}catch(W){throw Ge(b),W}}else if(Pe(b))h=Tn("<!---->"),g=h.ownerDocument.importNode(b,!0),g.nodeType===ve.element&&g.nodeName==="BODY"||g.nodeName==="HTML"?h=g:h.appendChild(g),wt(h);else{if(!Se&&!re&&!he&&b.indexOf("<")===-1)return N&&je?ie(b):b;if(h=Tn(b),!h)return Se?null:je?U:""}h&&pt&&se(h.firstChild);const C=x?b:h;try{const j=En(C);for(;T=j.nextNode();)Sn(T,C),Cn(T,C),ke(T.content)&&Qe(T.content)}catch(j){throw x&&(Ge(b),st(e.removed,W=>{W.element&&qe(W.element)})),j}if(x){let j=!1;if(st(e.removed,W=>{W.element&&(W.element===b&&(j=!0),qe(W.element))}),j)throw nt("a node selected for removal could not be safely returned; refusing to sanitize in place");return re&&St(b),b}if(Se){if(re&&St(h),We)for(S=Xt.call(h.ownerDocument);h.firstChild;)S.appendChild(h.firstChild);else S=h;return(L.shadowroot||L.shadowrootmode)&&(S=Fe.call(n,S,!0)),S}let O=he?h.outerHTML:h.innerHTML;return he&&M["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&le(ql,h.ownerDocument.doctype.name)&&(O="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
|
|
324
|
+
`+O),re&&(O=Ye(O)),N&&je?ie(O):O},e.setConfig=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(b),ft=!0,ze=M,Ue=L},e.clearConfig=function(){Ae=null,ft=!1,ze=null,Ue=null,N=ee,U=""},e.isValidAttribute=function(b,a,h){Ae||vt({});const g=_(b),T=_(a);return wn(g,T,h)},e.addHook=function(b,a){typeof a=="function"&&ge(k,b)&&Wt(k[b],a)},e.removeHook=function(b,a){if(ge(k,b)){if(a!==void 0){const h=Rl(k[b],a);return h===-1?void 0:Ol(k[b],h,1)[0]}return or(k[b])}},e.removeHooks=function(b){ge(k,b)&&(k[b]=[])},e.removeAllHooks=function(){k=br()},e}var nc=yr();function ic(r){return r?nc.sanitize(r,{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","input","button","textarea","select","option","base","meta","link"],ADD_ATTR:["target"]}):""}const Ti='[data-theme="dark"], .dark, .editora-theme-dark',oc=`/* Source Editor Dialog Styles */
|
|
252
325
|
.rte-source-editor-overlay {
|
|
253
326
|
position: fixed !important;
|
|
254
327
|
top: 0 !important;
|
|
@@ -547,7 +620,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
547
620
|
}
|
|
548
621
|
|
|
549
622
|
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active {
|
|
550
|
-
background: #
|
|
623
|
+
background: #2563eb;
|
|
551
624
|
color: #ffffff;
|
|
552
625
|
}
|
|
553
626
|
|
|
@@ -589,11 +662,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
589
662
|
}
|
|
590
663
|
|
|
591
664
|
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save {
|
|
592
|
-
background: #
|
|
665
|
+
background: #2563eb;
|
|
593
666
|
}
|
|
594
667
|
|
|
595
668
|
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save:hover:not(:disabled) {
|
|
596
|
-
background: #
|
|
669
|
+
background: #1d4ed8;
|
|
597
670
|
}
|
|
598
671
|
|
|
599
672
|
/* Responsive design */
|
|
@@ -625,10 +698,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
625
698
|
flex: 1;
|
|
626
699
|
text-align: center;
|
|
627
700
|
}
|
|
628
|
-
}`,
|
|
701
|
+
}`,rc=Object.freeze(Object.defineProperty({__proto__:null,CodePlugin:()=>({name:"code",toolbar:[{label:"Source",command:"toggleSourceView",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 0 1 0-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7ZM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 0 0-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7Z"></path></g></svg>',shortcut:"Mod-Shift-S"}],commands:{toggleSourceView:()=>{const e=(()=>{var l,c,d;const o=window.getSelection();if(o&&o.anchorNode){let u=o.anchorNode instanceof HTMLElement?o.anchorNode:o.anchorNode.parentElement;for(;u;){if((l=u.classList)!=null&&l.contains("rte-content"))return u;u=u.parentElement}}if(document.activeElement){let u=document.activeElement;if((c=u.classList)!=null&&c.contains("rte-content"))return u;for(;u&&u!==document.body;){if((d=u.classList)!=null&&d.contains("rte-content"))return u;const f=u.querySelector(".rte-content");if(f)return f;u=u.parentElement}}const s=document.querySelector("[data-editora-editor]");if(s){const u=s.querySelector(".rte-content");if(u)return u}return document.querySelector(".rte-content")})();if(!e)return console.error("[CodePlugin] Editor content area not found"),Qo("Editor content area not found. Please click inside the editor first."),!1;const t=e.innerHTML,n=o=>{let s="",l=0;const c=2,d=o.split(/(<\/?[a-zA-Z][^>]*>)/);for(const u of d)u.trim()&&(u.match(/^<\/[a-zA-Z]/)?(l=Math.max(0,l-1),s+=`
|
|
629
702
|
`+" ".repeat(l*c)+u):u.match(/^<[a-zA-Z]/)&&!u.match(/\/>$/)?(s+=`
|
|
630
703
|
`+" ".repeat(l*c)+u,l++):u.match(/^<[a-zA-Z].*\/>$/)?s+=`
|
|
631
|
-
`+" ".repeat(l*c)+u:s+=u.trim());return s.trim()};return(()=>{document.querySelectorAll(".rte-source-editor-overlay").forEach(
|
|
704
|
+
`+" ".repeat(l*c)+u:s+=u.trim());return s.trim()};return(()=>{document.querySelectorAll(".rte-source-editor-overlay").forEach($=>$.remove());const s=n(t);let l=null,c="dark",d=!1,u=!1,f=!1,p=!1;const y=!!e.closest(Ti)||document.body.matches(Ti)||document.documentElement.matches(Ti),m=document.createElement("div");Yo(m),m.className="rte-source-editor-overlay",y&&m.classList.add("rte-theme-dark");const E=document.createElement("div");E.className="rte-source-editor-modal",E.setAttribute("role","dialog"),E.setAttribute("aria-modal","true"),E.setAttribute("aria-labelledby","source-editor-title");const v=document.createElement("div");v.className="rte-source-editor-header",v.innerHTML=`
|
|
632
705
|
<h2 id="source-editor-title">Source Editor</h2>
|
|
633
706
|
<div class="rte-source-editor-header-toolbar">
|
|
634
707
|
<button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
|
|
@@ -664,7 +737,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
664
737
|
</svg>
|
|
665
738
|
</button>
|
|
666
739
|
</div>
|
|
667
|
-
`;const w=document.createElement("div");w.className="rte-source-editor-body";const A=document.createElement("div");A.className="rte-source-editor-content";const
|
|
740
|
+
`;const w=document.createElement("div");w.className="rte-source-editor-body";const A=document.createElement("div");A.className="rte-source-editor-content";const B=document.createElement("div");B.className="rte-source-editor-warning",B.textContent="⚠️ Advanced users only. Invalid HTML may break the editor.";const R=document.createElement("div");R.className="rte-source-editor-light-editor",R.style.height="400px",A.appendChild(B),A.appendChild(R),w.appendChild(A);const D=document.createElement("div");if(D.className="rte-source-editor-footer",D.innerHTML=`
|
|
668
741
|
<div class="rte-source-editor-footer-info">
|
|
669
742
|
<span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
|
|
670
743
|
</div>
|
|
@@ -672,7 +745,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
672
745
|
<button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
|
|
673
746
|
<button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
|
|
674
747
|
</div>
|
|
675
|
-
`,E.appendChild(v),E.appendChild(w),E.appendChild(
|
|
748
|
+
`,E.appendChild(v),E.appendChild(w),E.appendChild(D),m.appendChild(E),!document.getElementById("rte-source-editor-styles")){const $=document.createElement("style");$.id="rte-source-editor-styles",$.textContent=oc,document.head.appendChild($)}const z=v.querySelector(".theme-toggle-btn"),J=v.querySelector(".readonly-toggle-btn"),be=v.querySelector(".rte-source-editor-fullscreen-btn"),N=v.querySelector(".rte-source-editor-close-btn"),U=D.querySelector(".rte-source-editor-btn-cancel"),ee=D.querySelector(".rte-source-editor-btn-save"),_e=D.querySelector(".unsaved-changes"),ce=[],de=($,Fe,k,_t)=>{$.addEventListener(Fe,k,_t),ce.push(()=>$.removeEventListener(Fe,k,_t))},ie=$=>{f!==$&&(f=$,_e&&(_e.style.display=f?"inline":"none"))},Ie=()=>{if(!p){for(p=!0;ce.length;){const $=ce.pop();$==null||$()}l&&(l.destroy(),l=null),m.isConnected&&m.remove()}},Yt=()=>{c=c==="dark"?"light":"dark",l==null||l.setTheme(c),z&&(z.innerHTML=c==="light"?`
|
|
676
749
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
677
750
|
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
|
678
751
|
</svg>
|
|
@@ -688,7 +761,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
688
761
|
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
689
762
|
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
690
763
|
</svg>
|
|
691
|
-
`)},De=()=>{
|
|
764
|
+
`)},De=()=>{d=!d,l==null||l.setReadOnly(d),J&&(J.classList.toggle("active",d),J.innerHTML=d?`
|
|
692
765
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
693
766
|
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
694
767
|
<circle cx="12" cy="16" r="1"/>
|
|
@@ -699,7 +772,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
699
772
|
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
700
773
|
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
701
774
|
</svg>
|
|
702
|
-
`)},
|
|
775
|
+
`)},Be=()=>{u=!u,m.classList.toggle("fullscreen",u),R.style.height=u?"calc(100vh - 200px)":"400px",be&&(be.innerHTML=u?`
|
|
703
776
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
704
777
|
<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
|
|
705
778
|
</svg>
|
|
@@ -707,5 +780,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
707
780
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
708
781
|
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
709
782
|
</svg>
|
|
710
|
-
`)},at=()=>{p&&!confirm("You have unsaved changes. Are you sure you want to cancel?")||Ie()},Yt=()=>{try{const F=(l==null?void 0:l.getValue())||"";e.innerHTML=Ml(F);try{e.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!1,inputType:"insertReplacementText"}))}catch($e){e.dispatchEvent(new Event("input",{bubbles:!0}))}e.dispatchEvent(new Event("change",{bubbles:!0})),ne(!1),Ie()}catch(F){alert("Failed to update HTML. Please check your syntax."),console.error("HTML update error:",F)}};W&&de(W,"click",qt),Q&&de(Q,"click",De),me&&de(me,"click",ze),D&&de(D,"click",Ie),z&&de(z,"click",at),J&&de(J,"click",Yt),de(b,"click",F=>{F.target===b&&Ie()}),de(document,"keydown",F=>{const $e=F;$e.key==="Escape"&&($e.preventDefault(),Ie())}),document.body.appendChild(b),requestAnimationFrame(()=>{if(!(g||!b.isConnected))try{l=Ka(I,{value:s,theme:"dark",readOnly:!1,extensions:[new Fa,new $a,new za,new Wa,new ai,new ja,new Va]}),l.on("change",()=>{const F=(l==null?void 0:l.getValue())||"";ne(F!==s)}),requestAnimationFrame(()=>l==null?void 0:l.focus())}catch(F){console.error("Failed to initialize code editor:",F)}})})(),!0}},keymap:{"Mod-Shift-s":"toggleSourceView","Mod-Shift-S":"toggleSourceView"}})},Symbol.toStringTag,{value:"Module"})),bi=()=>hr("insertUnorderedList"),yi=()=>hr("insertOrderedList");function Ol(){const r=window.getSelection();if(r&&r.rangeCount>0){const t=r.getRangeAt(0).startContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement,i=n==null?void 0:n.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function _l(r){r.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach(t=>{Array.from(t.childNodes).forEach(i=>{if(i.nodeType===Node.TEXT_NODE){const s=(i.textContent||"").trim();if(!s){t.removeChild(i);return}const l=document.createElement("li");l.textContent=s,t.replaceChild(l,i);return}if(!(i instanceof HTMLElement)){t.removeChild(i);return}if(i.tagName==="LI")return;const o=document.createElement("li");for(;i.firstChild;)o.appendChild(i.firstChild);t.replaceChild(o,i)})})}const Il=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER"]);function Dl(r){let e=null;Array.from(r.childNodes).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE&&Il.has(t.tagName)){e=null;return}t.nodeType===Node.TEXT_NODE&&!(t.textContent||"").trim()||(e||(e=document.createElement("p"),r.insertBefore(e,t)),e.appendChild(t))})}function hr(r){const e=Ol();if(!e)return!1;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;const i=e.innerHTML;e.focus({preventScroll:!0});const o=document.execCommand(r,!1);return _l(e),Dl(e),ko(e,i),e.dispatchEvent(new Event("input",{bubbles:!0})),o!==!1}const ur=(r,e)=>{var t;typeof window!="undefined"&&((t=window.registerEditorCommand)==null||t.call(window,r,e))},fr=()=>{ur("toggleBulletList",bi),ur("toggleOrderedList",yi)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",fr):fr());const Nl=Object.freeze(Object.defineProperty({__proto__:null,ListPlugin:()=>({name:"list",nodes:{bulletList:{content:"listItem+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},orderedList:{content:"listItem+",group:"block",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},listItem:{content:"paragraph",parseDOM:[{tag:"li"}],toDOM:()=>["li",0]}},toolbar:[{label:"Bullet List",command:"toggleBulletList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2ZM4.5 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-8"},{label:"Numbered List",command:"toggleOrderedList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 1 1 0-2ZM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 0 1-.5-.5V5h-.5a.5.5 0 0 1 0-1H6Zm-1 8.8l.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0 0-.2l-.7.3a.5.5 0 0 1-.7-.3.5.5 0 0 1 .3-.6l.7-.4c.5-.2 1.1 0 1.4.4.3.5.3 1.1-.1 1.5l-1.2.7Zm0 3.7v.5c0 .3.2.5.5.5h1c.3 0 .5.2.5.5s-.2.5-.5.5h-1a1.5 1.5 0 0 1-1.5-1.5v-.5c0-.3.1-.6.3-.8l1.3-1.4c.3-.4.1-.9-.2-1-.1 0-.2 0-.3.2l-.4.5a.5.5 0 0 1-.7.1.5.5 0 0 1-.1-.7l.4-.5c.5-.5 1.2-.6 1.8-.4.6.3 1 .9 1 1.6 0 .4-.2.8-.5 1.1l-1.3 1.4-.3.4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-7"}],commands:{toggleBulletList:bi,toggleOrderedList:yi},keymap:{"Mod-Shift-8":"toggleBulletList","Mod-Shift-7":"toggleOrderedList"}}),toggleBulletList:bi,toggleOrderedList:yi},Symbol.toStringTag,{value:"Module"})),pr=".rte-content, .editora-content",gr=100,mr="__editoraCommandEditorRoot",Lt=new Map,Ti={};let br=!1,ve=null;function Pl(r){if(!r)return null;const e=r.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function Hl(){if(typeof window=="undefined")return null;const r=window[mr];if(!(r instanceof HTMLElement))return null;window[mr]=null;const e=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(r.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?r:null);if(e){const n=Pl(e);if(n)return n;if(e.getAttribute("contenteditable")==="true")return e}if(r.getAttribute("contenteditable")==="true")return r;const t=r.closest('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function Fl(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function Vt(r){const e=Fl(r);if(!e)return null;const t=e.closest(pr);if(t)return t;const n=e.closest('[contenteditable="true"]');if(!n)return null;let i=n,o=i.parentElement;for(;o;)o.getAttribute("contenteditable")==="true"&&(i=o),o=o.parentElement;return i}function Ei(){const r=Hl();if(r&&document.contains(r))return r;const e=window.getSelection();if(e&&e.rangeCount>0){const o=Vt(e.getRangeAt(0).startContainer);if(o)return o}const t=document.activeElement;if(t){const o=Vt(t);if(o)return o}if(ve!=null&&ve.isConnected)return ve;const n=Array.from(Lt.keys()).find(o=>o.isConnected);if(n)return n;const i=document.querySelector(pr);return i||document.querySelector('[contenteditable="true"]')}function yr(){for(const r of Lt.keys())r.isConnected||(Lt.delete(r),ve===r&&(ve=null))}function Nn(r){yr();let e=Lt.get(r);return e||(e={undoStack:[],redoStack:[]},Lt.set(r,e)),e}function Kt(r){r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}function Pn(r,e){if(!r)return;const t=Nn(r);t.undoStack.push(e),t.redoStack.length=0,t.undoStack.length>gr&&t.undoStack.splice(0,t.undoStack.length-gr),ve=r}function Tr(r,e="undo"){if(yr(),r!=null&&r.isConnected)return r;const t=Ei();if(t!=null&&t.isConnected)return t;if(ve!=null&&ve.isConnected)return ve;const n=i=>e==="undo"?i.undoStack.length>0:i.redoStack.length>0;for(const[i,o]of Lt.entries())if(i.isConnected&&n(o))return i;return null}function Er(r){const e={};for(const i of r.getAttributeNames()){const o=r.getAttribute(i);o!==null&&(e[i]=o)}const t=r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement,n=r instanceof HTMLInputElement;return{attributes:e,innerHTML:r.innerHTML,value:t?r.value:null,checked:n?r.checked:null}}function vr(r,e){const t=new Set(r.getAttributeNames());Object.keys(e.attributes).forEach(n=>t.delete(n)),t.forEach(n=>r.removeAttribute(n)),Object.entries(e.attributes).forEach(([n,i])=>{r.setAttribute(n,i)}),r.innerHTML!==e.innerHTML&&(r.innerHTML=e.innerHTML),e.value!==null&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement)&&(r.value=e.value),e.checked!==null&&r instanceof HTMLInputElement&&(r.checked=e.checked)}function ot(r,e){if(Ti[r]=e,typeof window=="undefined")return;const t=window.registerEditorCommand;typeof t=="function"?t(r,e):(window.registerEditorCommand=(n,i)=>{Ti[n]=i},window.registerEditorCommand(r,e))}const Sr=(r,...e)=>{const t=Ti[r];return t?t(...e):!1};function vi(){br||typeof window=="undefined"||(br=!0,window.execEditorCommand||(window.execEditorCommand=Sr),window.executeEditorCommand||(window.executeEditorCommand=Sr),ot("undo",Si),ot("redo",wi),ot("setAttribute",xi),ot("setText",Ci),ot("autoFixA11y",Ai),ot("recordDomTransaction",ki),ot("undoDom",Hn),ot("redoDom",Fn))}const Si=()=>{const r=Ei();return Hn(r!=null?r:void 0)},wi=()=>{const r=Ei();return Fn(r!=null?r:void 0)},xi=(r,e,t)=>{if(!(r instanceof HTMLElement))return;const n=Vt(r),i=r.hasAttribute(e),o=r.getAttribute(e);r.setAttribute(e,t),Pn(n,{undo:()=>{r.isConnected&&(i&&o!==null?r.setAttribute(e,o):r.removeAttribute(e))},redo:()=>{r.isConnected&&r.setAttribute(e,t)}}),Kt(n)},Ci=(r,e)=>{var i;if(!(r instanceof HTMLElement))return;const t=Vt(r),n=(i=r.textContent)!=null?i:"";r.textContent=e,Pn(t,{undo:()=>{r.isConnected&&(r.textContent=n)},redo:()=>{r.isConnected&&(r.textContent=e)}}),Kt(t)},Ai=r=>{var s;const e=r==null?void 0:r.element;if(!(e instanceof HTMLElement))return;const t=Vt(e),n=(s=window.a11yRuleRegistry)==null?void 0:s.find(l=>l.id===r.rule);if(!n||typeof n.fix!="function")return;const i=Er(e);n.fix(r);const o=Er(e);Pn(t,{undo:()=>{e.isConnected&&vr(e,i)},redo:()=>{e.isConnected&&vr(e,o)}}),Kt(t)},ki=(r,e,t)=>{if(!(r instanceof HTMLElement))return!1;const n=typeof t=="string"?t:r.innerHTML;if(e===n)return!1;const i=Nn(r).undoStack.slice(-1)[0];return i&&i.beforeHTML===e&&i.afterHTML===n?!1:(Pn(r,{beforeHTML:e,afterHTML:n,undo:()=>{r.isConnected&&(r.innerHTML=e)},redo:()=>{r.isConnected&&(r.innerHTML=n)}}),!0)},Hn=r=>{const e=Tr(r,"undo");if(!e)return!1;const t=Nn(e),n=t.undoStack.pop();return n?(n.undo(),t.redoStack.push(n),ve=e,Kt(e),!0):!1},Fn=r=>{const e=Tr(r,"redo");if(!e)return!1;const t=Nn(e),n=t.redoStack.pop();return n?(n.redo(),t.undoStack.push(n),ve=e,Kt(e),!0):!1};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",vi,{once:!0}):vi());const $l=Object.freeze(Object.defineProperty({__proto__:null,HistoryPlugin:()=>(vi(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:Si,redo:wi,setAttribute:xi,setText:Ci,autoFixA11y:Ai,recordDomTransaction:ki,undoDom:Hn,redoDom:Fn},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}}),autoFixA11y:Ai,recordDomTransaction:ki,redo:wi,redoDom:Fn,setAttribute:xi,setText:Ci,undo:Si,undoDom:Hn},Symbol.toStringTag,{value:"Module"}));wt.initWebComponent=wo,Object.defineProperty(wt,Symbol.toStringTag,{value:"Module"})}));
|
|
783
|
+
`)},ct=async()=>{f&&!await sl("You have unsaved changes. Are you sure you want to cancel?",{title:"Discard changes?",confirmText:"Discard changes",cancelText:"Keep editing",danger:!0,context:e})||Ie()},Xt=()=>{try{const $=(l==null?void 0:l.getValue())||"";e.innerHTML=ic($);try{e.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!1,inputType:"insertReplacementText"}))}catch(Fe){e.dispatchEvent(new Event("input",{bubbles:!0}))}e.dispatchEvent(new Event("change",{bubbles:!0})),ie(!1),Ie()}catch($){Qo("Failed to update HTML. Please check your syntax.","error"),console.error("HTML update error:",$)}};z&&de(z,"click",Yt),J&&de(J,"click",De),be&&de(be,"click",Be),N&&de(N,"click",Ie),U&&de(U,"click",ct),ee&&de(ee,"click",Xt),de(m,"click",$=>{$.target===m&&Ie()}),de(document,"keydown",$=>{const Fe=$;Fe.key==="Escape"&&(Fe.preventDefault(),Ie())}),document.body.appendChild(m),requestAnimationFrame(()=>{if(!(p||!m.isConnected))try{l=vl(R,{value:s,theme:"dark",readOnly:!1,extensions:[new fl,new pl,new gl,new yl,new di,new Tl,new El]}),l.on("change",()=>{const $=(l==null?void 0:l.getValue())||"";ie($!==s)}),requestAnimationFrame(()=>l==null?void 0:l.focus())}catch($){console.error("Failed to initialize code editor:",$)}})})(),!0}},keymap:{"Mod-Shift-s":"toggleSourceView","Mod-Shift-S":"toggleSourceView"}})},Symbol.toStringTag,{value:"Module"}));function sc(r){var o,s;const e=Array.from(r.querySelectorAll("ul, ol")).filter(l=>{var c;return((c=l.parentElement)==null?void 0:c.tagName)==="P"&&r.contains(l.parentElement)});if(e.length===0)return;const t=(s=(o=r.ownerDocument.defaultView)==null?void 0:o.getSelection())!=null?s:null,n=t&&t.rangeCount>0?t.getRangeAt(0):null,i=n&&r.contains(n.commonAncestorContainer)?{startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}:null;if(e.forEach(l=>{const c=l.parentElement;if(!c||c.tagName!=="P"||!c.parentNode)return;const d=c.parentNode,u=[],f=[];let p=!1;Array.from(c.childNodes).forEach(E=>{E===l?p=!0:p?f.push(E):u.push(E)});const y=E=>E.some(v=>{var w;return v.nodeType===Node.TEXT_NODE?((w=v.textContent)!=null?w:"").trim()!=="":!0}),m=E=>{const v=c.cloneNode(!1);return E.forEach(w=>v.appendChild(w)),v};y(u)&&d.insertBefore(m(u),c),d.insertBefore(l,c),y(f)&&d.insertBefore(m(f),c),d.removeChild(c)}),i&&t&&r.contains(i.startContainer)&&r.contains(i.endContainer)){const l=r.ownerDocument.createRange();l.setStart(i.startContainer,i.startOffset),l.setEnd(i.endContainer,i.endOffset),t.removeAllRanges(),t.addRange(l)}}function ac(r){var e;return r instanceof HTMLElement&&r.tagName==="P"&&((e=r.textContent)!=null?e:"")===""&&r.querySelector("*")===null}function lc(r){const e=(t,n)=>{var o;let i=t[n];for(;i&&i.nodeType===Node.TEXT_NODE&&((o=i.textContent)!=null?o:"").trim()==="";)i=i[n];return i};r.querySelectorAll("ul, ol").forEach(t=>{var n,i;if(!(t.parentNode!==r&&((n=t.parentElement)!=null&&n.closest("ul, ol"))))for(const o of["previousSibling","nextSibling"]){let s=e(t,o);for(;ac(s);){const l=s;s=e(l,o),(i=l.parentNode)==null||i.removeChild(l)}}})}const cc=/^(P|LI|H[1-6]|BLOCKQUOTE|PRE|DIV|TD|TH)$/;function Tr(r,e){let t=e;for(;t&&t!==r;){if(t instanceof HTMLElement&&cc.test(t.tagName))return t;t=t.parentNode}return null}function dc(r){var o;const e=(o=r.ownerDocument.defaultView)==null?void 0:o.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return null;const t=e.getRangeAt(0);if(!r.contains(t.startContainer))return null;const n=Tr(r,t.startContainer);if(!n)return null;const i=r.ownerDocument.createRange();return i.selectNodeContents(n),i.setEnd(t.startContainer,t.startOffset),i.toString().length}function uc(r,e){var u;const t=(u=r.ownerDocument.defaultView)==null?void 0:u.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;const n=t.getRangeAt(0);if(!r.contains(n.startContainer))return;const i=Tr(r,n.startContainer);if(!i)return;const o=r.ownerDocument.createTreeWalker(i,NodeFilter.SHOW_TEXT);let s=Math.max(0,e),l=null,c;const d=r.ownerDocument.createRange();for(;c=o.nextNode();){const f=c;if(l=f,s<=f.data.length){d.setStart(f,s),d.collapse(!0),t.removeAllRanges(),t.addRange(d);return}s-=f.data.length}l&&(d.setStart(l,l.data.length),d.collapse(!0),t.removeAllRanges(),t.addRange(d))}const Ei=()=>Er("insertUnorderedList"),vi=()=>Er("insertOrderedList");function hc(){const r=window.getSelection();if(r&&r.rangeCount>0){const t=r.getRangeAt(0).startContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement,i=n==null?void 0:n.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function fc(r){r.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach(t=>{Array.from(t.childNodes).forEach(i=>{if(i.nodeType===Node.TEXT_NODE){const s=(i.textContent||"").trim();if(!s){t.removeChild(i);return}const l=document.createElement("li");l.textContent=s,t.replaceChild(l,i);return}if(!(i instanceof HTMLElement)){t.removeChild(i);return}if(i.tagName==="LI")return;const o=document.createElement("li");for(;i.firstChild;)o.appendChild(i.firstChild);t.replaceChild(o,i)})})}const pc=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER"]);function gc(r){let e=null;Array.from(r.childNodes).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE&&pc.has(t.tagName)){e=null;return}t.nodeType===Node.TEXT_NODE&&!(t.textContent||"").trim()||(e||(e=document.createElement("p"),r.insertBefore(e,t)),e.appendChild(t))})}function Er(r){const e=hc();if(!e)return!1;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;const i=e.innerHTML,o=dc(e);e.focus({preventScroll:!0});const s=document.execCommand(r,!1);return fc(e),sc(e),lc(e),gc(e),o!==null&&uc(e,o),Ro(e,i),e.dispatchEvent(new Event("input",{bubbles:!0})),s!==!1}const vr=(r,e)=>{var t;typeof window!="undefined"&&((t=window.registerEditorCommand)==null||t.call(window,r,e))},Sr=()=>{vr("toggleBulletList",Ei),vr("toggleOrderedList",vi)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Sr):Sr());const mc=Object.freeze(Object.defineProperty({__proto__:null,ListPlugin:()=>({name:"list",nodes:{bulletList:{content:"listItem+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},orderedList:{content:"listItem+",group:"block",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},listItem:{content:"paragraph",parseDOM:[{tag:"li"}],toDOM:()=>["li",0]}},toolbar:[{label:"Bullet List",command:"toggleBulletList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2ZM4.5 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-8"},{label:"Numbered List",command:"toggleOrderedList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 1 1 0-2ZM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 0 1-.5-.5V5h-.5a.5.5 0 0 1 0-1H6Zm-1 8.8l.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0 0-.2l-.7.3a.5.5 0 0 1-.7-.3.5.5 0 0 1 .3-.6l.7-.4c.5-.2 1.1 0 1.4.4.3.5.3 1.1-.1 1.5l-1.2.7Zm0 3.7v.5c0 .3.2.5.5.5h1c.3 0 .5.2.5.5s-.2.5-.5.5h-1a1.5 1.5 0 0 1-1.5-1.5v-.5c0-.3.1-.6.3-.8l1.3-1.4c.3-.4.1-.9-.2-1-.1 0-.2 0-.3.2l-.4.5a.5.5 0 0 1-.7.1.5.5 0 0 1-.1-.7l.4-.5c.5-.5 1.2-.6 1.8-.4.6.3 1 .9 1 1.6 0 .4-.2.8-.5 1.1l-1.3 1.4-.3.4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-7"}],commands:{toggleBulletList:Ei,toggleOrderedList:vi},keymap:{"Mod-Shift-8":"toggleBulletList","Mod-Shift-7":"toggleOrderedList"}}),toggleBulletList:Ei,toggleOrderedList:vi},Symbol.toStringTag,{value:"Module"})),wr=".rte-content, .editora-content",xr=200,bc=4e7,yc=1e3,Tc=8e3,Cr="__editoraCommandEditorRoot",at=new Map,Si={};let Ar=!1,me=null;function Ec(r){if(!r)return null;const e=r.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function vc(){if(typeof window=="undefined")return null;const r=window[Cr];if(!(r instanceof HTMLElement))return null;window[Cr]=null;const e=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(r.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?r:null);if(e){const n=Ec(e);if(n)return n;if(e.getAttribute("contenteditable")==="true")return e}if(r.getAttribute("contenteditable")==="true")return r;const t=r.closest('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function Sc(r){return r?r.nodeType===Node.ELEMENT_NODE?r:r.parentElement:null}function lt(r){const e=Sc(r);if(!e)return null;const t=e.closest(wr);if(t)return t;const n=e.closest('[contenteditable="true"]');if(!n)return null;let i=n,o=i.parentElement;for(;o;)o.getAttribute("contenteditable")==="true"&&(i=o),o=o.parentElement;return i}function wi(){const r=vc();if(r&&document.contains(r))return r;const e=window.getSelection();if(e&&e.rangeCount>0){const o=lt(e.getRangeAt(0).startContainer);if(o)return o}const t=document.activeElement;if(t){const o=lt(t);if(o)return o}if(me!=null&&me.isConnected)return me;const n=Array.from(at.keys()).find(o=>o.isConnected);if(n)return n;const i=document.querySelector(wr);return i||document.querySelector('[contenteditable="true"]')}function kr(){for(const r of at.keys())r.isConnected||(at.delete(r),me===r&&(me=null))}function Pn(r){kr();let e=at.get(r);return e||(e={undoStack:[],redoStack:[]},at.set(r,e)),e}function Gt(r){r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}function wc(r){return r==="insertText"||r==="insertCompositionText"?"insert":r==="deleteContentBackward"||r==="deleteContentForward"?"delete":null}function $n(r){var n;if(!r)return;const e=(n=at.get(r))==null?void 0:n.undoStack,t=e&&e[e.length-1];t&&(t.closed=!0)}function Mr(r){var t;const e=document.createElement("div");return e.innerHTML=r,((t=e.textContent)!=null?t:"").replace(/\u00a0/g," ")}function xc(r,e){const t=Mr(r),n=Mr(e),i=Math.min(t.length,n.length);let o=0;for(;o<i&&t.charCodeAt(o)===n.charCodeAt(o);)o++;let s=0;for(;s<i-o&&t.charCodeAt(t.length-1-s)===n.charCodeAt(n.length-1-s);)s++;return{start:o,beforeEnd:t.length-s,afterEnd:n.length-s}}function Cc(r,e){const t=window.getSelection();if(!t)return;const n=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);let i=Math.max(0,e),o=null,s=null;for(;o=n.nextNode();){const c=o;if(s=c,i<=c.data.length){const d=document.createRange();d.setStart(c,i),d.collapse(!0),t.removeAllRanges(),t.addRange(d);return}i-=c.data.length}const l=document.createRange();s?l.setStart(s,s.data.length):l.selectNodeContents(r),l.collapse(!0),t.removeAllRanges(),t.addRange(l)}function Lr(r,e,t,n){const i=document.activeElement,o=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(!(!i||i===document.body||r.contains(i)||!!(o!=null&&o.contains(i))))return;const l=xc(e,t);Cc(r,n==="undo"?l.beforeEnd:l.afterEnd),r.contains(document.activeElement)||r.focus({preventScroll:!0})}let Rr=!1;function Ac(){Rr||typeof document=="undefined"||(Rr=!0,document.addEventListener("pointerdown",r=>$n(lt(r.target)),!0),document.addEventListener("keydown",r=>{/^(Arrow(Left|Right|Up|Down)|Home|End|Page(Up|Down)|Tab)$/.test(r.key)&&$n(lt(r.target))},!0))}function Fn(r,e){var o,s,l,c;if(!r)return;const t=Pn(r);t.undoStack.push(e),t.redoStack.length=0,t.undoStack.length>xr&&t.undoStack.splice(0,t.undoStack.length-xr);let n=0;t.undoStack.forEach(d=>{var u,f,p,y;n+=((f=(u=d.beforeHTML)==null?void 0:u.length)!=null?f:0)+((y=(p=d.afterHTML)==null?void 0:p.length)!=null?y:0)});let i=0;for(;n>bc&&t.undoStack.length-i>1;){const d=t.undoStack[i];n-=((s=(o=d.beforeHTML)==null?void 0:o.length)!=null?s:0)+((c=(l=d.afterHTML)==null?void 0:l.length)!=null?c:0),i+=1}i>0&&t.undoStack.splice(0,i),me=r}function Or(r,e="undo"){if(kr(),r!=null&&r.isConnected)return r;const t=wi();if(t!=null&&t.isConnected)return t;if(me!=null&&me.isConnected)return me;const n=i=>e==="undo"?i.undoStack.length>0:i.redoStack.length>0;for(const[i,o]of at.entries())if(i.isConnected&&n(o))return i;return null}function _r(r){const e={};for(const i of r.getAttributeNames()){const o=r.getAttribute(i);o!==null&&(e[i]=o)}const t=r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement,n=r instanceof HTMLInputElement;return{attributes:e,innerHTML:r.innerHTML,value:t?r.value:null,checked:n?r.checked:null}}function Ir(r,e){const t=new Set(r.getAttributeNames());Object.keys(e.attributes).forEach(n=>t.delete(n)),t.forEach(n=>r.removeAttribute(n)),Object.entries(e.attributes).forEach(([n,i])=>{r.setAttribute(n,i)}),r.innerHTML!==e.innerHTML&&(r.innerHTML=e.innerHTML),e.value!==null&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement)&&(r.value=e.value),e.checked!==null&&r instanceof HTMLInputElement&&(r.checked=e.checked)}function ot(r,e){if(Si[r]=e,typeof window=="undefined")return;const t=window.registerEditorCommand;typeof t=="function"?t(r,e):(window.registerEditorCommand=(n,i)=>{Si[n]=i},window.registerEditorCommand(r,e))}const Dr=(r,...e)=>{const t=Si[r];return t?t(...e):!1};function xi(){Ar||typeof window=="undefined"||(Ar=!0,Ac(),window.execEditorCommand||(window.execEditorCommand=Dr),window.executeEditorCommand||(window.executeEditorCommand=Dr),ot("undo",Ci),ot("redo",Ai),ot("setAttribute",ki),ot("setText",Mi),ot("autoFixA11y",Li),ot("recordDomTransaction",Ri),ot("undoDom",Bn),ot("redoDom",zn))}const Ci=()=>{const r=wi();return Bn(r!=null?r:void 0)},Ai=()=>{const r=wi();return zn(r!=null?r:void 0)},ki=(r,e,t)=>{if(!(r instanceof HTMLElement))return;const n=lt(r),i=r.hasAttribute(e),o=r.getAttribute(e);r.setAttribute(e,t),Fn(n,{undo:()=>{r.isConnected&&(i&&o!==null?r.setAttribute(e,o):r.removeAttribute(e))},redo:()=>{r.isConnected&&r.setAttribute(e,t)}}),Gt(n)},Mi=(r,e)=>{var i;if(!(r instanceof HTMLElement))return;const t=lt(r),n=(i=r.textContent)!=null?i:"";r.textContent=e,Fn(t,{undo:()=>{r.isConnected&&(r.textContent=n)},redo:()=>{r.isConnected&&(r.textContent=e)}}),Gt(t)},Li=r=>{var s;const e=r==null?void 0:r.element;if(!(e instanceof HTMLElement))return;const t=lt(e),n=(s=window.a11yRuleRegistry)==null?void 0:s.find(l=>l.id===r.rule);if(!n||typeof n.fix!="function")return;const i=_r(e);n.fix(r);const o=_r(e);Fn(t,{undo:()=>{e.isConnected&&Ir(e,i)},redo:()=>{e.isConnected&&Ir(e,o)}}),Gt(t)},Ri=(r,e,t,n)=>{var f,p;if(!(r instanceof HTMLElement))return!1;const i=typeof t=="string"?t:r.innerHTML;if(e===i)return!1;const o=Pn(r),s=o.undoStack[o.undoStack.length-1];if(s&&s.beforeHTML===e&&s.afterHTML===i)return!1;const l=Date.now(),c=(n==null?void 0:n.selectionCollapsed)===!1?null:wc(n==null?void 0:n.inputType),d=c==="insert"&&typeof(n==null?void 0:n.data)=="string"&&/\s/.test(n.data);if(c&&s&&s.group===c&&!s.closed&&s.afterHTML===e&&l-((f=s.updatedAt)!=null?f:0)<=yc&&l-((p=s.startedAt)!=null?p:0)<=Tc)return s.afterHTML=i,s.updatedAt=l,d&&(s.closed=!0),o.redoStack.length=0,me=r,!0;const u={beforeHTML:s&&s.afterHTML===e?s.afterHTML:e,afterHTML:i,group:c!=null?c:void 0,startedAt:l,updatedAt:l,closed:d,undo:()=>{r.isConnected&&(r.innerHTML=u.beforeHTML,Lr(r,u.beforeHTML,u.afterHTML,"undo"))},redo:()=>{r.isConnected&&(r.innerHTML=u.afterHTML,Lr(r,u.beforeHTML,u.afterHTML,"redo"))}};return Fn(r,u),!0},Bn=r=>{const e=Or(r,"undo");if(!e)return!1;const t=Pn(e),n=t.undoStack.pop();return n?(n.undo(),t.redoStack.push(n),$n(e),me=e,Gt(e),!0):!1},zn=r=>{const e=Or(r,"redo");if(!e)return!1;const t=Pn(e),n=t.redoStack.pop();return n?(n.redo(),t.undoStack.push(n),$n(e),me=e,Gt(e),!0):!1};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",xi,{once:!0}):xi());const kc=Object.freeze(Object.defineProperty({__proto__:null,HistoryPlugin:()=>(xi(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:Ci,redo:Ai,setAttribute:ki,setText:Mi,autoFixA11y:Li,recordDomTransaction:Ri,undoDom:Bn,redoDom:zn},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}}),autoFixA11y:Li,recordDomTransaction:Ri,redo:Ai,redoDom:zn,setAttribute:ki,setText:Mi,undo:Ci,undoDom:Bn},Symbol.toStringTag,{value:"Module"}));Ct.initWebComponent=Ao,Object.defineProperty(Ct,Symbol.toStringTag,{value:"Module"})}));
|
|
711
784
|
//# sourceMappingURL=webcomponent-core.min.js.map
|