koishi-plugin-codemirror 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -20,4 +20,4 @@ import{openBlock as vt,createElementBlock as Ut,createElementVNode as Zt,defineC
20
20
  \${}
21
21
  }
22
22
  }`,{label:"class",detail:"definition",type:"keyword"}),Qe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Qe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],U0=Df.concat([Qe("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Qe("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Qe("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Wa=new sp,zf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function $i(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),true}}const L0=["FunctionDeclaration"],N0={FunctionDeclaration:$i("function"),ClassDeclaration:$i("class"),ClassExpression:()=>true,EnumDeclaration:$i("constant"),TypeAliasDeclaration:$i("type"),NamespaceDeclaration:$i("namespace"),VariableDefinition(n,e){n.matchContext(L0)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function Ef(n,e){let t=Wa.get(e);if(t)return t;let i=[],s=true;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(re.IncludeAnonymous).iterate(o=>{if(s)s=false;else if(o.name){let l=N0[o.name];if(l&&l(o,r)||zf.has(o.name))return false}else if(o.to-o.from>8192){for(let l of Ef(n,o.node))i.push(l);return false}}),Wa.set(e,i),i}const Xa=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,jf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function I0(n){let e=oe(n.state).resolveInner(n.pos,-1);if(jf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Xa.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)zf.has(s.name)&&(i=i.concat(Ef(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Xa}}const zt=Ii.define({name:"javascript",parser:Ig.configure({props:[Zo.add({IfStatement:Di({except:/^\s*({|else\b)/}),TryStatement:Di({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:kp,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:Sp({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Di({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Co.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Ac,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),_f={test:n=>/^JSX/.test(n.name),facet:vc({commentTokens:{block:{open:"{/*",close:"*/}"}}})},G0=zt.configure({dialect:"ts"},"typescript"),F0=zt.configure({dialect:"jsx",props:[$o.add(n=>n.isTop?[_f]:void 0)]}),H0=zt.configure({dialect:"jsx ts",props:[$o.add(n=>n.isTop?[_f]:void 0)]},"typescript");let Vf=n=>({label:n,type:"keyword"});const Bf="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Vf),K0=Bf.concat(["declare","implements","private","protected","public"].map(Vf));function J0(n={}){let e=n.jsx?n.typescript?H0:F0:n.typescript?G0:zt,t=n.typescript?U0.concat(K0):Df.concat(Bf);return new Tc(e,[zt.data.of({autocomplete:Fg(jf,vf(t))}),zt.data.of({autocomplete:I0}),n.jsx?i1:[]])}function e1(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function qa(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const t1=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),i1=v.inputHandler.of((n,e,t,i,s)=>{if((t1?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!zt.isActiveAt(n.state,e,-1))return false;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var h;let{head:c}=a,f=oe(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:"</>"}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,O=d.parent;if(O&&d.from==c-2&&((u=qa(o.doc,O.firstChild,c))||((h=O.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let m=`${u}>`;return{range:y.cursor(c+m.length,-1),changes:{from:c,insert:m}}}}else if(i==">"){let d=e1(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=qa(o.doc,d,c)))return{range:a,changes:{from:c,insert:`</${u}>`}}}}return{range:a}});return l.changes.empty?false:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:true})]),true)}),n1=Po({String:p.string,Number:p.number,"True False":p.bool,PropertyName:p.propertyName,Null:p.null,",":p.separator,"[ ]":p.squareBracket,"{ }":p.brace}),s1=Fi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[n1],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),r1=Ii.define({name:"json",parser:s1.configure({props:[Zo.add({Object:Di({except:/^\s*\}/}),Array:Di({except:/^\s*\]/})}),Co.add({"Object Array":Ac})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function o1(){return new Tc(r1)}function U(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)Uf(n,arguments[e]);return n}function Uf(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Uf(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const Ya=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class di{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=false,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(Ya(l)):Ya,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return he(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=true,this;let t=oo(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ye(e);let s=this.normalize(t);for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,i){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=false;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:i}:(this.matches[r]++,l=true)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(di.prototype[Symbol.iterator]=function(){return this});const Lf={from:-1,to:-1,match:/.*/.exec("")},_o="gm"+(/x/.unicode==null?"":"u");class Nf{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=false,this.value=Lf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new If(e,t,i,s,r);this.re=new RegExp(t,_o+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=Os(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=Os(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=true,this}}}const sr=new WeakMap;class li{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=sr.get(e);if(!s||s.from>=i||s.to<=t){let l=new li(t,e.sliceString(t,i));return sr.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),sr.set(e,new li(o,r)),new li(t,r.slice(t-o,i-o))}}class If{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=false,this.value=Lf,this.matchPos=Os(e,s),this.re=new RegExp(t,_o+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=li.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=Os(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=true,this;this.flat=li.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Nf.prototype[Symbol.iterator]=If.prototype[Symbol.iterator]=function(){return this});function l1(n){try{return new RegExp(n,_o),true}catch{return false}}function Os(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function no(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=U("input",{class:"cm-textfield",name:"line",value:e}),i=U("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:ps.of(false)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},U("label",n.state.phrase("Go to line"),": ",t)," ",U("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=r,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let g=d/100;a&&(g=g*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*g)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let O=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),m=y.cursor(O.from+Math.max(0,Math.min(u,O.length)));n.dispatch({effects:[ps.of(false),v.scrollIntoView(m.from,{y:"center"})],selection:m}),n.focus()}return{dom:i}}const ps=R.define(),Da=le.define({create(){return true},update(n,e){for(let t of e.effects)t.is(ps)&&(n=t.value);return n},provide:n=>Li.from(n,e=>e?no:null)}),a1=n=>{let e=Ui(n,no);if(!e){let t=[ps.of(true)];n.state.field(Da,false)==null&&t.push(R.appendConfig.of([Da,h1])),n.dispatch({effects:t}),e=Ui(n,no)}return e&&e.dom.querySelector("input").select(),true},h1=v.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),c1={highlightWordAroundCursor:false,minSelectionLength:1,maxMatches:100,wholeWords:false},Gf=Z.define({combine(n){return st(n,c1,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function f1(n){let e=[m1,p1];return n&&e.push(Gf.of(n)),e}const u1=C.mark({class:"cm-selectionMatch"}),d1=C.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function za(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=I.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=I.Word)}function O1(n,e,t,i){return n(e.sliceDoc(t,t+1))==I.Word&&n(e.sliceDoc(i-1,i))==I.Word}const p1=te.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Gf),{state:t}=n,i=t.selection;if(i.ranges.length>1)return C.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return C.none;let a=t.wordAt(s.head);if(!a)return C.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return C.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(za(o,t,s.from,s.to)&&O1(o,t,s.from,s.to)))return C.none}else if(r=t.sliceDoc(s.from,s.to),!r)return C.none}let l=[];for(let a of n.visibleRanges){let h=new di(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||za(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(d1.range(c,f)):(c>=s.to||f<=s.from)&&l.push(u1.range(c,f)),l.length>e.maxMatches))return C.none}}return C.set(l)}},{decorations:n=>n.decorations}),m1=v.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),g1=({state:n,dispatch:e})=>{let{selection:t}=n,i=y.create(t.ranges.map(s=>n.wordAt(s.head)||y.cursor(s.head)),t.mainIndex);return i.eq(t)?false:(e(n.update({selection:i})),true)};function b1(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=false,l=new di(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new di(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=true}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const y1=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return g1({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return false;let s=b1(n,i);return s?(e(n.update({selection:n.selection.addRange(y.range(s.from,s.to),false),effects:v.scrollIntoView(s.to)})),true):false},bi=Z.define({combine(n){return st(n,{top:false,caseSensitive:false,literal:false,regexp:false,wholeWord:false,createPanel:e=>new A1(e),scrollToMatch:e=>v.scrollIntoView(e)})}});class Ff{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||l1(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
23
- `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new S1(this):new Q1(this)}getCursor(e,t=0,i){let s=e.doc?e:D.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Ht(this,s,t,i):Ft(this,s,t,i)}}class Hf{constructor(e){this.spec=e}}function Ft(n,e,t,i){return new di(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?x1(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function x1(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(ms(s,t-r))!=I.Word||e(gs(s,t-r))!=I.Word)&&(e(gs(s,i-r))!=I.Word||e(ms(s,i-r))!=I.Word))}class Q1 extends Hf{constructor(e){super(e)}nextMatch(e,t,i){let s=Ft(this.spec,e,i,e.doc.length).nextOverlapping();return s.done&&(s=Ft(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Ft(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Ft(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ft(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ht(n,e,t,i){return new Nf(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?w1(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ms(n,e){return n.slice(de(n,e,false),e)}function gs(n,e){return n.slice(e,de(n,e))}function w1(n){return(e,t,i)=>!i[0].length||(n(ms(i.input,i.index))!=I.Word||n(gs(i.input,i.index))!=I.Word)&&(n(gs(i.input,i.index+i[0].length))!=I.Word||n(ms(i.input,i.index+i[0].length))!=I.Word)}class S1 extends Hf{nextMatch(e,t,i){let s=Ht(this.spec,e,i,e.doc.length).next();return s.done&&(s=Ht(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Ht(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=Ht(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ht(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const en=R.define(),Vo=R.define(),at=le.define({create(n){return new rr(so(n).create(),null)},update(n,e){for(let t of e.effects)t.is(en)?n=new rr(t.value.create(),n.panel):t.is(Vo)&&(n=new rr(n.query,t.value?Bo:null));return n},provide:n=>Li.from(n,e=>e.panel)});function k1(n){var e;return((e=n.field(at,false))===null||e===void 0?void 0:e.panel)!=null}class rr{constructor(e,t){this.query=e,this.panel=t}}const P1=C.mark({class:"cm-searchMatch"}),$1=C.mark({class:"cm-searchMatch cm-searchMatch-selected"}),v1=te.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(at))}update(n){let e=n.state.field(at);(e!=n.startState.field(at)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return C.none;let{view:t}=this,i=new Qt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?$1:P1)})}return i.finish()}},{decorations:n=>n.decorations});function fn(n){return e=>{let t=e.state.field(at,false);return t&&t.query.spec.valid?n(e,t):Uo(e)}}const bs=fn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return false;let s=y.single(i.from,i.to),r=n.state.facet(bi);return n.dispatch({selection:s,effects:[No(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Jf(n),true}),ys=fn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return false;let r=y.single(s.from,s.to),o=n.state.facet(bi);return n.dispatch({selection:r,effects:[No(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Jf(n),true}),Z1=fn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?false:(n.dispatch({selection:y.create(t.map(i=>y.range(i.from,i.to))),userEvent:"select.search.matches"}),true)}),T1=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return false;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new di(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return false;l.value.from==i&&(o=r.length),r.push(y.range(l.value.from,l.value.to))}return e(n.update({selection:y.create(r,o),userEvent:"select.search.matches"})),true},Ea=fn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return false;let r=e.nextMatch(t,i,i);if(!r)return false;let o=[],l,a,h=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),h.push(v.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=y.single(r.from-c,r.to-c),h.push(No(n,r)),h.push(t.facet(bi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),true}),C1=fn((n,{query:e})=>{if(n.state.readOnly)return false;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return false;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:v.announce.of(i),userEvent:"input.replace.all"}),true});function Bo(n){return n.state.facet(bi).createPanel(n)}function so(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(bi);return new Ff({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Kf(n){let e=Ui(n,Bo);return e&&e.dom.querySelector("[main-field]")}function Jf(n){let e=Kf(n);e&&e==n.root.activeElement&&e.select()}const Uo=n=>{let e=n.state.field(at,false);if(e&&e.panel){let t=Kf(n);if(t&&t!=n.root.activeElement){let i=so(n.state,e.query.spec);i.valid&&n.dispatch({effects:en.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Vo.of(true),e?en.of(so(n.state,e.query.spec)):R.appendConfig.of(W1)]});return true},Lo=n=>{let e=n.state.field(at,false);if(!e||!e.panel)return false;let t=Ui(n,Bo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Vo.of(false)}),true},R1=[{key:"Mod-f",run:Uo,scope:"editor search-panel"},{key:"F3",run:bs,shift:ys,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:bs,shift:ys,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:Lo,scope:"editor search-panel"},{key:"Mod-Shift-l",run:T1},{key:"Mod-Alt-g",run:a1},{key:"Mod-d",run:y1,preventDefault:true}];class A1{constructor(e){this.view=e;let t=this.query=e.state.field(at).query.spec;this.commit=this.commit.bind(this),this.searchField=U("input",{value:t.search,placeholder:Ae(e,"Find"),"aria-label":Ae(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=U("input",{value:t.replace,placeholder:Ae(e,"Replace"),"aria-label":Ae(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=U("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=U("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=U("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return U("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=U("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>bs(e),[Ae(e,"next")]),i("prev",()=>ys(e),[Ae(e,"previous")]),i("select",()=>Z1(e),[Ae(e,"all")]),U("label",null,[this.caseField,Ae(e,"match case")]),U("label",null,[this.reField,Ae(e,"regexp")]),U("label",null,[this.wordField,Ae(e,"by word")]),...e.state.readOnly?[]:[U("br"),this.replaceField,i("replace",()=>Ea(e),[Ae(e,"replace")]),i("replaceAll",()=>C1(e),[Ae(e,"replace all")])],U("button",{name:"close",onclick:()=>Lo(e),"aria-label":Ae(e,"close"),type:"button"},["×"])])}commit(){let e=new Ff({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:en.of(e)}))}keydown(e){Jd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ys:bs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ea(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(en)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(bi).top}}function Ae(n,e){return n.state.phrase(e)}const Wn=30,Xn=/[\s\.,:;?!]/;function No(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Wn),o=Math.min(s,t+Wn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<Wn;a++)if(!Xn.test(l[a+1])&&Xn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Wn;a--)if(!Xn.test(l[a-1])&&Xn.test(l[a])){l=l.slice(0,a);break}}return v.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const M1=v.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),W1=[at,Tt.low(v1),M1],X1="#e5c07b",ja="#e06c75",q1="#56b6c2",Y1="#ffffff",Nn="#abb2bf",ro="#7d8799",D1="#61afef",z1="#98c379",_a="#d19a66",E1="#c678dd",j1="#21252b",Va="#2c313a",Ba="#282c34",or="#353a42",_1="#3E4451",Ua="#528bff",V1=v.theme({"&":{color:Nn,backgroundColor:Ba},".cm-content":{caretColor:Ua},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ua},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:_1},".cm-panels":{backgroundColor:j1,color:Nn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ba,color:ro,border:"none"},".cm-activeLineGutter":{backgroundColor:Va},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:or},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:or,borderBottomColor:or},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Va,color:Nn}}},{dark:true}),B1=an.define([{tag:p.keyword,color:E1},{tag:[p.name,p.deleted,p.character,p.propertyName,p.macroName],color:ja},{tag:[p.function(p.variableName),p.labelName],color:D1},{tag:[p.color,p.constant(p.name),p.standard(p.name)],color:_a},{tag:[p.definition(p.name),p.separator],color:Nn},{tag:[p.typeName,p.className,p.number,p.changed,p.annotation,p.modifier,p.self,p.namespace],color:X1},{tag:[p.operator,p.operatorKeyword,p.url,p.escape,p.regexp,p.link,p.special(p.string)],color:q1},{tag:[p.meta,p.comment],color:ro},{tag:p.strong,fontWeight:"bold"},{tag:p.emphasis,fontStyle:"italic"},{tag:p.strikethrough,textDecoration:"line-through"},{tag:p.link,color:ro,textDecoration:"underline"},{tag:p.heading,fontWeight:"bold",color:ja},{tag:[p.atom,p.bool,p.special(p.variableName)],color:_a},{tag:[p.processingInstruction,p.string,p.inserted],color:z1},{tag:p.invalid,color:Y1}]),U1=[V1,Ec(B1)];class L1{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Xt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(tn).markerFilter;r&&(s=r(s,i));let o=C.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?C.widget({widget:new tb(l),diagnostic:l}).range(l.from):C.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l,inclusive:true}).range(l.from,l.to)),true);return new Xt(o,t,Oi(o))}}function Oi(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new L1(s,r,o.diagnostic),false}),i}function N1(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(tn).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(eu))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function I1(n,e){return n.field(We,false)?e:e.concat(R.appendConfig.of(sb))}const eu=R.define(),Io=R.define(),tu=R.define(),We=le.define({create(){return new Xt(C.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Oi(t,n.selected.diagnostic,r)||Oi(t,null,r)}!t.size&&s&&e.state.facet(tn).autoPanel&&(s=null),n=new Xt(t,s,i)}for(let t of e.effects)if(t.is(eu)){let i=e.state.facet(tn).autoPanel?t.value.length?nn.open:null:n.panel;n=Xt.init(t.value,i,e.state)}else t.is(Io)?n=new Xt(n.diagnostics,t.value?nn.open:null,n.selected):t.is(tu)&&(n=new Xt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Li.from(n,e=>e.panel),v.decorations.from(n,e=>e.diagnostics)]}),G1=C.mark({class:"cm-lintRange cm-lintRange-active",inclusive:true});function F1(n,e,t){let{diagnostics:i}=n.state.field(We),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(s.push(c.diagnostic),r=Math.min(a,r),o=Math.max(h,o))});let l=n.state.facet(tn).tooltipFilter;return l&&(s=l(s,n.state)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:H1(n,s)}}}:null}function H1(n,e){return U("ul",{class:"cm-tooltip-lint"},e.map(t=>nu(n,t,false)))}const K1=n=>{let e=n.state.field(We,false);(!e||!e.panel)&&n.dispatch({effects:I1(n.state,[Io.of(true)])});let t=Ui(n,nn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),true},La=n=>{let e=n.state.field(We,false);return!e||!e.panel?false:(n.dispatch({effects:Io.of(false)}),true)},J1=n=>{let e=n.state.field(We,false);if(!e)return false;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?false:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:true}),true)},eb=[{key:"Mod-Shift-m",run:K1,preventDefault:true},{key:"F8",run:J1}],tn=Z.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},st(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function iu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function nu(n,e,t){var i;let s=t?iu(e.actions):[];return U("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},U("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=false,a=u=>{if(u.preventDefault(),l)return;l=true;let d=Oi(n.state.field(We).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),U("u",h.slice(c,c+1)),h.slice(c+1)];return U("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&U("div",{class:"cm-diagnosticSource"},e.source))}class tb extends dt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return U("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Na{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=nu(e,t,true),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nn{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)La(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=iu(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Oi(this.view.state.field(We).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=U("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=U("div",{class:"cm-panel-lint"},this.list,U("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>La(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(We).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(We),i=0,s=false,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new Na(this.view,a.diagnostic),this.items.splice(i,0,c),s=true):(c=this.items[h],h>i&&(this.items.splice(i,h-i),s=true)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=true,this.items.pop();this.items.length==0&&(this.items.push(new Na(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=true),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(We),i=Oi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:true,effects:tu.of(i)})}static open(e){return new nn(e)}}function ib(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function qn(n){return ib(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const nb=v.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:qn("#d11")},".cm-lintRange-warning":{backgroundImage:qn("orange")},".cm-lintRange-info":{backgroundImage:qn("#999")},".cm-lintRange-hint":{backgroundImage:qn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),sb=[We,v.decorations.compute([We],n=>{let{selected:e,panel:t}=n.field(We);return!e||!t||e.from==e.to?C.none:C.set([G1.range(e.from,e.to)])}),zO(F1,{hideOn:N1}),nb],rb=(()=>[IO(),HO(),mO(),um(),zp(),rO(),cO(),D.allowMultipleSelections.of(true),$p(),Ec(Vp,{fallback:true}),Fp(),A0(),V0(),ZO(),RO(),wO(),f1(),ws.of([...q0,...fg,...R1,...Qm,...Xp,...Yf,...eb])])(),Nt=(n,e)=>{const t=n.__vccOpts||n;for(const[i,s]of e)t[i]=s;return t},ob={},lb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},ab=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm4-4q-.425 0-.712-.288T7 16t.288-.712T8 15h8q.425 0 .713.288T17 16t-.288.713T16 17zm-4-4q-.425 0-.712-.288T3 12t.288-.712T4 11h16q.425 0 .713.288T21 12t-.288.713T20 13zm4-4q-.425 0-.712-.288T7 8t.288-.712T8 7h8q.425 0 .713.288T17 8t-.288.713T16 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5z"},null,-1),hb=[ab];function cb(n,e){return vt(),Ut("svg",lb,hb)}const fb=Nt(ob,[["render",cb]]),ub={},db={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Ob=Zt("path",{fill:"currentColor",d:"M11 6q-1.575 0-2.838.863T6.35 9.125q-.15.375-.487.563t-.738.112t-.638-.387t-.112-.663q.675-2.1 2.475-3.425T11 4q1.475 0 2.763.562T16 6.1V5q0-.425.288-.712T17 4t.713.288T18 5v4q0 .425-.288.713T17 10h-4q-.425 0-.712-.288T12 9t.288-.712T13 8h2q-.725-.9-1.737-1.45T11 6m0 12q-1.475 0-2.762-.562T6 15.9V17q0 .425-.288.713T5 18t-.712-.288T4 17v-4q0-.425.288-.712T5 12h4q.425 0 .713.288T10 13t-.288.713T9 14H7q.725.9 1.738 1.45T11 16q1.55 0 2.788-.825T15.6 13q.175-.4.513-.638t.762-.162q.425.1.625.45t.075.75q-.175.5-.413.938t-.562.862l3.7 3.7q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-3.7-3.7q-.9.675-1.962 1.038T11 18"},null,-1),pb=[Ob];function mb(n,e){return vt(),Ut("svg",db,pb)}const gb=Nt(ub,[["render",mb]]),bb={},yb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},xb=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm8-4q-.425 0-.712-.288T11 16t.288-.712T12 15h8q.425 0 .713.288T21 16t-.288.713T20 17zm0-4q-.425 0-.712-.288T11 12t.288-.712T12 11h8q.425 0 .713.288T21 12t-.288.713T20 13zm0-4q-.425 0-.712-.288T11 8t.288-.712T12 7h8q.425 0 .713.288T21 8t-.288.713T20 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5zm2.15 10.15l-2.8-2.8Q3.2 12.2 3.2 12t.15-.35l2.8-2.8q.25-.25.55-.125T7 9.2v5.6q0 .35-.3.475t-.55-.125"},null,-1),Qb=[xb];function wb(n,e){return vt(),Ut("svg",yb,Qb)}const Sb=Nt(bb,[["render",wb]]),kb={},Pb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},$b=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm8-4q-.425 0-.712-.288T11 16t.288-.712T12 15h8q.425 0 .713.288T21 16t-.288.713T20 17zm0-4q-.425 0-.712-.288T11 12t.288-.712T12 11h8q.425 0 .713.288T21 12t-.288.713T20 13zm0-4q-.425 0-.712-.288T11 8t.288-.712T12 7h8q.425 0 .713.288T21 8t-.288.713T20 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5zm-.15 10.15q-.25.25-.55.125T3 14.8V9.2q0-.35.3-.475t.55.125l2.8 2.8q.15.15.15.35t-.15.35z"},null,-1),vb=[$b];function Zb(n,e){return vt(),Ut("svg",Pb,vb)}const Tb=Nt(kb,[["render",Zb]]),Cb={},Rb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Ab=Zt("path",{fill:"currentColor",d:"M16.2 10H9.9q-1.575 0-2.738 1T6 13.5T7.163 16T9.9 17H16q.425 0 .713.288T17 18t-.288.713T16 19H9.9q-2.425 0-4.163-1.575T4 13.5t1.738-3.925T9.9 8h6.3l-1.9-1.9q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l3.6 3.6q.15.15.213.325t.062.375t-.062.375t-.213.325l-3.6 3.6q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7z"},null,-1),Mb=[Ab];function Wb(n,e){return vt(),Ut("svg",Rb,Mb)}const Xb=Nt(Cb,[["render",Wb]]),qb={},Yb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Db=Zt("path",{fill:"currentColor",d:"M4 5q-.425 0-.712-.288T3 4t.288-.712T4 3t.713.288T5 4t-.288.713T4 5m4 0q-.425 0-.712-.288T7 4t.288-.712T8 3t.713.288T9 4t-.288.713T8 5m4 0q-.425 0-.712-.288T11 4t.288-.712T12 3t.713.288T13 4t-.288.713T12 5m4 0q-.425 0-.712-.288T15 4t.288-.712T16 3t.713.288T17 4t-.288.713T16 5m4 0q-.425 0-.712-.288T19 4t.288-.712T20 3t.713.288T21 4t-.288.713T20 5M4 9q-.425 0-.712-.288T3 8t.288-.712T4 7t.713.288T5 8t-.288.713T4 9m16 0q-.425 0-.712-.288T19 8t.288-.712T20 7t.713.288T21 8t-.288.713T20 9M4 13q-.425 0-.712-.288T3 12t.288-.712T4 11t.713.288T5 12t-.288.713T4 13m16 0q-.425 0-.712-.288T19 12t.288-.712T20 11t.713.288T21 12t-.288.713T20 13M4 17q-.425 0-.712-.288T3 16t.288-.712T4 15t.713.288T5 16t-.288.713T4 17m16 0q-.425 0-.712-.288T19 16t.288-.712T20 15t.713.288T21 16t-.288.713T20 17M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19t.713.288T5 20t-.288.713T4 21m4 0q-.425 0-.712-.288T7 20t.288-.712T8 19t.713.288T9 20t-.288.713T8 21m4 0q-.425 0-.712-.288T11 20t.288-.712T12 19t.713.288T13 20t-.288.713T12 21m4 0q-.425 0-.712-.288T15 20t.288-.712T16 19t.713.288T17 20t-.288.713T16 21m4 0q-.425 0-.712-.288T19 20t.288-.712T20 19t.713.288T21 20t-.288.713T20 21M9 17q-.825 0-1.412-.587T7 15V9q0-.825.588-1.412T9 7h6q.825 0 1.413.588T17 9v6q0 .825-.587 1.413T15 17zm0-2h6V9H9z"},null,-1),zb=[Db];function Eb(n,e){return vt(),Ut("svg",Yb,zb)}const jb=Nt(qb,[["render",Eb]]),_b={},Vb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Bb=Zt("path",{fill:"currentColor",d:"M8 19q-.425 0-.712-.288T7 18t.288-.712T8 17h6.1q1.575 0 2.738-1T18 13.5T16.838 11T14.1 10H7.8l1.9 1.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275L4.7 9.7q-.15-.15-.213-.325T4.426 9t.063-.375T4.7 8.3l3.6-3.6q.275-.275.7-.275t.7.275t.275.7t-.275.7L7.8 8h6.3q2.425 0 4.163 1.575T20 13.5t-1.737 3.925T14.1 19z"},null,-1),Ub=[Bb];function Lb(n,e){return vt(),Ut("svg",Vb,Ub)}const Nb=Nt(_b,[["render",Lb]]);Lt.register("auto-indent",fb);Lt.register("find-replace",gb);Lt.register("indent-less",Sb);Lt.register("indent-more",Tb);Lt.register("redo",Xb);Lt.register("select-all",jb);Lt.register("undo",Nb);const Ib=su({__name:"codemirror",props:{schema:{},modelValue:{},disabled:{},prefix:{},initial:{}},setup(n){const e=n,t=Ho.useModel();let i=t.value;const s=new hi,r=new hi,o=Fo(()=>{var d;return((d=e.schema.meta.extra)==null?void 0:d.lang)==="json"?o1():J0()}),l=Fo(()=>e.disabled?[v.editable.of(false),D.readOnly.of(true)]:[]),a=ru();let h=null;function c(u){u.docChanged&&(t.value=i=u.state.doc.toString())}dn(a,()=>{a.value||(h.destroy(),h=null),h=new v({doc:i,extensions:[rb,s.of(o.value),v.lineWrapping,v.updateListener.of(c),U1,r.of(l.value)],parent:a.value})}),dn(o,u=>{s.reconfigure(u)}),dn(l,u=>{r.reconfigure(u)}),dn(t,u=>{u!==i&&(h.dispatch({changes:{from:0,to:h.state.doc.length,insert:u}}),i=u)});function f(){k1(h.state)?Lo(h):Uo(h)}return(u,d)=>{const O=On("k-icon"),m=On("el-button"),g=On("el-tooltip"),b=On("el-button-group");return vt(),ou(Ce(Ho),null,{title:F(()=>[yi(u.$slots,"title")]),desc:F(()=>[yi(u.$slots,"desc")]),menu:F(()=>[yi(u.$slots,"menu")]),prefix:F(()=>[yi(u.$slots,"prefix")]),suffix:F(()=>[yi(u.$slots,"suffix")]),control:F(()=>[H(b,null,{default:F(()=>[H(g,{content:"全选",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[0]||(d[0]=At(()=>{},["prevent"])),onClick:d[1]||(d[1]=()=>Ce(df)(Ce(h)))},{default:F(()=>[H(O,{name:"select-all"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"撤销",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[2]||(d[2]=At(()=>{},["prevent"])),onClick:d[3]||(d[3]=()=>Ce(Wo)(Ce(h)))},{default:F(()=>[H(O,{name:"undo"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"重做",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[4]||(d[4]=At(()=>{},["prevent"])),onClick:d[5]||(d[5]=()=>Ce(as)(Ce(h)))},{default:F(()=>[H(O,{name:"redo"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"减少缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[6]||(d[6]=At(()=>{},["prevent"])),onClick:d[7]||(d[7]=()=>Ce(Sf)(Ce(h)))},{default:F(()=>[H(O,{name:"indent-less"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"增加缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[8]||(d[8]=At(()=>{},["prevent"])),onClick:d[9]||(d[9]=()=>Ce(wf)(Ce(h)))},{default:F(()=>[H(O,{name:"indent-more"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"自动缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[10]||(d[10]=At(()=>{},["prevent"])),onClick:d[11]||(d[11]=()=>Ce(Qf)(Ce(h)))},{default:F(()=>[H(O,{name:"auto-indent"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"查找/替换",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[12]||(d[12]=At(()=>{},["prevent"])),onClick:d[13]||(d[13]=Q=>f())},{default:F(()=>[H(O,{name:"find-replace"})]),_:1},8,["disabled"])]),_:1})]),_:1})]),default:F(()=>[Zt("div",{class:"bottom",ref_key:"parent",ref:a},null,512)]),_:3})}}});const Jb=n=>{n.schema.component({type:"string",role:"codemirror",component:Ib,validate:e=>typeof e=="string"})};export{Jb as default};
23
+ `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new S1(this):new Q1(this)}getCursor(e,t=0,i){let s=e.doc?e:D.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Ht(this,s,t,i):Ft(this,s,t,i)}}class Hf{constructor(e){this.spec=e}}function Ft(n,e,t,i){return new di(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?x1(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function x1(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(ms(s,t-r))!=I.Word||e(gs(s,t-r))!=I.Word)&&(e(gs(s,i-r))!=I.Word||e(ms(s,i-r))!=I.Word))}class Q1 extends Hf{constructor(e){super(e)}nextMatch(e,t,i){let s=Ft(this.spec,e,i,e.doc.length).nextOverlapping();return s.done&&(s=Ft(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Ft(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Ft(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ft(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ht(n,e,t,i){return new Nf(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?w1(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ms(n,e){return n.slice(de(n,e,false),e)}function gs(n,e){return n.slice(e,de(n,e))}function w1(n){return(e,t,i)=>!i[0].length||(n(ms(i.input,i.index))!=I.Word||n(gs(i.input,i.index))!=I.Word)&&(n(gs(i.input,i.index+i[0].length))!=I.Word||n(ms(i.input,i.index+i[0].length))!=I.Word)}class S1 extends Hf{nextMatch(e,t,i){let s=Ht(this.spec,e,i,e.doc.length).next();return s.done&&(s=Ht(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Ht(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=Ht(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ht(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const en=R.define(),Vo=R.define(),at=le.define({create(n){return new rr(so(n).create(),null)},update(n,e){for(let t of e.effects)t.is(en)?n=new rr(t.value.create(),n.panel):t.is(Vo)&&(n=new rr(n.query,t.value?Bo:null));return n},provide:n=>Li.from(n,e=>e.panel)});function k1(n){var e;return((e=n.field(at,false))===null||e===void 0?void 0:e.panel)!=null}class rr{constructor(e,t){this.query=e,this.panel=t}}const P1=C.mark({class:"cm-searchMatch"}),$1=C.mark({class:"cm-searchMatch cm-searchMatch-selected"}),v1=te.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(at))}update(n){let e=n.state.field(at);(e!=n.startState.field(at)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return C.none;let{view:t}=this,i=new Qt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?$1:P1)})}return i.finish()}},{decorations:n=>n.decorations});function fn(n){return e=>{let t=e.state.field(at,false);return t&&t.query.spec.valid?n(e,t):Uo(e)}}const bs=fn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return false;let s=y.single(i.from,i.to),r=n.state.facet(bi);return n.dispatch({selection:s,effects:[No(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Jf(n),true}),ys=fn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return false;let r=y.single(s.from,s.to),o=n.state.facet(bi);return n.dispatch({selection:r,effects:[No(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Jf(n),true}),Z1=fn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?false:(n.dispatch({selection:y.create(t.map(i=>y.range(i.from,i.to))),userEvent:"select.search.matches"}),true)}),T1=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return false;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new di(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return false;l.value.from==i&&(o=r.length),r.push(y.range(l.value.from,l.value.to))}return e(n.update({selection:y.create(r,o),userEvent:"select.search.matches"})),true},Ea=fn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return false;let r=e.nextMatch(t,i,i);if(!r)return false;let o=[],l,a,h=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),h.push(v.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=y.single(r.from-c,r.to-c),h.push(No(n,r)),h.push(t.facet(bi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),true}),C1=fn((n,{query:e})=>{if(n.state.readOnly)return false;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return false;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:v.announce.of(i),userEvent:"input.replace.all"}),true});function Bo(n){return n.state.facet(bi).createPanel(n)}function so(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(bi);return new Ff({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Kf(n){let e=Ui(n,Bo);return e&&e.dom.querySelector("[main-field]")}function Jf(n){let e=Kf(n);e&&e==n.root.activeElement&&e.select()}const Uo=n=>{let e=n.state.field(at,false);if(e&&e.panel){let t=Kf(n);if(t&&t!=n.root.activeElement){let i=so(n.state,e.query.spec);i.valid&&n.dispatch({effects:en.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Vo.of(true),e?en.of(so(n.state,e.query.spec)):R.appendConfig.of(W1)]});return true},Lo=n=>{let e=n.state.field(at,false);if(!e||!e.panel)return false;let t=Ui(n,Bo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Vo.of(false)}),true},R1=[{key:"Mod-f",run:Uo,scope:"editor search-panel"},{key:"F3",run:bs,shift:ys,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:bs,shift:ys,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:Lo,scope:"editor search-panel"},{key:"Mod-Shift-l",run:T1},{key:"Mod-Alt-g",run:a1},{key:"Mod-d",run:y1,preventDefault:true}];class A1{constructor(e){this.view=e;let t=this.query=e.state.field(at).query.spec;this.commit=this.commit.bind(this),this.searchField=U("input",{value:t.search,placeholder:Ae(e,"Find"),"aria-label":Ae(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=U("input",{value:t.replace,placeholder:Ae(e,"Replace"),"aria-label":Ae(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=U("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=U("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=U("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return U("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=U("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>bs(e),[Ae(e,"next")]),i("prev",()=>ys(e),[Ae(e,"previous")]),i("select",()=>Z1(e),[Ae(e,"all")]),U("label",null,[this.caseField,Ae(e,"match case")]),U("label",null,[this.reField,Ae(e,"regexp")]),U("label",null,[this.wordField,Ae(e,"by word")]),...e.state.readOnly?[]:[U("br"),this.replaceField,i("replace",()=>Ea(e),[Ae(e,"replace")]),i("replaceAll",()=>C1(e),[Ae(e,"replace all")])],U("button",{name:"close",onclick:()=>Lo(e),"aria-label":Ae(e,"close"),type:"button"},["×"])])}commit(){let e=new Ff({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:en.of(e)}))}keydown(e){Jd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ys:bs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ea(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(en)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(bi).top}}function Ae(n,e){return n.state.phrase(e)}const Wn=30,Xn=/[\s\.,:;?!]/;function No(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Wn),o=Math.min(s,t+Wn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<Wn;a++)if(!Xn.test(l[a+1])&&Xn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Wn;a--)if(!Xn.test(l[a-1])&&Xn.test(l[a])){l=l.slice(0,a);break}}return v.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const M1=v.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),W1=[at,Tt.low(v1),M1],X1="#e5c07b",ja="#e06c75",q1="#56b6c2",Y1="#ffffff",Nn="#abb2bf",ro="#7d8799",D1="#61afef",z1="#98c379",_a="#d19a66",E1="#c678dd",j1="#21252b",Va="#2c313a",Ba="#282c34",or="#353a42",_1="#3E4451",Ua="#528bff",V1=v.theme({"&":{color:Nn,backgroundColor:Ba},".cm-content":{caretColor:Ua},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ua},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:_1},".cm-panels":{backgroundColor:j1,color:Nn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ba,color:ro,border:"none"},".cm-activeLineGutter":{backgroundColor:Va},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:or},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:or,borderBottomColor:or},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Va,color:Nn}}},{dark:true}),B1=an.define([{tag:p.keyword,color:E1},{tag:[p.name,p.deleted,p.character,p.propertyName,p.macroName],color:ja},{tag:[p.function(p.variableName),p.labelName],color:D1},{tag:[p.color,p.constant(p.name),p.standard(p.name)],color:_a},{tag:[p.definition(p.name),p.separator],color:Nn},{tag:[p.typeName,p.className,p.number,p.changed,p.annotation,p.modifier,p.self,p.namespace],color:X1},{tag:[p.operator,p.operatorKeyword,p.url,p.escape,p.regexp,p.link,p.special(p.string)],color:q1},{tag:[p.meta,p.comment],color:ro},{tag:p.strong,fontWeight:"bold"},{tag:p.emphasis,fontStyle:"italic"},{tag:p.strikethrough,textDecoration:"line-through"},{tag:p.link,color:ro,textDecoration:"underline"},{tag:p.heading,fontWeight:"bold",color:ja},{tag:[p.atom,p.bool,p.special(p.variableName)],color:_a},{tag:[p.processingInstruction,p.string,p.inserted],color:z1},{tag:p.invalid,color:Y1}]),U1=[V1,Ec(B1)];class L1{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Xt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(tn).markerFilter;r&&(s=r(s,i));let o=C.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?C.widget({widget:new tb(l),diagnostic:l}).range(l.from):C.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l,inclusive:true}).range(l.from,l.to)),true);return new Xt(o,t,Oi(o))}}function Oi(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new L1(s,r,o.diagnostic),false}),i}function N1(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(tn).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(eu))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function I1(n,e){return n.field(We,false)?e:e.concat(R.appendConfig.of(sb))}const eu=R.define(),Io=R.define(),tu=R.define(),We=le.define({create(){return new Xt(C.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Oi(t,n.selected.diagnostic,r)||Oi(t,null,r)}!t.size&&s&&e.state.facet(tn).autoPanel&&(s=null),n=new Xt(t,s,i)}for(let t of e.effects)if(t.is(eu)){let i=e.state.facet(tn).autoPanel?t.value.length?nn.open:null:n.panel;n=Xt.init(t.value,i,e.state)}else t.is(Io)?n=new Xt(n.diagnostics,t.value?nn.open:null,n.selected):t.is(tu)&&(n=new Xt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Li.from(n,e=>e.panel),v.decorations.from(n,e=>e.diagnostics)]}),G1=C.mark({class:"cm-lintRange cm-lintRange-active",inclusive:true});function F1(n,e,t){let{diagnostics:i}=n.state.field(We),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(s.push(c.diagnostic),r=Math.min(a,r),o=Math.max(h,o))});let l=n.state.facet(tn).tooltipFilter;return l&&(s=l(s,n.state)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:H1(n,s)}}}:null}function H1(n,e){return U("ul",{class:"cm-tooltip-lint"},e.map(t=>nu(n,t,false)))}const K1=n=>{let e=n.state.field(We,false);(!e||!e.panel)&&n.dispatch({effects:I1(n.state,[Io.of(true)])});let t=Ui(n,nn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),true},La=n=>{let e=n.state.field(We,false);return!e||!e.panel?false:(n.dispatch({effects:Io.of(false)}),true)},J1=n=>{let e=n.state.field(We,false);if(!e)return false;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?false:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:true}),true)},eb=[{key:"Mod-Shift-m",run:K1,preventDefault:true},{key:"F8",run:J1}],tn=Z.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},st(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function iu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function nu(n,e,t){var i;let s=t?iu(e.actions):[];return U("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},U("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=false,a=u=>{if(u.preventDefault(),l)return;l=true;let d=Oi(n.state.field(We).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),U("u",h.slice(c,c+1)),h.slice(c+1)];return U("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&U("div",{class:"cm-diagnosticSource"},e.source))}class tb extends dt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return U("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Na{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=nu(e,t,true),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nn{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)La(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=iu(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Oi(this.view.state.field(We).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=U("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=U("div",{class:"cm-panel-lint"},this.list,U("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>La(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(We).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(We),i=0,s=false,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new Na(this.view,a.diagnostic),this.items.splice(i,0,c),s=true):(c=this.items[h],h>i&&(this.items.splice(i,h-i),s=true)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=true,this.items.pop();this.items.length==0&&(this.items.push(new Na(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=true),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(We),i=Oi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:true,effects:tu.of(i)})}static open(e){return new nn(e)}}function ib(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function qn(n){return ib(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const nb=v.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:qn("#d11")},".cm-lintRange-warning":{backgroundImage:qn("orange")},".cm-lintRange-info":{backgroundImage:qn("#999")},".cm-lintRange-hint":{backgroundImage:qn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),sb=[We,v.decorations.compute([We],n=>{let{selected:e,panel:t}=n.field(We);return!e||!t||e.from==e.to?C.none:C.set([G1.range(e.from,e.to)])}),zO(F1,{hideOn:N1}),nb],rb=(()=>[IO(),HO(),mO(),um(),zp(),rO(),cO(),D.allowMultipleSelections.of(true),$p(),Ec(Vp,{fallback:true}),Fp(),A0(),V0(),ZO(),RO(),wO(),f1(),ws.of([...q0,...fg,...R1,...Qm,...Xp,...Yf,...eb])])(),Nt=(n,e)=>{const t=n.__vccOpts||n;for(const[i,s]of e)t[i]=s;return t},ob={},lb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},ab=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm4-4q-.425 0-.712-.288T7 16t.288-.712T8 15h8q.425 0 .713.288T17 16t-.288.713T16 17zm-4-4q-.425 0-.712-.288T3 12t.288-.712T4 11h16q.425 0 .713.288T21 12t-.288.713T20 13zm4-4q-.425 0-.712-.288T7 8t.288-.712T8 7h8q.425 0 .713.288T17 8t-.288.713T16 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5z"},null,-1),hb=[ab];function cb(n,e){return vt(),Ut("svg",lb,hb)}const fb=Nt(ob,[["render",cb]]),ub={},db={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Ob=Zt("path",{fill:"currentColor",d:"M11 6q-1.575 0-2.838.863T6.35 9.125q-.15.375-.487.563t-.738.112t-.638-.387t-.112-.663q.675-2.1 2.475-3.425T11 4q1.475 0 2.763.562T16 6.1V5q0-.425.288-.712T17 4t.713.288T18 5v4q0 .425-.288.713T17 10h-4q-.425 0-.712-.288T12 9t.288-.712T13 8h2q-.725-.9-1.737-1.45T11 6m0 12q-1.475 0-2.762-.562T6 15.9V17q0 .425-.288.713T5 18t-.712-.288T4 17v-4q0-.425.288-.712T5 12h4q.425 0 .713.288T10 13t-.288.713T9 14H7q.725.9 1.738 1.45T11 16q1.55 0 2.788-.825T15.6 13q.175-.4.513-.638t.762-.162q.425.1.625.45t.075.75q-.175.5-.413.938t-.562.862l3.7 3.7q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-3.7-3.7q-.9.675-1.962 1.038T11 18"},null,-1),pb=[Ob];function mb(n,e){return vt(),Ut("svg",db,pb)}const gb=Nt(ub,[["render",mb]]),bb={},yb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},xb=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm8-4q-.425 0-.712-.288T11 16t.288-.712T12 15h8q.425 0 .713.288T21 16t-.288.713T20 17zm0-4q-.425 0-.712-.288T11 12t.288-.712T12 11h8q.425 0 .713.288T21 12t-.288.713T20 13zm0-4q-.425 0-.712-.288T11 8t.288-.712T12 7h8q.425 0 .713.288T21 8t-.288.713T20 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5zm2.15 10.15l-2.8-2.8Q3.2 12.2 3.2 12t.15-.35l2.8-2.8q.25-.25.55-.125T7 9.2v5.6q0 .35-.3.475t-.55-.125"},null,-1),Qb=[xb];function wb(n,e){return vt(),Ut("svg",yb,Qb)}const Sb=Nt(bb,[["render",wb]]),kb={},Pb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},$b=Zt("path",{fill:"currentColor",d:"M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19h16q.425 0 .713.288T21 20t-.288.713T20 21zm8-4q-.425 0-.712-.288T11 16t.288-.712T12 15h8q.425 0 .713.288T21 16t-.288.713T20 17zm0-4q-.425 0-.712-.288T11 12t.288-.712T12 11h8q.425 0 .713.288T21 12t-.288.713T20 13zm0-4q-.425 0-.712-.288T11 8t.288-.712T12 7h8q.425 0 .713.288T21 8t-.288.713T20 9zM4 5q-.425 0-.712-.288T3 4t.288-.712T4 3h16q.425 0 .713.288T21 4t-.288.713T20 5zm-.15 10.15q-.25.25-.55.125T3 14.8V9.2q0-.35.3-.475t.55.125l2.8 2.8q.15.15.15.35t-.15.35z"},null,-1),vb=[$b];function Zb(n,e){return vt(),Ut("svg",Pb,vb)}const Tb=Nt(kb,[["render",Zb]]),Cb={},Rb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Ab=Zt("path",{fill:"currentColor",d:"M16.2 10H9.9q-1.575 0-2.738 1T6 13.5T7.163 16T9.9 17H16q.425 0 .713.288T17 18t-.288.713T16 19H9.9q-2.425 0-4.163-1.575T4 13.5t1.738-3.925T9.9 8h6.3l-1.9-1.9q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l3.6 3.6q.15.15.213.325t.062.375t-.062.375t-.213.325l-3.6 3.6q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7z"},null,-1),Mb=[Ab];function Wb(n,e){return vt(),Ut("svg",Rb,Mb)}const Xb=Nt(Cb,[["render",Wb]]),qb={},Yb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Db=Zt("path",{fill:"currentColor",d:"M4 5q-.425 0-.712-.288T3 4t.288-.712T4 3t.713.288T5 4t-.288.713T4 5m4 0q-.425 0-.712-.288T7 4t.288-.712T8 3t.713.288T9 4t-.288.713T8 5m4 0q-.425 0-.712-.288T11 4t.288-.712T12 3t.713.288T13 4t-.288.713T12 5m4 0q-.425 0-.712-.288T15 4t.288-.712T16 3t.713.288T17 4t-.288.713T16 5m4 0q-.425 0-.712-.288T19 4t.288-.712T20 3t.713.288T21 4t-.288.713T20 5M4 9q-.425 0-.712-.288T3 8t.288-.712T4 7t.713.288T5 8t-.288.713T4 9m16 0q-.425 0-.712-.288T19 8t.288-.712T20 7t.713.288T21 8t-.288.713T20 9M4 13q-.425 0-.712-.288T3 12t.288-.712T4 11t.713.288T5 12t-.288.713T4 13m16 0q-.425 0-.712-.288T19 12t.288-.712T20 11t.713.288T21 12t-.288.713T20 13M4 17q-.425 0-.712-.288T3 16t.288-.712T4 15t.713.288T5 16t-.288.713T4 17m16 0q-.425 0-.712-.288T19 16t.288-.712T20 15t.713.288T21 16t-.288.713T20 17M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19t.713.288T5 20t-.288.713T4 21m4 0q-.425 0-.712-.288T7 20t.288-.712T8 19t.713.288T9 20t-.288.713T8 21m4 0q-.425 0-.712-.288T11 20t.288-.712T12 19t.713.288T13 20t-.288.713T12 21m4 0q-.425 0-.712-.288T15 20t.288-.712T16 19t.713.288T17 20t-.288.713T16 21m4 0q-.425 0-.712-.288T19 20t.288-.712T20 19t.713.288T21 20t-.288.713T20 21M9 17q-.825 0-1.412-.587T7 15V9q0-.825.588-1.412T9 7h6q.825 0 1.413.588T17 9v6q0 .825-.587 1.413T15 17zm0-2h6V9H9z"},null,-1),zb=[Db];function Eb(n,e){return vt(),Ut("svg",Yb,zb)}const jb=Nt(qb,[["render",Eb]]),_b={},Vb={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Bb=Zt("path",{fill:"currentColor",d:"M8 19q-.425 0-.712-.288T7 18t.288-.712T8 17h6.1q1.575 0 2.738-1T18 13.5T16.838 11T14.1 10H7.8l1.9 1.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275L4.7 9.7q-.15-.15-.213-.325T4.426 9t.063-.375T4.7 8.3l3.6-3.6q.275-.275.7-.275t.7.275t.275.7t-.275.7L7.8 8h6.3q2.425 0 4.163 1.575T20 13.5t-1.737 3.925T14.1 19z"},null,-1),Ub=[Bb];function Lb(n,e){return vt(),Ut("svg",Vb,Ub)}const Nb=Nt(_b,[["render",Lb]]);Lt.register("auto-indent",fb);Lt.register("find-replace",gb);Lt.register("indent-less",Sb);Lt.register("indent-more",Tb);Lt.register("redo",Xb);Lt.register("select-all",jb);Lt.register("undo",Nb);const Ib=su({__name:"codemirror",props:{schema:{},modelValue:{},disabled:{},prefix:{},initial:{}},setup(n){const e=n,t=Ho.useModel();let i=t.value;const s=new hi,r=new hi,o=Fo(()=>{var d;return((d=e.schema.meta.extra)==null?void 0:d.lang)==="json"?o1():J0()}),l=Fo(()=>e.disabled?[v.editable.of(false),D.readOnly.of(true)]:[]),a=ru();let h=null;function c(u){u.docChanged&&(t.value=i=u.state.doc.toString())}dn(a,()=>{a.value||(h.destroy(),h=null),h=new v({doc:i,extensions:[rb,s.of(o.value),v.lineWrapping,v.updateListener.of(c),U1,r.of(l.value)],parent:a.value})}),dn(o,u=>{s.reconfigure(u)}),dn(l,u=>{r.reconfigure(u)}),dn(t,u=>{u!==i&&(h.dispatch({changes:{from:0,to:h.state.doc.length,insert:u}}),i=u)});function f(){k1(h.state)?Lo(h):Uo(h)}return(u,d)=>{const O=On("k-icon"),m=On("el-button"),g=On("el-tooltip"),b=On("el-button-group");return vt(),ou(Ce(Ho),null,{title:F(()=>[yi(u.$slots,"title")]),desc:F(()=>[yi(u.$slots,"desc")]),menu:F(()=>[yi(u.$slots,"menu")]),prefix:F(()=>[yi(u.$slots,"prefix")]),suffix:F(()=>[yi(u.$slots,"suffix")]),control:F(()=>[H(b,null,{default:F(()=>[H(g,{content:"全选",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[0]||(d[0]=At(()=>{},["prevent"])),onClick:d[1]||(d[1]=()=>Ce(df)(Ce(h)))},{default:F(()=>[H(O,{name:"select-all"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"撤销",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[2]||(d[2]=At(()=>{},["prevent"])),onClick:d[3]||(d[3]=()=>Ce(Wo)(Ce(h)))},{default:F(()=>[H(O,{name:"undo"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"重做",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[4]||(d[4]=At(()=>{},["prevent"])),onClick:d[5]||(d[5]=()=>Ce(as)(Ce(h)))},{default:F(()=>[H(O,{name:"redo"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"减少缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[6]||(d[6]=At(()=>{},["prevent"])),onClick:d[7]||(d[7]=()=>Ce(Sf)(Ce(h)))},{default:F(()=>[H(O,{name:"indent-less"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"增加缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[8]||(d[8]=At(()=>{},["prevent"])),onClick:d[9]||(d[9]=()=>Ce(wf)(Ce(h)))},{default:F(()=>[H(O,{name:"indent-more"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"自动缩进",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[10]||(d[10]=At(()=>{},["prevent"])),onClick:d[11]||(d[11]=()=>Ce(Qf)(Ce(h)))},{default:F(()=>[H(O,{name:"auto-indent"})]),_:1},8,["disabled"])]),_:1}),H(g,{content:"查找/替换",placement:"top"},{default:F(()=>[H(m,{disabled:n.disabled,onMousedown:d[12]||(d[12]=At(()=>{},["prevent"])),onClick:d[13]||(d[13]=Q=>f())},{default:F(()=>[H(O,{name:"find-replace"})]),_:1},8,["disabled"])]),_:1})]),_:1})]),default:F(()=>[Zt("div",{class:"bottom",ref_key:"parent",ref:a},null,512)]),_:3})}}});const Jb=n=>{n.schema({type:"string",role:"codemirror",component:Ib,validate:e=>typeof e=="string"})};export{Jb as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-codemirror",
3
3
  "description": "CodeMirror schema role for Koishi Web UI",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -29,11 +29,11 @@
29
29
  "@codemirror/lang-javascript": "^6.2.2",
30
30
  "@codemirror/lang-json": "^6.0.1",
31
31
  "@codemirror/theme-one-dark": "^6.1.2",
32
- "@koishijs/client": "^5.29.1",
32
+ "@koishijs/client": "^5.29.2",
33
33
  "codemirror": "^6.0.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@koishijs/plugin-console": "^5.29.1",
37
- "koishi": "^4.17.8"
36
+ "@koishijs/plugin-console": "^5.29.2",
37
+ "koishi": "^4.17.9"
38
38
  }
39
- }
39
+ }