Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@editora/light-code-editor

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@editora/light-code-editor - npm Package Compare versions

Comparing version
1.0.7
to
1.0.8
+1
dist/style.css
.rte-light-editor{position:relative;width:100%;height:400px;border:1px solid #ccc;border-radius:4px;overflow:hidden;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:21px}.rte-light-editor-content{position:relative;width:100%;height:100%;padding:8px;margin:0;border:none;outline:none;resize:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:auto;background:transparent}.rte-light-editor-gutter{position:absolute;left:0;top:0;bottom:0;width:50px;padding:8px 0;text-align:right;border-right:1px solid #e0e0e0;background:#f8f8f8;color:#999;font-size:12px;line-height:21px;-webkit-user-select:none;user-select:none;overflow:hidden}.rte-light-editor-gutter.dark{border-right-color:#3e3e3e;background:#1e1e1e;color:#666}.rte-syntax-highlight-overlay{position:absolute;top:0;left:50px;right:0;bottom:0;pointer-events:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:hidden;z-index:5;background:transparent;color:transparent}.syntax-html-tag{color:#569cd6!important}.syntax-html-comment{color:#6a9955!important}.syntax-html-attr-value{color:#ce9178!important}.dark .syntax-html-tag{color:#569cd6!important}.dark .syntax-html-comment{color:#6a9955!important}.dark .syntax-html-attr-value{color:#ce9178!important}.light .syntax-html-tag{color:#00f!important}.light .syntax-html-comment{color:green!important}.light .syntax-html-attr-value{color:#a31515!important}.rte-light-editor.dark{background:#1e1e1e;color:#d4d4d4;border-color:#3e3e3e}.rte-light-editor.dark .rte-light-editor-content{background:#1e1e1e;color:#d4d4d4}.rte-light-editor.light{background:#ffffff;color:#000;border-color:#e0e0e0}.rte-light-editor.light .rte-light-editor-content{background:#ffffff;color:#000}.rte-light-editor.readonly .rte-light-editor-content{cursor:not-allowed;opacity:.7}.rte-light-editor.readonly .rte-light-editor-content:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(255,255,255,.1);pointer-events:none}.rte-light-editor.focused{border-color:#007acc;box-shadow:0 0 0 2px #007acc33}.rte-light-editor-content::selection{background:rgba(0,122,204,.2)}.rte-light-editor.dark .rte-light-editor-content::selection{background:rgba(0,122,204,.3)}.rte-light-editor-content::-webkit-scrollbar{width:12px;height:12px}.rte-light-editor-content::-webkit-scrollbar-track{background:#f1f1f1}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-track{background:#2d2d2d}.rte-light-editor-content::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:6px}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb{background:#555}.rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#666}.bracket-match{background:rgba(0,122,204,.1);border-radius:2px}.dark .bracket-match{background:rgba(0,122,204,.2)}.search-match{background:rgba(255,255,0,.3);border-radius:2px}.search-match.current{background:rgba(255,255,0,.6);border:1px solid #ffcc00}.fold-indicator{position:absolute;left:35px;width:12px;height:12px;cursor:pointer;opacity:.5;transition:opacity .2s}.fold-indicator:hover{opacity:1}.fold-indicator.expanded:before{content:"▼";font-size:10px;color:#666}.fold-indicator.collapsed:before{content:"▶";font-size:10px;color:#666}.dark .fold-indicator.expanded:before,.dark .fold-indicator.collapsed:before{color:#999}.editor-container{font-family:monospace;background-color:#1e1e1e;color:#d4d4d4;padding:10px;border:1px solid #333;border-radius:4px;overflow:auto}.editor-line{white-space:pre}.editor-line-number{display:inline-block;width:30px;text-align:right;margin-right:10px;color:#858585}.lce-search-ui{position:absolute;top:12px;right:12px;z-index:1000;min-width:250px;max-width:min(320px,calc(100% - 24px));box-sizing:border-box;border-radius:6px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-background, #1e1e1e);box-shadow:0 8px 20px #0000003d;padding:8px}.lce-search-row{display:flex;align-items:center;gap:6px;margin-bottom:6px}.lce-search-options{display:flex;align-items:center;gap:8px;margin:2px 0 6px}.lce-search-option{display:inline-flex;align-items:center;gap:4px;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.2;-webkit-user-select:none;user-select:none;cursor:pointer}.lce-search-option-input{margin:0;accent-color:var(--editor-cursor, #007acc)}.lce-search-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.lce-search-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;min-width:0;height:30px;padding:6px 10px;box-sizing:border-box;border-radius:4px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-gutter-background, #252526);color:var(--editor-foreground, #f8f9fa);font-size:12px;line-height:1.4;outline:none}.lce-search-input:focus{border-color:var(--editor-cursor, #007acc);box-shadow:0 0 0 2px #007acc33}.lce-search-replace{display:none;margin-top:8px}.lce-search-btn{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:28px;min-width:28px;height:28px;padding:0;border-radius:4px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-gutter-background, #252526);color:var(--editor-gutter-foreground, #858585);font-size:12px;line-height:1;cursor:pointer}.lce-search-btn:hover{color:var(--editor-foreground, #f8f9fa)}.lce-search-status{min-height:16px;margin:2px 2px 0;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.35;text-align:left;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.lce-search-mode{min-height:16px;margin:2px 2px 0;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.35;white-space:nowrap;opacity:.9}
+3
-7

@@ -6,10 +6,10 @@ # Change Log

## 1.0.7 (2026-03-05)
## 1.0.8 (2026-03-08)
**Note:** Version bump only for package @editora/light-code-editor
## 1.0.7 (2026-03-05)
**Note:** Version bump only for package @editora/light-code-editor
## 1.0.2 (2026-02-13)

@@ -19,8 +19,4 @@

## 1.0.1 (2026-02-12)
**Note:** Version bump only for package @editora/light-code-editor

@@ -1,6 +0,6 @@

(function(y,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(y=typeof globalThis<"u"?globalThis:y||self,C(y.LightCodeEditor={}))})(this,(function(y){"use strict";class C{constructor(t=""){this._lines=[],this._version=0,this.setText(t)}getLine(t){return this._lines[t]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
(function(y,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(y=typeof globalThis<"u"?globalThis:y||self,w(y.LightCodeEditor={}))})(this,function(y){"use strict";const w="";class M{constructor(t=""){this._lines=[],this._version=0,this.setText(t)}getLine(t){return this._lines[t]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
`)}setText(t){this._lines=t.split(`
`),this._version++}getTextInRange(t){if(t.start.line===t.end.line)return this.getLine(t.start.line).substring(t.start.column,t.end.column);const e=[];e.push(this.getLine(t.start.line).substring(t.start.column));for(let s=t.start.line+1;s<t.end.line;s++)e.push(this.getLine(s));return t.end.line<this.getLineCount()&&e.push(this.getLine(t.end.line).substring(0,t.end.column)),e.join(`
`)}replaceRange(t,e){const s=this.getTextInRange(t);if(t.start.line===t.end.line){const i=this.getLine(t.start.line),n=i.substring(0,t.start.column)+e+i.substring(t.end.column);this._lines[t.start.line]=n}else{const i=this.getLine(t.start.line),n=this.getLine(t.end.line),r=i.substring(0,t.start.column)+e,l=n.substring(t.end.column),o=e.split(`
`);o[0]=r+o[0],o[o.length-1]=o[o.length-1]+l,this._lines.splice(t.start.line,t.end.line-t.start.line+1,...o)}return this._version++,{range:t,text:e,oldText:s}}insertText(t,e){const s={start:t,end:t};return this.replaceRange(s,e)}deleteRange(t){return this.replaceRange(t,"")}positionToOffset(t){let e=0;for(let s=0;s<t.line;s++)e+=this.getLine(s).length+1;return e+=t.column,e}offsetToPosition(t){let e=t;for(let s=0;s<this.getLineCount();s++){const i=this.getLine(s).length;if(e<=i)return{line:s,column:e};e-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(t){return!(t.line<0||t.line>=this.getLineCount()||t.column<0||t.column>this.getLine(t.line).length)}isValidRange(t){return this.isValidPosition(t.start)&&this.isValidPosition(t.end)}getVersion(){return this._version}clone(){const t=new C;return t._lines=[...this._lines],t._version=this._version,t}}class I{constructor(t){this.gutterWidth=50,this.lineHeight=21,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.virtualMarkerRegex=/[\u200B\uE000]/,this.container=t,this.createDOM()}createDOM(){this.container.innerHTML="";const t=document.createElement("div");this.editorContainer=t,t.setAttribute("data-lce-editor-container","true"),t.style.cssText=`
`);o[0]=r+o[0],o[o.length-1]=o[o.length-1]+l,this._lines.splice(t.start.line,t.end.line-t.start.line+1,...o)}return this._version++,{range:t,text:e,oldText:s}}insertText(t,e){const s={start:t,end:t};return this.replaceRange(s,e)}deleteRange(t){return this.replaceRange(t,"")}positionToOffset(t){let e=0;for(let s=0;s<t.line;s++)e+=this.getLine(s).length+1;return e+=t.column,e}offsetToPosition(t){let e=t;for(let s=0;s<this.getLineCount();s++){const i=this.getLine(s).length;if(e<=i)return{line:s,column:e};e-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(t){return!(t.line<0||t.line>=this.getLineCount()||t.column<0||t.column>this.getLine(t.line).length)}isValidRange(t){return this.isValidPosition(t.start)&&this.isValidPosition(t.end)}getVersion(){return this._version}clone(){const t=new M;return t._lines=[...this._lines],t._version=this._version,t}}class I{constructor(t){this.gutterWidth=50,this.lineHeight=21,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.virtualMarkerRegex=/[\u200B\uE000]/,this.container=t,this.createDOM()}createDOM(){this.container.innerHTML="";const t=document.createElement("div");this.editorContainer=t,t.setAttribute("data-lce-editor-container","true"),t.style.cssText=`
position: relative;

@@ -50,7 +50,7 @@ display: flex;

`))}getCursorPosition(){const t=window.getSelection();if(!t||t.rangeCount===0)return{line:0,column:0};const e=t.getRangeAt(0),s=e.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(e.endContainer,e.endOffset);const n=s.toString().replace(/\u200B/g,"").split(`
`);return{line:n.length-1,column:n[n.length-1].length}}setCursorPosition(t){const s=this.getText().split(`
`),i=Math.min(t.line,s.length-1),n=Math.min(t.column,s[i]?.length||0);let r=0;for(let h=0;h<i;h++)r+=s[h].length+1;r+=n;const l=document.createRange(),o=window.getSelection(),c=this.resolveOffsetToDomPoint(r);if(c)try{l.setStart(c.node,c.offset),l.setEnd(c.node,c.offset),o?.removeAllRanges(),o?.addRange(l),this.ensureCaretVisible()}catch(h){console.warn("Could not set cursor position:",h)}else{const h=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`);try{h&&h.parentNode===this.contentElement?l.setStartBefore(h):(l.selectNodeContents(this.contentElement),l.collapse(!1)),l.collapse(!0),o?.removeAllRanges(),o?.addRange(l),this.ensureCaretVisible()}catch(a){console.warn("Could not set fallback cursor position:",a)}}}getSelectionRange(){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;const e=t.getRangeAt(0),s=e.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(e.startContainer,e.startOffset);const n=s.toString().replace(/\u200B/g,"").split(`
`);return{line:n.length-1,column:n[n.length-1].length}}setCursorPosition(t){var h;const s=this.getText().split(`
`),i=Math.min(t.line,s.length-1),n=Math.min(t.column,((h=s[i])==null?void 0:h.length)||0);let r=0;for(let a=0;a<i;a++)r+=s[a].length+1;r+=n;const l=document.createRange(),o=window.getSelection(),c=this.resolveOffsetToDomPoint(r);if(c)try{l.setStart(c.node,c.offset),l.setEnd(c.node,c.offset),o==null||o.removeAllRanges(),o==null||o.addRange(l),this.ensureCaretVisible()}catch(a){console.warn("Could not set cursor position:",a)}else{const a=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`);try{a&&a.parentNode===this.contentElement?l.setStartBefore(a):(l.selectNodeContents(this.contentElement),l.collapse(!1)),l.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(l),this.ensureCaretVisible()}catch(u){console.warn("Could not set fallback cursor position:",u)}}}getSelectionRange(){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;const e=t.getRangeAt(0),s=e.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(e.startContainer,e.startOffset);const n=s.toString().replace(/\u200B/g,"").split(`
`),r=e.cloneRange();r.selectNodeContents(this.contentElement),r.setEnd(e.endContainer,e.endOffset);const o=r.toString().replace(/\u200B/g,"").split(`
`);return{start:{line:n.length-1,column:n[n.length-1].length},end:{line:o.length-1,column:o[o.length-1].length}}}setSelectionRange(t){const s=this.getText().split(`
`),i=u=>{const f=Math.max(0,Math.min(u.line,s.length-1)),d=Math.max(0,Math.min(u.column,s[f]?s[f].length:0));let g=0;for(let m=0;m<f;m++)g+=s[m].length+1;return g+d},n=i(t.start),r=i(t.end),[l,o]=n<=r?[n,r]:[r,n],c=this.resolveOffsetToDomPoint(l),h=this.resolveOffsetToDomPoint(o);if(!c||!h)return;const a=document.createRange();try{a.setStart(c.node,c.offset),a.setEnd(h.node,h.offset);const u=window.getSelection();u?.removeAllRanges(),u?.addRange(a),this.ensureCaretVisible()}catch(u){console.warn("Could not set selection range:",u)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(t){this.contentElement.contentEditable=t?"false":"true"}applyTheme(t){Object.entries(t).forEach(([e,s])=>{this.container.style.setProperty(`--${e}`,s)})}scrollToPosition(t){const e=this.lineNumbersElement.children[t.line];e&&e.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(t){this.editorContainer.scrollTop=t}syncTrailingNewlineMarker(t){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(s=>s.remove()),!t)return;const e=document.createElement("span");e.setAttribute(this.trailingNewlineMarkerAttr,"true"),e.setAttribute("aria-hidden","true"),e.contentEditable="false",e.style.cssText=`
`),i=u=>{const f=Math.max(0,Math.min(u.line,s.length-1)),d=Math.max(0,Math.min(u.column,s[f]?s[f].length:0));let g=0;for(let p=0;p<f;p++)g+=s[p].length+1;return g+d},n=i(t.start),r=i(t.end),[l,o]=n<=r?[n,r]:[r,n],c=this.resolveOffsetToDomPoint(l),h=this.resolveOffsetToDomPoint(o);if(!c||!h)return;const a=document.createRange();try{a.setStart(c.node,c.offset),a.setEnd(h.node,h.offset);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(a),this.ensureCaretVisible()}catch(u){console.warn("Could not set selection range:",u)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(t){this.contentElement.contentEditable=t?"false":"true"}applyTheme(t){Object.entries(t).forEach(([e,s])=>{this.container.style.setProperty(`--${e}`,s)})}scrollToPosition(t){const e=this.lineNumbersElement.children[t.line];e&&e.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(t){this.editorContainer.scrollTop=t}syncTrailingNewlineMarker(t){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(s=>s.remove()),!t)return;const e=document.createElement("span");e.setAttribute(this.trailingNewlineMarkerAttr,"true"),e.setAttribute("aria-hidden","true"),e.contentEditable="false",e.style.cssText=`
display: inline-block;

@@ -61,36 +61,36 @@ width: 0;

user-select: none;
`,e.appendChild(document.createTextNode("​")),this.contentElement.appendChild(e)}ensureCaretVisible(){const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0).cloneRange();e.collapse(!1);let s=e.getClientRects()[0]||e.getBoundingClientRect();if((!s||s.width===0&&s.height===0)&&t.focusNode instanceof Element?s=t.focusNode.getBoundingClientRect():(!s||s.width===0&&s.height===0)&&t.focusNode?.parentElement&&(s=t.focusNode.parentElement.getBoundingClientRect()),!s)return;const i=this.editorContainer.getBoundingClientRect(),n=12;s.bottom>i.bottom-n?this.editorContainer.scrollTop+=s.bottom-(i.bottom-n):s.top<i.top+n&&(this.editorContainer.scrollTop-=i.top+n-s.top)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(t){const e=Math.max(0,t);let s=0;const i=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let n=null,r;for(;r=i.nextNode();){if(r.parentElement?.hasAttribute(this.trailingNewlineMarkerAttr))continue;n=r;const o=r.textContent||"",c=this.buildVisibleToDomMap(o),h=Math.max(0,c.length-1);if(s+h>=e){const a=Math.max(0,e-s),u=c[a]??o.length;return{node:r,offset:u}}s+=h}if(n){const l=n.textContent?.length||0;return{node:n,offset:l}}return null}buildVisibleToDomMap(t){const e=[0];let s=0;for(let i=0;i<t.length;i++){const n=t[i];this.virtualMarkerRegex.test(n)||(s+=1,e[s]=i+1)}return e}}const S=class S{constructor(t,e={}){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.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...e},this.textModel=new C(this.config.value),this.view=new I(t),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(s=>this.addExtension(s)),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("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const t=this.view.getContentElement();t.addEventListener("input",()=>{const e=this.view.getText(),s=this.textModel.getText();if(e!==s){if(!this.suppressHistory){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end)),this.undoStack.push({text:s,cursorOffset:n,anchorOffset:l,focusOffset:o}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}this.textModel.setText(e),this.view.syncTrailingNewlineMarkerForText(e),this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{const i=this.view.getText();i!==this.textModel.getText()&&this.textModel.setText(i),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:s}])}}),t.addEventListener("selectionchange",()=>{const e=this.getCursor(),s=this.getSelection();this.emit("cursor",e),s&&this.emit("selection",s)}),t.addEventListener("keydown",e=>{if(this.emit("keydown",e),e.key==="Tab"){this.config.readOnly||this.insertTab(),e.preventDefault(),e.stopPropagation();return}if(e.key==="Enter"){if(!this.config.readOnly){const s=window.getSelection();if(s&&s.rangeCount>0){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end));const c=r&&l!==void 0&&o!==void 0?Math.min(l,o):n;this.suppressHistory||(this.undoStack.push({text:this.textModel.getText(),cursorOffset:n,anchorOffset:l,focusOffset:o}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0);const h=s.getRangeAt(0);h.deleteContents();const a=document.createTextNode(`
`);h.insertNode(a),h.setStartAfter(a),h.collapse(!0),s.removeAllRanges(),s.addRange(h),this.view.ensureCaretVisible();const u=this.view.getText();this.textModel.setText(u),this.view.syncTrailingNewlineMarkerForText(u);const f=Math.min(c+1,this.textModel.getText().length);try{const d=this.textModel.offsetToPosition(f);this.setCursor(d),this.view.ensureCaretVisible()}catch{}this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{this.renderTextWithHighlight(this.textModel.getText(),!1),requestAnimationFrame(()=>{try{const d=this.textModel.offsetToPosition(f);this.setCursor(d),this.view.ensureCaretVisible()}catch{}}),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:this.getValue(),oldText:""}])}}e.preventDefault(),e.stopPropagation();return}for(const s of this.extensions.values())if(s.onKeyDown&&s.onKeyDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("mousedown",e=>{this.emit("mousedown",e);for(const s of this.extensions.values())if(s.onMouseDown&&s.onMouseDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("focus",()=>{this.emit("focus")}),t.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const t=this.textModel.getLineCount();this.view.updateLineNumbers(t)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(t,...e){const s=this.eventListeners.get(t);s&&s.forEach(i=>i(...e))}getValue(){return this.textModel.getText()}setValue(t){const e=this.textModel.getText();this.textModel.setText(t),this.renderTextWithHighlight(t,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:t,oldText:e}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){const t=this.view.getCursorPosition();return{position:t,anchor:t}}setCursor(t){this.view.setCursorPosition(t),this.emit("cursor",this.getCursor())}getSelection(){return this.view.getSelectionRange()}setSelection(t){this.view.setSelectionRange(t),this.emit("selection",t)}setTheme(t){this.currentTheme=t;const e={"editor-background":t==="dark"?"#1e1e1e":"#ffffff","editor-foreground":t==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":t==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":t==="dark"?"#858585":"#666666","editor-gutter-border":t==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(e);const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.setTheme=="function")try{s.setTheme(t==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(t){this.config.readOnly=t,this.view.setReadOnly(t)}addExtension(t){if(this.extensions.has(t.name))throw new Error(`Extension '${t.name}' already exists`);this.extensions.set(t.name,t),t.setup(this),t.name==="syntax-highlighting"&&typeof t.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(t){const e=this.extensions.get(t);e&&e.destroy&&e.destroy(),this.extensions.delete(t)}executeCommand(t,...e){const s=this.commands.get(t);s?s(this,...e):console.warn(`Command '${t}' not found`)}registerCommand(t,e){this.commands.set(t,e)}search(t,e={}){if(!t)return[];const s={query:t,caseSensitive:!1,wholeWord:!1,regex:!1,...e},i=[],n=this.textModel.getText(),{normalizedText:r,normalizedToRawOffsets:l}=this.buildSearchTextAndOffsetMap(n),o=s.caseSensitive?r:r.toLowerCase(),c=s.caseSensitive?t:t.toLowerCase();if(s.regex){let h;try{h=new RegExp(t,s.caseSensitive?"g":"gi")}catch{return[]}let a;for(;(a=h.exec(r))!==null;){const u=a[0]??"";if(u.length===0){h.lastIndex=a.index+1;continue}const f=a.index,d=a.index+u.length;s.wholeWord&&!this.isWholeWordBoundary(r,f,d)||this.pushSearchResultFromOffsets(i,f,d,r,l)}}else{let h=0,a=o.indexOf(c,h);for(;a!==-1;){const u=a+c.length;!s.wholeWord||this.isWholeWordBoundary(r,a,u)?(this.pushSearchResultFromOffsets(i,a,u,r,l),h=u):h=a+1,a=o.indexOf(c,h)}}return i}pushSearchResultFromOffsets(t,e,s,i,n){const r=n[e]??e,l=n[s]??r,o=this.textModel.offsetToPosition(r),c=this.textModel.offsetToPosition(l);t.push({range:{start:o,end:c},match:i.substring(e,s)})}isWholeWordBoundary(t,e,s){const i=e>0?t[e-1]:"",n=s<t.length?t[s]:"";return!this.isWordChar(i)&&!this.isWordChar(n)}isWordChar(t){return/^[A-Za-z0-9_]$/.test(t)}buildSearchTextAndOffsetMap(t){const e=[],s=[0];let i=0;for(let n=0;n<t.length;n++){const r=t[n];r==="​"||r===S.CURSOR_SENTINEL||(e.push(r),i+=1,s[i]=n+1)}return s[i]=t.length,{normalizedText:e.join(""),normalizedToRawOffsets:s}}replace(t,e){const s=this.getValue();if(!this.suppressHistory){const n=this.getCursor().position,r=this.textModel.positionToOffset(n),l=this.getSelection();let o,c;l&&(o=this.textModel.positionToOffset(l.start),c=this.textModel.positionToOffset(l.end)),this.undoStack.push({text:s,cursorOffset:r,anchorOffset:o,focusOffset:c}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}const i=this.textModel.replaceRange(t,e);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(t,e,s={}){const i=this.search(t,s);let n=0;for(let r=i.length-1;r>=0;r--)this.replace(i[r].range,e),n++;return n}fold(t){const e={start:t.start,end:t.end,collapsed:!0,level:0};this.folds.push(e)}unfold(t){this.folds=this.folds.filter(e=>!(e.start.line===t.start.line&&e.end.line===t.end.line))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(t,e=!0){const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.highlightHTML=="function")try{const i=!e&&!this.expectingProgrammaticCursor;let n,r,l,o;if(e||i){n=this.getSelection();const u=this.getCollapsedSelectionOffsetInEditor();if(u!==void 0)r=u;else{const f=this.getCursor().position;r=this.textModel.positionToOffset(f)}n&&(l=this.textModel.positionToOffset(n.start),o=this.textModel.positionToOffset(n.end))}const c=(e||i)&&!n&&r!==void 0&&this.hasCollapsedSelectionInEditor(),h=c?this.insertSentinelAtOffset(t,r):t,a=s.highlightHTML(h);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(a):this.view.setHTML(a),this.view.syncTrailingNewlineMarkerForText(t),(e||i)&&requestAnimationFrame(()=>{try{if(c&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(n&&(l!==void 0||o!==void 0)){const u=l!==void 0?l:r,f=o!==void 0?o:r,d=Math.min(u,f),g=Math.max(u,f),m=this.textModel.offsetToPosition(d),x=this.textModel.offsetToPosition(g);this.view.setSelectionRange({start:m,end:x})}else if(r!==void 0){const u=this.textModel.offsetToPosition(r);this.view.setCursorPosition(u)}}catch{}});return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(t)}hasCollapsedSelectionInEditor(){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;const e=t.getRangeAt(0);return this.view.getContentElement().contains(e.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;const e=t.getRangeAt(0),s=this.view.getContentElement();if(!s.contains(e.commonAncestorContainer))return;const i=e.cloneRange();return i.selectNodeContents(s),i.setEnd(e.endContainer,e.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(t){return t.replace(/\u200B/g,"").split(S.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(t,e){const s=Math.max(0,Math.min(e,t.length));return t.slice(0,s)+S.CURSOR_SENTINEL+t.slice(s)}restoreCursorFromSentinel(){const t=this.view.getContentElement(),e=window.getSelection(),s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let i=s.nextNode(),n=null,r=0;for(;i;){const l=i.textContent??"",o=l.indexOf(S.CURSOR_SENTINEL);o!==-1&&(n||(n=i,r=o),i.textContent=l.split(S.CURSOR_SENTINEL).join("")),i=s.nextNode()}if(!n||!e)return!1;try{const l=document.createRange();return l.setStart(n,r),l.collapse(!0),e.removeAllRanges(),e.addRange(l),!0}catch{return!1}}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;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 t=this.undoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.redoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,r=t.focusOffset!==void 0?t.focusOffset:i,l=Math.min(n,r),o=Math.max(n,r),c=this.textModel.offsetToPosition(l),h=this.textModel.offsetToPosition(o);this.setSelection({start:c,end:h})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const t=this.redoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.undoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,r=t.focusOffset!==void 0?t.focusOffset:i,l=Math.min(n,r),o=Math.max(n,r),c=this.textModel.offsetToPosition(l),h=this.textModel.offsetToPosition(o);this.setSelection({start:c,end:h})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=" ".repeat(this.config.tabSize||2),i=this.textModel.insertText(t,s),n=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+s.length);if(!this.suppressHistory){const r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:l,focusOffset:o}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(n),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[i])}insertNewLine(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=this.textModel.insertText(t,`
`),i=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+1);if(!this.suppressHistory){const n=this.getSelection();let r,l;n&&(r=this.textModel.positionToOffset(n.start),l=this.textModel.positionToOffset(n.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:r,focusOffset:l}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(i),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[s])}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){if(!this.eventListeners.has(t))return;const s=this.eventListeners.get(t);if(e){const i=s.indexOf(e);i!==-1&&s.splice(i,1)}else s.length=0}};S.CURSOR_SENTINEL="";let M=S;class N{constructor(t){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=t||this.getDefaultKeymap()}setup(t){this.editor=t}handleKeyDown(t){if(!this.editor)return;const e=this.findMatchingBinding(t);if(e)return this.editor.executeCommand(e.command),t.preventDefault(),t.stopPropagation(),!1}findMatchingBinding(t){const{key:e,ctrlKey:s,altKey:i,shiftKey:n,metaKey:r}=t,l=String(e).toLowerCase(),o=this.keymap[l];if(!o)return null;for(const c of o){const h=c.ctrlKey===void 0||c.ctrlKey===s,a=c.altKey===void 0||c.altKey===i,u=c.shiftKey===void 0||c.shiftKey===n,f=c.metaKey===void 0||c.metaKey===r;if(h&&a&&u&&f)return c}return null}onKeyDown(t){return this.handleKeyDown(t)}getDefaultKeymap(){const t={};return this.addBinding(t,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(t,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(t,"f3",{},"findNext"),this.addBinding(t,"f3",{shiftKey:!0},"findPrev"),this.addBinding(t,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(t,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(t,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(t,"s",{ctrlKey:!0},"save"),this.addBinding(t,"s",{metaKey:!0},"save"),this.addBinding(t,"z",{ctrlKey:!0},"undo"),this.addBinding(t,"z",{metaKey:!0},"undo"),this.addBinding(t,"y",{ctrlKey:!0},"redo"),this.addBinding(t,"y",{metaKey:!0},"redo"),this.addBinding(t,"z",{ctrlKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"z",{metaKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"tab",{},"insertTab"),this.addBinding(t,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),t}addBinding(t,e,s,i){const n=e.toLowerCase();t[n]||(t[n]=[]),t[n].push({key:n,command:i,...s})}setKeymap(t){this.keymap={...t}}addKeyBinding(t){const e=t.key.toLowerCase();this.keymap[e]||(this.keymap[e]=[]),this.keymap[e]=this.keymap[e].filter(s=>s.command!==t.command),this.keymap[e].push({...t,key:e})}removeKeyBinding(t,e){const s=t.toLowerCase();e?this.keymap[s]&&(this.keymap[s]=this.keymap[s].filter(i=>i.command!==e),this.keymap[s].length===0&&delete this.keymap[s]):delete this.keymap[s]}getKeymap(){return{...this.keymap}}getBindingsForCommand(t){const e=[];for(const s in this.keymap)for(const i of this.keymap[s])i.command===t&&e.push({...i});return e}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class H{constructor(){this.name="transaction",this.transactions=[]}setup(t){t.on("change",e=>{const s={changes:e,selection:t.getSelection(),effects:[],annotations:[]};this.transactions.push(s)})}getTransactions(){return this.transactions}destroy(){this.transactions=[]}}class A{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(t){this.editor=t,this.createLineNumbers(),t.registerCommand("toggleLineNumbers",()=>{this.toggle()}),t.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView().getLineNumbersElement();e&&(this.lineNumbersElement=e)}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const t=this.editor.getValue().split(`
`).length,e=Array.from({length:Math.max(t,20)},(s,i)=>i+1);this.lineNumbersElement.innerHTML=e.map(s=>`<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("")}toggle(){if(!this.editor)return;this.isEnabled=!this.isEnabled,this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"block":"none");const t=this.editor.getView().getContentElement();t&&(t.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement=null,this.editor=null}}class P{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(t){this.editor=t,t.registerCommand("setTheme",e=>{this.setTheme(e)}),t.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(t){this.editor&&(this.currentTheme=t,this.editor.setTheme(t))}toggleTheme(){const t=this.currentTheme==="dark"?"light":"dark";this.setTheme(t)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class B{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(t){this.editor=t,t.registerCommand("setReadOnly",e=>{this.setReadOnly(e)}),t.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),t.on("keydown",e=>{if(e.ctrlKey&&e.key==="r")return e.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(t){this.editor&&(this.isReadOnly=t,this.editor.setReadOnly(t))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}let V=0;const p=class p{constructor(t={}){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=++V,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,...t}}setup(t){this.editor=t,this.hasCustomHighlightSupport=this.detectCustomHighlightSupport(),this.hasCustomHighlightSupport&&this.ensureHighlightStyles(),t.registerCommand("find",()=>{this.showSearch()}),t.registerCommand("findNext",()=>{this.findNext()}),t.registerCommand("findPrev",()=>{this.findPrev()}),t.registerCommand("replace",()=>{this.showReplace()}),t.registerCommand("replaceAll",(e,s)=>{this.replaceAll(e,s)}),this.editorChangeHandler=()=>{!this.isVisible||!this.currentQuery||this.scheduleLiveRefresh(!0)},t.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 t=this.editor.getView().getContentElement(),e=t.closest(this.editorContainerSelector),s=t.closest(".rte-source-editor-modal")||e||t.parentElement;if(!s)return;window.getComputedStyle(s).position==="static"&&(s.style.position="relative"),this.searchUI=document.createElement("div"),this.searchUI.className=p.css.root,this.searchUI.style.display="none",this.searchUI.innerHTML=`
<div class="${p.css.row}">
<input type="text" class="${p.css.findInput} ${p.css.inputBase}" placeholder="Find..." />
<button class="${p.css.prevButton} ${p.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
<button class="${p.css.nextButton} ${p.css.buttonBase}" type="button" aria-label="Next match">↓</button>
<button class="${p.css.closeButton} ${p.css.buttonBase}" type="button" aria-label="Close search">×</button>
`,e.appendChild(document.createTextNode("​")),this.contentElement.appendChild(e)}ensureCaretVisible(){var r;const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0).cloneRange();e.collapse(!1);let s=e.getClientRects()[0]||e.getBoundingClientRect();if((!s||s.width===0&&s.height===0)&&t.focusNode instanceof Element?s=t.focusNode.getBoundingClientRect():(!s||s.width===0&&s.height===0)&&((r=t.focusNode)!=null&&r.parentElement)&&(s=t.focusNode.parentElement.getBoundingClientRect()),!s)return;const i=this.editorContainer.getBoundingClientRect(),n=12;s.bottom>i.bottom-n?this.editorContainer.scrollTop+=s.bottom-(i.bottom-n):s.top<i.top+n&&(this.editorContainer.scrollTop-=i.top+n-s.top)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(t){var l;const e=Math.max(0,t);let s=0;const i=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let n=null,r;for(;r=i.nextNode();){const o=r.parentElement;if(o!=null&&o.hasAttribute(this.trailingNewlineMarkerAttr))continue;n=r;const c=r.textContent||"",h=this.buildVisibleToDomMap(c),a=Math.max(0,h.length-1);if(s+a>=e){const u=Math.max(0,e-s),f=h[u]??c.length;return{node:r,offset:f}}s+=a}if(n){const o=((l=n.textContent)==null?void 0:l.length)||0;return{node:n,offset:o}}return null}buildVisibleToDomMap(t){const e=[0];let s=0;for(let i=0;i<t.length;i++){const n=t[i];this.virtualMarkerRegex.test(n)||(s+=1,e[s]=i+1)}return e}}const N=class b{constructor(t,e={}){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.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...e},this.textModel=new M(this.config.value),this.view=new I(t),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(s=>this.addExtension(s)),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("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const t=this.view.getContentElement();t.addEventListener("input",()=>{const e=this.view.getText(),s=this.textModel.getText();if(e!==s){if(!this.suppressHistory){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end)),this.undoStack.push({text:s,cursorOffset:n,anchorOffset:l,focusOffset:o}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}this.textModel.setText(e),this.view.syncTrailingNewlineMarkerForText(e),this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{const i=this.view.getText();i!==this.textModel.getText()&&this.textModel.setText(i),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:s}])}}),t.addEventListener("selectionchange",()=>{const e=this.getCursor(),s=this.getSelection();this.emit("cursor",e),s&&this.emit("selection",s)}),t.addEventListener("keydown",e=>{if(this.emit("keydown",e),e.key==="Tab"){this.config.readOnly||this.insertTab(),e.preventDefault(),e.stopPropagation();return}if(e.key==="Enter"){if(!this.config.readOnly){const s=window.getSelection();if(s&&s.rangeCount>0){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end));const c=r&&l!==void 0&&o!==void 0?Math.min(l,o):n;this.suppressHistory||(this.undoStack.push({text:this.textModel.getText(),cursorOffset:n,anchorOffset:l,focusOffset:o}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0);const h=s.getRangeAt(0);h.deleteContents();const a=document.createTextNode(`
`);h.insertNode(a),h.setStartAfter(a),h.collapse(!0),s.removeAllRanges(),s.addRange(h),this.view.ensureCaretVisible();const u=this.view.getText();this.textModel.setText(u),this.view.syncTrailingNewlineMarkerForText(u);const f=Math.min(c+1,this.textModel.getText().length);try{const d=this.textModel.offsetToPosition(f);this.setCursor(d),this.view.ensureCaretVisible()}catch{}this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{this.renderTextWithHighlight(this.textModel.getText(),!1),requestAnimationFrame(()=>{try{const d=this.textModel.offsetToPosition(f);this.setCursor(d),this.view.ensureCaretVisible()}catch{}}),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:this.getValue(),oldText:""}])}}e.preventDefault(),e.stopPropagation();return}for(const s of this.extensions.values())if(s.onKeyDown&&s.onKeyDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("mousedown",e=>{this.emit("mousedown",e);for(const s of this.extensions.values())if(s.onMouseDown&&s.onMouseDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("focus",()=>{this.emit("focus")}),t.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const t=this.textModel.getLineCount();this.view.updateLineNumbers(t)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(t,...e){const s=this.eventListeners.get(t);s&&s.forEach(i=>i(...e))}getValue(){return this.textModel.getText()}setValue(t){const e=this.textModel.getText();this.textModel.setText(t),this.renderTextWithHighlight(t,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:t,oldText:e}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){const t=this.view.getCursorPosition();return{position:t,anchor:t}}setCursor(t){this.view.setCursorPosition(t),this.emit("cursor",this.getCursor())}getSelection(){return this.view.getSelectionRange()}setSelection(t){this.view.setSelectionRange(t),this.emit("selection",t)}setTheme(t){this.currentTheme=t;const e={"editor-background":t==="dark"?"#1e1e1e":"#ffffff","editor-foreground":t==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":t==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":t==="dark"?"#858585":"#666666","editor-gutter-border":t==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(e);const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.setTheme=="function")try{s.setTheme(t==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(t){this.config.readOnly=t,this.view.setReadOnly(t)}addExtension(t){if(this.extensions.has(t.name))throw new Error(`Extension '${t.name}' already exists`);this.extensions.set(t.name,t),t.setup(this),t.name==="syntax-highlighting"&&typeof t.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(t){const e=this.extensions.get(t);e&&e.destroy&&e.destroy(),this.extensions.delete(t)}executeCommand(t,...e){const s=this.commands.get(t);s?s(this,...e):console.warn(`Command '${t}' not found`)}registerCommand(t,e){this.commands.set(t,e)}search(t,e={}){if(!t)return[];const s={query:t,caseSensitive:!1,wholeWord:!1,regex:!1,...e},i=[],n=this.textModel.getText(),{normalizedText:r,normalizedToRawOffsets:l}=this.buildSearchTextAndOffsetMap(n),o=s.caseSensitive?r:r.toLowerCase(),c=s.caseSensitive?t:t.toLowerCase();if(s.regex){let h;try{h=new RegExp(t,s.caseSensitive?"g":"gi")}catch{return[]}let a;for(;(a=h.exec(r))!==null;){const u=a[0]??"";if(u.length===0){h.lastIndex=a.index+1;continue}const f=a.index,d=a.index+u.length;s.wholeWord&&!this.isWholeWordBoundary(r,f,d)||this.pushSearchResultFromOffsets(i,f,d,r,l)}}else{let h=0,a=o.indexOf(c,h);for(;a!==-1;){const u=a+c.length;!s.wholeWord||this.isWholeWordBoundary(r,a,u)?(this.pushSearchResultFromOffsets(i,a,u,r,l),h=u):h=a+1,a=o.indexOf(c,h)}}return i}pushSearchResultFromOffsets(t,e,s,i,n){const r=n[e]??e,l=n[s]??r,o=this.textModel.offsetToPosition(r),c=this.textModel.offsetToPosition(l);t.push({range:{start:o,end:c},match:i.substring(e,s)})}isWholeWordBoundary(t,e,s){const i=e>0?t[e-1]:"",n=s<t.length?t[s]:"";return!this.isWordChar(i)&&!this.isWordChar(n)}isWordChar(t){return/^[A-Za-z0-9_]$/.test(t)}buildSearchTextAndOffsetMap(t){const e=[],s=[0];let i=0;for(let n=0;n<t.length;n++){const r=t[n];r==="​"||r===b.CURSOR_SENTINEL||(e.push(r),i+=1,s[i]=n+1)}return s[i]=t.length,{normalizedText:e.join(""),normalizedToRawOffsets:s}}replace(t,e){const s=this.getValue();if(!this.suppressHistory){const n=this.getCursor().position,r=this.textModel.positionToOffset(n),l=this.getSelection();let o,c;l&&(o=this.textModel.positionToOffset(l.start),c=this.textModel.positionToOffset(l.end)),this.undoStack.push({text:s,cursorOffset:r,anchorOffset:o,focusOffset:c}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}const i=this.textModel.replaceRange(t,e);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(t,e,s={}){const i=this.search(t,s);let n=0;for(let r=i.length-1;r>=0;r--)this.replace(i[r].range,e),n++;return n}fold(t){const e={start:t.start,end:t.end,collapsed:!0,level:0};this.folds.push(e)}unfold(t){this.folds=this.folds.filter(e=>!(e.start.line===t.start.line&&e.end.line===t.end.line))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(t,e=!0){const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.highlightHTML=="function")try{const i=!e&&!this.expectingProgrammaticCursor;let n,r,l,o;if(e||i){n=this.getSelection();const u=this.getCollapsedSelectionOffsetInEditor();if(u!==void 0)r=u;else{const f=this.getCursor().position;r=this.textModel.positionToOffset(f)}n&&(l=this.textModel.positionToOffset(n.start),o=this.textModel.positionToOffset(n.end))}const c=(e||i)&&!n&&r!==void 0&&this.hasCollapsedSelectionInEditor(),h=c?this.insertSentinelAtOffset(t,r):t,a=s.highlightHTML(h);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(a):this.view.setHTML(a),this.view.syncTrailingNewlineMarkerForText(t),(e||i)&&requestAnimationFrame(()=>{try{if(c&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(n&&(l!==void 0||o!==void 0)){const u=l!==void 0?l:r,f=o!==void 0?o:r,d=Math.min(u,f),g=Math.max(u,f),p=this.textModel.offsetToPosition(d),x=this.textModel.offsetToPosition(g);this.view.setSelectionRange({start:p,end:x})}else if(r!==void 0){const u=this.textModel.offsetToPosition(r);this.view.setCursorPosition(u)}}catch{}});return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(t)}hasCollapsedSelectionInEditor(){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;const e=t.getRangeAt(0);return this.view.getContentElement().contains(e.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;const e=t.getRangeAt(0),s=this.view.getContentElement();if(!s.contains(e.commonAncestorContainer))return;const i=e.cloneRange();return i.selectNodeContents(s),i.setEnd(e.endContainer,e.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(t){return t.replace(/\u200B/g,"").split(b.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(t,e){const s=Math.max(0,Math.min(e,t.length));return t.slice(0,s)+b.CURSOR_SENTINEL+t.slice(s)}restoreCursorFromSentinel(){const t=this.view.getContentElement(),e=window.getSelection(),s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let i=s.nextNode(),n=null,r=0;for(;i;){const l=i.textContent??"",o=l.indexOf(b.CURSOR_SENTINEL);o!==-1&&(n||(n=i,r=o),i.textContent=l.split(b.CURSOR_SENTINEL).join("")),i=s.nextNode()}if(!n||!e)return!1;try{const l=document.createRange();return l.setStart(n,r),l.collapse(!0),e.removeAllRanges(),e.addRange(l),!0}catch{return!1}}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;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 t=this.undoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.redoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,r=t.focusOffset!==void 0?t.focusOffset:i,l=Math.min(n,r),o=Math.max(n,r),c=this.textModel.offsetToPosition(l),h=this.textModel.offsetToPosition(o);this.setSelection({start:c,end:h})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const t=this.redoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.undoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,r=t.focusOffset!==void 0?t.focusOffset:i,l=Math.min(n,r),o=Math.max(n,r),c=this.textModel.offsetToPosition(l),h=this.textModel.offsetToPosition(o);this.setSelection({start:c,end:h})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=" ".repeat(this.config.tabSize||2),i=this.textModel.insertText(t,s),n=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+s.length);if(!this.suppressHistory){const r=this.getSelection();let l,o;r&&(l=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:l,focusOffset:o}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(n),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[i])}insertNewLine(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=this.textModel.insertText(t,`
`),i=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+1);if(!this.suppressHistory){const n=this.getSelection();let r,l;n&&(r=this.textModel.positionToOffset(n.start),l=this.textModel.positionToOffset(n.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:r,focusOffset:l}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(i),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[s])}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){if(!this.eventListeners.has(t))return;const s=this.eventListeners.get(t);if(e){const i=s.indexOf(e);i!==-1&&s.splice(i,1)}else s.length=0}};N.CURSOR_SENTINEL="";let O=N;class ${constructor(t){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=t||this.getDefaultKeymap()}setup(t){this.editor=t}handleKeyDown(t){if(!this.editor)return;const e=this.findMatchingBinding(t);if(e)return this.editor.executeCommand(e.command),t.preventDefault(),t.stopPropagation(),!1}findMatchingBinding(t){const{key:e,ctrlKey:s,altKey:i,shiftKey:n,metaKey:r}=t,l=String(e).toLowerCase(),o=this.keymap[l];if(!o)return null;for(const c of o){const h=c.ctrlKey===void 0||c.ctrlKey===s,a=c.altKey===void 0||c.altKey===i,u=c.shiftKey===void 0||c.shiftKey===n,f=c.metaKey===void 0||c.metaKey===r;if(h&&a&&u&&f)return c}return null}onKeyDown(t){return this.handleKeyDown(t)}getDefaultKeymap(){const t={};return this.addBinding(t,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(t,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(t,"f3",{},"findNext"),this.addBinding(t,"f3",{shiftKey:!0},"findPrev"),this.addBinding(t,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(t,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(t,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(t,"s",{ctrlKey:!0},"save"),this.addBinding(t,"s",{metaKey:!0},"save"),this.addBinding(t,"z",{ctrlKey:!0},"undo"),this.addBinding(t,"z",{metaKey:!0},"undo"),this.addBinding(t,"y",{ctrlKey:!0},"redo"),this.addBinding(t,"y",{metaKey:!0},"redo"),this.addBinding(t,"z",{ctrlKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"z",{metaKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"tab",{},"insertTab"),this.addBinding(t,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),t}addBinding(t,e,s,i){const n=e.toLowerCase();t[n]||(t[n]=[]),t[n].push({key:n,command:i,...s})}setKeymap(t){this.keymap={...t}}addKeyBinding(t){const e=t.key.toLowerCase();this.keymap[e]||(this.keymap[e]=[]),this.keymap[e]=this.keymap[e].filter(s=>s.command!==t.command),this.keymap[e].push({...t,key:e})}removeKeyBinding(t,e){const s=t.toLowerCase();e?this.keymap[s]&&(this.keymap[s]=this.keymap[s].filter(i=>i.command!==e),this.keymap[s].length===0&&delete this.keymap[s]):delete this.keymap[s]}getKeymap(){return{...this.keymap}}getBindingsForCommand(t){const e=[];for(const s in this.keymap)for(const i of this.keymap[s])i.command===t&&e.push({...i});return e}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class P{constructor(){this.name="transaction",this.transactions=[]}setup(t){t.on("change",e=>{const s={changes:e,selection:t.getSelection(),effects:[],annotations:[]};this.transactions.push(s)})}getTransactions(){return this.transactions}destroy(){this.transactions=[]}}class B{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(t){this.editor=t,this.createLineNumbers(),t.registerCommand("toggleLineNumbers",()=>{this.toggle()}),t.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView().getLineNumbersElement();e&&(this.lineNumbersElement=e)}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const t=this.editor.getValue().split(`
`).length,e=Array.from({length:Math.max(t,20)},(s,i)=>i+1);this.lineNumbersElement.innerHTML=e.map(s=>`<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("")}toggle(){if(!this.editor)return;this.isEnabled=!this.isEnabled,this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"block":"none");const t=this.editor.getView().getContentElement();t&&(t.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement=null,this.editor=null}}class V{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(t){this.editor=t,t.registerCommand("setTheme",e=>{this.setTheme(e)}),t.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(t){this.editor&&(this.currentTheme=t,this.editor.setTheme(t))}toggleTheme(){const t=this.currentTheme==="dark"?"light":"dark";this.setTheme(t)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class D{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(t){this.editor=t,t.registerCommand("setReadOnly",e=>{this.setReadOnly(e)}),t.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),t.on("keydown",e=>{if(e.ctrlKey&&e.key==="r")return e.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(t){this.editor&&(this.isReadOnly=t,this.editor.setReadOnly(t))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}let F=0;const H=class m{constructor(t={}){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=++F,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,...t}}setup(t){this.editor=t,this.hasCustomHighlightSupport=this.detectCustomHighlightSupport(),this.hasCustomHighlightSupport&&this.ensureHighlightStyles(),t.registerCommand("find",()=>{this.showSearch()}),t.registerCommand("findNext",()=>{this.findNext()}),t.registerCommand("findPrev",()=>{this.findPrev()}),t.registerCommand("replace",()=>{this.showReplace()}),t.registerCommand("replaceAll",(e,s)=>{this.replaceAll(e,s)}),this.editorChangeHandler=()=>{!this.isVisible||!this.currentQuery||this.scheduleLiveRefresh(!0)},t.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 t=this.editor.getView().getContentElement(),e=t.closest(this.editorContainerSelector),s=t.closest(".rte-source-editor-modal")||e||t.parentElement;if(!s)return;window.getComputedStyle(s).position==="static"&&(s.style.position="relative"),this.searchUI=document.createElement("div"),this.searchUI.className=m.css.root,this.searchUI.style.display="none",this.searchUI.innerHTML=`
<div class="${m.css.row}">
<input type="text" class="${m.css.findInput} ${m.css.inputBase}" placeholder="Find..." />
<button class="${m.css.prevButton} ${m.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
<button class="${m.css.nextButton} ${m.css.buttonBase}" type="button" aria-label="Next match">↓</button>
<button class="${m.css.closeButton} ${m.css.buttonBase}" type="button" aria-label="Close search">×</button>
</div>
<div class="${p.css.options}">
<label class="${p.css.optionLabel}" title="Case sensitive">
<input type="checkbox" class="${p.css.optionInput} ${p.css.caseSensitive}" />
<div class="${m.css.options}">
<label class="${m.css.optionLabel}" title="Case sensitive">
<input type="checkbox" class="${m.css.optionInput} ${m.css.caseSensitive}" />
<span>Aa</span>
</label>
<label class="${p.css.optionLabel}" title="Whole word">
<input type="checkbox" class="${p.css.optionInput} ${p.css.wholeWord}" />
<label class="${m.css.optionLabel}" title="Whole word">
<input type="checkbox" class="${m.css.optionInput} ${m.css.wholeWord}" />
<span>Whole</span>
</label>
<label class="${p.css.optionLabel}" title="Regular expression">
<input type="checkbox" class="${p.css.optionInput} ${p.css.regex}" />
<label class="${m.css.optionLabel}" title="Regular expression">
<input type="checkbox" class="${m.css.optionInput} ${m.css.regex}" />
<span>.*</span>
</label>
</div>
<div class="${p.css.meta}">
<div class="${p.css.status} ${p.css.statusLayout}"></div>
<div class="${p.css.mode} ${p.css.modeLayout}" aria-live="polite"></div>
<div class="${m.css.meta}">
<div class="${m.css.status} ${m.css.statusLayout}"></div>
<div class="${m.css.mode} ${m.css.modeLayout}" aria-live="polite"></div>
</div>
<input type="text" class="${p.css.replaceInput} ${p.css.inputBase} ${p.css.replaceInputLayout}" placeholder="Replace with..." />
`;const i=this.searchUI.querySelector(`.${p.css.findInput}`),n=this.searchUI.querySelector(`.${p.css.replaceInput}`),r=this.searchUI.querySelector(`.${p.css.prevButton}`),l=this.searchUI.querySelector(`.${p.css.nextButton}`),o=this.searchUI.querySelector(`.${p.css.closeButton}`),c=this.searchUI.querySelector(`.${p.css.status}`),h=this.searchUI.querySelector(`.${p.css.mode}`),a=this.searchUI.querySelector(`.${p.css.caseSensitive}`),u=this.searchUI.querySelector(`.${p.css.wholeWord}`),f=this.searchUI.querySelector(`.${p.css.regex}`);this.findInput=i,this.replaceInputEl=n,this.statusDiv=c,this.modeDiv=h,this.caseSensitiveInput=a,this.wholeWordInput=u,this.regexInput=f,a.checked=!!this.searchOptions.caseSensitive,u.checked=!!this.searchOptions.wholeWord,f.checked=!!this.searchOptions.regex,i.addEventListener("input",()=>{this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer);const g=i.value;this.searchDebounceTimer=setTimeout(()=>{this.performSearch(g,!1,!1)},120)});const d=()=>{this.searchOptions.caseSensitive=a.checked,this.searchOptions.wholeWord=u.checked,this.searchOptions.regex=f.checked;const g=i.value;g.trim()?this.performSearch(g,!1,!1):this.performSearch("",!1,!1)};a.addEventListener("change",d),u.addEventListener("change",d),f.addEventListener("change",d),i.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),g.shiftKey?this.findPrev():this.findNext()):g.key==="Escape"&&(g.preventDefault(),this.hideSearch())}),n.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),g.shiftKey?this.replaceAll(i.value,n.value):this.replaceCurrent(i.value,n.value)):g.key==="Escape"&&(g.preventDefault(),this.hideSearch())}),r.addEventListener("click",()=>this.findPrev()),l.addEventListener("click",()=>this.findNext()),o.addEventListener("click",()=>this.hideSearch()),s.appendChild(this.searchUI)}updateModeHint(t){this.modeDiv&&(this.modeDiv.textContent=t?`Replace: move next ${this.config.replaceAndFindNext?"ON":"OFF"}`:"Find mode")}performSearch(t,e,s){if(!this.editor||!t.trim()){this.currentQuery="",this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("");return}if(this.searchOptions.regex&&!this.isValidRegex(t)){this.currentQuery=t,this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Invalid regular expression");return}this.currentQuery=t;const i=this.currentIndex,n=this.editor.search(t,this.searchOptions);if(this.currentResults=n,n.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("No matches");return}e&&i>=0?this.currentIndex=Math.min(i,n.length-1):this.currentIndex=0,this.updateHighlights(s)}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(t,e){if(!this.editor||!t.trim()||((this.currentQuery!==t||this.currentResults.length===0)&&this.performSearch(t,!1,!0),this.currentIndex<0||this.currentResults.length===0))return;const s=this.currentResults[this.currentIndex];if(!s)return;const i=this.computeReplacementRange(s.range.start,e);if(this.editor.replace(s.range,e),this.config.replaceAndFindNext){this.currentQuery=t;const n=this.editor.search(t,this.searchOptions);if(this.currentResults=n,n.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Replaced current occurrence"),this.restoreReplaceInputFocus();return}this.currentIndex=this.findNextResultIndexAfter(i.end,n),this.updateHighlights(!0)}else this.scrollLogicalRangeIntoView(i,!0),this.performSearch(t,!0,!1);this.currentResults.length>0||this.showTransientStatus("Replaced current occurrence"),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}replaceAll(t,e){if(!this.editor||!t.trim())return;const s=this.editor.replaceAll(t,e,this.searchOptions);this.performSearch(t,!1,!1),this.showTransientStatus(`Replaced ${s} occurrence${s===1?"":"s"}`),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}updateHighlights(t){if(this.clearHighlights(),this.currentResults.length===0||this.currentIndex===-1||!this.editor)return;this.applyCustomHighlights();const e=this.currentResults[this.currentIndex];e&&((t||!this.hasCustomHighlightSupport)&&this.navigateToResult(e,!this.hasCustomHighlightSupport),this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}navigateToResult(t,e){if(!this.editor)return;const s=document.activeElement,i=!!s&&(s===this.findInput||s===this.replaceInputEl);e?(this.editor.setSelection(t.range),this.centerCurrentSelectionInView()):this.scrollResultIntoView(t);const n=this.editor.getView();e&&typeof n.ensureCaretVisible=="function"&&n.ensureCaretVisible(),e&&i&&s&&requestAnimationFrame(()=>{this.focusWithoutScrolling(s)})}clearHighlights(){if(this.hasCustomHighlightSupport)try{const t=CSS;t.highlights?.delete(this.highlightMatchName),t.highlights?.delete(this.highlightActiveName)}catch{}}scrollResultIntoView(t){this.scrollLogicalRangeIntoView(t.range,!0)}scrollLogicalRangeIntoView(t,e){if(!this.editor)return;const s=this.editor.getView().getContentElement(),i=this.editor.getValue(),{lineStarts:n,lines:r}=this.buildLineStarts(i),l=this.buildTextNodeIndex(s);if(l.length===0)return;const o=this.toDomRange(t,n,r,l);if(!o)return;const c=o.startContainer.nodeType===Node.TEXT_NODE?o.startContainer.parentElement:o.startContainer,h=this.resolveScrollContainer(s);if(h){const a=o.getClientRects()[0]||o.getBoundingClientRect(),u=h.getBoundingClientRect(),d=h.scrollTop+(a.top-u.top)-u.height/2+a.height/2,g=18;let m=e?d:h.scrollTop,x=h.scrollLeft;const R=h.scrollLeft+(a.left-u.left),v=R+a.width;a.right>u.right-g?x=v-u.width+g:a.left<u.left+g&&(x=Math.max(0,R-g));const E=Math.max(0,h.scrollHeight-h.clientHeight),k=Math.max(0,h.scrollWidth-h.clientWidth);if(m=Math.min(E,Math.max(0,m)),x=Math.min(k,Math.max(0,x)),E===0&&k===0){c?.scrollIntoView({block:e?"center":"nearest",inline:"nearest",behavior:"smooth"});return}(m!==h.scrollTop||x!==h.scrollLeft)&&h.scrollTo({top:m,left:x,behavior:"smooth"});return}c?.scrollIntoView({block:e?"center":"nearest",inline:"nearest",behavior:"smooth"})}restoreReplaceInputFocus(){const t=this.replaceInputEl;!t||t.style.display==="none"||requestAnimationFrame(()=>{this.focusWithoutScrolling(t);const e=t.value.length;try{t.setSelectionRange(e,e)}catch{}})}centerCurrentSelectionInView(){if(!this.editor)return;const t=this.editor.getView().getContentElement(),e=this.resolveScrollContainer(t);if(!e)return;const s=window.getSelection();if(!s||s.rangeCount===0)return;const i=s.getRangeAt(0).cloneRange(),n=i.getClientRects()[0]||i.getBoundingClientRect();if(!n)return;const r=e.getBoundingClientRect(),o=e.scrollTop+(n.top-r.top)-r.height/2+n.height/2,c=Math.max(0,e.scrollHeight-e.clientHeight),h=Math.min(c,Math.max(0,o));h!==e.scrollTop&&e.scrollTo({top:h,behavior:"smooth"})}computeReplacementRange(t,e){const s=e.replace(/\r\n?/g,`
<input type="text" class="${m.css.replaceInput} ${m.css.inputBase} ${m.css.replaceInputLayout}" placeholder="Replace with..." />
`;const i=this.searchUI.querySelector(`.${m.css.findInput}`),n=this.searchUI.querySelector(`.${m.css.replaceInput}`),r=this.searchUI.querySelector(`.${m.css.prevButton}`),l=this.searchUI.querySelector(`.${m.css.nextButton}`),o=this.searchUI.querySelector(`.${m.css.closeButton}`),c=this.searchUI.querySelector(`.${m.css.status}`),h=this.searchUI.querySelector(`.${m.css.mode}`),a=this.searchUI.querySelector(`.${m.css.caseSensitive}`),u=this.searchUI.querySelector(`.${m.css.wholeWord}`),f=this.searchUI.querySelector(`.${m.css.regex}`);this.findInput=i,this.replaceInputEl=n,this.statusDiv=c,this.modeDiv=h,this.caseSensitiveInput=a,this.wholeWordInput=u,this.regexInput=f,a.checked=!!this.searchOptions.caseSensitive,u.checked=!!this.searchOptions.wholeWord,f.checked=!!this.searchOptions.regex,i.addEventListener("input",()=>{this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer);const g=i.value;this.searchDebounceTimer=setTimeout(()=>{this.performSearch(g,!1,!1)},120)});const d=()=>{this.searchOptions.caseSensitive=a.checked,this.searchOptions.wholeWord=u.checked,this.searchOptions.regex=f.checked;const g=i.value;g.trim()?this.performSearch(g,!1,!1):this.performSearch("",!1,!1)};a.addEventListener("change",d),u.addEventListener("change",d),f.addEventListener("change",d),i.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),g.shiftKey?this.findPrev():this.findNext()):g.key==="Escape"&&(g.preventDefault(),this.hideSearch())}),n.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),g.shiftKey?this.replaceAll(i.value,n.value):this.replaceCurrent(i.value,n.value)):g.key==="Escape"&&(g.preventDefault(),this.hideSearch())}),r.addEventListener("click",()=>this.findPrev()),l.addEventListener("click",()=>this.findNext()),o.addEventListener("click",()=>this.hideSearch()),s.appendChild(this.searchUI)}updateModeHint(t){this.modeDiv&&(this.modeDiv.textContent=t?`Replace: move next ${this.config.replaceAndFindNext?"ON":"OFF"}`:"Find mode")}performSearch(t,e,s){if(!this.editor||!t.trim()){this.currentQuery="",this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("");return}if(this.searchOptions.regex&&!this.isValidRegex(t)){this.currentQuery=t,this.currentResults=[],this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Invalid regular expression");return}this.currentQuery=t;const i=this.currentIndex,n=this.editor.search(t,this.searchOptions);if(this.currentResults=n,n.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("No matches");return}e&&i>=0?this.currentIndex=Math.min(i,n.length-1):this.currentIndex=0,this.updateHighlights(s)}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(t,e){if(!this.editor||!t.trim()||((this.currentQuery!==t||this.currentResults.length===0)&&this.performSearch(t,!1,!0),this.currentIndex<0||this.currentResults.length===0))return;const s=this.currentResults[this.currentIndex];if(!s)return;const i=this.computeReplacementRange(s.range.start,e);if(this.editor.replace(s.range,e),this.config.replaceAndFindNext){this.currentQuery=t;const n=this.editor.search(t,this.searchOptions);if(this.currentResults=n,n.length===0){this.currentIndex=-1,this.clearHighlights(),this.updateStatus("Replaced current occurrence"),this.restoreReplaceInputFocus();return}this.currentIndex=this.findNextResultIndexAfter(i.end,n),this.updateHighlights(!0)}else this.scrollLogicalRangeIntoView(i,!0),this.performSearch(t,!0,!1);this.currentResults.length>0||this.showTransientStatus("Replaced current occurrence"),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}replaceAll(t,e){if(!this.editor||!t.trim())return;const s=this.editor.replaceAll(t,e,this.searchOptions);this.performSearch(t,!1,!1),this.showTransientStatus(`Replaced ${s} occurrence${s===1?"":"s"}`),this.restoreReplaceInputFocus(),this.revealActiveResultAfterFocusRestore()}updateHighlights(t){if(this.clearHighlights(),this.currentResults.length===0||this.currentIndex===-1||!this.editor)return;this.applyCustomHighlights();const e=this.currentResults[this.currentIndex];e&&((t||!this.hasCustomHighlightSupport)&&this.navigateToResult(e,!this.hasCustomHighlightSupport),this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}navigateToResult(t,e){if(!this.editor)return;const s=document.activeElement,i=!!s&&(s===this.findInput||s===this.replaceInputEl);e?(this.editor.setSelection(t.range),this.centerCurrentSelectionInView()):this.scrollResultIntoView(t);const n=this.editor.getView();e&&typeof n.ensureCaretVisible=="function"&&n.ensureCaretVisible(),e&&i&&s&&requestAnimationFrame(()=>{this.focusWithoutScrolling(s)})}clearHighlights(){var t,e;if(this.hasCustomHighlightSupport)try{const s=CSS;(t=s.highlights)==null||t.delete(this.highlightMatchName),(e=s.highlights)==null||e.delete(this.highlightActiveName)}catch{}}scrollResultIntoView(t){this.scrollLogicalRangeIntoView(t.range,!0)}scrollLogicalRangeIntoView(t,e){if(!this.editor)return;const s=this.editor.getView().getContentElement(),i=this.editor.getValue(),{lineStarts:n,lines:r}=this.buildLineStarts(i),l=this.buildTextNodeIndex(s);if(l.length===0)return;const o=this.toDomRange(t,n,r,l);if(!o)return;const c=o.startContainer.nodeType===Node.TEXT_NODE?o.startContainer.parentElement:o.startContainer,h=this.resolveScrollContainer(s);if(h){const a=o.getClientRects()[0]||o.getBoundingClientRect(),u=h.getBoundingClientRect(),d=h.scrollTop+(a.top-u.top)-u.height/2+a.height/2,g=18;let p=e?d:h.scrollTop,x=h.scrollLeft;const R=h.scrollLeft+(a.left-u.left),C=R+a.width;a.right>u.right-g?x=C-u.width+g:a.left<u.left+g&&(x=Math.max(0,R-g));const E=Math.max(0,h.scrollHeight-h.clientHeight),k=Math.max(0,h.scrollWidth-h.clientWidth);if(p=Math.min(E,Math.max(0,p)),x=Math.min(k,Math.max(0,x)),E===0&&k===0){c==null||c.scrollIntoView({block:e?"center":"nearest",inline:"nearest",behavior:"smooth"});return}(p!==h.scrollTop||x!==h.scrollLeft)&&h.scrollTo({top:p,left:x,behavior:"smooth"});return}c==null||c.scrollIntoView({block:e?"center":"nearest",inline:"nearest",behavior:"smooth"})}restoreReplaceInputFocus(){const t=this.replaceInputEl;!t||t.style.display==="none"||requestAnimationFrame(()=>{this.focusWithoutScrolling(t);const e=t.value.length;try{t.setSelectionRange(e,e)}catch{}})}centerCurrentSelectionInView(){if(!this.editor)return;const t=this.editor.getView().getContentElement(),e=this.resolveScrollContainer(t);if(!e)return;const s=window.getSelection();if(!s||s.rangeCount===0)return;const i=s.getRangeAt(0).cloneRange(),n=i.getClientRects()[0]||i.getBoundingClientRect();if(!n)return;const r=e.getBoundingClientRect(),o=e.scrollTop+(n.top-r.top)-r.height/2+n.height/2,c=Math.max(0,e.scrollHeight-e.clientHeight),h=Math.min(c,Math.max(0,o));h!==e.scrollTop&&e.scrollTo({top:h,behavior:"smooth"})}computeReplacementRange(t,e){const s=e.replace(/\r\n?/g,`
`),i=s.split(`
`);let n;return i.length<=1?(n={start:t,end:{line:t.line,column:t.column+s.length}},this.clampRangeToDocument(n)):(n={start:t,end:{line:t.line+i.length-1,column:i[i.length-1].length}},this.clampRangeToDocument(n))}findNextResultIndexAfter(t,e){for(let s=0;s<e.length;s++)if(this.comparePositions(e[s].range.start,t)>=0)return s;return 0}comparePositions(t,e){return t.line!==e.line?t.line-e.line:t.column-e.column}clampRangeToDocument(t){const e=this.editor;if(!e)return t;const s=e.getValue().split(`
`),i=Math.max(0,s.length-1),n=Math.max(0,Math.min(t.start.line,i)),r=Math.max(0,Math.min(t.end.line,i)),l=Math.max(0,Math.min(t.start.column,s[n]?.length||0)),o=Math.max(0,Math.min(t.end.column,s[r]?.length||0));return{start:{line:n,column:l},end:{line:r,column:o}}}focusWithoutScrolling(t){try{t.focus({preventScroll:!0})}catch{const e=[];let s=t.parentElement;for(;s;)this.canScroll(s)&&e.push({el:s,top:s.scrollTop,left:s.scrollLeft}),s=s.parentElement;const i=window.scrollX,n=window.scrollY;t.focus();for(let r=0;r<e.length;r++){const l=e[r];l.el.scrollTop=l.top,l.el.scrollLeft=l.left}window.scrollTo(i,n)}}findScrollContainer(t){let e=t;for(;e;){const i=window.getComputedStyle(e).overflowY;if((i==="auto"||i==="scroll")&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}resolveScrollContainer(t){const s=this.editor?.getView()?.getScrollElement?.()||null;return s&&this.canScroll(s)?s:this.findScrollContainer(t)}canScroll(t){return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth}revealActiveResultAfterFocusRestore(){!this.currentResults.length||this.currentIndex<0||requestAnimationFrame(()=>{const t=this.currentResults[this.currentIndex];t&&this.scrollResultIntoView(t)})}applyCustomHighlights(){if(!this.editor||!this.hasCustomHighlightSupport||this.currentResults.length===0)return;const t=this.editor.getView().getContentElement(),e=this.editor.getValue(),{lineStarts:s,lines:i}=this.buildLineStarts(e),n=this.buildTextNodeIndex(t);if(n.length===0)return;const r=this.buildVisibleDocumentText(n),l=[];let o=null;const c=Math.min(this.currentResults.length,this.maxCustomHighlightRanges);for(let h=0;h<c;h++){const a=this.currentResults[h],u=this.searchOptions.regex?a.match||this.currentQuery:this.currentQuery||a.match,f=this.toDomRange(a.range,s,i,n,r,u);f&&(l.push(f),h===this.currentIndex&&(o=f))}if(l.length!==0)try{const h=CSS,a=window.Highlight;if(!h.highlights||!a)return;h.highlights.set(this.highlightMatchName,new a(...l)),o&&h.highlights.set(this.highlightActiveName,new a(o))}catch{}}buildLineStarts(t){const e=t.split(`
`),s=new Array(e.length);let i=0;for(let n=0;n<e.length;n++)s[n]=i,i+=e[n].length+1;return{lineStarts:s,lines:e}}positionToOffset(t,e,s){const i=Math.max(0,Math.min(t.line,s.length-1)),n=Math.max(0,Math.min(t.column,s[i]?.length||0));return e[i]+n}buildTextNodeIndex(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null),s=[];let i=0,n;for(;n=e.nextNode();){const r=n;if(r.parentElement?.hasAttribute(this.trailingMarkerAttr))continue;const o=r.textContent||"",c=this.buildVisibleToDomMap(o),h=Math.max(0,c.length-1);h===0&&o.length===0||(s.push({node:r,start:i,end:i+h,visibleToDom:c}),i+=h)}return s}resolveDomPoint(t,e){const s=Math.max(0,t);for(let n=0;n<e.length;n++){const r=e[n];if(s<=r.end){const l=Math.max(0,s-r.start),o=r.visibleToDom[l]??r.node.textContent?.length??0;return{node:r.node,offset:o}}}const i=e[e.length-1];return i?{node:i.node,offset:i.visibleToDom[i.visibleToDom.length-1]??i.node.textContent?.length??0}:null}toDomRange(t,e,s,i,n,r){const l=this.positionToOffset(t.start,e,s),o=this.positionToOffset(t.end,e,s);let c=Math.min(l,o),h=Math.max(l,o);if(n&&r){const d=r,g=n.slice(c,h);if(g.length===d.length&&g.toLowerCase()!==d.toLowerCase()){const m=this.findNearestMatchOffset(n,d,c);m!==-1&&(c=m,h=m+d.length)}}const a=this.resolveDomPoint(c,i),u=this.resolveDomPoint(h,i);if(!a||!u)return null;const f=document.createRange();try{return f.setStart(a.node,a.offset),f.setEnd(u.node,u.offset),f}catch{return null}}buildVisibleDocumentText(t){let e="";for(let s=0;s<t.length;s++){const i=t[s].node.textContent||"";for(let n=0;n<i.length;n++){const r=i[n];this.virtualMarkerRegex.test(r)||(e+=r)}}return e}findNearestMatchOffset(t,e,s){const i=e.toLowerCase();let n=t.toLowerCase().indexOf(i);if(n===-1)return-1;let r=n,l=Math.abs(n-s);for(;n!==-1;){const o=Math.abs(n-s);if(o<l&&(l=o,r=n),o===0)return n;n=t.toLowerCase().indexOf(i,n+1)}return r}scheduleLiveRefresh(t){this.liveRefreshTimer&&clearTimeout(this.liveRefreshTimer);const e=this.currentQuery;this.liveRefreshTimer=setTimeout(()=>{!this.isVisible||!e||this.performSearch(e,t,!1)},90)}updateStatus(t,e=!1){if(this.statusDiv){if(!e&&Date.now()<this.statusFreezeUntil)return;this.statusDiv.textContent=t}}showTransientStatus(t,e=900){this.statusFreezeUntil=Date.now()+e,this.updateStatus(t,!0),this.statusResetTimer&&clearTimeout(this.statusResetTimer),this.statusResetTimer=setTimeout(()=>{this.statusFreezeUntil=0,this.syncMatchStatus()},e)}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(t){try{const e=this.searchOptions.caseSensitive?"g":"gi";return new RegExp(t,e),!0}catch{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 t=CSS,e=window.Highlight;return!!t.highlights&&!!e}catch{return!1}}buildVisibleToDomMap(t){const e=[0];let s=0;for(let i=0;i<t.length;i++){const n=t[i];this.virtualMarkerRegex.test(n)||(s+=1,e[s]=i+1)}return e}ensureHighlightStyles(){if(document.getElementById(this.highlightStyleId))return;const t=document.createElement("style");t.id=this.highlightStyleId,t.textContent=`
`);let n;return i.length<=1?(n={start:t,end:{line:t.line,column:t.column+s.length}},this.clampRangeToDocument(n)):(n={start:t,end:{line:t.line+i.length-1,column:i[i.length-1].length}},this.clampRangeToDocument(n))}findNextResultIndexAfter(t,e){for(let s=0;s<e.length;s++)if(this.comparePositions(e[s].range.start,t)>=0)return s;return 0}comparePositions(t,e){return t.line!==e.line?t.line-e.line:t.column-e.column}clampRangeToDocument(t){var c,h;const e=this.editor;if(!e)return t;const s=e.getValue().split(`
`),i=Math.max(0,s.length-1),n=Math.max(0,Math.min(t.start.line,i)),r=Math.max(0,Math.min(t.end.line,i)),l=Math.max(0,Math.min(t.start.column,((c=s[n])==null?void 0:c.length)||0)),o=Math.max(0,Math.min(t.end.column,((h=s[r])==null?void 0:h.length)||0));return{start:{line:n,column:l},end:{line:r,column:o}}}focusWithoutScrolling(t){try{t.focus({preventScroll:!0})}catch{const e=[];let s=t.parentElement;for(;s;)this.canScroll(s)&&e.push({el:s,top:s.scrollTop,left:s.scrollLeft}),s=s.parentElement;const i=window.scrollX,n=window.scrollY;t.focus();for(let r=0;r<e.length;r++){const l=e[r];l.el.scrollTop=l.top,l.el.scrollLeft=l.left}window.scrollTo(i,n)}}findScrollContainer(t){let e=t;for(;e;){const i=window.getComputedStyle(e).overflowY;if((i==="auto"||i==="scroll")&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null}resolveScrollContainer(t){var i,n;const e=(i=this.editor)==null?void 0:i.getView(),s=((n=e==null?void 0:e.getScrollElement)==null?void 0:n.call(e))||null;return s&&this.canScroll(s)?s:this.findScrollContainer(t)}canScroll(t){return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth}revealActiveResultAfterFocusRestore(){!this.currentResults.length||this.currentIndex<0||requestAnimationFrame(()=>{const t=this.currentResults[this.currentIndex];t&&this.scrollResultIntoView(t)})}applyCustomHighlights(){if(!this.editor||!this.hasCustomHighlightSupport||this.currentResults.length===0)return;const t=this.editor.getView().getContentElement(),e=this.editor.getValue(),{lineStarts:s,lines:i}=this.buildLineStarts(e),n=this.buildTextNodeIndex(t);if(n.length===0)return;const r=this.buildVisibleDocumentText(n),l=[];let o=null;const c=Math.min(this.currentResults.length,this.maxCustomHighlightRanges);for(let h=0;h<c;h++){const a=this.currentResults[h],u=this.searchOptions.regex?a.match||this.currentQuery:this.currentQuery||a.match,f=this.toDomRange(a.range,s,i,n,r,u);f&&(l.push(f),h===this.currentIndex&&(o=f))}if(l.length!==0)try{const h=CSS,a=window.Highlight;if(!h.highlights||!a)return;h.highlights.set(this.highlightMatchName,new a(...l)),o&&h.highlights.set(this.highlightActiveName,new a(o))}catch{}}buildLineStarts(t){const e=t.split(`
`),s=new Array(e.length);let i=0;for(let n=0;n<e.length;n++)s[n]=i,i+=e[n].length+1;return{lineStarts:s,lines:e}}positionToOffset(t,e,s){var r;const i=Math.max(0,Math.min(t.line,s.length-1)),n=Math.max(0,Math.min(t.column,((r=s[i])==null?void 0:r.length)||0));return e[i]+n}buildTextNodeIndex(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null),s=[];let i=0,n;for(;n=e.nextNode();){const r=n,l=r.parentElement;if(l!=null&&l.hasAttribute(this.trailingMarkerAttr))continue;const o=r.textContent||"",c=this.buildVisibleToDomMap(o),h=Math.max(0,c.length-1);h===0&&o.length===0||(s.push({node:r,start:i,end:i+h,visibleToDom:c}),i+=h)}return s}resolveDomPoint(t,e){var n,r;const s=Math.max(0,t);for(let l=0;l<e.length;l++){const o=e[l];if(s<=o.end){const c=Math.max(0,s-o.start),h=o.visibleToDom[c]??((n=o.node.textContent)==null?void 0:n.length)??0;return{node:o.node,offset:h}}}const i=e[e.length-1];return i?{node:i.node,offset:i.visibleToDom[i.visibleToDom.length-1]??((r=i.node.textContent)==null?void 0:r.length)??0}:null}toDomRange(t,e,s,i,n,r){const l=this.positionToOffset(t.start,e,s),o=this.positionToOffset(t.end,e,s);let c=Math.min(l,o),h=Math.max(l,o);if(n&&r){const d=r,g=n.slice(c,h);if(g.length===d.length&&g.toLowerCase()!==d.toLowerCase()){const p=this.findNearestMatchOffset(n,d,c);p!==-1&&(c=p,h=p+d.length)}}const a=this.resolveDomPoint(c,i),u=this.resolveDomPoint(h,i);if(!a||!u)return null;const f=document.createRange();try{return f.setStart(a.node,a.offset),f.setEnd(u.node,u.offset),f}catch{return null}}buildVisibleDocumentText(t){let e="";for(let s=0;s<t.length;s++){const i=t[s].node.textContent||"";for(let n=0;n<i.length;n++){const r=i[n];this.virtualMarkerRegex.test(r)||(e+=r)}}return e}findNearestMatchOffset(t,e,s){const i=e.toLowerCase();let n=t.toLowerCase().indexOf(i);if(n===-1)return-1;let r=n,l=Math.abs(n-s);for(;n!==-1;){const o=Math.abs(n-s);if(o<l&&(l=o,r=n),o===0)return n;n=t.toLowerCase().indexOf(i,n+1)}return r}scheduleLiveRefresh(t){this.liveRefreshTimer&&clearTimeout(this.liveRefreshTimer);const e=this.currentQuery;this.liveRefreshTimer=setTimeout(()=>{!this.isVisible||!e||this.performSearch(e,t,!1)},90)}updateStatus(t,e=!1){if(this.statusDiv){if(!e&&Date.now()<this.statusFreezeUntil)return;this.statusDiv.textContent=t}}showTransientStatus(t,e=900){this.statusFreezeUntil=Date.now()+e,this.updateStatus(t,!0),this.statusResetTimer&&clearTimeout(this.statusResetTimer),this.statusResetTimer=setTimeout(()=>{this.statusFreezeUntil=0,this.syncMatchStatus()},e)}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(t){try{const e=this.searchOptions.caseSensitive?"g":"gi";return new RegExp(t,e),!0}catch{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 t=CSS,e=window.Highlight;return!!t.highlights&&!!e}catch{return!1}}buildVisibleToDomMap(t){const e=[0];let s=0;for(let i=0;i<t.length;i++){const n=t[i];this.virtualMarkerRegex.test(n)||(s+=1,e[s]=i+1)}return e}ensureHighlightStyles(){if(document.getElementById(this.highlightStyleId))return;const t=document.createElement("style");t.id=this.highlightStyleId,t.textContent=`
::highlight(${this.highlightMatchName}) {

@@ -104,5 +104,5 @@ background: var(--lce-search-match-bg, rgba(255, 214, 10, 0.34));

}
`,document.head.appendChild(t)}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 t=document.getElementById(this.highlightStyleId);t?.parentNode&&t.parentNode.removeChild(t),this.editor=null}};p.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 O=p;class D{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.currentMatch=null}setup(t){this.editor=t,t.on("cursor",()=>{this.updateBracketMatching()}),t.on("change",()=>{this.updateBracketMatching()})}updateBracketMatching(){if(!this.editor)return;const t=this.editor.getCursor(),e=this.editor.getValue();this.clearBracketHighlighting();const s=this.getBracketAtPosition(e,t.position);if(!s)return;const i=this.findMatchingBracket(e,s);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketAtPosition(t,e){const s=t.split(`
`,document.head.appendChild(t)}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 t=document.getElementById(this.highlightStyleId);t!=null&&t.parentNode&&t.parentNode.removeChild(t),this.editor=null}};H.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 U=H;class W{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.currentMatch=null}setup(t){this.editor=t,t.on("cursor",()=>{this.updateBracketMatching()}),t.on("change",()=>{this.updateBracketMatching()})}updateBracketMatching(){if(!this.editor)return;const t=this.editor.getCursor(),e=this.editor.getValue();this.clearBracketHighlighting();const s=this.getBracketAtPosition(e,t.position);if(!s)return;const i=this.findMatchingBracket(e,s);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketAtPosition(t,e){const s=t.split(`
`);if(e.line>=s.length)return null;const i=s[e.line];if(e.column>=i.length)return null;const n=i[e.column];return this.bracketPairs[n]||this.reverseBracketPairs[n]?{char:n,position:e}:null}findMatchingBracket(t,e){const s=t.split(`
`),i=e.position.line,n=e.position.column,r=e.char;return this.bracketPairs[r]?this.findClosingBracket(t,s,i,n,r):this.reverseBracketPairs[r]?this.findOpeningBracket(t,s,i,n,r):null}findClosingBracket(t,e,s,i,n){const r=this.bracketPairs[n];let l=0;for(let o=s;o<e.length;o++){const c=e[o],h=o===s?i:0;for(let a=h;a<c.length;a++){const u=c[a];if(u===n)l++;else if(u===r&&(l--,l===0))return{open:{start:{line:s,column:i},end:{line:s,column:i+1}},close:{start:{line:o,column:a},end:{line:o,column:a+1}},type:n}}}return null}findOpeningBracket(t,e,s,i,n){const r=this.reverseBracketPairs[n];let l=0;for(let o=s;o>=0;o--){const c=e[o],h=o===s?i:c.length-1;for(let a=h;a>=0;a--){const u=c[a];if(u===n)l++;else if(u===r&&(l--,l===0))return{open:{start:{line:o,column:a},end:{line:o,column:a+1}},close:{start:{line:s,column:i},end:{line:s,column:i+1}},type:r}}}return null}highlightBrackets(t){}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class F{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null,this.pendingUpdateRaf=null,this.lastSnapshot="",this.changeHandler=null}setup(t){this.editor=t,t.registerCommand("fold",()=>{this.foldAtCursor()}),t.registerCommand("unfold",()=>{this.unfoldAtCursor()}),t.registerCommand("foldAll",()=>{this.foldAll()}),t.registerCommand("unfoldAll",()=>{this.unfoldAll()}),this.changeHandler=()=>{this.scheduleFoldIndicatorUpdate()},t.on("change",this.changeHandler),this.createFoldingUI(),this.scheduleFoldIndicatorUpdate()}createFoldingUI(){if(!this.editor)return;const t=this.editor.getView().getContentElement(),e=t.closest(".rte-source-editor-modal")||t.parentElement;e&&(this.foldingUI=document.createElement("div"),this.foldingUI.style.cssText=`
`),i=e.position.line,n=e.position.column,r=e.char;return this.bracketPairs[r]?this.findClosingBracket(t,s,i,n,r):this.reverseBracketPairs[r]?this.findOpeningBracket(t,s,i,n,r):null}findClosingBracket(t,e,s,i,n){const r=this.bracketPairs[n];let l=0;for(let o=s;o<e.length;o++){const c=e[o],h=o===s?i:0;for(let a=h;a<c.length;a++){const u=c[a];if(u===n)l++;else if(u===r&&(l--,l===0))return{open:{start:{line:s,column:i},end:{line:s,column:i+1}},close:{start:{line:o,column:a},end:{line:o,column:a+1}},type:n}}}return null}findOpeningBracket(t,e,s,i,n){const r=this.reverseBracketPairs[n];let l=0;for(let o=s;o>=0;o--){const c=e[o],h=o===s?i:c.length-1;for(let a=h;a>=0;a--){const u=c[a];if(u===n)l++;else if(u===r&&(l--,l===0))return{open:{start:{line:o,column:a},end:{line:o,column:a+1}},close:{start:{line:s,column:i},end:{line:s,column:i+1}},type:r}}}return null}highlightBrackets(t){}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class K{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null,this.pendingUpdateRaf=null,this.lastSnapshot="",this.changeHandler=null}setup(t){this.editor=t,t.registerCommand("fold",()=>{this.foldAtCursor()}),t.registerCommand("unfold",()=>{this.unfoldAtCursor()}),t.registerCommand("foldAll",()=>{this.foldAll()}),t.registerCommand("unfoldAll",()=>{this.unfoldAll()}),this.changeHandler=()=>{this.scheduleFoldIndicatorUpdate()},t.on("change",this.changeHandler),this.createFoldingUI(),this.scheduleFoldIndicatorUpdate()}createFoldingUI(){if(!this.editor)return;const t=this.editor.getView().getContentElement(),e=t.closest(".rte-source-editor-modal")||t.parentElement;e&&(this.foldingUI=document.createElement("div"),this.foldingUI.style.cssText=`
position: absolute;

@@ -130,2 +130,2 @@ left: 40px;

user-select: none;
`,e.innerHTML="▶",e.title="Code folding not yet implemented - click shows fold indicators",e.addEventListener("click",()=>{}),e}foldAtCursor(){}unfoldAtCursor(){}foldAll(){}unfoldAll(){}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.changeHandler=null,this.lastSnapshot="",this.foldingUI=null,this.foldIndicators=[],this.editor=null}}class U{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(t){this.editor=t,this.registerMode("html",{name:"html",highlight:(e,s)=>this._highlightHTML(e,s)}),this.registerMode("javascript",{name:"javascript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("typescript",{name:"typescript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("php",{name:"php",highlight:(e,s)=>this._highlightPHP(e,s)})}setTheme(t){this.currentTheme=t}setLanguage(t){this.currentLanguage=t}registerMode(t,e){this.modes.set(t.toLowerCase(),e)}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(t,e){const s=this.getSyntaxColors(),i=(e||this.currentLanguage||"html").toLowerCase();return(this.modes.get(i)||this.modes.get("html")).highlight(t,s)}highlightHTML(t){return this.highlight(t,"html")}escapeHTML(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}unescapeEntitiesRepeated(t){let e=t||"";for(let s=0;s<5;s++){const i=e;if(e=e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),e===i)break}return e}_highlightHTML(t,e){const s=e,i=c=>this.escapeHTML(c);let n=i(t);const r=c=>{let h=c.replace(/&quot;/g,'"').replace(/&#39;/g,"'");return h=h.replace(/(\/\*[\s\S]*?\*\/)/g,`<span style="color: ${s.comment};">$1</span>`),h=h.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g,(a,u,f,d,g)=>{const m=String(d).trim(),x=i(m);return`<span style="color: ${s.styleProp};">${u}</span>${f}<span style="color: ${s.styleVal};">${x}</span>${g}`}),h},l=[];try{t.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(c,h,a)=>(l.push({attrs:String(h||""),inner:String(a||"")}),c))}catch{}let o=0;return n=n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi,(c,h,a,u,f)=>{const d=l[o++]?.inner??this.unescapeEntitiesRepeated(u||"");(l[o-1]?.attrs||a||"").toLowerCase();const g=this._highlightJS(d,s);return`${h}${g}${f}`}),n=n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi,(c,h,a,u)=>{const f=r(a);return`${h}${f}${u}`}),n=n.replace(/(&lt;!--[\s\S]*?--&gt;)/g,`<span style="color: ${s.comment};">$1</span>`),n=n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i,`<span style="color: ${s.doctype};">$1</span>`),n=n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g,(c,h,a,u,f)=>{const d=`<span style="color: ${s.tag};">${a}</span>`;let g=u;return g=g.replace(/([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,(m,x,R,v)=>{const E=String(x).toLowerCase(),k=`<span style="color: ${s.attrName};">${x}</span>`;let L=v,w="";v.startsWith("&quot;")&&v.endsWith("&quot;")?(L=v.slice(6,-6),w="&quot;"):v.startsWith("&#39;")&&v.endsWith("&#39;")&&(L=v.slice(5,-5),w="&#39;");let b=v;if(E==="style"){const $=L.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(q,K,z,Q)=>`<span style="color: ${s.styleProp};">${K}</span>:<span style="color: ${s.styleVal};">${z.trim()}</span>${Q}`);w?b=`${w}${$}${w}`:b=$,b=`<span style="color: ${s.attrValue};">${b}</span>`}else w&&(b=`${w}${L}${w}`),b=`<span style="color: ${s.attrValue};">${b}</span>`;return`${k}${R}${b}`}),`${h}${d}${g}${f}`}),n}_highlightJS(t,e){const s=this.unescapeEntitiesRepeated(t);this.escapeHTML(s);const i=[],n=f=>{let d="",g=f;do d=String.fromCharCode(97+g%26)+d,g=Math.floor(g/26)-1;while(g>=0);return d||"a"},r=f=>`\0${n(f)}\0`,l=f=>{const d=i.length;return i.push(f),r(d)};let o;const c=/(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;let h=0,a="";for(;o=c.exec(s);){const f=o.index;h<f&&(a+=this.escapeHTML(s.slice(h,f)));const d=o[0];/^\/\*/.test(d)||/^\/\//.test(d)?a+=l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`):a+=l(`<span style="color: ${e.string};">${this.escapeHTML(d)}</span>`),h=c.lastIndex}return h<s.length&&(a+=this.escapeHTML(s.slice(h))),a=a.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g,(f,d,g)=>{const m=a[g-1]||"",x=a[g+f.length]||"";return m==="&"||m==="#"||x===";"||x==="#"?f:`<span style="color: ${e.number};">${f}</span>`}),a=a.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: ${e.keyword};">$1</span>`),a.replace(/\u0000([a-z]+)\u0000/g,(f,d)=>{let g=0;for(let m=0;m<d.length;m++)g=g*26+(d.charCodeAt(m)-97+1);return g=g-1,i[g]||""})}_highlightPHP(t,e){const s=this.unescapeEntitiesRepeated(t);let i=this.escapeHTML(s);const n=[],r=d=>{let g="",m=d;do g=String.fromCharCode(97+m%26)+g,m=Math.floor(m/26)-1;while(m>=0);return g||"a"},l=d=>{const g=n.length;return n.push(d),`\0${r(g)}\0`},o=(d,g)=>{const m=i.indexOf(d);return m===-1?!1:(i=i.slice(0,m)+g+i.slice(m+d.length),!0)};let c;const h=/\/\*[\s\S]*?\*\//g,a=/\/\/[^\n\r]*/g,u=/\#([^\n\r]*)/g,f=/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;for(;c=h.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=a.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=u.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=f.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.string};">${this.escapeHTML(d)}</span>`))}return i=i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g,`<span style="color: ${e.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: ${e.keyword};">$1</span>`),i=i.replace(/\u0000([a-z]+)\u0000/g,(d,g)=>{let m=0;for(let x=0;x<g.length;x++)m=m*26+(g.charCodeAt(x)-97+1);return m=m-1,n[m]||""}),i}shouldHighlight(t){return/<\/?[\w:-]+|<!--/.test(t)}destroy(){this.editor=null,this.modes.clear()}}function W(T,t){const e={...t};return e.extensions||(e.extensions=[]),e.extensions.some(n=>n.name==="keymap")||e.extensions.unshift(new N(e.keymap)),e.extensions.some(n=>n.name==="transaction")||e.extensions.unshift(new H),new M(T,e)}y.BracketMatchingExtension=D,y.CodeFoldingExtension=F,y.EditorCore=M,y.KeymapExtension=N,y.LineNumbersExtension=A,y.ReadOnlyExtension=B,y.SearchExtension=O,y.SyntaxHighlightingExtension=U,y.TextModel=C,y.ThemeExtension=P,y.View=I,y.createEditor=W,y.default=M,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
`,e.innerHTML="▶",e.title="Code folding not yet implemented - click shows fold indicators",e.addEventListener("click",()=>{}),e}foldAtCursor(){}unfoldAtCursor(){}foldAll(){}unfoldAll(){}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.changeHandler=null,this.lastSnapshot="",this.foldingUI=null,this.foldIndicators=[],this.editor=null}}class z{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(t){this.editor=t,this.registerMode("html",{name:"html",highlight:(e,s)=>this._highlightHTML(e,s)}),this.registerMode("javascript",{name:"javascript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("typescript",{name:"typescript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("php",{name:"php",highlight:(e,s)=>this._highlightPHP(e,s)})}setTheme(t){this.currentTheme=t}setLanguage(t){this.currentLanguage=t}registerMode(t,e){this.modes.set(t.toLowerCase(),e)}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(t,e){const s=this.getSyntaxColors(),i=(e||this.currentLanguage||"html").toLowerCase();return(this.modes.get(i)||this.modes.get("html")).highlight(t,s)}highlightHTML(t){return this.highlight(t,"html")}escapeHTML(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}unescapeEntitiesRepeated(t){let e=t||"";for(let s=0;s<5;s++){const i=e;if(e=e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),e===i)break}return e}_highlightHTML(t,e){const s=e,i=c=>this.escapeHTML(c);let n=i(t);const r=c=>{let h=c.replace(/&quot;/g,'"').replace(/&#39;/g,"'");return h=h.replace(/(\/\*[\s\S]*?\*\/)/g,`<span style="color: ${s.comment};">$1</span>`),h=h.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g,(a,u,f,d,g)=>{const p=String(d).trim(),x=i(p);return`<span style="color: ${s.styleProp};">${u}</span>${f}<span style="color: ${s.styleVal};">${x}</span>${g}`}),h},l=[];try{t.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(c,h,a)=>(l.push({attrs:String(h||""),inner:String(a||"")}),c))}catch{}let o=0;return n=n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi,(c,h,a,u,f)=>{var p,x;const d=((p=l[o++])==null?void 0:p.inner)??this.unescapeEntitiesRepeated(u||"");(((x=l[o-1])==null?void 0:x.attrs)||a||"").toLowerCase();const g=this._highlightJS(d,s);return`${h}${g}${f}`}),n=n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi,(c,h,a,u)=>{const f=r(a);return`${h}${f}${u}`}),n=n.replace(/(&lt;!--[\s\S]*?--&gt;)/g,`<span style="color: ${s.comment};">$1</span>`),n=n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i,`<span style="color: ${s.doctype};">$1</span>`),n=n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g,(c,h,a,u,f)=>{const d=`<span style="color: ${s.tag};">${a}</span>`;let g=u;return g=g.replace(/([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,(p,x,R,C)=>{const E=String(x).toLowerCase(),k=`<span style="color: ${s.attrName};">${x}</span>`;let L=C,v="";C.startsWith("&quot;")&&C.endsWith("&quot;")?(L=C.slice(6,-6),v="&quot;"):C.startsWith("&#39;")&&C.endsWith("&#39;")&&(L=C.slice(5,-5),v="&#39;");let S=C;if(E==="style"){const A=L.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(Y,q,j,_)=>`<span style="color: ${s.styleProp};">${q}</span>:<span style="color: ${s.styleVal};">${j.trim()}</span>${_}`);v?S=`${v}${A}${v}`:S=A,S=`<span style="color: ${s.attrValue};">${S}</span>`}else v&&(S=`${v}${L}${v}`),S=`<span style="color: ${s.attrValue};">${S}</span>`;return`${k}${R}${S}`}),`${h}${d}${g}${f}`}),n}_highlightJS(t,e){const s=this.unescapeEntitiesRepeated(t);this.escapeHTML(s);const i=[],n=f=>{let d="",g=f;do d=String.fromCharCode(97+g%26)+d,g=Math.floor(g/26)-1;while(g>=0);return d||"a"},r=f=>`\0${n(f)}\0`,l=f=>{const d=i.length;return i.push(f),r(d)};let o;const c=/(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;let h=0,a="";for(;o=c.exec(s);){const f=o.index;h<f&&(a+=this.escapeHTML(s.slice(h,f)));const d=o[0];/^\/\*/.test(d)||/^\/\//.test(d)?a+=l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`):a+=l(`<span style="color: ${e.string};">${this.escapeHTML(d)}</span>`),h=c.lastIndex}return h<s.length&&(a+=this.escapeHTML(s.slice(h))),a=a.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g,(f,d,g)=>{const p=a[g-1]||"",x=a[g+f.length]||"";return p==="&"||p==="#"||x===";"||x==="#"?f:`<span style="color: ${e.number};">${f}</span>`}),a=a.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: ${e.keyword};">$1</span>`),a.replace(/\u0000([a-z]+)\u0000/g,(f,d)=>{let g=0;for(let p=0;p<d.length;p++)g=g*26+(d.charCodeAt(p)-97+1);return g=g-1,i[g]||""})}_highlightPHP(t,e){const s=this.unescapeEntitiesRepeated(t);let i=this.escapeHTML(s);const n=[],r=d=>{let g="",p=d;do g=String.fromCharCode(97+p%26)+g,p=Math.floor(p/26)-1;while(p>=0);return g||"a"},l=d=>{const g=n.length;return n.push(d),`\0${r(g)}\0`},o=(d,g)=>{const p=i.indexOf(d);return p===-1?!1:(i=i.slice(0,p)+g+i.slice(p+d.length),!0)};let c;const h=/\/\*[\s\S]*?\*\//g,a=/\/\/[^\n\r]*/g,u=/\#([^\n\r]*)/g,f=/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;for(;c=h.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=a.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=u.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.comment};">${this.escapeHTML(d)}</span>`))}for(;c=f.exec(s);){const d=c[0];o(this.escapeHTML(d),l(`<span style="color: ${e.string};">${this.escapeHTML(d)}</span>`))}return i=i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g,`<span style="color: ${e.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: ${e.keyword};">$1</span>`),i=i.replace(/\u0000([a-z]+)\u0000/g,(d,g)=>{let p=0;for(let x=0;x<g.length;x++)p=p*26+(g.charCodeAt(x)-97+1);return p=p-1,n[p]||""}),i}shouldHighlight(t){return/<\/?[\w:-]+|<!--/.test(t)}destroy(){this.editor=null,this.modes.clear()}}function Q(T,t){const e={...t};return e.extensions||(e.extensions=[]),e.extensions.some(n=>n.name==="keymap")||e.extensions.unshift(new $(e.keymap)),e.extensions.some(n=>n.name==="transaction")||e.extensions.unshift(new P),new O(T,e)}y.BracketMatchingExtension=W,y.CodeFoldingExtension=K,y.EditorCore=O,y.KeymapExtension=$,y.LineNumbersExtension=B,y.ReadOnlyExtension=D,y.SearchExtension=U,y.SyntaxHighlightingExtension=z,y.TextModel=M,y.ThemeExtension=V,y.View=I,y.createEditor=Q,y.default=O,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "@editora/light-code-editor",
"version": "1.0.7",
"description": "Lightweight, extensible code editor for the web — syntax highlighting, line numbers, code folding, and a plugin-friendly API. Ideal for embedding in docs, demos, and web apps.",
"version": "1.0.8",
"description": "Lightweight code editor for React and web apps with syntax highlighting, search/replace, extensions, and enterprise SaaS integration patterns.",
"authors": [

@@ -35,2 +35,8 @@ "Ajay Kumar <ajaykr089@gmail.com>"

"keywords": [
"react ui library",
"react component library",
"saas ui components",
"enterprise react components",
"modern design system",
"rich text editor react",
"code-editor",

@@ -52,3 +58,3 @@ "lightweight-editor",

},
"homepage": "https://github.com/ajaykr089/Editora#readme",
"homepage": "https://editora-ecosystem.netlify.app/docs/packages/light-code-editor",
"bugs": {

@@ -66,5 +72,5 @@ "url": "https://github.com/ajaykr089/Editora/issues"

"typescript": "^5.0.0",
"vite": "^7.3.1"
"vite": "^4.5.14"
},
"gitHead": "80e0808ae4909de63b8e0f1dd915b06b33a8ed44"
"gitHead": "7883627e823aa99dd5ecb66a5201116df972f88b"
}
# Light Code Editor
> [!IMPORTANT]
> **Live Website:** https://editora-ecosystem.netlify.app/
> **Storybook:** https://editora-ecosystem-storybook.netlify.app/
A lightweight, modular code editor library inspired by CodeMirror, optimized for embedding inside rich text editors.

@@ -4,0 +9,0 @@

.rte-light-editor{position:relative;width:100%;height:400px;border:1px solid #ccc;border-radius:4px;overflow:hidden;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:21px}.rte-light-editor-content{position:relative;width:100%;height:100%;padding:8px;margin:0;border:none;outline:none;resize:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:auto;background:transparent}.rte-light-editor-gutter{position:absolute;left:0;top:0;bottom:0;width:50px;padding:8px 0;text-align:right;border-right:1px solid #e0e0e0;background:#f8f8f8;color:#999;font-size:12px;line-height:21px;-webkit-user-select:none;user-select:none;overflow:hidden}.rte-light-editor-gutter.dark{border-right-color:#3e3e3e;background:#1e1e1e;color:#666}.rte-syntax-highlight-overlay{position:absolute;inset:0 0 0 50px;pointer-events:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:hidden;z-index:5;background:transparent;color:transparent}.syntax-html-tag{color:#569cd6!important}.syntax-html-comment{color:#6a9955!important}.syntax-html-attr-value{color:#ce9178!important}.dark .syntax-html-tag{color:#569cd6!important}.dark .syntax-html-comment{color:#6a9955!important}.dark .syntax-html-attr-value{color:#ce9178!important}.light .syntax-html-tag{color:#00f!important}.light .syntax-html-comment{color:green!important}.light .syntax-html-attr-value{color:#a31515!important}.rte-light-editor.dark{background:#1e1e1e;color:#d4d4d4;border-color:#3e3e3e}.rte-light-editor.dark .rte-light-editor-content{background:#1e1e1e;color:#d4d4d4}.rte-light-editor.light{background:#fff;color:#000;border-color:#e0e0e0}.rte-light-editor.light .rte-light-editor-content{background:#fff;color:#000}.rte-light-editor.readonly .rte-light-editor-content{cursor:not-allowed;opacity:.7}.rte-light-editor.readonly .rte-light-editor-content:after{content:"";position:absolute;inset:0;background:#ffffff1a;pointer-events:none}.rte-light-editor.focused{border-color:#007acc;box-shadow:0 0 0 2px #007acc33}.rte-light-editor-content::selection{background:#007acc33}.rte-light-editor.dark .rte-light-editor-content::selection{background:#007acc4d}.rte-light-editor-content::-webkit-scrollbar{width:12px;height:12px}.rte-light-editor-content::-webkit-scrollbar-track{background:#f1f1f1}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-track{background:#2d2d2d}.rte-light-editor-content::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:6px}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb{background:#555}.rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#666}.bracket-match{background:#007acc1a;border-radius:2px}.dark .bracket-match{background:#007acc33}.search-match{background:#ffff004d;border-radius:2px}.search-match.current{background:#ff09;border:1px solid #ffcc00}.fold-indicator{position:absolute;left:35px;width:12px;height:12px;cursor:pointer;opacity:.5;transition:opacity .2s}.fold-indicator:hover{opacity:1}.fold-indicator.expanded:before{content:"▼";font-size:10px;color:#666}.fold-indicator.collapsed:before{content:"▶";font-size:10px;color:#666}.dark .fold-indicator.expanded:before,.dark .fold-indicator.collapsed:before{color:#999}.editor-container{font-family:monospace;background-color:#1e1e1e;color:#d4d4d4;padding:10px;border:1px solid #333;border-radius:4px;overflow:auto}.editor-line{white-space:pre}.editor-line-number{display:inline-block;width:30px;text-align:right;margin-right:10px;color:#858585}.lce-search-ui{position:absolute;top:12px;right:12px;z-index:1000;min-width:250px;max-width:min(320px,calc(100% - 24px));box-sizing:border-box;border-radius:6px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-background, #1e1e1e);box-shadow:0 8px 20px #0000003d;padding:8px}.lce-search-row{display:flex;align-items:center;gap:6px;margin-bottom:6px}.lce-search-options{display:flex;align-items:center;gap:8px;margin:2px 0 6px}.lce-search-option{display:inline-flex;align-items:center;gap:4px;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.2;-webkit-user-select:none;user-select:none;cursor:pointer}.lce-search-option-input{margin:0;accent-color:var(--editor-cursor, #007acc)}.lce-search-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.lce-search-input{appearance:none;width:100%;min-width:0;height:30px;padding:6px 10px;box-sizing:border-box;border-radius:4px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-gutter-background, #252526);color:var(--editor-foreground, #f8f9fa);font-size:12px;line-height:1.4;outline:none}.lce-search-input:focus{border-color:var(--editor-cursor, #007acc);box-shadow:0 0 0 2px #007acc33}.lce-search-replace{display:none;margin-top:8px}.lce-search-btn{appearance:none;width:28px;min-width:28px;height:28px;padding:0;border-radius:4px;border:1px solid var(--editor-gutter-border, #3e3e42);background:var(--editor-gutter-background, #252526);color:var(--editor-gutter-foreground, #858585);font-size:12px;line-height:1;cursor:pointer}.lce-search-btn:hover{color:var(--editor-foreground, #f8f9fa)}.lce-search-status{min-height:16px;margin:2px 2px 0;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.35;text-align:left;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.lce-search-mode{min-height:16px;margin:2px 2px 0;color:var(--editor-gutter-foreground, #858585);font-size:11px;line-height:1.35;white-space:nowrap;opacity:.9}
MIT License
Copyright (c) 2026 Ajay Kumar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Sorry, the diff of this file is too big to display