@synclineapi/editor 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -4
- package/dist/syncline-editor.es.js +3907 -3178
- package/dist/syncline-editor.es.js.map +1 -1
- package/dist/syncline-editor.umd.js +178 -173
- package/dist/syncline-editor.umd.js.map +1 -1
- package/dist/types/index.d.ts +391 -179
- package/package.json +1 -1
|
@@ -1,5 +1,161 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`)}function z(s){const e=s.sel;if(!e)return s.cur;const t=W(e),i=(s.doc[t.ar]??"").slice(0,t.ac),n=(s.doc[t.fr]??"").slice(t.fc);return s.doc.splice(t.ar,t.fr-t.ar+1,i+n),s.sel=null,{row:t.ar,col:t.ac}}function et(s,e,t){if(!t||s.length<=e)return[s];const i=[];let n=0;for(;n<s.length;){if(s.length-n<=e){i.push(s.slice(n));break}const r=n+e;let o=-1;for(let l=r;l>n;l--)if(s[l-1]===" "){o=l;break}o===-1?(i.push(s.slice(n,r)),n=r):(i.push(s.slice(n,o)),n=o)}return i}function tt(s,e,t,i){const n=[],r=[],o=[];let l=-1;for(let a=0;a<s.length;a++){if(a>0&&a<=l){o.push(r.length),n.push([s[a]??""]);continue}o.push(r.length);const c=et(s[a]??"",e,t);n.push(c),c.forEach((d,h)=>r.push({docLine:a,segIdx:h,text:d})),i.has(a)&&(l=i.get(a))}return{segments:n,visualRows:r,docToVisArr:o}}function F(s,e,t){const i=s.segments[e]??[""];let n=t;for(let r=0;r<i.length;r++){if(n<=i[r].length||r===i.length-1)return{visRow:s.docToVisArr[e]+r,colInSeg:Math.min(n,i[r].length)};n-=i[r].length}return{visRow:s.docToVisArr[e]??0,colInSeg:0}}function Z(s,e,t){var o;const i=s.visualRows[e];if(!i)return{row:0,col:0};const n=s.segments[i.docLine]??[""];let r=Math.min(t,((o=n[i.segIdx])==null?void 0:o.length)??0);for(let l=0;l<i.segIdx;l++)r+=n[l].length;return{row:i.docLine,col:r}}function ie(s,e={}){var d,h;const t=[],i=s.length;let n=0;const r=(p,f,_)=>{_>f&&t.push({cls:p,start:f,end:_})},o=ge[e.language??"typescript"]??ee,l=be[e.language??"typescript"]??te,a=(d=e.extraKeywords)!=null&&d.size?new Set([...o,...e.extraKeywords]):o,c=(h=e.extraTypes)!=null&&h.size?new Set([...l,...e.extraTypes]):l;for(;n<i;){if(s[n]==="/"&&s[n+1]==="/"){r("cmt",n,i);break}if(s[n]==="*"||s[n]==="/"&&s[n+1]==="*"){r("cmt",n,i);break}if(s[n]==="@"){let p=n+1;for(;p<i&&/\w/.test(s[p]);)p++;r("dec",n,p),n=p;continue}if(s[n]==='"'||s[n]==="'"||s[n]==="`"){const p=s[n];let f=n+1;for(;f<i;){if(s[f]==="\\"){f+=2;continue}if(s[f]===p){f++;break}f++}r("str",n,f),n=f;continue}if(/\d/.test(s[n])&&(n===0||!/\w/.test(s[n-1]))){let p=n;for(;p<i&&/[\d._xXa-fA-F]/.test(s[p]);)p++;r("num",n,p),n=p;continue}if(/[a-zA-Z_$]/.test(s[n])){let p=n;for(;p<i&&/[\w$]/.test(s[p]);)p++;const f=s.slice(n,p);a.has(f)?r("kw",n,p):c.has(f)?r("typ",n,p):p<i&&s[p]==="("?r("fn",n,p):/^[A-Z]/.test(f)&&r("cls",n,p),n=p;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(s[n])){r("op",n,n+1),n++;continue}n++}return t}function ve(s,e){const t=new Array(s.length).fill("");for(const i of e)for(let n=i.start;n<i.end;n++)t[n]=i.cls;return t}class it{constructor(e=5e3){g(this,"_cache",new Map);g(this,"_maxSize");g(this,"_hits",0);g(this,"_misses",0);g(this,"_evictions",0);this._maxSize=e}get metrics(){return{hits:this._hits,misses:this._misses,evictions:this._evictions,size:this._cache.size}}get(e,t){const i=this._cache.get(e);return i&&i.src===t?(this._hits++,i.segs):(this._misses++,null)}set(e,t,i){this._cache.size>=this._maxSize&&(this._cache.delete(this._cache.keys().next().value),this._evictions++),this._cache.set(e,{src:t,segs:i})}invalidateLine(e,t){for(let i=0;i<t;i++)this._cache.delete(`${e}:${i}`)}clear(){this._cache.clear(),this._hits=0,this._misses=0,this._evictions=0}resetMetrics(){this._hits=0,this._misses=0,this._evictions=0}}const we={id:"",name:"VR Dark",description:"Default deep dark theme",light:!1,tokens:{bg0:"#0d0d0f",bg1:"#111115",bg2:"#16161b",bg3:"#1d1d24",bg4:"#24242d",border:"rgba(255,255,255,.07)",border2:"rgba(255,255,255,.12)",border3:"rgba(255,255,255,.19)",text:"#c9c7c0",text2:"#8b8994",text3:"#4e4c58",accent:"#6e9fff",accent2:"#2f5db0",green:"#4ec9a0",orange:"#d4976e",purple:"#b48eff",red:"#f28b82",yellow:"#e8c97a",cur:"#6e9fff",curGlow:"rgba(110,159,255,.65)",curLineBg:"rgba(255,255,255,.032)",curLineGutter:"#181820",gutterBg:"#0f0f12",gutterHover:"#181820",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#4e4c58",gutterNumAct:"#9997a2",selBg:"rgba(110,159,255,.22)",wordHlBg:"rgba(200,198,210,.09)",wordHlBorder:"rgba(200,198,210,.28)",bmBorder:"rgba(110,159,255,.65)",foldBg:"rgba(110,159,255,.07)",foldBorder:"rgba(110,159,255,.30)",findBg:"rgba(234,180,86,.18)",findBorder:"rgba(234,180,86,.50)",findCurBg:"rgba(234,180,86,.80)",findCurBorder:"rgba(234,180,86,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(110,159,255,.11)",fileActiveText:"#6e9fff",mmBg:"#0d0d0f",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#6e9fff",tokStr:"#4ec9a0",tokCmt:"#4e4c58",tokFn:"#d4976e",tokNum:"#b48eff",tokCls:"#e8c97a",tokOp:"#55536a",tokTyp:"#6ec9d4",tokDec:"#f28b82"}},ke={id:"vscode-dark",name:"VSCode Dark+",description:"Visual Studio Code dark",light:!1,tokens:{bg0:"#1e1e1e",bg1:"#252526",bg2:"#1e1e1e",bg3:"#2d2d30",bg4:"#3a3a3d",border:"rgba(255,255,255,.09)",border2:"rgba(255,255,255,.15)",border3:"rgba(255,255,255,.24)",text:"#d4d4d4",text2:"#9a9a9a",text3:"#505050",accent:"#569cd6",accent2:"#0e639c",green:"#4ec9b0",orange:"#ce9178",purple:"#c586c0",red:"#f44747",yellow:"#dcdcaa",cur:"#aeafad",curGlow:"rgba(174,175,173,.40)",curLineBg:"rgba(255,255,255,.038)",curLineGutter:"#282828",gutterBg:"#1e1e1e",gutterHover:"#282828",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#838383",gutterNumAct:"#c8c8c8",selBg:"rgba(38,79,120,.65)",wordHlBg:"rgba(173,214,255,.06)",wordHlBorder:"rgba(173,214,255,.28)",bmBorder:"rgba(86,156,214,.70)",foldBg:"rgba(86,156,214,.07)",foldBorder:"rgba(86,156,214,.35)",findBg:"rgba(255,215,0,.13)",findBorder:"rgba(255,215,0,.52)",findCurBg:"#f6f6a0",findCurBorder:"#d4d400",findCurText:"#000",fileActiveBg:"rgba(255,255,255,.07)",fileActiveText:"#d4d4d4",mmBg:"#1e1e1e",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#569cd6",tokStr:"#ce9178",tokCmt:"#6a9955",tokFn:"#dcdcaa",tokNum:"#b5cea8",tokCls:"#4ec9b0",tokOp:"#d4d4d4",tokTyp:"#4ec9b0",tokDec:"#9cdcfe"}},xe={id:"monokai",name:"Monokai",description:"Classic Sublime Text theme",light:!1,tokens:{bg0:"#272822",bg1:"#1e1f1c",bg2:"#272822",bg3:"#3a3930",bg4:"#48473d",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.13)",border3:"rgba(255,255,255,.20)",text:"#f8f8f2",text2:"#a8a7a0",text3:"#58574e",accent:"#a6e22e",accent2:"#3d5a10",green:"#a6e22e",orange:"#fd971f",purple:"#ae81ff",red:"#f92672",yellow:"#e6db74",cur:"#f8f8f2",curGlow:"rgba(248,248,242,.25)",curLineBg:"rgba(255,255,255,.042)",curLineGutter:"#2c2d27",gutterBg:"#1e1f1c",gutterHover:"#2c2d27",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#6e6d64",gutterNumAct:"#cccac0",selBg:"rgba(73,72,62,.80)",wordHlBg:"rgba(248,248,242,.06)",wordHlBorder:"rgba(248,248,242,.22)",bmBorder:"rgba(166,226,46,.65)",foldBg:"rgba(166,226,46,.07)",foldBorder:"rgba(166,226,46,.30)",findBg:"rgba(230,219,116,.16)",findBorder:"rgba(230,219,116,.52)",findCurBg:"#e6db74",findCurBorder:"#c9be50",findCurText:"#272822",fileActiveBg:"rgba(166,226,46,.10)",fileActiveText:"#a6e22e",mmBg:"#1e1f1c",mmSlider:"rgba(255,255,255,.06)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#f92672",tokStr:"#e6db74",tokCmt:"#75715e",tokFn:"#a6e22e",tokNum:"#ae81ff",tokCls:"#66d9e8",tokOp:"#f8f8f2",tokTyp:"#66d9e8",tokDec:"#fd971f"}},Te={id:"dracula",name:"Dracula",description:"Purple-tinted dark theme",light:!1,tokens:{bg0:"#282a36",bg1:"#21222c",bg2:"#282a36",bg3:"#333545",bg4:"#44475a",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.14)",border3:"rgba(255,255,255,.22)",text:"#f8f8f2",text2:"#b2b5c8",text3:"#5a5e78",accent:"#bd93f9",accent2:"#5b3fa8",green:"#50fa7b",orange:"#ffb86c",purple:"#bd93f9",red:"#ff5555",yellow:"#f1fa8c",cur:"#f8f8f2",curGlow:"rgba(189,147,249,.55)",curLineBg:"rgba(255,255,255,.045)",curLineGutter:"#2f3144",gutterBg:"#21222c",gutterHover:"#2f3144",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#5e638a",gutterNumAct:"#f8f8f2",selBg:"rgba(68,71,90,.85)",wordHlBg:"rgba(248,248,242,.05)",wordHlBorder:"rgba(248,248,242,.20)",bmBorder:"rgba(189,147,249,.70)",foldBg:"rgba(189,147,249,.08)",foldBorder:"rgba(189,147,249,.35)",findBg:"rgba(241,250,140,.14)",findBorder:"rgba(241,250,140,.52)",findCurBg:"#f1fa8c",findCurBorder:"#d4dc50",findCurText:"#282a36",fileActiveBg:"rgba(189,147,249,.12)",fileActiveText:"#bd93f9",mmBg:"#21222c",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#ff79c6",tokStr:"#f1fa8c",tokCmt:"#6272a4",tokFn:"#50fa7b",tokNum:"#bd93f9",tokCls:"#8be9fd",tokOp:"#f8f8f2",tokTyp:"#8be9fd",tokDec:"#ffb86c"}},Ee={id:"github-light",name:"GitHub Light",description:"GitHub's clean light theme",light:!0,tokens:{bg0:"#ffffff",bg1:"#f6f8fa",bg2:"#ffffff",bg3:"#f0f3f6",bg4:"#e7eaee",border:"#d0d7de",border2:"#bdc4cc",border3:"#aab1ba",text:"#1f2328",text2:"#57606a",text3:"#8c959f",accent:"#0969da",accent2:"#0550ae",green:"#1a7f37",orange:"#bc4c00",purple:"#8250df",red:"#cf222e",yellow:"#7d4e00",cur:"#0969da",curGlow:"rgba(9,105,218,.30)",curLineBg:"rgba(9,105,218,.055)",curLineGutter:"#ebf0f8",gutterBg:"#f6f8fa",gutterHover:"#eaedf1",gutterBorder:"#d0d7de",gutterNum:"#9da5b0",gutterNumAct:"#1f2328",selBg:"rgba(9,105,218,.15)",wordHlBg:"rgba(9,105,218,.07)",wordHlBorder:"rgba(9,105,218,.28)",bmBorder:"rgba(9,105,218,.60)",foldBg:"rgba(9,105,218,.06)",foldBorder:"rgba(9,105,218,.28)",findBg:"rgba(180,100,0,.09)",findBorder:"rgba(180,100,0,.42)",findCurBg:"rgba(180,100,0,.75)",findCurBorder:"rgba(180,100,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(9,105,218,.09)",fileActiveText:"#0969da",mmBg:"#f6f8fa",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.09)",tokKw:"#cf222e",tokStr:"#0a3069",tokCmt:"#6e7781",tokFn:"#8250df",tokNum:"#0550ae",tokCls:"#953800",tokOp:"#1f2328",tokTyp:"#0550ae",tokDec:"#0969da"}},Ce={id:"solarized-light",name:"Solarized Light",description:"Warm precision light theme",light:!0,tokens:{bg0:"#fdf6e3",bg1:"#eee8d5",bg2:"#fdf6e3",bg3:"#e5dfcc",bg4:"#dad4c1",border:"#cdc7b4",border2:"#bab4a2",border3:"#a9a390",text:"#002b36",text2:"#586e75",text3:"#93a1a1",accent:"#268bd2",accent2:"#1a6fa8",green:"#859900",orange:"#cb4b16",purple:"#6c71c4",red:"#dc322f",yellow:"#b58900",cur:"#268bd2",curGlow:"rgba(38,139,210,.32)",curLineBg:"rgba(38,139,210,.07)",curLineGutter:"#e2dcc8",gutterBg:"#eee8d5",gutterHover:"#e2dcc8",gutterBorder:"#cdc7b4",gutterNum:"#93a1a1",gutterNumAct:"#002b36",selBg:"rgba(38,139,210,.18)",wordHlBg:"rgba(38,139,210,.08)",wordHlBorder:"rgba(38,139,210,.28)",bmBorder:"rgba(38,139,210,.58)",foldBg:"rgba(38,139,210,.07)",foldBorder:"rgba(38,139,210,.28)",findBg:"rgba(181,137,0,.11)",findBorder:"rgba(181,137,0,.42)",findCurBg:"rgba(181,137,0,.75)",findCurBorder:"rgba(181,137,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(38,139,210,.10)",fileActiveText:"#268bd2",mmBg:"#eee8d5",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.16)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#859900",tokStr:"#2aa198",tokCmt:"#93a1a1",tokFn:"#268bd2",tokNum:"#d33682",tokCls:"#b58900",tokOp:"#657b83",tokTyp:"#268bd2",tokDec:"#cb4b16"}},Me={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},Se={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Le=[we,ke,xe,Te,Ee,Ce,Me,Se],nt={bg0:"--bg0",bg1:"--bg1",bg2:"--bg2",bg3:"--bg3",bg4:"--bg4",border:"--border",border2:"--border2",border3:"--border3",text:"--text",text2:"--text2",text3:"--text3",accent:"--accent",accent2:"--accent2",green:"--green",orange:"--orange",purple:"--purple",red:"--red",yellow:"--yellow",cur:"--cur",curGlow:"--cur-glow",curLineBg:"--cur-line-bg",curLineGutter:"--cur-line-gutter",gutterBg:"--gutter-bg",gutterHover:"--gutter-hover",gutterBorder:"--gutter-border",gutterNum:"--gutter-num",gutterNumAct:"--gutter-num-act",selBg:"--sel-bg",wordHlBg:"--word-hl-bg",wordHlBorder:"--word-hl-border",bmBorder:"--bm-border",foldBg:"--fold-bg",foldBorder:"--fold-border",findBg:"--find-bg",findBorder:"--find-border",findCurBg:"--find-cur-bg",findCurBorder:"--find-cur-border",findCurText:"--find-cur-text",fileActiveBg:"--file-active-bg",fileActiveText:"--file-active-text",mmBg:"--mm-bg",mmSlider:"--mm-slider",mmDim:"--mm-dim",mmEdge:"--mm-edge",indentGuide:"--indent-guide",tokKw:"--tok-kw",tokStr:"--tok-str",tokCmt:"--tok-cmt",tokFn:"--tok-fn",tokNum:"--tok-num",tokCls:"--tok-cls",tokOp:"--tok-op",tokTyp:"--tok-typ",tokDec:"--tok-dec"};class rt{constructor(e){g(this,"_registry",new Map);g(this,"_activeId","");g(this,"_root");this._root=e;for(const t of Le)this._registry.set(t.id,t)}register(e){this._registry.set(e.id,e)}apply(e){let t;typeof e=="string"?(t=this._registry.get(e),t||(console.warn(`[syncline-editor] Unknown theme: "${e}". Falling back to VR Dark.`),t=this._registry.get(""))):(t=e,this._registry.set(t.id,t)),this._activeId=t.id,this._applyTokens(t.tokens)}get activeId(){return this._activeId}get activeTheme(){return this._registry.get(this._activeId)}get allIds(){return[...this._registry.keys()]}get all(){return[...this._registry.values()]}_applyTokens(e){const t=this._root.style;for(const[i,n]of Object.entries(nt))t.setProperty(n,e[i])}}const st=`
|
|
1
|
+
(function(D,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(D=typeof globalThis<"u"?globalThis:D||self,$(D.SynclineEditor={}))})(this,function(D){"use strict";var li=Object.defineProperty;var ci=(D,$,K)=>$ in D?li(D,$,{enumerable:!0,configurable:!0,writable:!0,value:K}):D[$]=K;var v=(D,$,K)=>ci(D,typeof $!="symbol"?$+"":$,K);const Zt={typescript:"//",javascript:"//",css:"//",json:"",markdown:"",text:""},ot=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","interface","type","readonly","private","public","protected","static","override","implements","enum","namespace","declare","abstract","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor"]),Qt=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor","static"]),te=new Set(["media","keyframes","import","charset","supports","layer","container","namespace","page","static","relative","absolute","fixed","sticky","block","inline","flex","grid","none","contents","table","hidden","visible","scroll","clip","auto","bold","normal","italic","underline","uppercase","lowercase","capitalize","left","right","center","justify","inherit","initial","unset","revert","pointer","default","transparent","solid","dashed","dotted","double","cover","contain","no-repeat","repeat","var","calc","min","max","clamp"]),ee=new Set(["null","true","false"]),yt=new Set,at=new Set(["number","string","boolean","any","never","unknown","object","Promise","Array","Map","Set","Record","Partial","Required","Readonly","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),ie=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),se=new Set,ne=new Set,wt=new Set,vt={typescript:ot,javascript:Qt,css:te,json:ee,markdown:yt,text:yt},kt={typescript:at,javascript:ie,css:se,json:ne,markdown:wt,text:wt};function xt(r,t){return{fileId:r,doc:[...t],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function re(r,t){switch(r.kind){case"insert":t.splice(r.row,0,...r.lines);break;case"delete":t.splice(r.row,r.count);break;case"replace":t.splice(r.row,r.oldLines.length,...r.newLines);break}}function oe(r,t){switch(r.kind){case"insert":t.splice(r.row,r.lines.length);break;case"delete":t.splice(r.row,0,...r.removed);break;case"replace":t.splice(r.row,r.newLines.length,...r.oldLines);break}}function M(r,t=100,s,i,e,n=[],o=[]){const l={op:s,beforeCur:{...i},beforeSel:e?{...e}:null,afterCur:{...r.cur},afterSel:r.sel?{...r.sel}:null,beforeExtra:n.map(a=>({...a,sel:a.sel?{...a.sel}:null})),afterExtra:o.map(a=>({...a,sel:a.sel?{...a.sel}:null}))};r.undoStack.push(l),r.undoStack.length>t&&r.undoStack.shift(),r.redoStack=[],r.dirty=!0}function ae(r){if(!r.undoStack.length)return null;const t=r.undoStack.pop();return r.redoStack.push(t),oe(t.op,r.doc),r.cur={...t.beforeCur},r.sel=t.beforeSel?{...t.beforeSel}:null,t.beforeExtra.map(s=>({...s,sel:s.sel?{...s.sel}:null}))}function le(r){if(!r.redoStack.length)return null;const t=r.redoStack.pop();return r.undoStack.push(t),re(t.op,r.doc),r.cur={...t.afterCur},r.sel=t.afterSel?{...t.afterSel}:null,t.afterExtra.map(s=>({...s,sel:s.sel?{...s.sel}:null}))}function L(r){const{doc:t,cur:s}=r;s.row=Math.max(0,Math.min(t.length-1,s.row)),s.col=Math.max(0,Math.min((t[s.row]??"").length,s.col))}function A(r){const{ar:t,ac:s,fr:i,fc:e}=r;return t<i||t===i&&s<=e?r:{ar:i,ac:e,fr:t,fc:s}}function Ct(r,t,s){if(!r)return null;const i=A(r);return t<i.ar||t>i.fr?null:{start:t===i.ar?i.ac:0,end:t===i.fr?i.fc:s}}function ce(r){if(!r.sel)return 0;const t=A(r.sel);let s=0;for(let i=t.ar;i<=t.fr;i++){const e=r.doc[i]??"",n=i===t.ar?t.ac:0,o=i===t.fr?t.fc:e.length;s+=o-n}return s}function St(r){if(!r.sel)return"";const t=A(r.sel),s=[];for(let i=t.ar;i<=t.fr;i++){const e=r.doc[i]??"";s.push(e.slice(i===t.ar?t.ac:0,i===t.fr?t.fc:e.length))}return s.join(`
|
|
2
|
+
`)}function lt(r,t){const s=Math.min(r.length,t.length);let i=0;for(;i<s&&r[i]===t[i];)i++;if(i===r.length&&i===t.length)return{row:i,oldLines:[],newLines:[]};let e=r.length-1,n=t.length-1;for(;e>i&&n>i&&r[e]===t[n];)e--,n--;return{row:i,oldLines:r.slice(i,e+1),newLines:t.slice(i,n+1)}}function O(r){const t=r.sel;if(!t)return r.cur;const s=A(t),i=(r.doc[s.ar]??"").slice(0,s.ac),e=(r.doc[s.fr]??"").slice(s.fc);return r.doc.splice(s.ar,s.fr-s.ar+1,i+e),r.sel=null,{row:s.ar,col:s.ac}}function de(r,t,s){if(!s||r.length<=t)return[r];const i=[];let e=0;for(;e<r.length;){if(r.length-e<=t){i.push(r.slice(e));break}const n=e+t;let o=-1;for(let l=n;l>e;l--)if(r[l-1]===" "){o=l;break}o===-1?(i.push(r.slice(e,n)),e=n):(i.push(r.slice(e,o)),e=o)}return i}function he(r,t,s){return!s||r.length<=t?1:Math.max(1,Math.ceil(r.length/t))}function Tt(r,t,s,i,e,n){const o=e!==void 0&&n!==void 0,l=e??0,a=n??r.length-1;if(o&&!s&&i.size===0){const g=[],k=[];for(let f=l;f<=a&&f<r.length;f++){const C=r[f]??"";g[f]=[C],k.push({docLine:f,segIdx:0,text:C})}return{segments:g,visualRows:k,docToVisArr:null,totalVisualRows:r.length,windowVisStart:l}}const d=new Array(r.length),c=new Array(r.length),p=[];let h=0,b=-1,m=0;for(let g=0;g<r.length;g++){if(c[g]=h,g>0&&g<=b){d[g]=[r[g]??""];continue}if(o&&g===l&&(m=h),!o||g>=l&&g<=a){const k=de(r[g]??"",t,s);d[g]=k,k.forEach((f,C)=>p.push({docLine:g,segIdx:C,text:f})),h+=k.length}else d[g]=[],h+=he(r[g]??"",t,s);i.has(g)&&(b=i.get(g))}return{segments:d,visualRows:p,docToVisArr:c,totalVisualRows:h,windowVisStart:m}}function z(r,t,s){const i=r.segments[t];if(!i||i.length===0)return{visRow:r.docToVisArr!==null?r.docToVisArr[t]??t:t,colInSeg:0};const e=r.docToVisArr!==null?r.docToVisArr[t]??t:t;let n=s;for(let o=0;o<i.length;o++){if(n<=i[o].length||o===i.length-1)return{visRow:e+o,colInSeg:Math.min(n,i[o].length)};n-=i[o].length}return{visRow:e,colInSeg:0}}function et(r,t,s){var l,a;const i=t-r.windowVisStart,e=r.visualRows[i];if(!e)return r.docToVisArr===null?{row:Math.max(0,Math.min(r.totalVisualRows-1,t)),col:s}:{row:0,col:0};const n=r.segments[e.docLine]??[""];let o=Math.min(s,((l=n[e.segIdx])==null?void 0:l.length)??0);for(let d=0;d<e.segIdx;d++)o+=((a=n[d])==null?void 0:a.length)??0;return{row:e.docLine,col:o}}function Mt(r){return r.split(`
|
|
3
|
+
`)}function I(r){return r.join(`
|
|
4
|
+
`)}function it(r){return(r.match(/^(\s*)/)??["",""])[1]}function st(r){return" ".repeat(Math.max(0,r))}function Et(r){return/[\w$]/.test(r)}function Lt(r,t,s=Et){let i=t;for(;i>0&&s(r[i-1]);)i--;return i}function Rt(r,t,s=Et){let i=t;for(;i<r.length&&s(r[i]);)i++;return i}function ct(r,t){let s=0,i=null;return(...e)=>{const n=Date.now(),o=t-(n-s);o<=0?(i!==null&&(clearTimeout(i),i=null),s=n,r(...e)):i===null&&(i=setTimeout(()=>{s=Date.now(),i=null,r(...e)},o))}}function pe(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function It(r,t,s,i){r.cursors.some(n=>n.row===t&&n.col===s)||r.cursors.push({row:t,col:s,sel:i})}function At(r){r.cursors=[],r.searchWord="",r.lastMatchRow=-1,r.lastMatchCol=-1}function ue(r,t,s,i,e){const n=[{row:t,col:s,isPrimary:!0,idx:0},...i.map((c,p)=>({row:c.row,col:c.col,isPrimary:!1,idx:p+1}))];n.sort((c,p)=>p.row!==c.row?p.row-c.row:p.col-c.col);const o=r.map(c=>c);let l=t,a=s;const d=i.map(c=>({...c}));for(const c of n){const p=o[c.row]??"";o[c.row]=p.slice(0,c.col)+e+p.slice(c.col);for(const h of n)h!==c&&h.row===c.row&&h.col>=c.col&&(h.col+=e.length);c.col+=e.length}for(const c of n)c.isPrimary?(l=c.row,a=c.col):(d[c.idx-1].row=c.row,d[c.idx-1].col=c.col);return{doc:o,primaryRow:l,primaryCol:a,extraCursors:d}}function dt(r,t,s,i,e,n){const o=[{row:t,col:s,sel:i,isPrimary:!0,idx:0},...e.map((p,h)=>({row:p.row,col:p.col,sel:p.sel,isPrimary:!1,idx:h+1}))];o.sort((p,h)=>h.row!==p.row?h.row-p.row:h.col-p.col);const l=r.slice();let a=t,d=s;const c=e.map(p=>({...p}));for(const p of o){const h=n(l,p.row,p.col,p.sel);if(!h)continue;const{fromRow:b,fromCol:m,toRow:g,toCol:k}=h;if(b===g){const f=l[b]??"";l[b]=f.slice(0,m)+f.slice(k)}else{const f=l[b]??"",C=l[g]??"";l[b]=f.slice(0,m)+C.slice(k),l.splice(b+1,g-b)}p.isPrimary?(a=b,d=m):(c[p.idx-1].row=b,c[p.idx-1].col=m,c[p.idx-1].sel=null)}return{doc:l,primaryRow:a,primaryCol:d,extraCursors:c}}function fe(r,t,s,i,e){let n=r.searchWord;if(!n){if(e&&e.ar===e.fr&&(n=(t[e.ar]??"").slice(e.ac,e.fc),n))return r.searchWord=n,r.lastMatchRow=e.fr,r.lastMatchCol=e.fc,{word:n,sel:{ar:e.ar,ac:e.ac,fr:e.fr,fc:e.fc},row:e.fr,col:e.fc};const a=t[s]??"",d=Lt(a,i),c=Rt(a,i);return n=a.slice(d,c),n?(r.searchWord=n,r.lastMatchRow=s,r.lastMatchCol=c,{word:n,sel:{ar:s,ac:d,fr:s,fc:c},row:s,col:c}):null}const o=r.lastMatchRow,l=r.lastMatchCol;for(let a=o;a<t.length;a++){const d=t[a]??"";let p=a===o?l:0;for(;p<=d.length-n.length;){const h=d.indexOf(n,p);if(h<0)break;const b=h===0||!/\w/.test(d[h-1]),m=h+n.length>=d.length||!/\w/.test(d[h+n.length]);if(b&&m)return r.lastMatchRow=a,r.lastMatchCol=h+n.length,{word:n,sel:{ar:a,ac:h,fr:a,fc:h+n.length},row:a,col:h+n.length};p=h+1}}for(let a=0;a<=o;a++){const d=t[a]??"",c=a===o?l:d.length;let p=0;for(;p<c;){const h=d.indexOf(n,p);if(h<0||h>=c)break;const b=h===0||!/\w/.test(d[h-1]),m=h+n.length>=d.length||!/\w/.test(d[h+n.length]);if(b&&m)return r.lastMatchRow=a,r.lastMatchCol=h+n.length,{word:n,sel:{ar:a,ac:h,fr:a,fc:h+n.length},row:a,col:h+n.length};p=h+1}}return null}function ht(r,t={}){var c,p;if(t.provideTokens)return t.provideTokens(r,t.language??"typescript");const s=[],i=r.length;let e=0;const n=(h,b,m)=>{m>b&&s.push({cls:h,start:b,end:m})},o=vt[t.language??"typescript"]??ot,l=kt[t.language??"typescript"]??at,a=(c=t.extraKeywords)!=null&&c.size?new Set([...o,...t.extraKeywords]):o,d=(p=t.extraTypes)!=null&&p.size?new Set([...l,...t.extraTypes]):l;for(;e<i;){if(r[e]==="/"&&r[e+1]==="/"){n("cmt",e,i);break}if(r[e]==="*"||r[e]==="/"&&r[e+1]==="*"){n("cmt",e,i);break}if(r[e]==="@"){let h=e+1;for(;h<i&&/\w/.test(r[h]);)h++;n("dec",e,h),e=h;continue}if(r[e]==='"'||r[e]==="'"||r[e]==="`"){const h=r[e];let b=e+1;for(;b<i;){if(r[b]==="\\"){b+=2;continue}if(r[b]===h){b++;break}b++}n("str",e,b),e=b;continue}if(/\d/.test(r[e])&&(e===0||!/\w/.test(r[e-1]))){let h=e;for(;h<i&&/[\d._xXa-fA-F]/.test(r[h]);)h++;n("num",e,h),e=h;continue}if(/[a-zA-Z_$]/.test(r[e])){let h=e;for(;h<i&&/[\w$]/.test(r[h]);)h++;const b=r.slice(e,h);a.has(b)?n("kw",e,h):d.has(b)?n("typ",e,h):h<i&&r[h]==="("?n("fn",e,h):/^[A-Z]/.test(b)&&n("cls",e,h),e=h;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(r[e])){n("op",e,e+1),e++;continue}e++}return s}function Ht(r,t){const s=new Array(r.length).fill("");for(const i of t)for(let e=i.start;e<i.end;e++)s[e]=i.cls;return s}class be{constructor(t=5e3){v(this,"_cache",new Map);v(this,"_maxSize");v(this,"_hits",0);v(this,"_misses",0);v(this,"_evictions",0);this._maxSize=t}get metrics(){return{hits:this._hits,misses:this._misses,evictions:this._evictions,size:this._cache.size}}get(t,s){const i=this._cache.get(t);return i&&i.src===s?(this._hits++,i.segs):(this._misses++,null)}set(t,s,i){this._cache.size>=this._maxSize&&(this._cache.delete(this._cache.keys().next().value),this._evictions++),this._cache.set(t,{src:s,segs:i})}invalidateLine(t,s){for(let i=0;i<s;i++)this._cache.delete(`${t}:${i}`)}clear(){this._cache.clear(),this._hits=0,this._misses=0,this._evictions=0}resetMetrics(){this._hits=0,this._misses=0,this._evictions=0}}function B(r,t,s){const i=document.createElement(r);return t&&(i.className=t),i}function q(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function nt(r,t=document.documentElement){return getComputedStyle(t).getPropertyValue(r).trim()}function Dt(r,t){const s=r.replace("#",""),i=parseInt(s.slice(0,2),16),e=parseInt(s.slice(2,4),16),n=parseInt(s.slice(4,6),16);return`rgba(${i},${e},${n},${t})`}function pt(r,t,s,i,e){const n=Math.max(0,r*e-s),o=Math.max(0,r*2-i),a=(n>0?t/n:0)*o,d=Math.max(20,s/e*2),c=t/e*2-a;return{mmScroll:a,sliderTop:c,sliderHeight:d}}function ge(r,t,s,i,e){const n=Math.max(0,t*e-s),o=Math.max(0,t*2-i);if(n<=0)return 0;const l=2/e-o/n;if(Math.abs(l)<1e-9){const a=Math.max(20,s/e*2);return Math.max(0,Math.min(n,r/Math.max(1,i-a)*n))}return Math.max(0,Math.min(n,r/l))}function _e(r,t,s,i,e,n){const o=Math.max(0,t*n-i),l=Math.max(0,t*2-e);if(o<=0)return 0;const a=s/o*l,d=(r+a)/2;return Math.max(0,Math.min(o,d*n-i/2))}function ut(r){const t=s=>{const i=r(s);return i.startsWith("#")&&i.length===7?Dt(i,.85):i};return{kw:t("--tok-kw"),fn:t("--tok-fn"),cls:t("--tok-cls"),typ:t("--tok-typ"),str:t("--tok-str"),num:t("--tok-num"),cmt:t("--tok-cmt"),dec:t("--tok-dec"),op:t("--tok-op"),txt:(()=>{const s=r("--text2");return s.startsWith("#")&&s.length===7?Dt(s,.28):"rgba(150,148,140,0.28)"})()}}function me(r){var J,Z,Q,tt;const{canvas:t,doc:s,firstLine:i,lastLine:e,subPx:n,wrapperWidth:o,canvasHeight:l,cursorRow:a,sel:d,findMatches:c,findIdx:p,sliderTop:h,sliderHeight:b,colors:m,getCssVar:g,dpr:k}=r,f=t.getContext("2d");if(!f)return;f.setTransform(k,0,0,k,0,0);const C=g("--mm-bg")||"#0d0d0f",_=g("--mm-dim")||"rgba(0,0,0,.30)",w=g("--mm-edge")||"rgba(255,255,255,.18)",u=g("--mm-slider")||"rgba(255,255,255,.07)",y=g("--sel-bg")||"rgba(110,159,255,.22)",S=g("--cur-line-bg")||"rgba(255,255,255,.05)",x=g("--find-border")||"rgba(234,180,86,.50)",R=g("--find-cur-bg")||"rgba(234,180,86,.80)",P=T=>(T-i)*2;if(f.fillStyle=C,f.fillRect(0,0,o,l),a>=i&&a<e&&(f.fillStyle=S,f.fillRect(0,P(a),o,2)),d){const T=Math.max(i,d.ar),E=Math.min(e-1,d.fr);E>=T&&(f.fillStyle=y,f.fillRect(0,P(T),o,(E-T+1)*2))}for(const T of c){if(T.row<i||T.row>=e)continue;const E=p>=0&&((J=c[p])==null?void 0:J.row)===T.row&&((Z=c[p])==null?void 0:Z.col)===T.col;f.fillStyle=E?R:x,f.fillRect(3+T.col*1.1,P(T.row),Math.max(3,T.len*1.1),2)}const j=Math.floor((o-3)/1.1);for(let T=i;T<e;T++){const E=s[T]??"";if(!E.trim())continue;const H=P(T),W=1.5,U=`${T}:0:none`;let V=((Q=r.tokenCache)==null?void 0:Q.get(U,E))??null;V||(V=ht(E,{language:r.language,provideTokens:r.provideTokens}),(tt=r.tokenCache)==null||tt.set(U,E,V));let F=0;for(const G of V){if(G.start>=j)break;G.start>F&&(f.fillStyle=m.txt,f.fillRect(3+F*1.1,H,(Math.min(G.start,j)-F)*1.1,W));const ai=m[G.cls]??m.txt,Jt=Math.min(G.end,j)-G.start;Jt>0&&(f.fillStyle=ai,f.fillRect(3+G.start*1.1,H,Jt*1.1,W)),F=Math.max(F,Math.min(G.end,j))}const Xt=Math.min(E.length,j);F<Xt&&(f.fillStyle=m.txt,f.fillRect(3+F*1.1,H,(Xt-F)*1.1,W))}const N=h+n,X=N+b;f.fillStyle=_,N>0&&f.fillRect(0,0,o,N),X<l&&f.fillRect(0,X,o,l-X),f.fillStyle=u,f.fillRect(0,N,o,b),f.fillStyle=w,f.fillRect(0,Math.max(0,N),o,1),f.fillRect(0,Math.max(0,X-1),o,1)}function ye(r,t){const s=n=>/[\w$]/.test(n);let i=t;for(;i<r.length&&s(r[i]);)i++;let e=t;for(;e>0&&s(r[e-1]);)e--;if(e===i)return"";if(e>0&&r[e-1]==="."){let n=e-1,o=n;for(;o>0&&s(r[o-1]);)o--;if(o<n)return r.slice(o,i)}return r.slice(e,i)}const we={console:{title:"console",type:"Console",body:"Provides access to the browser's debugging console. Useful for logging, timing, profiling, and inspecting values during development.",language:["typescript","javascript"]},"console.log":{title:"console.log()",type:"(...data: any[]) => void",body:"Outputs a message to the web console. Accepts any number of arguments — objects are logged as expandable trees, primitives as their string form.",language:["typescript","javascript"]},"console.error":{title:"console.error()",type:"(...data: any[]) => void",body:"Logs an error message to the console, typically rendered in red with a stack trace. Use for unrecoverable failures.",language:["typescript","javascript"]},"console.warn":{title:"console.warn()",type:"(...data: any[]) => void",body:"Logs a warning message to the console, typically rendered in yellow. Use for non-fatal issues or deprecation notices.",language:["typescript","javascript"]},"console.info":{title:"console.info()",type:"(...data: any[]) => void",body:"Logs an informational message. Behaves identically to console.log in most environments.",language:["typescript","javascript"]},"console.table":{title:"console.table()",type:"(data: any, columns?: string[]) => void",body:"Displays an array or object as a formatted table in the console. Optionally restrict displayed columns.",language:["typescript","javascript"]},"console.time":{title:"console.time()",type:"(label?: string) => void",body:"Starts a timer with the given label. Call console.timeEnd() with the same label to log the elapsed time.",language:["typescript","javascript"]},"console.timeEnd":{title:"console.timeEnd()",type:"(label?: string) => void",body:"Stops the timer started by console.time() and logs the elapsed duration in milliseconds.",language:["typescript","javascript"]},"console.group":{title:"console.group()",type:"(...label: any[]) => void",body:"Creates a new inline group in the console output, indenting subsequent messages until console.groupEnd() is called.",language:["typescript","javascript"]},"console.groupEnd":{title:"console.groupEnd()",type:"() => void",body:"Closes the current inline group in the console, exiting the indented group created by console.group().",language:["typescript","javascript"]},Math:{title:"Math",type:"namespace Math",body:"A built-in object with properties and methods for mathematical constants and functions. Not a constructor — all properties and methods are static.",language:["typescript","javascript"]},"Math.max":{title:"Math.max()",type:"(...values: number[]) => number",body:"Returns the largest of the given numbers. Returns -Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.min":{title:"Math.min()",type:"(...values: number[]) => number",body:"Returns the smallest of the given numbers. Returns Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.floor":{title:"Math.floor()",type:"(x: number) => number",body:"Returns the largest integer less than or equal to x. Rounds toward negative infinity.",language:["typescript","javascript"]},"Math.ceil":{title:"Math.ceil()",type:"(x: number) => number",body:"Returns the smallest integer greater than or equal to x. Rounds toward positive infinity.",language:["typescript","javascript"]},"Math.round":{title:"Math.round()",type:"(x: number) => number",body:"Returns the value of x rounded to the nearest integer. Values with a fractional part of exactly 0.5 round up.",language:["typescript","javascript"]},"Math.abs":{title:"Math.abs()",type:"(x: number) => number",body:"Returns the absolute (non-negative) value of x.",language:["typescript","javascript"]},"Math.sqrt":{title:"Math.sqrt()",type:"(x: number) => number",body:"Returns the square root of x. Returns NaN if x is negative.",language:["typescript","javascript"]},"Math.pow":{title:"Math.pow()",type:"(base: number, exponent: number) => number",body:"Returns base raised to the power of exponent. Equivalent to the ** operator.",language:["typescript","javascript"]},"Math.random":{title:"Math.random()",type:"() => number",body:"Returns a pseudo-random floating-point number in the range [0, 1). Not cryptographically secure — use crypto.getRandomValues() for security-sensitive code.",language:["typescript","javascript"]},"Math.PI":{title:"Math.PI",type:"number",body:"The ratio of a circle's circumference to its diameter: approximately 3.14159265358979.",language:["typescript","javascript"]},"Math.trunc":{title:"Math.trunc()",type:"(x: number) => number",body:"Returns the integer part of x by removing any fractional digits. Does not round — simply truncates toward zero.",language:["typescript","javascript"]},"Math.sign":{title:"Math.sign()",type:"(x: number) => number",body:"Returns 1 if x is positive, -1 if x is negative, 0 if x is zero, or NaN if x is not a number.",language:["typescript","javascript"]},"Math.clamp":{title:"Math.clamp()",type:"(value: number, min: number, max: number) => number",body:"Clamps value between min and max. Note: not yet standard — use Math.min(Math.max(value, min), max) for compatibility.",language:["typescript","javascript"]},JSON:{title:"JSON",type:"namespace JSON",body:"Provides methods for parsing and serializing JSON (JavaScript Object Notation). All methods are static.",language:["typescript","javascript"]},"JSON.stringify":{title:"JSON.stringify()",type:"(value: any, replacer?: any, space?: string | number) => string",body:"Converts a JavaScript value to a JSON string. Pass a number or string as the third argument to pretty-print with indentation. Throws on circular references.",language:["typescript","javascript"]},"JSON.parse":{title:"JSON.parse()",type:"(text: string, reviver?: (key: string, value: any) => any) => any",body:"Parses a JSON string and returns the corresponding JavaScript value. Throws SyntaxError if the string is not valid JSON.",language:["typescript","javascript"]},Array:{title:"Array",type:"interface Array<T>",body:"Represents an ordered list of values. Provides methods for traversal, mutation, searching, and transformation.",language:["typescript","javascript"]},"Array.from":{title:"Array.from()",type:"<T>(arrayLike: Iterable<T> | ArrayLike<T>, mapFn?: (v: T, i: number) => T) => T[]",body:"Creates a new Array from an array-like or iterable object (e.g. NodeList, Set, Map, string). Optionally applies a mapping function.",language:["typescript","javascript"]},"Array.isArray":{title:"Array.isArray()",type:"(value: unknown) => value is any[]",body:"Returns true if the given value is an Array. More reliable than instanceof Array across iframe boundaries.",language:["typescript","javascript"]},Object:{title:"Object",type:"interface Object",body:"The base class of all JavaScript objects. Provides static methods for working with object properties, prototypes, and descriptors.",language:["typescript","javascript"]},"Object.keys":{title:"Object.keys()",type:"(obj: object) => string[]",body:"Returns an array of an object's own enumerable string-keyed property names, in insertion order.",language:["typescript","javascript"]},"Object.values":{title:"Object.values()",type:"(obj: object) => any[]",body:"Returns an array of an object's own enumerable string-keyed property values, in insertion order.",language:["typescript","javascript"]},"Object.entries":{title:"Object.entries()",type:"(obj: object) => [string, any][]",body:"Returns an array of [key, value] pairs for all own enumerable string-keyed properties of an object.",language:["typescript","javascript"]},"Object.assign":{title:"Object.assign()",type:"<T, U>(target: T, source: U) => T & U",body:"Copies own enumerable properties from one or more source objects into a target object. Returns the modified target. Does a shallow copy.",language:["typescript","javascript"]},"Object.freeze":{title:"Object.freeze()",type:"<T>(obj: T) => Readonly<T>",body:"Freezes an object — prevents adding, removing, or changing its properties. Returns the same object. Shallow — nested objects are not frozen.",language:["typescript","javascript"]},"Object.create":{title:"Object.create()",type:"(proto: object | null, propertiesObject?: PropertyDescriptorMap) => any",body:"Creates a new object with the specified prototype object and optional property descriptors.",language:["typescript","javascript"]},"Object.fromEntries":{title:"Object.fromEntries()",type:"<T>(entries: Iterable<[string, T]>) => Record<string, T>",body:"Creates an object from an array of [key, value] pairs or any iterable of key-value entries. The inverse of Object.entries().",language:["typescript","javascript"]},Promise:{title:"Promise",type:"interface Promise<T>",body:"Represents an asynchronous operation that will eventually complete (or fail) and produce a value. Use .then(), .catch(), and .finally() to handle outcomes.",language:["typescript","javascript"]},"Promise.all":{title:"Promise.all()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T[]>",body:"Waits for all promises to resolve and returns an array of results. If any promise rejects, the entire result rejects immediately (fail-fast).",language:["typescript","javascript"]},"Promise.allSettled":{title:"Promise.allSettled()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<PromiseSettledResult<T>[]>",body:'Waits for all promises to settle (resolve or reject) and returns an array of result objects, each with a status of "fulfilled" or "rejected". Never rejects.',language:["typescript","javascript"]},"Promise.race":{title:"Promise.race()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T>",body:"Returns a promise that resolves or rejects as soon as one of the given promises resolves or rejects, with that value or reason.",language:["typescript","javascript"]},"Promise.resolve":{title:"Promise.resolve()",type:"<T>(value: T | PromiseLike<T>) => Promise<T>",body:"Returns a Promise object that is resolved with the given value. If the value is a thenable, the returned promise follows it.",language:["typescript","javascript"]},"Promise.reject":{title:"Promise.reject()",type:"(reason?: any) => Promise<never>",body:"Returns a Promise that is rejected with the given reason. Useful for creating pre-rejected promises in control flow.",language:["typescript","javascript"]},setTimeout:{title:"setTimeout()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Executes a function after a specified delay in milliseconds. Returns a timer ID that can be passed to clearTimeout() to cancel.",language:["typescript","javascript"]},clearTimeout:{title:"clearTimeout()",type:"(id: number) => void",body:"Cancels a timeout previously established by setTimeout(), preventing its callback from running.",language:["typescript","javascript"]},setInterval:{title:"setInterval()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Repeatedly executes a function with a fixed time delay between each call. Returns a timer ID for cancellation via clearInterval().",language:["typescript","javascript"]},clearInterval:{title:"clearInterval()",type:"(id: number) => void",body:"Cancels a repeating timer established by setInterval().",language:["typescript","javascript"]},requestAnimationFrame:{title:"requestAnimationFrame()",type:"(callback: (timestamp: DOMHighResTimeStamp) => void) => number",body:"Schedules a callback to run before the next browser repaint. Ideal for animations — the browser can batch and throttle calls to 60fps or the display refresh rate.",language:["typescript","javascript"]},cancelAnimationFrame:{title:"cancelAnimationFrame()",type:"(id: number) => void",body:"Cancels an animation frame request previously scheduled with requestAnimationFrame().",language:["typescript","javascript"]},queueMicrotask:{title:"queueMicrotask()",type:"(callback: () => void) => void",body:"Queues a microtask to be executed before the next task in the event loop. Runs after the current JavaScript execution but before any setTimeout callbacks.",language:["typescript","javascript"]},fetch:{title:"fetch()",type:"(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>",body:"Fetches a resource from the network. Returns a Promise that resolves to a Response. Use .json(), .text(), or .blob() on the response to read the body.",language:["typescript","javascript"]},parseInt:{title:"parseInt()",type:"(string: string, radix?: number) => number",body:"Parses a string and returns an integer in the specified radix (base). Always provide the radix (typically 10) to avoid unexpected behavior with leading zeros.",language:["typescript","javascript"]},parseFloat:{title:"parseFloat()",type:"(string: string) => number",body:"Parses a string and returns a floating-point number. Returns NaN if the string cannot be converted.",language:["typescript","javascript"]},isNaN:{title:"isNaN()",type:"(value: number) => boolean",body:"Returns true if the value is NaN (Not a Number). Note: coerces the argument to number first — use Number.isNaN() for strict checking without coercion.",language:["typescript","javascript"]},isFinite:{title:"isFinite()",type:"(value: number) => boolean",body:"Returns true if the value is a finite number. Returns false for ±Infinity and NaN. Coerces the argument to number first.",language:["typescript","javascript"]},encodeURIComponent:{title:"encodeURIComponent()",type:"(uriComponent: string | number | boolean) => string",body:"Encodes a URI component by replacing special characters with their UTF-8 escape sequences. Use for encoding query string values before appending to a URL.",language:["typescript","javascript"]},decodeURIComponent:{title:"decodeURIComponent()",type:"(encodedURIComponent: string) => string",body:"Decodes a URI component that was previously encoded with encodeURIComponent(). Throws URIError on malformed sequences.",language:["typescript","javascript"]},structuredClone:{title:"structuredClone()",type:"<T>(value: T, options?: StructuredSerializeOptions) => T",body:"Creates a deep clone of the given value using the structured clone algorithm. Handles cycles, Maps, Sets, Dates, and typed arrays. Does not clone functions or class instances.",language:["typescript","javascript"]},"document.getElementById":{title:"document.getElementById()",type:"(elementId: string) => HTMLElement | null",body:"Returns the first element in the document with the specified ID, or null if not found. IDs must be unique per document.",language:["typescript","javascript"]},"document.querySelector":{title:"document.querySelector()",type:"(selectors: string) => Element | null",body:"Returns the first Element matching the given CSS selector string, or null if no match. Use querySelectorAll() for all matches.",language:["typescript","javascript"]},"document.querySelectorAll":{title:"document.querySelectorAll()",type:"(selectors: string) => NodeListOf<Element>",body:"Returns a static NodeList of all Elements matching the given CSS selector string. Does not update as the document changes.",language:["typescript","javascript"]},"document.createElement":{title:"document.createElement()",type:"<K extends keyof HTMLElementTagNameMap>(tagName: K) => HTMLElementTagNameMap[K]",body:"Creates a new HTML element with the specified tag name. The element is not attached to the DOM until you call appendChild() or similar.",language:["typescript","javascript"]},addEventListener:{title:"addEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void",body:"Registers an event listener on the target element. The listener is called whenever the specified event fires. Remember to call removeEventListener() to clean up.",language:["typescript","javascript"]},removeEventListener:{title:"removeEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void",body:"Removes an event listener previously added with addEventListener(). The listener reference must be the same function object.",language:["typescript","javascript"]},const:{title:"const",type:"keyword",body:"Declares a block-scoped variable that cannot be reassigned. The binding is immutable — but for objects and arrays, their contents can still be mutated.",language:["typescript","javascript"]},let:{title:"let",type:"keyword",body:"Declares a block-scoped variable that can be reassigned. Prefer const for bindings that never change.",language:["typescript","javascript"]},var:{title:"var",type:"keyword",body:"Declares a function-scoped (or globally-scoped) variable. Hoisted to the top of its scope. Prefer const or let in modern code.",language:["typescript","javascript"]},function:{title:"function",type:"keyword",body:"Defines a named function declaration, or introduces a function expression. Function declarations are hoisted; expressions are not.",language:["typescript","javascript"]},class:{title:"class",type:"keyword",body:"Declares a class — a blueprint for creating objects with shared methods and properties. Classes support extends, implements, constructors, getters, setters, and static members.",language:["typescript","javascript"]},async:{title:"async",type:"keyword",body:"Marks a function as asynchronous, making it return a Promise implicitly. Enables the use of the await keyword inside the function body.",language:["typescript","javascript"]},await:{title:"await",type:"keyword",body:"Pauses execution of an async function until the Promise settles, then returns the resolved value. Must be used inside an async function.",language:["typescript","javascript"]},return:{title:"return",type:"keyword",body:"Exits the current function and optionally returns a value to the caller. In an async function, the value is wrapped in a resolved Promise.",language:["typescript","javascript"]},interface:{title:"interface",type:"keyword",body:"Defines a TypeScript interface — a named contract describing the shape of an object. Interfaces can be extended, merged (declaration merging), and implemented by classes.",language:["typescript"]},type:{title:"type",type:"keyword",body:"Declares a TypeScript type alias — a name for any type expression including unions, intersections, tuples, mapped types, and conditional types.",language:["typescript"]},extends:{title:"extends",type:"keyword",body:"Establishes inheritance (class extends Base) or constrains a generic type parameter (T extends object). Also used in conditional types (T extends U ? X : Y).",language:["typescript","javascript"]},implements:{title:"implements",type:"keyword",body:"Declares that a class satisfies the shape of one or more interfaces. TypeScript verifies at compile time that all required members are present.",language:["typescript"]},export:{title:"export",type:"keyword",body:"Makes a declaration (variable, function, class, type, interface) available for import in other modules. Use export default for a single primary export.",language:["typescript","javascript"]},import:{title:"import",type:"keyword",body:"Imports bindings from another module. Supports named imports ({ foo, bar }), default imports (Foo), namespace imports (* as Foo), and side-effect imports.",language:["typescript","javascript"]},typeof:{title:"typeof",type:"keyword",body:'Returns a string describing the type of its operand at runtime ("string", "number", "boolean", "object", "function", "undefined", "symbol", "bigint"). In TypeScript, also used as a type operator to capture the type of a value.',language:["typescript","javascript"]},instanceof:{title:"instanceof",type:"keyword",body:"Tests whether an object has a given constructor in its prototype chain. Returns true if the object is an instance of the constructor.",language:["typescript","javascript"]},new:{title:"new",type:"keyword",body:"Creates a new instance of a class or constructor function. Allocates memory, sets the prototype, calls the constructor with `this` bound to the new object, and returns it.",language:["typescript","javascript"]},throw:{title:"throw",type:"keyword",body:"Throws a user-defined exception, stopping execution of the current function and propagating up the call stack until caught by a try...catch block.",language:["typescript","javascript"]},try:{title:"try...catch...finally",type:"keyword",body:"Wraps code that might throw an exception. The catch block handles errors; the finally block always runs whether or not an error occurred.",language:["typescript","javascript"]},string:{title:"string",type:"primitive type",body:'Represents a sequence of UTF-16 code units. In TypeScript, the string type accepts any text value. Literal types like "hello" narrow to specific string values.',language:["typescript"]},number:{title:"number",type:"primitive type",body:"Represents a double-precision 64-bit IEEE 754 floating-point value. Includes integers, decimals, NaN, and Infinity. TypeScript does not have a separate int type.",language:["typescript"]},boolean:{title:"boolean",type:"primitive type",body:"Represents a logical true or false value. Literal types true and false narrow to specific boolean values.",language:["typescript"]},any:{title:"any",type:"TypeScript type",body:"Disables type checking for a value — allows any operation without compile errors. Avoid using any; prefer unknown when the type is genuinely uncertain.",language:["typescript"]},unknown:{title:"unknown",type:"TypeScript type",body:"The type-safe alternative to any. You cannot perform operations on an unknown value without first narrowing its type with typeof, instanceof, or a type guard.",language:["typescript"]},void:{title:"void",type:"TypeScript type",body:"Represents the absence of a value, typically used as the return type of functions that do not return anything meaningful.",language:["typescript"]},never:{title:"never",type:"TypeScript type",body:"A type with no values — used for functions that never return (throw or infinite loop) and for exhaustive checks in union type switches.",language:["typescript"]},Record:{title:"Record<K, V>",type:"type Record<K extends keyof any, T> = { [P in K]: T }",body:"A utility type that constructs an object type whose keys are of type K and values are of type V. Useful for dictionaries and lookup tables.",language:["typescript"]},Partial:{title:"Partial<T>",type:"type Partial<T> = { [P in keyof T]?: T[P] }",body:"A utility type that makes all properties of T optional. Useful for update payloads, patches, and configuration objects with defaults.",language:["typescript"]},Required:{title:"Required<T>",type:"type Required<T> = { [P in keyof T]-?: T[P] }",body:"A utility type that makes all properties of T required (removes optionality). The inverse of Partial<T>.",language:["typescript"]},Readonly:{title:"Readonly<T>",type:"type Readonly<T> = { readonly [P in keyof T]: T[P] }",body:"A utility type that makes all properties of T readonly. Prevents property reassignment at the type level.",language:["typescript"]},ReturnType:{title:"ReturnType<T>",type:"type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any",body:"A utility type that extracts the return type of a function type T.",language:["typescript"]},Omit:{title:"Omit<T, K>",type:"type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>",body:"A utility type that constructs a type by picking all properties from T then removing those in K.",language:["typescript"]},Pick:{title:"Pick<T, K>",type:"type Pick<T, K extends keyof T> = { [P in K]: T[P] }",body:"A utility type that constructs a type by picking the set of properties K from T.",language:["typescript"]},NonNullable:{title:"NonNullable<T>",type:"type NonNullable<T> = T extends null | undefined ? never : T",body:"A utility type that removes null and undefined from the type T.",language:["typescript"]},keyof:{title:"keyof",type:"TypeScript type operator",body:'Produces a union type of all property keys of an object type. keyof { a: string; b: number } is "a" | "b".',language:["typescript"]}};function ve(r,t){const s=we[r];return!s||s.language&&!(Array.isArray(s.language)?s.language:[s.language]).includes(t)?null:s}const ke=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Bt(r){const t=r.trim();if(!t)return null;try{const s=ft(t);return s===t?null:s}catch{return null}}function ft(r){if(r.includes(">")){const s=r.indexOf(">");return bt(r.slice(0,s),ft(r.slice(s+1)))}if(r.includes("+"))return r.split("+").map(s=>ft(s.trim())).join(`
|
|
5
|
+
`);const t=r.match(/^(.+)\*(\d+)$/);if(t){const s=parseInt(t[2],10);return Array.from({length:s},(i,e)=>bt(t[1],`$${e+1}`)).join(`
|
|
6
|
+
`)}return bt(r,"$1")}function bt(r,t){const s=r.match(/#([\w-]+)/),i=r.match(/\.([\w.-]+)/g),e=r.match(/\[([^\]]+)\]/);let n=r.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",o="";return s&&(o+=` id="${s[1]}"`),i&&(o+=` class="${i.map(l=>l.slice(1)).join(" ")}"`),e&&(o+=` ${e[1]}`),ke.has(n)?`<${n}${o}>`:`<${n}${o}>${t}</${n}>`}function jt(r,t){let s=t;for(;s>0&&/[\w#.[\]*>+{}()$@:-]/.test(r[s-1]);)s--;const i=r.slice(s,t);return i.length<2?null:{abbr:i,start:s}}const xe=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
7
|
+
|
|
8
|
+
function name(params) {
|
|
9
|
+
// body
|
|
10
|
+
}`,body:`function $1($2) {
|
|
11
|
+
$3
|
|
12
|
+
}`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
|
|
13
|
+
|
|
14
|
+
const name = (params) => {
|
|
15
|
+
// body
|
|
16
|
+
};`,body:`const $1 = ($2) => {
|
|
17
|
+
$3
|
|
18
|
+
};`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
|
|
19
|
+
|
|
20
|
+
async function name(params): Promise<T> {
|
|
21
|
+
// body
|
|
22
|
+
}`,body:`async function $1($2): Promise<$3> {
|
|
23
|
+
$4
|
|
24
|
+
}`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
|
|
25
|
+
|
|
26
|
+
class Name {
|
|
27
|
+
constructor(params) { ... }
|
|
28
|
+
}`,body:`class $1 {
|
|
29
|
+
constructor($2) {
|
|
30
|
+
$3
|
|
31
|
+
}
|
|
32
|
+
}`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
|
|
33
|
+
|
|
34
|
+
for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
|
|
35
|
+
$3
|
|
36
|
+
}`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
|
|
37
|
+
|
|
38
|
+
for (const key in object) { ... }`,body:`for (const $1 in $2) {
|
|
39
|
+
$3
|
|
40
|
+
}`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
...
|
|
44
|
+
} catch (error) {
|
|
45
|
+
...
|
|
46
|
+
}`,body:`try {
|
|
47
|
+
$1
|
|
48
|
+
} catch ($2error) {
|
|
49
|
+
$3
|
|
50
|
+
}`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
|
|
51
|
+
|
|
52
|
+
new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
|
|
53
|
+
$2
|
|
54
|
+
})`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
|
|
55
|
+
|
|
56
|
+
import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
|
|
57
|
+
|
|
58
|
+
interface Name {
|
|
59
|
+
field: Type;
|
|
60
|
+
}`,body:`interface $1 {
|
|
61
|
+
$2: $3;
|
|
62
|
+
}`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
|
|
63
|
+
|
|
64
|
+
((params) => {
|
|
65
|
+
...
|
|
66
|
+
})(args);`,body:`(($1) => {
|
|
67
|
+
$2
|
|
68
|
+
})($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
|
|
69
|
+
|
|
70
|
+
switch (expr) {
|
|
71
|
+
case value:
|
|
72
|
+
...
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
...
|
|
76
|
+
}`,body:`switch ($1) {
|
|
77
|
+
case $2:
|
|
78
|
+
$3
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
$4
|
|
82
|
+
}`}],Ce=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
83
|
+
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;`,body:`display: flex;
|
|
87
|
+
align-items: $1center;
|
|
88
|
+
justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
|
|
89
|
+
|
|
90
|
+
display: grid;
|
|
91
|
+
grid-template-columns: repeat(3, 1fr);
|
|
92
|
+
gap: 16px;`,body:`display: grid;
|
|
93
|
+
grid-template-columns: $1repeat(3, 1fr);
|
|
94
|
+
gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
|
|
95
|
+
|
|
96
|
+
@media (max-width: 768px) {
|
|
97
|
+
...
|
|
98
|
+
}`,body:`@media ($1max-width: 768px) {
|
|
99
|
+
$2
|
|
100
|
+
}`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
|
|
101
|
+
|
|
102
|
+
@keyframes name {
|
|
103
|
+
from { ... }
|
|
104
|
+
to { ... }
|
|
105
|
+
}`,body:`@keyframes $1 {
|
|
106
|
+
from { $2 }
|
|
107
|
+
to { $3 }
|
|
108
|
+
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
109
|
+
|
|
110
|
+
--name: value;`,body:"--$1: $2;",language:["css"]}],Se=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary>Title</summary>
|
|
114
|
+
<div>content</div>
|
|
115
|
+
</details>`,body:`<details>
|
|
116
|
+
<summary>$1Title</summary>
|
|
117
|
+
<div>
|
|
118
|
+
$2
|
|
119
|
+
</div>
|
|
120
|
+
</details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
|
|
121
|
+
<div class="card-header">$1</div>
|
|
122
|
+
<div class="card-body">$2</div>
|
|
123
|
+
<div class="card-footer">$3</div>
|
|
124
|
+
</div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
|
|
125
|
+
|
|
126
|
+
<nav class="navbar">
|
|
127
|
+
<a href="#">Home</a> ...
|
|
128
|
+
</nav>`,body:`<nav class="navbar">
|
|
129
|
+
<a href="$1#">Home</a>
|
|
130
|
+
<a href="$2#">About</a>
|
|
131
|
+
<a href="$3#">Contact</a>
|
|
132
|
+
</nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
|
|
133
|
+
|
|
134
|
+
<div class="modal">
|
|
135
|
+
<div class="modal-dialog"> ... </div>
|
|
136
|
+
</div>`,body:`<div class="modal">
|
|
137
|
+
<div class="modal-dialog">
|
|
138
|
+
<div class="modal-header">$1</div>
|
|
139
|
+
<div class="modal-body">$2</div>
|
|
140
|
+
<div class="modal-footer">$3</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
|
|
143
|
+
|
|
144
|
+
<table>
|
|
145
|
+
<thead><tr><th>...</th></tr></thead>
|
|
146
|
+
<tbody><tr><td>...</td></tr></tbody>
|
|
147
|
+
</table>`,body:`<table>
|
|
148
|
+
<thead>
|
|
149
|
+
<tr>
|
|
150
|
+
<th>$1</th>
|
|
151
|
+
</tr>
|
|
152
|
+
</thead>
|
|
153
|
+
<tbody>
|
|
154
|
+
<tr>
|
|
155
|
+
<td>$2</td>
|
|
156
|
+
</tr>
|
|
157
|
+
</tbody>
|
|
158
|
+
</table>`}];function Te(r){const t=[...Se];return(r==="typescript"||r==="javascript")&&t.push(...xe.filter(s=>!s.language||(Array.isArray(s.language)?s.language.includes(r):s.language===r))),r==="css"&&t.push(...Ce),t}function Me(r,t,s){let i=t;for(;i>0&&/\w/.test(r[i-1]);)i--;const e=r.slice(i,t);if(!e)return null;const n=s.find(o=>o.kind==="snip"&&o.label===e);return n?{snippet:n,start:i}:null}const gt=[{label:"console.log",kind:"fn",detail:"void"},{label:"console.error",kind:"fn",detail:"void"},{label:"console.warn",kind:"fn",detail:"void"},{label:"console.info",kind:"fn",detail:"void"},{label:"console.table",kind:"fn",detail:"void"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null"},{label:"document.querySelector",kind:"fn",detail:"Element | null"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeList"},{label:"document.createElement",kind:"fn",detail:"HTMLElement"},{label:"document.createTextNode",kind:"fn",detail:"Text"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"removeEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number"},{label:"cancelAnimationFrame",kind:"fn",detail:"(id) => void"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => id"},{label:"clearTimeout",kind:"fn",detail:"(id) => void"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => id"},{label:"clearInterval",kind:"fn",detail:"(id) => void"},{label:"JSON.stringify",kind:"fn",detail:"string"},{label:"JSON.parse",kind:"fn",detail:"any"},{label:"Math.max",kind:"fn",detail:"number"},{label:"Math.min",kind:"fn",detail:"number"},{label:"Math.floor",kind:"fn",detail:"number"},{label:"Math.ceil",kind:"fn",detail:"number"},{label:"Math.round",kind:"fn",detail:"number"},{label:"Math.abs",kind:"fn",detail:"number"},{label:"Math.pow",kind:"fn",detail:"number"},{label:"Math.sqrt",kind:"fn",detail:"number"},{label:"Math.random",kind:"fn",detail:"number"},{label:"Object.keys",kind:"fn",detail:"string[]"},{label:"Object.values",kind:"fn",detail:"any[]"},{label:"Object.entries",kind:"fn",detail:"[string, any][]"},{label:"Object.assign",kind:"fn",detail:"T & U"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>"},{label:"Object.create",kind:"fn",detail:"object"},{label:"Array.from",kind:"fn",detail:"T[]"},{label:"Array.isArray",kind:"fn",detail:"boolean"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>"},{label:"Promise.allSettled",kind:"fn",detail:"Promise<...>"},{label:"parseInt",kind:"fn",detail:"number"},{label:"parseFloat",kind:"fn",detail:"number"},{label:"isNaN",kind:"fn",detail:"boolean"},{label:"isFinite",kind:"fn",detail:"boolean"},{label:"encodeURIComponent",kind:"fn",detail:"string"},{label:"decodeURIComponent",kind:"fn",detail:"string"},{label:"structuredClone",kind:"fn",detail:"T"},{label:"queueMicrotask",kind:"fn",detail:"void"},{label:"fetch",kind:"fn",detail:"Promise<Response>"}],Ee={typescript:gt,javascript:gt,css:[{label:"display",kind:"var",detail:"property"},{label:"position",kind:"var",detail:"property"},{label:"top",kind:"var",detail:"property"},{label:"right",kind:"var",detail:"property"},{label:"bottom",kind:"var",detail:"property"},{label:"left",kind:"var",detail:"property"},{label:"width",kind:"var",detail:"property"},{label:"height",kind:"var",detail:"property"},{label:"min-width",kind:"var",detail:"property"},{label:"max-width",kind:"var",detail:"property"},{label:"min-height",kind:"var",detail:"property"},{label:"max-height",kind:"var",detail:"property"},{label:"z-index",kind:"var",detail:"property"},{label:"overflow",kind:"var",detail:"property"},{label:"overflow-x",kind:"var",detail:"property"},{label:"overflow-y",kind:"var",detail:"property"},{label:"box-sizing",kind:"var",detail:"property"},{label:"flex",kind:"var",detail:"property"},{label:"flex-direction",kind:"var",detail:"property"},{label:"flex-wrap",kind:"var",detail:"property"},{label:"flex-grow",kind:"var",detail:"property"},{label:"flex-shrink",kind:"var",detail:"property"},{label:"flex-basis",kind:"var",detail:"property"},{label:"flex-flow",kind:"var",detail:"property"},{label:"align-items",kind:"var",detail:"property"},{label:"align-content",kind:"var",detail:"property"},{label:"align-self",kind:"var",detail:"property"},{label:"justify-content",kind:"var",detail:"property"},{label:"justify-items",kind:"var",detail:"property"},{label:"justify-self",kind:"var",detail:"property"},{label:"gap",kind:"var",detail:"property"},{label:"row-gap",kind:"var",detail:"property"},{label:"column-gap",kind:"var",detail:"property"},{label:"grid",kind:"var",detail:"property"},{label:"grid-template",kind:"var",detail:"property"},{label:"grid-template-columns",kind:"var",detail:"property"},{label:"grid-template-rows",kind:"var",detail:"property"},{label:"grid-template-areas",kind:"var",detail:"property"},{label:"grid-column",kind:"var",detail:"property"},{label:"grid-row",kind:"var",detail:"property"},{label:"grid-area",kind:"var",detail:"property"},{label:"grid-auto-flow",kind:"var",detail:"property"},{label:"margin",kind:"var",detail:"property"},{label:"margin-top",kind:"var",detail:"property"},{label:"margin-right",kind:"var",detail:"property"},{label:"margin-bottom",kind:"var",detail:"property"},{label:"margin-left",kind:"var",detail:"property"},{label:"padding",kind:"var",detail:"property"},{label:"padding-top",kind:"var",detail:"property"},{label:"padding-right",kind:"var",detail:"property"},{label:"padding-bottom",kind:"var",detail:"property"},{label:"padding-left",kind:"var",detail:"property"},{label:"color",kind:"var",detail:"property"},{label:"font",kind:"var",detail:"property"},{label:"font-family",kind:"var",detail:"property"},{label:"font-size",kind:"var",detail:"property"},{label:"font-weight",kind:"var",detail:"property"},{label:"font-style",kind:"var",detail:"property"},{label:"line-height",kind:"var",detail:"property"},{label:"text-align",kind:"var",detail:"property"},{label:"text-decoration",kind:"var",detail:"property"},{label:"text-transform",kind:"var",detail:"property"},{label:"letter-spacing",kind:"var",detail:"property"},{label:"word-spacing",kind:"var",detail:"property"},{label:"white-space",kind:"var",detail:"property"},{label:"word-break",kind:"var",detail:"property"},{label:"word-wrap",kind:"var",detail:"property"},{label:"text-overflow",kind:"var",detail:"property"},{label:"background",kind:"var",detail:"property"},{label:"background-color",kind:"var",detail:"property"},{label:"background-image",kind:"var",detail:"property"},{label:"background-size",kind:"var",detail:"property"},{label:"background-position",kind:"var",detail:"property"},{label:"background-repeat",kind:"var",detail:"property"},{label:"background-clip",kind:"var",detail:"property"},{label:"background-attachment",kind:"var",detail:"property"},{label:"border",kind:"var",detail:"property"},{label:"border-width",kind:"var",detail:"property"},{label:"border-style",kind:"var",detail:"property"},{label:"border-color",kind:"var",detail:"property"},{label:"border-radius",kind:"var",detail:"property"},{label:"border-top",kind:"var",detail:"property"},{label:"border-right",kind:"var",detail:"property"},{label:"border-bottom",kind:"var",detail:"property"},{label:"border-left",kind:"var",detail:"property"},{label:"outline",kind:"var",detail:"property"},{label:"outline-width",kind:"var",detail:"property"},{label:"outline-style",kind:"var",detail:"property"},{label:"outline-color",kind:"var",detail:"property"},{label:"outline-offset",kind:"var",detail:"property"},{label:"opacity",kind:"var",detail:"property"},{label:"box-shadow",kind:"var",detail:"property"},{label:"text-shadow",kind:"var",detail:"property"},{label:"filter",kind:"var",detail:"property"},{label:"backdrop-filter",kind:"var",detail:"property"},{label:"transform",kind:"var",detail:"property"},{label:"transform-origin",kind:"var",detail:"property"},{label:"transition",kind:"var",detail:"property"},{label:"animation",kind:"var",detail:"property"},{label:"animation-name",kind:"var",detail:"property"},{label:"animation-duration",kind:"var",detail:"property"},{label:"animation-timing-function",kind:"var",detail:"property"},{label:"animation-delay",kind:"var",detail:"property"},{label:"animation-iteration-count",kind:"var",detail:"property"},{label:"animation-fill-mode",kind:"var",detail:"property"},{label:"cursor",kind:"var",detail:"property"},{label:"pointer-events",kind:"var",detail:"property"},{label:"user-select",kind:"var",detail:"property"},{label:"resize",kind:"var",detail:"property"},{label:"visibility",kind:"var",detail:"property"},{label:"content",kind:"var",detail:"property"},{label:"list-style",kind:"var",detail:"property"},{label:"will-change",kind:"var",detail:"property"},{label:"appearance",kind:"var",detail:"property"},{label:"clip-path",kind:"var",detail:"property"},{label:"object-fit",kind:"var",detail:"property"},{label:"object-position",kind:"var",detail:"property"},{label:"scroll-behavior",kind:"var",detail:"property"},{label:"aspect-ratio",kind:"var",detail:"property"},{label:"var",kind:"fn",detail:"css fn"},{label:"calc",kind:"fn",detail:"css fn"},{label:"min",kind:"fn",detail:"css fn"},{label:"max",kind:"fn",detail:"css fn"},{label:"clamp",kind:"fn",detail:"css fn"},{label:"rgb",kind:"fn",detail:"css fn"},{label:"rgba",kind:"fn",detail:"css fn"},{label:"hsl",kind:"fn",detail:"css fn"},{label:"hsla",kind:"fn",detail:"css fn"},{label:"oklch",kind:"fn",detail:"css fn"},{label:"linear-gradient",kind:"fn",detail:"css fn"},{label:"radial-gradient",kind:"fn",detail:"css fn"},{label:"conic-gradient",kind:"fn",detail:"css fn"},{label:"translate",kind:"fn",detail:"css fn"},{label:"scale",kind:"fn",detail:"css fn"},{label:"rotate",kind:"fn",detail:"css fn"},{label:"skew",kind:"fn",detail:"css fn"},{label:"matrix",kind:"fn",detail:"css fn"},{label:"perspective",kind:"fn",detail:"css fn"},{label:"url",kind:"fn",detail:"css fn"},{label:"attr",kind:"fn",detail:"css fn"},{label:"env",kind:"fn",detail:"css fn"},{label:"repeat",kind:"fn",detail:"css fn"},{label:"minmax",kind:"fn",detail:"css fn"},{label:"fit-content",kind:"fn",detail:"css fn"}],json:[],markdown:[],text:[]};function Pt(r,t,s){const i=vt[r]??ot,e=kt[r]??at,n=Ee[r]??gt;return[...[...i,...t].map(o=>({label:o,kind:"kw",detail:"keyword"})),...[...e,...s].map(o=>({label:o,kind:"typ",detail:"type"})),...n]}function Le(r,t){const s=new Set;for(const i of r){const e=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const n of e)n!==t&&n.length>2&&s.add(n)}return s}function Wt(r,t){return r.language?Array.isArray(r.language)?r.language.includes(t):r.language===t:!0}function Re(r,t,s={},i=0,e=0){if(t.length<2)return[];const n=t.toLowerCase(),{language:o="typescript",extraKeywords:l=[],extraTypes:a=[],completions:d=[],replaceBuiltins:c=!1,maxResults:p=14}=s,h=d.filter(u=>u.kind==="snip"&&!!u.body&&Wt(u,o)),b=d.filter(u=>!(u.kind==="snip"&&u.body)&&Wt(u,o)),m=h.filter(u=>u.label.toLowerCase().startsWith(n));let g;if(s.provideCompletions){const u={line:r[i]??"",col:e,prefix:t,language:o,doc:r};let y;try{y=s.provideCompletions(u)}catch(S){console.error("[syncline-editor] provideCompletions threw an error:",S),y=null}g=y!=null?[...y,...b]:[...c?[]:Pt(o,l,a),...b]}else g=c?b:[...Pt(o,l,a),...b];const k=new Set(g.map(u=>u.label)),f=g.filter(u=>u.label.toLowerCase().startsWith(n)&&u.label!==t),C=new Set(m.map(u=>u.label)),w=[...Le(r,t)].filter(u=>u.toLowerCase().startsWith(n)&&!k.has(u)&&!C.has(u)).slice(0,8).map(u=>({label:u,kind:"var",detail:"in file"}));return[...m,...f.filter(u=>!C.has(u.label)),...w].slice(0,p)}function Ie(r,t,s=!1){let i=t;for(;i>0&&(s?/[\w$.\-]/:/[\w$.]/).test(r[i-1]);)i--;return{prefix:r.slice(i,t),start:i}}function Ae(r,t,s){if(!t)return[];const i=[];for(let e=0;e<r.length;e++){const n=r[e]??"";if(s.useRegex)try{const o=new RegExp(t,s.caseSensitive?"g":"gi");let l;for(;(l=o.exec(n))!==null&&(i.push({row:e,col:l.index,len:l[0].length}),!!l[0].length););}catch{}else{const o=s.caseSensitive?n:n.toLowerCase(),l=s.caseSensitive?t:t.toLowerCase();let a=0;for(;;){const d=o.indexOf(l,a);if(d===-1)break;i.push({row:e,col:d,len:t.length}),a=d+1}}}return i}function He(r,t,s,i){const e=t[s];if(!e)return r;const n=[...r],o=n[e.row]??"";return n[e.row]=o.slice(0,e.col)+i+o.slice(e.col+e.len),n}function De(r,t,s){const i=[...r];for(let e=t.length-1;e>=0;e--){const n=t[e],o=i[n.row]??"";i[n.row]=o.slice(0,n.col)+s+o.slice(n.col+n.len)}return i}function Be(r,t,s){return r.length?(t+s+r.length)%r.length:-1}function je(r,t){const s=r[t]??"";let i=0;for(const e of s)e==="{"?i++:e==="}"&&i--;return i>0}function Pe(r,t){let s=0;for(let i=t;i<r.length;i++)for(const e of r[i]??"")if(e==="{")s++;else if(e==="}"&&(s--,s===0))return i;return null}function We(r,t,s){const i=new Map(r);if(i.has(s))i.delete(s);else{const e=Pe(t,s);e!==null&&e>s&&i.set(s,e)}return i}function $e(r){var J,Z,Q,tt;const{vr:t,visIdx:s,curVisRow:i,wm:e,foldedLines:n,isFoldable:o,opts:l}=r,{docLine:a,segIdx:d,text:c}=t,p=s===i,h=a===((J=e.visualRows[i-e.windowVisStart])==null?void 0:J.docLine),b=d>0,m=((Z=e.segments[a])==null?void 0:Z.slice(0,d).reduce((T,E)=>T+E.length,0))??0,g=r.docSel?Ct(r.docSel,a,((Q=(e.segments[a]??[""])[d])==null?void 0:Q.length)??0):null;let k=null;if(g){const T=((tt=(e.segments[a]??[""])[d])==null?void 0:tt.length)??0,E=Ct(r.docSel,a,T+m);if(E){const H=E.start-m,W=E.end-m;W>0&&H<c.length&&(k={start:Math.max(0,H),end:Math.min(c.length,W)})}}const f=r.findMatches.filter(T=>T.row===a).map(T=>{var U,V;const E=T.col-m,H=T.col+T.len-m;if(H<=0||E>=c.length)return null;const W=r.findIdx>=0&&((U=r.findMatches[r.findIdx])==null?void 0:U.row)===T.row&&((V=r.findMatches[r.findIdx])==null?void 0:V.col)===T.col;return{start:Math.max(0,E),end:Math.min(c.length,H),isCur:W}}).filter(Boolean),C=r.wordHighlights.filter(T=>T.row===a).map(T=>{const E=T.col-m,H=T.col+T.len-m;return H<=0||E>=c.length?null:{start:Math.max(0,E),end:Math.min(c.length,H)}}).filter(Boolean),_=[];if(r.bracketMatch){for(const T of[r.bracketMatch.open,r.bracketMatch.close])if(T.row===a){const E=T.col-m;E>=0&&E<c.length&&_.push({start:E,end:E+1})}}const w=[],u=[];for(const T of r.extraCursors){const E=z(e,T.row,T.col);if(E.visRow===s&&w.push(E.colInSeg),T.sel){const H=Oe(T.sel);if(a>=H.ar&&a<=H.fr){const W=a===H.ar?H.ac-m:-m,U=a===H.fr?H.fc-m:c.length+999;U>0&&W<c.length&&u.push({start:Math.max(0,W),end:Math.min(c.length,U)})}}}const y=Ne(c,l.renderWhitespace),S=p||k||f.length||w.length||C.length||_.length||u.length||r.snippetStopCols.length>0;let x;if(S)x=Fe(y,p?r.curColInSeg:-1,k,f,w,r.snippetStopCols,C,_,u,l.tokeniserOpts);else{const T=`${a}:${d}:${l.renderWhitespace}`;let E=r.tokenCache.get(T,y);E||(E=ht(y,l.tokeniserOpts),r.tokenCache.set(T,y,E)),x=Ue(y,E)||"​"}let R="";if(d===0&&l.showIndentGuides){const T=(c.match(/^(\s*)/)??["",""])[1].length,E=Math.floor(T/l.tabSize);for(let H=1;H<E;H++){const W=l.codePaddingLeft+H*l.tabSize*l.charWidth;R+=`<span class="sl-ig" style="left:${W}px"></span>`}}let P="";if(d===0&&o){const T=n.has(a);P=`<span class="sl-fold-btn" data-row="${a}">${T?"▸":"▾"}</span>`}const j=n.has(a)&&d===0,N=d===0?String(a+1):"";return`<div class="${["sl-er",l.highlightActiveLine&&h?"sl-cur-row":"",b?"sl-wrap-cont":"",j?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${l.lineHeight}px" data-v="${s}" data-doc="${a}"><div class="sl-eg" style="position:relative">${P}<span class="sl-egn">${N}</span></div><div class="sl-el"><span class="sl-cl">${R}${x}</span></div></div>`}function Ne(r,t){if(t==="none")return r;if(t==="all")return r.replace(/ /g,"·").replace(/\t/g,"→");const s=(r.match(/^ +/)??[""])[0].length,i=(r.match(/ +$/)??[""])[0].length;let e=r;return s&&(e="·".repeat(s)+e.slice(s)),i&&(e=e.slice(0,e.length-i)+"·".repeat(i)),e.replace(/\t/g,"→")}function Oe(r){return r.ar<r.fr||r.ar===r.fr&&r.ac<=r.fc?r:{ar:r.fr,ac:r.fc,fr:r.ar,fc:r.ac}}function Ue(r,t){if(!r)return"";const s=Ht(r,t);let i="",e=0,n=s[0];const o=l=>{if(l<=e)return;const a=q(r.slice(e,l));i+=n?`<span class="${n}">${a}</span>`:a};for(let l=1;l<=r.length;l++){const a=l<r.length?s[l]:null;a!==n&&(o(l),e=l,n=a??"")}return i}function Fe(r,t,s,i,e,n,o,l,a,d){if(r.length===0){let f=t>=0?'<span class="sl-cur"></span>':"";for(const C of e)f+='<span class="sl-cur-extra"></span>';for(const C of n)f+='<span class="sl-snip-stop"></span>';return f||"​"}const c=ht(r,d),p=Ht(r,c);let h="",b=0,m="",g="";const k=f=>{if(f<=b)return;const C=q(r.slice(b,f)),_=[m,g].filter(Boolean).join(" ");h+=_?`<span class="${_}">${C}</span>`:C};for(let f=0;f<=r.length;f++){t===f&&(k(f),b=f,h+='<span class="sl-cur"></span>');for(const x of e)x===f&&(k(f),b=f,h+='<span class="sl-cur-extra"></span>');for(const x of n)x===f&&(k(f),b=f,h+='<span class="sl-snip-stop"></span>');if(f===r.length){k(f);break}const C=p[f],_=i.find(x=>f>=x.start&&f<x.end),w=s&&f>=s.start&&f<s.end||a.some(x=>f>=x.start&&f<x.end),u=!w&&!_&&o.some(x=>f>=x.start&&f<x.end),y=!w&&!_&&l.some(x=>f>=x.start&&f<x.end);let S="";w?S="sl-sh":_?S="sl-fh"+(_.isCur?" sl-fh-cur":""):y?S="sl-bm":u&&(S="sl-wh"),(S!==m||C!==g)&&(k(f),b=f,m=S,g=C)}return h||"​"}const _t={"(":")","{":"}","[":"]"},mt={")":"(","}":"{","]":"["};function Ge(r,t){const{row:s,col:i}=t,e=r[s]??"";let n=e[i],o=i;if(!_t[n]&&!mt[n]&&(n=e[i-1],o=i-1),!n)return null;if(_t[n]){const l=_t[n];let a=0;for(let d=s;d<Math.min(r.length,s+500);d++){const c=r[d]??"",p=d===s?o:0;for(let h=p;h<c.length;h++)if(c[h]===n)a++;else if(c[h]===l&&(a--,a===0))return{open:{row:s,col:o},close:{row:d,col:h}}}}else if(mt[n]){const l=mt[n];let a=0;for(let d=s;d>=Math.max(0,s-500);d--){const c=r[d]??"",p=d===s?o:c.length-1;for(let h=p;h>=0;h--)if(c[h]===n)a++;else if(c[h]===l&&(a--,a===0))return{open:{row:d,col:h},close:{row:s,col:o}}}}return null}function ze(r,t,s,i,e=0,n=r.length-1){if(i)return[];const o=r[t]??"",l=Lt(o,s),a=Rt(o,s),d=o.slice(l,a);if(!d||d.length<2)return[];const c=[],p=Math.min(n,r.length-1);for(let h=Math.max(0,e);h<=p;h++){const b=r[h]??"";let m=0;for(;m<=b.length-d.length;){const g=b.indexOf(d,m);if(g<0)break;const k=g===0||!/\w/.test(b[g-1]),f=g+d.length>=b.length||!/\w/.test(b[g+d.length]);k&&f&&!(h===t&&g===l)&&c.push({row:h,col:g,len:d.length}),m=g+1}}return c}const $t={id:"",name:"VR Dark",description:"Default deep dark theme",light:!1,tokens:{bg0:"#0d0d0f",bg1:"#111115",bg2:"#16161b",bg3:"#1d1d24",bg4:"#24242d",border:"rgba(255,255,255,.07)",border2:"rgba(255,255,255,.12)",border3:"rgba(255,255,255,.19)",text:"#c9c7c0",text2:"#8b8994",text3:"#4e4c58",accent:"#6e9fff",accent2:"#2f5db0",green:"#4ec9a0",orange:"#d4976e",purple:"#b48eff",red:"#f28b82",yellow:"#e8c97a",cur:"#6e9fff",curGlow:"rgba(110,159,255,.65)",curLineBg:"rgba(255,255,255,.032)",curLineGutter:"#181820",gutterBg:"#0f0f12",gutterHover:"#181820",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#4e4c58",gutterNumAct:"#9997a2",selBg:"rgba(110,159,255,.22)",wordHlBg:"rgba(200,198,210,.09)",wordHlBorder:"rgba(200,198,210,.28)",bmBorder:"rgba(110,159,255,.65)",foldBg:"rgba(110,159,255,.07)",foldBorder:"rgba(110,159,255,.30)",findBg:"rgba(234,180,86,.18)",findBorder:"rgba(234,180,86,.50)",findCurBg:"rgba(234,180,86,.80)",findCurBorder:"rgba(234,180,86,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(110,159,255,.11)",fileActiveText:"#6e9fff",mmBg:"#0d0d0f",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#6e9fff",tokStr:"#4ec9a0",tokCmt:"#4e4c58",tokFn:"#d4976e",tokNum:"#b48eff",tokCls:"#e8c97a",tokOp:"#55536a",tokTyp:"#6ec9d4",tokDec:"#f28b82"}},Nt={id:"vscode-dark",name:"VSCode Dark+",description:"Visual Studio Code dark",light:!1,tokens:{bg0:"#1e1e1e",bg1:"#252526",bg2:"#1e1e1e",bg3:"#2d2d30",bg4:"#3a3a3d",border:"rgba(255,255,255,.09)",border2:"rgba(255,255,255,.15)",border3:"rgba(255,255,255,.24)",text:"#d4d4d4",text2:"#9a9a9a",text3:"#505050",accent:"#569cd6",accent2:"#0e639c",green:"#4ec9b0",orange:"#ce9178",purple:"#c586c0",red:"#f44747",yellow:"#dcdcaa",cur:"#aeafad",curGlow:"rgba(174,175,173,.40)",curLineBg:"rgba(255,255,255,.038)",curLineGutter:"#282828",gutterBg:"#1e1e1e",gutterHover:"#282828",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#838383",gutterNumAct:"#c8c8c8",selBg:"rgba(38,79,120,.65)",wordHlBg:"rgba(173,214,255,.06)",wordHlBorder:"rgba(173,214,255,.28)",bmBorder:"rgba(86,156,214,.70)",foldBg:"rgba(86,156,214,.07)",foldBorder:"rgba(86,156,214,.35)",findBg:"rgba(255,215,0,.13)",findBorder:"rgba(255,215,0,.52)",findCurBg:"#f6f6a0",findCurBorder:"#d4d400",findCurText:"#000",fileActiveBg:"rgba(255,255,255,.07)",fileActiveText:"#d4d4d4",mmBg:"#1e1e1e",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#569cd6",tokStr:"#ce9178",tokCmt:"#6a9955",tokFn:"#dcdcaa",tokNum:"#b5cea8",tokCls:"#4ec9b0",tokOp:"#d4d4d4",tokTyp:"#4ec9b0",tokDec:"#9cdcfe"}},Ot={id:"monokai",name:"Monokai",description:"Classic Sublime Text theme",light:!1,tokens:{bg0:"#272822",bg1:"#1e1f1c",bg2:"#272822",bg3:"#3a3930",bg4:"#48473d",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.13)",border3:"rgba(255,255,255,.20)",text:"#f8f8f2",text2:"#a8a7a0",text3:"#58574e",accent:"#a6e22e",accent2:"#3d5a10",green:"#a6e22e",orange:"#fd971f",purple:"#ae81ff",red:"#f92672",yellow:"#e6db74",cur:"#f8f8f2",curGlow:"rgba(248,248,242,.25)",curLineBg:"rgba(255,255,255,.042)",curLineGutter:"#2c2d27",gutterBg:"#1e1f1c",gutterHover:"#2c2d27",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#6e6d64",gutterNumAct:"#cccac0",selBg:"rgba(73,72,62,.80)",wordHlBg:"rgba(248,248,242,.06)",wordHlBorder:"rgba(248,248,242,.22)",bmBorder:"rgba(166,226,46,.65)",foldBg:"rgba(166,226,46,.07)",foldBorder:"rgba(166,226,46,.30)",findBg:"rgba(230,219,116,.16)",findBorder:"rgba(230,219,116,.52)",findCurBg:"#e6db74",findCurBorder:"#c9be50",findCurText:"#272822",fileActiveBg:"rgba(166,226,46,.10)",fileActiveText:"#a6e22e",mmBg:"#1e1f1c",mmSlider:"rgba(255,255,255,.06)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#f92672",tokStr:"#e6db74",tokCmt:"#75715e",tokFn:"#a6e22e",tokNum:"#ae81ff",tokCls:"#66d9e8",tokOp:"#f8f8f2",tokTyp:"#66d9e8",tokDec:"#fd971f"}},Ut={id:"dracula",name:"Dracula",description:"Purple-tinted dark theme",light:!1,tokens:{bg0:"#282a36",bg1:"#21222c",bg2:"#282a36",bg3:"#333545",bg4:"#44475a",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.14)",border3:"rgba(255,255,255,.22)",text:"#f8f8f2",text2:"#b2b5c8",text3:"#5a5e78",accent:"#bd93f9",accent2:"#5b3fa8",green:"#50fa7b",orange:"#ffb86c",purple:"#bd93f9",red:"#ff5555",yellow:"#f1fa8c",cur:"#f8f8f2",curGlow:"rgba(189,147,249,.55)",curLineBg:"rgba(255,255,255,.045)",curLineGutter:"#2f3144",gutterBg:"#21222c",gutterHover:"#2f3144",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#5e638a",gutterNumAct:"#f8f8f2",selBg:"rgba(68,71,90,.85)",wordHlBg:"rgba(248,248,242,.05)",wordHlBorder:"rgba(248,248,242,.20)",bmBorder:"rgba(189,147,249,.70)",foldBg:"rgba(189,147,249,.08)",foldBorder:"rgba(189,147,249,.35)",findBg:"rgba(241,250,140,.14)",findBorder:"rgba(241,250,140,.52)",findCurBg:"#f1fa8c",findCurBorder:"#d4dc50",findCurText:"#282a36",fileActiveBg:"rgba(189,147,249,.12)",fileActiveText:"#bd93f9",mmBg:"#21222c",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#ff79c6",tokStr:"#f1fa8c",tokCmt:"#6272a4",tokFn:"#50fa7b",tokNum:"#bd93f9",tokCls:"#8be9fd",tokOp:"#f8f8f2",tokTyp:"#8be9fd",tokDec:"#ffb86c"}},Ft={id:"github-light",name:"GitHub Light",description:"GitHub's clean light theme",light:!0,tokens:{bg0:"#ffffff",bg1:"#f6f8fa",bg2:"#ffffff",bg3:"#f0f3f6",bg4:"#e7eaee",border:"#d0d7de",border2:"#bdc4cc",border3:"#aab1ba",text:"#1f2328",text2:"#57606a",text3:"#8c959f",accent:"#0969da",accent2:"#0550ae",green:"#1a7f37",orange:"#bc4c00",purple:"#8250df",red:"#cf222e",yellow:"#7d4e00",cur:"#0969da",curGlow:"rgba(9,105,218,.30)",curLineBg:"rgba(9,105,218,.055)",curLineGutter:"#ebf0f8",gutterBg:"#f6f8fa",gutterHover:"#eaedf1",gutterBorder:"#d0d7de",gutterNum:"#9da5b0",gutterNumAct:"#1f2328",selBg:"rgba(9,105,218,.15)",wordHlBg:"rgba(9,105,218,.07)",wordHlBorder:"rgba(9,105,218,.28)",bmBorder:"rgba(9,105,218,.60)",foldBg:"rgba(9,105,218,.06)",foldBorder:"rgba(9,105,218,.28)",findBg:"rgba(180,100,0,.09)",findBorder:"rgba(180,100,0,.42)",findCurBg:"rgba(180,100,0,.75)",findCurBorder:"rgba(180,100,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(9,105,218,.09)",fileActiveText:"#0969da",mmBg:"#f6f8fa",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.09)",tokKw:"#cf222e",tokStr:"#0a3069",tokCmt:"#6e7781",tokFn:"#8250df",tokNum:"#0550ae",tokCls:"#953800",tokOp:"#1f2328",tokTyp:"#0550ae",tokDec:"#0969da"}},Gt={id:"solarized-light",name:"Solarized Light",description:"Warm precision light theme",light:!0,tokens:{bg0:"#fdf6e3",bg1:"#eee8d5",bg2:"#fdf6e3",bg3:"#e5dfcc",bg4:"#dad4c1",border:"#cdc7b4",border2:"#bab4a2",border3:"#a9a390",text:"#002b36",text2:"#586e75",text3:"#93a1a1",accent:"#268bd2",accent2:"#1a6fa8",green:"#859900",orange:"#cb4b16",purple:"#6c71c4",red:"#dc322f",yellow:"#b58900",cur:"#268bd2",curGlow:"rgba(38,139,210,.32)",curLineBg:"rgba(38,139,210,.07)",curLineGutter:"#e2dcc8",gutterBg:"#eee8d5",gutterHover:"#e2dcc8",gutterBorder:"#cdc7b4",gutterNum:"#93a1a1",gutterNumAct:"#002b36",selBg:"rgba(38,139,210,.18)",wordHlBg:"rgba(38,139,210,.08)",wordHlBorder:"rgba(38,139,210,.28)",bmBorder:"rgba(38,139,210,.58)",foldBg:"rgba(38,139,210,.07)",foldBorder:"rgba(38,139,210,.28)",findBg:"rgba(181,137,0,.11)",findBorder:"rgba(181,137,0,.42)",findCurBg:"rgba(181,137,0,.75)",findCurBorder:"rgba(181,137,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(38,139,210,.10)",fileActiveText:"#268bd2",mmBg:"#eee8d5",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.16)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#859900",tokStr:"#2aa198",tokCmt:"#93a1a1",tokFn:"#268bd2",tokNum:"#d33682",tokCls:"#b58900",tokOp:"#657b83",tokTyp:"#268bd2",tokDec:"#cb4b16"}},zt={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},Vt={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Kt=[$t,Nt,Ot,Ut,Ft,Gt,zt,Vt],Ve={bg0:"--bg0",bg1:"--bg1",bg2:"--bg2",bg3:"--bg3",bg4:"--bg4",border:"--border",border2:"--border2",border3:"--border3",text:"--text",text2:"--text2",text3:"--text3",accent:"--accent",accent2:"--accent2",green:"--green",orange:"--orange",purple:"--purple",red:"--red",yellow:"--yellow",cur:"--cur",curGlow:"--cur-glow",curLineBg:"--cur-line-bg",curLineGutter:"--cur-line-gutter",gutterBg:"--gutter-bg",gutterHover:"--gutter-hover",gutterBorder:"--gutter-border",gutterNum:"--gutter-num",gutterNumAct:"--gutter-num-act",selBg:"--sel-bg",wordHlBg:"--word-hl-bg",wordHlBorder:"--word-hl-border",bmBorder:"--bm-border",foldBg:"--fold-bg",foldBorder:"--fold-border",findBg:"--find-bg",findBorder:"--find-border",findCurBg:"--find-cur-bg",findCurBorder:"--find-cur-border",findCurText:"--find-cur-text",fileActiveBg:"--file-active-bg",fileActiveText:"--file-active-text",mmBg:"--mm-bg",mmSlider:"--mm-slider",mmDim:"--mm-dim",mmEdge:"--mm-edge",indentGuide:"--indent-guide",tokKw:"--tok-kw",tokStr:"--tok-str",tokCmt:"--tok-cmt",tokFn:"--tok-fn",tokNum:"--tok-num",tokCls:"--tok-cls",tokOp:"--tok-op",tokTyp:"--tok-typ",tokDec:"--tok-dec"};class Ke{constructor(t){v(this,"_registry",new Map);v(this,"_activeId","");v(this,"_root");this._root=t;for(const s of Kt)this._registry.set(s.id,s)}register(t){this._registry.set(t.id,t)}apply(t){let s;typeof t=="string"?(s=this._registry.get(t),s||(console.warn(`[syncline-editor] Unknown theme: "${t}". Falling back to VR Dark.`),s=this._registry.get(""))):(s=t,this._registry.set(s.id,s)),this._activeId=s.id,this._applyTokens(s.tokens)}get activeId(){return this._activeId}get activeTheme(){return this._registry.get(this._activeId)}get allIds(){return[...this._registry.keys()]}get all(){return[...this._registry.values()]}_applyTokens(t){const s=this._root.style;for(const[i,e]of Object.entries(Ve))s.setProperty(e,t[i])}}const qe=`
|
|
3
159
|
/* ── Reset ── */
|
|
4
160
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
5
161
|
|
|
@@ -284,163 +440,7 @@
|
|
|
284
440
|
/* ── Empty state ── */
|
|
285
441
|
.sl-empty{flex:1;display:flex;flex-direction:column;align-items:center;
|
|
286
442
|
justify-content:center;gap:10px;color:var(--text3);font-size:13px}
|
|
287
|
-
|
|
288
|
-
`)}function D(s){return s.join(`
|
|
289
|
-
`)}function De(s){return(s.match(/^(\s*)/)??["",""])[1]}function Q(s){return" ".repeat(Math.max(0,s))}function He(s){return/[\w$]/.test(s)}function re(s,e,t=He){let i=e;for(;i>0&&t(s[i-1]);)i--;return i}function se(s,e,t=He){let i=e;for(;i<s.length&&t(s[i]);)i++;return i}function oe(s,e){let t=0,i=null;return(...n)=>{const r=Date.now(),o=e-(r-t);o<=0?(i!==null&&(clearTimeout(i),i=null),t=r,s(...n)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,s(...n)},o))}}const ot={fontSize:[8,72,13],lineHeight:[14,64,22],tabSize:[1,16,2],wrapColumn:[20,500,80],maxCompletions:[1,50,14],autocompletePrefixLength:[1,10,2],gutterWidth:[30,200,60],minimapWidth:[60,300,120],cursorBlinkRate:[200,5e3,1050],maxUndoHistory:[10,5e3,300],undoBatchMs:[0,5e3,700]};function at(s,e,t,i){const n=Number(s);return Number.isFinite(n)?Math.max(e,Math.min(t,Math.round(n))):i}function Re(s){const e={...s};for(const[t,i]of Object.entries(ot))if(t in s&&s[t]!==void 0){const[n,r,o]=i;e[t]=at(s[t],n,r,o)}return e}const ae={"(":")","{":"}","[":"]"},le={")":"(","}":"{","]":"["};function lt(s,e){const{row:t,col:i}=e,n=s[t]??"";let r=n[i],o=i;if(!ae[r]&&!le[r]&&(r=n[i-1],o=i-1),!r)return null;if(ae[r]){const l=ae[r];let a=0;for(let c=t;c<Math.min(s.length,t+500);c++){const d=s[c]??"",h=c===t?o:0;for(let p=h;p<d.length;p++)if(d[p]===r)a++;else if(d[p]===l&&(a--,a===0))return{open:{row:t,col:o},close:{row:c,col:p}}}}else if(le[r]){const l=le[r];let a=0;for(let c=t;c>=Math.max(0,t-500);c--){const d=s[c]??"",h=c===t?o:d.length-1;for(let p=h;p>=0;p--)if(d[p]===r)a++;else if(d[p]===l&&(a--,a===0))return{open:{row:c,col:p},close:{row:t,col:o}}}}return null}function ct(s,e){const t=s[e]??"";let i=0;for(const n of t)n==="{"?i++:n==="}"&&i--;return i>0}function dt(s,e){let t=0;for(let i=e;i<s.length;i++)for(const n of s[i]??"")if(n==="{")t++;else if(n==="}"&&(t--,t===0))return i;return null}function pt(s,e,t){const i=new Map(s);if(i.has(t))i.delete(t);else{const n=dt(e,t);n!==null&&n>t&&i.set(t,n)}return i}const ht=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Be(s){const e=s.trim();if(!e)return null;try{const t=ce(e);return t===e?null:t}catch{return null}}function ce(s){if(s.includes(">")){const t=s.indexOf(">");return de(s.slice(0,t),ce(s.slice(t+1)))}if(s.includes("+"))return s.split("+").map(t=>ce(t.trim())).join(`
|
|
290
|
-
`);const e=s.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,n)=>de(e[1],`$${n+1}`)).join(`
|
|
291
|
-
`)}return de(s,"$1")}function de(s,e){const t=s.match(/#([\w-]+)/),i=s.match(/\.([\w.-]+)/g),n=s.match(/\[([^\]]+)\]/);let r=s.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",o="";return t&&(o+=` id="${t[1]}"`),i&&(o+=` class="${i.map(l=>l.slice(1)).join(" ")}"`),n&&(o+=` ${n[1]}`),ht.has(r)?`<${r}${o}>`:`<${r}${o}>${e}</${r}>`}function je(s,e){let t=e;for(;t>0&&/[\w#.[\]*>+{}()$@:-]/.test(s[t-1]);)t--;const i=s.slice(t,e);return i.length<2?null:{abbr:i,start:t}}const ut=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
292
|
-
|
|
293
|
-
function name(params) {
|
|
294
|
-
// body
|
|
295
|
-
}`,body:`function $1($2) {
|
|
296
|
-
$3
|
|
297
|
-
}`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
|
|
298
|
-
|
|
299
|
-
const name = (params) => {
|
|
300
|
-
// body
|
|
301
|
-
};`,body:`const $1 = ($2) => {
|
|
302
|
-
$3
|
|
303
|
-
};`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
|
|
304
|
-
|
|
305
|
-
async function name(params): Promise<T> {
|
|
306
|
-
// body
|
|
307
|
-
}`,body:`async function $1($2): Promise<$3> {
|
|
308
|
-
$4
|
|
309
|
-
}`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
|
|
310
|
-
|
|
311
|
-
class Name {
|
|
312
|
-
constructor(params) { ... }
|
|
313
|
-
}`,body:`class $1 {
|
|
314
|
-
constructor($2) {
|
|
315
|
-
$3
|
|
316
|
-
}
|
|
317
|
-
}`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
|
|
318
|
-
|
|
319
|
-
for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
|
|
320
|
-
$3
|
|
321
|
-
}`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
|
|
322
|
-
|
|
323
|
-
for (const key in object) { ... }`,body:`for (const $1 in $2) {
|
|
324
|
-
$3
|
|
325
|
-
}`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
|
|
326
|
-
|
|
327
|
-
try {
|
|
328
|
-
...
|
|
329
|
-
} catch (error) {
|
|
330
|
-
...
|
|
331
|
-
}`,body:`try {
|
|
332
|
-
$1
|
|
333
|
-
} catch ($2error) {
|
|
334
|
-
$3
|
|
335
|
-
}`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
|
|
336
|
-
|
|
337
|
-
new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
|
|
338
|
-
$2
|
|
339
|
-
})`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
|
|
340
|
-
|
|
341
|
-
import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
|
|
342
|
-
|
|
343
|
-
interface Name {
|
|
344
|
-
field: Type;
|
|
345
|
-
}`,body:`interface $1 {
|
|
346
|
-
$2: $3;
|
|
347
|
-
}`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
|
|
348
|
-
|
|
349
|
-
((params) => {
|
|
350
|
-
...
|
|
351
|
-
})(args);`,body:`(($1) => {
|
|
352
|
-
$2
|
|
353
|
-
})($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
|
|
354
|
-
|
|
355
|
-
switch (expr) {
|
|
356
|
-
case value:
|
|
357
|
-
...
|
|
358
|
-
break;
|
|
359
|
-
default:
|
|
360
|
-
...
|
|
361
|
-
}`,body:`switch ($1) {
|
|
362
|
-
case $2:
|
|
363
|
-
$3
|
|
364
|
-
break;
|
|
365
|
-
default:
|
|
366
|
-
$4
|
|
367
|
-
}`}],ft=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
368
|
-
|
|
369
|
-
display: flex;
|
|
370
|
-
align-items: center;
|
|
371
|
-
justify-content: center;`,body:`display: flex;
|
|
372
|
-
align-items: $1center;
|
|
373
|
-
justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
|
|
374
|
-
|
|
375
|
-
display: grid;
|
|
376
|
-
grid-template-columns: repeat(3, 1fr);
|
|
377
|
-
gap: 16px;`,body:`display: grid;
|
|
378
|
-
grid-template-columns: $1repeat(3, 1fr);
|
|
379
|
-
gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
|
|
380
|
-
|
|
381
|
-
@media (max-width: 768px) {
|
|
382
|
-
...
|
|
383
|
-
}`,body:`@media ($1max-width: 768px) {
|
|
384
|
-
$2
|
|
385
|
-
}`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
|
|
386
|
-
|
|
387
|
-
@keyframes name {
|
|
388
|
-
from { ... }
|
|
389
|
-
to { ... }
|
|
390
|
-
}`,body:`@keyframes $1 {
|
|
391
|
-
from { $2 }
|
|
392
|
-
to { $3 }
|
|
393
|
-
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
394
|
-
|
|
395
|
-
--name: value;`,body:"--$1: $2;",language:["css"]}],gt=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
396
|
-
|
|
397
|
-
<details>
|
|
398
|
-
<summary>Title</summary>
|
|
399
|
-
<div>content</div>
|
|
400
|
-
</details>`,body:`<details>
|
|
401
|
-
<summary>$1Title</summary>
|
|
402
|
-
<div>
|
|
403
|
-
$2
|
|
404
|
-
</div>
|
|
405
|
-
</details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
|
|
406
|
-
<div class="card-header">$1</div>
|
|
407
|
-
<div class="card-body">$2</div>
|
|
408
|
-
<div class="card-footer">$3</div>
|
|
409
|
-
</div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
|
|
410
|
-
|
|
411
|
-
<nav class="navbar">
|
|
412
|
-
<a href="#">Home</a> ...
|
|
413
|
-
</nav>`,body:`<nav class="navbar">
|
|
414
|
-
<a href="$1#">Home</a>
|
|
415
|
-
<a href="$2#">About</a>
|
|
416
|
-
<a href="$3#">Contact</a>
|
|
417
|
-
</nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
|
|
418
|
-
|
|
419
|
-
<div class="modal">
|
|
420
|
-
<div class="modal-dialog"> ... </div>
|
|
421
|
-
</div>`,body:`<div class="modal">
|
|
422
|
-
<div class="modal-dialog">
|
|
423
|
-
<div class="modal-header">$1</div>
|
|
424
|
-
<div class="modal-body">$2</div>
|
|
425
|
-
<div class="modal-footer">$3</div>
|
|
426
|
-
</div>
|
|
427
|
-
</div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
|
|
428
|
-
|
|
429
|
-
<table>
|
|
430
|
-
<thead><tr><th>...</th></tr></thead>
|
|
431
|
-
<tbody><tr><td>...</td></tr></tbody>
|
|
432
|
-
</table>`,body:`<table>
|
|
433
|
-
<thead>
|
|
434
|
-
<tr>
|
|
435
|
-
<th>$1</th>
|
|
436
|
-
</tr>
|
|
437
|
-
</thead>
|
|
438
|
-
<tbody>
|
|
439
|
-
<tr>
|
|
440
|
-
<td>$2</td>
|
|
441
|
-
</tr>
|
|
442
|
-
</tbody>
|
|
443
|
-
</table>`}];function bt(s){const e=[...gt];return(s==="typescript"||s==="javascript")&&e.push(...ut.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(s):t.language===s))),s==="css"&&e.push(...ft),e}function mt(s,e,t){let i=e;for(;i>0&&/\w/.test(s[i-1]);)i--;const n=s.slice(i,e);if(!n)return null;const r=t.find(o=>o.kind==="snip"&&o.label===n);return r?{snippet:r,start:i}:null}function _t(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function Pe(s,e,t,i){s.cursors.some(r=>r.row===e&&r.col===t)||s.cursors.push({row:e,col:t,sel:i})}function $e(s){s.cursors=[],s.searchWord="",s.lastMatchRow=-1,s.lastMatchCol=-1}function yt(s,e,t,i,n){const r=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((d,h)=>({row:d.row,col:d.col,isPrimary:!1,idx:h+1}))];r.sort((d,h)=>h.row!==d.row?h.row-d.row:h.col-d.col);const o=s.map(d=>d);let l=e,a=t;const c=i.map(d=>({...d}));for(const d of r){const h=o[d.row]??"";o[d.row]=h.slice(0,d.col)+n+h.slice(d.col);for(const p of r)p!==d&&p.row===d.row&&p.col>=d.col&&(p.col+=n.length);d.col+=n.length,d.isPrimary?(l=d.row,a=d.col):(c[d.idx-1].row=d.row,c[d.idx-1].col=d.col)}return{doc:o,primaryRow:l,primaryCol:a,extraCursors:c}}function vt(s,e,t,i){const n=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((c,d)=>({row:c.row,col:c.col,isPrimary:!1,idx:d+1}))];n.sort((c,d)=>d.row!==c.row?d.row-c.row:d.col-c.col);const r=s.map(c=>c);let o=e,l=t;const a=i.map(c=>({...c}));for(const c of n){if(c.col<=0)continue;const d=r[c.row]??"";r[c.row]=d.slice(0,c.col-1)+d.slice(c.col);for(const h of n)h!==c&&h.row===c.row&&h.col>c.col&&h.col--;c.col--,c.isPrimary?(o=c.row,l=c.col):a[c.idx-1].col=c.col}return{doc:r,primaryRow:o,primaryCol:l,extraCursors:a}}function wt(s,e,t,i,n){let r=s.searchWord;if(!r){if(n&&n.ar===n.fr&&(r=(e[n.ar]??"").slice(n.ac,n.fc)),!r){const a=e[t]??"",c=re(a,i),d=se(a,i);r=a.slice(c,d)}if(!r)return null;s.searchWord=r,s.lastMatchRow=t,s.lastMatchCol=i}const o=s.lastMatchRow,l=s.lastMatchCol;for(let a=o;a<e.length;a++){const c=e[a]??"";let h=a===o?l:0;for(;h<=c.length-r.length;){const p=c.indexOf(r,h);if(p<0)break;const f=p===0||!/\w/.test(c[p-1]),_=p+r.length>=c.length||!/\w/.test(c[p+r.length]);if(f&&_)return s.lastMatchRow=a,s.lastMatchCol=p+r.length,{word:r,sel:{ar:a,ac:p,fr:a,fc:p+r.length},row:a,col:p+r.length};h=p+1}}for(let a=0;a<=o;a++){const c=e[a]??"",d=a===o?l:c.length;let h=0;for(;h<d;){const p=c.indexOf(r,h);if(p<0||p>=d)break;const f=p===0||!/\w/.test(c[p-1]),_=p+r.length>=c.length||!/\w/.test(c[p+r.length]);if(f&&_)return s.lastMatchRow=a,s.lastMatchCol=p+r.length,{word:r,sel:{ar:a,ac:p,fr:a,fc:p+r.length},row:a,col:p+r.length};h=p+1}}return null}function kt(s,e,t){if(!e)return[];const i=[];for(let n=0;n<s.length;n++){const r=s[n]??"";if(t.useRegex)try{const o=new RegExp(e,t.caseSensitive?"g":"gi");let l;for(;(l=o.exec(r))!==null&&(i.push({row:n,col:l.index,len:l[0].length}),!!l[0].length););}catch{}else{const o=t.caseSensitive?r:r.toLowerCase(),l=t.caseSensitive?e:e.toLowerCase();let a=0;for(;;){const c=o.indexOf(l,a);if(c===-1)break;i.push({row:n,col:c,len:e.length}),a=c+1}}}return i}function xt(s,e,t,i){const n=e[t];if(!n)return s;const r=[...s],o=r[n.row]??"";return r[n.row]=o.slice(0,n.col)+i+o.slice(n.col+n.len),r}function Tt(s,e,t){const i=[...s];for(let n=e.length-1;n>=0;n--){const r=e[n],o=i[r.row]??"";i[r.row]=o.slice(0,r.col)+t+o.slice(r.col+r.len)}return i}function Et(s,e,t){return s.length?(e+t+s.length)%s.length:-1}function Ct(s,e,t,i){if(i)return[];const n=s[e]??"",r=re(n,t),o=se(n,t),l=n.slice(r,o);if(!l||l.length<2)return[];const a=[];for(let c=0;c<s.length;c++){const d=s[c]??"";let h=0;for(;h<=d.length-l.length;){const p=d.indexOf(l,h);if(p<0)break;const f=p===0||!/\w/.test(d[p-1]),_=p+l.length>=d.length||!/\w/.test(d[p+l.length]);f&&_&&!(c===e&&p===r)&&a.push({row:c,col:p,len:l.length}),h=p+1}}return a}const pe=[{label:"console.log",kind:"fn",detail:"void"},{label:"console.error",kind:"fn",detail:"void"},{label:"console.warn",kind:"fn",detail:"void"},{label:"console.info",kind:"fn",detail:"void"},{label:"console.table",kind:"fn",detail:"void"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null"},{label:"document.querySelector",kind:"fn",detail:"Element | null"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeList"},{label:"document.createElement",kind:"fn",detail:"HTMLElement"},{label:"document.createTextNode",kind:"fn",detail:"Text"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"removeEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number"},{label:"cancelAnimationFrame",kind:"fn",detail:"(id) => void"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => id"},{label:"clearTimeout",kind:"fn",detail:"(id) => void"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => id"},{label:"clearInterval",kind:"fn",detail:"(id) => void"},{label:"JSON.stringify",kind:"fn",detail:"string"},{label:"JSON.parse",kind:"fn",detail:"any"},{label:"Math.max",kind:"fn",detail:"number"},{label:"Math.min",kind:"fn",detail:"number"},{label:"Math.floor",kind:"fn",detail:"number"},{label:"Math.ceil",kind:"fn",detail:"number"},{label:"Math.round",kind:"fn",detail:"number"},{label:"Math.abs",kind:"fn",detail:"number"},{label:"Math.pow",kind:"fn",detail:"number"},{label:"Math.sqrt",kind:"fn",detail:"number"},{label:"Math.random",kind:"fn",detail:"number"},{label:"Object.keys",kind:"fn",detail:"string[]"},{label:"Object.values",kind:"fn",detail:"any[]"},{label:"Object.entries",kind:"fn",detail:"[string, any][]"},{label:"Object.assign",kind:"fn",detail:"T & U"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>"},{label:"Object.create",kind:"fn",detail:"object"},{label:"Array.from",kind:"fn",detail:"T[]"},{label:"Array.isArray",kind:"fn",detail:"boolean"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>"},{label:"Promise.allSettled",kind:"fn",detail:"Promise<...>"},{label:"parseInt",kind:"fn",detail:"number"},{label:"parseFloat",kind:"fn",detail:"number"},{label:"isNaN",kind:"fn",detail:"boolean"},{label:"isFinite",kind:"fn",detail:"boolean"},{label:"encodeURIComponent",kind:"fn",detail:"string"},{label:"decodeURIComponent",kind:"fn",detail:"string"},{label:"structuredClone",kind:"fn",detail:"T"},{label:"queueMicrotask",kind:"fn",detail:"void"},{label:"fetch",kind:"fn",detail:"Promise<Response>"}],Mt={typescript:pe,javascript:pe,css:[{label:"display",kind:"var",detail:"property"},{label:"position",kind:"var",detail:"property"},{label:"top",kind:"var",detail:"property"},{label:"right",kind:"var",detail:"property"},{label:"bottom",kind:"var",detail:"property"},{label:"left",kind:"var",detail:"property"},{label:"width",kind:"var",detail:"property"},{label:"height",kind:"var",detail:"property"},{label:"min-width",kind:"var",detail:"property"},{label:"max-width",kind:"var",detail:"property"},{label:"min-height",kind:"var",detail:"property"},{label:"max-height",kind:"var",detail:"property"},{label:"z-index",kind:"var",detail:"property"},{label:"overflow",kind:"var",detail:"property"},{label:"overflow-x",kind:"var",detail:"property"},{label:"overflow-y",kind:"var",detail:"property"},{label:"box-sizing",kind:"var",detail:"property"},{label:"flex",kind:"var",detail:"property"},{label:"flex-direction",kind:"var",detail:"property"},{label:"flex-wrap",kind:"var",detail:"property"},{label:"flex-grow",kind:"var",detail:"property"},{label:"flex-shrink",kind:"var",detail:"property"},{label:"flex-basis",kind:"var",detail:"property"},{label:"flex-flow",kind:"var",detail:"property"},{label:"align-items",kind:"var",detail:"property"},{label:"align-content",kind:"var",detail:"property"},{label:"align-self",kind:"var",detail:"property"},{label:"justify-content",kind:"var",detail:"property"},{label:"justify-items",kind:"var",detail:"property"},{label:"justify-self",kind:"var",detail:"property"},{label:"gap",kind:"var",detail:"property"},{label:"row-gap",kind:"var",detail:"property"},{label:"column-gap",kind:"var",detail:"property"},{label:"grid",kind:"var",detail:"property"},{label:"grid-template",kind:"var",detail:"property"},{label:"grid-template-columns",kind:"var",detail:"property"},{label:"grid-template-rows",kind:"var",detail:"property"},{label:"grid-template-areas",kind:"var",detail:"property"},{label:"grid-column",kind:"var",detail:"property"},{label:"grid-row",kind:"var",detail:"property"},{label:"grid-area",kind:"var",detail:"property"},{label:"grid-auto-flow",kind:"var",detail:"property"},{label:"margin",kind:"var",detail:"property"},{label:"margin-top",kind:"var",detail:"property"},{label:"margin-right",kind:"var",detail:"property"},{label:"margin-bottom",kind:"var",detail:"property"},{label:"margin-left",kind:"var",detail:"property"},{label:"padding",kind:"var",detail:"property"},{label:"padding-top",kind:"var",detail:"property"},{label:"padding-right",kind:"var",detail:"property"},{label:"padding-bottom",kind:"var",detail:"property"},{label:"padding-left",kind:"var",detail:"property"},{label:"color",kind:"var",detail:"property"},{label:"font",kind:"var",detail:"property"},{label:"font-family",kind:"var",detail:"property"},{label:"font-size",kind:"var",detail:"property"},{label:"font-weight",kind:"var",detail:"property"},{label:"font-style",kind:"var",detail:"property"},{label:"line-height",kind:"var",detail:"property"},{label:"text-align",kind:"var",detail:"property"},{label:"text-decoration",kind:"var",detail:"property"},{label:"text-transform",kind:"var",detail:"property"},{label:"letter-spacing",kind:"var",detail:"property"},{label:"word-spacing",kind:"var",detail:"property"},{label:"white-space",kind:"var",detail:"property"},{label:"word-break",kind:"var",detail:"property"},{label:"word-wrap",kind:"var",detail:"property"},{label:"text-overflow",kind:"var",detail:"property"},{label:"background",kind:"var",detail:"property"},{label:"background-color",kind:"var",detail:"property"},{label:"background-image",kind:"var",detail:"property"},{label:"background-size",kind:"var",detail:"property"},{label:"background-position",kind:"var",detail:"property"},{label:"background-repeat",kind:"var",detail:"property"},{label:"background-clip",kind:"var",detail:"property"},{label:"background-attachment",kind:"var",detail:"property"},{label:"border",kind:"var",detail:"property"},{label:"border-width",kind:"var",detail:"property"},{label:"border-style",kind:"var",detail:"property"},{label:"border-color",kind:"var",detail:"property"},{label:"border-radius",kind:"var",detail:"property"},{label:"border-top",kind:"var",detail:"property"},{label:"border-right",kind:"var",detail:"property"},{label:"border-bottom",kind:"var",detail:"property"},{label:"border-left",kind:"var",detail:"property"},{label:"outline",kind:"var",detail:"property"},{label:"outline-width",kind:"var",detail:"property"},{label:"outline-style",kind:"var",detail:"property"},{label:"outline-color",kind:"var",detail:"property"},{label:"outline-offset",kind:"var",detail:"property"},{label:"opacity",kind:"var",detail:"property"},{label:"box-shadow",kind:"var",detail:"property"},{label:"text-shadow",kind:"var",detail:"property"},{label:"filter",kind:"var",detail:"property"},{label:"backdrop-filter",kind:"var",detail:"property"},{label:"transform",kind:"var",detail:"property"},{label:"transform-origin",kind:"var",detail:"property"},{label:"transition",kind:"var",detail:"property"},{label:"animation",kind:"var",detail:"property"},{label:"animation-name",kind:"var",detail:"property"},{label:"animation-duration",kind:"var",detail:"property"},{label:"animation-timing-function",kind:"var",detail:"property"},{label:"animation-delay",kind:"var",detail:"property"},{label:"animation-iteration-count",kind:"var",detail:"property"},{label:"animation-fill-mode",kind:"var",detail:"property"},{label:"cursor",kind:"var",detail:"property"},{label:"pointer-events",kind:"var",detail:"property"},{label:"user-select",kind:"var",detail:"property"},{label:"resize",kind:"var",detail:"property"},{label:"visibility",kind:"var",detail:"property"},{label:"content",kind:"var",detail:"property"},{label:"list-style",kind:"var",detail:"property"},{label:"will-change",kind:"var",detail:"property"},{label:"appearance",kind:"var",detail:"property"},{label:"clip-path",kind:"var",detail:"property"},{label:"object-fit",kind:"var",detail:"property"},{label:"object-position",kind:"var",detail:"property"},{label:"scroll-behavior",kind:"var",detail:"property"},{label:"aspect-ratio",kind:"var",detail:"property"},{label:"var",kind:"fn",detail:"css fn"},{label:"calc",kind:"fn",detail:"css fn"},{label:"min",kind:"fn",detail:"css fn"},{label:"max",kind:"fn",detail:"css fn"},{label:"clamp",kind:"fn",detail:"css fn"},{label:"rgb",kind:"fn",detail:"css fn"},{label:"rgba",kind:"fn",detail:"css fn"},{label:"hsl",kind:"fn",detail:"css fn"},{label:"hsla",kind:"fn",detail:"css fn"},{label:"oklch",kind:"fn",detail:"css fn"},{label:"linear-gradient",kind:"fn",detail:"css fn"},{label:"radial-gradient",kind:"fn",detail:"css fn"},{label:"conic-gradient",kind:"fn",detail:"css fn"},{label:"translate",kind:"fn",detail:"css fn"},{label:"scale",kind:"fn",detail:"css fn"},{label:"rotate",kind:"fn",detail:"css fn"},{label:"skew",kind:"fn",detail:"css fn"},{label:"matrix",kind:"fn",detail:"css fn"},{label:"perspective",kind:"fn",detail:"css fn"},{label:"url",kind:"fn",detail:"css fn"},{label:"attr",kind:"fn",detail:"css fn"},{label:"env",kind:"fn",detail:"css fn"},{label:"repeat",kind:"fn",detail:"css fn"},{label:"minmax",kind:"fn",detail:"css fn"},{label:"fit-content",kind:"fn",detail:"css fn"}],json:[],markdown:[],text:[]};function We(s,e,t){const i=ge[s]??ee,n=be[s]??te,r=Mt[s]??pe;return[...[...i,...e].map(o=>({label:o,kind:"kw",detail:"keyword"})),...[...n,...t].map(o=>({label:o,kind:"typ",detail:"type"})),...r]}function St(s,e){const t=new Set;for(const i of s){const n=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const r of n)r!==e&&r.length>2&&t.add(r)}return t}function Ne(s,e){return s.language?Array.isArray(s.language)?s.language.includes(e):s.language===e:!0}function Lt(s,e,t={},i=0,n=0){if(e.length<2)return[];const r=e.toLowerCase(),{language:o="typescript",extraKeywords:l=[],extraTypes:a=[],completions:c=[],replaceBuiltins:d=!1,maxResults:h=14}=t,p=c.filter(y=>y.kind==="snip"&&!!y.body&&Ne(y,o)),f=c.filter(y=>!(y.kind==="snip"&&y.body)&&Ne(y,o)),_=p.filter(y=>y.label.toLowerCase().startsWith(r));let b;if(t.provideCompletions){const y={line:s[i]??"",col:n,prefix:e,language:o,doc:s};let H;try{H=t.provideCompletions(y)}catch(B){console.error("[syncline-editor] provideCompletions threw an error:",B),H=null}b=H!=null?[...H,...f]:[...d?[]:We(o,l,a),...f]}else b=d?f:[...We(o,l,a),...f];const v=new Set(b.map(y=>y.label)),u=b.filter(y=>y.label.toLowerCase().startsWith(r)&&y.label!==e),T=new Set(_.map(y=>y.label)),w=[...St(s,e)].filter(y=>y.toLowerCase().startsWith(r)&&!v.has(y)&&!T.has(y)).slice(0,8).map(y=>({label:y,kind:"var",detail:"in file"}));return[..._,...u.filter(y=>!T.has(y.label)),...w].slice(0,h)}function It(s,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(s[i-1]);)i--;return{prefix:s.slice(i,e),start:i}}function At(s,e){const t=r=>/[\w$]/.test(r);let i=e;for(;i<s.length&&t(s[i]);)i++;let n=e;for(;n>0&&t(s[n-1]);)n--;if(n===i)return"";if(n>0&&s[n-1]==="."){let r=n-1,o=r;for(;o>0&&t(s[o-1]);)o--;if(o<r)return s.slice(o,i)}return s.slice(n,i)}const Dt={console:{title:"console",type:"Console",body:"Provides access to the browser's debugging console. Useful for logging, timing, profiling, and inspecting values during development.",language:["typescript","javascript"]},"console.log":{title:"console.log()",type:"(...data: any[]) => void",body:"Outputs a message to the web console. Accepts any number of arguments — objects are logged as expandable trees, primitives as their string form.",language:["typescript","javascript"]},"console.error":{title:"console.error()",type:"(...data: any[]) => void",body:"Logs an error message to the console, typically rendered in red with a stack trace. Use for unrecoverable failures.",language:["typescript","javascript"]},"console.warn":{title:"console.warn()",type:"(...data: any[]) => void",body:"Logs a warning message to the console, typically rendered in yellow. Use for non-fatal issues or deprecation notices.",language:["typescript","javascript"]},"console.info":{title:"console.info()",type:"(...data: any[]) => void",body:"Logs an informational message. Behaves identically to console.log in most environments.",language:["typescript","javascript"]},"console.table":{title:"console.table()",type:"(data: any, columns?: string[]) => void",body:"Displays an array or object as a formatted table in the console. Optionally restrict displayed columns.",language:["typescript","javascript"]},"console.time":{title:"console.time()",type:"(label?: string) => void",body:"Starts a timer with the given label. Call console.timeEnd() with the same label to log the elapsed time.",language:["typescript","javascript"]},"console.timeEnd":{title:"console.timeEnd()",type:"(label?: string) => void",body:"Stops the timer started by console.time() and logs the elapsed duration in milliseconds.",language:["typescript","javascript"]},"console.group":{title:"console.group()",type:"(...label: any[]) => void",body:"Creates a new inline group in the console output, indenting subsequent messages until console.groupEnd() is called.",language:["typescript","javascript"]},"console.groupEnd":{title:"console.groupEnd()",type:"() => void",body:"Closes the current inline group in the console, exiting the indented group created by console.group().",language:["typescript","javascript"]},Math:{title:"Math",type:"namespace Math",body:"A built-in object with properties and methods for mathematical constants and functions. Not a constructor — all properties and methods are static.",language:["typescript","javascript"]},"Math.max":{title:"Math.max()",type:"(...values: number[]) => number",body:"Returns the largest of the given numbers. Returns -Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.min":{title:"Math.min()",type:"(...values: number[]) => number",body:"Returns the smallest of the given numbers. Returns Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.floor":{title:"Math.floor()",type:"(x: number) => number",body:"Returns the largest integer less than or equal to x. Rounds toward negative infinity.",language:["typescript","javascript"]},"Math.ceil":{title:"Math.ceil()",type:"(x: number) => number",body:"Returns the smallest integer greater than or equal to x. Rounds toward positive infinity.",language:["typescript","javascript"]},"Math.round":{title:"Math.round()",type:"(x: number) => number",body:"Returns the value of x rounded to the nearest integer. Values with a fractional part of exactly 0.5 round up.",language:["typescript","javascript"]},"Math.abs":{title:"Math.abs()",type:"(x: number) => number",body:"Returns the absolute (non-negative) value of x.",language:["typescript","javascript"]},"Math.sqrt":{title:"Math.sqrt()",type:"(x: number) => number",body:"Returns the square root of x. Returns NaN if x is negative.",language:["typescript","javascript"]},"Math.pow":{title:"Math.pow()",type:"(base: number, exponent: number) => number",body:"Returns base raised to the power of exponent. Equivalent to the ** operator.",language:["typescript","javascript"]},"Math.random":{title:"Math.random()",type:"() => number",body:"Returns a pseudo-random floating-point number in the range [0, 1). Not cryptographically secure — use crypto.getRandomValues() for security-sensitive code.",language:["typescript","javascript"]},"Math.PI":{title:"Math.PI",type:"number",body:"The ratio of a circle's circumference to its diameter: approximately 3.14159265358979.",language:["typescript","javascript"]},"Math.trunc":{title:"Math.trunc()",type:"(x: number) => number",body:"Returns the integer part of x by removing any fractional digits. Does not round — simply truncates toward zero.",language:["typescript","javascript"]},"Math.sign":{title:"Math.sign()",type:"(x: number) => number",body:"Returns 1 if x is positive, -1 if x is negative, 0 if x is zero, or NaN if x is not a number.",language:["typescript","javascript"]},"Math.clamp":{title:"Math.clamp()",type:"(value: number, min: number, max: number) => number",body:"Clamps value between min and max. Note: not yet standard — use Math.min(Math.max(value, min), max) for compatibility.",language:["typescript","javascript"]},JSON:{title:"JSON",type:"namespace JSON",body:"Provides methods for parsing and serializing JSON (JavaScript Object Notation). All methods are static.",language:["typescript","javascript"]},"JSON.stringify":{title:"JSON.stringify()",type:"(value: any, replacer?: any, space?: string | number) => string",body:"Converts a JavaScript value to a JSON string. Pass a number or string as the third argument to pretty-print with indentation. Throws on circular references.",language:["typescript","javascript"]},"JSON.parse":{title:"JSON.parse()",type:"(text: string, reviver?: (key: string, value: any) => any) => any",body:"Parses a JSON string and returns the corresponding JavaScript value. Throws SyntaxError if the string is not valid JSON.",language:["typescript","javascript"]},Array:{title:"Array",type:"interface Array<T>",body:"Represents an ordered list of values. Provides methods for traversal, mutation, searching, and transformation.",language:["typescript","javascript"]},"Array.from":{title:"Array.from()",type:"<T>(arrayLike: Iterable<T> | ArrayLike<T>, mapFn?: (v: T, i: number) => T) => T[]",body:"Creates a new Array from an array-like or iterable object (e.g. NodeList, Set, Map, string). Optionally applies a mapping function.",language:["typescript","javascript"]},"Array.isArray":{title:"Array.isArray()",type:"(value: unknown) => value is any[]",body:"Returns true if the given value is an Array. More reliable than instanceof Array across iframe boundaries.",language:["typescript","javascript"]},Object:{title:"Object",type:"interface Object",body:"The base class of all JavaScript objects. Provides static methods for working with object properties, prototypes, and descriptors.",language:["typescript","javascript"]},"Object.keys":{title:"Object.keys()",type:"(obj: object) => string[]",body:"Returns an array of an object's own enumerable string-keyed property names, in insertion order.",language:["typescript","javascript"]},"Object.values":{title:"Object.values()",type:"(obj: object) => any[]",body:"Returns an array of an object's own enumerable string-keyed property values, in insertion order.",language:["typescript","javascript"]},"Object.entries":{title:"Object.entries()",type:"(obj: object) => [string, any][]",body:"Returns an array of [key, value] pairs for all own enumerable string-keyed properties of an object.",language:["typescript","javascript"]},"Object.assign":{title:"Object.assign()",type:"<T, U>(target: T, source: U) => T & U",body:"Copies own enumerable properties from one or more source objects into a target object. Returns the modified target. Does a shallow copy.",language:["typescript","javascript"]},"Object.freeze":{title:"Object.freeze()",type:"<T>(obj: T) => Readonly<T>",body:"Freezes an object — prevents adding, removing, or changing its properties. Returns the same object. Shallow — nested objects are not frozen.",language:["typescript","javascript"]},"Object.create":{title:"Object.create()",type:"(proto: object | null, propertiesObject?: PropertyDescriptorMap) => any",body:"Creates a new object with the specified prototype object and optional property descriptors.",language:["typescript","javascript"]},"Object.fromEntries":{title:"Object.fromEntries()",type:"<T>(entries: Iterable<[string, T]>) => Record<string, T>",body:"Creates an object from an array of [key, value] pairs or any iterable of key-value entries. The inverse of Object.entries().",language:["typescript","javascript"]},Promise:{title:"Promise",type:"interface Promise<T>",body:"Represents an asynchronous operation that will eventually complete (or fail) and produce a value. Use .then(), .catch(), and .finally() to handle outcomes.",language:["typescript","javascript"]},"Promise.all":{title:"Promise.all()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T[]>",body:"Waits for all promises to resolve and returns an array of results. If any promise rejects, the entire result rejects immediately (fail-fast).",language:["typescript","javascript"]},"Promise.allSettled":{title:"Promise.allSettled()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<PromiseSettledResult<T>[]>",body:'Waits for all promises to settle (resolve or reject) and returns an array of result objects, each with a status of "fulfilled" or "rejected". Never rejects.',language:["typescript","javascript"]},"Promise.race":{title:"Promise.race()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T>",body:"Returns a promise that resolves or rejects as soon as one of the given promises resolves or rejects, with that value or reason.",language:["typescript","javascript"]},"Promise.resolve":{title:"Promise.resolve()",type:"<T>(value: T | PromiseLike<T>) => Promise<T>",body:"Returns a Promise object that is resolved with the given value. If the value is a thenable, the returned promise follows it.",language:["typescript","javascript"]},"Promise.reject":{title:"Promise.reject()",type:"(reason?: any) => Promise<never>",body:"Returns a Promise that is rejected with the given reason. Useful for creating pre-rejected promises in control flow.",language:["typescript","javascript"]},setTimeout:{title:"setTimeout()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Executes a function after a specified delay in milliseconds. Returns a timer ID that can be passed to clearTimeout() to cancel.",language:["typescript","javascript"]},clearTimeout:{title:"clearTimeout()",type:"(id: number) => void",body:"Cancels a timeout previously established by setTimeout(), preventing its callback from running.",language:["typescript","javascript"]},setInterval:{title:"setInterval()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Repeatedly executes a function with a fixed time delay between each call. Returns a timer ID for cancellation via clearInterval().",language:["typescript","javascript"]},clearInterval:{title:"clearInterval()",type:"(id: number) => void",body:"Cancels a repeating timer established by setInterval().",language:["typescript","javascript"]},requestAnimationFrame:{title:"requestAnimationFrame()",type:"(callback: (timestamp: DOMHighResTimeStamp) => void) => number",body:"Schedules a callback to run before the next browser repaint. Ideal for animations — the browser can batch and throttle calls to 60fps or the display refresh rate.",language:["typescript","javascript"]},cancelAnimationFrame:{title:"cancelAnimationFrame()",type:"(id: number) => void",body:"Cancels an animation frame request previously scheduled with requestAnimationFrame().",language:["typescript","javascript"]},queueMicrotask:{title:"queueMicrotask()",type:"(callback: () => void) => void",body:"Queues a microtask to be executed before the next task in the event loop. Runs after the current JavaScript execution but before any setTimeout callbacks.",language:["typescript","javascript"]},fetch:{title:"fetch()",type:"(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>",body:"Fetches a resource from the network. Returns a Promise that resolves to a Response. Use .json(), .text(), or .blob() on the response to read the body.",language:["typescript","javascript"]},parseInt:{title:"parseInt()",type:"(string: string, radix?: number) => number",body:"Parses a string and returns an integer in the specified radix (base). Always provide the radix (typically 10) to avoid unexpected behavior with leading zeros.",language:["typescript","javascript"]},parseFloat:{title:"parseFloat()",type:"(string: string) => number",body:"Parses a string and returns a floating-point number. Returns NaN if the string cannot be converted.",language:["typescript","javascript"]},isNaN:{title:"isNaN()",type:"(value: number) => boolean",body:"Returns true if the value is NaN (Not a Number). Note: coerces the argument to number first — use Number.isNaN() for strict checking without coercion.",language:["typescript","javascript"]},isFinite:{title:"isFinite()",type:"(value: number) => boolean",body:"Returns true if the value is a finite number. Returns false for ±Infinity and NaN. Coerces the argument to number first.",language:["typescript","javascript"]},encodeURIComponent:{title:"encodeURIComponent()",type:"(uriComponent: string | number | boolean) => string",body:"Encodes a URI component by replacing special characters with their UTF-8 escape sequences. Use for encoding query string values before appending to a URL.",language:["typescript","javascript"]},decodeURIComponent:{title:"decodeURIComponent()",type:"(encodedURIComponent: string) => string",body:"Decodes a URI component that was previously encoded with encodeURIComponent(). Throws URIError on malformed sequences.",language:["typescript","javascript"]},structuredClone:{title:"structuredClone()",type:"<T>(value: T, options?: StructuredSerializeOptions) => T",body:"Creates a deep clone of the given value using the structured clone algorithm. Handles cycles, Maps, Sets, Dates, and typed arrays. Does not clone functions or class instances.",language:["typescript","javascript"]},"document.getElementById":{title:"document.getElementById()",type:"(elementId: string) => HTMLElement | null",body:"Returns the first element in the document with the specified ID, or null if not found. IDs must be unique per document.",language:["typescript","javascript"]},"document.querySelector":{title:"document.querySelector()",type:"(selectors: string) => Element | null",body:"Returns the first Element matching the given CSS selector string, or null if no match. Use querySelectorAll() for all matches.",language:["typescript","javascript"]},"document.querySelectorAll":{title:"document.querySelectorAll()",type:"(selectors: string) => NodeListOf<Element>",body:"Returns a static NodeList of all Elements matching the given CSS selector string. Does not update as the document changes.",language:["typescript","javascript"]},"document.createElement":{title:"document.createElement()",type:"<K extends keyof HTMLElementTagNameMap>(tagName: K) => HTMLElementTagNameMap[K]",body:"Creates a new HTML element with the specified tag name. The element is not attached to the DOM until you call appendChild() or similar.",language:["typescript","javascript"]},addEventListener:{title:"addEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void",body:"Registers an event listener on the target element. The listener is called whenever the specified event fires. Remember to call removeEventListener() to clean up.",language:["typescript","javascript"]},removeEventListener:{title:"removeEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void",body:"Removes an event listener previously added with addEventListener(). The listener reference must be the same function object.",language:["typescript","javascript"]},const:{title:"const",type:"keyword",body:"Declares a block-scoped variable that cannot be reassigned. The binding is immutable — but for objects and arrays, their contents can still be mutated.",language:["typescript","javascript"]},let:{title:"let",type:"keyword",body:"Declares a block-scoped variable that can be reassigned. Prefer const for bindings that never change.",language:["typescript","javascript"]},var:{title:"var",type:"keyword",body:"Declares a function-scoped (or globally-scoped) variable. Hoisted to the top of its scope. Prefer const or let in modern code.",language:["typescript","javascript"]},function:{title:"function",type:"keyword",body:"Defines a named function declaration, or introduces a function expression. Function declarations are hoisted; expressions are not.",language:["typescript","javascript"]},class:{title:"class",type:"keyword",body:"Declares a class — a blueprint for creating objects with shared methods and properties. Classes support extends, implements, constructors, getters, setters, and static members.",language:["typescript","javascript"]},async:{title:"async",type:"keyword",body:"Marks a function as asynchronous, making it return a Promise implicitly. Enables the use of the await keyword inside the function body.",language:["typescript","javascript"]},await:{title:"await",type:"keyword",body:"Pauses execution of an async function until the Promise settles, then returns the resolved value. Must be used inside an async function.",language:["typescript","javascript"]},return:{title:"return",type:"keyword",body:"Exits the current function and optionally returns a value to the caller. In an async function, the value is wrapped in a resolved Promise.",language:["typescript","javascript"]},interface:{title:"interface",type:"keyword",body:"Defines a TypeScript interface — a named contract describing the shape of an object. Interfaces can be extended, merged (declaration merging), and implemented by classes.",language:["typescript"]},type:{title:"type",type:"keyword",body:"Declares a TypeScript type alias — a name for any type expression including unions, intersections, tuples, mapped types, and conditional types.",language:["typescript"]},extends:{title:"extends",type:"keyword",body:"Establishes inheritance (class extends Base) or constrains a generic type parameter (T extends object). Also used in conditional types (T extends U ? X : Y).",language:["typescript","javascript"]},implements:{title:"implements",type:"keyword",body:"Declares that a class satisfies the shape of one or more interfaces. TypeScript verifies at compile time that all required members are present.",language:["typescript"]},export:{title:"export",type:"keyword",body:"Makes a declaration (variable, function, class, type, interface) available for import in other modules. Use export default for a single primary export.",language:["typescript","javascript"]},import:{title:"import",type:"keyword",body:"Imports bindings from another module. Supports named imports ({ foo, bar }), default imports (Foo), namespace imports (* as Foo), and side-effect imports.",language:["typescript","javascript"]},typeof:{title:"typeof",type:"keyword",body:'Returns a string describing the type of its operand at runtime ("string", "number", "boolean", "object", "function", "undefined", "symbol", "bigint"). In TypeScript, also used as a type operator to capture the type of a value.',language:["typescript","javascript"]},instanceof:{title:"instanceof",type:"keyword",body:"Tests whether an object has a given constructor in its prototype chain. Returns true if the object is an instance of the constructor.",language:["typescript","javascript"]},new:{title:"new",type:"keyword",body:"Creates a new instance of a class or constructor function. Allocates memory, sets the prototype, calls the constructor with `this` bound to the new object, and returns it.",language:["typescript","javascript"]},throw:{title:"throw",type:"keyword",body:"Throws a user-defined exception, stopping execution of the current function and propagating up the call stack until caught by a try...catch block.",language:["typescript","javascript"]},try:{title:"try...catch...finally",type:"keyword",body:"Wraps code that might throw an exception. The catch block handles errors; the finally block always runs whether or not an error occurred.",language:["typescript","javascript"]},string:{title:"string",type:"primitive type",body:'Represents a sequence of UTF-16 code units. In TypeScript, the string type accepts any text value. Literal types like "hello" narrow to specific string values.',language:["typescript"]},number:{title:"number",type:"primitive type",body:"Represents a double-precision 64-bit IEEE 754 floating-point value. Includes integers, decimals, NaN, and Infinity. TypeScript does not have a separate int type.",language:["typescript"]},boolean:{title:"boolean",type:"primitive type",body:"Represents a logical true or false value. Literal types true and false narrow to specific boolean values.",language:["typescript"]},any:{title:"any",type:"TypeScript type",body:"Disables type checking for a value — allows any operation without compile errors. Avoid using any; prefer unknown when the type is genuinely uncertain.",language:["typescript"]},unknown:{title:"unknown",type:"TypeScript type",body:"The type-safe alternative to any. You cannot perform operations on an unknown value without first narrowing its type with typeof, instanceof, or a type guard.",language:["typescript"]},void:{title:"void",type:"TypeScript type",body:"Represents the absence of a value, typically used as the return type of functions that do not return anything meaningful.",language:["typescript"]},never:{title:"never",type:"TypeScript type",body:"A type with no values — used for functions that never return (throw or infinite loop) and for exhaustive checks in union type switches.",language:["typescript"]},Record:{title:"Record<K, V>",type:"type Record<K extends keyof any, T> = { [P in K]: T }",body:"A utility type that constructs an object type whose keys are of type K and values are of type V. Useful for dictionaries and lookup tables.",language:["typescript"]},Partial:{title:"Partial<T>",type:"type Partial<T> = { [P in keyof T]?: T[P] }",body:"A utility type that makes all properties of T optional. Useful for update payloads, patches, and configuration objects with defaults.",language:["typescript"]},Required:{title:"Required<T>",type:"type Required<T> = { [P in keyof T]-?: T[P] }",body:"A utility type that makes all properties of T required (removes optionality). The inverse of Partial<T>.",language:["typescript"]},Readonly:{title:"Readonly<T>",type:"type Readonly<T> = { readonly [P in keyof T]: T[P] }",body:"A utility type that makes all properties of T readonly. Prevents property reassignment at the type level.",language:["typescript"]},ReturnType:{title:"ReturnType<T>",type:"type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any",body:"A utility type that extracts the return type of a function type T.",language:["typescript"]},Omit:{title:"Omit<T, K>",type:"type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>",body:"A utility type that constructs a type by picking all properties from T then removing those in K.",language:["typescript"]},Pick:{title:"Pick<T, K>",type:"type Pick<T, K extends keyof T> = { [P in K]: T[P] }",body:"A utility type that constructs a type by picking the set of properties K from T.",language:["typescript"]},NonNullable:{title:"NonNullable<T>",type:"type NonNullable<T> = T extends null | undefined ? never : T",body:"A utility type that removes null and undefined from the type T.",language:["typescript"]},keyof:{title:"keyof",type:"TypeScript type operator",body:'Produces a union type of all property keys of an object type. keyof { a: string; b: number } is "a" | "b".',language:["typescript"]}};function Ht(s,e){const t=Dt[s];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}function Rt(s){var J,X,I,P;const{vr:e,visIdx:t,curVisRow:i,wm:n,foldedLines:r,isFoldable:o,opts:l}=s,{docLine:a,segIdx:c,text:d}=e,h=t===i,p=a===((J=n.visualRows[i])==null?void 0:J.docLine),f=c>0,_=((X=n.segments[a])==null?void 0:X.slice(0,c).reduce((k,x)=>k+x.length,0))??0,b=s.docSel?_e(s.docSel,a,((I=(n.segments[a]??[""])[c])==null?void 0:I.length)??0):null;let v=null;if(b){const k=((P=(n.segments[a]??[""])[c])==null?void 0:P.length)??0,x=_e(s.docSel,a,k+_);if(x){const A=x.start-_,R=x.end-_;R>0&&A<d.length&&(v={start:Math.max(0,A),end:Math.min(d.length,R)})}}const u=s.findMatches.filter(k=>k.row===a).map(k=>{var O,$;const x=k.col-_,A=k.col+k.len-_;if(A<=0||x>=d.length)return null;const R=s.findIdx>=0&&((O=s.findMatches[s.findIdx])==null?void 0:O.row)===k.row&&(($=s.findMatches[s.findIdx])==null?void 0:$.col)===k.col;return{start:Math.max(0,x),end:Math.min(d.length,A),isCur:R}}).filter(Boolean),T=s.wordHighlights.filter(k=>k.row===a).map(k=>{const x=k.col-_,A=k.col+k.len-_;return A<=0||x>=d.length?null:{start:Math.max(0,x),end:Math.min(d.length,A)}}).filter(Boolean),m=[];if(s.bracketMatch){for(const k of[s.bracketMatch.open,s.bracketMatch.close])if(k.row===a){const x=k.col-_;x>=0&&x<d.length&&m.push({start:x,end:x+1})}}const w=[],y=[];for(const k of s.extraCursors){const x=F(n,k.row,k.col);if(x.visRow===t&&w.push(x.colInSeg),k.sel){const A=jt(k.sel);if(a>=A.ar&&a<=A.fr){const R=a===A.ar?A.ac-_:-_,O=a===A.fr?A.fc-_:d.length+999;O>0&&R<d.length&&y.push({start:Math.max(0,R),end:Math.min(d.length,O)})}}}const H=Bt(d,l.renderWhitespace),B=h||v||u.length||w.length||T.length||m.length||y.length||s.snippetStopCols.length>0;let C;if(B)C=$t(H,h?s.curColInSeg:-1,v,u,w,s.snippetStopCols,T,m,y,l.tokeniserOpts);else{const k=`${a}:${c}:${l.renderWhitespace}`;let x=s.tokenCache.get(k,H);x||(x=ie(H,l.tokeniserOpts),s.tokenCache.set(k,H,x)),C=Pt(H,x)||"​"}let K="";if(c===0&&l.showIndentGuides){const k=(d.match(/^(\s*)/)??["",""])[1].length,x=Math.floor(k/l.tabSize);for(let A=1;A<x;A++){const R=l.codePaddingLeft+A*l.tabSize*l.charWidth;K+=`<span class="sl-ig" style="left:${R}px"></span>`}}let N="";if(c===0&&o){const k=r.has(a);N=`<span class="sl-fold-btn" data-row="${a}">${k?"▸":"▾"}</span>`}const U=r.has(a)&&c===0,G=c===0?String(a+1):"";return`<div class="${["sl-er",l.highlightActiveLine&&p?"sl-cur-row":"",f?"sl-wrap-cont":"",U?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${l.lineHeight}px" data-v="${t}" data-doc="${a}"><div class="sl-eg" style="position:relative">${N}<span class="sl-egn">${G}</span></div><div class="sl-el"><span class="sl-cl">${K}${C}</span></div></div>`}function Bt(s,e){if(e==="none")return s;if(e==="all")return s.replace(/ /g,"·").replace(/\t/g,"→");const t=(s.match(/^ +/)??[""])[0].length,i=(s.match(/ +$/)??[""])[0].length;let n=s;return t&&(n="·".repeat(t)+n.slice(t)),i&&(n=n.slice(0,n.length-i)+"·".repeat(i)),n.replace(/\t/g,"→")}function jt(s){return s.ar<s.fr||s.ar===s.fr&&s.ac<=s.fc?s:{ar:s.fr,ac:s.fc,fr:s.ar,fc:s.ac}}function Pt(s,e){if(!s)return"";const t=ve(s,e);let i="",n=0,r=t[0];const o=l=>{if(l<=n)return;const a=V(s.slice(n,l));i+=r?`<span class="${r}">${a}</span>`:a};for(let l=1;l<=s.length;l++){const a=l<s.length?t[l]:null;a!==r&&(o(l),n=l,r=a??"")}return i}function $t(s,e,t,i,n,r,o,l,a,c){if(s.length===0){let u=e>=0?'<span class="sl-cur"></span>':"";for(const T of n)u+='<span class="sl-cur-extra"></span>';for(const T of r)u+='<span class="sl-snip-stop"></span>';return u||"​"}const d=ie(s,c),h=ve(s,d);let p="",f=0,_="",b="";const v=u=>{if(u<=f)return;const T=V(s.slice(f,u)),m=[_,b].filter(Boolean).join(" ");p+=m?`<span class="${m}">${T}</span>`:T};for(let u=0;u<=s.length;u++){e===u&&(v(u),f=u,p+='<span class="sl-cur"></span>');for(const C of n)C===u&&(v(u),f=u,p+='<span class="sl-cur-extra"></span>');for(const C of r)C===u&&(v(u),f=u,p+='<span class="sl-snip-stop"></span>');if(u===s.length){v(u);break}const T=h[u],m=i.find(C=>u>=C.start&&u<C.end),w=t&&u>=t.start&&u<t.end||a.some(C=>u>=C.start&&u<C.end),y=!w&&!m&&o.some(C=>u>=C.start&&u<C.end),H=!w&&!m&&l.some(C=>u>=C.start&&u<C.end);let B="";w?B="sl-sh":m?B="sl-fh"+(m.isCur?" sl-fh-cur":""):H?B="sl-bm":y&&(B="sl-wh"),(B!==_||T!==b)&&(v(u),f=u,_=B,b=T)}return p||"​"}function he(s,e,t,i,n){const r=Math.max(0,s*n-t),o=Math.max(0,s*2-i),a=(r>0?e/r:0)*o,c=Math.max(20,t/n*2),d=e/n*2-a;return{mmScroll:a,sliderTop:d,sliderHeight:c}}function Wt(s,e,t,i,n){const r=Math.max(0,e*n-t),o=Math.max(0,e*2-i);if(r<=0)return 0;const l=2/n-o/r;if(Math.abs(l)<1e-9){const a=Math.max(20,t/n*2);return Math.max(0,Math.min(r,s/Math.max(1,i-a)*r))}return Math.max(0,Math.min(r,s/l))}function Nt(s,e,t,i,n,r){const o=Math.max(0,e*r-i),l=Math.max(0,e*2-n);if(o<=0)return 0;const a=t/o*l,c=(s+a)/2;return Math.max(0,Math.min(o,c*r-i/2))}function Oe(s){const e=t=>{const i=s(t);return i.startsWith("#")&&i.length===7?Ie(i,.85):i};return{kw:e("--tok-kw"),fn:e("--tok-fn"),cls:e("--tok-cls"),typ:e("--tok-typ"),str:e("--tok-str"),num:e("--tok-num"),cmt:e("--tok-cmt"),dec:e("--tok-dec"),op:e("--tok-op"),txt:(()=>{const t=s("--text2");return t.startsWith("#")&&t.length===7?Ie(t,.28):"rgba(150,148,140,0.28)"})()}}function Ot(s){var J,X;const{canvas:e,doc:t,firstLine:i,lastLine:n,subPx:r,wrapperWidth:o,canvasHeight:l,cursorRow:a,sel:c,findMatches:d,findIdx:h,sliderTop:p,sliderHeight:f,colors:_,getCssVar:b,dpr:v}=s,u=e.getContext("2d");if(!u)return;u.setTransform(v,0,0,v,0,0);const T=b("--mm-bg")||"#0d0d0f",m=b("--mm-dim")||"rgba(0,0,0,.30)",w=b("--mm-edge")||"rgba(255,255,255,.18)",y=b("--mm-slider")||"rgba(255,255,255,.07)",H=b("--sel-bg")||"rgba(110,159,255,.22)",B=b("--cur-line-bg")||"rgba(255,255,255,.05)",C=b("--find-border")||"rgba(234,180,86,.50)",K=b("--find-cur-bg")||"rgba(234,180,86,.80)",N=I=>(I-i)*2;if(u.fillStyle=T,u.fillRect(0,0,o,l),a>=i&&a<n&&(u.fillStyle=B,u.fillRect(0,N(a),o,2)),c){const I=Math.max(i,c.ar),P=Math.min(n-1,c.fr);P>=I&&(u.fillStyle=H,u.fillRect(0,N(I),o,(P-I+1)*2))}for(const I of d){if(I.row<i||I.row>=n)continue;const P=h>=0&&((J=d[h])==null?void 0:J.row)===I.row&&((X=d[h])==null?void 0:X.col)===I.col;u.fillStyle=P?K:C,u.fillRect(3+I.col*1.1,N(I.row),Math.max(3,I.len*1.1),2)}const U=Math.floor((o-3)/1.1);for(let I=i;I<n;I++){const P=t[I]??"";if(!P.trim())continue;const k=N(I),x=1.5,A=ie(P);let R=0;for(const $ of A){if($.start>=U)break;$.start>R&&(u.fillStyle=_.txt,u.fillRect(3+R*1.1,k,(Math.min($.start,U)-R)*1.1,x));const Gt=_[$.cls]??_.txt,Ue=Math.min($.end,U)-$.start;Ue>0&&(u.fillStyle=Gt,u.fillRect(3+$.start*1.1,k,Ue*1.1,x)),R=Math.max(R,Math.min($.end,U))}const O=Math.min(P.length,U);R<O&&(u.fillStyle=_.txt,u.fillRect(3+R*1.1,k,(O-R)*1.1,x))}const G=p+r,Y=G+f;u.fillStyle=m,G>0&&u.fillRect(0,0,o,G),Y<l&&u.fillRect(0,Y,o,l-Y),u.fillStyle=y,u.fillRect(0,G,o,f),u.fillStyle=w,u.fillRect(0,Math.max(0,G),o,1),u.fillRect(0,Math.max(0,Y-1),o,1)}const Ft={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:80,fontFamily:"'JetBrains Mono', monospace",fontSize:13,lineHeight:22,tabSize:2,insertSpaces:!0,maxUndoHistory:300,showIndentGuides:!0,bracketMatching:!0,codeFolding:!0,emmet:!0,snippetExpansion:!0,autocomplete:!0,multiCursor:!0,find:!0,findReplace:!0,wordSelection:!0,wordHighlight:!0,highlightActiveLine:!0,autocompletePrefixLength:2,readOnly:!1,extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:700,gutterWidth:60,minimapWidth:120,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0,placeholder:"",goToLine:!1};class Fe{constructor(e,t={}){g(this,"_host");g(this,"_shadow");g(this,"_editorEl");g(this,"_spacerEl");g(this,"_vpEl");g(this,"_inputEl");g(this,"_minimapWrap");g(this,"_mmCanvas");g(this,"_mmSlider");g(this,"_statusBar");g(this,"_findBar");g(this,"_findInput");g(this,"_replaceInput");g(this,"_findCount");g(this,"_replaceRow");g(this,"_acPopup");g(this,"_emmetTip");g(this,"_snippetTip");g(this,"_hoverTip");g(this,"_themeOverlay");g(this,"_themePanel");g(this,"_placeholderEl");g(this,"_goToLineBar");g(this,"_goToLineInput");g(this,"_goToLineHint");g(this,"_config");g(this,"_tab",me(1,[""]));g(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0]});g(this,"_foldedLines",new Map);g(this,"_tokenCache",new it);g(this,"_themeManager");g(this,"_findMatches",[]);g(this,"_findIdx",-1);g(this,"_findCaseSensitive",!1);g(this,"_findRegex",!1);g(this,"_wordHighlights",[]);g(this,"_bracketMatch",null);g(this,"_acItems",[]);g(this,"_acSel",0);g(this,"_acPrefix","");g(this,"_acStartCol",0);g(this,"_emmetAcStartCol",0);g(this,"_mc",_t());g(this,"_extraCursors",[]);g(this,"_isDragging",!1);g(this,"_dragAnchor",null);g(this,"_hoverTimer",null);g(this,"_hoverPinned",!1);g(this,"_mmDragMode","none");g(this,"_mmDragStartY",0);g(this,"_mmDragStartScroll",0);g(this,"_mmSliderOffset",0);g(this,"_mmColors");g(this,"_lastInputTime",0);g(this,"_dynamicStyleEl");g(this,"_emmetExpanded",null);g(this,"_snippetExpanded",null);g(this,"_snippetSession",null);g(this,"_acDebounceTimer",null);g(this,"_rafId",null);g(this,"_onWinMouseUp");g(this,"_onWinResize");g(this,"_onEditorScroll");g(this,"_onWinMmMouseMove");g(this,"_onWinMmMouseUp");g(this,"_ro",null);g(this,"_onFoldBtnClick",e=>{const t=e.target.closest(".sl-fold-btn");if(!t)return;e.preventDefault(),e.stopPropagation();const i=parseInt(t.dataset.row??"0",10);this._foldedLines=pt(this._foldedLines,this._tab.doc,i),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()});this._config={...Ft,...Re(t)},this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=oe(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=oe(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=a=>{if(this._mmDragMode==="none")return;const c=this._minimapWrap.clientHeight;if(this._mmDragMode==="slider"){const d=a.clientY-this._minimapWrap.getBoundingClientRect().top;this._editorEl.scrollTop=Wt(d-this._mmSliderOffset,this._tab.doc.length,this._editorEl.clientHeight,c,this._config.lineHeight)}else{const d=a.clientY-this._mmDragStartY,h=Math.max(0,this._tab.doc.length*this._config.lineHeight-this._editorEl.clientHeight);this._editorEl.scrollTop=Math.max(0,Math.min(h,this._mmDragStartScroll+d/2*this._config.lineHeight))}this._render()},this._onWinMmMouseUp=()=>{this._mmDragMode!=="none"&&(this._mmDragMode="none",this._minimapWrap.style.cursor="pointer")},this._host=e,this._host.classList.add("sl-host"),this._shadow=this._host.attachShadow({mode:"open"});const i=L("style");i.textContent=st,this._shadow.appendChild(i),this._dynamicStyleEl=L("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new rt(this._host);const n=typeof this._config.theme=="string"?this._config.theme:this._config.theme;this._themeManager.apply(n);const r=L("div","sl-layout"),o=L("div","sl-ed-pane");this._inputEl=L("textarea","sl-input"),this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label","Code editor"),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._editorEl=L("div","sl-editor"),this._spacerEl=L("div","sl-spacer"),this._vpEl=L("div","sl-vp"),this._editorEl.appendChild(this._spacerEl),this._editorEl.appendChild(this._vpEl),this._findBar=this._buildFindBar(),this._findInput=this._findBar.querySelector(".sl-find-input"),this._replaceInput=this._findBar.querySelector(".sl-find-replace-input"),this._findCount=this._findBar.querySelector(".sl-find-count"),this._replaceRow=this._findBar.querySelector(".sl-replace-row"),this._goToLineBar=this._buildGoToLineBar(),this._goToLineInput=this._goToLineBar.querySelector(".sl-gtl-input"),this._goToLineHint=this._goToLineBar.querySelector(".sl-gtl-hint"),this._placeholderEl=L("div","sl-placeholder"),this._placeholderEl.textContent=this._config.placeholder,this._placeholderEl.style.display="none",o.appendChild(this._inputEl),o.appendChild(this._findBar),o.appendChild(this._goToLineBar),o.appendChild(this._placeholderEl),o.appendChild(this._editorEl),this._minimapWrap=L("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=L("canvas",""),this._mmSlider=L("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),r.appendChild(o),this._config.showMinimap&&r.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=L("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=L("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=L("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=L("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=L("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=L("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(r),this._config.showStatusBar&&this._shadow.appendChild(this._statusBar),this._shadow.appendChild(this._acPopup),this._shadow.appendChild(this._emmetTip),this._shadow.appendChild(this._snippetTip),this._shadow.appendChild(this._hoverTip),this._shadow.appendChild(this._themeOverlay);const l=typeof this._config.value=="string"?Ae(this._config.value):this._config.value;this._tab=me(1,l.length?l:[""]),this._mmColors=Oe(a=>ne(a,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(oe(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render()}getValue(){return D(this._tab.doc)}setValue(e){var t,i;S(this._tab,this._config.maxUndoHistory),this._tab.doc=Ae(e),this._tab.cur={row:0,col:0},this._tab.sel=null,this._tokenCache.clear(),this._foldedLines.clear(),this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,e)}getCursor(){return{...this._tab.cur}}setCursor(e){this._tab.cur={...e},E(this._tab),this._scrollIntoView(),this._render()}getSelection(){return this._tab.sel?{...this._tab.sel}:null}setSelection(e){this._tab.sel=e,this._render()}insertText(e){this._config.readOnly||(this._insertStr(e,!1),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=Oe(t=>ne(t,this._host)),this._tokenCache.clear(),this._render()}updateConfig(e){const t=Re(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:n,...r}=t;Object.assign(this._config,r)}else Object.assign(this._config,t);if(t.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!t.readOnly)),e.theme!==void 0&&this.setTheme(e.theme),(e.wordWrap!==void 0||e.wrapColumn!==void 0)&&this._rebuildWrapMap(),e.showMinimap!==void 0){const i=this._shadow.querySelector(".sl-layout");e.showMinimap?i.contains(this._minimapWrap)||i.appendChild(this._minimapWrap):this._minimapWrap.remove()}e.showStatusBar!==void 0&&(e.showStatusBar?this._shadow.contains(this._statusBar)||this._shadow.appendChild(this._statusBar):this._statusBar.remove()),(e.fontFamily!==void 0||e.fontSize!==void 0||e.lineHeight!==void 0||e.cursorBlinkRate!==void 0||e.cursorStyle!==void 0||e.gutterWidth!==void 0||e.minimapWidth!==void 0||e.showGutter!==void 0||e.tokenColors!==void 0)&&this._applyDynamicStyles(),(e.language!==void 0||e.extraKeywords!==void 0||e.extraTypes!==void 0||e.renderWhitespace!==void 0||e.completions!==void 0)&&this._tokenCache.clear(),e.find===!1?this._closeFind():e.findReplace===!1&&(this._replaceRow.style.display="none"),e.goToLine===!1&&this._closeGoToLine(),e.placeholder!==void 0&&(this._placeholderEl.textContent=e.placeholder),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(e){this._themeManager.register(e)}undo(){var e,t;Xe(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}redo(){var e,t;Ze(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}executeCommand(e){const t=this._config.readOnly;switch(e){case"undo":t||this.undo();break;case"redo":t||this.redo();break;case"selectAll":this._selectAll();break;case"copy":this._doCopy();break;case"cut":t||this._doCut();break;case"toggleComment":t||this._toggleComment();break;case"duplicateLine":t||this._duplicateLine();break;case"deleteLine":t||this._deleteLine();break;case"toggleWordWrap":this._toggleWrap();break;case"find":this._config.find&&this._openFind(!1);break;case"findReplace":this._config.find&&this._config.findReplace&&this._openFind(!0);break;case"indentLine":t||this._indentSel();break;case"outdentLine":t||this._unindentSel();break;default:console.warn(`[syncline-editor] executeCommand: unknown command "${e}"`);break}}destroy(){var t;this._acDebounceTimer!==null&&(clearTimeout(this._acDebounceTimer),this._acDebounceTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),window.removeEventListener("mouseup",this._onWinMouseUp),window.removeEventListener("resize",this._onWinResize),window.removeEventListener("mousemove",this._onWinMmMouseMove),window.removeEventListener("mouseup",this._onWinMmMouseUp),(t=this._ro)==null||t.disconnect();const e=this._mmCanvas.getContext("2d");e&&e.clearRect(0,0,this._mmCanvas.width,this._mmCanvas.height),this._shadow.innerHTML="",this._host.classList.remove("sl-host")}_buildFindBar(){const e=L("div","sl-find-bar");return e.innerHTML=`
|
|
443
|
+
`,Ye={fontSize:[8,72,13],lineHeight:[14,64,22],tabSize:[1,16,2],wrapColumn:[20,500,80],maxCompletions:[1,50,14],autocompletePrefixLength:[1,10,2],gutterWidth:[30,200,60],minimapWidth:[60,300,120],cursorBlinkRate:[200,5e3,1050],maxUndoHistory:[10,5e3,300],undoBatchMs:[0,5e3,700]};function Xe(r,t,s,i){const e=Number(r);return Number.isFinite(e)?Math.max(t,Math.min(s,Math.round(e))):i}function qt(r){const t={...r};for(const[s,i]of Object.entries(Ye))if(s in r&&r[s]!==void 0){const[e,n,o]=i;t[s]=Xe(r[s],e,n,o)}return t}const Je={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:80,fontFamily:"'JetBrains Mono', monospace",fontSize:13,lineHeight:22,tabSize:2,insertSpaces:!0,maxUndoHistory:100,showIndentGuides:!0,bracketMatching:!0,codeFolding:!0,emmet:!0,snippetExpansion:!0,autocomplete:!0,multiCursor:!0,find:!0,findReplace:!0,wordSelection:!0,wordHighlight:!0,highlightActiveLine:!0,autocompletePrefixLength:2,readOnly:!1,extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:700,gutterWidth:60,minimapWidth:120,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0,placeholder:"",goToLine:!1};class Ze{constructor(t,s={}){v(this,"_host");v(this,"_shadow");v(this,"_editorEl");v(this,"_spacerEl");v(this,"_vpEl");v(this,"_inputEl");v(this,"_minimapWrap");v(this,"_mmCanvas");v(this,"_mmSlider");v(this,"_statusBar");v(this,"_findBar");v(this,"_findInput");v(this,"_replaceInput");v(this,"_findCount");v(this,"_replaceRow");v(this,"_acPopup");v(this,"_emmetTip");v(this,"_snippetTip");v(this,"_hoverTip");v(this,"_themeOverlay");v(this,"_themePanel");v(this,"_placeholderEl");v(this,"_goToLineBar");v(this,"_goToLineInput");v(this,"_goToLineHint");v(this,"_config");v(this,"_tab",xt(1,[""]));v(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0],totalVisualRows:1,windowVisStart:0});v(this,"_foldedLines",new Map);v(this,"_tokenCache",new be);v(this,"_themeManager");v(this,"_findMatches",[]);v(this,"_findIdx",-1);v(this,"_findCaseSensitive",!1);v(this,"_findRegex",!1);v(this,"_wordHighlights",[]);v(this,"_bracketMatch",null);v(this,"_acItems",[]);v(this,"_acSel",0);v(this,"_acPrefix","");v(this,"_acStartCol",0);v(this,"_emmetAcStartCol",0);v(this,"_mc",pe());v(this,"_extraCursors",[]);v(this,"_isDragging",!1);v(this,"_dragAnchor",null);v(this,"_hoverTimer",null);v(this,"_hoverPinned",!1);v(this,"_mmDragMode","none");v(this,"_mmDragStartY",0);v(this,"_mmDragStartScroll",0);v(this,"_mmSliderOffset",0);v(this,"_mmColors");v(this,"_lastInputTime",0);v(this,"_linewiseCopy",!1);v(this,"_dynamicStyleEl");v(this,"_emmetExpanded",null);v(this,"_snippetExpanded",null);v(this,"_snippetSession",null);v(this,"_acDebounceTimer",null);v(this,"_rafId",null);v(this,"_renderedRowCount",0);v(this,"_lastRenderScroll",-1);v(this,"_onWinMouseUp");v(this,"_onWinResize");v(this,"_onEditorScroll");v(this,"_onWinMmMouseMove");v(this,"_onWinMmMouseUp");v(this,"_ro",null);this._config={...Je,...qt(s)},this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=ct(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=ct(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=l=>{if(this._mmDragMode==="none")return;const a=this._minimapWrap.clientHeight,d=this._tab.doc.length,c=this._config.lineHeight;if(this._mmDragMode==="slider"){const p=l.clientY-this._minimapWrap.getBoundingClientRect().top,h=ge(p-this._mmSliderOffset,d,this._editorEl.clientHeight,a,c);this._editorEl.scrollTop=this._domScroll(h)}else{const p=l.clientY-this._mmDragStartY,h=this._logicalScroll(this._mmDragStartScroll),b=Math.max(0,d*c-this._editorEl.clientHeight),m=Math.max(0,Math.min(b,h+p/2*c));this._editorEl.scrollTop=this._domScroll(m)}this._render()},this._onWinMmMouseUp=()=>{this._mmDragMode!=="none"&&(this._mmDragMode="none",this._minimapWrap.style.cursor="pointer")},this._host=t,this._host.classList.add("sl-host"),this._shadow=this._host.attachShadow({mode:"open"});const i=B("style");i.textContent=qe,this._shadow.appendChild(i),this._dynamicStyleEl=B("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new Ke(this._host),this._themeManager.apply(this._config.theme);const e=B("div","sl-layout"),n=B("div","sl-ed-pane");this._inputEl=B("textarea","sl-input"),this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label","Code editor"),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._editorEl=B("div","sl-editor"),this._spacerEl=B("div","sl-spacer"),this._vpEl=B("div","sl-vp"),this._editorEl.appendChild(this._spacerEl),this._editorEl.appendChild(this._vpEl),this._findBar=this._buildFindBar(),this._findInput=this._findBar.querySelector(".sl-find-input"),this._replaceInput=this._findBar.querySelector(".sl-find-replace-input"),this._findCount=this._findBar.querySelector(".sl-find-count"),this._replaceRow=this._findBar.querySelector(".sl-replace-row"),this._goToLineBar=this._buildGoToLineBar(),this._goToLineInput=this._goToLineBar.querySelector(".sl-gtl-input"),this._goToLineHint=this._goToLineBar.querySelector(".sl-gtl-hint"),this._placeholderEl=B("div","sl-placeholder"),this._placeholderEl.textContent=this._config.placeholder,this._placeholderEl.style.display="none",n.appendChild(this._inputEl),n.appendChild(this._findBar),n.appendChild(this._goToLineBar),n.appendChild(this._placeholderEl),n.appendChild(this._editorEl),this._minimapWrap=B("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=B("canvas",""),this._mmSlider=B("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),e.appendChild(n),this._config.showMinimap&&e.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=B("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=B("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=B("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=B("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=B("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=B("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(e),this._config.showStatusBar&&this._shadow.appendChild(this._statusBar),this._shadow.appendChild(this._acPopup),this._shadow.appendChild(this._emmetTip),this._shadow.appendChild(this._snippetTip),this._shadow.appendChild(this._hoverTip),this._shadow.appendChild(this._themeOverlay);const o=typeof this._config.value=="string"?Mt(this._config.value):this._config.value;this._tab=xt(1,o.length?o:[""]),this._mmColors=ut(l=>nt(l,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(ct(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render()}_logicalScroll(t){const s=this._tab.doc.length*this._config.lineHeight;if(s<=15e6)return t;const i=this._editorEl.clientHeight,e=15e6-i,n=s-i;return e<=0?0:t/e*n}_domScroll(t){const s=this._tab.doc.length*this._config.lineHeight;if(s<=15e6)return t;const i=this._editorEl.clientHeight,e=15e6-i,n=s-i;return n<=0?0:t/n*e}_buildFindBar(){const t=B("div","sl-find-bar");return t.innerHTML=`
|
|
444
444
|
<div class="sl-find-row">
|
|
445
445
|
<input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false">
|
|
446
446
|
<span class="sl-find-count">–</span>
|
|
@@ -455,12 +455,12 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
455
455
|
<button class="sl-find-btn sl-replace-one">Replace</button>
|
|
456
456
|
<button class="sl-find-btn sl-replace-all">All</button>
|
|
457
457
|
</div>
|
|
458
|
-
`,
|
|
458
|
+
`,t}_buildGoToLineBar(){const t=B("div","sl-gtl-bar");t.innerHTML=`
|
|
459
459
|
<span class="sl-gtl-label">Go to line</span>
|
|
460
460
|
<input class="sl-gtl-input" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" placeholder="…">
|
|
461
461
|
<span class="sl-gtl-hint"></span>
|
|
462
462
|
<span class="sl-find-x sl-gtl-close" title="Close">✕</span>
|
|
463
|
-
`;const t
|
|
463
|
+
`;const s=t.querySelector(".sl-gtl-input"),i=t.querySelector(".sl-gtl-hint");return s.addEventListener("input",()=>{const e=parseInt(s.value,10),n=!isNaN(e)&&e>=1&&e<=this._tab.doc.length;s.classList.toggle("sl-gtl-err",s.value!==""&&!n),i.textContent=`(1–${this._tab.doc.length})`}),s.addEventListener("keydown",e=>{var n,o;if(e.key==="Enter"){e.preventDefault();const l=parseInt(s.value,10);!isNaN(l)&&l>=1&&l<=this._tab.doc.length&&(this._tab.cur.row=l-1,this._tab.cur.col=Math.min(this._tab.cur.col,(this._tab.doc[l-1]??"").length),L(this._tab),this._tab.sel=null,this._closeGoToLine(),this._scrollIntoView(),this._render(),(o=(n=this._config).onCursorChange)==null||o.call(n,{...this._tab.cur}))}else e.key==="Escape"&&(e.preventDefault(),this._closeGoToLine());e.stopPropagation()}),t.querySelector(".sl-gtl-close").addEventListener("click",()=>this._closeGoToLine()),t}_openGoToLine(){if(this._goToLineBar.classList.contains("sl-open")){this._closeGoToLine();return}this._goToLineHint.textContent=`(1–${this._tab.doc.length})`,this._goToLineInput.value=String(this._tab.cur.row+1),this._goToLineInput.classList.remove("sl-gtl-err"),this._goToLineBar.classList.add("sl-open"),this._goToLineInput.focus(),this._goToLineInput.select()}_closeGoToLine(){this._goToLineBar.classList.remove("sl-open"),this._focusInput()}_focusInput(){this._inputEl.style.pointerEvents="auto",this._inputEl.focus(),this._inputEl.style.pointerEvents="none"}_buildStatusBar(){const t=B("div","sl-statusbar");return t.innerHTML=`
|
|
464
464
|
<div class="sl-sb-item sl-no-click sl-sb-lang">⬡ TypeScript</div>
|
|
465
465
|
<div class="sl-sb-sep"></div>
|
|
466
466
|
<div class="sl-sb-item sl-no-click sl-sb-pos">Ln 1, Col 1</div>
|
|
@@ -472,30 +472,34 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
472
472
|
<div class="sl-sb-item sl-no-click">UTF-8 LF</div>
|
|
473
473
|
<div class="sl-sb-right">
|
|
474
474
|
<div class="sl-sb-item sl-no-click sl-sb-mc" style="display:none">⊕ <span class="sl-sb-mc-count">1</span> cursors</div>
|
|
475
|
+
<div class="sl-sb-item sl-no-click sl-sb-dom">0 DOM rows</div>
|
|
476
|
+
<div class="sl-sb-sep"></div>
|
|
475
477
|
<div class="sl-sb-item sl-sb-wrap sl-sb-wrap-btn">⇥ Wrap: OFF</div>
|
|
476
478
|
<div class="sl-sb-sep"></div>
|
|
477
479
|
<div class="sl-sb-item sl-sb-theme-btn">🎨 Theme</div>
|
|
478
480
|
<div class="sl-sb-sep"></div>
|
|
479
481
|
<div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
|
|
480
482
|
</div>
|
|
481
|
-
`,
|
|
482
|
-
.sl-el{font-family:${
|
|
483
|
+
`,t.querySelector(".sl-sb-wrap-btn").addEventListener("click",()=>this._toggleWrap()),t.querySelector(".sl-sb-theme-btn").addEventListener("click",()=>this._openThemePicker()),t}_destroyBase(){var s;this._acDebounceTimer!==null&&(clearTimeout(this._acDebounceTimer),this._acDebounceTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),window.removeEventListener("mouseup",this._onWinMouseUp),window.removeEventListener("resize",this._onWinResize),window.removeEventListener("mousemove",this._onWinMmMouseMove),window.removeEventListener("mouseup",this._onWinMmMouseUp),(s=this._ro)==null||s.disconnect();const t=this._mmCanvas.getContext("2d");t&&t.clearRect(0,0,this._mmCanvas.width,this._mmCanvas.height),this._shadow.innerHTML="",this._host.classList.remove("sl-host")}}class Qe extends Ze{_applyDynamicStyles(){const{fontFamily:t,fontSize:s,lineHeight:i,cursorBlinkRate:e,cursorStyle:n,gutterWidth:o,minimapWidth:l,showGutter:a}=this._config,d=Math.max(2,i-4),c=Math.floor((i-d)/2);let p="";n==="block"?p=`width:${7.82}px;opacity:.5;border-radius:1px;`:n==="underline"&&(p=`width:${7.82}px;height:2px;top:${i-2}px;border-radius:0;`);const h=a?o:0;this._dynamicStyleEl.textContent=`
|
|
484
|
+
.sl-el{font-family:${t};font-size:${s}px;line-height:${i}px}
|
|
483
485
|
.sl-cl{height:${i}px;line-height:${i}px}
|
|
484
486
|
.sl-egn{height:${i}px;line-height:${i}px}
|
|
485
|
-
.sl-eg{min-width:${
|
|
486
|
-
.sl-cur::after{height:${
|
|
487
|
-
.sl-cur-extra::after{height:${
|
|
488
|
-
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${l}px`,this._placeholderEl.style.left=`${
|
|
489
|
-
`),l=n[r.row]??"",a=l.slice(0,r.col),c=l.slice(r.col);if(o.length===1)n[r.row]=a+e+c,r.col+=e.length;else{const p=[a+o[0]];for(let f=1;f<o.length-1;f++)p.push(o[f]);p.push(o[o.length-1]+c),n.splice(r.row,1,...p),r.row+=o.length-1,r.col=o[o.length-1].length}this._tokenCache.invalidateLine(r.row,(this._wm.segments[r.row]??[""]).length),this._tab.dirty=!0,(h=(d=this._config).onChange)==null||h.call(d,D(n))}_doBackspace(){var i;if(S(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=z(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:e,cur:t}=this._tab;if(t.col>0){const n=e[t.row]??"",r=n.slice(0,t.col),o=r.length>=2&&r.endsWith(" ")&&!r.trim()?2:1;e[t.row]=n.slice(0,t.col-o)+n.slice(t.col),t.col-=o,this._tokenCache.invalidateLine(t.row,((i=this._wm.segments[t.row])==null?void 0:i.length)??1)}else if(t.row>0){const n=(e[t.row-1]??"").length;e[t.row-1]+=e[t.row]??"",e.splice(t.row,1),t.row--,t.col=n,this._tokenCache.clear()}this._tab.dirty=!0}_doEnter(){S(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=z(this._tab));const{doc:e,cur:t}=this._tab,i=e[t.row]??"",n=i.slice(0,t.col),r=i.slice(t.col),o=De(i),l=n.trimEnd().endsWith("{")?Q(this._config.tabSize):"";e[t.row]=n,n.trimEnd().endsWith("{")&&r.trimStart()==="}"?e.splice(t.row+1,0,o+l,o+r):e.splice(t.row+1,0,o+l+r),t.row++,t.col=o.length+l.length,this._tokenCache.clear(),this._tab.dirty=!0}_doDelete(){var n;if(S(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=z(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:e,cur:t}=this._tab,i=e[t.row]??"";t.col<i.length?(e[t.row]=i.slice(0,t.col)+i.slice(t.col+1),this._tokenCache.invalidateLine(t.row,((n=this._wm.segments[t.row])==null?void 0:n.length)??1)):t.row<e.length-1&&(e[t.row]=i+(e[t.row+1]??""),e.splice(t.row+1,1),this._tokenCache.clear()),this._tab.dirty=!0}_selectAll(){const e=this._tab.doc,t=e.length-1;this._tab.sel={ar:0,ac:0,fr:t,fc:(e[t]??"").length},this._tab.cur={row:t,col:(e[t]??"").length},this._render()}_doCopy(){var t;const e=ye(this._tab);e&&((t=navigator.clipboard)==null||t.writeText(e).catch(()=>{}))}_doCut(){var t,i,n;const e=ye(this._tab);e&&((t=navigator.clipboard)==null||t.writeText(e).catch(()=>{}),S(this._tab,this._config.maxUndoHistory),this._tab.cur=z(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc)))}_toggleComment(){var r,o;S(this._tab,this._config.maxUndoHistory);const e=this._getSelRows(),t=this._config.lineCommentToken||Ge[this._config.language]||"";if(!t)return;const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=e.every(l=>(this._tab.doc[l]??"").trimStart().startsWith(t));e.forEach(l=>{var c;const a=this._tab.doc[l]??"";this._tab.doc[l]=n?a.replace(new RegExp(`^(\\s*)${i}\\s?`),"$1"):a.replace(/^(\s*)/,`$1${t} `),this._tokenCache.invalidateLine(l,((c=this._wm.segments[l])==null?void 0:c.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(o=(r=this._config).onChange)==null||o.call(r,D(this._tab.doc))}_duplicateLine(){var t,i;S(this._tab,this._config.maxUndoHistory);const e=this._tab.cur.row;this._tab.doc.splice(e+1,0,this._tab.doc[e]??""),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc))}_deleteLine(){var i,n;S(this._tab,this._config.maxUndoHistory);const{doc:e,cur:t}=this._tab;e.length>1?e.splice(t.row,1):(e[0]="",t.col=0),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab),this._rebuildWrapMap(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc))}_indentSel(){var t,i;if(!this._tab.sel){this._insertStr(Q(this._config.tabSize),!1);return}S(this._tab,this._config.maxUndoHistory);const e=Q(this._config.tabSize);this._getSelRows().forEach(n=>{var r;this._tab.doc[n]=e+(this._tab.doc[n]??""),this._tokenCache.invalidateLine(n,((r=this._wm.segments[n])==null?void 0:r.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc))}_unindentSel(){var t,i;S(this._tab,this._config.maxUndoHistory);const e=this._config.tabSize;this._getSelRows().forEach(n=>{var o;const r=this._tab.doc[n]??"";r.startsWith(Q(e))?this._tab.doc[n]=r.slice(e):r.startsWith(" ")&&(this._tab.doc[n]=r.slice(1)),this._tokenCache.invalidateLine(n,((o=this._wm.segments[n])==null?void 0:o.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc))}_toggleWrap(){this._config.wordWrap=!this._config.wordWrap,this._vpEl.classList.toggle("sl-wrap-mode",this._config.wordWrap);const e=this._statusBar.querySelector(".sl-sb-wrap-btn");e&&(e.textContent=`⇥ Wrap: ${this._config.wordWrap?"ON":"OFF"}`,e.classList.toggle("sl-on",this._config.wordWrap)),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const e=W(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_posFromMouse(e){var c;const t=this._editorEl.getBoundingClientRect(),i=e.clientY-t.top+this._editorEl.scrollTop,n=this._config.showGutter?this._config.gutterWidth:0,r=e.clientX-t.left-n-14,o=this._config.lineHeight,l=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(i/o))),a=Math.max(0,Math.min((((c=this._wm.visualRows[l])==null?void 0:c.text)??"").length,Math.round(r/7.82)));return Z(this._wm,l,a)}_openFind(e){this._findBar.classList.add("sl-open"),this._replaceRow.style.display=e&&this._config.findReplace?"":"none",this._findInput.focus(),this._findInput.select(),this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx=-1,this._navFind(1)):this._render()}_closeFind(){this._findBar.classList.remove("sl-open"),this._findMatches=[],this._findIdx=-1,this._findCount.textContent="–",this._focusInput(),this._render()}_runFind(e){this._findMatches=kt(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=Et(this._findMatches,this._findIdx,e);const t=this._findMatches[this._findIdx];this._tab.cur={row:t.row,col:t.col},this._tab.sel={ar:t.row,ac:t.col,fr:t.row,fc:t.col+t.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${this._findIdx+1}/${this._findMatches.length}`}_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[]}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},120)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",n=this._config.language==="css",{prefix:r,start:o}=It(i,e.col,n);this._acPrefix=r,this._acStartCol=o;const l=[];if(this._config.emmet){const c=je(i,e.col);if(c){const d=Be(c.abbr);if(d){this._emmetAcStartCol=c.start;const h=d.replace(/\n/g,"↵ ").slice(0,60);l.push({label:c.abbr,kind:"emmet",detail:h,body:d})}}}const a=r.length>=this._config.autocompletePrefixLength?Lt(t,r,{language:this._config.language,extraKeywords:this._config.extraKeywords,extraTypes:this._config.extraTypes,completions:this._allCompletions(),replaceBuiltins:this._config.replaceBuiltins,maxResults:this._config.maxCompletions,provideCompletions:this._config.provideCompletions},e.row,e.col):[];if(this._acItems=[...l,...a],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=a=>{switch(a){case"kw":return"K";case"fn":return"f";case"typ":return"T";case"cls":return"C";case"snip":return"S";case"emmet":return"E";default:return"·"}},t=this._acItems[this._acSel];let i="";t!=null&&t.description?i=t.description:(t==null?void 0:t.kind)==="snip"&&t.body?i=t.body.replace(/\$\d/g,"▌"):(t==null?void 0:t.kind)==="emmet"&&t.body&&(i=t.body);const n=this._acItems.map((a,c)=>{const d=c===this._acSel;return`<div class="sl-ac-item${d?" sl-sel":""}" data-i="${c}" role="option" aria-selected="${d}"><span class="sl-ac-badge ${a.kind}">${e(a.kind)}</span><span class="sl-ac-label">${a.label}</span><span class="sl-ac-detail">${a.detail??""}</span></div>`}).join(""),r=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"<")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${n}</div>`+r,this._acPopup.style.display="flex",this._posAcPopup();const o=this._acPopup.querySelector(".sl-ac-list"),l=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(o&&l){const a=l.offsetTop,c=a+l.offsetHeight;c>o.scrollTop+o.clientHeight?o.scrollTop=c-o.clientHeight:a<o.scrollTop&&(o.scrollTop=a)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(a=>{a.addEventListener("mousedown",c=>{c.preventDefault(),this._acSel=parseInt(a.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=F(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,n=e.left+i+14+this._acStartCol*7.82,r=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,l=!!this._acPopup.querySelector(".sl-ac-desc")?620:300,a=Math.min(this._acItems.length*28+8,320),c=r+a>window.innerHeight-16;this._acPopup.style.left=`${Math.min(n,window.innerWidth-l-16)}px`,this._acPopup.style.top=`${c?r-this._config.lineHeight-2-a:r}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){S(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._emmetAcStartCol);return}if(e.body){S(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._acStartCol);return}const t=e.label.slice(this._acPrefix.length);this._insertStr(t,!1),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render()}_emmetCheck(){if(this._emmetTip.style.display="none",!this._config.emmet){this._emmetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",n=je(i,e.col);if(!n){this._emmetExpanded=null;return}const r=Be(n.abbr);if(!r){this._emmetExpanded=null;return}this._emmetExpanded={abbr:n.abbr,result:r,start:n.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{abbr:e,result:t,start:i}=this._emmetExpanded;return S(this._tab,this._config.maxUndoHistory),this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(t,i),!0}_allCompletions(){return[...this._config.replaceBuiltins?[]:bt(this._config.language),...this._config.completions]}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",n=mt(i,e.col,this._allCompletions());if(!n){this._snippetExpanded=null;return}this._snippetExpanded={snippet:n.snippet,start:n.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:e,start:t}=this._snippetExpanded;return e.body?(S(this._tab,this._config.maxUndoHistory),this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t),!0):!1}_expandBodyAt(e,t){var u,T;const{doc:i,cur:n}=this._tab,r=n.row,o=i[n.row]??"",l=o.slice(0,t),a=o.slice(n.col),c=De(o),d=e.split(`
|
|
490
|
-
|
|
491
|
-
`),p=[],f=/\$(\d+)/g;let _;for(;(_=f.exec(h))!==null;){const m=parseInt(_[1],10),y=h.slice(0,_.index).split(`
|
|
492
|
-
`)
|
|
487
|
+
.sl-eg{min-width:${h}px;width:${h}px;${a?"":"display:none"}}
|
|
488
|
+
.sl-cur::after{height:${d}px;top:${c}px;animation-duration:${e}ms;${p}}
|
|
489
|
+
.sl-cur-extra::after{height:${d}px;top:${c}px;animation-duration:${e}ms;${p}}
|
|
490
|
+
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${l}px`,this._placeholderEl.style.left=`${h+14}px`,this._placeholderEl.style.fontFamily=t,this._placeholderEl.style.fontSize=`${s}px`,this._placeholderEl.style.lineHeight=`${i}px`}_applyTokenOverrides(){const t=this._config.tokenColors??{},s=this._themeManager.activeTheme,i=this._host.style,e=(o,l,a)=>{i.setProperty(o,l||a)},n=s==null?void 0:s.tokens;e("--tok-kw",t.keyword,(n==null?void 0:n.tokKw)??""),e("--tok-str",t.string,(n==null?void 0:n.tokStr)??""),e("--tok-cmt",t.comment,(n==null?void 0:n.tokCmt)??""),e("--tok-fn",t.function,(n==null?void 0:n.tokFn)??""),e("--tok-num",t.number,(n==null?void 0:n.tokNum)??""),e("--tok-cls",t.class,(n==null?void 0:n.tokCls)??""),e("--tok-op",t.operator,(n==null?void 0:n.tokOp)??""),e("--tok-typ",t.type,(n==null?void 0:n.tokTyp)??""),e("--tok-dec",t.decorator,(n==null?void 0:n.tokDec)??"")}_refreshMinimapColors(){this._mmColors=ut(t=>nt(t,this._host))}}const Y=1e4,rt=6*4;class ti extends Qe{constructor(){super(...arguments);v(this,"_onFoldBtnClick",s=>{const i=s.target.closest(".sl-fold-btn");if(!i)return;s.preventDefault(),s.stopPropagation();const e=parseInt(i.dataset.row??"0",10);if(this._foldedLines=We(this._foldedLines,this._tab.doc,e),this._foldedLines.has(e)){const n=this._foldedLines.get(e),o=this._tab.cur;o.row>e&&o.row<=n&&(this._tab.cur={row:e,col:(this._tab.doc[e]??"").length},this._tab.sel=null)}this._rebuildWrapMap(),this._render()})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:s,cur:i,sel:e}=this._tab,{lineHeight:n}=this._config,o=s.length,l=o*n,a=Math.min(l,15e6);this._spacerEl.style.height=`${a}px`;const d=this._editorEl.scrollTop,c=this._logicalScroll(d);o>Y&&d!==this._lastRenderScroll&&(this._lastRenderScroll=d,this._rebuildWrapMap());const p=this._wm.totalVisualRows,h=this._editorEl.clientHeight,b=Math.max(0,Math.floor(c/n)-6),m=Math.min(p-1,Math.ceil((c+h)/n)+6),g=o>Y?b:0,k=o>Y?m:o-1;if(this._wordHighlights=this._config.wordHighlight?ze(s,i.row,i.col,e,g,k):[],this._bracketMatch=this._config.bracketMatching?Ge(s,i):null,this._config.wordWrap)this._spacerEl.style.width="",this._vpEl.style.width="";else{const u=o>Y?this._wm.visualRows.reduce((x,R)=>Math.max(x,(s[R.docLine]??"").length),0):s.reduce((x,R)=>Math.max(x,R.length),0),y=this._config.showGutter?this._config.gutterWidth:0,S=Math.max(this._editorEl.clientWidth,y+14+Math.ceil(u*7.82)+20+64);this._spacerEl.style.width=`${S}px`,this._vpEl.style.width=`${S}px`}this._vpEl.style.transform=`translateY(${d+(b*n-c)}px)`;const f=z(this._wm,i.row,i.col),C=new Map;if(this._snippetSession)for(let u=this._snippetSession.idx+1;u<this._snippetSession.stops.length;u++){const y=this._snippetSession.stops[u],S=z(this._wm,y.row,y.col),x=C.get(S.visRow)??[];x.push(S.colInSeg),C.set(S.visRow,x)}const _=this._wm.windowVisStart;let w="";for(let u=b;u<=m;u++){const y=this._wm.visualRows[u-_];y&&(w+=$e({vr:y,visIdx:u,curVisRow:f.visRow,curColInSeg:f.colInSeg,docSel:e,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,snippetStopCols:C.get(u)??[],foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&je(s,y.docLine),wm:this._wm,tokenCache:this._tokenCache,opts:{tokeniserOpts:{language:this._config.language,extraKeywords:new Set(this._config.extraKeywords),extraTypes:new Set(this._config.extraTypes),provideTokens:this._config.provideTokens},showIndentGuides:this._config.showIndentGuides,highlightActiveLine:this._config.highlightActiveLine,charWidth:7.82,codePaddingLeft:14,tabSize:this._config.tabSize,lineHeight:n,renderWhitespace:this._config.renderWhitespace}}))}if(this._renderedRowCount=Math.max(0,m-b+1),this._vpEl.innerHTML=w,this._updateStatusBar(),this._updateMinimap(),this._config.placeholder){const u=this._tab.doc.length===1&&this._tab.doc[0]==="";this._placeholderEl.style.display=u?"":"none"}else this._placeholderEl.style.display="none"}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:s,doc:i,undoStack:e,redoStack:n}=this._tab,o=this._config.language,l={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},a=b=>this._statusBar.querySelector(b);a(".sl-sb-lang").textContent=`⬡ ${l[o]??o}`,a(".sl-sb-pos").textContent=`Ln ${s.row+1}, Col ${s.col+1}`,a(".sl-sb-lines").textContent=`${i.length.toLocaleString()} lines`;const d=ce(this._tab),c=a(".sl-sb-sel"),p=a(".sl-sb-sel-sep");c.textContent=d?`${d.toLocaleString()} selected`:"",p.style.display=d?"":"none",a(".sl-sb-undo").textContent=`↩${e.length} ↪${n.length}`;const h=a(".sl-sb-mc");this._extraCursors.length?(h.style.display="",a(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):h.style.display="none",a(".sl-sb-dom").textContent=`${this._renderedRowCount} DOM rows`}_updateMinimap(){if(!this._config.showMinimap)return;const s=this._minimapWrap.clientWidth,i=this._minimapWrap.clientHeight;if(!s||!i)return;const e=this._tab.doc,n=e.length,o=Math.min(window.devicePixelRatio||1,2),l=this._config.lineHeight,{mmScroll:a,sliderTop:d,sliderHeight:c}=pt(n,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,l),p=a/2,h=Math.floor(p),b=Math.ceil(i/2)+2,m=Math.min(n,h+b),g=(m-h)*2,k=(p-h)*2,f=Math.round(s*o),C=Math.round(g*o);(this._mmCanvas.width!==f||this._mmCanvas.height!==C)&&(this._mmCanvas.width=f,this._mmCanvas.height=C,this._mmCanvas.style.width=`${s}px`,this._mmCanvas.style.height=`${g}px`),this._mmCanvas.style.transform=`translateY(${-k}px)`,me({canvas:this._mmCanvas,doc:e,firstLine:h,lastLine:m,subPx:k,wrapperWidth:s,canvasHeight:g,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:d,sliderHeight:c,colors:this._mmColors,getCssVar:_=>nt(_,this._host),dpr:o,tokenCache:this._tokenCache,language:this._config.language,provideTokens:this._config.provideTokens}),this._mmSlider.style.top=`${Math.max(0,Math.min(i-c,d))}px`,this._mmSlider.style.height=`${c}px`}_rebuildWrapMap(){let s;if(this._config.wordWrap){const e=this._config.showGutter?this._config.gutterWidth:0,n=this._editorEl.clientWidth;if(n>0){const o=n-e-14-20;s=Math.max(20,Math.floor(o/7.82))}else s=this._config.wrapColumn}else s=9999;const i=this._tab.doc.length;if(i>Y){const e=this._config.lineHeight,n=this._editorEl.scrollTop,o=this._logicalScroll(n),l=this._editorEl.clientHeight,a=this._tab.cur.row,d=Math.max(0,Math.floor(o/e)-rt),c=Math.min(i-1,Math.ceil((o+l)/e)+rt),p=this._config.wordWrap||this._foldedLines.size>0,h=p?Math.max(0,Math.min(d,a-rt)):d,b=p?Math.min(i-1,Math.max(c,a+rt)):c;this._wm=Tt(this._tab.doc,s,this._config.wordWrap,this._foldedLines,h,b)}else this._wm=Tt(this._tab.doc,s,this._config.wordWrap,this._foldedLines)}_scrollIntoView(){const s=this._tab.cur,i=this._config.lineHeight,n=this._tab.doc.length*i,o=Math.min(n,15e6);this._spacerEl.style.height=`${o}px`;const a=z(this._wm,s.row,s.col).visRow*i,d=a+i,c=this._domScroll(a),p=this._domScroll(d),h=this._editorEl.scrollTop,b=this._editorEl.clientHeight,m=i*3;c<h+m?this._editorEl.scrollTop=Math.max(0,c-m):p>h+b-m&&(this._editorEl.scrollTop=p-b+m)}}class ei extends ti{_insertStr(t,s){var g,k;const i=Date.now(),e=!s||i-this._lastInputTime>this._config.undoBatchMs;this._lastInputTime=i;const n={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null;let l,a;if(this._tab.sel){const f=A(this._tab.sel);l=f.ar,a=this._tab.doc.slice(f.ar,f.fr+1),this._tab.cur=O(this._tab)}else l=this._tab.cur.row,a=[this._tab.doc[l]??""];const{doc:d,cur:c}=this._tab,p=t.split(`
|
|
491
|
+
`),h=d[c.row]??"",b=h.slice(0,c.col),m=h.slice(c.col);if(p.length===1)d[c.row]=b+t+m,c.col+=t.length;else{const f=[b+p[0]];for(let C=1;C<p.length-1;C++)f.push(p[C]);f.push(p[p.length-1]+m),d.splice(c.row,1,...f),c.row+=p.length-1,c.col=p[p.length-1].length}if(e){const f=d.slice(l,c.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:l,oldLines:a,newLines:f},n,o)}this._tokenCache.invalidateLine(c.row,(this._wm.segments[c.row]??[""]).length),this._tab.dirty=!0,(k=(g=this._config).onChange)==null||k.call(g,I(d))}_doBackspace(){var n;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const o=A(this._tab.sel),l=this._tab.doc.slice(o.ar,o.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const a=[this._tab.doc[o.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.ar,oldLines:l,newLines:a},t,s);return}const{doc:i,cur:e}=this._tab;if(e.col>0){const o=i[e.row]??"",l=o.slice(0,e.col),a=l.length>=2&&l.endsWith(" ")&&!l.trim()?2:1;i[e.row]=o.slice(0,e.col-a)+o.slice(e.col),e.col-=a,this._tokenCache.invalidateLine(e.row,((n=this._wm.segments[e.row])==null?void 0:n.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[o],newLines:[i[e.row]]},t,s)}else if(e.row>0){const o=i[e.row-1]??"",l=i[e.row]??"",a=o.length;i[e.row-1]=o+l,i.splice(e.row,1),e.row--,e.col=a,this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[o,l],newLines:[i[e.row]]},t,s)}else return;this._tab.dirty=!0}_doEnter(){const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;let i,e;if(this._tab.sel){const b=A(this._tab.sel);i=b.ar,e=this._tab.doc.slice(b.ar,b.fr+1),this._tab.cur=O(this._tab)}else i=this._tab.cur.row,e=[this._tab.doc[i]??""];const{doc:n,cur:o}=this._tab,l=n[o.row]??"",a=l.slice(0,o.col),d=l.slice(o.col),c=it(l),p=a.trimEnd().endsWith("{")?st(this._config.tabSize):"";n[o.row]=a,a.trimEnd().endsWith("{")&&d.trimStart()==="}"?n.splice(o.row+1,0,c+p,c+d):n.splice(o.row+1,0,c+p+d),o.row++,o.col=c.length+p.length,this._tokenCache.clear();const h=n.slice(i,o.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:i,oldLines:e,newLines:h},t,s),this._tab.dirty=!0}_doDelete(){var o;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const l=A(this._tab.sel),a=this._tab.doc.slice(l.ar,l.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[l.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:l.ar,oldLines:a,newLines:d},t,s);return}const{doc:i,cur:e}=this._tab,n=i[e.row]??"";if(e.col<n.length){const l=n;i[e.row]=n.slice(0,e.col)+n.slice(e.col+1),this._tokenCache.invalidateLine(e.row,((o=this._wm.segments[e.row])==null?void 0:o.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[l],newLines:[i[e.row]]},t,s)}else if(e.row<i.length-1){const l=n,a=i[e.row+1]??"";i[e.row]=l+a,i.splice(e.row+1,1),this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[l,a],newLines:[i[e.row]]},t,s)}else return;this._tab.dirty=!0}_selectAll(){const t=this._tab.doc,s=t.length-1;this._tab.sel={ar:0,ac:0,fr:s,fc:(t[s]??"").length},this._tab.cur={row:s,col:(t[s]??"").length},this._render()}_doCopy(){var s,i;const t=St(this._tab);if(t)this._linewiseCopy=!1,(s=navigator.clipboard)==null||s.writeText(t).catch(()=>{});else{this._linewiseCopy=!0;const e=(this._tab.doc[this._tab.cur.row]??"")+`
|
|
492
|
+
`;(i=navigator.clipboard)==null||i.writeText(e).catch(()=>{})}}_doCut(){var s,i,e,n,o,l;const t=St(this._tab);if(t){this._linewiseCopy=!1,(s=navigator.clipboard)==null||s.writeText(t).catch(()=>{});const a={...this._tab.cur},d=this._tab.sel?{...this._tab.sel}:null,c=A(this._tab.sel),p=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[c.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:p,newLines:h},a,d),this._rebuildWrapMap(),this._render(),(e=(i=this._config).onChange)==null||e.call(i,I(this._tab.doc))}else{this._linewiseCopy=!0;const{doc:a,cur:d}=this._tab,c={...d},p=a[d.row]??"";(n=navigator.clipboard)==null||n.writeText(p+`
|
|
493
|
+
`).catch(()=>{}),a.length>1?(a.splice(d.row,1),L(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"delete",row:c.row,count:1,removed:[p]},c,null)):(a[0]="",d.col=0,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[p],newLines:[""]},c,null)),this._rebuildWrapMap(),L(this._tab),this._render(),(l=(o=this._config).onChange)==null||l.call(o,I(this._tab.doc))}}_doInsertLineBelow(){var n,o,l,a;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,i=this._tab.cur.row,e=it(this._tab.doc[i]??"");this._tab.doc.splice(i+1,0,e),this._tab.cur.row=i+1,this._tab.cur.col=e.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:i+1,lines:[e]},t,s),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(o=(n=this._config).onChange)==null||o.call(n,I(this._tab.doc)),(a=(l=this._config).onCursorChange)==null||a.call(l,{...this._tab.cur})}_doInsertLineAbove(){var n,o,l,a;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,i=this._tab.cur.row,e=it(this._tab.doc[i]??"");this._tab.doc.splice(i,0,e),this._tab.cur.row=i,this._tab.cur.col=e.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:i,lines:[e]},t,s),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(o=(n=this._config).onChange)==null||o.call(n,I(this._tab.doc)),(a=(l=this._config).onCursorChange)==null||a.call(l,{...this._tab.cur})}_toggleComment(){var p,h;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,i=this._getSelRows(),e=i[0],n=i[i.length-1],o=this._tab.doc.slice(e,n+1),l=this._config.lineCommentToken||Zt[this._config.language]||"";if(!l)return;const a=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=i.every(b=>(this._tab.doc[b]??"").trimStart().startsWith(l));i.forEach(b=>{var g;const m=this._tab.doc[b]??"";this._tab.doc[b]=d?m.replace(new RegExp(`^(\\s*)${a}\\s?`),"$1"):m.replace(/^(\s*)/,`$1${l} `),this._tokenCache.invalidateLine(b,((g=this._wm.segments[b])==null?void 0:g.length)??1)}),this._tab.dirty=!0;const c=this._tab.doc.slice(e,n+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e,oldLines:o,newLines:c},t,s),this._rebuildWrapMap(),this._render(),(h=(p=this._config).onChange)==null||h.call(p,I(this._tab.doc))}_duplicateLine(){var n,o;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,i=this._tab.cur.row,e=this._tab.doc[i]??"";this._tab.doc.splice(i+1,0,e),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:i+1,lines:[e]},t,s),this._rebuildWrapMap(),this._render(),(o=(n=this._config).onChange)==null||o.call(n,I(this._tab.doc))}_deleteLine(){var n,o;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,{doc:i,cur:e}=this._tab;if(i.length>1){const l=e.row,a=[i[l]??""];i.splice(l,1),L(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"delete",row:l,count:1,removed:a},t,s)}else{const l=i[0]??"";i[0]="",e.col=0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[l],newLines:[""]},t,s)}this._tokenCache.clear(),this._tab.dirty=!0,L(this._tab),this._rebuildWrapMap(),this._render(),(o=(n=this._config).onChange)==null||o.call(n,I(this._tab.doc))}_indentSel(){var d,c;if(!this._tab.sel){this._insertStr(st(this._config.tabSize),!1);return}const t={...this._tab.cur},s={...this._tab.sel},i=st(this._config.tabSize),e=this._getSelRows(),n=e[0],o=e[e.length-1],l=this._tab.doc.slice(n,o+1);e.forEach(p=>{var h;this._tab.doc[p]=i+(this._tab.doc[p]??""),this._tokenCache.invalidateLine(p,((h=this._wm.segments[p])==null?void 0:h.length)??1)}),this._tab.dirty=!0;const a=this._tab.doc.slice(n,o+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:l,newLines:a},t,s),this._rebuildWrapMap(),this._render(),(c=(d=this._config).onChange)==null||c.call(d,I(this._tab.doc))}_unindentSel(){var d,c;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,i=this._config.tabSize,e=this._getSelRows(),n=e[0],o=e[e.length-1],l=this._tab.doc.slice(n,o+1);e.forEach(p=>{var b;const h=this._tab.doc[p]??"";h.startsWith(st(i))?this._tab.doc[p]=h.slice(i):h.startsWith(" ")&&(this._tab.doc[p]=h.slice(1)),this._tokenCache.invalidateLine(p,((b=this._wm.segments[p])==null?void 0:b.length)??1)}),this._tab.dirty=!0;const a=this._tab.doc.slice(n,o+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:l,newLines:a},t,s),this._rebuildWrapMap(),this._render(),(c=(d=this._config).onChange)==null||c.call(d,I(this._tab.doc))}_toggleWrap(){this._config.wordWrap=!this._config.wordWrap,this._vpEl.classList.toggle("sl-wrap-mode",this._config.wordWrap);const t=this._statusBar.querySelector(".sl-sb-wrap-btn");t&&(t.textContent=`⇥ Wrap: ${this._config.wordWrap?"ON":"OFF"}`,t.classList.toggle("sl-on",this._config.wordWrap)),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const t=A(this._tab.sel),s=[];for(let i=t.ar;i<=t.fr;i++)s.push(i);return s}_duplicateLines(t){var c,p,h,b;const{doc:s,cur:i}=this._tab,e=this._tab.sel;let n=i.row,o=i.row;if(e){const m=A(e);n=m.ar,o=m.fr,m.fc===0&&m.fr>m.ar&&o--}const l={...this._tab.cur},a=e?{...e}:null,d=s.slice(n,o+1);t?(s.splice(o+1,0,...d),i.row+=d.length,e&&(e.ar+=d.length,e.fr+=d.length),M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o+1,lines:[...d]},l,a)):(s.splice(n,0,...d),M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:n,lines:[...d]},l,a)),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(p=(c=this._config).onChange)==null||p.call(c,I(this._tab.doc)),(b=(h=this._config).onCursorChange)==null||b.call(h,{...this._tab.cur})}_moveLines(t){var l,a,d,c;const{doc:s,cur:i}=this._tab,e=this._tab.sel;let n=i.row,o=i.row;if(e){const p=A(e);n=p.ar,o=p.fr,p.fc===0&&p.fr>p.ar&&o--}if(t){if(n===0)return;const p={...this._tab.cur},h=e?{...e}:null,b=n-1,m=s.slice(b,o+1),g=s.splice(n,o-n+1);s.splice(n-1,0,...g),i.row--,e&&(e.ar--,e.fr--);const k=s.slice(b,o+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:b,oldLines:m,newLines:k},p,h)}else{if(o>=s.length-1)return;const p={...this._tab.cur},h=e?{...e}:null,b=o+1,m=s.slice(n,b+1),g=s.splice(n,o-n+1);s.splice(n+1,0,...g),i.row++,e&&(e.ar++,e.fr++);const k=s.slice(n,b+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:m,newLines:k},p,h)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(a=(l=this._config).onChange)==null||a.call(l,I(this._tab.doc)),(c=(d=this._config).onCursorChange)==null||c.call(d,{...this._tab.cur})}_wordSkipRight(t,s){let i=s;const e=t.length;for(;i<e&&/\s/.test(t[i]);)i++;if(i>=e)return i;if(/\w/.test(t[i]))for(;i<e&&/\w/.test(t[i]);)i++;else for(;i<e&&/[^\w\s]/.test(t[i]);)i++;return i}_wordSkipLeft(t,s){let i=s;for(;i>0&&/\s/.test(t[i-1]);)i--;if(i<=0)return i;if(/\w/.test(t[i-1]))for(;i>0&&/\w/.test(t[i-1]);)i--;else for(;i>0&&/[^\w\s]/.test(t[i-1]);)i--;return i}_deleteToLineStart(){var o;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const l=A(this._tab.sel),a=this._tab.doc.slice(l.ar,l.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[l.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:l.ar,oldLines:a,newLines:d},t,s);return}const{doc:i,cur:e}=this._tab;if(e.col===0)return;const n=i[e.row]??"";i[e.row]=n.slice(e.col),e.col=0,this._tokenCache.invalidateLine(e.row,((o=this._wm.segments[e.row])==null?void 0:o.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[n],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}_deleteWordLeft(){var a;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const d=A(this._tab.sel),c=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const p=[this._tab.doc[d.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:c,newLines:p},t,s);return}const{doc:i,cur:e}=this._tab;if(e.col===0){if(e.row>0){const d=i[e.row-1]??"",c=i[e.row]??"",p=d.length;i[e.row-1]=d+c,i.splice(e.row,1),e.row--,e.col=p,this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[d,c],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}return}const n=i[e.row]??"",o=this._wordSkipLeft(n,e.col),l=n;i[e.row]=n.slice(0,o)+n.slice(e.col),e.col=o,this._tokenCache.invalidateLine(e.row,((a=this._wm.segments[e.row])==null?void 0:a.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[l],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}_deleteToLineEnd(){var l;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const a=A(this._tab.sel),d=this._tab.doc.slice(a.ar,a.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const c=[this._tab.doc[a.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.ar,oldLines:d,newLines:c},t,s);return}const{doc:i,cur:e}=this._tab,n=i[e.row]??"";if(e.col>=n.length)return;const o=n;i[e.row]=n.slice(0,e.col),this._tokenCache.invalidateLine(e.row,((l=this._wm.segments[e.row])==null?void 0:l.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[o],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}_deleteWordRight(){var a;const t={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const d=A(this._tab.sel),c=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=O(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const p=[this._tab.doc[d.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:c,newLines:p},t,s);return}const{doc:i,cur:e}=this._tab,n=i[e.row]??"";if(e.col>=n.length){if(e.row<i.length-1){const d=i[e.row+1]??"",c=n;i[e.row]=n+d,i.splice(e.row+1,1),this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[c,d],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}return}const o=this._wordSkipRight(n,e.col),l=n;i[e.row]=n.slice(0,e.col)+n.slice(o),this._tokenCache.invalidateLine(e.row,((a=this._wm.segments[e.row])==null?void 0:a.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e.row,oldLines:[l],newLines:[i[e.row]]},t,s),this._tab.dirty=!0}_doUndo(){var s,i;const t=ae(this._tab);t!==null&&(this._extraCursors=t,this._mc.cursors=t,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(i=(s=this._config).onChange)==null||i.call(s,I(this._tab.doc)))}_doRedo(){var s,i;const t=le(this._tab);t!==null&&(this._extraCursors=t,this._mc.cursors=t,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(i=(s=this._config).onChange)==null||i.call(s,I(this._tab.doc)))}}class ii extends ei{_openFind(t){this._findBar.classList.add("sl-open"),this._replaceRow.style.display=t&&this._config.findReplace?"":"none",this._findInput.focus(),this._findInput.select(),this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx=-1,this._navFind(1)):this._render()}_closeFind(){this._findBar.classList.remove("sl-open"),this._findMatches=[],this._findIdx=-1,this._findCount.textContent="–",this._focusInput(),this._render()}_runFind(t){this._findMatches=Ae(this._tab.doc,t,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(t){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=Be(this._findMatches,this._findIdx,t);const s=this._findMatches[this._findIdx];this._tab.cur={row:s.row,col:s.col},this._tab.sel={ar:s.row,ac:s.col,fr:s.row,fc:s.col+s.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${this._findIdx+1}/${this._findMatches.length}`}_doReplaceOne(){var o,l;if(this._findIdx<0||!this._findMatches.length)return;const t=this._findMatches[this._findIdx],s={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null,e=this._tab.doc[t.row]??"";this._tab.doc=He(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const n=this._tab.doc[t.row]??"";M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:t.row,oldLines:[e],newLines:[n]},s,i),this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx>=this._findMatches.length&&(this._findIdx=0),this._navFind(0)):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(l=(o=this._config).onChange)==null||l.call(o,I(this._tab.doc))}_doReplaceAll(){var a,d;if(!this._findMatches.length)return;const t=this._findMatches.length,s={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null,e=this._findMatches[0].row,n=this._findMatches[this._findMatches.length-1].row,o=this._tab.doc.slice(e,n+1);this._tab.doc=De(this._tab.doc,this._findMatches,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const l=this._tab.doc.slice(e,n+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:e,oldLines:o,newLines:l},s,i),this._findMatches=[],this._findIdx=-1,this._findCount.textContent=`0/0 (${t} replaced)`,this._rebuildWrapMap(),this._render(),(d=(a=this._config).onChange)==null||d.call(a,I(this._tab.doc))}_bindFindEvents(){var t,s,i,e,n,o,l;this._findInput.addEventListener("input",()=>{this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),this._findInput.addEventListener("keydown",a=>{a.key==="Enter"?a.shiftKey?this._navFind(-1):this._navFind(1):a.key==="Escape"&&this._closeFind(),a.stopPropagation()}),this._replaceInput.addEventListener("keydown",a=>{a.key==="Enter"?this._doReplaceOne():a.key==="Escape"&&this._closeFind(),a.stopPropagation()}),(t=this._findBar.querySelector(".sl-find-prev"))==null||t.addEventListener("click",()=>this._navFind(-1)),(s=this._findBar.querySelector(".sl-find-next"))==null||s.addEventListener("click",()=>this._navFind(1)),(i=this._findBar.querySelector(".sl-find-close"))==null||i.addEventListener("click",()=>this._closeFind()),(e=this._findBar.querySelector(".sl-find-case"))==null||e.addEventListener("click",a=>{this._findCaseSensitive=!this._findCaseSensitive,a.target.classList.toggle("sl-active",this._findCaseSensitive),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(n=this._findBar.querySelector(".sl-find-regex"))==null||n.addEventListener("click",a=>{this._findRegex=!this._findRegex,a.target.classList.toggle("sl-active",this._findRegex),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(o=this._findBar.querySelector(".sl-replace-one"))==null||o.addEventListener("click",()=>this._doReplaceOne()),(l=this._findBar.querySelector(".sl-replace-all"))==null||l.addEventListener("click",()=>this._doReplaceAll())}}class si extends ii{_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[]}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},120)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}const{cur:t,doc:s}=this._tab,i=s[t.row]??"",e=this._config.language==="css",{prefix:n,start:o}=Ie(i,t.col,e);this._acPrefix=n,this._acStartCol=o;const l=[];if(this._config.emmet){const d=jt(i,t.col);if(d){const c=Bt(d.abbr);if(c){this._emmetAcStartCol=d.start;const p=c.replace(/\n/g,"↵ ").slice(0,60);l.push({label:d.abbr,kind:"emmet",detail:p,body:c})}}}const a=n.length>=this._config.autocompletePrefixLength?Re(s,n,{language:this._config.language,extraKeywords:this._config.extraKeywords,extraTypes:this._config.extraTypes,completions:this._allCompletions(),replaceBuiltins:this._config.replaceBuiltins,maxResults:this._config.maxCompletions,provideCompletions:this._config.provideCompletions},t.row,t.col):[];if(this._acItems=[...l,...a],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const t=a=>{switch(a){case"kw":return"K";case"fn":return"f";case"typ":return"T";case"cls":return"C";case"snip":return"S";case"emmet":return"E";default:return"·"}},s=this._acItems[this._acSel];let i="";s!=null&&s.description?i=s.description:(s==null?void 0:s.kind)==="snip"&&s.body?i=s.body.replace(/\$\d/g,"▌"):(s==null?void 0:s.kind)==="emmet"&&s.body&&(i=s.body);const e=this._acItems.map((a,d)=>{const c=d===this._acSel;return`<div class="sl-ac-item${c?" sl-sel":""}" data-i="${d}" role="option" aria-selected="${c}"><span class="sl-ac-badge ${a.kind}">${t(a.kind)}</span><span class="sl-ac-label">${a.label}</span><span class="sl-ac-detail">${a.detail??""}</span></div>`}).join(""),n=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"<")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${e}</div>`+n,this._acPopup.style.display="flex",this._posAcPopup();const o=this._acPopup.querySelector(".sl-ac-list"),l=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(o&&l){const a=l.offsetTop,d=a+l.offsetHeight;d>o.scrollTop+o.clientHeight?o.scrollTop=d-o.clientHeight:a<o.scrollTop&&(o.scrollTop=a)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(a=>{a.addEventListener("mousedown",d=>{d.preventDefault(),this._acSel=parseInt(a.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const t=this._editorEl.getBoundingClientRect(),s=z(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,e=t.left+i+14+this._acStartCol*7.82,n=t.top+(s.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,l=!!this._acPopup.querySelector(".sl-ac-desc")?620:300,a=Math.min(this._acItems.length*28+8,320),d=n+a>window.innerHeight-16;this._acPopup.style.left=`${Math.min(e,window.innerWidth-l-16)}px`,this._acPopup.style.top=`${d?n-this._config.lineHeight-2-a:n}px`}_acAccept(){const t=this._acItems[this._acSel];if(!t)return;if(this._acHide(),t.kind==="emmet"&&t.body){const i={...this._tab.cur},e=this._tab.sel?{...this._tab.sel}:null,n=this._tab.cur.row,o=this._tab.doc[n]??"";this._expandBodyAt(t.body,this._emmetAcStartCol);const l=this._tab.doc.slice(n,this._tab.cur.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:[o],newLines:l},i,e);return}if(t.body){const i={...this._tab.cur},e=this._tab.sel?{...this._tab.sel}:null,n=this._tab.cur.row,o=this._tab.doc[n]??"";this._expandBodyAt(t.body,this._acStartCol);const l=this._tab.doc.slice(n,this._tab.cur.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:[o],newLines:l},i,e);return}const s=t.label.slice(this._acPrefix.length);this._insertStr(s,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render()}_allCompletions(){return[...this._config.replaceBuiltins?[]:Te(this._config.language),...this._config.completions]}_emmetCheck(){if(this._emmetTip.style.display="none",!this._config.emmet){this._emmetExpanded=null;return}const{cur:t,doc:s}=this._tab,i=s[t.row]??"",e=jt(i,t.col);if(!e){this._emmetExpanded=null;return}const n=Bt(e.abbr);if(!n){this._emmetExpanded=null;return}this._emmetExpanded={abbr:e.abbr,result:n,start:e.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{result:t,start:s}=this._emmetExpanded,i={...this._tab.cur},e=this._tab.sel?{...this._tab.sel}:null,n=this._tab.cur.row,o=this._tab.doc[n]??"";this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(t,s);const l=this._tab.doc.slice(n,this._tab.cur.row+1);return M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:[o],newLines:l},i,e),!0}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:t,doc:s}=this._tab,i=s[t.row]??"",e=Me(i,t.col,this._allCompletions());if(!e){this._snippetExpanded=null;return}this._snippetExpanded={snippet:e.snippet,start:e.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:t,start:s}=this._snippetExpanded;if(!t.body)return!1;const i={...this._tab.cur},e=this._tab.sel?{...this._tab.sel}:null,n=this._tab.cur.row,o=this._tab.doc[n]??"";this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(t.body,s);const l=this._tab.doc.slice(n,this._tab.cur.row+1);return M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n,oldLines:[o],newLines:l},i,e),!0}_expandBodyAt(t,s){var f,C;const{doc:i,cur:e}=this._tab,n=e.row,o=i[e.row]??"",l=o.slice(0,s),a=o.slice(e.col),d=it(o),c=t.split(`
|
|
494
|
+
`).map((_,w)=>w===0?_:d+_),p=c.join(`
|
|
495
|
+
`),h=[],b=/\$(\d+)/g;let m;for(;(m=b.exec(p))!==null;){const _=parseInt(m[1],10),u=p.slice(0,m.index).split(`
|
|
496
|
+
`),y=u.length-1,S=u[y].length,x=(u[y].match(/\$\d+/g)??[]).join("").length,R=n+y,P=(y===0?s:d.length)+(S-x);h.push({n:_,row:R,col:P})}h.sort((_,w)=>_.n===0?1:w.n===0?-1:_.n-w.n);const g=c.map(_=>_.replace(/\$\d+/g,"")),k=g.length===1?[l+g[0]+a]:[l+g[0],...g.slice(1,-1),g[g.length-1]+a];i.splice(e.row,1,...k),h.length>0?(this._snippetSession={stops:h.map(_=>({row:_.row,col:_.col})),idx:0},e.row=h[0].row,e.col=h[0].col):(this._snippetSession=null,e.row+=k.length-1,e.col=(k[k.length-1]??"").length-a.length),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(C=(f=this._config).onChange)==null||C.call(f,I(this._tab.doc))}_ctrlD(){if(!this._config.multiCursor)return;const t=!this._mc.searchWord,s=!!this._tab.sel;if(t&&s){const e=this._tab.sel,n=Math.min(e.ac,e.fc),o=Math.max(e.ac,e.fc);if(e.ar===e.fr){const l=(this._tab.doc[e.ar]??"").slice(n,o);l&&(this._mc.searchWord=l,this._mc.lastMatchRow=e.fr,this._mc.lastMatchCol=o)}}const i=fe(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel);i&&(t&&!s?(this._tab.sel=i.sel,this._tab.cur.row=i.row,this._tab.cur.col=i.col):(i.row!==this._tab.cur.row||i.col!==this._tab.cur.col)&&(It(this._mc,i.row,i.col,i.sel),this._extraCursors=[...this._mc.cursors]),this._mc.searchWord=i.word,this._mc.lastMatchRow=i.row,this._mc.lastMatchCol=i.col,this._scrollIntoView(),this._render())}}class ni extends si{_scheduleHover(t){this._hoverTip.style.display!=="none"&&(this._hoverTip.style.display="none"),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null);const{clientX:s,clientY:i}=t;this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._doHover(s,i)},500)}_doHover(t,s){var f,C,_;if(!this._config.hover)return;const i=this._editorEl.getBoundingClientRect(),e=this._logicalScroll(this._editorEl.scrollTop),n=s-i.top+e,o=this._config.showGutter?this._config.gutterWidth:0,l=t-i.left-o-14,a=this._config.lineHeight,d=this._wm.windowVisStart,c=d+this._wm.visualRows.length-1,p=Math.max(d,Math.min(c,Math.floor(n/a))),h=Math.max(0,Math.min((((f=this._wm.visualRows[p-d])==null?void 0:f.text)??"").length,Math.round(l/7.82))),b=et(this._wm,p,h),m=this._tab.doc[b.row]??"",g=ye(m,b.col);if(!g)return;let k=ve(g,this._config.language);if(!k){const w=this._config.completions.find(u=>u.label===g);w&&(w.description||w.detail)&&(k={title:w.label,type:w.detail,body:w.description??""})}if(!k){const w=(_=(C=this._config).provideHover)==null?void 0:_.call(C,{word:g,row:b.row,col:b.col,line:m,language:this._config.language,doc:this._tab.doc});w&&(k=w)}k&&this._showHoverTip(k,t,s)}_showHoverTip(t,s,i){const e=this._hoverTip;let n='<div class="sl-ht-sig">';n+=`<span class="sl-ht-title">${q(t.title)}</span>`,t.type&&(n+=`<code class="sl-ht-type">${q(t.type)}</code>`),n+="</div>",t.title&&t.body&&(n+='<div class="sl-ht-divider"></div>'),t.body&&(n+=`<div class="sl-ht-body">${q(t.body)}</div>`),e.innerHTML=n,e.style.display="block";const o=12,l=18,a=e.offsetWidth||300,d=e.offsetHeight||80;let c=s,p=i+l;p+d>window.innerHeight-o&&(p=i-d-8),c+a>window.innerWidth-o&&(c=window.innerWidth-a-o),c<o&&(c=o),e.style.left=`${c}px`,e.style.top=`${Math.max(o,p)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_openThemePicker(){var s;const t=this._themeManager.all;this._themePanel.innerHTML=`
|
|
493
497
|
<div class="sl-theme-header">
|
|
494
498
|
<div class="sl-theme-title">Color Theme</div>
|
|
495
499
|
<div class="sl-theme-close">✕</div>
|
|
496
500
|
</div>
|
|
497
501
|
<div class="sl-theme-list">
|
|
498
|
-
${
|
|
502
|
+
${t.map(i=>`
|
|
499
503
|
<div class="sl-theme-item${i.id===this._themeManager.activeId?" sl-active":""}" data-id="${i.id}">
|
|
500
504
|
<div class="sl-theme-swatch">
|
|
501
505
|
${i.tokens.bg0?`<span style="background:${i.tokens.bg0}"></span>`:""}
|
|
@@ -511,5 +515,6 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
511
515
|
</div>
|
|
512
516
|
`).join("")}
|
|
513
517
|
</div>
|
|
514
|
-
`,this._themeOverlay.style.display="block",(t=this._themePanel.querySelector(".sl-theme-close"))==null||t.addEventListener("click",()=>{this._themeOverlay.style.display="none"}),this._themeOverlay.addEventListener("click",i=>{i.target===this._themeOverlay&&(this._themeOverlay.style.display="none")},{once:!0}),this._themePanel.querySelectorAll(".sl-theme-item").forEach(i=>{i.addEventListener("click",()=>{const n=i.dataset.id??"";this.setTheme(n),this._themePanel.querySelectorAll(".sl-theme-item").forEach(r=>r.classList.remove("sl-active")),i.classList.add("sl-active")})})}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",this._onFoldBtnClick),this._editorEl.addEventListener("mousedown",e=>{if(e.button!==0)return;e.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",e.altKey||($e(this._mc),this._extraCursors=[]);const t=this._posFromMouse(e);if(this._tab.cur={...t},e.detail===3)this._tab.sel={ar:t.row,ac:0,fr:t.row,fc:(this._tab.doc[t.row]??"").length},this._tab.cur.col=this._tab.sel.fc;else if(e.detail===2&&this._config.wordSelection){const i=this._tab.doc[t.row]??"",n=re(i,t.col,this._isWordChar.bind(this)),r=se(i,t.col,this._isWordChar.bind(this));n!==r?(this._tab.sel={ar:t.row,ac:n,fr:t.row,fc:r},this._tab.cur.col=r):this._tab.sel=null}else{if(e.altKey&&this._config.multiCursor){Pe(this._mc,t.row,t.col,null),this._extraCursors=[...this._mc.cursors],this._render();return}this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...t}}E(this._tab),this._render()}),this._editorEl.addEventListener("mousemove",e=>{if(this._config.hover&&!this._hoverPinned&&!this._isDragging&&this._scheduleHover(e),!this._isDragging||!this._dragAnchor)return;const t=this._posFromMouse(e);this._tab.cur={...t},t.row!==this._dragAnchor.row||t.col!==this._dragAnchor.col?this._tab.sel={ar:this._dragAnchor.row,ac:this._dragAnchor.col,fr:t.row,fc:t.col}:this._tab.sel=null,E(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverPinned||this._hideHover()}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize),this._inputEl.addEventListener("keydown",e=>this._onKeyDown(e)),this._inputEl.addEventListener("input",e=>this._onInput(e)),this._inputEl.addEventListener("paste",e=>{var i;if(e.preventDefault(),this._config.readOnly)return;const t=(i=e.clipboardData??window.clipboardData)==null?void 0:i.getData("text/plain");t&&(this._insertStr(t,!1),this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render())}),this._editorEl.addEventListener("mousedown",()=>setTimeout(()=>this._focusInput(),0)),this._inputEl.addEventListener("focus",()=>{var e,t;return(t=(e=this._config).onFocus)==null?void 0:t.call(e)}),this._inputEl.addEventListener("blur",()=>{var e,t;return(t=(e=this._config).onBlur)==null?void 0:t.call(e)})}_onKeyDown(e){var o,l,a,c,d,h,p,f,_;const t=e.ctrlKey||e.metaKey,i=e.shiftKey,n=e.altKey,r=this._config.readOnly;if(this._hideHover(),this._acVisible()){if(e.key==="ArrowDown"){e.preventDefault(),this._acSel=Math.min(this._acItems.length-1,this._acSel+1),this._renderAcPopup();return}if(e.key==="ArrowUp"){e.preventDefault(),this._acSel=Math.max(0,this._acSel-1),this._renderAcPopup();return}if(e.key==="Tab"||e.key==="Enter"){e.preventDefault(),this._acAccept();return}if(e.key==="Escape"){this._acHide();return}}if(n&&(e.key==="z"||e.key==="Z"||e.key==="Ω")){e.preventDefault(),this._toggleWrap();return}if(t&&e.key==="z"&&!i){e.preventDefault(),r||this.undo();return}if(t&&(e.key==="y"||i&&e.key==="z")){e.preventDefault(),r||this.redo();return}if(t&&e.key==="a"){e.preventDefault(),this._selectAll();return}if(t&&e.key==="c"){e.preventDefault(),this._doCopy();return}if(t&&e.key==="x"){e.preventDefault(),r||this._doCut();return}if(t&&e.key==="f"){e.preventDefault(),this._config.find&&this._openFind(!1);return}if(t&&e.key==="h"){e.preventDefault(),this._config.find&&this._config.findReplace&&this._openFind(!0);return}if(t&&e.key==="g"){e.preventDefault(),this._config.goToLine&&this._openGoToLine();return}if(t&&e.key==="d"){e.preventDefault(),!r&&this._config.multiCursor&&this._ctrlD();return}if(t&&i&&e.key==="d"){e.preventDefault(),r||this._duplicateLine();return}if(t&&e.key==="/"){e.preventDefault(),r||this._toggleComment();return}if(t&&e.key==="k"){e.preventDefault(),r||this._deleteLine();return}if(e.key==="Escape"){this._tab.sel=null,this._acHide(),this._closeFind(),this._closeGoToLine(),this._emmetTip.style.display="none",this._snippetTip.style.display="none",this._snippetExpanded=null,this._snippetSession=null,$e(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(r){this._handleArrowKeys(e,t,i);return}if(e.key==="Tab"){if(e.preventDefault(),this._snippetSession){if(i){if(this._snippetSession.idx>0){this._snippetSession.idx--;const b=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=b.row,this._tab.cur.col=b.col,this._tab.sel=null,E(this._tab),this._scrollIntoView(),this._render()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const b=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=b.row,this._tab.cur.col=b.col,this._tab.sel=null,E(this._tab),this._scrollIntoView(),this._render()}return}if(!i&&this._emmetAccept()||!i&&this._snippetAccept())return;i?this._unindentSel():this._indentSel(),E(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){this._snippetSession=null;const b=vt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors);this._tab.doc=b.doc,this._tab.cur.row=b.primaryRow,this._tab.cur.col=b.primaryCol,this._extraCursors=b.extraCursors,this._mc.cursors=b.extraCursors}else{if(this._snippetSession){const b=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===b.row&&this._tab.cur.col>b.col){for(let v=this._snippetSession.idx+1;v<this._snippetSession.stops.length;v++){const u=this._snippetSession.stops[v];u.row===b.row&&u.col>=this._tab.cur.col&&u.col--}b.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(l=(o=this._config).onChange)==null||l.call(o,D(this._tab.doc));return}if(e.key==="Delete"){e.preventDefault(),this._snippetSession=null,this._doDelete(),this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(c=(a=this._config).onChange)==null||c.call(a,D(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(h=(d=this._config).onChange)==null||h.call(d,D(this._tab.doc));return}if(!t&&!n&&this._config.autoClosePairs[e.key]){e.preventDefault(),S(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=z(this._tab));const{doc:b,cur:v}=this._tab,u=b[v.row]??"";b[v.row]=u.slice(0,v.col)+e.key+this._config.autoClosePairs[e.key]+u.slice(v.col),v.col++,this._tokenCache.invalidateLine(v.row,((p=this._wm.segments[v.row])==null?void 0:p.length)??1),this._tab.dirty=!0,this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(_=(f=this._config).onChange)==null||_.call(f,D(this._tab.doc));return}if(!t&&!n&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:b,cur:v}=this._tab;if((b[v.row]??"")[v.col]===e.key){e.preventDefault(),v.col++,E(this._tab),this._scrollIntoView(),this._render();return}}if(i&&n&&!t&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._duplicateLines(e.key==="ArrowDown");return}if(n&&!t&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._moveLines(e.key==="ArrowUp");return}this._handleArrowKeys(e,t,i)}_handleArrowKeys(e,t,i){var f,_,b,v,u,T;const{doc:n,cur:r}=this._tab,o=this._config.lineHeight,l=e.metaKey,a=e.ctrlKey,c=e.altKey,d=(m,w)=>{if(i){this._tab.sel||(this._tab.sel={ar:r.row,ac:r.col,fr:r.row,fc:r.col}),r.row=m,r.col=w;const y=this._tab.sel;y.fr=m,y.fc=w,y.ar===y.fr&&y.ac===y.fc&&(this._tab.sel=null)}else this._tab.sel=null,r.row=m,r.col=w},h=m=>{const y=(n[m]??"").search(/\S/);return y===-1||r.col===y?0:y},p=()=>({row:n.length-1,col:(n[n.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const m=W(this._tab.sel);r.row=m.fr,r.col=m.fc,this._tab.sel=null;break}if(l)d(r.row,(n[r.row]??"").length);else if(a||c){const m=n[r.row]??"";if(r.col>=m.length)r.row<n.length-1&&d(r.row+1,0);else{const w=this._wordSkipRight(m,r.col);d(r.row,w)}}else r.col<(n[r.row]??"").length?d(r.row,r.col+1):r.row<n.length-1&&d(r.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const m=W(this._tab.sel);r.row=m.ar,r.col=m.ac,this._tab.sel=null;break}if(l)d(r.row,h(r.row));else if(a||c)if(r.col===0)r.row>0&&d(r.row-1,(n[r.row-1]??"").length);else{const m=this._wordSkipLeft(n[r.row]??"",r.col);d(r.row,m)}else r.col>0?d(r.row,r.col-1):r.row>0&&d(r.row-1,(n[r.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),l){const m=p();d(m.row,m.col)}else if(this._config.wordWrap){const m=F(this._wm,r.row,r.col),w=Math.min(this._wm.visualRows.length-1,m.visRow+1),y=Z(this._wm,w,Math.min(m.colInSeg,(((f=this._wm.visualRows[w])==null?void 0:f.text)??"").length));d(y.row,y.col)}else{const m=Math.min(n.length-1,r.row+1);d(m,Math.min(r.col,(n[m]??"").length))}break;case"ArrowUp":if(e.preventDefault(),l)d(0,0);else if(this._config.wordWrap){const m=F(this._wm,r.row,r.col),w=Math.max(0,m.visRow-1),y=Z(this._wm,w,Math.min(m.colInSeg,(((_=this._wm.visualRows[w])==null?void 0:_.text)??"").length));d(y.row,y.col)}else{const m=Math.max(0,r.row-1);d(m,Math.min(r.col,(n[m]??"").length))}break;case"Home":e.preventDefault(),a?d(0,0):d(r.row,h(r.row));break;case"End":if(e.preventDefault(),a){const m=p();d(m.row,m.col)}else d(r.row,(n[r.row]??"").length);break;case"PageDown":e.preventDefault();{const m=Math.max(1,Math.floor(this._editorEl.clientHeight/o)-1),w=Math.min(n.length-1,r.row+m);d(w,Math.min(r.col,(n[w]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-o;break}case"PageUp":e.preventDefault();{const m=Math.max(1,Math.floor(this._editorEl.clientHeight/o)-1),w=Math.max(0,r.row-m);d(w,Math.min(r.col,(n[w]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-o;break}default:return}E(this._tab),this._scrollIntoView(),this._acHide(),(v=(b=this._config).onCursorChange)==null||v.call(b,{...this._tab.cur}),(T=(u=this._config).onSelectionChange)==null||T.call(u,this._tab.sel?{...this._tab.sel}:null),this._render()}_isWordChar(e){const t=this._config.wordSeparators;return t?e.trim()!==""&&!t.includes(e):/[\w$]/.test(e)}_wordSkipRight(e,t){let i=t;const n=e.length;for(;i<n&&/\s/.test(e[i]);)i++;if(i>=n)return i;if(/\w/.test(e[i]))for(;i<n&&/\w/.test(e[i]);)i++;else for(;i<n&&/[^\w\s]/.test(e[i]);)i++;return i}_wordSkipLeft(e,t){let i=t;for(;i>0&&/\s/.test(e[i-1]);)i--;if(i<=0)return i;if(/\w/.test(e[i-1]))for(;i>0&&/\w/.test(e[i-1]);)i--;else for(;i>0&&/[^\w\s]/.test(e[i-1]);)i--;return i}_duplicateLines(e){var a,c,d,h;const{doc:t,cur:i}=this._tab,n=this._tab.sel;let r=i.row,o=i.row;if(n){const p=W(n);r=p.ar,o=p.fr,p.fc===0&&p.fr>p.ar&&o--}S(this._tab,this._config.maxUndoHistory);const l=t.slice(r,o+1);e?(t.splice(o+1,0,...l),i.row+=l.length,n&&(n.ar+=l.length,n.fr+=l.length)):t.splice(r,0,...l),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(c=(a=this._config).onChange)==null||c.call(a,D(this._tab.doc)),(h=(d=this._config).onCursorChange)==null||h.call(d,{...this._tab.cur})}_moveLines(e){var l,a,c,d;const{doc:t,cur:i}=this._tab,n=this._tab.sel;let r=i.row,o=i.row;if(n){const h=W(n);r=h.ar,o=h.fr,h.fc===0&&h.fr>h.ar&&o--}if(e){if(r===0)return;S(this._tab,this._config.maxUndoHistory);const h=t.splice(r,o-r+1);t.splice(r-1,0,...h),i.row--,n&&(n.ar--,n.fr--)}else{if(o>=t.length-1)return;S(this._tab,this._config.maxUndoHistory);const h=t.splice(r,o-r+1);t.splice(r+1,0,...h),i.row++,n&&(n.ar++,n.fr++)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),(a=(l=this._config).onChange)==null||a.call(l,D(this._tab.doc)),(d=(c=this._config).onCursorChange)==null||d.call(c,{...this._tab.cur})}_scheduleHover(e){this._hoverTip.style.display!=="none"&&(this._hoverTip.style.display="none"),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null);const{clientX:t,clientY:i}=e;this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._doHover(t,i)},500)}_doHover(e,t){var _,b,v;if(!this._config.hover)return;const i=this._editorEl.getBoundingClientRect(),n=t-i.top+this._editorEl.scrollTop,r=this._config.showGutter?this._config.gutterWidth:0,o=e-i.left-r-14,l=this._config.lineHeight,a=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(n/l))),c=Math.max(0,Math.min((((_=this._wm.visualRows[a])==null?void 0:_.text)??"").length,Math.round(o/7.82))),d=Z(this._wm,a,c),h=this._tab.doc[d.row]??"",p=At(h,d.col);if(!p)return;let f=Ht(p,this._config.language);if(!f){const u=this._config.completions.find(T=>T.label===p);u&&(u.description||u.detail)&&(f={title:u.label,type:u.detail,body:u.description??""})}if(!f){const u=(v=(b=this._config).provideHover)==null?void 0:v.call(b,{word:p,row:d.row,col:d.col,line:h,language:this._config.language,doc:this._tab.doc});u&&(f=u)}f&&this._showHoverTip(f,e,t)}_showHoverTip(e,t,i){const n=this._hoverTip;let r='<div class="sl-ht-sig">';r+=`<span class="sl-ht-title">${V(e.title)}</span>`,e.type&&(r+=`<code class="sl-ht-type">${V(e.type)}</code>`),r+="</div>",e.title&&e.body&&(r+='<div class="sl-ht-divider"></div>'),e.body&&(r+=`<div class="sl-ht-body">${V(e.body)}</div>`),n.innerHTML=r,n.style.display="block";const o=12,l=18,a=n.offsetWidth||300,c=n.offsetHeight||80;let d=t,h=i+l;h+c>window.innerHeight-o&&(h=i-c-8),d+a>window.innerWidth-o&&(d=window.innerWidth-a-o),d<o&&(d=o),n.style.left=`${d}px`,n.style.top=`${Math.max(o,h)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_onInput(e){var r,o,l,a;if(this._config.readOnly){e.target.value="";return}const t=e.target,i=t.value;if(t.value="",!i||i==="Ω")return;const n=i.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(n){if(this._extraCursors.length){this._snippetSession=null;const c=yt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors,n);this._tab.doc=c.doc,this._tab.cur.row=c.primaryRow,this._tab.cur.col=c.primaryCol,this._extraCursors=c.extraCursors,this._mc.cursors=c.extraCursors,this._tab.dirty=!0,(o=(r=this._config).onChange)==null||o.call(r,D(this._tab.doc))}else{const c=this._tab.cur.row,d=this._tab.cur.col;if(this._insertStr(n,!0),this._snippetSession){const h=this._snippetSession,p=h.stops[h.idx];if(this._tab.cur.row===p.row){const f=this._tab.cur.col-d;for(let _=h.idx+1;_<h.stops.length;_++){const b=h.stops[_];b.row===c&&b.col>=d&&(b.col+=f)}p.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),E(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(a=(l=this._config).onCursorChange)==null||a.call(l,{...this._tab.cur})}}_ctrlD(){if(!this._config.multiCursor)return;const e=wt(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel);e&&(!this._mc.cursors.length||e.word!==this._mc.searchWord?(this._tab.sel=e.sel,this._tab.cur.col=e.col):(Pe(this._mc,e.row,e.col,e.sel),this._extraCursors=[...this._mc.cursors]),this._mc.searchWord=e.word,this._mc.lastMatchRow=e.row,this._mc.lastMatchCol=e.col,this._scrollIntoView(),this._render())}_bindFindEvents(){var e,t,i,n,r,o,l;this._findInput.addEventListener("input",()=>{this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),this._findInput.addEventListener("keydown",a=>{a.key==="Enter"?a.shiftKey?this._navFind(-1):this._navFind(1):a.key==="Escape"&&this._closeFind(),a.stopPropagation()}),this._replaceInput.addEventListener("keydown",a=>{a.key==="Enter"?this._doReplaceOne():a.key==="Escape"&&this._closeFind(),a.stopPropagation()}),(e=this._findBar.querySelector(".sl-find-prev"))==null||e.addEventListener("click",()=>this._navFind(-1)),(t=this._findBar.querySelector(".sl-find-next"))==null||t.addEventListener("click",()=>this._navFind(1)),(i=this._findBar.querySelector(".sl-find-close"))==null||i.addEventListener("click",()=>this._closeFind()),(n=this._findBar.querySelector(".sl-find-case"))==null||n.addEventListener("click",a=>{this._findCaseSensitive=!this._findCaseSensitive,a.target.classList.toggle("sl-active",this._findCaseSensitive),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(r=this._findBar.querySelector(".sl-find-regex"))==null||r.addEventListener("click",a=>{this._findRegex=!this._findRegex,a.target.classList.toggle("sl-active",this._findRegex),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(o=this._findBar.querySelector(".sl-replace-one"))==null||o.addEventListener("click",()=>this._doReplaceOne()),(l=this._findBar.querySelector(".sl-replace-all"))==null||l.addEventListener("click",()=>this._doReplaceAll())}_doReplaceOne(){var e,t;this._findIdx<0||!this._findMatches.length||(S(this._tab,this._config.maxUndoHistory),this._tab.doc=xt(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx>=this._findMatches.length&&(this._findIdx=0),this._navFind(0)):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}_doReplaceAll(){var t,i;if(!this._findMatches.length)return;const e=this._findMatches.length;S(this._tab,this._config.maxUndoHistory),this._tab.doc=Tt(this._tab.doc,this._findMatches,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._findMatches=[],this._findIdx=-1,this._findCount.textContent=`0/0 (${e} replaced)`,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc))}_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:n,sliderHeight:r}=he(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=n&&i<=n+r?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,n=t.clientY-e.getBoundingClientRect().top,{sliderTop:r,sliderHeight:o}=he(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);if(n>=r&&n<=r+o)this._mmDragMode="slider",this._mmSliderOffset=n-r,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const l=Nt(n,this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=l,this._mmDragStartY=t.clientY,this._mmDragStartScroll=l,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}function Ut(s,e){return new Fe(s,e)}M.BUILT_IN_THEMES=Le,M.SynclineEditor=Fe,M.THEME_DRACULA=Te,M.THEME_GITHUB_LIGHT=Ee,M.THEME_MDX_DARK=Me,M.THEME_MDX_LIGHT=Se,M.THEME_MONOKAI=xe,M.THEME_SOLARIZED_LIGHT=Ce,M.THEME_VR_DARK=we,M.THEME_VSCODE_DARK=ke,M.createEditor=Ut,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
518
|
+
`,this._themeOverlay.style.display="block",(s=this._themePanel.querySelector(".sl-theme-close"))==null||s.addEventListener("click",()=>{this._themeOverlay.style.display="none"}),this._themeOverlay.addEventListener("click",i=>{i.target===this._themeOverlay&&(this._themeOverlay.style.display="none")},{once:!0}),this._themePanel.querySelectorAll(".sl-theme-item").forEach(i=>{i.addEventListener("click",()=>{const e=i.dataset.id??"";this._applyTheme(e),this._themePanel.querySelectorAll(".sl-theme-item").forEach(n=>n.classList.remove("sl-active")),i.classList.add("sl-active")})})}_applyTheme(t){this._themeManager.apply(t),this._applyTokenOverrides(),this._mmColors=ut(s=>nt(s,this._host)),this._tokenCache.clear(),this._render()}}class ri extends ni{_posFromMouse(t){var h;const s=this._editorEl.getBoundingClientRect(),i=this._logicalScroll(this._editorEl.scrollTop),e=t.clientY-s.top+i,n=this._config.showGutter?this._config.gutterWidth:0,o=t.clientX-s.left-n-14,l=this._config.lineHeight,a=this._wm.windowVisStart,d=a+this._wm.visualRows.length-1,c=Math.max(a,Math.min(d,Math.floor(e/l))),p=Math.max(0,Math.min((((h=this._wm.visualRows[c-a])==null?void 0:h.text)??"").length,Math.round(o/7.82)));return et(this._wm,c,p)}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",t=>this._onFoldBtnClick(t)),this._editorEl.addEventListener("mousedown",t=>{var i,e;if(t.button!==0)return;t.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",t.altKey||(At(this._mc),this._extraCursors=[]);const s=this._posFromMouse(t);if(t.altKey&&t.detail===1&&!t.shiftKey&&this._config.multiCursor){It(this._mc,s.row,s.col,null),this._extraCursors=[...this._mc.cursors],this._render();return}if(t.shiftKey&&t.detail===1){const n=this._tab.sel?{row:this._tab.sel.ar,col:this._tab.sel.ac}:{row:this._tab.cur.row,col:this._tab.cur.col};this._tab.cur={...s},this._tab.sel={ar:n.row,ac:n.col,fr:s.row,fc:s.col},n.row===s.row&&n.col===s.col&&(this._tab.sel=null),this._isDragging=!1,L(this._tab),this._render(),(e=(i=this._config).onSelectionChange)==null||e.call(i,this._tab.sel?{...this._tab.sel}:null);return}if(this._tab.cur={...s},t.detail===3)this._tab.sel={ar:s.row,ac:0,fr:s.row,fc:(this._tab.doc[s.row]??"").length},this._tab.cur.col=this._tab.sel.fc;else if(t.detail===2&&this._config.wordSelection){const n=this._tab.doc[s.row]??"",o=this._wordStart(n,s.col),l=this._wordEnd(n,s.col);o!==l?(this._tab.sel={ar:s.row,ac:o,fr:s.row,fc:l},this._tab.cur.col=l):this._tab.sel=null}else this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...s};L(this._tab),this._render()}),this._editorEl.addEventListener("mousemove",t=>{if(this._config.hover&&!this._hoverPinned&&!this._isDragging&&this._scheduleHover(t),!this._isDragging||!this._dragAnchor)return;const s=this._posFromMouse(t);this._tab.cur={...s},s.row!==this._dragAnchor.row||s.col!==this._dragAnchor.col?this._tab.sel={ar:this._dragAnchor.row,ac:this._dragAnchor.col,fr:s.row,fc:s.col}:this._tab.sel=null,L(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverPinned||this._hideHover()}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize),this._inputEl.addEventListener("keydown",t=>this._onKeyDown(t)),this._inputEl.addEventListener("input",t=>this._onInput(t)),this._inputEl.addEventListener("paste",t=>{var i,e,n,o,l;if(t.preventDefault(),this._config.readOnly)return;const s=(i=t.clipboardData??window.clipboardData)==null?void 0:i.getData("text/plain");if(s){if(this._linewiseCopy&&!this._tab.sel){const a={...this._tab.cur},d=this._tab.cur.row,c=s.endsWith(`
|
|
519
|
+
`)?s.slice(0,-1):s;this._tab.doc.splice(d,0,c),this._tab.cur.row=d+1,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[c]},a,null),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(n=(e=this._config).onChange)==null||n.call(e,I(this._tab.doc)),(l=(o=this._config).onCursorChange)==null||l.call(o,{...this._tab.cur});return}this._insertStr(s,!1),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render()}}),this._editorEl.addEventListener("mousedown",()=>setTimeout(()=>this._focusInput(),0)),this._inputEl.addEventListener("focus",()=>{var t,s;return(s=(t=this._config).onFocus)==null?void 0:s.call(t)}),this._inputEl.addEventListener("blur",()=>{var t,s;return(s=(t=this._config).onBlur)==null?void 0:s.call(t)})}_onKeyDown(t){var o,l,a,d,c,p,h,b,m;const s=t.ctrlKey||t.metaKey,i=t.shiftKey,e=t.altKey,n=this._config.readOnly;if(this._hideHover(),this._acVisible()){if(t.key==="ArrowDown"){t.preventDefault(),this._acSel=Math.min(this._acItems.length-1,this._acSel+1),this._renderAcPopup();return}if(t.key==="ArrowUp"){t.preventDefault(),this._acSel=Math.max(0,this._acSel-1),this._renderAcPopup();return}if(t.key==="Tab"||t.key==="Enter"){t.preventDefault(),this._acAccept();return}if(t.key==="Escape"){this._acHide();return}}if(e&&(t.key==="z"||t.key==="Z"||t.key==="Ω")){t.preventDefault(),this._toggleWrap();return}if(s&&t.key==="z"&&!i){t.preventDefault(),n||this._doUndo();return}if(s&&(t.key==="y"||i&&t.key==="z")){t.preventDefault(),n||this._doRedo();return}if(s&&t.key==="a"){t.preventDefault(),this._selectAll();return}if(s&&t.key==="c"){t.preventDefault(),this._doCopy();return}if(s&&t.key==="x"){t.preventDefault(),n||this._doCut();return}if(s&&t.key==="f"){t.preventDefault(),this._config.find&&this._openFind(!1);return}if(s&&t.key==="h"){t.preventDefault(),this._config.find&&this._config.findReplace&&this._openFind(!0);return}if(s&&t.key==="g"){t.preventDefault(),this._config.goToLine&&this._openGoToLine();return}if(s&&t.key==="d"){t.preventDefault(),!n&&this._config.multiCursor&&this._ctrlD();return}if(s&&i&&t.key==="d"){t.preventDefault(),n||this._duplicateLine();return}if(s&&t.key==="/"){t.preventDefault(),n||this._toggleComment();return}if(s&&t.key==="k"){t.preventDefault(),n||this._deleteLine();return}if(s&&t.key==="Enter"){t.preventDefault(),n||(i?this._doInsertLineAbove():this._doInsertLineBelow());return}if(t.key==="Escape"){this._tab.sel=null,this._acHide(),this._closeFind(),this._closeGoToLine(),this._emmetTip.style.display="none",this._snippetTip.style.display="none",this._snippetExpanded=null,this._snippetSession=null,At(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(n){this._handleArrowKeys(t,s,i);return}if(t.key==="Tab"){if(t.preventDefault(),this._snippetSession){if(i){if(this._snippetSession.idx>0){this._snippetSession.idx--;const g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,L(this._tab),this._scrollIntoView(),this._render()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,L(this._tab),this._scrollIntoView(),this._render()}return}if(!i&&this._emmetAccept()||!i&&this._snippetAccept())return;i?this._unindentSel():this._indentSel(),L(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(t.key==="Backspace"){if(t.preventDefault(),this._extraCursors.length){this._snippetSession=null;const g=t.metaKey,k=t.altKey||t.ctrlKey,f=this._tab.doc.slice(),C={...this._tab.cur},_=this._tab.sel?{...this._tab.sel}:null,w=this._extraCursors.map(S=>({...S,sel:S.sel?{...S.sel}:null})),u=dt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,(S,x,R,P)=>{if(P){const j=A(P);return{fromRow:j.ar,fromCol:j.ac,toRow:j.fr,toCol:j.fc}}return g?R===0?null:{fromRow:x,fromCol:0,toRow:x,toCol:R}:k?R===0?x===0?null:{fromRow:x-1,fromCol:(S[x-1]??"").length,toRow:x,toCol:0}:{fromRow:x,fromCol:this._wordSkipLeft(S[x]??"",R),toRow:x,toCol:R}:R===0?x===0?null:{fromRow:x-1,fromCol:(S[x-1]??"").length,toRow:x,toCol:0}:{fromRow:x,fromCol:R-1,toRow:x,toCol:R}});this._tab.doc=u.doc,this._tab.cur.row=u.primaryRow,this._tab.cur.col=u.primaryCol,this._tab.sel=null,this._extraCursors=u.extraCursors,this._mc.cursors=u.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const y=lt(f,this._tab.doc);(y.oldLines.length||y.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:y.row,oldLines:y.oldLines,newLines:y.newLines},C,_,w,u.extraCursors)}else if(t.metaKey)this._snippetSession=null,this._deleteToLineStart();else if(t.altKey||t.ctrlKey)this._snippetSession=null,this._deleteWordLeft();else{if(this._snippetSession){const g=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===g.row&&this._tab.cur.col>g.col){for(let k=this._snippetSession.idx+1;k<this._snippetSession.stops.length;k++){const f=this._snippetSession.stops[k];f.row===g.row&&f.col>=this._tab.cur.col&&f.col--}g.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(l=(o=this._config).onChange)==null||l.call(o,I(this._tab.doc));return}if(t.key==="Delete"){if(t.preventDefault(),this._snippetSession=null,this._extraCursors.length){const g=t.metaKey,k=t.altKey||t.ctrlKey,f=this._tab.doc.slice(),C={...this._tab.cur},_=this._tab.sel?{...this._tab.sel}:null,w=this._extraCursors.map(S=>({...S,sel:S.sel?{...S.sel}:null})),u=dt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,(S,x,R,P)=>{if(P){const N=A(P);return{fromRow:N.ar,fromCol:N.ac,toRow:N.fr,toCol:N.fc}}const j=S[x]??"";return g?R>=j.length?null:{fromRow:x,fromCol:R,toRow:x,toCol:j.length}:k?R>=j.length?x>=S.length-1?null:{fromRow:x,fromCol:R,toRow:x+1,toCol:0}:{fromRow:x,fromCol:R,toRow:x,toCol:this._wordSkipRight(j,R)}:R<j.length?{fromRow:x,fromCol:R,toRow:x,toCol:R+1}:x<S.length-1?{fromRow:x,fromCol:R,toRow:x+1,toCol:0}:null});this._tab.doc=u.doc,this._tab.cur.row=u.primaryRow,this._tab.cur.col=u.primaryCol,this._tab.sel=null,this._extraCursors=u.extraCursors,this._mc.cursors=u.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const y=lt(f,this._tab.doc);(y.oldLines.length||y.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:y.row,oldLines:y.oldLines,newLines:y.newLines},C,_,w,u.extraCursors)}else t.metaKey?this._deleteToLineEnd():t.altKey||t.ctrlKey?this._deleteWordRight():this._doDelete();this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(d=(a=this._config).onChange)==null||d.call(a,I(this._tab.doc));return}if(t.key==="Enter"){t.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(p=(c=this._config).onChange)==null||p.call(c,I(this._tab.doc));return}if(!s&&!e&&this._config.autoClosePairs[t.key]){t.preventDefault();const g={...this._tab.cur},k=this._tab.sel?{...this._tab.sel}:null;let f,C;if(this._tab.sel){const y=A(this._tab.sel);f=y.ar,C=this._tab.doc.slice(y.ar,y.fr+1),this._tab.cur=O(this._tab)}else f=this._tab.cur.row,C=[this._tab.doc[f]??""];const{doc:_,cur:w}=this._tab,u=_[w.row]??"";_[w.row]=u.slice(0,w.col)+t.key+this._config.autoClosePairs[t.key]+u.slice(w.col),w.col++,this._tokenCache.invalidateLine(w.row,((h=this._wm.segments[w.row])==null?void 0:h.length)??1),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:f,oldLines:C,newLines:[_[w.row]]},g,k),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(m=(b=this._config).onChange)==null||m.call(b,I(this._tab.doc));return}if(!s&&!e&&Object.values(this._config.autoClosePairs).includes(t.key)){const{doc:g,cur:k}=this._tab;if((g[k.row]??"")[k.col]===t.key){t.preventDefault(),k.col++,L(this._tab),this._scrollIntoView(),this._render();return}}if(i&&e&&!s&&(t.key==="ArrowUp"||t.key==="ArrowDown")){t.preventDefault(),this._duplicateLines(t.key==="ArrowDown");return}if(e&&!s&&(t.key==="ArrowUp"||t.key==="ArrowDown")){t.preventDefault(),this._moveLines(t.key==="ArrowUp");return}this._handleArrowKeys(t,s,i)}_handleArrowKeys(t,s,i){var b,m,g,k,f,C;const{doc:e,cur:n}=this._tab,o=this._config.lineHeight,l=t.metaKey,a=t.ctrlKey,d=t.altKey,c=(_,w)=>{if(i){this._tab.sel||(this._tab.sel={ar:n.row,ac:n.col,fr:n.row,fc:n.col}),n.row=_,n.col=w;const u=this._tab.sel;u.fr=_,u.fc=w,u.ar===u.fr&&u.ac===u.fc&&(this._tab.sel=null)}else this._tab.sel=null,n.row=_,n.col=w},p=_=>{const u=(e[_]??"").search(/\S/);return u===-1||n.col===u?0:u},h=()=>({row:e.length-1,col:(e[e.length-1]??"").length});switch(t.key){case"ArrowRight":if(t.preventDefault(),this._tab.sel&&!i){const _=A(this._tab.sel);n.row=_.fr,n.col=_.fc,this._tab.sel=null;break}if(l)c(n.row,(e[n.row]??"").length);else if(a||d){const _=e[n.row]??"";if(n.col>=_.length)n.row<e.length-1&&c(n.row+1,0);else{const w=this._wordSkipRight(_,n.col);c(n.row,w)}}else n.col<(e[n.row]??"").length?c(n.row,n.col+1):n.row<e.length-1&&c(n.row+1,0);break;case"ArrowLeft":if(t.preventDefault(),this._tab.sel&&!i){const _=A(this._tab.sel);n.row=_.ar,n.col=_.ac,this._tab.sel=null;break}if(l)c(n.row,p(n.row));else if(a||d)if(n.col===0)n.row>0&&c(n.row-1,(e[n.row-1]??"").length);else{const _=this._wordSkipLeft(e[n.row]??"",n.col);c(n.row,_)}else n.col>0?c(n.row,n.col-1):n.row>0&&c(n.row-1,(e[n.row-1]??"").length);break;case"ArrowDown":if(t.preventDefault(),l){const _=h();c(_.row,_.col)}else if(this._config.wordWrap){const _=z(this._wm,n.row,n.col),w=this._wm.windowVisStart,u=Math.min(this._wm.totalVisualRows-1,_.visRow+1),y=et(this._wm,u,Math.min(_.colInSeg,(((b=this._wm.visualRows[u-w])==null?void 0:b.text)??"").length));c(y.row,y.col)}else{let _=Math.min(e.length-1,n.row+1);for(const[w,u]of this._foldedLines)if(_>w&&_<=u){_=Math.min(e.length-1,u+1);break}c(_,Math.min(n.col,(e[_]??"").length))}break;case"ArrowUp":if(t.preventDefault(),l)c(0,0);else if(this._config.wordWrap){const _=z(this._wm,n.row,n.col),w=this._wm.windowVisStart,u=Math.max(0,_.visRow-1),y=et(this._wm,u,Math.min(_.colInSeg,(((m=this._wm.visualRows[u-w])==null?void 0:m.text)??"").length));c(y.row,y.col)}else{let _=Math.max(0,n.row-1);for(const[w,u]of this._foldedLines)if(_>w&&_<=u){_=w;break}c(_,Math.min(n.col,(e[_]??"").length))}break;case"Home":t.preventDefault(),a?c(0,0):c(n.row,p(n.row));break;case"End":if(t.preventDefault(),a){const _=h();c(_.row,_.col)}else c(n.row,(e[n.row]??"").length);break;case"PageDown":t.preventDefault();{const _=Math.max(1,Math.floor(this._editorEl.clientHeight/o)-1),w=Math.min(e.length-1,n.row+_);c(w,Math.min(n.col,(e[w]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-o;break}case"PageUp":t.preventDefault();{const _=Math.max(1,Math.floor(this._editorEl.clientHeight/o)-1),w=Math.max(0,n.row-_);c(w,Math.min(n.col,(e[w]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-o;break}default:return}if(this._extraCursors.length){const _=(w,u)=>{const S=(e[w]??"").search(/\S/);return S===-1||u===S?0:S};this._extraCursors=this._extraCursors.map(w=>{let u=w.row,y=w.col;if(!i&&w.sel){const S=A(w.sel);if(t.key==="ArrowLeft")return{row:S.ar,col:S.ac,sel:null};if(t.key==="ArrowRight")return{row:S.fr,col:S.fc,sel:null};y=w.col}switch(t.key){case"ArrowRight":if(l)y=(e[u]??"").length;else if(a||d){const S=e[u]??"";y>=S.length?u<e.length-1&&(u++,y=0):y=this._wordSkipRight(S,y)}else y<(e[u]??"").length?y++:u<e.length-1&&(u++,y=0);break;case"ArrowLeft":l?y=_(u,y):a||d?y===0?u>0&&(u--,y=(e[u]??"").length):y=this._wordSkipLeft(e[u]??"",y):y>0?y--:u>0&&(u--,y=(e[u]??"").length);break;case"ArrowDown":l?(u=e.length-1,y=(e[u]??"").length):(u=Math.min(e.length-1,u+1),y=Math.min(w.col,(e[u]??"").length));break;case"ArrowUp":l?(u=0,y=0):(u=Math.max(0,u-1),y=Math.min(w.col,(e[u]??"").length));break;case"Home":a?(u=0,y=0):y=_(u,y);break;case"End":a&&(u=e.length-1),y=(e[u]??"").length;break}return y=Math.max(0,Math.min(y,(e[u]??"").length)),{row:u,col:y,sel:i?w.sel:null}}),this._extraCursors=this._extraCursors.filter(w=>!(w.row===this._tab.cur.row&&w.col===this._tab.cur.col)),this._mc.cursors=this._extraCursors}L(this._tab),this._scrollIntoView(),this._acHide(),(k=(g=this._config).onCursorChange)==null||k.call(g,{...this._tab.cur}),(C=(f=this._config).onSelectionChange)==null||C.call(f,this._tab.sel?{...this._tab.sel}:null),this._render()}_isWordChar(t){const s=this._config.wordSeparators;return s?t.trim()!==""&&!s.includes(t):/[\w$]/.test(t)}_wordStart(t,s){let i=s;for(;i>0&&this._isWordChar(t[i-1]);)i--;return i}_wordEnd(t,s){let i=s;for(;i<t.length&&this._isWordChar(t[i]);)i++;return i}_onInput(t){var n,o,l,a;if(this._config.readOnly){t.target.value="";return}const s=t.target,i=s.value;if(s.value="",!i||i==="Ω")return;const e=i.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(e){if(this._extraCursors.length){this._snippetSession=null;const d=this._tab.doc.slice(),c={...this._tab.cur},p=this._tab.sel?{...this._tab.sel}:null,h=this._extraCursors.map(_=>({..._,sel:_.sel?{..._.sel}:null}));let b=this._tab.doc,m=this._tab.cur.row,g=this._tab.cur.col,k=this._extraCursors;if(this._tab.sel||this._extraCursors.some(_=>_.sel)){const _=dt(b,m,g,this._tab.sel,k,(w,u,y,S)=>{if(!S)return null;const x=A(S);return{fromRow:x.ar,fromCol:x.ac,toRow:x.fr,toCol:x.fc}});b=_.doc,m=_.primaryRow,g=_.primaryCol,k=_.extraCursors,this._tab.sel=null,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1}const f=ue(b,m,g,k,e);this._tab.doc=f.doc,this._tab.cur.row=f.primaryRow,this._tab.cur.col=f.primaryCol,this._extraCursors=f.extraCursors,this._mc.cursors=f.extraCursors,this._tab.dirty=!0;const C=lt(d,this._tab.doc);(C.oldLines.length||C.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:C.row,oldLines:C.oldLines,newLines:C.newLines},c,p,h,this._extraCursors),(o=(n=this._config).onChange)==null||o.call(n,I(this._tab.doc))}else{const d=this._tab.cur.row,c=this._tab.cur.col;if(this._insertStr(e,!0),this._snippetSession){const p=this._snippetSession,h=p.stops[p.idx];if(this._tab.cur.row===h.row){const b=this._tab.cur.col-c;for(let m=p.idx+1;m<p.stops.length;m++){const g=p.stops[m];g.row===d&&g.col>=c&&(g.col+=b)}h.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(a=(l=this._config).onCursorChange)==null||a.call(l,{...this._tab.cur})}}_bindMinimapEvents(){const t=this._minimapWrap;t.addEventListener("mousemove",s=>{if(this._mmDragMode!=="none")return;const i=s.clientY-t.getBoundingClientRect().top,{sliderTop:e,sliderHeight:n}=pt(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,t.clientHeight,this._config.lineHeight);t.style.cursor=i>=e&&i<=e+n?"grab":"pointer"}),t.addEventListener("mousedown",s=>{s.preventDefault();const i=t.clientHeight,e=s.clientY-t.getBoundingClientRect().top,{sliderTop:n,sliderHeight:o}=pt(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);if(e>=n&&e<=n+o)this._mmDragMode="slider",this._mmSliderOffset=e-n,this._mmDragStartY=s.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,t.style.cursor="grabbing";else{this._mmDragMode="jump";const l=_e(e,this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=this._domScroll(l),this._mmDragStartY=s.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}class Yt extends ri{getValue(){return I(this._tab.doc)}setValue(t){var o,l;const s={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null,e=[...this._tab.doc];this._tab.doc=Mt(t),this._tab.cur={row:0,col:0},this._tab.sel=null;const n=[...this._tab.doc];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:e,newLines:n},s,i),this._tokenCache.clear(),this._foldedLines.clear(),this._rebuildWrapMap(),this._render(),(l=(o=this._config).onChange)==null||l.call(o,t)}getCursor(){return{...this._tab.cur}}setCursor(t){this._tab.cur={...t},L(this._tab),this._scrollIntoView(),this._render()}getSelection(){return this._tab.sel?{...this._tab.sel}:null}setSelection(t){this._tab.sel=t,this._render()}insertText(t){this._config.readOnly||(this._insertStr(t,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render())}setTheme(t){this._applyTheme(t)}updateConfig(t){const s=qt(t);if(s.autoClosePairs!==void 0){const i=s.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:e,...n}=s;Object.assign(this._config,n)}else Object.assign(this._config,s);if(s.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!s.readOnly)),t.theme!==void 0&&this.setTheme(t.theme),(t.wordWrap!==void 0||t.wrapColumn!==void 0)&&this._rebuildWrapMap(),t.showMinimap!==void 0){const i=this._shadow.querySelector(".sl-layout");t.showMinimap?i.contains(this._minimapWrap)||i.appendChild(this._minimapWrap):this._minimapWrap.remove()}t.showStatusBar!==void 0&&(t.showStatusBar?this._shadow.contains(this._statusBar)||this._shadow.appendChild(this._statusBar):this._statusBar.remove()),(t.fontFamily!==void 0||t.fontSize!==void 0||t.lineHeight!==void 0||t.cursorBlinkRate!==void 0||t.cursorStyle!==void 0||t.gutterWidth!==void 0||t.minimapWidth!==void 0||t.showGutter!==void 0||t.tokenColors!==void 0)&&this._applyDynamicStyles(),(t.language!==void 0||t.extraKeywords!==void 0||t.extraTypes!==void 0||t.renderWhitespace!==void 0||t.completions!==void 0||t.provideTokens!==void 0)&&this._tokenCache.clear(),t.find===!1?this._closeFind():t.findReplace===!1&&(this._replaceRow.style.display="none"),t.goToLine===!1&&this._closeGoToLine(),t.placeholder!==void 0&&(this._placeholderEl.textContent=t.placeholder),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(t){this._themeManager.register(t)}undo(){this._doUndo()}redo(){this._doRedo()}executeCommand(t){const s=this._config.readOnly;switch(t){case"undo":s||this.undo();break;case"redo":s||this.redo();break;case"selectAll":this._selectAll();break;case"copy":this._doCopy();break;case"cut":s||this._doCut();break;case"toggleComment":s||this._toggleComment();break;case"duplicateLine":s||this._duplicateLine();break;case"deleteLine":s||this._deleteLine();break;case"toggleWordWrap":this._toggleWrap();break;case"find":this._config.find&&this._openFind(!1);break;case"findReplace":this._config.find&&this._config.findReplace&&this._openFind(!0);break;case"indentLine":s||this._indentSel();break;case"outdentLine":s||this._unindentSel();break;default:console.warn(`[syncline-editor] executeCommand: unknown command "${t}"`);break}}destroy(){this._destroyBase()}}function oi(r,t){return new Yt(r,t)}D.BUILT_IN_THEMES=Kt,D.SynclineEditor=Yt,D.THEME_DRACULA=Ut,D.THEME_GITHUB_LIGHT=Ft,D.THEME_MDX_DARK=zt,D.THEME_MDX_LIGHT=Vt,D.THEME_MONOKAI=Ot,D.THEME_SOLARIZED_LIGHT=Gt,D.THEME_VR_DARK=$t,D.THEME_VSCODE_DARK=Nt,D.createEditor=oi,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
|
515
520
|
//# sourceMappingURL=syncline-editor.umd.js.map
|