@synclineapi/editor 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -274
- package/package.json +1 -1
- package/dist/syncline-editor.es.js +0 -5293
- package/dist/syncline-editor.es.js.map +0 -1
- package/dist/syncline-editor.umd.js +0 -569
- package/dist/syncline-editor.umd.js.map +0 -1
- package/dist/types/index.d.ts +0 -1596
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
(function(C,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(C=typeof globalThis<"u"?globalThis:C||self,D(C.SynclineEditor={}))})(this,function(C){"use strict";var Ri=Object.defineProperty;var Bi=(C,D,O)=>D in C?Ri(C,D,{enumerable:!0,configurable:!0,writable:!0,value:O}):C[D]=O;var p=(C,D,O)=>Bi(C,typeof D!="symbol"?D+"":D,O);const D=Object.freeze({site:"\0root",clock:0});function O(r){return`${r.site}@${r.clock}`}function de(r,e){return r.site===e.site&&r.clock===e.clock}function he(r){return Object.fromEntries(r)}function Ee(r){return new Map(Object.entries(r))}class ae{constructor(e){p(this,"_chars",new Map);p(this,"_seq",[]);p(this,"_idxDirty",!1);p(this,"_idxMap",new Map);p(this,"siteId");p(this,"_clock",0);p(this,"stateVector",new Map);p(this,"_opLog",[]);this.siteId=e;const t={id:D,after:D,char:"",deleted:!0};this._chars.set(O(D),t),this._seq=[D],this._rebuildIdx()}get clock(){return this._clock}getText(){let e="";for(const t of this._seq){const i=this._chars.get(O(t));i.deleted||(e+=i.char)}return e}get length(){let e=0;for(const t of this._seq)this._chars.get(O(t)).deleted||e++;return e}localInsert(e,t){const i=[];let s=this._visibleIdAt(e-1);for(const n of t){const o=this._genId(),a={type:"insert",id:o,after:s,char:n};this._applyInsert(a,!0),this._opLog.push(a),i.push(a),s=o}return i}localDelete(e,t){const i=this._visibleIdsInRange(e,t),s=[];for(const n of i){const o={type:"delete",id:n};this._applyDelete(o,!0),this._opLog.push(o),s.push(o)}return s}apply(e){const t=O(e.id);if(e.type==="insert"){if(this._chars.has(t))return!1;this._applyInsert(e,!1)}else{const i=this._chars.get(t);if(!i||i.deleted)return!1;this._applyDelete(e,!1)}return this._opLog.push(e),this._updateSV(e.id),!0}getOpsSince(e){return this._opLog.filter(t=>(e.get(t.id.site)??0)<t.id.clock)}getStateVector(){return new Map(this.stateVector)}serialize(){return{siteId:this.siteId,clock:this._clock,ops:[...this._opLog]}}static deserialize(e){const t=new ae(e.siteId);t._clock=e.clock;for(const i of e.ops)t.apply(i);return t}_genId(){return{site:this.siteId,clock:++this._clock}}_updateSV(e){const t=this.stateVector.get(e.site)??0;e.clock>t&&this.stateVector.set(e.site,e.clock),e.clock>=this._clock&&(this._clock=e.clock+1)}_applyInsert(e,t){t&&this._updateSV(e.id);const i={id:e.id,after:e.after,char:e.char,deleted:!1};this._chars.set(O(e.id),i);const s=O(e.after);this._idxDirty&&this._rebuildIdx();let n=(this._idxMap.get(s)??0)+1;for(;n<this._seq.length;){const o=this._seq[n],a=this._chars.get(O(o));if(!de(a.after,e.after))break;if(this._cmp(o,e.id)>0){n++;continue}break}this._seq.splice(n,0,e.id),this._idxDirty=!0}_applyDelete(e,t){t&&this._updateSV(e.id);const i=this._chars.get(O(e.id));i&&(i.deleted=!0)}_cmp(e,t){return e.clock!==t.clock?e.clock-t.clock:e.site<t.site?1:e.site>t.site?-1:0}_rebuildIdx(){this._idxMap.clear();for(let e=0;e<this._seq.length;e++)this._idxMap.set(O(this._seq[e]),e);this._idxDirty=!1}_visibleIdAt(e){if(e<0)return D;let t=0;for(const s of this._seq)if(!(this._chars.get(O(s)).deleted||de(s,D))){if(t===e)return s;t++}let i=D;for(const s of this._seq)this._chars.get(O(s)).deleted||(i=s);return i}_visibleIdsInRange(e,t){const i=[];let s=0;for(const n of this._seq){if(i.length>=t)break;this._chars.get(O(n)).deleted||de(n,D)||(s>=e&&i.push(n),s++)}return i}}function Ie(r,e){if(r===e)return[];if(r.length===0)return[{type:"insert",offset:0,chars:e}];if(e.length===0)return[{type:"delete",offset:0,chars:r}];let t=0;const i=Math.min(r.length,e.length);for(;t<i&&r[t]===e[t];)t++;let s=0;for(;s<r.length-t&&s<e.length-t&&r[r.length-1-s]===e[e.length-1-s];)s++;const n=r.slice(t,r.length-s),o=e.slice(t,e.length-s),a=[];return n.length>0&&a.push({type:"delete",offset:t,chars:n}),o.length>0&&a.push({type:"insert",offset:t,chars:o}),a}const Le=1e4,vt=3e3,Re=["#e06c75","#98c379","#e5c07b","#61afef","#c678dd","#56b6c2","#d19a66","#be5046"];function Be(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return Re[e%Re.length]}class Ae{constructor(e,t){p(this,"_local");p(this,"_peers",new Map);p(this,"_transport");p(this,"_unsub",null);p(this,"_heartbeat",null);p(this,"_gcTimer",null);p(this,"_onChange",null);this._transport=e,this._local={siteId:e.siteId,name:t,color:Be(e.siteId),cursor:null,selection:null,updatedAt:Date.now()},this._unsub=e.onMessage(i=>{var n;if(i.type!=="awareness")return;const s=i.state;s.siteId!==e.siteId&&(this._peers.set(s.siteId,s),(n=this._onChange)==null||n.call(this,this._peers))}),this._heartbeat=setInterval(()=>this._broadcast(),vt),this._gcTimer=setInterval(()=>{var n;const i=Date.now();let s=!1;for(const[o,a]of this._peers)i-a.updatedAt>Le&&(this._peers.delete(o),s=!0);s&&((n=this._onChange)==null||n.call(this,this._peers))},Le)}updateCursor(e,t){this._local={...this._local,cursor:{row:e,col:t},updatedAt:Date.now()},this._broadcast()}updateSelection(e,t){this._local={...this._local,selection:{from:e,to:t},updatedAt:Date.now()},this._broadcast()}clearSelection(){this._local={...this._local,selection:null,updatedAt:Date.now()},this._broadcast()}get localState(){return this._local}get peers(){return this._peers}onChange(e){this._onChange=e}broadcast(){this._broadcast()}_broadcast(){this._transport.send({type:"awareness",state:{...this._local,updatedAt:Date.now()}})}destroy(){var e;(e=this._unsub)==null||e.call(this),this._heartbeat&&clearInterval(this._heartbeat),this._gcTimer&&clearInterval(this._gcTimer)}}class fe{constructor(e,t,i,s={}){p(this,"doc");p(this,"awareness");p(this,"_editor");p(this,"_transport");p(this,"_unsub");p(this,"_lastText");p(this,"_suppress",!1);if(this._editor=e,this.doc=t,this._transport=i,this._lastText=e.getValue(),this._lastText){const n=t.localInsert(0,this._lastText);i.send({type:"ops",fromSite:i.siteId,ops:n,sv:he(t.stateVector)})}this.awareness=new Ae(i,s.name??"Peer"),this.awareness.onChange(n=>{var o;return(o=s.onPeersChange)==null?void 0:o.call(s,n)}),e.updateConfig({onChange:n=>this._onEditorChange(n)}),this._unsub=i.onMessage(n=>this._onMessage(n)),i.send({type:"sync-request",fromSite:i.siteId,sv:he(t.stateVector)}),this.awareness.broadcast()}_onEditorChange(e){if(this._suppress)return;const t=this._lastText;this._lastText=e;const i=Ie(t,e);if(i.length===0)return;const s=[],n=i.filter(a=>a.type==="delete"),o=i.filter(a=>a.type==="insert");for(const a of[...n].reverse())s.push(...this.doc.localDelete(a.offset,a.chars.length));for(const a of o)s.push(...this.doc.localInsert(a.offset,a.chars));s.length>0&&this._transport.send({type:"ops",fromSite:this._transport.siteId,ops:s,sv:he(this.doc.stateVector)})}_onMessage(e){if(e.type==="ops")this._applyRemoteOps(e.ops);else if(e.type==="sync-request"){const t=Ee(e.sv),i=this.doc.getOpsSince(t);i.length>0&&this._transport.send({type:"sync-reply",fromSite:this._transport.siteId,ops:i})}else e.type==="sync-reply"&&this._applyRemoteOps(e.ops)}_applyRemoteOps(e){let t=!1;for(const s of e)this.doc.apply(s)&&(t=!0);if(!t)return;const i=this.doc.getText();i!==this._lastText&&(this._suppress=!0,this._lastText=i,this._editor.setValue(i),this._suppress=!1)}destroy(){this._unsub(),this.awareness.destroy()}}const wt=22,De=6,je=300,kt=60,ie=14,He=20,Q=7.82,xt=13,Ct=2,Tt=80,V=2,Y=1.1,le=3,St=120,Mt=700,Et=120,It={typescript:"//",javascript:"//",css:"//",json:"",markdown:"",text:""},ge=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"]),Lt=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"]),Rt=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"]),Bt=new Set(["null","true","false"]),Pe=new Set,be=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"]),At=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),Dt=new Set,jt=new Set,$e=new Set,We={typescript:ge,javascript:Lt,css:Rt,json:Bt,markdown:Pe,text:Pe},Oe={typescript:be,javascript:At,css:Dt,json:jt,markdown:$e,text:$e};function Ne(r,e){return{fileId:r,doc:[...e],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function j(r,e=je){const t={doc:[...r.doc],cur:{...r.cur},sel:r.sel?{...r.sel}:null};r.undoStack.push(t),r.undoStack.length>e&&r.undoStack.shift(),r.redoStack=[],r.dirty=!0}function Ht(r){if(!r.undoStack.length)return!1;const e={doc:[...r.doc],cur:{...r.cur},sel:r.sel?{...r.sel}:null};r.redoStack.push(e);const t=r.undoStack.pop();return r.doc=t.doc,r.cur=t.cur,r.sel=t.sel,!0}function Pt(r){if(!r.redoStack.length)return!1;const e={doc:[...r.doc],cur:{...r.cur},sel:r.sel?{...r.sel}:null};r.undoStack.push(e);const t=r.redoStack.pop();return r.doc=t.doc,r.cur=t.cur,r.sel=t.sel,!0}function A(r){const{doc:e,cur:t}=r;t.row=Math.max(0,Math.min(e.length-1,t.row)),t.col=Math.max(0,Math.min((e[t.row]??"").length,t.col))}function J(r){const{ar:e,ac:t,fr:i,fc:s}=r;return e<i||e===i&&t<=s?r:{ar:i,ac:s,fr:e,fc:t}}function Fe(r,e,t){if(!r)return null;const i=J(r);return e<i.ar||e>i.fr?null:{start:e===i.ar?i.ac:0,end:e===i.fr?i.fc:t}}function $t(r){if(!r.sel)return 0;const e=J(r.sel);let t=0;for(let i=e.ar;i<=e.fr;i++){const s=r.doc[i]??"",n=i===e.ar?e.ac:0,o=i===e.fr?e.fc:s.length;t+=o-n}return t}function Ue(r){if(!r.sel)return"";const e=J(r.sel),t=[];for(let i=e.ar;i<=e.fr;i++){const s=r.doc[i]??"";t.push(s.slice(i===e.ar?e.ac:0,i===e.fr?e.fc:s.length))}return t.join(`
|
|
2
|
-
`)}function oe(r){const e=r.sel;if(!e)return r.cur;const t=J(e),i=(r.doc[t.ar]??"").slice(0,t.ac),s=(r.doc[t.fr]??"").slice(t.fc);return r.doc.splice(t.ar,t.fr-t.ar+1,i+s),r.sel=null,{row:t.ar,col:t.ac}}function Wt(r,e,t){if(!t||r.length<=e)return[r];const i=[];let s=0;for(;s<r.length;){if(r.length-s<=e){i.push(r.slice(s));break}const n=s+e;let o=-1;for(let a=n;a>s;a--)if(r[a-1]===" "){o=a;break}o===-1?(i.push(r.slice(s,n)),s=n):(i.push(r.slice(s,o)),s=o)}return i}function Ot(r,e,t,i){const s=[],n=[],o=[];let a=-1;for(let l=0;l<r.length;l++){if(l>0&&l<=a){o.push(n.length),s.push([r[l]??""]);continue}o.push(n.length);const c=Wt(r[l]??"",e,t);s.push(c),c.forEach((d,u)=>n.push({docLine:l,segIdx:u,text:d})),i.has(l)&&(a=i.get(l))}return{segments:s,visualRows:n,docToVisArr:o}}function ee(r,e,t){const i=r.segments[e]??[""];let s=t;for(let n=0;n<i.length;n++){if(s<=i[n].length||n===i.length-1)return{visRow:r.docToVisArr[e]+n,colInSeg:Math.min(s,i[n].length)};s-=i[n].length}return{visRow:r.docToVisArr[e]??0,colInSeg:0}}function pe(r,e,t){var o;const i=r.visualRows[e];if(!i)return{row:0,col:0};const s=r.segments[i.docLine]??[""];let n=Math.min(t,((o=s[i.segIdx])==null?void 0:o.length)??0);for(let a=0;a<i.segIdx;a++)n+=s[a].length;return{row:i.docLine,col:n}}function _e(r,e={}){var d,u;const t=[],i=r.length;let s=0;const n=(h,_,y)=>{y>_&&t.push({cls:h,start:_,end:y})},o=We[e.language??"typescript"]??ge,a=Oe[e.language??"typescript"]??be,l=(d=e.extraKeywords)!=null&&d.size?new Set([...o,...e.extraKeywords]):o,c=(u=e.extraTypes)!=null&&u.size?new Set([...a,...e.extraTypes]):a;for(;s<i;){if(r[s]==="/"&&r[s+1]==="/"){n("cmt",s,i);break}if(r[s]==="*"||r[s]==="/"&&r[s+1]==="*"){n("cmt",s,i);break}if(r[s]==="@"){let h=s+1;for(;h<i&&/\w/.test(r[h]);)h++;n("dec",s,h),s=h;continue}if(r[s]==='"'||r[s]==="'"||r[s]==="`"){const h=r[s];let _=s+1;for(;_<i;){if(r[_]==="\\"){_+=2;continue}if(r[_]===h){_++;break}_++}n("str",s,_),s=_;continue}if(/\d/.test(r[s])&&(s===0||!/\w/.test(r[s-1]))){let h=s;for(;h<i&&/[\d._xXa-fA-F]/.test(r[h]);)h++;n("num",s,h),s=h;continue}if(/[a-zA-Z_$]/.test(r[s])){let h=s;for(;h<i&&/[\w$]/.test(r[h]);)h++;const _=r.slice(s,h);l.has(_)?n("kw",s,h):c.has(_)?n("typ",s,h):h<i&&r[h]==="("?n("fn",s,h):/^[A-Z]/.test(_)&&n("cls",s,h),s=h;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(r[s])){n("op",s,s+1),s++;continue}s++}return t}function ze(r,e){const t=new Array(r.length).fill("");for(const i of e)for(let s=i.start;s<i.end;s++)t[s]=i.cls;return t}class Nt{constructor(e=5e3){p(this,"_cache",new Map);p(this,"_maxSize");p(this,"_hits",0);p(this,"_misses",0);p(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 qe={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"}},Ge={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"}},Ve={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"}},Ke={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"}},Ye={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"}},Je={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"}},Xe=[qe,Ge,Ve,Ke,Ye,Je,{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"}},{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"}}],Ft={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 Ut{constructor(e){p(this,"_registry",new Map);p(this,"_activeId","");p(this,"_root");this._root=e;for(const t of Xe)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,s]of Object.entries(Ft))t.setProperty(s,e[i])}}const zt=`
|
|
3
|
-
/* ── Reset ── */
|
|
4
|
-
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
5
|
-
|
|
6
|
-
/* ── Host element ── */
|
|
7
|
-
:host,.sl-host{
|
|
8
|
-
display:flex;flex-direction:column;
|
|
9
|
-
height:100%;overflow:hidden;
|
|
10
|
-
font-family:var(--sans,'Geist',system-ui,sans-serif);
|
|
11
|
-
color:var(--text,#c9c7c0);
|
|
12
|
-
background:var(--bg0,#0d0d0f);
|
|
13
|
-
|
|
14
|
-
/* Default token vars (can be overridden by theme) */
|
|
15
|
-
--sans:'Geist',system-ui,sans-serif;
|
|
16
|
-
--mono:'JetBrains Mono',monospace;
|
|
17
|
-
|
|
18
|
-
/* ── VR Dark defaults ── */
|
|
19
|
-
--bg0:#0d0d0f; --bg1:#111115; --bg2:#16161b; --bg3:#1d1d24; --bg4:#24242d;
|
|
20
|
-
--border:rgba(255,255,255,.07);
|
|
21
|
-
--border2:rgba(255,255,255,.12);
|
|
22
|
-
--border3:rgba(255,255,255,.19);
|
|
23
|
-
--text:#c9c7c0; --text2:#8b8994; --text3:#4e4c58;
|
|
24
|
-
--accent:#6e9fff; --accent2:#2f5db0;
|
|
25
|
-
--green:#4ec9a0; --orange:#d4976e; --purple:#b48eff;
|
|
26
|
-
--red:#f28b82; --yellow:#e8c97a;
|
|
27
|
-
--cur:#6e9fff; --cur-glow:rgba(110,159,255,.65);
|
|
28
|
-
--cur-line-bg:rgba(255,255,255,.032);
|
|
29
|
-
--cur-line-gutter:#181820;
|
|
30
|
-
--gutter-bg:#0f0f12; --gutter-hover:#181820;
|
|
31
|
-
--gutter-border:rgba(255,255,255,.06);
|
|
32
|
-
--gutter-num:#4e4c58; --gutter-num-act:#9997a2;
|
|
33
|
-
--sel-bg:rgba(110,159,255,.22);
|
|
34
|
-
--word-hl-bg:rgba(200,198,210,.09);
|
|
35
|
-
--word-hl-border:rgba(200,198,210,.28);
|
|
36
|
-
--bm-border:rgba(110,159,255,.65);
|
|
37
|
-
--fold-bg:rgba(110,159,255,.07);
|
|
38
|
-
--fold-border:rgba(110,159,255,.30);
|
|
39
|
-
--find-bg:rgba(234,180,86,.18);
|
|
40
|
-
--find-border:rgba(234,180,86,.50);
|
|
41
|
-
--find-cur-bg:rgba(234,180,86,.80);
|
|
42
|
-
--find-cur-border:rgba(234,180,86,.95);
|
|
43
|
-
--find-cur-text:#1a1000;
|
|
44
|
-
--file-active-bg:rgba(110,159,255,.11);
|
|
45
|
-
--file-active-text:#6e9fff;
|
|
46
|
-
--mm-bg:#0d0d0f; --mm-slider:rgba(255,255,255,.07);
|
|
47
|
-
--mm-dim:rgba(0,0,0,.30); --mm-edge:rgba(255,255,255,.18);
|
|
48
|
-
--indent-guide:rgba(255,255,255,.06);
|
|
49
|
-
--tok-kw:#6e9fff; --tok-str:#4ec9a0; --tok-cmt:#4e4c58;
|
|
50
|
-
--tok-fn:#d4976e; --tok-num:#b48eff; --tok-cls:#e8c97a;
|
|
51
|
-
--tok-op:#55536a; --tok-typ:#6ec9d4; --tok-dec:#f28b82;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* ── Layout ── */
|
|
55
|
-
.sl-layout{display:flex;flex:1;overflow:hidden}
|
|
56
|
-
.sl-ed-pane{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative;background:var(--bg2)}
|
|
57
|
-
|
|
58
|
-
/* ── Hidden textarea (input capture) ── */
|
|
59
|
-
.sl-input{position:fixed;left:-9999px;top:0;width:200px;height:40px;
|
|
60
|
-
opacity:0;resize:none;border:none;outline:none;padding:0;margin:0;
|
|
61
|
-
font-size:16px;background:transparent;color:transparent;
|
|
62
|
-
caret-color:transparent;pointer-events:none}
|
|
63
|
-
|
|
64
|
-
/* ── Editor scroll container ── */
|
|
65
|
-
.sl-editor{flex:1;overflow-y:scroll;overflow-x:auto;position:relative;
|
|
66
|
-
cursor:text;scrollbar-width:thin;scrollbar-color:var(--border3) transparent}
|
|
67
|
-
.sl-editor::-webkit-scrollbar{width:10px;height:8px}
|
|
68
|
-
.sl-editor::-webkit-scrollbar-track{background:transparent}
|
|
69
|
-
.sl-editor::-webkit-scrollbar-thumb{background:var(--border3);border-radius:5px;border:2px solid var(--bg2)}
|
|
70
|
-
.sl-spacer{position:absolute;left:0;top:0;width:1px;pointer-events:none}
|
|
71
|
-
/* overflow-x:clip clips horizontal overflow without creating a scroll container.
|
|
72
|
-
* Unlike overflow-x:hidden, it does NOT force overflow-y from visible→auto,
|
|
73
|
-
* so absolutely-positioned children (remote cursor name labels) that extend
|
|
74
|
-
* above their row are never clipped on the Y axis. */
|
|
75
|
-
.sl-vp{position:absolute;left:0;right:0;overflow-x:clip;overflow-y:visible;will-change:transform}
|
|
76
|
-
|
|
77
|
-
/* ── Editor row ── */
|
|
78
|
-
.sl-er{display:flex;align-items:stretch;position:relative}
|
|
79
|
-
.sl-er:hover .sl-eg{background:var(--gutter-hover)}
|
|
80
|
-
.sl-er.sl-cur-row{background:var(--cur-line-bg)}
|
|
81
|
-
.sl-er.sl-cur-row .sl-eg{background:var(--cur-line-gutter)!important}
|
|
82
|
-
.sl-eg{min-width:60px;font-family:var(--mono);font-size:11px;color:var(--gutter-num);
|
|
83
|
-
user-select:none;border-right:1px solid var(--gutter-border);
|
|
84
|
-
background:var(--gutter-bg);flex-shrink:0;position:sticky;left:0;z-index:2;
|
|
85
|
-
display:flex;flex-direction:column;justify-content:flex-start;
|
|
86
|
-
transition:background .12s,color .12s}
|
|
87
|
-
.sl-er.sl-cur-row .sl-eg{color:var(--gutter-num-act)}
|
|
88
|
-
.sl-egn{height:22px;line-height:22px;padding-right:10px;text-align:right;display:block}
|
|
89
|
-
.sl-er.sl-wrap-cont .sl-egn{visibility:hidden}
|
|
90
|
-
.sl-el{flex:1;font-family:var(--mono);font-size:13px;line-height:22px;
|
|
91
|
-
color:var(--text);position:relative;min-width:0}
|
|
92
|
-
.sl-cl{display:block;height:22px;line-height:22px;
|
|
93
|
-
padding:0 20px 0 14px;white-space:pre;position:relative}
|
|
94
|
-
.sl-wrap-mode .sl-cl{white-space:pre-wrap;word-break:break-all;height:auto;overflow-wrap:anywhere}
|
|
95
|
-
|
|
96
|
-
/* ── Cursor ── */
|
|
97
|
-
.sl-cur{display:inline;width:0;height:0;position:relative}
|
|
98
|
-
.sl-cur::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
99
|
-
background:var(--cur);border-radius:1px;
|
|
100
|
-
box-shadow:0 0 8px var(--cur-glow);
|
|
101
|
-
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
102
|
-
@keyframes sl-blink{0%,100%{opacity:1}45%,55%{opacity:0}}
|
|
103
|
-
|
|
104
|
-
/* ── Multi-cursor extra beams ── */
|
|
105
|
-
.sl-cur-extra{display:inline;width:0;height:0;position:relative}
|
|
106
|
-
.sl-cur-extra::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
107
|
-
background:var(--cur);border-radius:1px;
|
|
108
|
-
box-shadow:0 0 8px var(--cur-glow);
|
|
109
|
-
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
110
|
-
|
|
111
|
-
/* ── Snippet tab-stop ghost markers ── */
|
|
112
|
-
.sl-snip-stop{display:inline;width:0;height:0;position:relative}
|
|
113
|
-
.sl-snip-stop::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
114
|
-
background:var(--cur);border-radius:1px;opacity:0.28;pointer-events:none}
|
|
115
|
-
|
|
116
|
-
/* ── Remote peer cursors ── */
|
|
117
|
-
/*
|
|
118
|
-
* Architecture:
|
|
119
|
-
* .sl-rc — zero-size inline anchor; creates relative-positioning context
|
|
120
|
-
* .sl-rc::after — the 2 px tall vertical beam (full line height, like local cursor)
|
|
121
|
-
* .sl-rc-label — name chip anchored at beam-top, translated up by its own height
|
|
122
|
-
* so it always floats ABOVE the current row regardless of font/line-height.
|
|
123
|
-
* .sl-rc-label::after — tiny downward triangle connecting label to beam
|
|
124
|
-
*/
|
|
125
|
-
.sl-rc{display:inline;width:0;height:0;position:relative}
|
|
126
|
-
/* Full-height coloured beam */
|
|
127
|
-
.sl-rc::after{
|
|
128
|
-
content:'';position:absolute;left:0;top:1px;
|
|
129
|
-
width:2px;height:20px;
|
|
130
|
-
background:var(--rc-color,#e06c75);border-radius:1px;
|
|
131
|
-
pointer-events:none;z-index:3;
|
|
132
|
-
box-shadow:0 0 6px color-mix(in srgb,var(--rc-color,#e06c75) 55%,transparent)}
|
|
133
|
-
/* Name label — sits at beam-top then transforms up by its own height */
|
|
134
|
-
.sl-rc-label{
|
|
135
|
-
position:absolute;top:1px;left:2px;
|
|
136
|
-
transform:translateY(-100%);
|
|
137
|
-
background:var(--rc-color,#e06c75);color:#fff;
|
|
138
|
-
font-size:10px;padding:1px 6px;
|
|
139
|
-
border-radius:3px 3px 3px 0;white-space:nowrap;
|
|
140
|
-
pointer-events:none;opacity:0.93;
|
|
141
|
-
font-family:var(--mono);line-height:1.5;
|
|
142
|
-
z-index:10;
|
|
143
|
-
box-shadow:0 1px 5px rgba(0,0,0,.35);
|
|
144
|
-
/* Small downward-pointing triangle connecting label to beam */
|
|
145
|
-
}
|
|
146
|
-
.sl-rc-label::after{
|
|
147
|
-
content:'';position:absolute;bottom:-4px;left:0;
|
|
148
|
-
width:0;height:0;
|
|
149
|
-
border-left:4px solid transparent;
|
|
150
|
-
border-right:4px solid transparent;
|
|
151
|
-
border-top:4px solid var(--rc-color,#e06c75);
|
|
152
|
-
}
|
|
153
|
-
/* Flipped variant: label below the cursor beam (used on the first visible row
|
|
154
|
-
so the label is never clipped by the scroll container's overflow). */
|
|
155
|
-
.sl-rc-flip .sl-rc-label{
|
|
156
|
-
top:auto;bottom:1px;
|
|
157
|
-
transform:translateY(100%);
|
|
158
|
-
border-radius:0 3px 3px 3px}
|
|
159
|
-
.sl-rc-flip .sl-rc-label::after{
|
|
160
|
-
bottom:auto;top:-4px;
|
|
161
|
-
border-top:none;
|
|
162
|
-
border-bottom:4px solid var(--rc-color,#e06c75)}
|
|
163
|
-
/* Remote peer selection highlight — semi-transparent coloured fill */
|
|
164
|
-
.sl-rs{border-radius:2px;background:var(--rs-color,rgba(224,108,117,0.28))}
|
|
165
|
-
|
|
166
|
-
/* ── Overlays ── */
|
|
167
|
-
.sl-sh{background:var(--sel-bg);border-radius:2px}
|
|
168
|
-
.sl-fh{background:var(--find-bg);box-shadow:0 0 0 1px var(--find-border);border-radius:2px}
|
|
169
|
-
.sl-fh.sl-fh-cur{background:var(--find-cur-bg);box-shadow:0 0 0 1px var(--find-cur-border);color:var(--find-cur-text)}
|
|
170
|
-
.sl-wh{background:var(--word-hl-bg);box-shadow:0 0 0 1px var(--word-hl-border);border-radius:2px}
|
|
171
|
-
.sl-bm{box-shadow:0 0 0 1px var(--bm-border);border-radius:2px}
|
|
172
|
-
.sl-ig{position:absolute;top:0;bottom:0;width:1px;background:var(--indent-guide);pointer-events:none}
|
|
173
|
-
|
|
174
|
-
/* ── Code folding ── */
|
|
175
|
-
.sl-fold-btn{position:absolute;left:3px;top:4px;width:13px;height:13px;border-radius:3px;
|
|
176
|
-
display:flex;align-items:center;justify-content:center;font-size:9px;
|
|
177
|
-
color:var(--gutter-num);cursor:pointer;opacity:0;
|
|
178
|
-
transition:opacity .15s,background .1s;user-select:none;line-height:1}
|
|
179
|
-
.sl-er:hover .sl-fold-btn{opacity:1}
|
|
180
|
-
.sl-fold-btn:hover{background:var(--border3);color:var(--gutter-num-act)}
|
|
181
|
-
.sl-folded{background:var(--fold-bg);border-bottom:1px dashed var(--fold-border)}
|
|
182
|
-
|
|
183
|
-
/* ── Syntax tokens ── */
|
|
184
|
-
.kw{color:var(--tok-kw)}.str{color:var(--tok-str)}.cmt{color:var(--tok-cmt);font-style:italic}
|
|
185
|
-
.fn{color:var(--tok-fn)}.num{color:var(--tok-num)}.cls{color:var(--tok-cls)}
|
|
186
|
-
.op{color:var(--tok-op)}.typ{color:var(--tok-typ)}.dec{color:var(--tok-dec)}
|
|
187
|
-
|
|
188
|
-
/* ── Minimap ── */
|
|
189
|
-
.sl-minimap{background:var(--mm-bg);border-left:1px solid var(--border);
|
|
190
|
-
overflow:hidden;position:relative;flex-shrink:0;cursor:pointer;user-select:none}
|
|
191
|
-
.sl-minimap canvas{display:block;position:absolute;top:0;left:0}
|
|
192
|
-
.sl-mm-slider{position:absolute;left:0;right:0;pointer-events:none}
|
|
193
|
-
|
|
194
|
-
/* ── Status bar ── */
|
|
195
|
-
.sl-statusbar{height:26px;background:var(--accent2);display:flex;align-items:center;
|
|
196
|
-
padding:0 6px;font-size:11px;color:rgba(255,255,255,.85);flex-shrink:0;gap:0}
|
|
197
|
-
.sl-sb-item{display:flex;align-items:center;gap:4px;padding:0 8px;height:100%;
|
|
198
|
-
cursor:pointer;transition:background .1s;white-space:nowrap;border-radius:3px}
|
|
199
|
-
.sl-sb-item:hover{background:rgba(255,255,255,.15)}
|
|
200
|
-
.sl-sb-item.sl-no-click{cursor:default}
|
|
201
|
-
.sl-sb-item.sl-no-click:hover{background:transparent}
|
|
202
|
-
.sl-sb-sep{width:1px;height:14px;background:rgba(255,255,255,.22);margin:0 1px;flex-shrink:0}
|
|
203
|
-
.sl-sb-right{margin-left:auto;display:flex;align-items:center}
|
|
204
|
-
.sl-sb-wrap.sl-on{font-weight:700}
|
|
205
|
-
|
|
206
|
-
/* ── Placeholder ── */
|
|
207
|
-
.sl-placeholder{position:absolute;top:0;right:0;pointer-events:none;user-select:none;
|
|
208
|
-
color:var(--text3);white-space:pre;overflow:hidden;z-index:1}
|
|
209
|
-
|
|
210
|
-
/* ── Go to Line bar ── */
|
|
211
|
-
.sl-gtl-bar{position:absolute;top:0;left:50%;z-index:50;background:var(--bg3);
|
|
212
|
-
border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
|
|
213
|
-
display:flex;align-items:center;gap:8px;padding:8px 12px;
|
|
214
|
-
transform:translateX(-50%) translateY(-100%);transition:transform .18s,box-shadow .18s;pointer-events:none}
|
|
215
|
-
.sl-gtl-bar.sl-open{transform:translateX(-50%) translateY(0);pointer-events:all;box-shadow:0 8px 28px rgba(0,0,0,.4)}
|
|
216
|
-
.sl-gtl-label{font-size:12px;color:var(--text2);white-space:nowrap}
|
|
217
|
-
.sl-gtl-input{width:72px;background:var(--bg4);border:1px solid var(--border3);
|
|
218
|
-
border-radius:5px;padding:4px 8px;font-size:12px;font-family:var(--mono);
|
|
219
|
-
color:var(--text);outline:none;transition:border-color .15s;text-align:center}
|
|
220
|
-
.sl-gtl-input:focus{border-color:var(--accent)}
|
|
221
|
-
.sl-gtl-input.sl-gtl-err{border-color:#e05252}
|
|
222
|
-
.sl-gtl-hint{font-size:11px;color:var(--text3);font-family:var(--mono);min-width:40px}
|
|
223
|
-
|
|
224
|
-
/* ── Find + Replace bar ── */
|
|
225
|
-
.sl-find-bar{position:absolute;top:0;right:125px;z-index:50;background:var(--bg3);
|
|
226
|
-
border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
|
|
227
|
-
display:flex;flex-direction:column;overflow:hidden;
|
|
228
|
-
transform:translateY(-100%);transition:transform .18s,box-shadow .18s;pointer-events:none}
|
|
229
|
-
.sl-find-bar.sl-open{transform:translateY(0);pointer-events:all;box-shadow:0 8px 28px rgba(0,0,0,.4)}
|
|
230
|
-
.sl-find-row{display:flex;align-items:center;gap:6px;padding:7px 10px}
|
|
231
|
-
.sl-find-row+.sl-find-row{border-top:1px solid var(--border)}
|
|
232
|
-
.sl-find-bar input{width:180px;background:var(--bg4);border:1px solid var(--border3);
|
|
233
|
-
border-radius:5px;padding:4px 8px;font-size:12px;font-family:var(--mono);
|
|
234
|
-
color:var(--text);outline:none;transition:border-color .15s}
|
|
235
|
-
.sl-find-bar input:focus{border-color:var(--accent)}
|
|
236
|
-
.sl-find-btn{padding:3px 8px;font-size:11px;border:1px solid var(--border3);
|
|
237
|
-
border-radius:4px;background:transparent;color:var(--text2);cursor:pointer;
|
|
238
|
-
transition:background .1s;white-space:nowrap}
|
|
239
|
-
.sl-find-btn:hover{background:var(--border3);color:var(--text)}
|
|
240
|
-
.sl-find-btn.sl-active{background:var(--accent);border-color:var(--accent);color:#fff}
|
|
241
|
-
.sl-find-count{font-size:11px;color:var(--text3);font-family:var(--mono);min-width:52px}
|
|
242
|
-
.sl-find-x{font-size:14px;color:var(--text3);cursor:pointer;padding:2px 5px;
|
|
243
|
-
border-radius:3px;margin-left:2px}
|
|
244
|
-
.sl-find-x:hover{color:var(--text);background:var(--border3)}
|
|
245
|
-
|
|
246
|
-
/* ── Autocomplete popup (VS Code-style with optional description panel) ── */
|
|
247
|
-
.sl-ac-popup{position:fixed;z-index:400;background:var(--bg3);
|
|
248
|
-
border:1px solid var(--border3);border-radius:8px;overflow:hidden;
|
|
249
|
-
box-shadow:0 12px 40px rgba(0,0,0,.55);
|
|
250
|
-
display:flex;flex-direction:row;
|
|
251
|
-
animation:sl-acIn .1s ease;pointer-events:all}
|
|
252
|
-
@keyframes sl-acIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
253
|
-
/* Left: item list */
|
|
254
|
-
.sl-ac-list{min-width:240px;max-width:300px;max-height:320px;overflow-y:auto;flex-shrink:0}
|
|
255
|
-
.sl-ac-list::-webkit-scrollbar{width:4px}
|
|
256
|
-
.sl-ac-list::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
257
|
-
.sl-ac-item{display:flex;align-items:center;gap:8px;padding:4px 10px;font-size:12px;
|
|
258
|
-
font-family:var(--mono);cursor:pointer;color:var(--text2);transition:background .07s;
|
|
259
|
-
white-space:nowrap}
|
|
260
|
-
.sl-ac-item:hover,.sl-ac-item.sl-sel{background:var(--bg4);color:var(--text)}
|
|
261
|
-
.sl-ac-badge{width:18px;height:18px;border-radius:4px;display:flex;align-items:center;
|
|
262
|
-
justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;font-family:var(--sans)}
|
|
263
|
-
.sl-ac-badge.kw{background:rgba(110,159,255,.18);color:var(--tok-kw)}
|
|
264
|
-
.sl-ac-badge.fn{background:rgba(212,151,110,.18);color:var(--tok-fn)}
|
|
265
|
-
.sl-ac-badge.typ{background:rgba(110,201,212,.18);color:var(--tok-typ)}
|
|
266
|
-
.sl-ac-badge.cls{background:rgba(232,201,122,.18);color:var(--tok-cls)}
|
|
267
|
-
.sl-ac-badge.var{background:rgba(78,201,160,.18);color:var(--tok-str)}
|
|
268
|
-
.sl-ac-badge.snip{background:rgba(155,100,255,.18);color:#a78bfa}
|
|
269
|
-
.sl-ac-badge.emmet{background:rgba(255,140,0,.18);color:#fb923c}
|
|
270
|
-
.sl-ac-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
271
|
-
.sl-ac-detail{font-size:10px;color:var(--text3);flex-shrink:0;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left:4px}
|
|
272
|
-
/* Right: description / docs panel */
|
|
273
|
-
.sl-ac-desc{width:260px;max-height:320px;overflow-y:auto;
|
|
274
|
-
border-left:1px solid var(--border3);padding:10px 12px;flex-shrink:0}
|
|
275
|
-
.sl-ac-desc::-webkit-scrollbar{width:4px}
|
|
276
|
-
.sl-ac-desc::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
277
|
-
.sl-ac-desc-body{margin:0;font-size:11.5px;font-family:var(--mono);
|
|
278
|
-
color:var(--text2);line-height:1.6;white-space:pre-wrap;word-break:break-word}
|
|
279
|
-
|
|
280
|
-
/* ── Hover documentation tooltip ── */
|
|
281
|
-
.sl-hover-tip{position:fixed;z-index:500;background:var(--bg3);
|
|
282
|
-
border:1px solid var(--border3);border-radius:8px;
|
|
283
|
-
box-shadow:0 8px 32px rgba(0,0,0,.55);
|
|
284
|
-
max-width:380px;min-width:180px;padding:10px 14px;
|
|
285
|
-
pointer-events:all;cursor:default;
|
|
286
|
-
animation:sl-hoverIn .12s ease}
|
|
287
|
-
@keyframes sl-hoverIn{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
|
|
288
|
-
.sl-ht-sig{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;margin-bottom:5px}
|
|
289
|
-
.sl-ht-title{font-size:12.5px;font-family:var(--mono);font-weight:600;color:var(--tok-fn)}
|
|
290
|
-
.sl-ht-type{font-size:11px;font-family:var(--mono);color:var(--tok-typ);opacity:.9;word-break:break-all}
|
|
291
|
-
.sl-ht-body{font-size:12px;font-family:var(--sans);color:var(--text2);line-height:1.55;
|
|
292
|
-
max-height:120px;overflow-y:auto}
|
|
293
|
-
.sl-ht-body::-webkit-scrollbar{width:3px}
|
|
294
|
-
.sl-ht-body::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
295
|
-
.sl-hover-tip .sl-ht-divider{height:1px;background:var(--border);margin:6px 0}
|
|
296
|
-
|
|
297
|
-
/* ── Emmet tooltip ── */
|
|
298
|
-
.sl-emmet-tip{position:fixed;z-index:600;background:var(--bg3);
|
|
299
|
-
border:1px solid var(--border3);border-radius:6px;padding:4px 10px;
|
|
300
|
-
font-size:11px;font-family:var(--mono);color:var(--accent);
|
|
301
|
-
pointer-events:none;box-shadow:0 4px 16px rgba(0,0,0,.45);
|
|
302
|
-
white-space:nowrap;max-width:400px;overflow:hidden;text-overflow:ellipsis}
|
|
303
|
-
|
|
304
|
-
/* ── Theme picker ── */
|
|
305
|
-
.sl-theme-overlay{position:fixed;inset:0;z-index:700;
|
|
306
|
-
background:rgba(0,0,0,.50);backdrop-filter:blur(2px)}
|
|
307
|
-
.sl-theme-panel{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
|
|
308
|
-
z-index:701;background:var(--bg2);border:1px solid var(--border3);
|
|
309
|
-
border-radius:14px;overflow:hidden;width:420px;
|
|
310
|
-
box-shadow:0 32px 80px rgba(0,0,0,.65),0 0 0 1px var(--border2)}
|
|
311
|
-
.sl-theme-header{padding:16px 20px 12px;display:flex;align-items:center;
|
|
312
|
-
justify-content:space-between;border-bottom:1px solid var(--border)}
|
|
313
|
-
.sl-theme-title{font-size:13px;font-weight:600;color:var(--text);letter-spacing:.01em}
|
|
314
|
-
.sl-theme-close{width:24px;height:24px;border-radius:6px;display:flex;align-items:center;
|
|
315
|
-
justify-content:center;font-size:14px;color:var(--text3);cursor:pointer;
|
|
316
|
-
transition:background .1s,color .1s}
|
|
317
|
-
.sl-theme-close:hover{background:var(--border3);color:var(--text)}
|
|
318
|
-
.sl-theme-list{padding:8px 8px 10px}
|
|
319
|
-
.sl-theme-item{display:flex;align-items:center;gap:14px;padding:10px 12px;
|
|
320
|
-
border-radius:9px;cursor:pointer;transition:background .1s;
|
|
321
|
-
border:1px solid transparent;margin-bottom:2px}
|
|
322
|
-
.sl-theme-item:hover{background:var(--bg4)}
|
|
323
|
-
.sl-theme-item.sl-active{background:var(--bg4);border-color:var(--border3)}
|
|
324
|
-
.sl-theme-check{width:18px;height:18px;margin-left:auto;color:var(--accent);
|
|
325
|
-
font-size:13px;font-weight:700;flex-shrink:0;opacity:0}
|
|
326
|
-
.sl-theme-item.sl-active .sl-theme-check{opacity:1}
|
|
327
|
-
.sl-theme-swatch{width:46px;height:30px;border-radius:7px;flex-shrink:0;
|
|
328
|
-
overflow:hidden;border:1px solid rgba(0,0,0,.15);
|
|
329
|
-
display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr}
|
|
330
|
-
.sl-theme-swatch span{display:block}
|
|
331
|
-
.sl-theme-name{font-size:13px;color:var(--text);font-weight:500;line-height:1.3}
|
|
332
|
-
.sl-theme-desc{font-size:11px;color:var(--text3);margin-top:2px}
|
|
333
|
-
.sl-theme-tag{display:inline-block;font-size:9px;font-weight:600;letter-spacing:.08em;
|
|
334
|
-
text-transform:uppercase;padding:1px 5px;border-radius:3px;margin-left:6px;
|
|
335
|
-
background:var(--border3);color:var(--text3);vertical-align:middle}
|
|
336
|
-
.sl-theme-tag.sl-light{background:rgba(255,200,50,.15);color:#b58900}
|
|
337
|
-
|
|
338
|
-
/* ── Empty state ── */
|
|
339
|
-
.sl-empty{flex:1;display:flex;flex-direction:column;align-items:center;
|
|
340
|
-
justify-content:center;gap:10px;color:var(--text3);font-size:13px}
|
|
341
|
-
`;function H(r,e,t){const i=document.createElement(r);return e&&(i.className=e),i}function se(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function me(r,e=document.documentElement){return getComputedStyle(e).getPropertyValue(r).trim()}function Ze(r,e){const t=r.replace("#",""),i=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return`rgba(${i},${s},${n},${e})`}function Qe(r){return r.split(`
|
|
342
|
-
`)}function $(r){return r.join(`
|
|
343
|
-
`)}function et(r){return(r.match(/^(\s*)/)??["",""])[1]}function ue(r){return" ".repeat(Math.max(0,r))}function tt(r){return/[\w$]/.test(r)}function ye(r,e,t=tt){let i=e;for(;i>0&&t(r[i-1]);)i--;return i}function ve(r,e,t=tt){let i=e;for(;i<r.length&&t(r[i]);)i++;return i}function we(r,e){let t=0,i=null;return(...s)=>{const n=Date.now(),o=e-(n-t);o<=0?(i!==null&&(clearTimeout(i),i=null),t=n,r(...s)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,r(...s)},o))}}const qt={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 Gt(r,e,t,i){const s=Number(r);return Number.isFinite(s)?Math.max(e,Math.min(t,Math.round(s))):i}function it(r){const e={...r};for(const[t,i]of Object.entries(qt))if(t in r&&r[t]!==void 0){const[s,n,o]=i;e[t]=Gt(r[t],s,n,o)}return e}const ke={"(":")","{":"}","[":"]"},xe={")":"(","}":"{","]":"["};function Vt(r,e){const{row:t,col:i}=e,s=r[t]??"";let n=s[i],o=i;if(!ke[n]&&!xe[n]&&(n=s[i-1],o=i-1),!n)return null;if(ke[n]){const a=ke[n];let l=0;for(let c=t;c<Math.min(r.length,t+500);c++){const d=r[c]??"",u=c===t?o:0;for(let h=u;h<d.length;h++)if(d[h]===n)l++;else if(d[h]===a&&(l--,l===0))return{open:{row:t,col:o},close:{row:c,col:h}}}}else if(xe[n]){const a=xe[n];let l=0;for(let c=t;c>=Math.max(0,t-500);c--){const d=r[c]??"",u=c===t?o:d.length-1;for(let h=u;h>=0;h--)if(d[h]===n)l++;else if(d[h]===a&&(l--,l===0))return{open:{row:c,col:h},close:{row:t,col:o}}}}return null}function Kt(r,e){const t=r[e]??"";let i=0;for(const s of t)s==="{"?i++:s==="}"&&i--;return i>0}function Yt(r,e){let t=0;for(let i=e;i<r.length;i++)for(const s of r[i]??"")if(s==="{")t++;else if(s==="}"&&(t--,t===0))return i;return null}function Jt(r,e,t){const i=new Map(r);if(i.has(t))i.delete(t);else{const s=Yt(e,t);s!==null&&s>t&&i.set(t,s)}return i}const Xt=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function st(r){const e=r.trim();if(!e)return null;try{const t=Ce(e);return t===e?null:t}catch{return null}}function Ce(r){if(r.includes(">")){const t=r.indexOf(">");return Te(r.slice(0,t),Ce(r.slice(t+1)))}if(r.includes("+"))return r.split("+").map(t=>Ce(t.trim())).join(`
|
|
344
|
-
`);const e=r.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,s)=>Te(e[1],`$${s+1}`)).join(`
|
|
345
|
-
`)}return Te(r,"$1")}function Te(r,e){const t=r.match(/#([\w-]+)/),i=r.match(/\.([\w.-]+)/g),s=r.match(/\[([^\]]+)\]/);let n=r.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",o="";return t&&(o+=` id="${t[1]}"`),i&&(o+=` class="${i.map(a=>a.slice(1)).join(" ")}"`),s&&(o+=` ${s[1]}`),Xt.has(n)?`<${n}${o}>`:`<${n}${o}>${e}</${n}>`}function nt(r,e){let t=e;for(;t>0&&/[\w#.[\]*>+{}()$@:-]/.test(r[t-1]);)t--;const i=r.slice(t,e);return i.length<2?null:{abbr:i,start:t}}const Zt=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
346
|
-
|
|
347
|
-
function name(params) {
|
|
348
|
-
// body
|
|
349
|
-
}`,body:`function $1($2) {
|
|
350
|
-
$3
|
|
351
|
-
}`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
|
|
352
|
-
|
|
353
|
-
const name = (params) => {
|
|
354
|
-
// body
|
|
355
|
-
};`,body:`const $1 = ($2) => {
|
|
356
|
-
$3
|
|
357
|
-
};`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
|
|
358
|
-
|
|
359
|
-
async function name(params): Promise<T> {
|
|
360
|
-
// body
|
|
361
|
-
}`,body:`async function $1($2): Promise<$3> {
|
|
362
|
-
$4
|
|
363
|
-
}`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
|
|
364
|
-
|
|
365
|
-
class Name {
|
|
366
|
-
constructor(params) { ... }
|
|
367
|
-
}`,body:`class $1 {
|
|
368
|
-
constructor($2) {
|
|
369
|
-
$3
|
|
370
|
-
}
|
|
371
|
-
}`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
|
|
372
|
-
|
|
373
|
-
for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
|
|
374
|
-
$3
|
|
375
|
-
}`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
|
|
376
|
-
|
|
377
|
-
for (const key in object) { ... }`,body:`for (const $1 in $2) {
|
|
378
|
-
$3
|
|
379
|
-
}`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
|
|
380
|
-
|
|
381
|
-
try {
|
|
382
|
-
...
|
|
383
|
-
} catch (error) {
|
|
384
|
-
...
|
|
385
|
-
}`,body:`try {
|
|
386
|
-
$1
|
|
387
|
-
} catch ($2error) {
|
|
388
|
-
$3
|
|
389
|
-
}`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
|
|
390
|
-
|
|
391
|
-
new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
|
|
392
|
-
$2
|
|
393
|
-
})`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
|
|
394
|
-
|
|
395
|
-
import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
|
|
396
|
-
|
|
397
|
-
interface Name {
|
|
398
|
-
field: Type;
|
|
399
|
-
}`,body:`interface $1 {
|
|
400
|
-
$2: $3;
|
|
401
|
-
}`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
|
|
402
|
-
|
|
403
|
-
((params) => {
|
|
404
|
-
...
|
|
405
|
-
})(args);`,body:`(($1) => {
|
|
406
|
-
$2
|
|
407
|
-
})($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
|
|
408
|
-
|
|
409
|
-
switch (expr) {
|
|
410
|
-
case value:
|
|
411
|
-
...
|
|
412
|
-
break;
|
|
413
|
-
default:
|
|
414
|
-
...
|
|
415
|
-
}`,body:`switch ($1) {
|
|
416
|
-
case $2:
|
|
417
|
-
$3
|
|
418
|
-
break;
|
|
419
|
-
default:
|
|
420
|
-
$4
|
|
421
|
-
}`}],Qt=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
422
|
-
|
|
423
|
-
display: flex;
|
|
424
|
-
align-items: center;
|
|
425
|
-
justify-content: center;`,body:`display: flex;
|
|
426
|
-
align-items: $1center;
|
|
427
|
-
justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
|
|
428
|
-
|
|
429
|
-
display: grid;
|
|
430
|
-
grid-template-columns: repeat(3, 1fr);
|
|
431
|
-
gap: 16px;`,body:`display: grid;
|
|
432
|
-
grid-template-columns: $1repeat(3, 1fr);
|
|
433
|
-
gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
|
|
434
|
-
|
|
435
|
-
@media (max-width: 768px) {
|
|
436
|
-
...
|
|
437
|
-
}`,body:`@media ($1max-width: 768px) {
|
|
438
|
-
$2
|
|
439
|
-
}`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
|
|
440
|
-
|
|
441
|
-
@keyframes name {
|
|
442
|
-
from { ... }
|
|
443
|
-
to { ... }
|
|
444
|
-
}`,body:`@keyframes $1 {
|
|
445
|
-
from { $2 }
|
|
446
|
-
to { $3 }
|
|
447
|
-
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
448
|
-
|
|
449
|
-
--name: value;`,body:"--$1: $2;",language:["css"]}],ei=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
450
|
-
|
|
451
|
-
<details>
|
|
452
|
-
<summary>Title</summary>
|
|
453
|
-
<div>content</div>
|
|
454
|
-
</details>`,body:`<details>
|
|
455
|
-
<summary>$1Title</summary>
|
|
456
|
-
<div>
|
|
457
|
-
$2
|
|
458
|
-
</div>
|
|
459
|
-
</details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
|
|
460
|
-
<div class="card-header">$1</div>
|
|
461
|
-
<div class="card-body">$2</div>
|
|
462
|
-
<div class="card-footer">$3</div>
|
|
463
|
-
</div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
|
|
464
|
-
|
|
465
|
-
<nav class="navbar">
|
|
466
|
-
<a href="#">Home</a> ...
|
|
467
|
-
</nav>`,body:`<nav class="navbar">
|
|
468
|
-
<a href="$1#">Home</a>
|
|
469
|
-
<a href="$2#">About</a>
|
|
470
|
-
<a href="$3#">Contact</a>
|
|
471
|
-
</nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
|
|
472
|
-
|
|
473
|
-
<div class="modal">
|
|
474
|
-
<div class="modal-dialog"> ... </div>
|
|
475
|
-
</div>`,body:`<div class="modal">
|
|
476
|
-
<div class="modal-dialog">
|
|
477
|
-
<div class="modal-header">$1</div>
|
|
478
|
-
<div class="modal-body">$2</div>
|
|
479
|
-
<div class="modal-footer">$3</div>
|
|
480
|
-
</div>
|
|
481
|
-
</div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
|
|
482
|
-
|
|
483
|
-
<table>
|
|
484
|
-
<thead><tr><th>...</th></tr></thead>
|
|
485
|
-
<tbody><tr><td>...</td></tr></tbody>
|
|
486
|
-
</table>`,body:`<table>
|
|
487
|
-
<thead>
|
|
488
|
-
<tr>
|
|
489
|
-
<th>$1</th>
|
|
490
|
-
</tr>
|
|
491
|
-
</thead>
|
|
492
|
-
<tbody>
|
|
493
|
-
<tr>
|
|
494
|
-
<td>$2</td>
|
|
495
|
-
</tr>
|
|
496
|
-
</tbody>
|
|
497
|
-
</table>`}];function ti(r){const e=[...ei];return(r==="typescript"||r==="javascript")&&e.push(...Zt.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(r):t.language===r))),r==="css"&&e.push(...Qt),e}function ii(r,e,t){let i=e;for(;i>0&&/\w/.test(r[i-1]);)i--;const s=r.slice(i,e);if(!s)return null;const n=t.find(o=>o.kind==="snip"&&o.label===s);return n?{snippet:n,start:i}:null}function si(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function rt(r,e,t,i){r.cursors.some(n=>n.row===e&&n.col===t)||r.cursors.push({row:e,col:t,sel:i})}function ot(r){r.cursors=[],r.searchWord="",r.lastMatchRow=-1,r.lastMatchCol=-1}function ni(r,e,t,i,s){const n=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((d,u)=>({row:d.row,col:d.col,isPrimary:!1,idx:u+1}))];n.sort((d,u)=>u.row!==d.row?u.row-d.row:u.col-d.col);const o=r.map(d=>d);let a=e,l=t;const c=i.map(d=>({...d}));for(const d of n){const u=o[d.row]??"";o[d.row]=u.slice(0,d.col)+s+u.slice(d.col);for(const h of n)h!==d&&h.row===d.row&&h.col>=d.col&&(h.col+=s.length);d.col+=s.length,d.isPrimary?(a=d.row,l=d.col):(c[d.idx-1].row=d.row,c[d.idx-1].col=d.col)}return{doc:o,primaryRow:a,primaryCol:l,extraCursors:c}}function ri(r,e,t,i){const s=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((c,d)=>({row:c.row,col:c.col,isPrimary:!1,idx:d+1}))];s.sort((c,d)=>d.row!==c.row?d.row-c.row:d.col-c.col);const n=r.map(c=>c);let o=e,a=t;const l=i.map(c=>({...c}));for(const c of s){if(c.col<=0)continue;const d=n[c.row]??"";n[c.row]=d.slice(0,c.col-1)+d.slice(c.col);for(const u of s)u!==c&&u.row===c.row&&u.col>c.col&&u.col--;c.col--,c.isPrimary?(o=c.row,a=c.col):l[c.idx-1].col=c.col}return{doc:n,primaryRow:o,primaryCol:a,extraCursors:l}}function oi(r,e,t,i,s){let n=r.searchWord;if(!n){if(s&&s.ar===s.fr&&(n=(e[s.ar]??"").slice(s.ac,s.fc)),!n){const l=e[t]??"",c=ye(l,i),d=ve(l,i);n=l.slice(c,d)}if(!n)return null;r.searchWord=n,r.lastMatchRow=t,r.lastMatchCol=i}const o=r.lastMatchRow,a=r.lastMatchCol;for(let l=o;l<e.length;l++){const c=e[l]??"";let u=l===o?a:0;for(;u<=c.length-n.length;){const h=c.indexOf(n,u);if(h<0)break;const _=h===0||!/\w/.test(c[h-1]),y=h+n.length>=c.length||!/\w/.test(c[h+n.length]);if(_&&y)return r.lastMatchRow=l,r.lastMatchCol=h+n.length,{word:n,sel:{ar:l,ac:h,fr:l,fc:h+n.length},row:l,col:h+n.length};u=h+1}}for(let l=0;l<=o;l++){const c=e[l]??"",d=l===o?a:c.length;let u=0;for(;u<d;){const h=c.indexOf(n,u);if(h<0||h>=d)break;const _=h===0||!/\w/.test(c[h-1]),y=h+n.length>=c.length||!/\w/.test(c[h+n.length]);if(_&&y)return r.lastMatchRow=l,r.lastMatchCol=h+n.length,{word:n,sel:{ar:l,ac:h,fr:l,fc:h+n.length},row:l,col:h+n.length};u=h+1}}return null}function ai(r,e,t){if(!e)return[];const i=[];for(let s=0;s<r.length;s++){const n=r[s]??"";if(t.useRegex)try{const o=new RegExp(e,t.caseSensitive?"g":"gi");let a;for(;(a=o.exec(n))!==null&&(i.push({row:s,col:a.index,len:a[0].length}),!!a[0].length););}catch{}else{const o=t.caseSensitive?n:n.toLowerCase(),a=t.caseSensitive?e:e.toLowerCase();let l=0;for(;;){const c=o.indexOf(a,l);if(c===-1)break;i.push({row:s,col:c,len:e.length}),l=c+1}}}return i}function li(r,e,t,i){const s=e[t];if(!s)return r;const n=[...r],o=n[s.row]??"";return n[s.row]=o.slice(0,s.col)+i+o.slice(s.col+s.len),n}function ci(r,e,t){const i=[...r];for(let s=e.length-1;s>=0;s--){const n=e[s],o=i[n.row]??"";i[n.row]=o.slice(0,n.col)+t+o.slice(n.col+n.len)}return i}function di(r,e,t){return r.length?(e+t+r.length)%r.length:-1}function hi(r,e,t,i){if(i)return[];const s=r[e]??"",n=ye(s,t),o=ve(s,t),a=s.slice(n,o);if(!a||a.length<2)return[];const l=[];for(let c=0;c<r.length;c++){const d=r[c]??"";let u=0;for(;u<=d.length-a.length;){const h=d.indexOf(a,u);if(h<0)break;const _=h===0||!/\w/.test(d[h-1]),y=h+a.length>=d.length||!/\w/.test(d[h+a.length]);_&&y&&!(c===e&&h===n)&&l.push({row:c,col:h,len:a.length}),u=h+1}}return l}const Se=[{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>"}],pi={typescript:Se,javascript:Se,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 at(r,e,t){const i=We[r]??ge,s=Oe[r]??be,n=pi[r]??Se;return[...[...i,...e].map(o=>({label:o,kind:"kw",detail:"keyword"})),...[...s,...t].map(o=>({label:o,kind:"typ",detail:"type"})),...n]}function ui(r,e){const t=new Set;for(const i of r){const s=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const n of s)n!==e&&n.length>2&&t.add(n)}return t}function lt(r,e){return r.language?Array.isArray(r.language)?r.language.includes(e):r.language===e:!0}function fi(r,e,t={},i=0,s=0){if(e.length<2)return[];const n=e.toLowerCase(),{language:o="typescript",extraKeywords:a=[],extraTypes:l=[],completions:c=[],replaceBuiltins:d=!1,maxResults:u=14}=t,h=c.filter(f=>f.kind==="snip"&&!!f.body&<(f,o)),_=c.filter(f=>!(f.kind==="snip"&&f.body)&<(f,o)),y=h.filter(f=>f.label.toLowerCase().startsWith(n));let g;if(t.provideCompletions){const f={line:r[i]??"",col:s,prefix:e,language:o,doc:r};let I;try{I=t.provideCompletions(f)}catch(T){console.error("[syncline-editor] provideCompletions threw an error:",T),I=null}g=I!=null?[...I,..._]:[...d?[]:at(o,a,l),..._]}else g=d?_:[...at(o,a,l),..._];const k=new Set(g.map(f=>f.label)),b=g.filter(f=>f.label.toLowerCase().startsWith(n)&&f.label!==e),M=new Set(y.map(f=>f.label)),x=[...ui(r,e)].filter(f=>f.toLowerCase().startsWith(n)&&!k.has(f)&&!M.has(f)).slice(0,8).map(f=>({label:f,kind:"var",detail:"in file"}));return[...y,...b.filter(f=>!M.has(f.label)),...x].slice(0,u)}function gi(r,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(r[i-1]);)i--;return{prefix:r.slice(i,e),start:i}}function bi(r,e){const t=n=>/[\w$]/.test(n);let i=e;for(;i<r.length&&t(r[i]);)i++;let s=e;for(;s>0&&t(r[s-1]);)s--;if(s===i)return"";if(s>0&&r[s-1]==="."){let n=s-1,o=n;for(;o>0&&t(r[o-1]);)o--;if(o<n)return r.slice(o,i)}return r.slice(s,i)}const _i={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 mi(r,e){const t=_i[r];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}function yi(r){var R,q,X,Z;const{vr:e,visIdx:t,curVisRow:i,wm:s,foldedLines:n,isFoldable:o,opts:a}=r,{docLine:l,segIdx:c,text:d}=e,u=t===i,h=l===((R=s.visualRows[i])==null?void 0:R.docLine),_=c>0,y=((q=s.segments[l])==null?void 0:q.slice(0,c).reduce((v,w)=>v+w.length,0))??0,g=r.docSel?Fe(r.docSel,l,((X=(s.segments[l]??[""])[c])==null?void 0:X.length)??0):null;let k=null;if(g){const v=((Z=(s.segments[l]??[""])[c])==null?void 0:Z.length)??0,w=Fe(r.docSel,l,v+y);if(w){const E=w.start-y,B=w.end-y;B>0&&E<d.length&&(k={start:Math.max(0,E),end:Math.min(d.length,B)})}}const b=r.findMatches.filter(v=>v.row===l).map(v=>{var G,te;const w=v.col-y,E=v.col+v.len-y;if(E<=0||w>=d.length)return null;const B=r.findIdx>=0&&((G=r.findMatches[r.findIdx])==null?void 0:G.row)===v.row&&((te=r.findMatches[r.findIdx])==null?void 0:te.col)===v.col;return{start:Math.max(0,w),end:Math.min(d.length,E),isCur:B}}).filter(Boolean),M=r.wordHighlights.filter(v=>v.row===l).map(v=>{const w=v.col-y,E=v.col+v.len-y;return E<=0||w>=d.length?null:{start:Math.max(0,w),end:Math.min(d.length,E)}}).filter(Boolean),m=[];if(r.bracketMatch){for(const v of[r.bracketMatch.open,r.bracketMatch.close])if(v.row===l){const w=v.col-y;w>=0&&w<d.length&&m.push({start:w,end:w+1})}}const x=[],f=[];for(const v of r.extraCursors){const w=ee(s,v.row,v.col);if(w.visRow===t&&x.push(w.colInSeg),v.sel){const E=wi(v.sel);if(l>=E.ar&&l<=E.fr){const B=l===E.ar?E.ac-y:-y,G=l===E.fr?E.fc-y:d.length+999;G>0&&B<d.length&&f.push({start:Math.max(0,B),end:Math.min(d.length,G)})}}}const I=[];for(const v of r.remoteCursors){const w=ee(s,v.row,v.col);w.visRow===t&&I.push({col:w.colInSeg,name:v.name,color:v.color})}const T=[];for(const v of r.remoteSels){const w=v.from.row<v.to.row||v.from.row===v.to.row&&v.from.col<=v.to.col?v.from:v.to,E=w===v.from?v.to:v.from;if(l>=w.row&&l<=E.row){const B=l===w.row?w.col-y:-y,G=l===E.row?E.col-y:d.length+999;G>0&&B<d.length&&T.push({start:Math.max(0,B),end:Math.min(d.length,G),color:v.color})}}const L=vi(d,a.renderWhitespace),K=u||k||b.length||x.length||M.length||m.length||f.length||r.snippetStopCols.length>0||I.length>0||T.length>0;let N;if(K)N=xi(L,u?r.curColInSeg:-1,k,b,x,r.snippetStopCols,M,m,f,a.tokeniserOpts,I,T,t===0);else{const v=`${l}:${c}:${a.renderWhitespace}`;let w=r.tokenCache.get(v,L);w||(w=_e(L,a.tokeniserOpts),r.tokenCache.set(v,L,w)),N=ki(L,w)||"​"}let W="";if(c===0&&a.showIndentGuides){const v=(d.match(/^(\s*)/)??["",""])[1].length,w=Math.floor(v/a.tabSize);for(let E=1;E<w;E++){const B=a.codePaddingLeft+E*a.tabSize*a.charWidth;W+=`<span class="sl-ig" style="left:${B}px"></span>`}}let F="";if(c===0&&o){const v=n.has(l);F=`<span class="sl-fold-btn" data-row="${l}">${v?"▸":"▾"}</span>`}const z=n.has(l)&&c===0,S=c===0?String(l+1):"";return`<div class="${["sl-er",a.highlightActiveLine&&h?"sl-cur-row":"",_?"sl-wrap-cont":"",z?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${a.lineHeight}px" data-v="${t}" data-doc="${l}"><div class="sl-eg" style="position:relative">${F}<span class="sl-egn">${S}</span></div><div class="sl-el"><span class="sl-cl">${W}${N}</span></div></div>`}function vi(r,e){if(e==="none")return r;if(e==="all")return r.replace(/ /g,"·").replace(/\t/g,"→");const t=(r.match(/^ +/)??[""])[0].length,i=(r.match(/ +$/)??[""])[0].length;let s=r;return t&&(s="·".repeat(t)+s.slice(t)),i&&(s=s.slice(0,s.length-i)+"·".repeat(i)),s.replace(/\t/g,"→")}function wi(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 ki(r,e){if(!r)return"";const t=ze(r,e);let i="",s=0,n=t[0];const o=a=>{if(a<=s)return;const l=se(r.slice(s,a));i+=n?`<span class="${n}">${l}</span>`:l};for(let a=1;a<=r.length;a++){const l=a<r.length?t[a]:null;l!==n&&(o(a),s=a,n=l??"")}return i}function xi(r,e,t,i,s,n,o,a,l,c,d=[],u=[],h=!1){if(r.length===0){let f=e>=0?'<span class="sl-cur"></span>':"";for(const I of s)f+='<span class="sl-cur-extra"></span>';for(const I of n)f+='<span class="sl-snip-stop"></span>';for(const I of d)f+=`<span class="${h?"sl-rc sl-rc-flip":"sl-rc"}" style="--rc-color:${I.color}"><span class="sl-rc-label">${se(I.name)}</span></span>`;return f||"​"}const _=_e(r,c),y=ze(r,_);let g="",k=0,b="",M="",m="";const x=f=>{if(f<=k)return;const I=se(r.slice(k,f)),T=[b,M,m?"sl-rs":""].filter(Boolean).join(" "),L=m?` style="--rs-color:${m}33"`:"";g+=T||L?`<span${L}${T?` class="${T}"`:""}>${I}</span>`:I};for(let f=0;f<=r.length;f++){e===f&&(x(f),k=f,g+='<span class="sl-cur"></span>');for(const S of s)S===f&&(x(f),k=f,g+='<span class="sl-cur-extra"></span>');for(const S of n)S===f&&(x(f),k=f,g+='<span class="sl-snip-stop"></span>');for(const S of d)S.col===f&&(x(f),k=f,g+=`<span class="${h?"sl-rc sl-rc-flip":"sl-rc"}" style="--rc-color:${S.color}"><span class="sl-rc-label">${se(S.name)}</span></span>`);if(f===r.length){x(f);break}const I=y[f]??"",T=i.find(S=>f>=S.start&&f<S.end),L=t&&f>=t.start&&f<t.end||l.some(S=>f>=S.start&&f<S.end),K=!L&&!T&&o.some(S=>f>=S.start&&f<S.end),N=!L&&!T&&a.some(S=>f>=S.start&&f<S.end);let W="";L?W="sl-sh":T?W="sl-fh"+(T.isCur?" sl-fh-cur":""):N?W="sl-bm":K&&(W="sl-wh");const F=L?void 0:u.find(S=>f>=S.start&&f<S.end),z=(F==null?void 0:F.color)??"";(W!==b||I!==M||z!==m)&&(x(f),k=f,b=W,M=I,m=z)}return g||"​"}function Me(r,e,t,i,s){const n=Math.max(0,r*s-t),o=Math.max(0,r*V-i),l=(n>0?e/n:0)*o,c=Math.max(20,t/s*V),d=e/s*V-l;return{mmScroll:l,sliderTop:d,sliderHeight:c}}function Ci(r,e,t,i,s){const n=Math.max(0,e*s-t),o=Math.max(0,e*V-i);if(n<=0)return 0;const a=V/s-o/n;if(Math.abs(a)<1e-9){const l=Math.max(20,t/s*V);return Math.max(0,Math.min(n,r/Math.max(1,i-l)*n))}return Math.max(0,Math.min(n,r/a))}function Ti(r,e,t,i,s,n){const o=Math.max(0,e*n-i),a=Math.max(0,e*V-s);if(o<=0)return 0;const l=t/o*a,c=(r+l)/V;return Math.max(0,Math.min(o,c*n-i/2))}function ct(r){const e=t=>{const i=r(t);return i.startsWith("#")&&i.length===7?Ze(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=r("--text2");return t.startsWith("#")&&t.length===7?Ze(t,.28):"rgba(150,148,140,0.28)"})()}}function Si(r){var S,ne;const{canvas:e,doc:t,firstLine:i,lastLine:s,subPx:n,wrapperWidth:o,canvasHeight:a,cursorRow:l,sel:c,findMatches:d,findIdx:u,sliderTop:h,sliderHeight:_,colors:y,getCssVar:g,dpr:k}=r,b=e.getContext("2d");if(!b)return;b.setTransform(k,0,0,k,0,0);const M=g("--mm-bg")||"#0d0d0f",m=g("--mm-dim")||"rgba(0,0,0,.30)",x=g("--mm-edge")||"rgba(255,255,255,.18)",f=g("--mm-slider")||"rgba(255,255,255,.07)",I=g("--sel-bg")||"rgba(110,159,255,.22)",T=g("--cur-line-bg")||"rgba(255,255,255,.05)",L=g("--find-border")||"rgba(234,180,86,.50)",K=g("--find-cur-bg")||"rgba(234,180,86,.80)",N=R=>(R-i)*V;if(b.fillStyle=M,b.fillRect(0,0,o,a),l>=i&&l<s&&(b.fillStyle=T,b.fillRect(0,N(l),o,V)),c){const R=Math.max(i,c.ar),q=Math.min(s-1,c.fr);q>=R&&(b.fillStyle=I,b.fillRect(0,N(R),o,(q-R+1)*V))}for(const R of d){if(R.row<i||R.row>=s)continue;const q=u>=0&&((S=d[u])==null?void 0:S.row)===R.row&&((ne=d[u])==null?void 0:ne.col)===R.col;b.fillStyle=q?K:L,b.fillRect(le+R.col*Y,N(R.row),Math.max(3,R.len*Y),V)}const W=Math.floor((o-le)/Y);for(let R=i;R<s;R++){const q=t[R]??"";if(!q.trim())continue;const X=N(R),Z=1.5,v=_e(q);let w=0;for(const B of v){if(B.start>=W)break;B.start>w&&(b.fillStyle=y.txt,b.fillRect(le+w*Y,X,(Math.min(B.start,W)-w)*Y,Z));const G=y[B.cls]??y.txt,te=Math.min(B.end,W)-B.start;te>0&&(b.fillStyle=G,b.fillRect(le+B.start*Y,X,te*Y,Z)),w=Math.max(w,Math.min(B.end,W))}const E=Math.min(q.length,W);w<E&&(b.fillStyle=y.txt,b.fillRect(le+w*Y,X,(E-w)*Y,Z))}const F=h+n,z=F+_;b.fillStyle=m,F>0&&b.fillRect(0,0,o,F),z<a&&b.fillRect(0,z,o,a-z),b.fillStyle=f,b.fillRect(0,F,o,_),b.fillStyle=x,b.fillRect(0,Math.max(0,F),o,1),b.fillRect(0,Math.max(0,z-1),o,1)}const Mi={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:Tt,fontFamily:"'JetBrains Mono', monospace",fontSize:xt,lineHeight:wt,tabSize:Ct,insertSpaces:!0,maxUndoHistory:je,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:Mt,gutterWidth:kt,minimapWidth:St,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0,placeholder:"",goToLine:!1};class dt{constructor(e,t={}){p(this,"_host");p(this,"_shadow");p(this,"_editorEl");p(this,"_spacerEl");p(this,"_vpEl");p(this,"_inputEl");p(this,"_minimapWrap");p(this,"_mmCanvas");p(this,"_mmSlider");p(this,"_statusBar");p(this,"_findBar");p(this,"_findInput");p(this,"_replaceInput");p(this,"_findCount");p(this,"_replaceRow");p(this,"_acPopup");p(this,"_emmetTip");p(this,"_snippetTip");p(this,"_hoverTip");p(this,"_themeOverlay");p(this,"_themePanel");p(this,"_placeholderEl");p(this,"_goToLineBar");p(this,"_goToLineInput");p(this,"_goToLineHint");p(this,"_config");p(this,"_tab",Ne(1,[""]));p(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0]});p(this,"_foldedLines",new Map);p(this,"_tokenCache",new Nt);p(this,"_themeManager");p(this,"_findMatches",[]);p(this,"_findIdx",-1);p(this,"_findCaseSensitive",!1);p(this,"_findRegex",!1);p(this,"_wordHighlights",[]);p(this,"_bracketMatch",null);p(this,"_acItems",[]);p(this,"_acSel",0);p(this,"_acPrefix","");p(this,"_acStartCol",0);p(this,"_emmetAcStartCol",0);p(this,"_mc",si());p(this,"_extraCursors",[]);p(this,"_isDragging",!1);p(this,"_dragAnchor",null);p(this,"_hoverTimer",null);p(this,"_hoverPinned",!1);p(this,"_mmDragMode","none");p(this,"_mmDragStartY",0);p(this,"_mmDragStartScroll",0);p(this,"_mmSliderOffset",0);p(this,"_mmColors");p(this,"_lastInputTime",0);p(this,"_dynamicStyleEl");p(this,"_emmetExpanded",null);p(this,"_snippetExpanded",null);p(this,"_snippetSession",null);p(this,"_collabBinding",null);p(this,"_remotePeers",new Map);p(this,"_acDebounceTimer",null);p(this,"_rafId",null);p(this,"_onWinMouseUp");p(this,"_onWinResize");p(this,"_onEditorScroll");p(this,"_onWinMmMouseMove");p(this,"_onWinMmMouseUp");p(this,"_ro",null);p(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=Jt(this._foldedLines,this._tab.doc,i),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()});this._config={...Mi,...it(t)},this._onWinMouseUp=()=>{var l,c,d,u;this._isDragging&&((c=(l=this._config).onCursorChange)==null||c.call(l,{...this._tab.cur}),(u=(d=this._config).onSelectionChange)==null||u.call(d,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab()),this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=we(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=we(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=l=>{if(this._mmDragMode==="none")return;const c=this._minimapWrap.clientHeight;if(this._mmDragMode==="slider"){const d=l.clientY-this._minimapWrap.getBoundingClientRect().top;this._editorEl.scrollTop=Ci(d-this._mmSliderOffset,this._tab.doc.length,this._editorEl.clientHeight,c,this._config.lineHeight)}else{const d=l.clientY-this._mmDragStartY,u=Math.max(0,this._tab.doc.length*this._config.lineHeight-this._editorEl.clientHeight);this._editorEl.scrollTop=Math.max(0,Math.min(u,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=H("style");i.textContent=zt,this._shadow.appendChild(i),this._dynamicStyleEl=H("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new Ut(this._host);const s=typeof this._config.theme=="string"?this._config.theme:this._config.theme;this._themeManager.apply(s);const n=H("div","sl-layout"),o=H("div","sl-ed-pane");this._inputEl=H("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=H("div","sl-editor"),this._spacerEl=H("div","sl-spacer"),this._vpEl=H("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=H("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=H("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=H("canvas",""),this._mmSlider=H("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),n.appendChild(o),this._config.showMinimap&&n.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=H("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=H("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=H("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=H("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=H("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=H("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(n),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 a=typeof this._config.value=="string"?Qe(this._config.value):this._config.value;this._tab=Ne(1,a.length?a:[""]),this._mmColors=ct(l=>me(l,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(we(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render(),this._config.collab&&this._initCollab(this._config.collab)}getValue(){return $(this._tab.doc)}setValue(e){var t,i;j(this._tab,this._config.maxUndoHistory),this._tab.doc=Qe(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},A(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(),A(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=ct(t=>me(t,this._host)),this._tokenCache.clear(),this._render()}updateConfig(e){const t=it(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:s,...n}=t;Object.assign(this._config,n)}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),"collab"in e&&(e.collab?this._initCollab(e.collab):this._destroyCollab()),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(e){this._themeManager.register(e)}undo(){var e,t;Ht(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,$(this._tab.doc)))}redo(){var e,t;Pt(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,$(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}}_initCollab(e){this._destroyCollab();const t=new ae(e.transport.siteId),i=this._config.onChange;this._collabBinding=new fe(this,t,e.transport,{name:e.name,onPeersChange:n=>{var o;this._remotePeers=new Map(n),(o=e.onPeersChange)==null||o.call(e,n),this._scheduleRender()}});const s=this._config.onChange;s!==i&&(this._config.onChange=n=>{s==null||s(n),i==null||i(n)}),this._broadcastCursorToCollab()}_destroyCollab(){this._collabBinding&&(this._collabBinding.destroy(),this._collabBinding=null,this._remotePeers=new Map,this._scheduleRender())}_broadcastCursorToCollab(){if(!this._collabBinding)return;const{row:e,col:t}=this._tab.cur;if(this._collabBinding.awareness.updateCursor(e,t),this._tab.sel){const i=this._tab.sel;this._collabBinding.awareness.updateSelection({row:i.ar,col:i.ac},{row:i.fr,col:i.fc})}else this._collabBinding.awareness.clearSelection()}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"),this._destroyCollab()}_buildFindBar(){const e=H("div","sl-find-bar");return e.innerHTML=`
|
|
498
|
-
<div class="sl-find-row">
|
|
499
|
-
<input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false">
|
|
500
|
-
<span class="sl-find-count">–</span>
|
|
501
|
-
<button class="sl-find-btn sl-find-prev" title="Previous">↑</button>
|
|
502
|
-
<button class="sl-find-btn sl-find-next" title="Next">↓</button>
|
|
503
|
-
<button class="sl-find-btn sl-find-case" title="Match case">Aa</button>
|
|
504
|
-
<button class="sl-find-btn sl-find-regex" title="Regex">.*</button>
|
|
505
|
-
<span class="sl-find-x sl-find-close">✕</span>
|
|
506
|
-
</div>
|
|
507
|
-
<div class="sl-find-row sl-replace-row" style="display:none">
|
|
508
|
-
<input class="sl-find-replace-input" placeholder="Replace…" autocomplete="off" spellcheck="false">
|
|
509
|
-
<button class="sl-find-btn sl-replace-one">Replace</button>
|
|
510
|
-
<button class="sl-find-btn sl-replace-all">All</button>
|
|
511
|
-
</div>
|
|
512
|
-
`,e}_buildGoToLineBar(){const e=H("div","sl-gtl-bar");e.innerHTML=`
|
|
513
|
-
<span class="sl-gtl-label">Go to line</span>
|
|
514
|
-
<input class="sl-gtl-input" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" placeholder="…">
|
|
515
|
-
<span class="sl-gtl-hint"></span>
|
|
516
|
-
<span class="sl-find-x sl-gtl-close" title="Close">✕</span>
|
|
517
|
-
`;const t=e.querySelector(".sl-gtl-input"),i=e.querySelector(".sl-gtl-hint");return t.addEventListener("input",()=>{const s=parseInt(t.value,10),n=!isNaN(s)&&s>=1&&s<=this._tab.doc.length;t.classList.toggle("sl-gtl-err",t.value!==""&&!n),i.textContent=`(1–${this._tab.doc.length})`}),t.addEventListener("keydown",s=>{var n,o;if(s.key==="Enter"){s.preventDefault();const a=parseInt(t.value,10);!isNaN(a)&&a>=1&&a<=this._tab.doc.length&&(this._tab.cur.row=a-1,this._tab.cur.col=Math.min(this._tab.cur.col,(this._tab.doc[a-1]??"").length),A(this._tab),this._tab.sel=null,this._closeGoToLine(),this._scrollIntoView(),this._render(),(o=(n=this._config).onCursorChange)==null||o.call(n,{...this._tab.cur}),this._broadcastCursorToCollab())}else s.key==="Escape"&&(s.preventDefault(),this._closeGoToLine());s.stopPropagation()}),e.querySelector(".sl-gtl-close").addEventListener("click",()=>this._closeGoToLine()),e}_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()}_buildStatusBar(){const e=H("div","sl-statusbar");return e.innerHTML=`
|
|
518
|
-
<div class="sl-sb-item sl-no-click sl-sb-lang">⬡ TypeScript</div>
|
|
519
|
-
<div class="sl-sb-sep"></div>
|
|
520
|
-
<div class="sl-sb-item sl-no-click sl-sb-pos">Ln 1, Col 1</div>
|
|
521
|
-
<div class="sl-sb-sep"></div>
|
|
522
|
-
<div class="sl-sb-item sl-no-click sl-sb-sel"></div>
|
|
523
|
-
<div class="sl-sb-sep sl-sb-sel-sep" style="display:none"></div>
|
|
524
|
-
<div class="sl-sb-item sl-no-click sl-sb-lines">1 line</div>
|
|
525
|
-
<div class="sl-sb-sep"></div>
|
|
526
|
-
<div class="sl-sb-item sl-no-click">UTF-8 LF</div>
|
|
527
|
-
<div class="sl-sb-right">
|
|
528
|
-
<div class="sl-sb-item sl-no-click sl-sb-mc" style="display:none">⊕ <span class="sl-sb-mc-count">1</span> cursors</div>
|
|
529
|
-
<div class="sl-sb-item sl-sb-wrap sl-sb-wrap-btn">⇥ Wrap: OFF</div>
|
|
530
|
-
<div class="sl-sb-sep"></div>
|
|
531
|
-
<div class="sl-sb-item sl-sb-theme-btn">🎨 Theme</div>
|
|
532
|
-
<div class="sl-sb-sep"></div>
|
|
533
|
-
<div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
|
|
534
|
-
</div>
|
|
535
|
-
`,e.querySelector(".sl-sb-wrap-btn").addEventListener("click",()=>this._toggleWrap()),e.querySelector(".sl-sb-theme-btn").addEventListener("click",()=>this._openThemePicker()),e}_applyDynamicStyles(){const{fontFamily:e,fontSize:t,lineHeight:i,cursorBlinkRate:s,cursorStyle:n,gutterWidth:o,minimapWidth:a,showGutter:l}=this._config,c=Math.max(2,i-4),d=Math.floor((i-c)/2);let u="";n==="block"?u=`width:${Q}px;opacity:.5;border-radius:1px;`:n==="underline"&&(u=`width:${Q}px;height:2px;top:${i-2}px;border-radius:0;`);const h=l?o:0;this._dynamicStyleEl.textContent=`
|
|
536
|
-
.sl-el{font-family:${e};font-size:${t}px;line-height:${i}px}
|
|
537
|
-
.sl-cl{height:${i}px;line-height:${i}px}
|
|
538
|
-
.sl-egn{height:${i}px;line-height:${i}px}
|
|
539
|
-
.sl-eg{min-width:${h}px;width:${h}px;${l?"":"display:none"}}
|
|
540
|
-
.sl-cur::after{height:${c}px;top:${d}px;animation-duration:${s}ms;${u}}
|
|
541
|
-
.sl-cur-extra::after{height:${c}px;top:${d}px;animation-duration:${s}ms;${u}}
|
|
542
|
-
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${a}px`,this._placeholderEl.style.left=`${h+ie}px`,this._placeholderEl.style.fontFamily=e,this._placeholderEl.style.fontSize=`${t}px`,this._placeholderEl.style.lineHeight=`${i}px`}_applyTokenOverrides(){const e=this._config.tokenColors??{},t=this._themeManager.activeTheme,i=this._host.style,s=(o,a,l)=>{i.setProperty(o,a||l)},n=t==null?void 0:t.tokens;s("--tok-kw",e.keyword,(n==null?void 0:n.tokKw)??""),s("--tok-str",e.string,(n==null?void 0:n.tokStr)??""),s("--tok-cmt",e.comment,(n==null?void 0:n.tokCmt)??""),s("--tok-fn",e.function,(n==null?void 0:n.tokFn)??""),s("--tok-num",e.number,(n==null?void 0:n.tokNum)??""),s("--tok-cls",e.class,(n==null?void 0:n.tokCls)??""),s("--tok-op",e.operator,(n==null?void 0:n.tokOp)??""),s("--tok-typ",e.type,(n==null?void 0:n.tokTyp)??""),s("--tok-dec",e.decorator,(n==null?void 0:n.tokDec)??"")}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:e,cur:t,sel:i}=this._tab,{lineHeight:s}=this._config;this._wordHighlights=this._config.wordHighlight?hi(e,t.row,t.col,i):[],this._bracketMatch=this._config.bracketMatching?Vt(e,t):null;const n=this._wm.visualRows.length;if(this._spacerEl.style.height=`${n*s}px`,this._config.wordWrap)this._spacerEl.style.width="",this._vpEl.style.width="";else{const g=e.reduce((M,m)=>Math.max(M,m.length),0),k=this._config.showGutter?this._config.gutterWidth:0,b=Math.max(this._editorEl.clientWidth,k+ie+Math.ceil(g*Q)+He+64);this._spacerEl.style.width=`${b}px`,this._vpEl.style.width=`${b}px`}const o=this._editorEl.scrollTop,a=this._editorEl.clientHeight,l=Math.max(0,Math.floor(o/s)-De),c=Math.min(n-1,Math.ceil((o+a)/s)+De);this._vpEl.style.transform=`translateY(${l*s}px)`;const d=ee(this._wm,t.row,t.col),u=new Map;if(this._snippetSession)for(let g=this._snippetSession.idx+1;g<this._snippetSession.stops.length;g++){const k=this._snippetSession.stops[g],b=ee(this._wm,k.row,k.col),M=u.get(b.visRow)??[];M.push(b.colInSeg),u.set(b.visRow,M)}const h=[],_=[];for(const g of this._remotePeers.values())g.cursor&&h.push({row:g.cursor.row,col:g.cursor.col,name:g.name,color:g.color}),g.selection&&_.push({from:g.selection.from,to:g.selection.to,color:g.color});let y="";for(let g=l;g<=c;g++){const k=this._wm.visualRows[g];k&&(y+=yi({vr:k,visIdx:g,curVisRow:d.visRow,curColInSeg:d.colInSeg,docSel:i,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,snippetStopCols:u.get(g)??[],foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&Kt(e,k.docLine),wm:this._wm,tokenCache:this._tokenCache,remoteCursors:h,remoteSels:_,opts:{tokeniserOpts:{language:this._config.language,extraKeywords:new Set(this._config.extraKeywords),extraTypes:new Set(this._config.extraTypes)},showIndentGuides:this._config.showIndentGuides,highlightActiveLine:this._config.highlightActiveLine,charWidth:Q,codePaddingLeft:ie,tabSize:this._config.tabSize,lineHeight:s,renderWhitespace:this._config.renderWhitespace}}))}if(this._vpEl.innerHTML=y,this._updateStatusBar(),this._updateMinimap(),this._config.placeholder){const g=this._tab.doc.length===1&&this._tab.doc[0]==="";this._placeholderEl.style.display=g?"":"none"}else this._placeholderEl.style.display="none"}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:e,doc:t,undoStack:i,redoStack:s}=this._tab,n=this._config.language,o={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},a=h=>this._statusBar.querySelector(h);a(".sl-sb-lang").textContent=`⬡ ${o[n]??n}`,a(".sl-sb-pos").textContent=`Ln ${e.row+1}, Col ${e.col+1}`,a(".sl-sb-lines").textContent=`${t.length.toLocaleString()} lines`;const l=$t(this._tab),c=a(".sl-sb-sel"),d=a(".sl-sb-sel-sep");c.textContent=l?`${l.toLocaleString()} selected`:"",d.style.display=l?"":"none",a(".sl-sb-undo").textContent=`↩${i.length} ↪${s.length}`;const u=a(".sl-sb-mc");this._extraCursors.length?(u.style.display="",a(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):u.style.display="none"}_updateMinimap(){if(!this._config.showMinimap)return;const e=this._minimapWrap.clientWidth,t=this._minimapWrap.clientHeight;if(!e||!t)return;const i=this._tab.doc,s=i.length,n=Math.min(window.devicePixelRatio||1,2),o=this._config.lineHeight,{mmScroll:a,sliderTop:l,sliderHeight:c}=Me(s,this._editorEl.scrollTop,this._editorEl.clientHeight,t,o),d=a/2,u=Math.floor(d),h=Math.ceil(t/2)+2,_=Math.min(s,u+h),y=(_-u)*2,g=(d-u)*2,k=Math.round(e*n),b=Math.round(y*n);(this._mmCanvas.width!==k||this._mmCanvas.height!==b)&&(this._mmCanvas.width=k,this._mmCanvas.height=b,this._mmCanvas.style.width=`${e}px`,this._mmCanvas.style.height=`${y}px`),this._mmCanvas.style.transform=`translateY(${-g}px)`,Si({canvas:this._mmCanvas,doc:i,firstLine:u,lastLine:_,subPx:g,wrapperWidth:e,canvasHeight:y,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:l,sliderHeight:c,colors:this._mmColors,getCssVar:M=>me(M,this._host),dpr:n}),this._mmSlider.style.top=`${Math.max(0,Math.min(t-c,l))}px`,this._mmSlider.style.height=`${c}px`}_rebuildWrapMap(){let e;if(this._config.wordWrap){const t=this._config.showGutter?this._config.gutterWidth:0,i=this._editorEl.clientWidth;if(i>0){const s=i-t-ie-He;e=Math.max(20,Math.floor(s/Q))}else e=this._config.wrapColumn}else e=9999;this._wm=Ot(this._tab.doc,e,this._config.wordWrap,this._foldedLines)}_scrollIntoView(){const e=this._config.lineHeight;this._spacerEl.style.height=`${this._wm.visualRows.length*e}px`;const t=this._tab.cur,s=ee(this._wm,t.row,t.col).visRow*e,n=s+e,o=this._editorEl.scrollTop,a=this._editorEl.clientHeight,l=e*3;s<o+l?this._editorEl.scrollTop=Math.max(0,s-l):n>o+a-l&&(this._editorEl.scrollTop=n-a+l)}_focusInput(){this._inputEl.style.pointerEvents="auto",this._inputEl.focus(),this._inputEl.style.pointerEvents="none"}_insertStr(e,t){var d,u;const i=Date.now();(!t||i-this._lastInputTime>this._config.undoBatchMs)&&j(this._tab,this._config.maxUndoHistory),this._lastInputTime=i,this._tab.sel&&(this._tab.cur=oe(this._tab));const{doc:s,cur:n}=this._tab,o=e.split(`
|
|
543
|
-
`),a=s[n.row]??"",l=a.slice(0,n.col),c=a.slice(n.col);if(o.length===1)s[n.row]=l+e+c,n.col+=e.length;else{const h=[l+o[0]];for(let _=1;_<o.length-1;_++)h.push(o[_]);h.push(o[o.length-1]+c),s.splice(n.row,1,...h),n.row+=o.length-1,n.col=o[o.length-1].length}this._tokenCache.invalidateLine(n.row,(this._wm.segments[n.row]??[""]).length),this._tab.dirty=!0,(u=(d=this._config).onChange)==null||u.call(d,$(s))}_doBackspace(){var i;if(j(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=oe(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:e,cur:t}=this._tab;if(t.col>0){const s=e[t.row]??"",n=s.slice(0,t.col),o=n.length>=2&&n.endsWith(" ")&&!n.trim()?2:1;e[t.row]=s.slice(0,t.col-o)+s.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 s=(e[t.row-1]??"").length;e[t.row-1]+=e[t.row]??"",e.splice(t.row,1),t.row--,t.col=s,this._tokenCache.clear()}this._tab.dirty=!0}_doEnter(){j(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=oe(this._tab));const{doc:e,cur:t}=this._tab,i=e[t.row]??"",s=i.slice(0,t.col),n=i.slice(t.col),o=et(i),a=s.trimEnd().endsWith("{")?ue(this._config.tabSize):"";e[t.row]=s,s.trimEnd().endsWith("{")&&n.trimStart()==="}"?e.splice(t.row+1,0,o+a,o+n):e.splice(t.row+1,0,o+a+n),t.row++,t.col=o.length+a.length,this._tokenCache.clear(),this._tab.dirty=!0}_doDelete(){var s;if(j(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=oe(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,((s=this._wm.segments[t.row])==null?void 0:s.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(){var i,s,n,o;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(),(s=(i=this._config).onCursorChange)==null||s.call(i,{...this._tab.cur}),(o=(n=this._config).onSelectionChange)==null||o.call(n,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab()}_doCopy(){var t;const e=Ue(this._tab);e&&((t=navigator.clipboard)==null||t.writeText(e).catch(()=>{}))}_doCut(){var t,i,s,n,o,a,l;const e=Ue(this._tab);e&&((t=navigator.clipboard)==null||t.writeText(e).catch(()=>{}),j(this._tab,this._config.maxUndoHistory),this._tab.cur=oe(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(s=(i=this._config).onChange)==null||s.call(i,$(this._tab.doc)),(o=(n=this._config).onCursorChange)==null||o.call(n,{...this._tab.cur}),(l=(a=this._config).onSelectionChange)==null||l.call(a,null),this._broadcastCursorToCollab())}_toggleComment(){var n,o,a,l;j(this._tab,this._config.maxUndoHistory);const e=this._getSelRows(),t=this._config.lineCommentToken||It[this._config.language]||"";if(!t)return;const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.every(c=>(this._tab.doc[c]??"").trimStart().startsWith(t));e.forEach(c=>{var u;const d=this._tab.doc[c]??"";this._tab.doc[c]=s?d.replace(new RegExp(`^(\\s*)${i}\\s?`),"$1"):d.replace(/^(\s*)/,`$1${t} `),this._tokenCache.invalidateLine(c,((u=this._wm.segments[c])==null?void 0:u.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(o=(n=this._config).onChange)==null||o.call(n,$(this._tab.doc)),(l=(a=this._config).onCursorChange)==null||l.call(a,{...this._tab.cur}),this._broadcastCursorToCollab()}_duplicateLine(){var t,i,s,n;j(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,$(this._tab.doc)),(n=(s=this._config).onCursorChange)==null||n.call(s,{...this._tab.cur}),this._broadcastCursorToCollab()}_deleteLine(){var i,s,n,o;j(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,A(this._tab),this._rebuildWrapMap(),this._render(),(s=(i=this._config).onChange)==null||s.call(i,$(this._tab.doc)),(o=(n=this._config).onCursorChange)==null||o.call(n,{...this._tab.cur}),this._broadcastCursorToCollab()}_indentSel(){var t,i,s,n;if(!this._tab.sel){this._insertStr(ue(this._config.tabSize),!1);return}j(this._tab,this._config.maxUndoHistory);const e=ue(this._config.tabSize);this._getSelRows().forEach(o=>{var a;this._tab.doc[o]=e+(this._tab.doc[o]??""),this._tokenCache.invalidateLine(o,((a=this._wm.segments[o])==null?void 0:a.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,$(this._tab.doc)),(n=(s=this._config).onCursorChange)==null||n.call(s,{...this._tab.cur}),this._broadcastCursorToCollab()}_unindentSel(){var t,i,s,n;j(this._tab,this._config.maxUndoHistory);const e=this._config.tabSize;this._getSelRows().forEach(o=>{var l;const a=this._tab.doc[o]??"";a.startsWith(ue(e))?this._tab.doc[o]=a.slice(e):a.startsWith(" ")&&(this._tab.doc[o]=a.slice(1)),this._tokenCache.invalidateLine(o,((l=this._wm.segments[o])==null?void 0:l.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,$(this._tab.doc)),(n=(s=this._config).onCursorChange)==null||n.call(s,{...this._tab.cur}),this._broadcastCursorToCollab()}_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=J(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,s=this._config.showGutter?this._config.gutterWidth:0,n=e.clientX-t.left-s-ie,o=this._config.lineHeight,a=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(i/o))),l=Math.max(0,Math.min((((c=this._wm.visualRows[a])==null?void 0:c.text)??"").length,Math.round(n/Q)));return pe(this._wm,a,l)}_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=ai(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=di(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()},Et)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",s=this._config.language==="css",{prefix:n,start:o}=gi(i,e.col,s);this._acPrefix=n,this._acStartCol=o;const a=[];if(this._config.emmet){const c=nt(i,e.col);if(c){const d=st(c.abbr);if(d){this._emmetAcStartCol=c.start;const u=d.replace(/\n/g,"↵ ").slice(0,60);a.push({label:c.abbr,kind:"emmet",detail:u,body:d})}}}const l=n.length>=this._config.autocompletePrefixLength?fi(t,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},e.row,e.col):[];if(this._acItems=[...a,...l],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=l=>{switch(l){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 s=this._acItems.map((l,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 ${l.kind}">${e(l.kind)}</span><span class="sl-ac-label">${l.label}</span><span class="sl-ac-detail">${l.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">${s}</div>`+n,this._acPopup.style.display="flex",this._posAcPopup();const o=this._acPopup.querySelector(".sl-ac-list"),a=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(o&&a){const l=a.offsetTop,c=l+a.offsetHeight;c>o.scrollTop+o.clientHeight?o.scrollTop=c-o.clientHeight:l<o.scrollTop&&(o.scrollTop=l)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(l=>{l.addEventListener("mousedown",c=>{c.preventDefault(),this._acSel=parseInt(l.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=ee(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,s=e.left+i+ie+this._acStartCol*Q,n=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,a=!!this._acPopup.querySelector(".sl-ac-desc")?620:300,l=Math.min(this._acItems.length*28+8,320),c=n+l>window.innerHeight-16;this._acPopup.style.left=`${Math.min(s,window.innerWidth-a-16)}px`,this._acPopup.style.top=`${c?n-this._config.lineHeight-2-l:n}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){j(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._emmetAcStartCol);return}if(e.body){j(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(),A(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]??"",s=nt(i,e.col);if(!s){this._emmetExpanded=null;return}const n=st(s.abbr);if(!n){this._emmetExpanded=null;return}this._emmetExpanded={abbr:s.abbr,result:n,start:s.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{abbr:e,result:t,start:i}=this._emmetExpanded;return j(this._tab,this._config.maxUndoHistory),this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(t,i),!0}_allCompletions(){return[...this._config.replaceBuiltins?[]:ti(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]??"",s=ii(i,e.col,this._allCompletions());if(!s){this._snippetExpanded=null;return}this._snippetExpanded={snippet:s.snippet,start:s.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:e,start:t}=this._snippetExpanded;return e.body?(j(this._tab,this._config.maxUndoHistory),this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t),!0):!1}_expandBodyAt(e,t){var b,M,m,x,f,I;const{doc:i,cur:s}=this._tab,n=s.row,o=i[s.row]??"",a=o.slice(0,t),l=o.slice(s.col),c=et(o),d=e.split(`
|
|
544
|
-
`).map((T,L)=>L===0?T:c+T),u=d.join(`
|
|
545
|
-
`),h=[],_=/\$(\d+)/g;let y;for(;(y=_.exec(u))!==null;){const T=parseInt(y[1],10),K=u.slice(0,y.index).split(`
|
|
546
|
-
`),N=K.length-1,W=K[N].length,F=(K[N].match(/\$\d+/g)??[]).join("").length,z=n+N,S=(N===0?t:c.length)+(W-F);h.push({n:T,row:z,col:S})}h.sort((T,L)=>T.n===0?1:L.n===0?-1:T.n-L.n);const g=d.map(T=>T.replace(/\$\d+/g,"")),k=g.length===1?[a+g[0]+l]:[a+g[0],...g.slice(1,-1),g[g.length-1]+l];i.splice(s.row,1,...k),h.length>0?(this._snippetSession={stops:h.map(T=>({row:T.row,col:T.col})),idx:0},s.row=h[0].row,s.col=h[0].col):(this._snippetSession=null,s.row+=k.length-1,s.col=(k[k.length-1]??"").length-l.length),this._tokenCache.clear(),this._tab.dirty=!0,this._tab.sel=null,this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(M=(b=this._config).onCursorChange)==null||M.call(b,{...this._tab.cur}),(x=(m=this._config).onSelectionChange)==null||x.call(m,null),this._broadcastCursorToCollab(),(I=(f=this._config).onChange)==null||I.call(f,$(this._tab.doc))}_openThemePicker(){var t;const e=this._themeManager.all;this._themePanel.innerHTML=`
|
|
547
|
-
<div class="sl-theme-header">
|
|
548
|
-
<div class="sl-theme-title">Color Theme</div>
|
|
549
|
-
<div class="sl-theme-close">✕</div>
|
|
550
|
-
</div>
|
|
551
|
-
<div class="sl-theme-list">
|
|
552
|
-
${e.map(i=>`
|
|
553
|
-
<div class="sl-theme-item${i.id===this._themeManager.activeId?" sl-active":""}" data-id="${i.id}">
|
|
554
|
-
<div class="sl-theme-swatch">
|
|
555
|
-
${i.tokens.bg0?`<span style="background:${i.tokens.bg0}"></span>`:""}
|
|
556
|
-
<span style="background:${i.tokens.accent}"></span>
|
|
557
|
-
<span style="background:${i.tokens.tokStr}"></span>
|
|
558
|
-
<span style="background:${i.tokens.tokFn}"></span>
|
|
559
|
-
</div>
|
|
560
|
-
<div>
|
|
561
|
-
<div class="sl-theme-name">${i.name}<span class="sl-theme-tag${i.light?" sl-light":""}">${i.light?"Light":"Dark"}</span></div>
|
|
562
|
-
<div class="sl-theme-desc">${i.description}</div>
|
|
563
|
-
</div>
|
|
564
|
-
<div class="sl-theme-check">✓</div>
|
|
565
|
-
</div>
|
|
566
|
-
`).join("")}
|
|
567
|
-
</div>
|
|
568
|
-
`,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 s=i.dataset.id??"";this.setTheme(s),this._themePanel.querySelectorAll(".sl-theme-item").forEach(n=>n.classList.remove("sl-active")),i.classList.add("sl-active")})})}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",this._onFoldBtnClick),this._editorEl.addEventListener("mousedown",e=>{var i,s,n,o;if(e.button!==0)return;e.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",e.altKey||(ot(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 a=this._tab.doc[t.row]??"",l=ye(a,t.col,this._isWordChar.bind(this)),c=ve(a,t.col,this._isWordChar.bind(this));l!==c?(this._tab.sel={ar:t.row,ac:l,fr:t.row,fc:c},this._tab.cur.col=c):this._tab.sel=null}else{if(e.altKey&&this._config.multiCursor){rt(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}}A(this._tab),this._render(),(s=(i=this._config).onCursorChange)==null||s.call(i,{...this._tab.cur}),(o=(n=this._config).onSelectionChange)==null||o.call(n,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab()}),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,A(this._tab),this._render(),this._broadcastCursorToCollab()}),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(),A(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,a,l,c,d,u,h,_,y,g,k,b,M,m,x,f,I,T,L,K,N,W,F,z,S,ne,R,q,X,Z,v,w,E,B,G,te,ut,ft,gt,bt,_t,mt,yt;const t=e.ctrlKey||e.metaKey,i=e.shiftKey,s=e.altKey,n=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(s&&(e.key==="z"||e.key==="Z"||e.key==="Ω")){e.preventDefault(),this._toggleWrap();return}if(t&&e.key==="z"&&!i){e.preventDefault(),n||this.undo();return}if(t&&(e.key==="y"||i&&e.key==="z")){e.preventDefault(),n||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(),n||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(),!n&&this._config.multiCursor&&this._ctrlD();return}if(t&&i&&e.key==="d"){e.preventDefault(),n||this._duplicateLine();return}if(t&&e.key==="/"){e.preventDefault(),n||this._toggleComment();return}if(t&&e.key==="k"){e.preventDefault(),n||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,ot(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render(),(a=(o=this._config).onCursorChange)==null||a.call(o,{...this._tab.cur}),(c=(l=this._config).onSelectionChange)==null||c.call(l,null),this._broadcastCursorToCollab();return}if(n){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 P=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=P.row,this._tab.cur.col=P.col,this._tab.sel=null,A(this._tab),this._scrollIntoView(),this._render(),(u=(d=this._config).onCursorChange)==null||u.call(d,{...this._tab.cur}),(_=(h=this._config).onSelectionChange)==null||_.call(h,null),this._broadcastCursorToCollab()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const P=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=P.row,this._tab.cur.col=P.col,this._tab.sel=null,A(this._tab),this._scrollIntoView(),this._render(),(g=(y=this._config).onCursorChange)==null||g.call(y,{...this._tab.cur}),(b=(k=this._config).onSelectionChange)==null||b.call(k,null),this._broadcastCursorToCollab()}return}if(!i&&this._emmetAccept()||!i&&this._snippetAccept())return;i?this._unindentSel():this._indentSel(),A(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render(),(m=(M=this._config).onCursorChange)==null||m.call(M,{...this._tab.cur}),(f=(x=this._config).onSelectionChange)==null||f.call(x,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){this._snippetSession=null;const P=ri(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors);this._tab.doc=P.doc,this._tab.cur.row=P.primaryRow,this._tab.cur.col=P.primaryCol,this._extraCursors=P.extraCursors,this._mc.cursors=P.extraCursors}else{if(this._snippetSession){const P=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===P.row&&this._tab.cur.col>P.col){for(let U=this._snippetSession.idx+1;U<this._snippetSession.stops.length;U++){const re=this._snippetSession.stops[U];re.row===P.row&&re.col>=this._tab.cur.col&&re.col--}P.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(T=(I=this._config).onChange)==null||T.call(I,$(this._tab.doc)),(K=(L=this._config).onCursorChange)==null||K.call(L,{...this._tab.cur}),(W=(N=this._config).onSelectionChange)==null||W.call(N,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab();return}if(e.key==="Delete"){e.preventDefault(),this._snippetSession=null,this._doDelete(),this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(z=(F=this._config).onChange)==null||z.call(F,$(this._tab.doc)),(ne=(S=this._config).onCursorChange)==null||ne.call(S,{...this._tab.cur}),(q=(R=this._config).onSelectionChange)==null||q.call(R,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab();return}if(e.key==="Enter"){e.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(Z=(X=this._config).onChange)==null||Z.call(X,$(this._tab.doc)),(w=(v=this._config).onCursorChange)==null||w.call(v,{...this._tab.cur}),(B=(E=this._config).onSelectionChange)==null||B.call(E,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab();return}if(!t&&!s&&this._config.autoClosePairs[e.key]){e.preventDefault(),j(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=oe(this._tab));const{doc:P,cur:U}=this._tab,re=P[U.row]??"";P[U.row]=re.slice(0,U.col)+e.key+this._config.autoClosePairs[e.key]+re.slice(U.col),U.col++,this._tokenCache.invalidateLine(U.row,((G=this._wm.segments[U.row])==null?void 0:G.length)??1),this._tab.dirty=!0,this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(ut=(te=this._config).onChange)==null||ut.call(te,$(this._tab.doc)),(gt=(ft=this._config).onCursorChange)==null||gt.call(ft,{...this._tab.cur}),(_t=(bt=this._config).onSelectionChange)==null||_t.call(bt,null),this._broadcastCursorToCollab();return}if(!t&&!s&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:P,cur:U}=this._tab;if((P[U.row]??"")[U.col]===e.key){e.preventDefault(),U.col++,A(this._tab),this._scrollIntoView(),this._render(),(yt=(mt=this._config).onCursorChange)==null||yt.call(mt,{...this._tab.cur}),this._broadcastCursorToCollab();return}}if(i&&s&&!t&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._duplicateLines(e.key==="ArrowDown");return}if(s&&!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 _,y,g,k,b,M;const{doc:s,cur:n}=this._tab,o=this._config.lineHeight,a=e.metaKey,l=e.ctrlKey,c=e.altKey,d=(m,x)=>{if(i){this._tab.sel||(this._tab.sel={ar:n.row,ac:n.col,fr:n.row,fc:n.col}),n.row=m,n.col=x;const f=this._tab.sel;f.fr=m,f.fc=x,f.ar===f.fr&&f.ac===f.fc&&(this._tab.sel=null)}else this._tab.sel=null,n.row=m,n.col=x},u=m=>{const f=(s[m]??"").search(/\S/);return f===-1||n.col===f?0:f},h=()=>({row:s.length-1,col:(s[s.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const m=J(this._tab.sel);n.row=m.fr,n.col=m.fc,this._tab.sel=null;break}if(a)d(n.row,(s[n.row]??"").length);else if(l||c){const m=s[n.row]??"";if(n.col>=m.length)n.row<s.length-1&&d(n.row+1,0);else{const x=this._wordSkipRight(m,n.col);d(n.row,x)}}else n.col<(s[n.row]??"").length?d(n.row,n.col+1):n.row<s.length-1&&d(n.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const m=J(this._tab.sel);n.row=m.ar,n.col=m.ac,this._tab.sel=null;break}if(a)d(n.row,u(n.row));else if(l||c)if(n.col===0)n.row>0&&d(n.row-1,(s[n.row-1]??"").length);else{const m=this._wordSkipLeft(s[n.row]??"",n.col);d(n.row,m)}else n.col>0?d(n.row,n.col-1):n.row>0&&d(n.row-1,(s[n.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),a){const m=h();d(m.row,m.col)}else if(this._config.wordWrap){const m=ee(this._wm,n.row,n.col),x=Math.min(this._wm.visualRows.length-1,m.visRow+1),f=pe(this._wm,x,Math.min(m.colInSeg,(((_=this._wm.visualRows[x])==null?void 0:_.text)??"").length));d(f.row,f.col)}else{const m=Math.min(s.length-1,n.row+1);d(m,Math.min(n.col,(s[m]??"").length))}break;case"ArrowUp":if(e.preventDefault(),a)d(0,0);else if(this._config.wordWrap){const m=ee(this._wm,n.row,n.col),x=Math.max(0,m.visRow-1),f=pe(this._wm,x,Math.min(m.colInSeg,(((y=this._wm.visualRows[x])==null?void 0:y.text)??"").length));d(f.row,f.col)}else{const m=Math.max(0,n.row-1);d(m,Math.min(n.col,(s[m]??"").length))}break;case"Home":e.preventDefault(),l?d(0,0):d(n.row,u(n.row));break;case"End":if(e.preventDefault(),l){const m=h();d(m.row,m.col)}else d(n.row,(s[n.row]??"").length);break;case"PageDown":e.preventDefault();{const m=Math.max(1,Math.floor(this._editorEl.clientHeight/o)-1),x=Math.min(s.length-1,n.row+m);d(x,Math.min(n.col,(s[x]??"").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),x=Math.max(0,n.row-m);d(x,Math.min(n.col,(s[x]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-o;break}default:return}A(this._tab),this._scrollIntoView(),this._acHide(),(k=(g=this._config).onCursorChange)==null||k.call(g,{...this._tab.cur}),(M=(b=this._config).onSelectionChange)==null||M.call(b,this._tab.sel?{...this._tab.sel}:null),this._broadcastCursorToCollab(),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 s=e.length;for(;i<s&&/\s/.test(e[i]);)i++;if(i>=s)return i;if(/\w/.test(e[i]))for(;i<s&&/\w/.test(e[i]);)i++;else for(;i<s&&/[^\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 l,c,d,u;const{doc:t,cur:i}=this._tab,s=this._tab.sel;let n=i.row,o=i.row;if(s){const h=J(s);n=h.ar,o=h.fr,h.fc===0&&h.fr>h.ar&&o--}j(this._tab,this._config.maxUndoHistory);const a=t.slice(n,o+1);e?(t.splice(o+1,0,...a),i.row+=a.length,s&&(s.ar+=a.length,s.fr+=a.length)):t.splice(n,0,...a),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(c=(l=this._config).onChange)==null||c.call(l,$(this._tab.doc)),(u=(d=this._config).onCursorChange)==null||u.call(d,{...this._tab.cur}),this._broadcastCursorToCollab()}_moveLines(e){var a,l,c,d;const{doc:t,cur:i}=this._tab,s=this._tab.sel;let n=i.row,o=i.row;if(s){const u=J(s);n=u.ar,o=u.fr,u.fc===0&&u.fr>u.ar&&o--}if(e){if(n===0)return;j(this._tab,this._config.maxUndoHistory);const u=t.splice(n,o-n+1);t.splice(n-1,0,...u),i.row--,s&&(s.ar--,s.fr--)}else{if(o>=t.length-1)return;j(this._tab,this._config.maxUndoHistory);const u=t.splice(n,o-n+1);t.splice(n+1,0,...u),i.row++,s&&(s.ar++,s.fr++)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(l=(a=this._config).onChange)==null||l.call(a,$(this._tab.doc)),(d=(c=this._config).onCursorChange)==null||d.call(c,{...this._tab.cur}),this._broadcastCursorToCollab()}_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 y,g,k;if(!this._config.hover)return;const i=this._editorEl.getBoundingClientRect(),s=t-i.top+this._editorEl.scrollTop,n=this._config.showGutter?this._config.gutterWidth:0,o=e-i.left-n-ie,a=this._config.lineHeight,l=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(s/a))),c=Math.max(0,Math.min((((y=this._wm.visualRows[l])==null?void 0:y.text)??"").length,Math.round(o/Q))),d=pe(this._wm,l,c),u=this._tab.doc[d.row]??"",h=bi(u,d.col);if(!h)return;let _=mi(h,this._config.language);if(!_){const b=this._config.completions.find(M=>M.label===h);b&&(b.description||b.detail)&&(_={title:b.label,type:b.detail,body:b.description??""})}if(!_){const b=(k=(g=this._config).provideHover)==null?void 0:k.call(g,{word:h,row:d.row,col:d.col,line:u,language:this._config.language,doc:this._tab.doc});b&&(_=b)}_&&this._showHoverTip(_,e,t)}_showHoverTip(e,t,i){const s=this._hoverTip;let n='<div class="sl-ht-sig">';n+=`<span class="sl-ht-title">${se(e.title)}</span>`,e.type&&(n+=`<code class="sl-ht-type">${se(e.type)}</code>`),n+="</div>",e.title&&e.body&&(n+='<div class="sl-ht-divider"></div>'),e.body&&(n+=`<div class="sl-ht-body">${se(e.body)}</div>`),s.innerHTML=n,s.style.display="block";const o=12,a=18,l=s.offsetWidth||300,c=s.offsetHeight||80;let d=t,u=i+a;u+c>window.innerHeight-o&&(u=i-c-8),d+l>window.innerWidth-o&&(d=window.innerWidth-l-o),d<o&&(d=o),s.style.left=`${d}px`,s.style.top=`${Math.max(o,u)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_onInput(e){var n,o,a,l;if(this._config.readOnly){e.target.value="";return}const t=e.target,i=t.value;if(t.value="",!i||i==="Ω")return;const s=i.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(s){if(this._extraCursors.length){this._snippetSession=null;const c=ni(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors,s);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=(n=this._config).onChange)==null||o.call(n,$(this._tab.doc))}else{const c=this._tab.cur.row,d=this._tab.cur.col;if(this._insertStr(s,!0),this._snippetSession){const u=this._snippetSession,h=u.stops[u.idx];if(this._tab.cur.row===h.row){const _=this._tab.cur.col-d;for(let y=u.idx+1;y<u.stops.length;y++){const g=u.stops[y];g.row===c&&g.col>=d&&(g.col+=_)}h.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(l=(a=this._config).onCursorChange)==null||l.call(a,{...this._tab.cur}),this._broadcastCursorToCollab()}}_ctrlD(){if(!this._config.multiCursor)return;const e=oi(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):(rt(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,s,n,o,a;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",l=>{l.key==="Enter"?l.shiftKey?this._navFind(-1):this._navFind(1):l.key==="Escape"&&this._closeFind(),l.stopPropagation()}),this._replaceInput.addEventListener("keydown",l=>{l.key==="Enter"?this._doReplaceOne():l.key==="Escape"&&this._closeFind(),l.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()),(s=this._findBar.querySelector(".sl-find-case"))==null||s.addEventListener("click",l=>{this._findCaseSensitive=!this._findCaseSensitive,l.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",l=>{this._findRegex=!this._findRegex,l.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()),(a=this._findBar.querySelector(".sl-replace-all"))==null||a.addEventListener("click",()=>this._doReplaceAll())}_doReplaceOne(){var e,t;this._findIdx<0||!this._findMatches.length||(j(this._tab,this._config.maxUndoHistory),this._tab.doc=li(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,$(this._tab.doc)))}_doReplaceAll(){var t,i;if(!this._findMatches.length)return;const e=this._findMatches.length;j(this._tab,this._config.maxUndoHistory),this._tab.doc=ci(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,$(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:s,sliderHeight:n}=Me(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=s&&i<=s+n?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,s=t.clientY-e.getBoundingClientRect().top,{sliderTop:n,sliderHeight:o}=Me(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);if(s>=n&&s<=n+o)this._mmDragMode="slider",this._mmSliderOffset=s-n,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const a=Ti(s,this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=a,this._mmDragStartY=t.clientY,this._mmDragStartScroll=a,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}const ce=new Map;class ht{constructor(e,t){p(this,"siteId");p(this,"_room");p(this,"_cbs",new Set);p(this,"_receive",e=>{for(const t of this._cbs)t(e)});this._room=e,this.siteId=t,ce.has(e)||ce.set(e,new Set),ce.get(e).add(this._receive)}send(e){const t=ce.get(this._room);t&&queueMicrotask(()=>{for(const i of t)i!==this._receive&&i(e)})}onMessage(e){return this._cbs.add(e),()=>this._cbs.delete(e)}close(){var e;(e=ce.get(this._room))==null||e.delete(this._receive),this._cbs.clear()}}class pt{constructor(e,t){p(this,"siteId");p(this,"_channel");p(this,"_cbs",new Set);this.siteId=t,this._channel=new BroadcastChannel(e),this._channel.onmessage=i=>{for(const s of this._cbs)s(i.data)}}send(e){try{this._channel.postMessage(e)}catch{}}onMessage(e){return this._cbs.add(e),()=>this._cbs.delete(e)}close(){this._channel.close(),this._cbs.clear()}}class Ei{constructor(e,t,i,s={}){p(this,"siteId");p(this,"_ws",null);p(this,"_baseUrl");p(this,"_cbs",new Set);p(this,"_reconnectTimer",null);p(this,"_pingTimer",null);p(this,"_closed",!1);p(this,"_attempt",0);p(this,"_queue",[]);p(this,"_opts");this.siteId=i;const n=e.replace(/\/$/,"");this._baseUrl=`${n}/${encodeURIComponent(t)}?site=${encodeURIComponent(i)}`,this._opts={onConnect:s.onConnect??(()=>{}),onDisconnect:s.onDisconnect??(()=>{}),onError:s.onError??(()=>{}),pingIntervalMs:s.pingIntervalMs??25e3,maxBackoffMs:s.maxBackoffMs??3e4},this._connect()}_connect(){this._closed||(this._ws=new WebSocket(this._baseUrl),this._ws.onopen=()=>{this._attempt=0;for(const e of this._queue)this._rawSend(e);this._queue=[],this._startPing(),this._opts.onConnect()},this._ws.onmessage=e=>{if(e.data!=="__pong__")try{const t=JSON.parse(e.data);for(const i of this._cbs)i(t)}catch{}},this._ws.onclose=()=>{if(this._stopPing(),this._closed){this._opts.onDisconnect(!1);return}this._opts.onDisconnect(!0),this._scheduleReconnect()},this._ws.onerror=e=>{var t;this._opts.onError(e),(t=this._ws)==null||t.close()})}_scheduleReconnect(){const e=Math.min(250*2**this._attempt,this._opts.maxBackoffMs);this._attempt++,this._reconnectTimer=setTimeout(()=>this._connect(),e)}_startPing(){this._opts.pingIntervalMs<=0||(this._pingTimer=setInterval(()=>{var e;((e=this._ws)==null?void 0:e.readyState)===WebSocket.OPEN&&this._ws.send("__ping__")},this._opts.pingIntervalMs))}_stopPing(){this._pingTimer!==null&&(clearInterval(this._pingTimer),this._pingTimer=null)}send(e){var t;((t=this._ws)==null?void 0:t.readyState)===WebSocket.OPEN?this._rawSend(e):this._queue.push(e)}_rawSend(e){try{this._ws.send(JSON.stringify(e))}catch{}}onMessage(e){return this._cbs.add(e),()=>this._cbs.delete(e)}close(){var e;this._closed=!0,this._reconnectTimer!==null&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null),this._stopPing(),(e=this._ws)==null||e.close(),this._cbs.clear()}get connectionState(){var e;switch((e=this._ws)==null?void 0:e.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"open";case WebSocket.CLOSING:return"closing";default:return"closed"}}get queuedMessageCount(){return this._queue.length}}function Ii(r,e={}){const t=e.siteId??crypto.randomUUID(),i=e.room??"syncline-default",s=new ae(t);let n;const o=e.transport??"local";o==="broadcastchannel"?n=new pt(i,t):typeof o=="function"?n=new o(i,t):n=new ht(i,t);const a=new fe(r,s,n,{name:e.name,onPeersChange:e.onPeersChange});return{binding:a,doc:s,destroy(){a.destroy(),n.close()}}}function Li(r,e){return new dt(r,e)}C.AwarenessManager=Ae,C.BUILT_IN_THEMES=Xe,C.BroadcastChannelTransport=pt,C.CRDTBinding=fe,C.LocalTransport=ht,C.RGADocument=ae,C.ROOT_ID=D,C.SynclineEditor=dt,C.THEME_DRACULA=Ke,C.THEME_GITHUB_LIGHT=Ye,C.THEME_MONOKAI=Ve,C.THEME_SOLARIZED_LIGHT=Je,C.THEME_VR_DARK=qe,C.THEME_VSCODE_DARK=Ge,C.WebSocketTransport=Ei,C.charIdEq=de,C.charIdToStr=O,C.createCollabSession=Ii,C.createEditor=Li,C.diffText=Ie,C.siteColor=Be,C.svFromRecord=Ee,C.svToRecord=he,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
|
569
|
-
//# sourceMappingURL=syncline-editor.umd.js.map
|