t;){let f=true,c=false;if(!h||a>r[h-1].to){let g=q[a-1];g!=l&&(f=false,c=g==16);}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;t:for(;;)if(h&&p==r[h-1].to){if(c)break t;let g=r[--h];if(!f)for(let m=g.from,b=h;;){if(m==t)break t;if(b&&r[b-1].to==m)m=r[--b].from;else {if(q[m-1]==l)break t;break}}if(u)u.push(g);else {g.toq.length;)q[q.length]=256;let i=[],s=t==fe?0:1;return _s(n,s,s,e,0,n.length,i),i}function Bo(n){return [new Ht(0,n,0)]}let Eo="";function Ea(n,t,e,i,s){var r;let o=i.head-n.from,l=Ht.find(t,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=t[l],h=a.side(s,e);if(o==h){let u=l+=s?1:-1;if(u<0||u>=t.length)return null;a=t[l=u],o=a.side(!s,e),h=a.side(s,e);}let f=mt(n.text,o,a.forward(s,e));(f =0;N-=3)O[K++]=R[N],O[K++]=R[N+1]-V,O[K++]=R[N+2]-V,O[K++]=K;x.push(new Qt(O,R[2]-V,i)),E.push(V-w);}}function d(w,v){return (x,E,R)=>{let z=0,P=x.length-1,O,V;if(P>=0&&(O=x[P])instanceof _){if(!P&&O.type==w&&O.length==R)return O;(V=O.prop(I.lookAhead))&&(z=E[P]+O.length+V);}return g(w,x,E,R,z,v)}}function p(w,v,x,E,R,z,P,O,V){let N=[],K=[];for(;w.length>E;)N.push(w.pop()),K.push(v.pop()+x-R);w.push(g(i.types[P],N,K,z-R,O-z,V)),v.push(R-x);}function g(w,v,x,E,R,z,P){if(z){let O=[I.contextHash,z];P=P?[O].concat(P):[O];}if(R>25){let O=[I.lookAhead,R];P=P?[O].concat(P):[O];}return new _(w,v,x,E,P)}function m(w,v){let x=l.fork(),E=0,R=0,z=0,P=x.end-s,O={size:0,start:0,skip:0};t:for(let V=x.pos-w;x.pos>V;){let N=x.size;if(x.id==v&&N>=0){O.size=E,O.start=R,O.skip=z,z+=4,E+=4,x.next();continue}let K=x.pos-N;if(N<0||K=h&&(h=Math.min(g.top,h),f=Math.max(g.bottom,f),b=0),(r<0||(b-a||m-l)<0)&&(r>=0&&a&&l0&&l>0&&n.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));e-=o+a-r;}if(othis.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let r=[];t>0&&this.decomposeLeft(t,r);let o=r.length;for(let l of i)r.push(l);if(t>0&&br(r,o-1),e=t&&a<=e}function iu(n,t={}){let e=U.define(),i=Ft.define({create(){return []},update(s,r){if(s.length&&(t.hideOnChange&&(r.docChanged||r.selection)?s=[]:t.hideOn&&(s=s.filter(o=>!t.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,at.TrackDel);if(a!=null){let h=Object.assign(Object.create(null),l);h.pos=a,h.end!=null&&(h.end=r.changes.mapPos(h.end)),o.push(h);}}s=o;}for(let o of r.effects)o.is(e)&&(s=o.value),o.is(Pf)&&(s=[]);return s},provide:s=>Fi.from(s)});return {active:i,extension:[i,nt.define(s=>new Df(s,n,i,e,t.hoverTime||300)),Of]}}function su(n,t){let e=n.plugin(Dn);if(!e)return null;let i=e.manager.tooltips.indexOf(t);return i<0?null:e.manager.tooltipViews[i]}const Pf=U.define(),Rr=A.define({combine(n){let t,e;for(let i of n)t=t||i.topContainer,e=e||i.bottomContainer;return {topContainer:t,bottomContainer:e}}});function nu(n,t){let e=n.plugin(ml),i=e?e.specs.indexOf(t):-1;return i>-1?e.panels[i]:null}const ml=nt.fromClass(class{constructor(n){this.input=n.state.facet(Ir),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(n));let t=n.state.facet(Rr);this.top=new wi(n,true,t.topContainer),this.bottom=new wi(n,false,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount();}update(n){let t=n.state.facet(Rr);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new wi(n.view,true,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new wi(n.view,false,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=n.state.facet(Ir);if(e!=this.input){let i=e.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),f;h<0?(f=a(n.view),l.push(f)):(f=this.panels[h],f.update&&f.update(n)),s.push(f),(f.top?r:o).push(f);}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount();}else for(let i of this.panels)i.update&&i.update(n);}destroy(){this.top.sync([]),this.bottom.sync([]);}},{provide:n=>B.scrollMargins.of(t=>{let e=t.plugin(n);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class wi{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses();}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM();}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null);}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Lr(t);t=t.nextSibling;}else this.dom.insertBefore(e.dom,t);for(;t;)t=Lr(t);}scrollMargin(){return !this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of (this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t);}}}function Lr(n){let t=n.nextSibling;return n.remove(),t}const Ir=A.define({enables:ml});class Jt extends le{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return false}destroy(t){}}Jt.prototype.elementClass="";Jt.prototype.toDOM=void 0;Jt.prototype.mapMode=at.TrackBefore;Jt.prototype.startSide=Jt.prototype.endSide=-1;Jt.prototype.point=true;const gs=A.define(),Rf=A.define(),Lf={class:"",renderEmptyElements:false,elementStyle:"",markers:()=>L.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},qe=A.define();function If(n){return [bl(),qe.of({...Lf,...n})]}const Nr=A.define({combine:n=>n.some(t=>t)});function bl(n){return [Nf]}const Nf=nt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(qe).map(t=>new Wr(n,t)),this.fixed=!n.state.facet(Nr);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(false),n.scrollDOM.insertBefore(this.dom,n.contentDOM);}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let t=this.prevViewport,e=n.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8);}if(n.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t);}this.view.state.facet(Nr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport;}syncGutters(n){let t=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let e=L.iter(this.view.state.facet(gs),this.view.viewport.from),i=[],s=this.gutters.map(r=>new Hf(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=true;for(let l of r.type)if(l.type==et.Text&&o){on(e,i,l.from);for(let a of s)a.line(this.view,l,i);o=false;}else if(l.widget)for(let a of s)a.widget(this.view,l);}else if(r.type==et.Text){on(e,i,r.from);for(let o of s)o.line(this.view,r,i);}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter));}updateGutters(n){let t=n.startState.facet(qe),e=n.state.facet(qe),i=n.docChanged||n.heightChanged||n.viewportChanged||!L.eq(n.startState.facet(gs),n.state.facet(gs),n.view.viewport.from,n.view.viewport.to);if(t==e)for(let s of this.gutters)s.update(n)&&(i=true);else {i=true;let s=[];for(let r of e){let o=t.indexOf(r);o<0?s.push(new Wr(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]));}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s;}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove();}},{provide:n=>B.scrollMargins.of(t=>{let e=t.plugin(n);if(!e||e.gutters.length==0||!e.fixed)return null;let i=e.dom.offsetWidth*t.scaleX,s=e.domAfter?e.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==$.LTR?{left:i,right:s}:{right:i,left:s}})});function Hr(n){return Array.isArray(n)?n:[n]}function on(n,t,e){for(;n.value&&n.from<=e;)n.from==e&&t.push(n.value),n.next();}class Hf{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=L.iter(t.markers,e.from);}addElement(t,e,i){let{gutter:s}=this,r=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==s.elements.length){let l=new yl(t,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom);}else s.elements[this.i].update(t,o,r,i);this.height=e.bottom,this.i++;}line(t,e,i){let s=[];on(this.cursor,s,e.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(t,e,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(t,e,s);}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let r of t.state.facet(Rf)){let o=r(t,e.widget,e);o&&(s||(s=[])).push(o);}s&&this.addElement(t,e,s);}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy();}}}class Wr{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2;}else o=s.clientY;let l=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,l,s)&&s.preventDefault();});this.markers=Hr(e.markers(t)),e.initialSpacer&&(this.spacer=new yl(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none");}update(t){let e=this.markers;if(this.markers=Hr(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],t);s!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[s]);}let i=t.view.viewport;return !L.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):false)}destroy(){for(let t of this.elements)t.destroy();}}class yl{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s);}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Wf(this.markers,s)||this.setMarkers(t,s);}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r=f)break;v+=x;}if(T==D+1){if(v>f){let x=p[D];d(x.children,x.positions,0,x.children.length,g[D]+M);continue}c.push(p[D]);}else {let x=g[T-1]+p[T-1].length-w;c.push(Rn(n,p,g,D,T,w,x,null,a));}u.push(w+M-r);}}return d(t,e,i,s,0),(l||a)(c,u,o)}class oe{constructor(t,e,i,s,r=false,o=false){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0);}get openStart(){return (this.open&1)>0}get openEnd(){return (this.open&2)>0}static addTree(t,e=[],i=false){let s=[new oe(0,t.length,t,0,false,i)];for(let r of e)r.to>t.length&&s.push(r);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],r=1,o=t.length?t[0]:null;for(let l=0,a=0,h=0;;l++){let f=l