=c)break;O+=w}if(x==S+1){if(O>c){let w=d[S];f(w.children,w.positions,0,w.children.length,m[S]+v);continue}p.push(d[S])}else{let w=m[x-1]+d[x-1].length-C;p.push(Gp(r,d,m,S,x,C,w,null,o))}h.push(C+v-i)}}return f(e,t,s,n,0),(l||o)(p,h,a)}var uu=class{constructor(){this.map=new WeakMap}setBuffer(e,t,s){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,s)}getBuffer(e,t){let s=this.map.get(e);return s&&s.get(t)}set(e,t){e instanceof ci?this.setBuffer(e.context.buffer,e.index,t):e instanceof ln&&this.map.set(e.tree,t)}get(e){return e instanceof ci?this.getBuffer(e.context.buffer,e.index):e instanceof ln?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},fi=class r{constructor(e,t,s,n,i=!1,a=!1){this.from=e,this.to=t,this.tree=s,this.offset=n,this.open=(i?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],s=!1){let n=[new r(0,e.length,e,0,!1,s)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,s=128){if(!t.length)return e;let n=[],i=1,a=e.length?e[0]:null;for(let l=0,o=0,u=0;;l++){let c=l=s)for(;a&&a.from=h.from||p<=h.to||u){let f=Math.max(h.from,o)-u,d=Math.min(h.to,p)-u;h=f>=d?null:new r(f,d,h.tree,h.offset+u,l>0,!!c)}if(h&&n.push(h),a.to>p)break;a=inew Eo(n.from,n.to)):[new Eo(0,0)]:[new Eo(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let n=this.startParse(e,t,s);for(;;){let i=n.advance();if(i)return i}}},Zp=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var YX=new kt({perNode:!0});var Wj=0,vn=class r{constructor(e,t,s,n){this.name=e,this.set=t,this.base=s,this.modified=n,this.id=Wj++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let s=typeof e=="string"?e:"?";if(e instanceof r&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new r(s,[],null,[]);if(n.set.push(n),t)for(let i of t.set)n.set.push(i);return n}static defineModifier(e){let t=new hu(e);return s=>s.modified.indexOf(t)>-1?s:hu.get(s.base||s,s.modified.concat(t).sort((n,i)=>n.id-i.id))}},Gj=0,hu=class r{constructor(e){this.name=e,this.instances=[],this.id=Gj++}static get(e,t){if(!t.length)return e;let s=t[0].instances.find(l=>l.base==e&&Xj(t,l.modified));if(s)return s;let n=[],i=new vn(e.name,n,e,t);for(let l of t)l.instances.push(i);let a=Yj(t);for(let l of e.set)if(!l.modified.length)for(let o of a)n.push(r.get(l,o));return i}};function Xj(r,e){return r.length==e.length&&r.every((t,s)=>t==e[s])}function Yj(r){let e=[[]];for(let t=0;ts.length-t.length)}function du(r){let e=Object.create(null);for(let t in r){let s=r[t];Array.isArray(s)||(s=[s]);for(let n of t.split(" "))if(n){let i=[],a=2,l=n;for(let p=0;;){if(l=="..."&&p>0&&p+3==n.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+n);if(i.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),p+=h[0].length,p==n.length)break;let f=n[p++];if(p==n.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+n);l=n.slice(p)}let o=i.length-1,u=i[o];if(!u)throw new RangeError("Invalid path: "+n);let c=new ra(s,a,o>0?i.slice(0,o):null);e[u]=c.sort(e[u])}}return ew.add(e)}var ew=new kt,ra=class{constructor(e,t,s,n){this.tags=e,this.mode=t,this.context=s,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=n;for(let l of i)for(let o of l.set){let u=t[o.id];if(u){a=a?a+" "+u:u;break}}return a},scope:s}}function Hj(r,e){let t=null;for(let s of r){let n=s.style(e);n&&(t=t?t+" "+n:n)}return t}function tw(r,e,t,s=0,n=r.length){let i=new Yp(s,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),s,n,"",i.highlighters),i.flush(n)}var Yp=class{constructor(e,t,s){this.at=e,this.highlighters=t,this.span=s,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,s,n,i){let{type:a,from:l,to:o}=e;if(l>=s||o<=t)return;a.isTop&&(i=this.highlighters.filter(f=>!f.scope||f.scope(a)));let u=n,c=Kj(e)||ra.empty,p=Hj(i,c.tags);if(p&&(u&&(u+=" "),u+=p,c.mode==1&&(n+=(n?" ":"")+p)),this.startSpan(Math.max(t,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(kt.mounted);if(h&&h.overlay){let f=e.node.enter(h.overlay[0].from+l,1),d=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g=x||!e.nextSibling())););if(!v||x>s)break;y=v.to+l,y>t&&(this.highlightRange(f.cursor(),Math.max(t,v.from+l),Math.min(s,y),"",d),this.startSpan(Math.min(s,y),u))}m&&e.parent()}else if(e.firstChild()){h&&(n="");do if(!(e.to<=t)){if(e.from>=s)break;this.highlightRange(e,t,s,n,i),this.startSpan(Math.min(s,e.to),u)}while(e.nextSibling());e.parent()}}};function Kj(r){let e=r.type.prop(ew);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var lt=vn.define,cu=lt(),Rs=lt(),KC=lt(Rs),JC=lt(Rs),Fs=lt(),fu=lt(Fs),Xp=lt(Fs),Vn=lt(),pi=lt(Vn),qn=lt(),Qn=lt(),Hp=lt(),Ao=lt(Hp),pu=lt(),we={comment:cu,lineComment:lt(cu),blockComment:lt(cu),docComment:lt(cu),name:Rs,variableName:lt(Rs),typeName:KC,tagName:lt(KC),propertyName:JC,attributeName:lt(JC),className:lt(Rs),labelName:lt(Rs),namespace:lt(Rs),macroName:lt(Rs),literal:Fs,string:fu,docString:lt(fu),character:lt(fu),attributeValue:lt(fu),number:Xp,integer:lt(Xp),float:lt(Xp),bool:lt(Fs),regexp:lt(Fs),escape:lt(Fs),color:lt(Fs),url:lt(Fs),keyword:qn,self:lt(qn),null:lt(qn),atom:lt(qn),unit:lt(qn),modifier:lt(qn),operatorKeyword:lt(qn),controlKeyword:lt(qn),definitionKeyword:lt(qn),moduleKeyword:lt(qn),operator:Qn,derefOperator:lt(Qn),arithmeticOperator:lt(Qn),logicOperator:lt(Qn),bitwiseOperator:lt(Qn),compareOperator:lt(Qn),updateOperator:lt(Qn),definitionOperator:lt(Qn),typeOperator:lt(Qn),controlOperator:lt(Qn),punctuation:Hp,separator:lt(Hp),bracket:Ao,angleBracket:lt(Ao),squareBracket:lt(Ao),paren:lt(Ao),brace:lt(Ao),content:Vn,heading:pi,heading1:lt(pi),heading2:lt(pi),heading3:lt(pi),heading4:lt(pi),heading5:lt(pi),heading6:lt(pi),contentSeparator:lt(Vn),list:lt(Vn),quote:lt(Vn),emphasis:lt(Vn),strong:lt(Vn),link:lt(Vn),monospace:lt(Vn),strikethrough:lt(Vn),inserted:lt(),deleted:lt(),changed:lt(),invalid:lt(),meta:pu,documentMeta:lt(pu),annotation:lt(pu),processingInstruction:lt(pu),definition:vn.defineModifier("definition"),constant:vn.defineModifier("constant"),function:vn.defineModifier("function"),standard:vn.defineModifier("standard"),local:vn.defineModifier("local"),special:vn.defineModifier("special")};for(let r in we){let e=we[r];e instanceof vn&&(e.name=r)}var JX=Kp([{tag:we.link,class:"tok-link"},{tag:we.heading,class:"tok-heading"},{tag:we.emphasis,class:"tok-emphasis"},{tag:we.strong,class:"tok-strong"},{tag:we.keyword,class:"tok-keyword"},{tag:we.atom,class:"tok-atom"},{tag:we.bool,class:"tok-bool"},{tag:we.url,class:"tok-url"},{tag:we.labelName,class:"tok-labelName"},{tag:we.inserted,class:"tok-inserted"},{tag:we.deleted,class:"tok-deleted"},{tag:we.literal,class:"tok-literal"},{tag:we.string,class:"tok-string"},{tag:we.number,class:"tok-number"},{tag:[we.regexp,we.escape,we.special(we.string)],class:"tok-string2"},{tag:we.variableName,class:"tok-variableName"},{tag:we.local(we.variableName),class:"tok-variableName tok-local"},{tag:we.definition(we.variableName),class:"tok-variableName tok-definition"},{tag:we.special(we.variableName),class:"tok-variableName2"},{tag:we.definition(we.propertyName),class:"tok-propertyName tok-definition"},{tag:we.typeName,class:"tok-typeName"},{tag:we.namespace,class:"tok-namespace"},{tag:we.className,class:"tok-className"},{tag:we.macroName,class:"tok-macroName"},{tag:we.propertyName,class:"tok-propertyName"},{tag:we.operator,class:"tok-operator"},{tag:we.comment,class:"tok-comment"},{tag:we.meta,class:"tok-meta"},{tag:we.invalid,class:"tok-invalid"},{tag:we.punctuation,class:"tok-punctuation"}]);var Jp,na=new kt;function ch(r){return ut.define({combine:r?e=>e.concat(r):void 0})}var yu=new kt,Yr=class{constructor(e,t,s=[],n=""){this.data=e,this.name=n,Vt.prototype.hasOwnProperty("tree")||Object.defineProperty(Vt.prototype,"tree",{get(){return pr(this)}}),this.parser=t,this.extension=[sa.of(this),Vt.languageData.of((i,a,l)=>{let o=rw(i,a,l),u=o.type.prop(na);if(!u)return[];let c=i.facet(u),p=o.type.prop(yu);if(p){let h=o.resolve(a-o.from,l);for(let f of p)if(f.test(h,i)){let d=i.facet(f.facet);return f.type=="replace"?d:d.concat(c)}}return c})].concat(s)}isActiveAt(e,t,s=-1){return rw(e,t,s).type.prop(na)==this.data}findRegions(e){let t=e.facet(sa);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],n=(i,a)=>{if(i.prop(na)==this.data){s.push({from:a,to:a+i.length});return}let l=i.prop(kt.mounted);if(l){if(l.tree.prop(na)==this.data){if(l.overlay)for(let o of l.overlay)s.push({from:o.from+a,to:o.to+a});else s.push({from:a,to:a+i.length});return}else if(l.overlay){let o=s.length;if(n(l.tree,l.overlay[0].from+a),s.length>o)return}}for(let o=0;os.isTop?t:void 0)]}),e.name)}configure(e,t){return new r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function pr(r){let e=r.field(Yr.state,!1);return e?e.tree:or.empty}var nh=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let s=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}},Po=null,sh=class r{constructor(e,t,s=[],n,i,a,l,o){this.parser=e,this.state=t,this.fragments=s,this.tree=n,this.treeLen=i,this.viewport=a,this.skipped=l,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(e,t,s){return new r(e,t,[],or.empty,0,s,[],null)}startParse(){return this.parser.startParse(new nh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=or.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Po;Po=this;try{return e()}finally{Po=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nw(e,t.from,t.to);return e}changes(e,t){let{fragments:s,tree:n,treeLen:i,viewport:a,skipped:l}=this;if(this.takeTree(),!e.empty){let o=[];if(e.iterChangedRanges((u,c,p,h)=>o.push({fromA:u,toA:c,fromB:p,toB:h})),s=fi.applyChanges(s,o),n=or.empty,i=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),p=e.mapPos(u.to,-1);ce.from&&(this.fragments=nw(this.fragments,n,i),this.skipped.splice(s--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends ta{createParse(t,s,n){let i=n[0].from,a=n[n.length-1].to;return{parsedPos:i,advance(){let o=Po;if(o){for(let u of n)o.tempSkipped.push(u);e&&(o.scheduleOn=o.scheduleOn?Promise.all([o.scheduleOn,e]):e)}return this.parsedPos=a,new or(Ar.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Po}};function nw(r,e,t){return fi.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var To=class r{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,s)||t.takeTree(),new r(t)}static init(e){let t=Math.min(3e3,e.doc.length),s=sh.create(e.facet(sa).parser,e,{from:0,to:t});return s.work(20,t)||s.takeTree(),new r(s)}};Yr.state=Yt.define({create:To.init,update(r,e){for(let t of e.effects)if(t.is(Yr.setState))return t.value;return e.startState.facet(sa)!=e.state.facet(sa)?To.init(e.state):r.apply(e)}});var ow=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ow=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var eh=typeof navigator<"u"&&(!((Jp=navigator.scheduling)===null||Jp===void 0)&&Jp.isInputPending)?()=>navigator.scheduling.isInputPending():null,Jj=rr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Yr.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Yr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ow(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,o=i.context.work(()=>eh&&eh()||Date.now()>a,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(o||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Yr.setState.of(new To(i.context))})),this.chunkBudget>0&&!(o&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>yr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),sa=ut.define({combine(r){return r.length?r[0]:null},enables:r=>[Yr.state,Jj,at.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]}),gu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var eq=ut.define(),aa=ut.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Do(r){let e=r.facet(aa);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function oa(r,e){let t="",s=r.tabSize,n=r.facet(aa)[0];if(n==" "){for(;e>=s;)t+=" ",e-=s;n=" "}for(let i=0;i=e?tq(r,t,e):null}var hi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Do(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:i}=this.options;return n!=null&&n>=s.from&&n<=s.to?i&&n==e?{text:"",from:e}:(t<0?n-1&&(i+=a-this.countColumn(s,s.search(/\S|$/))),i}countColumn(e,t=e.length){return os(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:n}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let a=i(n);if(a>-1)return a}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},fh=new kt;function tq(r,e,t){let s=e.resolveStack(t),n=s.node.enterUnfinishedNodesBefore(t);if(n!=s.node){let i=[];for(let a=n;a!=s.node;a=a.parent)i.push(a);for(let a=i.length-1;a>=0;a--)s={node:i[a],next:s}}return lw(s,r,t)}function lw(r,e,t){for(let s=r;s;s=s.next){let n=nq(s.node);if(n)return n(ih.create(e,t,s))}return 0}function rq(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function nq(r){let e=r.type.prop(fh);if(e)return e;let t=r.firstChild,s;if(t&&(s=t.type.prop(kt.closedBy))){let n=r.lastChild,i=n&&s.indexOf(n.name)>-1;return a=>cw(a,!0,1,void 0,i&&!rq(a)?n.from:void 0)}return r.parent==null?sq:null}function sq(){return 0}var ih=class r extends hi{constructor(e,t,s){super(e.state,e.options),this.base=e,this.pos=t,this.context=s}get node(){return this.context.node}static create(e,t,s){return new r(e,t,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let s=e.resolve(t.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(iq(s,e))break;t=this.state.doc.lineAt(s.from)}return this.lineIndent(t.from)}continue(){return lw(this.context.next,this.base,this.pos)}};function iq(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function aq(r){let e=r.node,t=e.childAfter(e.from),s=e.lastChild;if(!t)return null;let n=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),a=n==null||n<=i.from?i.to:Math.min(i.to,n);for(let l=t.to;;){let o=e.childAfter(l);if(!o||o==s)return null;if(!o.type.isSkipped){if(o.from>=a)return null;let u=/^ */.exec(i.text.slice(t.to-i.from))[0].length;return{from:t.from,to:t.to+u}}l=o.to}}function uw({closing:r,align:e=!0,units:t=1}){return s=>cw(s,e,t,r)}function cw(r,e,t,s,n){let i=r.textAfter,a=i.match(/^\s*/)[0].length,l=s&&i.slice(a,a+s.length)==s||n==r.pos+a,o=e?aq(r):null;return o?l?r.column(o.from):r.column(o.to):r.baseIndent+(l?0:r.unit*t)}var fw=r=>r.baseIndent;function vu({except:r,units:e=1}={}){return t=>{let s=r&&r.test(t.textAfter);return t.baseIndent+(s?0:e*t.unit)}}var oq=200;function pw(){return Vt.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:s}=r.newSelection.main,n=t.lineAt(s);if(s>n.from+oq)return r;let i=t.sliceString(n.from,s);if(!e.some(u=>u.test(i)))return r;let{state:a}=r,l=-1,o=[];for(let{head:u}of a.selection.ranges){let c=a.doc.lineAt(u);if(c.from==l)continue;l=c.from;let p=bu(a,c.from);if(p==null)continue;let h=/^\s*/.exec(c.text)[0],f=oa(a,p);h!=f&&o.push({from:c.from,to:c.from+h.length,insert:f})}return o.length?[r,{changes:o,sequential:!0}]:r})}var hw=new kt;function dw(r){let e=r.firstChild,t=r.lastChild;return e&&e.tol.prop(na)==a.data:a?l=>l==a:void 0,this.style=Kp(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=s?new nn(s):null,this.themeType=t.themeType}static define(e,t){return new r(e,t||{})}},ah=ut.define(),mw=ut.define({combine(r){return r.length?[r[0]]:null}});function th(r){let e=r.facet(ah);return e.length?e:r.facet(mw)}function xu(r,e){let t=[lq],s;return r instanceof ia&&(r.module&&t.push(at.styleModule.of(r.module)),s=r.themeType),e?.fallback?t.push(mw.of(r)):s?t.push(ah.computeN([at.darkTheme],n=>n.facet(at.darkTheme)==(s=="dark")?[r]:[])):t.push(ah.of(r)),t}var oh=class{constructor(e){this.markCache=Object.create(null),this.tree=pr(e.state),this.decorations=this.buildDeco(e,th(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=pr(e.state),s=th(e.state),n=s!=th(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return yt.none;let s=new Fn;for(let{from:n,to:i}of e.visibleRanges)tw(this.tree,t,(a,l,o)=>{s.add(a,l,this.markCache[o]||(this.markCache[o]=yt.mark({class:o})))},n,i);return s.finish()}},lq=rn.high(rr.fromClass(oh,{decorations:r=>r.decorations})),gw=ia.define([{tag:we.meta,color:"#404740"},{tag:we.link,textDecoration:"underline"},{tag:we.heading,textDecoration:"underline",fontWeight:"bold"},{tag:we.emphasis,fontStyle:"italic"},{tag:we.strong,fontWeight:"bold"},{tag:we.strikethrough,textDecoration:"line-through"},{tag:we.keyword,color:"#708"},{tag:[we.atom,we.bool,we.url,we.contentSeparator,we.labelName],color:"#219"},{tag:[we.literal,we.inserted],color:"#164"},{tag:[we.string,we.deleted],color:"#a11"},{tag:[we.regexp,we.escape,we.special(we.string)],color:"#e40"},{tag:we.definition(we.variableName),color:"#00f"},{tag:we.local(we.variableName),color:"#30a"},{tag:[we.typeName,we.namespace],color:"#085"},{tag:we.className,color:"#167"},{tag:[we.special(we.variableName),we.macroName],color:"#256"},{tag:we.definition(we.propertyName),color:"#00c"},{tag:we.comment,color:"#940"},{tag:we.invalid,color:"#f00"}]),uq=at.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yw=1e4,bw="()[]{}",vw=ut.define({combine(r){return kr(r,{afterCursor:!0,brackets:bw,maxScanDistance:yw,renderMatch:pq})}}),cq=yt.mark({class:"cm-matchingBracket"}),fq=yt.mark({class:"cm-nonmatchingBracket"});function pq(r){let e=[],t=r.matched?cq:fq;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}var hq=Yt.define({create(){return yt.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let t=[],s=e.state.facet(vw);for(let n of e.state.selection.ranges){if(!n.empty)continue;let i=xn(e.state,n.head,-1,s)||n.head>0&&xn(e.state,n.head-1,1,s)||s.afterCursor&&(xn(e.state,n.head,1,s)||n.headat.decorations.from(r)}),dq=[hq,uq];function xw(r={}){return[vw.of(r),dq]}var mq=new kt;function lh(r,e,t){let s=r.prop(e<0?kt.openedBy:kt.closedBy);if(s)return s;if(r.name.length==1){let n=t.indexOf(r.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function uh(r){let e=r.type.prop(mq);return e?e(r.node):r}function xn(r,e,t,s={}){let n=s.maxScanDistance||yw,i=s.brackets||bw,a=pr(r),l=a.resolveInner(e,t);for(let o=l;o;o=o.parent){let u=lh(o.type,t,i);if(u&&o.from0?e>=c.from&&ec.from&&e<=c.to))return gq(r,e,t,o,c,u,i)}}return yq(r,e,t,a,l.type,n,i)}function gq(r,e,t,s,n,i,a){let l=s.parent,o={from:n.from,to:n.to},u=0,c=l?.cursor();if(c&&(t<0?c.childBefore(s.from):c.childAfter(s.to)))do if(t<0?c.to<=s.from:c.from>=s.to){if(u==0&&i.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=r.doc.iterRange(e,t>0?r.doc.length:0),p=0;for(let h=0;!c.next().done&&h<=i;){let f=c.value;t<0&&(h+=f.length);let d=e+h*t;for(let m=t>0?0:f.length-1,g=t>0?f.length:-1;m!=g;m+=t){let y=a.indexOf(f[m]);if(!(y<0||s.resolveInner(d+m,1).type!=n))if(y%2==0==t>0)p++;else{if(p==1)return{start:u,end:{from:d+m,to:d+m+1},matched:y>>1==o>>1};p--}}t>0&&(h+=f.length)}return c.done?{start:u,matched:!1}:null}var bq=Object.create(null),sw=[Ar.none];var iw=[],aw=Object.create(null),vq=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])vq[r]=xq(bq,e);function rh(r,e){iw.indexOf(r)>-1||(iw.push(r),console.warn(e))}function xq(r,e){let t=[];for(let l of e.split(" ")){let o=[];for(let u of l.split(".")){let c=r[u]||we[u];c?typeof c=="function"?o.length?o=o.map(c):rh(u,`Modifier ${u} used at start of tag`):o.length?rh(u,`Tag ${u} used as modifier`):o=Array.isArray(c)?c:[c]:rh(u,`Unknown highlighting tag ${u}`)}for(let u of o)t.push(u)}if(!t.length)return 0;let s=e.replace(/ /g,"_"),n=s+" "+t.map(l=>l.id),i=aw[n];if(i)return i.id;let a=aw[n]=Ar.define({id:sw.length,name:s,props:[du({[s]:t})]});return sw.push(a),a.id}var oY={rtl:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Zt.RTL}),ltr:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Zt.LTR}),auto:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gh=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),s=bh(r.state,t.from);return s.line?Oq(r):s.block?Eq(r):!1};function yh(r,e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let n=r(e,t);return n?(s(t.update(n)),!0):!1}}var Oq=yh(kq,0);var Sq=yh(Tw,0);var Eq=yh((r,e)=>Tw(r,e,wq(e)),0);function bh(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var _o=50;function Cq(r,{open:e,close:t},s,n){let i=r.sliceDoc(s-_o,s),a=r.sliceDoc(n,n+_o),l=/\s*$/.exec(i)[0].length,o=/^\s*/.exec(a)[0].length,u=i.length-l;if(i.slice(u-e.length,u)==e&&a.slice(o,o+t.length)==t)return{open:{pos:s-l,margin:l&&1},close:{pos:n+o,margin:o&&1}};let c,p;n-s<=2*_o?c=p=r.sliceDoc(s,n):(c=r.sliceDoc(s,s+_o),p=r.sliceDoc(n-_o,n));let h=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(p)[0].length,d=p.length-f-t.length;return c.slice(h,h+e.length)==e&&p.slice(d,d+t.length)==t?{open:{pos:s+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:n-f-t.length,margin:/\s/.test(p.charAt(d-1))?1:0}}:null}function wq(r){let e=[];for(let t of r.selection.ranges){let s=r.doc.lineAt(t.from),n=t.to<=s.to?s:r.doc.lineAt(t.to);n.from>s.from&&n.from==t.to&&(n=t.to==s.to+1?s:r.doc.lineAt(t.to-1));let i=e.length-1;i>=0&&e[i].to>s.from?e[i].to=n.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:n.to})}return e}function Tw(r,e,t=e.selection.ranges){let s=t.map(i=>bh(e,i.from).block);if(!s.every(i=>i))return null;let n=t.map((i,a)=>Cq(e,s[a],i.from,i.to));if(r!=2&&!n.every(i=>i))return{changes:e.changes(t.map((i,a)=>n[a]?[]:[{from:i.from,insert:s[a].open+" "},{from:i.to,insert:" "+s[a].close}]))};if(r!=1&&n.some(i=>i)){let i=[];for(let a=0,l;an&&(i==a||a>p.from)){n=p.from;let h=/^\s*/.exec(p.text)[0].length,f=h==p.length,d=p.text.slice(h,h+u.length)==u?h:-1;hi.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:o,indent:u,empty:c,single:p}of s)(p||!c)&&i.push({from:l.from+u,insert:o+" "});let a=e.changes(i);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=1&&s.some(i=>i.comment>=0)){let i=[];for(let{line:a,comment:l,token:o}of s)if(l>=0){let u=a.from+l,c=u+o.length;a.text[c-a.from]==" "&&c++,i.push({from:u,to:c})}return{changes:i}}return null}var hh=Mr.define(),Aq=Mr.define(),Pq=ut.define(),Dw=ut.define({combine(r){return kr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(s,n)=>e(s,n)||t(s,n)})}}),_w=Yt.define({create(){return di.empty},update(r,e){let t=e.state.facet(Dw),s=e.annotation(hh);if(s){let o=On.fromTransaction(e,s.selection),u=s.side,c=u==0?r.undone:r.done;return o?c=Su(c,c.length,t.minDepth,o):c=Fw(c,e.startState.selection),new di(u==0?s.rest:c,u==0?c:s.rest)}let n=e.annotation(Aq);if((n=="full"||n=="before")&&(r=r.isolate()),e.annotation(lr.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=On.fromTransaction(e),a=e.annotation(lr.time),l=e.annotation(lr.userEvent);return i?r=r.addChanges(i,a,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,a,l,t.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new di(r.done.map(On.fromJSON),r.undone.map(On.fromJSON))}});function Iw(r={}){return[_w,Dw.of(r),at.domEventHandlers({beforeinput(e,t){let s=e.inputType=="historyUndo"?Cu:e.inputType=="historyRedo"?Io:null;return s?(e.preventDefault(),s(t)):!1}})]}function Eu(r,e){return function({state:t,dispatch:s}){if(!e&&t.readOnly)return!1;let n=t.field(_w,!1);if(!n)return!1;let i=n.pop(r,t,e);return i?(s(i),!0):!1}}var Cu=Eu(0,!1),Io=Eu(1,!1),Tq=Eu(0,!0),Dq=Eu(1,!0);var On=class r{constructor(e,t,s,n,i){this.changes=e,this.effects=t,this.mapped=s,this.startSelection=n,this.selectionsAfter=i}setSelAfter(e){return new r(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new r(e.changes&&Dr.fromJSON(e.changes),[],e.mapped&&as.fromJSON(e.mapped),e.startSelection&&Ze.fromJSON(e.startSelection),e.selectionsAfter.map(Ze.fromJSON))}static fromTransaction(e,t){let s=un;for(let n of e.startState.facet(Pq)){let i=n(e);i.length&&(s=s.concat(i))}return!s.length&&e.changes.empty?null:new r(e.changes.invert(e.startState.doc),s,void 0,t||e.startState.selection,un)}static selection(e){return new r(void 0,un,void 0,void 0,e)}};function Su(r,e,t,s){let n=e+1>t+20?e-t-1:0,i=r.slice(n,e);return i.push(s),i}function _q(r,e){let t=[],s=!1;return r.iterChangedRanges((n,i)=>t.push(n,i)),e.iterChangedRanges((n,i,a,l)=>{for(let o=0;o=u&&a<=c&&(s=!0)}}),s}function Iq(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,s)=>t.empty!=e.ranges[s].empty).length===0}function Rw(r,e){return r.length?e.length?r.concat(e):r:e}var un=[],Rq=200;function Fw(r,e){if(r.length){let t=r[r.length-1],s=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Rq));return s.length&&s[s.length-1].eq(e)?r:(s.push(e),Su(r,r.length-1,1e9,t.setSelAfter(s)))}else return[On.selection([e])]}function Fq(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ph(r,e){if(!r.length)return r;let t=r.length,s=un;for(;t;){let n=Bq(r[t-1],e,s);if(n.changes&&!n.changes.empty||n.effects.length){let i=r.slice(0,t);return i[t-1]=n,i}else e=n.mapped,t--,s=n.selectionsAfter}return s.length?[On.selection(s)]:un}function Bq(r,e,t){let s=Rw(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):un,t);if(!r.changes)return On.selection(s);let n=r.changes.map(e),i=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(i):i;return new On(n,Et.mapEffects(r.effects,e),a,r.startSelection.map(i),s)}var Lq=/^(input\.type|delete)($|\.)/,di=class r{constructor(e,t,s=0,n=void 0){this.done=e,this.undone=t,this.prevTime=s,this.prevUserEvent=n}isolate(){return this.prevTime?new r(this.done,this.undone):this}addChanges(e,t,s,n,i){let a=this.done,l=a[a.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!s||Lq.test(s))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?r.moveByChar(t,e):wu(t,e))}function Pr(r){return r.textDirectionAt(r.state.selection.main.head)==Zt.LTR}var Nw=r=>Lw(r,!Pr(r)),$w=r=>Lw(r,Pr(r));function Mw(r,e){return Sn(r,t=>t.empty?r.moveByGroup(t,e):wu(t,e))}var Nq=r=>Mw(r,!Pr(r)),$q=r=>Mw(r,Pr(r));var dY=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Mq(r,e,t){if(e.type.prop(t))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function ku(r,e,t){let s=pr(r).resolveInner(e.head),n=t?kt.closedBy:kt.openedBy;for(let o=e.head;;){let u=t?s.childAfter(o):s.childBefore(o);if(!u)break;Mq(r,u,n)?s=u:o=t?u.to:u.from}let i=s.type.prop(n),a,l;return i&&(a=t?xn(r,s.from,1):xn(r,s.to,-1))&&a.matched?l=t?a.end.to:a.end.from:l=t?s.to:s.from,Ze.cursor(l,t?-1:1)}var jq=r=>Sn(r,e=>ku(r.state,e,!Pr(r))),qq=r=>Sn(r,e=>ku(r.state,e,Pr(r)));function jw(r,e){return Sn(r,t=>{if(!t.empty)return wu(t,e);let s=r.moveVertically(t,e);return s.head!=t.head?s:r.moveToLineBoundary(t,e)})}var qw=r=>jw(r,!1),Qw=r=>jw(r,!0);function Vw(r){let e=r.scrollDOM.clientHeighta.empty?r.moveVertically(a,e,t.height):wu(a,e));if(n.eq(s.selection))return!1;let i;if(t.selfScroll){let a=r.coordsAtPos(s.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),o=l.top+t.marginTop,u=l.bottom-t.marginBottom;a&&a.top>o&&a.bottomUw(r,!1),dh=r=>Uw(r,!0);function Bs(r,e,t){let s=r.lineBlockAt(e.head),n=r.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?s.to:s.from)&&(n=r.moveToLineBoundary(e,t,!1)),!t&&n.head==s.from&&s.length){let i=/^\s*/.exec(r.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(n=Ze.cursor(s.from+i))}return n}var Qq=r=>Sn(r,e=>Bs(r,e,!0)),Vq=r=>Sn(r,e=>Bs(r,e,!1)),Uq=r=>Sn(r,e=>Bs(r,e,!Pr(r))),zq=r=>Sn(r,e=>Bs(r,e,Pr(r))),Zq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from,1)),Wq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to,-1));function Gq(r,e,t){let s=!1,n=la(r.selection,i=>{let a=xn(r,i.head,-1)||xn(r,i.head,1)||i.head>0&&xn(r,i.head-1,1)||i.headGq(r,e,!1);function cn(r,e){let t=la(r.state.selection,s=>{let n=e(s);return Ze.range(s.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Un(r.state,t)),!0)}function zw(r,e){return cn(r,t=>r.moveByChar(t,e))}var Zw=r=>zw(r,!Pr(r)),Ww=r=>zw(r,Pr(r));function Gw(r,e){return cn(r,t=>r.moveByGroup(t,e))}var Yq=r=>Gw(r,!Pr(r)),Hq=r=>Gw(r,Pr(r));var Kq=r=>cn(r,e=>ku(r.state,e,!Pr(r))),Jq=r=>cn(r,e=>ku(r.state,e,Pr(r)));function Xw(r,e){return cn(r,t=>r.moveVertically(t,e))}var Yw=r=>Xw(r,!1),Hw=r=>Xw(r,!0);function Kw(r,e){return cn(r,t=>r.moveVertically(t,e,Vw(r).height))}var Sw=r=>Kw(r,!1),Ew=r=>Kw(r,!0),eQ=r=>cn(r,e=>Bs(r,e,!0)),tQ=r=>cn(r,e=>Bs(r,e,!1)),rQ=r=>cn(r,e=>Bs(r,e,!Pr(r))),nQ=r=>cn(r,e=>Bs(r,e,Pr(r))),sQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from)),iQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to)),Cw=({state:r,dispatch:e})=>(e(Un(r,{anchor:0})),!0),ww=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.doc.length})),!0),kw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:0})),!0),Aw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),vh=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),aQ=({state:r,dispatch:e})=>{let t=Au(r).map(({from:s,to:n})=>Ze.range(s,Math.min(n+1,r.doc.length)));return e(r.update({selection:Ze.create(t),userEvent:"select"})),!0},oQ=({state:r,dispatch:e})=>{let t=la(r.selection,s=>{let n=pr(r),i=n.resolveStack(s.from,1);if(s.empty){let a=n.resolveStack(s.from,-1);a.node.from>=i.node.from&&a.node.to<=i.node.to&&(i=a)}for(let a=i;a;a=a.next){let{node:l}=a;if((l.from=s.to||l.to>s.to&&l.from<=s.from)&&a.next)return Ze.range(l.to,l.from)}return s});return t.eq(r.selection)?!1:(e(Un(r,t)),!0)},lQ=({state:r,dispatch:e})=>{let t=r.selection,s=null;return t.ranges.length>1?s=Ze.create([t.main]):t.main.empty||(s=Ze.create([Ze.cursor(t.main.head)])),s?(e(Un(r,s)),!0):!1};function Ro(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:s}=r,n=s.changeByRange(i=>{let{from:a,to:l}=i;if(a==l){let o=e(i);oa&&(t="delete.forward",o=Ou(r,o,!0)),a=Math.min(a,o),l=Math.max(l,o)}else a=Ou(r,a,!1),l=Ou(r,l,!0);return a==l?{range:i}:{changes:{from:a,to:l},range:Ze.cursor(a,an(r)))s.between(e,e,(n,i)=>{ne&&(e=t?i:n)});return e}var Jw=(r,e,t)=>Ro(r,s=>{let n=s.from,{state:i}=r,a=i.doc.lineAt(n),l,o;if(t&&!e&&n>a.from&&nJw(r,!1,!0);var ek=r=>Jw(r,!0,!1),tk=(r,e)=>Ro(r,t=>{let s=t.head,{state:n}=r,i=n.doc.lineAt(s),a=n.charCategorizer(s);for(let l=null;;){if(s==(e?i.to:i.from)){s==t.head&&i.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);break}let o=ur(i.text,s-i.from,e)+i.from,u=i.text.slice(Math.min(s,o)-i.from,Math.max(s,o)-i.from),c=a(u);if(l!=null&&c!=l)break;(u!=" "||s!=t.head)&&(l=c),s=o}return s}),rk=r=>tk(r,!1),uQ=r=>tk(r,!0),cQ=r=>Ro(r,e=>{let t=r.lineBlockAt(e.head).to;return e.headRo(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),pQ=r=>Ro(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head{if(r.readOnly)return!1;let t=r.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:It.of(["",""])},range:Ze.cursor(s.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},dQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(s=>{if(!s.empty||s.from==0||s.from==r.doc.length)return{range:s};let n=s.from,i=r.doc.lineAt(n),a=n==i.from?n-1:ur(i.text,n-i.from,!1)+i.from,l=n==i.to?n+1:ur(i.text,n-i.from,!0)+i.from;return{changes:{from:a,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(a,n))},range:Ze.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Au(r){let e=[],t=-1;for(let s of r.selection.ranges){let n=r.doc.lineAt(s.from),i=r.doc.lineAt(s.to);if(!s.empty&&s.to==i.from&&(i=r.doc.lineAt(s.to-1)),t>=n.number){let a=e[e.length-1];a.to=i.to,a.ranges.push(s)}else e.push({from:n.from,to:i.to,ranges:[s]});t=i.number+1}return e}function nk(r,e,t){if(r.readOnly)return!1;let s=[],n=[];for(let i of Au(r)){if(t?i.to==r.doc.length:i.from==0)continue;let a=r.doc.lineAt(t?i.to+1:i.from-1),l=a.length+1;if(t){s.push({from:i.to,to:a.to},{from:i.from,insert:a.text+r.lineBreak});for(let o of i.ranges)n.push(Ze.range(Math.min(r.doc.length,o.anchor+l),Math.min(r.doc.length,o.head+l)))}else{s.push({from:a.from,to:i.from},{from:i.to,insert:r.lineBreak+a.text});for(let o of i.ranges)n.push(Ze.range(o.anchor-l,o.head-l))}}return s.length?(e(r.update({changes:s,scrollIntoView:!0,selection:Ze.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var mQ=({state:r,dispatch:e})=>nk(r,e,!1),gQ=({state:r,dispatch:e})=>nk(r,e,!0);function sk(r,e,t){if(r.readOnly)return!1;let s=[];for(let n of Au(r))t?s.push({from:n.from,insert:r.doc.slice(n.from,n.to)+r.lineBreak}):s.push({from:n.to,insert:r.lineBreak+r.doc.slice(n.from,n.to)});return e(r.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var yQ=({state:r,dispatch:e})=>sk(r,e,!1),bQ=({state:r,dispatch:e})=>sk(r,e,!0),vQ=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Au(e).map(({from:n,to:i})=>(n>0?n--:i{let i;if(r.lineWrapping){let a=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(i=a.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,i)}).map(t);return r.dispatch({changes:t,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function xQ(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=pr(r).resolveInner(e),s=t.childBefore(e),n=t.childAfter(e),i;return s&&n&&s.to<=e&&n.from>=e&&(i=s.type.prop(kt.closedBy))&&i.indexOf(n.name)>-1&&r.doc.lineAt(s.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(s.to,n.from))?{from:s.to,to:n.from}:null}var Pw=ik(!1),OQ=ik(!0);function ik(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(n=>{let{from:i,to:a}=n,l=e.doc.lineAt(i),o=!r&&i==a&&xQ(e,i);r&&(i=a=(a<=l.to?l:e.doc.lineAt(a)).to);let u=new hi(e,{simulateBreak:i,simulateDoubleBreak:!!o}),c=bu(u,i);for(c==null&&(c=os(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));al.from&&i{let n=[];for(let a=s.from;a<=s.to;){let l=r.doc.lineAt(a);l.number>t&&(s.empty||s.to>l.from)&&(e(l,n,s),t=l.number),a=l.to+1}let i=r.changes(n);return{changes:n,range:Ze.range(i.mapPos(s.anchor,1),i.mapPos(s.head,1))}})}var SQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),s=new hi(r,{overrideIndentation:i=>{let a=t[i];return a??-1}}),n=xh(r,(i,a,l)=>{let o=bu(s,i.from);if(o==null)return;/\S/.test(i.text)||(o=0);let u=/^\s*/.exec(i.text)[0],c=oa(r,o);(u!=c||l.fromr.readOnly?!1:(e(r.update(xh(r,(t,s)=>{s.push({from:t.from,insert:r.facet(aa)})}),{userEvent:"input.indent"})),!0),ak=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(xh(r,(t,s)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let i=os(n,r.tabSize),a=0,l=oa(r,Math.max(0,i-Do(r)));for(;a(r.setTabFocusMode(),!0);var CQ=[{key:"Ctrl-b",run:Nw,shift:Zw,preventDefault:!0},{key:"Ctrl-f",run:$w,shift:Ww},{key:"Ctrl-p",run:qw,shift:Yw},{key:"Ctrl-n",run:Qw,shift:Hw},{key:"Ctrl-a",run:Zq,shift:sQ},{key:"Ctrl-e",run:Wq,shift:iQ},{key:"Ctrl-d",run:ek},{key:"Ctrl-h",run:mh},{key:"Ctrl-k",run:cQ},{key:"Ctrl-Alt-h",run:rk},{key:"Ctrl-o",run:hQ},{key:"Ctrl-t",run:dQ},{key:"Ctrl-v",run:dh}],wQ=[{key:"ArrowLeft",run:Nw,shift:Zw,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Nq,shift:Yq,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Uq,shift:rQ,preventDefault:!0},{key:"ArrowRight",run:$w,shift:Ww,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$q,shift:Hq,preventDefault:!0},{mac:"Cmd-ArrowRight",run:zq,shift:nQ,preventDefault:!0},{key:"ArrowUp",run:qw,shift:Yw,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cw,shift:kw},{mac:"Ctrl-ArrowUp",run:Ow,shift:Sw},{key:"ArrowDown",run:Qw,shift:Hw,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ww,shift:Aw},{mac:"Ctrl-ArrowDown",run:dh,shift:Ew},{key:"PageUp",run:Ow,shift:Sw},{key:"PageDown",run:dh,shift:Ew},{key:"Home",run:Vq,shift:tQ,preventDefault:!0},{key:"Mod-Home",run:Cw,shift:kw},{key:"End",run:Qq,shift:eQ,preventDefault:!0},{key:"Mod-End",run:ww,shift:Aw},{key:"Enter",run:Pw,shift:Pw},{key:"Mod-a",run:vh},{key:"Backspace",run:mh,shift:mh},{key:"Delete",run:ek},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rk},{key:"Mod-Delete",mac:"Alt-Delete",run:uQ},{mac:"Mod-Backspace",run:fQ},{mac:"Mod-Delete",run:pQ}].concat(CQ.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),ok=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jq,shift:Kq},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qq,shift:Jq},{key:"Alt-ArrowUp",run:mQ},{key:"Shift-Alt-ArrowUp",run:yQ},{key:"Alt-ArrowDown",run:gQ},{key:"Shift-Alt-ArrowDown",run:bQ},{key:"Escape",run:lQ},{key:"Mod-Enter",run:OQ},{key:"Alt-l",mac:"Ctrl-l",run:aQ},{key:"Mod-i",run:oQ,preventDefault:!0},{key:"Mod-[",run:ak},{key:"Mod-]",run:Pu},{key:"Mod-Alt-\\",run:SQ},{key:"Shift-Mod-k",run:vQ},{key:"Shift-Mod-\\",run:Xq},{key:"Mod-/",run:gh},{key:"Alt-A",run:Sq},{key:"Ctrl-m",mac:"Shift-Alt-m",run:EQ}].concat(wQ),lk={key:"Tab",run:Pu,shift:ak};function Ut(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var n=t[s];typeof n=="string"?r.setAttribute(s,n):n!=null&&(r[s]=n)}e++}for(;er.normalize("NFKD"):r=>r,Ns=class{constructor(e,t,s=0,n=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,n),this.bufferStart=s,this.normalize=i?l=>i(ck(l)):ck,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 gr(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=!0,this;let t=Ka(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=$r(e);let n=this.normalize(t);for(let i=0,a=s;;i++){let l=n.charCodeAt(i),o=this.match(l,a,this.bufferPos+this.bufferStart);if(i==n.length-1){if(o)return this.value=o,this;break}a==s&&ithis.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 s=this.curLineStart+t.index,n=s+t[0].length;if(this.matchPos=Fu(this.text,n+(s==n?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||n.to<=t){let l=new r(t,e.sliceString(t,s));return Oh.set(e,l),l}if(n.from==t&&n.to==s)return n;let{text:i,from:a}=n;return a>t&&(i=e.sliceString(t,a)+i,a=t),n.to=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 s=this.flat.from+t.index,n=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this.matchPos=Fu(this.text,n+(s==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Iu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(_u.prototype[Symbol.iterator]=Ru.prototype[Symbol.iterator]=function(){return this});function kQ(r){try{return new RegExp(r,Ah),!0}catch{return!1}}function Fu(r,e){if(e>=r.length)return e;let t=r.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}function Sh(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),t=Ut("input",{class:"cm-textfield",name:"line",value:e}),s=Ut("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),r.dispatch({effects:Bu.of(!1)}),r.focus()):i.keyCode==13&&(i.preventDefault(),n())},onsubmit:i=>{i.preventDefault(),n()}},Ut("label",r.state.phrase("Go to line"),": ",t)," ",Ut("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:a}=r,l=a.doc.lineAt(a.selection.main.head),[,o,u,c,p]=i,h=c?+c.slice(1):0,f=u?+u:l.number;if(u&&p){let g=f/100;o&&(g=g*(o=="-"?-1:1)+l.number/a.doc.lines),f=Math.round(a.doc.lines*g)}else u&&o&&(f=f*(o=="-"?-1:1)+l.number);let d=a.doc.line(Math.max(1,Math.min(a.doc.lines,f))),m=Ze.cursor(d.from+Math.max(0,Math.min(h,d.length)));r.dispatch({effects:[Bu.of(!1),at.scrollIntoView(m.from,{y:"center"})],selection:m}),r.focus()}return{dom:s}}var Bu=Et.define(),fk=Yt.define({create(){return!0},update(r,e){for(let t of e.effects)t.is(Bu)&&(r=t.value);return r},provide:r=>ui.from(r,e=>e?Sh:null)}),AQ=r=>{let e=Ji(r,Sh);if(!e){let t=[Bu.of(!0)];r.state.field(fk,!1)==null&&t.push(Et.appendConfig.of([fk,PQ])),r.dispatch({effects:t}),e=Ji(r,Sh)}return e&&e.dom.querySelector("input").select(),!0},PQ=at.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),TQ={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},mk=ut.define({combine(r){return kr(r,TQ,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function gk(r){let e=[FQ,RQ];return r&&e.push(mk.of(r)),e}var DQ=yt.mark({class:"cm-selectionMatch"}),_Q=yt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function pk(r,e,t,s){return(t==0||r(e.sliceDoc(t-1,t))!=zt.Word)&&(s==e.doc.length||r(e.sliceDoc(s,s+1))!=zt.Word)}function IQ(r,e,t,s){return r(e.sliceDoc(t,t+1))==zt.Word&&r(e.sliceDoc(s-1,s))==zt.Word}var RQ=rr.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(mk),{state:t}=r,s=t.selection;if(s.ranges.length>1)return yt.none;let n=s.main,i,a=null;if(n.empty){if(!e.highlightWordAroundCursor)return yt.none;let o=t.wordAt(n.head);if(!o)return yt.none;a=t.charCategorizer(n.head),i=t.sliceDoc(o.from,o.to)}else{let o=n.to-n.from;if(o200)return yt.none;if(e.wholeWords){if(i=t.sliceDoc(n.from,n.to),a=t.charCategorizer(n.head),!(pk(a,t,n.from,n.to)&&IQ(a,t,n.from,n.to)))return yt.none}else if(i=t.sliceDoc(n.from,n.to),!i)return yt.none}let l=[];for(let o of r.visibleRanges){let u=new Ns(t.doc,i,o.from,o.to);for(;!u.next().done;){let{from:c,to:p}=u.value;if((!a||pk(a,t,c,p))&&(n.empty&&c<=n.from&&p>=n.to?l.push(_Q.range(c,p)):(c>=n.to||p<=n.from)&&l.push(DQ.range(c,p)),l.length>e.maxMatches))return yt.none}}return yt.set(l)}},{decorations:r=>r.decorations}),FQ=at.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),BQ=({state:r,dispatch:e})=>{let{selection:t}=r,s=Ze.create(t.ranges.map(n=>r.wordAt(n.head)||Ze.cursor(n.head)),t.mainIndex);return s.eq(t)?!1:(e(r.update({selection:s})),!0)};function LQ(r,e){let{main:t,ranges:s}=r.selection,n=r.wordAt(t.head),i=n&&n.from==t.from&&n.to==t.to;for(let a=!1,l=new Ns(r.doc,e,s[s.length-1].to);;)if(l.next(),l.done){if(a)return null;l=new Ns(r.doc,e,0,Math.max(0,s[s.length-1].from-1)),a=!0}else{if(a&&s.some(o=>o.from==l.value.from))continue;if(i){let o=r.wordAt(l.value.from);if(!o||o.from!=l.value.from||o.to!=l.value.to)continue}return l.value}}var NQ=({state:r,dispatch:e})=>{let{ranges:t}=r.selection;if(t.some(i=>i.from===i.to))return BQ({state:r,dispatch:e});let s=r.sliceDoc(t[0].from,t[0].to);if(r.selection.ranges.some(i=>r.sliceDoc(i.from,i.to)!=s))return!1;let n=LQ(r,s);return n?(e(r.update({selection:r.selection.addRange(Ze.range(n.from,n.to),!1),effects:at.scrollIntoView(n.to)})),!0):!1},fa=ut.define({combine(r){return kr(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new kh(e),scrollToMatch:e=>at.scrollIntoView(e)})}});var Lu=class{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||kQ(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?`
`:s=="r"?"\r":s=="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 Ch(this):new Eh(this)}getCursor(e,t=0,s){let n=e.doc?e:Vt.create({doc:e});return s==null&&(s=n.doc.length),this.regexp?ca(this,n,t,s):ua(this,n,t,s)}},Nu=class{constructor(e){this.spec=e}};function ua(r,e,t,s){return new Ns(e.doc,r.unquoted,t,s,r.caseSensitive?void 0:n=>n.toLowerCase(),r.wholeWord?$Q(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function $Q(r,e){return(t,s,n,i)=>((i>t||i+n.length=t)return null;n.push(s.value)}return n}highlight(e,t,s,n){let i=ua(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)n(i.value.from,i.value.to)}};function ca(r,e,t,s){return new _u(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?MQ(e.charCategorizer(e.selection.main.head)):void 0},t,s)}function $u(r,e){return r.slice(ur(r,e,!1),e)}function Mu(r,e){return r.slice(e,ur(r,e))}function MQ(r){return(e,t,s)=>!s[0].length||(r($u(s.input,s.index))!=zt.Word||r(Mu(s.input,s.index))!=zt.Word)&&(r(Mu(s.input,s.index+s[0].length))!=zt.Word||r($u(s.input,s.index+s[0].length))!=zt.Word)}var Ch=class extends Nu{nextMatch(e,t,s){let n=ca(this.spec,e,s,e.doc.length).next();return n.done&&(n=ca(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,s){for(let n=1;;n++){let i=Math.max(t,s-n*1e4),a=ca(this.spec,e,i,s),l=null;for(;!a.next().done;)l=a.value;if(l&&(i==t||l.from>i+10))return l;if(i==t)return null}}prevMatch(e,t,s){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,s)=>s=="$"?"$":s=="&"?e.match[0]:s!="0"&&+s=t)return null;n.push(s.value)}return n}highlight(e,t,s,n){let i=ca(this.spec,e,Math.max(0,t-250),Math.min(s+250,e.doc.length));for(;!i.next().done;)n(i.value.from,i.value.to)}},Bo=Et.define(),Ph=Et.define(),Ls=Yt.define({create(r){return new Fo(wh(r).create(),null)},update(r,e){for(let t of e.effects)t.is(Bo)?r=new Fo(t.value.create(),r.panel):t.is(Ph)&&(r=new Fo(r.query,t.value?Th:null));return r},provide:r=>ui.from(r,e=>e.panel)});var Fo=class{constructor(e,t){this.query=e,this.panel=t}},jQ=yt.mark({class:"cm-searchMatch"}),qQ=yt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),QQ=rr.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(Ls))}update(r){let e=r.state.field(Ls);(e!=r.startState.field(Ls)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return yt.none;let{view:t}=this,s=new Fn;for(let n=0,i=t.visibleRanges,a=i.length;ni[n+1].from-2*250;)o=i[++n].to;r.highlight(t.state,l,o,(u,c)=>{let p=t.state.selection.ranges.some(h=>h.from==u&&h.to==c);s.add(u,c,p?qQ:jQ)})}return s.finish()}},{decorations:r=>r.decorations});function Lo(r){return e=>{let t=e.state.field(Ls,!1);return t&&t.query.spec.valid?r(e,t):Qu(e)}}var ju=Lo((r,{query:e})=>{let{to:t}=r.state.selection.main,s=e.nextMatch(r.state,t,t);if(!s)return!1;let n=Ze.single(s.from,s.to),i=r.state.facet(fa);return r.dispatch({selection:n,effects:[Dh(r,s),i.scrollToMatch(n.main,r)],userEvent:"select.search"}),bk(r),!0}),qu=Lo((r,{query:e})=>{let{state:t}=r,{from:s}=t.selection.main,n=e.prevMatch(t,s,s);if(!n)return!1;let i=Ze.single(n.from,n.to),a=r.state.facet(fa);return r.dispatch({selection:i,effects:[Dh(r,n),a.scrollToMatch(i.main,r)],userEvent:"select.search"}),bk(r),!0}),VQ=Lo((r,{query:e})=>{let t=e.matchAll(r.state,1e3);return!t||!t.length?!1:(r.dispatch({selection:Ze.create(t.map(s=>Ze.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),UQ=({state:r,dispatch:e})=>{let t=r.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:s,to:n}=t.main,i=[],a=0;for(let l=new Ns(r.doc,r.sliceDoc(s,n));!l.next().done;){if(i.length>1e3)return!1;l.value.from==s&&(a=i.length),i.push(Ze.range(l.value.from,l.value.to))}return e(r.update({selection:Ze.create(i,a),userEvent:"select.search.matches"})),!0},hk=Lo((r,{query:e})=>{let{state:t}=r,{from:s,to:n}=t.selection.main;if(t.readOnly)return!1;let i=e.nextMatch(t,s,s);if(!i)return!1;let a=[],l,o,u=[];if(i.from==s&&i.to==n&&(o=t.toText(e.getReplacement(i)),a.push({from:i.from,to:i.to,insert:o}),i=e.nextMatch(t,i.from,i.to),u.push(at.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(s).number)+"."))),i){let c=a.length==0||a[0].from>=i.to?0:i.to-i.from-o.length;l=Ze.single(i.from-c,i.to-c),u.push(Dh(r,i)),u.push(t.facet(fa).scrollToMatch(l.main,r))}return r.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),zQ=Lo((r,{query:e})=>{if(r.state.readOnly)return!1;let t=e.matchAll(r.state,1e9).map(n=>{let{from:i,to:a}=n;return{from:i,to:a,insert:e.getReplacement(n)}});if(!t.length)return!1;let s=r.state.phrase("replaced $ matches",t.length)+".";return r.dispatch({changes:t,effects:at.announce.of(s),userEvent:"input.replace.all"}),!0});function Th(r){return r.state.facet(fa).createPanel(r)}function wh(r,e){var t,s,n,i,a;let l=r.selection.main,o=l.empty||l.to>l.from+100?"":r.sliceDoc(l.from,l.to);if(e&&!o)return e;let u=r.facet(fa);return new Lu({search:((t=e?.literal)!==null&&t!==void 0?t:u.literal)?o:o.replace(/\n/g,"\\n"),caseSensitive:(s=e?.caseSensitive)!==null&&s!==void 0?s:u.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:u.literal,regexp:(i=e?.regexp)!==null&&i!==void 0?i:u.regexp,wholeWord:(a=e?.wholeWord)!==null&&a!==void 0?a:u.wholeWord})}function yk(r){let e=Ji(r,Th);return e&&e.dom.querySelector("[main-field]")}function bk(r){let e=yk(r);e&&e==r.root.activeElement&&e.select()}var Qu=r=>{let e=r.state.field(Ls,!1);if(e&&e.panel){let t=yk(r);if(t&&t!=r.root.activeElement){let s=wh(r.state,e.query.spec);s.valid&&r.dispatch({effects:Bo.of(s)}),t.focus(),t.select()}}else r.dispatch({effects:[Ph.of(!0),e?Bo.of(wh(r.state,e.query.spec)):Et.appendConfig.of(WQ)]});return!0},vk=r=>{let e=r.state.field(Ls,!1);if(!e||!e.panel)return!1;let t=Ji(r,Th);return t&&t.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:Ph.of(!1)}),!0},xk=[{key:"Mod-f",run:Qu,scope:"editor search-panel"},{key:"F3",run:ju,shift:qu,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ju,shift:qu,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:vk,scope:"editor search-panel"},{key:"Mod-Shift-l",run:UQ},{key:"Mod-Alt-g",run:AQ},{key:"Mod-d",run:NQ,preventDefault:!0}],kh=class{constructor(e){this.view=e;let t=this.query=e.state.field(Ls).query.spec;this.commit=this.commit.bind(this),this.searchField=Ut("input",{value:t.search,placeholder:Hr(e,"Find"),"aria-label":Hr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ut("input",{value:t.replace,placeholder:Hr(e,"Replace"),"aria-label":Hr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ut("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ut("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ut("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function s(n,i,a){return Ut("button",{class:"cm-button",name:n,onclick:i,type:"button"},a)}this.dom=Ut("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,s("next",()=>ju(e),[Hr(e,"next")]),s("prev",()=>qu(e),[Hr(e,"previous")]),s("select",()=>VQ(e),[Hr(e,"all")]),Ut("label",null,[this.caseField,Hr(e,"match case")]),Ut("label",null,[this.reField,Hr(e,"regexp")]),Ut("label",null,[this.wordField,Hr(e,"by word")]),...e.state.readOnly?[]:[Ut("br"),this.replaceField,s("replace",()=>hk(e),[Hr(e,"replace")]),s("replaceAll",()=>zQ(e),[Hr(e,"replace all")])],Ut("button",{name:"close",onclick:()=>vk(e),"aria-label":Hr(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Lu({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:Bo.of(e)}))}keydown(e){PC(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qu:ju)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),hk(this.view))}update(e){for(let t of e.transactions)for(let s of t.effects)s.is(Bo)&&!s.value.eq(this.query)&&this.setQuery(s.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(fa).top}};function Hr(r,e){return r.state.phrase(e)}var Tu=30,Du=/[\s\.,:;?!]/;function Dh(r,{from:e,to:t}){let s=r.state.doc.lineAt(e),n=r.state.doc.lineAt(t).to,i=Math.max(s.from,e-Tu),a=Math.min(n,t+Tu),l=r.state.sliceDoc(i,a);if(i!=s.from){for(let o=0;ol.length-Tu;o--)if(!Du.test(l[o-1])&&Du.test(l[o])){l=l.slice(0,o);break}}return at.announce.of(`${r.state.phrase("current match")}. ${l} ${r.state.phrase("on line")} ${s.number}.`)}var ZQ=at.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"}}),WQ=[Ls,rn.low(QQ),ZQ];var Uu=class{constructor(e,t,s,n){this.state=e,this.pos=t,this.explicit=s,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=pr(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),s=Math.max(t.from,this.pos-250),n=t.text.slice(s-t.from,this.pos-t.from),i=n.search(_k(e,!1));return i<0?null:{from:s+i,to:this.pos,text:n.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,s){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),s&&s.onDocChange&&(this.abortOnDocChange=!0))}};function Ok(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function GQ(r){let e=Object.create(null),t=Object.create(null);for(let{label:n}of r){e[n[0]]=!0;for(let i=1;itypeof n=="string"?{label:n}:n),[t,s]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:GQ(e);return n=>{let i=n.matchBefore(s);return i||n.explicit?{from:i?i.from:n.pos,options:e,validFor:t}:null}}function Dk(r,e){return t=>{for(let s=pr(t.state).resolveInner(t.pos,-1);s;s=s.parent){if(r.indexOf(s.name)>-1)return null;if(s.type.isTop)break}return e(t)}}var zu=class{constructor(e,t,s,n){this.completion=e,this.source=t,this.match=s,this.score=n}};function $s(r){return r.selection.main.from}function _k(r,e){var t;let{source:s}=r,n=e&&s[0]!="^",i=s[s.length-1]!="$";return!n&&!i?r:new RegExp(`${n?"^":""}(?:${s})${i?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":"")}var Vh=Mr.define();function XQ(r,e,t,s){let{main:n}=r.selection,i=t-n.from,a=s-n.from;return Object.assign(Object.assign({},r.changeByRange(l=>{if(l!=n&&t!=s&&r.sliceDoc(l.from+i,l.from+a)!=r.sliceDoc(t,s))return{range:l};let o=r.toText(e);return{changes:{from:l.from+i,to:s==n.from?l.to:l.from+a,insert:o},range:Ze.cursor(l.from+i+o.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}var Sk=new WeakMap;function YQ(r){if(!Array.isArray(r))return r;let e=Sk.get(r);return e||Sk.set(r,e=Qh(r)),e}var Zu=Et.define(),No=Et.define(),Rh=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(O=Ka(C))!=O.toLowerCase()?1:O!=O.toUpperCase()?2:0;(!v||w==1&&g||S==0&&w!=0)&&(t[p]==C||s[p]==C&&(h=!0)?a[p++]=v:a.length&&(y=!1)),S=w,v+=$r(C)}return p==o&&a[0]==0&&y?this.result(-100+(h?-200:0),a,e):f==o&&d==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==o?this.ret(-900-e.length,[d,m]):p==o?this.result(-100+(h?-200:0)+-700+(y?0:-1100),a,e):t.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,s){let n=[],i=0;for(let a of t){let l=a+(this.astral?$r(gr(s,a)):1);i&&n[i-1]==a?n[i-1]=l:(n[i++]=a,n[i++]=l)}return this.ret(e-s.length,n)}},Fh=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:HQ,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>s=>Ek(e(s),t(s)),optionClass:(e,t)=>s=>Ek(e(s),t(s)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Ek(r,e){return r?e?r+" "+e:r:e}function HQ(r,e,t,s,n,i){let a=r.textDirection==Zt.RTL,l=a,o=!1,u="top",c,p,h=e.left-n.left,f=n.right-e.right,d=s.right-s.left,m=s.bottom-s.top;if(l&&h=m||v>e.top?c=t.bottom-e.top:(u="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/i.offsetHeight,y=(e.right-e.left)/i.offsetWidth;return{style:`${u}: ${c/g}px; max-width: ${p/y}px`,class:"cm-completionInfo-"+(o?a?"left-narrow":"right-narrow":l?"left":"right")}}function KQ(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(t){let s=document.createElement("div");return s.classList.add("cm-completionIcon"),t.type&&s.classList.add(...t.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),s.setAttribute("aria-hidden","true"),s},position:20}),e.push({render(t,s,n,i){let a=document.createElement("span");a.className="cm-completionLabel";let l=t.displayLabel||t.label,o=0;for(let u=0;uo&&a.appendChild(document.createTextNode(l.slice(o,c)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(l.slice(c,p))),h.className="cm-completionMatchedText",o=p}return ot.position-s.position).map(t=>t.render)}function _h(r,e,t){if(r<=t)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let n=Math.floor(e/t);return{from:n*t,to:(n+1)*t}}let s=Math.floor((r-e)/t);return{from:r-(s+1)*t,to:r-s*t}}var Bh=class{constructor(e,t,s){this.view=e,this.stateField=t,this.applyCompletion=s,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:o=>this.placeInfo(o),key:this},this.space=null,this.currentClass="";let n=e.state.field(t),{options:i,selected:a}=n.open,l=e.state.facet(Sr);this.optionContent=KQ(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=_h(i.length,a,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",o=>{let{options:u}=e.state.field(t).open;for(let c=o.target,p;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(p=/-(\d+)$/.exec(c.id))&&+p[1]{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(Sr).closeOnBlur&&o.relatedTarget!=e.contentDOM&&e.dispatch({effects:No.of(null)})}),this.showOptions(i,n.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let s=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),s!=n){let{options:i,selected:a,disabled:l}=s.open;(!n.open||n.open.options!=i)&&(this.range=_h(i.length,a,e.state.facet(Sr).maxRenderedOptions),this.showOptions(i,s.id)),this.updateSel(),l!=((t=n.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let s of this.currentClass.split(" "))s&&this.dom.classList.remove(s);for(let s of t.split(" "))s&&this.dom.classList.add(s);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=_h(t.options.length,t.selected,this.view.state.facet(Sr).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:n}=s;if(!n)return;let i=typeof n=="string"?document.createTextNode(n):n(s);if(!i)return;"then"in i?i.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>yr(this.view.state,a,"completion info")):this.addInfoPane(i,s)}}addInfoPane(e,t){this.destroyInfo();let s=this.info=document.createElement("div");if(s.className="cm-tooltip cm-completionInfo",e.nodeType!=null)s.appendChild(e),this.infoDestroy=null;else{let{dom:n,destroy:i}=e;s.appendChild(n),this.infoDestroy=i||null}this.dom.appendChild(s),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let s=this.list.firstChild,n=this.range.from;s;s=s.nextSibling,n++)s.nodeName!="LI"||!s.id?n--:n==e?s.hasAttribute("aria-selected")||(s.setAttribute("aria-selected","true"),t=s):s.hasAttribute("aria-selected")&&s.removeAttribute("aria-selected");return t&&e5(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),n=e.getBoundingClientRect(),i=this.space;if(!i){let a=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:a.innerWidth,bottom:a.innerHeight}}return n.top>Math.min(i.bottom,t.bottom)-10||n.bottoms.from||s.from==0))if(i=h,typeof u!="string"&&u.header)n.appendChild(u.header(u));else{let f=n.appendChild(document.createElement("completion-section"));f.textContent=h}}let c=n.appendChild(document.createElement("li"));c.id=t+"-"+a,c.setAttribute("role","option");let p=this.optionClass(l);p&&(c.className=p);for(let h of this.optionContent){let f=h(l,this.view.state,this.view,o);f&&c.appendChild(f)}}return s.from&&n.classList.add("cm-completionListIncompleteTop"),s.tonew Bh(t,r,e)}function e5(r,e){let t=r.getBoundingClientRect(),s=e.getBoundingClientRect(),n=t.height/r.offsetHeight;s.topt.bottom&&(r.scrollTop+=(s.bottom-t.bottom)/n)}function Ck(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function t5(r,e){let t=[],s=null,n=u=>{t.push(u);let{section:c}=u.completion;if(c){s||(s=[]);let p=typeof c=="string"?c:c.name;s.some(h=>h.name==p)||s.push(typeof c=="string"?{name:p}:c)}},i=e.facet(Sr);for(let u of r)if(u.hasResult()){let c=u.result.getMatch;if(u.result.filter===!1)for(let p of u.result.options)n(new zu(p,u.source,c?c(p):[],1e9-t.length));else{let p=e.sliceDoc(u.from,u.to),h,f=i.filterStrict?new Fh(p):new Rh(p);for(let d of u.result.options)if(h=f.match(d.label)){let m=d.displayLabel?c?c(d,h.matched):[]:h.matched;n(new zu(d,u.source,m,h.score+(d.boost||0)))}}}if(s){let u=Object.create(null),c=0,p=(h,f)=>{var d,m;return((d=h.rank)!==null&&d!==void 0?d:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(h.namep.score-c.score||o(c.completion,p.completion))){let c=u.completion;!l||l.label!=c.label||l.detail!=c.detail||l.type!=null&&c.type!=null&&l.type!=c.type||l.apply!=c.apply||l.boost!=c.boost?a.push(u):Ck(u.completion)>Ck(l)&&(a[a.length-1]=u),l=u.completion}return a}var Lh=class r{constructor(e,t,s,n,i,a){this.options=e,this.attrs=t,this.tooltip=s,this.timestamp=n,this.selected=i,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new r(this.options,wk(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,s,n,i){let a=t5(e,t);if(!a.length)return n&&e.some(o=>o.state==1)?new r(n.options,n.attrs,n.tooltip,n.timestamp,n.selected,!0):null;let l=t.facet(Sr).selectOnOpen?0:-1;if(n&&n.selected!=l&&n.selected!=-1){let o=n.options[n.selected].completion;for(let u=0;uu.hasResult()?Math.min(o,u.from):o,1e8),create:o5,above:i.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(e){return new r(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},Nh=class r{constructor(e,t,s){this.active=e,this.id=t,this.open=s}static start(){return new r(i5,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,s=t.facet(Sr),i=(s.override||t.languageDataAt("autocomplete",$s(t)).map(YQ)).map(l=>(this.active.find(u=>u.source==l)||new us(l,this.active.some(u=>u.state!=0)?1:0)).update(e,s));i.length==this.active.length&&i.every((l,o)=>l==this.active[o])&&(i=this.active);let a=this.open;a&&e.docChanged&&(a=a.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!r5(i,this.active)?a=Lh.build(i,t,this.id,a,s):a&&a.disabled&&!i.some(l=>l.state==1)&&(a=null),!a&&i.every(l=>l.state!=1)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new us(l.source,0):l));for(let l of e.effects)l.is(Fk)&&(a=a&&a.setSelected(l.value,this.id));return i==this.active&&a==this.open?this:new r(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?n5:s5}};function r5(r,e){if(r==e)return!0;for(let t=0,s=0;;){for(;t-1&&(t["aria-activedescendant"]=r+"-"+e),t}var i5=[];function Ik(r,e){if(r.isUserEvent("input.complete")){let s=r.annotation(Vh);if(s&&e.activateOnCompletion(s))return 12}let t=r.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:r.isUserEvent("delete.backward")?2:r.selection?8:r.docChanged?16:0}var us=class r{constructor(e,t,s=-1){this.source=e,this.state=t,this.explicitPos=s}hasResult(){return!1}update(e,t){let s=Ik(e,t),n=this;(s&8||s&16&&this.touches(e))&&(n=new r(n.source,0)),s&4&&n.state==0&&(n=new r(this.source,1)),n=n.updateFor(e,s);for(let i of e.effects)if(i.is(Zu))n=new r(n.source,1,i.value?$s(e.state):-1);else if(i.is(No))n=new r(n.source,0);else if(i.is(Rk))for(let a of i.value)a.source==n.source&&(n=a);return n}updateFor(e,t){return this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new r(this.source,this.state,e.mapPos(this.explicitPos))}touches(e){return e.changes.touchesRange($s(e.state))}},Wu=class r extends us{constructor(e,t,s,n,i){super(e,2,t),this.result=s,this.from=n,this.to=i}hasResult(){return!0}updateFor(e,t){var s;if(!(t&3))return this.map(e.changes);let n=this.result;n.map&&!e.changes.empty&&(n=n.map(n,e.changes));let i=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=$s(e.state);if((this.explicitPos<0?l<=i:la||!n||t&2&&$s(e.startState)==this.from)return new us(this.source,t&4?1:0);let o=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return a5(n.validFor,e.state,i,a)?new r(this.source,o,n,i,a):n.update&&(n=n.update(n,i,a,new Uu(e.state,l,o>=0)))?new r(this.source,o,n,n.from,(s=n.to)!==null&&s!==void 0?s:$s(e.state)):new us(this.source,1,o)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new r(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new us(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function a5(r,e,t,s){if(!r)return!1;let n=e.sliceDoc(t,s);return typeof r=="function"?r(n,t,s,e):_k(r,!0).test(n)}var Rk=Et.define({map(r,e){return r.map(t=>t.map(e))}}),Fk=Et.define(),qr=Yt.define({create(){return Nh.start()},update(r,e){return r.update(e)},provide:r=>[Ki.from(r,e=>e.tooltip),at.contentAttributes.from(r,e=>e.attrs)]});function Uh(r,e){let t=e.completion.apply||e.completion.label,s=r.state.field(qr).active.find(n=>n.source==e.source);return s instanceof Wu?(typeof t=="string"?r.dispatch(Object.assign(Object.assign({},XQ(r.state,t,s.from,s.to)),{annotations:Vh.of(e.completion)})):t(r,e.completion,s.from,s.to),!0):!1}var o5=JQ(qr,Uh);function Vu(r,e="option"){return t=>{let s=t.state.field(qr,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp-1?s.open.selected+n*(r?1:-1):r?0:a-1;return l<0?l=e=="page"?0:a-1:l>=a&&(l=e=="page"?a-1:0),t.dispatch({effects:Fk.of(l)}),!0}}var l5=r=>{let e=r.state.field(qr,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampr.state.field(qr,!1)?(r.dispatch({effects:Zu.of(!0)}),!0):!1,u5=r=>{let e=r.state.field(qr,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(r.dispatch({effects:No.of(null)}),!0)},$h=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},c5=50,f5=1e3,p5=rr.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(qr).active)e.state==1&&this.startQuery(e)}update(r){let e=r.state.field(qr),t=r.state.facet(Sr);if(!r.selectionSet&&!r.docChanged&&r.startState.field(qr)==e)return;let s=r.transactions.some(i=>{let a=Ik(i,t);return a&8||(i.selection||i.docChanged)&&!(a&3)});for(let i=0;ic5&&Date.now()-a.time>f5){for(let l of a.context.abortListeners)try{l()}catch(o){yr(this.view.state,o)}a.context.abortListeners=null,this.running.splice(i--,1)}else a.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(i=>i.effects.some(a=>a.is(Zu)))&&(this.pendingStart=!0);let n=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(a=>a.active.source==i.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let i of r.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(qr);for(let t of e.active)t.state==1&&!this.running.some(s=>s.active.source==t.source)&&this.startQuery(t)}startQuery(r){let{state:e}=this.view,t=$s(e),s=new Uu(e,t,r.explicitPos==t,this.view),n=new $h(r,s);this.running.push(n),Promise.resolve(r.source(s)).then(i=>{n.context.aborted||(n.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:No.of(null)}),yr(this.view.state,i)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Sr).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Sr);for(let s=0;sa.source==n.active.source);if(i&&i.state==1)if(n.done==null){let a=new us(n.active.source,0);for(let l of n.updates)a=a.update(l,t);a.state!=1&&e.push(a)}else this.startQuery(i)}e.length&&this.view.dispatch({effects:Rk.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(qr,!1);if(e&&e.tooltip&&this.view.state.facet(Sr).closeOnBlur){let t=e.open&&jp(this.view,e.open.tooltip);(!t||!t.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:No.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Zu.of(!1)}),20),this.composing=0}}}),h5=typeof navigator=="object"&&/Win/.test(navigator.platform),d5=rn.highest(at.domEventHandlers({keydown(r,e){let t=e.state.field(qr,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||r.key.length>1||r.ctrlKey&&!(h5&&r.altKey)||r.metaKey)return!1;let s=t.open.options[t.open.selected],n=t.active.find(a=>a.source==s.source),i=s.completion.commitCharacters||n.result.commitCharacters;return i&&i.indexOf(r.key)>-1&&Uh(e,s),!1}})),Bk=at.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Mh=class{constructor(e,t,s,n){this.field=e,this.line=t,this.from=s,this.to=n}},jh=class r{constructor(e,t,s){this.field=e,this.from=t,this.to=s}map(e){let t=e.mapPos(this.from,-1,fr.TrackDel),s=e.mapPos(this.to,1,fr.TrackDel);return t==null||s==null?null:new r(this.field,t,s)}},qh=class r{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let s=[],n=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let o of this.lines){if(s.length){let u=a,c=/^\t*/.exec(o)[0].length;for(let p=0;pnew jh(o.field,n[o.line]+o.from,n[o.line]+o.to));return{text:s,ranges:l}}static parse(e){let t=[],s=[],n=[],i;for(let a of e.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let l=i[1]?+i[1]:null,o=i[2]||i[3]||"",u=-1,c=o.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p=u&&h.field++}n.push(new Mh(u,s.length,i.index,i.index+c.length)),a=a.slice(0,i.index)+o+a.slice(i.index+i[0].length)}a=a.replace(/\\([{}])/g,(l,o,u)=>{for(let c of n)c.line==s.length&&c.from>u&&(c.from--,c.to--);return o}),s.push(a)}return new r(s,n)}},m5=yt.widget({widget:new class extends an{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),g5=yt.mark({class:"cm-snippetField"}),pa=class r{constructor(e,t){this.ranges=e,this.active=t,this.deco=yt.set(e.map(s=>(s.from==s.to?m5:g5).range(s.from,s.to)))}map(e){let t=[];for(let s of this.ranges){let n=s.map(e);if(!n)return null;t.push(n)}return new r(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(s=>s.field==this.active&&s.from<=t.from&&s.to>=t.to))}},Mo=Et.define({map(r,e){return r&&r.map(e)}}),y5=Et.define(),$o=Yt.define({create(){return null},update(r,e){for(let t of e.effects){if(t.is(Mo))return t.value;if(t.is(y5)&&r)return new pa(r.ranges,t.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>at.decorations.from(r,e=>e?e.deco:yt.none)});function zh(r,e){return Ze.create(r.filter(t=>t.field==e).map(t=>Ze.range(t.from,t.to)))}function b5(r){let e=qh.parse(r);return(t,s,n,i)=>{let{text:a,ranges:l}=e.instantiate(t.state,n),o={changes:{from:n,to:i,insert:It.of(a)},scrollIntoView:!0,annotations:s?[Vh.of(s),lr.userEvent.of("input.complete")]:void 0};if(l.length&&(o.selection=zh(l,0)),l.some(u=>u.field>0)){let u=new pa(l,0),c=o.effects=[Mo.of(u)];t.state.field($o,!1)===void 0&&c.push(Et.appendConfig.of([$o,E5,C5,Bk]))}t.dispatch(t.state.update(o))}}function Lk(r){return({state:e,dispatch:t})=>{let s=e.field($o,!1);if(!s||r<0&&s.active==0)return!1;let n=s.active+r,i=r>0&&!s.ranges.some(a=>a.field==n+r);return t(e.update({selection:zh(s.ranges,n),effects:Mo.of(i?null:new pa(s.ranges,n)),scrollIntoView:!0})),!0}}var v5=({state:r,dispatch:e})=>r.field($o,!1)?(e(r.update({effects:Mo.of(null)})),!0):!1,x5=Lk(1),O5=Lk(-1);var S5=[{key:"Tab",run:x5,shift:O5},{key:"Escape",run:v5}],Ak=ut.define({combine(r){return r.length?r[0]:S5}}),E5=rn.highest(_s.compute([Ak],r=>r.facet(Ak)));function Rr(r,e){return Object.assign(Object.assign({},e),{apply:b5(r)})}var C5=at.domEventHandlers({mousedown(r,e){let t=e.state.field($o,!1),s;if(!t||(s=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let n=t.ranges.find(i=>i.from<=s&&i.to>=s);return!n||n.field==t.active?!1:(e.dispatch({selection:zh(t.ranges,n.field),effects:Mo.of(t.ranges.some(i=>i.field>n.field)?new pa(t.ranges,n.field):null),scrollIntoView:!0}),!0)}});var Gu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=Et.define({map(r,e){let t=e.mapPos(r,-1,fr.TrackAfter);return t??void 0}}),Zh=new class extends yn{};Zh.startSide=1;Zh.endSide=-1;var Nk=Yt.define({create(){return Mt.empty},update(r,e){if(r=r.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:s=>s>=t.from&&s<=t.to})}for(let t of e.effects)t.is(mi)&&(r=r.update({add:[Zh.range(t.value,t.value+1)]}));return r}});function $k(){return[P5,Nk]}var Ih="()[]{}<>";function w5(r){for(let e=0;e{if((A5?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let n=r.state.selection.main;if(s.length>2||s.length==2&&$r(gr(s,0))==1||e!=n.from||t!=n.to)return!1;let i=T5(r.state,s);return i?(r.dispatch(i),!0):!1});function T5(r,e){let t=k5(r,r.selection.main.head),s=t.brackets||Gu.brackets;for(let n of s){let i=w5(gr(n,0));if(e==n)return i==n?I5(r,n,s.indexOf(n+n+n)>-1,t):D5(r,n,i,t.before||Gu.before);if(e==i&&Mk(r,r.selection.main.from))return _5(r,n,i)}return null}function Mk(r,e){let t=!1;return r.field(Nk).between(0,r.doc.length,s=>{s==e&&(t=!0)}),t}function Wh(r,e){let t=r.sliceString(e,e+2);return t.slice(0,$r(gr(t,0)))}function D5(r,e,t,s){let n=null,i=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:mi.of(a.to+e.length),range:Ze.range(a.anchor+e.length,a.head+e.length)};let l=Wh(r.doc,a.head);return!l||/\s/.test(l)||s.indexOf(l)>-1?{changes:{insert:e+t,from:a.head},effects:mi.of(a.head+e.length),range:Ze.cursor(a.head+e.length)}:{range:n=a}});return n?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function _5(r,e,t){let s=null,n=r.changeByRange(i=>i.empty&&Wh(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:Ze.cursor(i.head+t.length)}:s={range:i});return s?null:r.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function I5(r,e,t,s){let n=s.stringPrefixes||Gu.stringPrefixes,i=null,a=r.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:mi.of(l.to+e.length),range:Ze.range(l.anchor+e.length,l.head+e.length)};let o=l.head,u=Wh(r.doc,o),c;if(u==e){if(Pk(r,o))return{changes:{insert:e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)};if(Mk(r,o)){let h=t&&r.sliceDoc(o,o+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:o,to:o+h.length,insert:h},range:Ze.cursor(o+h.length)}}}else{if(t&&r.sliceDoc(o-2*e.length,o)==e+e&&(c=Tk(r,o-2*e.length,n))>-1&&Pk(r,c))return{changes:{insert:e+e+e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)};if(r.charCategorizer(o)(u)!=zt.Word&&Tk(r,o,n)>-1&&!R5(r,o,e,n))return{changes:{insert:e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)}}return{range:i=l}});return i?null:r.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Pk(r,e){let t=pr(r).resolveInner(e+1);return t.parent&&t.from==e}function R5(r,e,t,s){let n=pr(r).resolveInner(e,-1),i=s.reduce((a,l)=>Math.max(a,l.length),0);for(let a=0;a<5;a++){let l=r.sliceDoc(n.from,Math.min(n.to,n.from+t.length+i)),o=l.indexOf(t);if(!o||o>-1&&s.indexOf(l.slice(0,o))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>t.length+o;){if(r.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let u=n.to==e&&n.parent;if(!u)break;n=u}return!1}function Tk(r,e,t){let s=r.charCategorizer(e);if(s(r.sliceDoc(e-1,e))!=zt.Word)return e;for(let n of t){let i=e-n.length;if(r.sliceDoc(i,e)==n&&s(r.sliceDoc(i-1,i))!=zt.Word)return i}return-1}function jk(r={}){return[d5,qr,Sr.of(r),p5,B5,Bk]}var F5=[{key:"Ctrl-Space",run:kk},{mac:"Alt-`",run:kk},{key:"Escape",run:u5},{key:"ArrowDown",run:Vu(!0)},{key:"ArrowUp",run:Vu(!1)},{key:"PageDown",run:Vu(!0,"page")},{key:"PageUp",run:Vu(!1,"page")},{key:"Enter",run:l5}],B5=rn.highest(_s.computeN([Sr],r=>r.facet(Sr).defaultKeymap?[F5]:[]));var Gh=class{constructor(e,t,s){this.from=e,this.to=t,this.diagnostic=s}},gi=class r{constructor(e,t,s){this.diagnostics=e,this.panel=t,this.selected=s}static init(e,t,s){let n=e,i=s.facet(zn).markerFilter;i&&(n=i(n,s));let a=yt.set(n.map(l=>l.from==l.to||l.from==l.to-1&&s.doc.lineAt(l.from).to==l.from?yt.widget({widget:new Xh(l),diagnostic:l}).range(l.from):yt.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new r(a,t,ha(a))}};function ha(r,e=null,t=0){let s=null;return r.between(t,1e9,(n,i,{spec:a})=>{if(!(e&&a.diagnostic!=e))return s=new Gh(n,i,a.diagnostic),!1}),s}function Vk(r,e){let t=e.pos,s=e.end||t,n=r.state.facet(zn).hideOn(r,t,s);if(n!=null)return n;let i=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(a=>a.is(ec))||r.changes.touchesRange(i.from,Math.max(i.to,s)))}function L5(r,e){return r.field(En,!1)?e:e.concat(Et.appendConfig.of(Hk))}function N5(r,e){return{effects:L5(r,[ec.of(e)])}}var ec=Et.define(),Uk=Et.define(),zk=Et.define(),En=Yt.define({create(){return new gi(yt.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let t=r.diagnostics.map(e.changes),s=null,n=r.panel;if(r.selected){let i=e.changes.mapPos(r.selected.from,1);s=ha(t,r.selected.diagnostic,i)||ha(t,null,i)}!t.size&&n&&e.state.facet(zn).autoPanel&&(n=null),r=new gi(t,n,s)}for(let t of e.effects)if(t.is(ec)){let s=e.state.facet(zn).autoPanel?t.value.length?Ku.open:null:r.panel;r=gi.init(t.value,s,e.state)}else t.is(Uk)?r=new gi(r.diagnostics,t.value?Ku.open:null,r.selected):t.is(zk)&&(r=new gi(r.diagnostics,r.panel,t.value));return r},provide:r=>[ui.from(r,e=>e.panel),at.decorations.from(r,e=>e.diagnostics)]});var $5=yt.mark({class:"cm-lintRange cm-lintRange-active"});function M5(r,e,t){let{diagnostics:s}=r.state.field(En),n=[],i=2e8,a=0;s.between(e-(t<0?1:0),e+(t>0?1:0),(o,u,{spec:c})=>{e>=o&&e<=u&&(o==u||(e>o||t>0)&&(eXk(r,t,!1)))}var qk=r=>{let e=r.state.field(En,!1);return!e||!e.panel?!1:(r.dispatch({effects:Uk.of(!1)}),!0)};var j5=rr.fromClass(class{constructor(r){this.view=r,this.timeout=-1,this.set=!0;let{delay:e}=r.state.facet(zn);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let r=Date.now();if(rPromise.resolve(s(this.view))),s=>{this.view.state.doc==e.doc&&this.view.dispatch(N5(this.view.state,s.reduce((n,i)=>n.concat(i))))},s=>{yr(this.view.state,s)})}}update(r){let e=r.state.facet(zn);(r.docChanged||e!=r.startState.facet(zn)||e.needsRefresh&&e.needsRefresh(r))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function q5(r,e,t){let s=[],n=-1;for(let i of r)i.then(a=>{s.push(a),clearTimeout(n),s.length==r.length?e(s):setTimeout(()=>e(s),200)},t)}var zn=ut.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},kr(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?s=>e(s)||t(s):e:t}))}});function Wk(r,e={}){return[zn.of({source:r,config:e}),j5,Hk]}function Gk(r){let e=[];if(r)e:for(let{name:t}of r){for(let s=0;si.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function Xk(r,e,t){var s;let n=t?Gk(e.actions):[];return Ut("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ut("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(s=e.actions)===null||s===void 0?void 0:s.map((i,a)=>{let l=!1,o=h=>{if(h.preventDefault(),l)return;l=!0;let f=ha(r.state.field(En).diagnostics,e);f&&i.apply(r,f.from,f.to)},{name:u}=i,c=n[a]?u.indexOf(n[a]):-1,p=c<0?u:[u.slice(0,c),Ut("u",u.slice(c,c+1)),u.slice(c+1)];return Ut("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${u}${c<0?"":` (access key "${n[a]})"`}.`},p)}),e.source&&Ut("div",{class:"cm-diagnosticSource"},e.source))}var Xh=class extends an{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Ut("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Hu=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Xk(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ku=class r{constructor(e){this.view=e,this.items=[];let t=n=>{if(n.keyCode==27)qk(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],a=Gk(i.actions);for(let l=0;l{for(let i=0;iqk(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(En).selected;if(!e)return-1;for(let t=0;t{let u=-1,c;for(let p=s;ps&&(this.items.splice(s,u-s),n=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),i=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),s++});s