this.addMatch(F,t,P,M));e=e.update({filterFrom:p,filterTo:v,filter:(P,F)=>Pv,add:x})}}return e}}function Rx(){return zx}const Bx=Yt.line({class:"cm-activeLine"}),zx=ti.fromClass(class{constructor(o){this.decorations=this.getDeco(o)}update(o){(o.docChanged||o.selectionSet)&&(this.decorations=this.getDeco(o.view))}getDeco(o){let t=-1,e=[];for(let i of o.state.selection.ranges){let n=o.lineBlockAt(i.head);n.from>t&&(e.push(Bx.range(n.from)),t=n.from)}return Yt.set(e)}},{decorations:o=>o.decorations});class Fx extends Zo{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?_s(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),n=zr(e[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return n.bottom-n.top>s*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+s}:n}ignoreEvent(){return!1}}function Wx(o){let t=ti.fromClass(class{constructor(e){this.view=e,this.placeholder=o?Yt.set([Yt.widget({widget:new Fx(o),side:1}).range(0)]):Yt.none}get decorations(){return this.view.state.doc.length?Yt.none:this.placeholder}},{decorations:e=>e.decorations});return typeof o=="string"?[t,Wt.contentAttributes.of({"aria-placeholder":o})]:t}const rr="-10000px";class pg{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=i(a,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(c=>c);if(n===this.input){for(let c of this.tooltipViews)c.update&&c.update(t);return!1}let a=[],l=e?[]:null;for(let c=0;ce[u]=c),e.length=l.length),this.input=n,this.tooltips=s,this.tooltipViews=a,!0}}function Hx(o){let t=o.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Ac=Ft.define({combine:o=>{var t,e,i;return{position:Bt.ios?"absolute":((t=o.find(n=>n.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=o.find(n=>n.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=o.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Hx}}}),_p=new WeakMap,fg=ti.fromClass(class{constructor(o){this.view=o,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=o.state.facet(Ac);this.position=t.position,this.parent=t.parent,this.classes=o.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new pg(o,fh,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),o.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let o of this.manager.tooltipViews)this.intersectionObserver.observe(o.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(o){o.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(o,this.above);t&&this.observeIntersection();let e=t||o.geometryChanged,i=o.state.facet(Ac);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(o,t){let e=o.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),o.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",e.dom.appendChild(n)}return e.dom.style.position=this.position,e.dom.style.top=rr,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var o,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(o=i.destroy)===null||o===void 0||o.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let o=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Bt.gecko)e=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==rr&&s.style.left=="0px"){let a=s.getBoundingClientRect();e=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}}if(e||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(o=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:o,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=dh(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let l=this.manager.tooltipViews[a];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Ac).tooltipSpace(this.view),scaleX:o,scaleY:t,makeAbsolute:e}}writeMeasure(o){var t;if(o.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:n,scaleY:s}=o,a=[];for(let l=0;l=Math.min(e.bottom,i.bottom)||v.rightMath.min(e.right,i.right)+.1)){p.style.top=rr;continue}let T=c.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,M=T?7:0,P=x.right-x.left,F=(t=_p.get(u))!==null&&t!==void 0?t:x.bottom-x.top,R=u.offset||Ux,q=this.view.textDirection==Fe.LTR,H=x.width>i.right-i.left?q?i.left:i.right-x.width:q?Math.max(i.left,Math.min(v.left-(T?14:0)+R.x,i.right-P)):Math.min(Math.max(i.left,v.left-P+(T?14:0)-R.x),i.right-P),Q=this.above[l];!c.strictSide&&(Q?v.top-F-M-R.yi.bottom)&&Q==i.bottom-v.bottom>v.top-i.top&&(Q=this.above[l]=!Q);let tt=(Q?v.top-i.top:i.bottom-v.bottom)-M;if(ttH&&vt.topit&&(it=Q?vt.top-F-2-M:vt.bottom+M+2);if(this.position=="absolute"?(p.style.top=(it-o.parent.top)/s+"px",xp(p,(H-o.parent.left)/n)):(p.style.top=it/s+"px",xp(p,H/n)),T){let vt=v.left+(q?R.x:-R.x)-(H+14-7);T.style.left=vt/n+"px"}u.overlap!==!0&&a.push({left:H,top:it,right:rt,bottom:it+F}),p.classList.toggle("cm-tooltip-above",Q),p.classList.toggle("cm-tooltip-below",!Q),u.positioned&&u.positioned(o.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let o of this.manager.tooltipViews)o.dom.style.top=rr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function xp(o,t){let e=parseInt(o.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(o.style.left=t+"px")}const Vx=Wt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Ux={x:0,y:0},fh=Ft.define({enables:[fg,Vx]}),yl=Ft.define({combine:o=>o.reduce((t,e)=>t.concat(e),[])});class Bl{static create(t){return new Bl(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new pg(t,yl,(e,i)=>this.createHostedView(e,i),e=>e.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(n!==void 0){if(e===void 0)e=n;else if(e!==n)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const jx=fh.compute([yl],o=>{let t=o.facet(yl);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var i;return(i=e.end)!==null&&i!==void 0?i:e.pos})),create:Bl.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class qx{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;tl.bottom||e.xl.right+t.defaultCharacterWidth)return;let c=t.bidiSpans(t.state.doc.lineAt(n)).find(p=>p.from<=n&&p.to>=n),u=c&&c.dir==Fe.RTL?-1:1;s=e.x{this.pending==l&&(this.pending=null,c&&!(Array.isArray(c)&&!c.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])}))},c=>Ji(t.state,c,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let t=this.view.plugin(fg),e=t?t.manager.tooltips.findIndex(i=>i.create==Bl.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!Kx(s.dom,t)||this.pending){let{pos:a}=n[0]||this.pending,l=(i=(e=n[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!Zx(this.view,a,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const La=4;function Kx(o,t){let{left:e,right:i,top:n,bottom:s}=o.getBoundingClientRect(),a;if(a=o.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();n=Math.min(l.top,n),s=Math.max(l.bottom,s)}return t.clientX>=e-La&&t.clientX<=i+La&&t.clientY>=n-La&&t.clientY<=s+La}function Zx(o,t,e,i,n,s){let a=o.scrollDOM.getBoundingClientRect(),l=o.documentTop+o.documentPadding.top+o.contentHeight;if(a.left>i||a.rightn||Math.min(a.bottom,l)=t&&c<=e}function Gx(o,t={}){let e=me.define(),i=$i.define({create(){return[]},update(n,s){if(n.length&&(t.hideOnChange&&(s.docChanged||s.selection)?n=[]:t.hideOn&&(n=n.filter(a=>!t.hideOn(s,a))),s.docChanged)){let a=[];for(let l of n){let c=s.changes.mapPos(l.pos,-1,mi.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),l);u.pos=c,u.end!=null&&(u.end=s.changes.mapPos(u.end)),a.push(u)}}n=a}for(let a of s.effects)a.is(e)&&(n=a.value),a.is(Yx)&&(n=[]);return n},provide:n=>yl.from(n)});return{active:i,extension:[i,ti.define(n=>new qx(n,o,i,e,t.hoverTime||300)),jx]}}const Yx=me.define(),kp=Ft.define({combine(o){let t,e;for(let i of o)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}}),Jx=ti.fromClass(class{constructor(o){this.input=o.state.facet(Nr),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(o));let t=o.state.facet(kp);this.top=new Na(o,!0,t.topContainer),this.bottom=new Na(o,!1,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(o){let t=o.state.facet(kp);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Na(o.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Na(o.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=o.state.facet(Nr);if(e!=this.input){let i=e.filter(c=>c),n=[],s=[],a=[],l=[];for(let c of i){let u=this.specs.indexOf(c),p;u<0?(p=c(o.view),l.push(p)):(p=this.panels[u],p.update&&p.update(o)),n.push(p),(p.top?s:a).push(p)}this.specs=i,this.panels=n,this.top.sync(s),this.bottom.sync(a);for(let c of l)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let i of this.panels)i.update&&i.update(o)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:o=>Wt.scrollMargins.of(t=>{let e=t.plugin(o);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Na{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=Cp(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Cp(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 Cp(o){let t=o.nextSibling;return o.remove(),t}const Nr=Ft.define({enables:Jx});class oo extends ws{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}oo.prototype.elementClass="";oo.prototype.toDOM=void 0;oo.prototype.mapMode=mi.TrackBefore;oo.prototype.startSide=oo.prototype.endSide=-1;oo.prototype.point=!0;const Lc=Ft.define(),Qx=Ft.define(),Xx={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ue.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Cr=Ft.define();function mg(o){return[gg(),Cr.of({...Xx,...o})]}const $p=Ft.define({combine:o=>o.some(t=>t)});function gg(o){return[t0]}const t0=ti.fromClass(class{constructor(o){this.view=o,this.prevViewport=o.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=o.state.facet(Cr).map(t=>new Tp(o,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!o.state.facet($p),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),o.scrollDOM.insertBefore(this.dom,o.contentDOM)}update(o){if(this.updateGutters(o)){let t=this.prevViewport,e=o.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}o.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet($p)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=o.view.viewport}syncGutters(o){let t=this.dom.nextSibling;o&&this.dom.remove();let e=ue.iter(this.view.state.facet(Lc),this.view.viewport.from),i=[],n=this.gutters.map(s=>new e0(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let a=!0;for(let l of s.type)if(l.type==nn.Text&&a){Ed(e,i,l.from);for(let c of n)c.line(this.view,l,i);a=!1}else if(l.widget)for(let c of n)c.widget(this.view,l)}else if(s.type==nn.Text){Ed(e,i,s.from);for(let a of n)a.line(this.view,s,i)}else if(s.widget)for(let a of n)a.widget(this.view,s);for(let s of n)s.finish();o&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(o){let t=o.startState.facet(Cr),e=o.state.facet(Cr),i=o.docChanged||o.heightChanged||o.viewportChanged||!ue.eq(o.startState.facet(Lc),o.state.facet(Lc),o.view.viewport.from,o.view.viewport.to);if(t==e)for(let n of this.gutters)n.update(o)&&(i=!0);else{i=!0;let n=[];for(let s of e){let a=t.indexOf(s);a<0?n.push(new Tp(this.view,s)):(this.gutters[a].update(o),n.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),n.indexOf(s)<0&&s.destroy();for(let s of n)this.dom.appendChild(s.dom);this.gutters=n}return i}destroy(){for(let o of this.gutters)o.destroy();this.dom.remove()}},{provide:o=>Wt.scrollMargins.of(t=>{let e=t.plugin(o);return!e||e.gutters.length==0||!e.fixed?null:t.textDirection==Fe.LTR?{left:e.dom.offsetWidth*t.scaleX}:{right:e.dom.offsetWidth*t.scaleX}})});function Sp(o){return Array.isArray(o)?o:[o]}function Ed(o,t,e){for(;o.value&&o.from<=e;)o.from==e&&t.push(o.value),o.next()}class e0{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=ue.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,a=e.height/t.scaleY;if(this.i==n.elements.length){let l=new vg(t,a,s,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(t,a,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Ed(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let a=this.gutter;n.length==0&&!a.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let s of t.state.facet(Qx)){let a=s(t,e.widget,e);a&&(n||(n=[])).push(a)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Tp{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,n=>{let s=n.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let c=s.getBoundingClientRect();a=(c.top+c.bottom)/2}else a=n.clientY;let l=t.lineBlockAtHeight(a-t.documentTop);e.domEventHandlers[i](t,l,n)&&n.preventDefault()});this.markers=Sp(e.markers(t)),e.initialSpacer&&(this.spacer=new vg(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=Sp(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!ue.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class vg{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),i0(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,a=0;;){let l=a,c=ss(l,c,u)||a(l,c,u):a}return i}})}});class Nc extends oo{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Mc(o,t){return o.state.facet(ps).formatNumber(t,o.state)}const s0=Cr.compute([ps],o=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(n0)},lineMarker(t,e,i){return i.some(n=>n.toDOM)?null:new Nc(Mc(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let n of t.state.facet(o0)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(ps)!=t.state.facet(ps),initialSpacer(t){return new Nc(Mc(t,Ep(t.state.doc.lines)))},updateSpacer(t,e){let i=Mc(e.view,Ep(e.view.state.doc.lines));return i==t.number?t:new Nc(i)},domEventHandlers:o.facet(ps).domEventHandlers}));function r0(o={}){return[ps.of(o),gg(),s0]}function Ep(o){let t=9;for(;t{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=Ci.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}de.closedBy=new de({deserialize:o=>o.split(" ")});de.openedBy=new de({deserialize:o=>o.split(" ")});de.group=new de({deserialize:o=>o.split(" ")});de.isolate=new de({deserialize:o=>{if(o&&o!="rtl"&&o!="ltr"&&o!="auto")throw new RangeError("Invalid value for isolate: "+o);return o||"auto"}});de.contextHash=new de({perNode:!0});de.lookAhead=new de({perNode:!0});de.mounted=new de({perNode:!0});class Mr{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[de.mounted.id]}}const c0=Object.create(null);class Ci{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):c0,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),n=new Ci(t.name||"",e,t.id,i);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}}return n}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(de.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return i=>{for(let n=i.prop(de.group),s=-1;s<(n?n.length:0);s++){let a=e[s<0?i.name:n[s]];if(a)return a}}}}Ci.none=new Ci("",Object.create(null),0,8);class mh{constructor(t){this.types=t;for(let e=0;e0;for(let c=this.cursor(a|ze.IncludeAnonymous);;){let u=!1;if(c.from<=s&&c.to>=n&&(!l&&c.type.isAnonymous||e(c)!==!1)){if(c.firstChild())continue;u=!0}for(;u&&i&&(l||!c.type.isAnonymous)&&i(c),!c.nextSibling();){if(!c.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:yh(Ci.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,n)=>new Le(this.type,e,i,n,this.propValues),t.makeTree||((e,i,n)=>new Le(Ci.none,e,i,n)))}static build(t){return p0(t)}}Le.empty=new Le(Ci.none,[],[],0);class gh{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new gh(this.buffer,this.index)}}class $o{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Ci.none}toString(){let t=[];for(let e=0;e0));c=a[c+3]);return l}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),a=0;for(let l=t,c=0;l=t&&et;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function Pr(o,t,e,i){for(var n;o.from==o.to||(e<1?o.from>=t:o.from>t)||(e>-1?o.to<=t:o.to0?l.length:-1;t!=u;t+=e){let p=l[t],v=c[t]+a.from;if(yg(n,i,v,v+p.length)){if(p instanceof $o){if(s&ze.ExcludeBuffers)continue;let x=p.findChild(0,p.buffer.length,e,i-v,n);if(x>-1)return new Ln(new d0(a,p,t,v),null,x)}else if(s&ze.IncludeAnonymous||!p.type.isAnonymous||vh(p)){let x;if(!(s&ze.IgnoreMounts)&&(x=Mr.get(p))&&!x.overlay)return new vi(x.tree,v,t,a);let T=new vi(p,v,t,a);return s&ze.IncludeAnonymous||!T.type.isAnonymous?T:T.nextChild(e<0?p.children.length-1:0,e,i,n)}}}if(s&ze.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+e:t=e<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&ze.IgnoreOverlays)&&(n=Mr.get(this._tree))&&n.overlay){let s=t-this.from;for(let{from:a,to:l}of n.overlay)if((e>0?a<=s:a=s:l>s))return new vi(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Ap(o,t,e,i){let n=o.cursor(),s=[];if(!n.firstChild())return s;if(e!=null){for(let a=!1;!a;)if(a=n.type.is(e),!n.nextSibling())return s}for(;;){if(i!=null&&n.type.is(i))return s;if(n.type.is(t)&&s.push(n.node),!n.nextSibling())return i==null?s:[]}}function Id(o,t,e=t.length-1){for(let i=o;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class d0{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Ln extends bg{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new Ln(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&ze.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Ln(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Ln(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Ln(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let a=i.buffer[this.index+1];t.push(i.slice(n,s,a)),e.push(0)}return new Le(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function wg(o){if(!o.length)return null;let t=0,e=o[0];for(let s=1;se.from||a.to=t){let l=new vi(a.tree,a.overlay[0].from+s.from,-1,s);(n||(n=[i])).push(Pr(l,t,e,!1))}}return n?wg(n):i}class bl{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof vi)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof vi?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&ze.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ze.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ze.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index-1)for(let s=e+t,a=t<0?-1:i._tree.children.length;s!=a;s+=t){let l=i._tree.children[s];if(this.mode&ze.IncludeAnonymous||l instanceof $o||!l.type.isAnonymous||vh(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let a=t;a;a=a._parent)if(a.index==n){if(n==this.index)return a;e=a,i=s+1;break t}n=this.stack[--s]}for(let n=i;n=0;s--){if(s<0)return Id(this._tree,t,n);let a=i[e.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[n]&&t[n]!=a.name)return!1;n--}}return!0}}function vh(o){return o.children.some(t=>t instanceof $o||!t.type.isAnonymous||vh(t))}function p0(o){var t;let{buffer:e,nodeSet:i,maxBufferLength:n=a0,reused:s=[],minRepeatType:a=i.types.length}=o,l=Array.isArray(e)?new gh(e,e.length):e,c=i.types,u=0,p=0;function v(tt,it,rt,vt,Dt,jt){let{id:gt,start:Ct,end:St,size:Nt}=l,Zt=p,re=u;for(;Nt<0;)if(l.next(),Nt==-1){let Tt=s[gt];rt.push(Tt),vt.push(Ct-tt);return}else if(Nt==-3){u=gt;return}else if(Nt==-4){p=gt;return}else throw new RangeError(`Unrecognized record size: ${Nt}`);let te=c[gt],ut,bt,ht=Ct-tt;if(St-Ct<=n&&(bt=F(l.pos-it,Dt))){let Tt=new Uint16Array(bt.size-bt.skip),mt=l.pos-bt.size,At=Tt.length;for(;l.pos>mt;)At=R(bt.start,Tt,At);ut=new $o(Tt,St-bt.start,i),ht=bt.start-tt}else{let Tt=l.pos-Nt;l.next();let mt=[],At=[],Et=gt>=a?gt:-1,dt=0,b=St;for(;l.pos>Tt;)Et>=0&&l.id==Et&&l.size>=0?(l.end<=b-n&&(M(mt,At,Ct,dt,l.end,b,Et,Zt,re),dt=mt.length,b=l.end),l.next()):jt>2500?x(Ct,Tt,mt,At):v(Ct,Tt,mt,At,Et,jt+1);if(Et>=0&&dt>0&&dt-1&&dt>0){let k=T(te,re);ut=yh(te,mt,At,0,mt.length,0,St-Ct,k,k)}else ut=P(te,mt,At,St-Ct,Zt-St,re)}rt.push(ut),vt.push(ht)}function x(tt,it,rt,vt){let Dt=[],jt=0,gt=-1;for(;l.pos>it;){let{id:Ct,start:St,end:Nt,size:Zt}=l;if(Zt>4)l.next();else{if(gt>-1&&St=0;Nt-=3)Ct[Zt++]=Dt[Nt],Ct[Zt++]=Dt[Nt+1]-St,Ct[Zt++]=Dt[Nt+2]-St,Ct[Zt++]=Zt;rt.push(new $o(Ct,Dt[2]-St,i)),vt.push(St-tt)}}function T(tt,it){return(rt,vt,Dt)=>{let jt=0,gt=rt.length-1,Ct,St;if(gt>=0&&(Ct=rt[gt])instanceof Le){if(!gt&&Ct.type==tt&&Ct.length==Dt)return Ct;(St=Ct.prop(de.lookAhead))&&(jt=vt[gt]+Ct.length+St)}return P(tt,rt,vt,Dt,jt,it)}}function M(tt,it,rt,vt,Dt,jt,gt,Ct,St){let Nt=[],Zt=[];for(;tt.length>vt;)Nt.push(tt.pop()),Zt.push(it.pop()+rt-Dt);tt.push(P(i.types[gt],Nt,Zt,jt-Dt,Ct-jt,St)),it.push(Dt-rt)}function P(tt,it,rt,vt,Dt,jt,gt){if(jt){let Ct=[de.contextHash,jt];gt=gt?[Ct].concat(gt):[Ct]}if(Dt>25){let Ct=[de.lookAhead,Dt];gt=gt?[Ct].concat(gt):[Ct]}return new Le(tt,it,rt,vt,gt)}function F(tt,it){let rt=l.fork(),vt=0,Dt=0,jt=0,gt=rt.end-n,Ct={size:0,start:0,skip:0};t:for(let St=rt.pos-tt;rt.pos>St;){let Nt=rt.size;if(rt.id==it&&Nt>=0){Ct.size=vt,Ct.start=Dt,Ct.skip=jt,jt+=4,vt+=4,rt.next();continue}let Zt=rt.pos-Nt;if(Nt<0||Zt=a?4:0,te=rt.start;for(rt.next();rt.pos>Zt;){if(rt.size<0)if(rt.size==-3)re+=4;else break t;else rt.id>=a&&(re+=4);rt.next()}Dt=te,vt+=Nt,jt+=re}return(it<0||vt==tt)&&(Ct.size=vt,Ct.start=Dt,Ct.skip=jt),Ct.size>4?Ct:void 0}function R(tt,it,rt){let{id:vt,start:Dt,end:jt,size:gt}=l;if(l.next(),gt>=0&&vt4){let St=l.pos-(gt-4);for(;l.pos>St;)rt=R(tt,it,rt)}it[--rt]=Ct,it[--rt]=jt-tt,it[--rt]=Dt-tt,it[--rt]=vt}else gt==-3?u=vt:gt==-4&&(p=vt);return rt}let q=[],H=[];for(;l.pos>0;)v(o.start||0,o.bufferStart||0,q,H,-1,0);let Q=(t=o.length)!==null&&t!==void 0?t:q.length?H[0]+q[0].length:0;return new Le(c[o.topID],q.reverse(),H.reverse(),Q)}const Lp=new WeakMap;function nl(o,t){if(!o.isAnonymous||t instanceof $o||t.type!=o)return 1;let e=Lp.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=o||!(i instanceof Le)){e=1;break}e+=nl(o,i)}Lp.set(t,e)}return e}function yh(o,t,e,i,n,s,a,l,c){let u=0;for(let M=i;M=p)break;it+=rt}if(H==Q+1){if(it>p){let rt=M[Q];T(rt.children,rt.positions,0,rt.children.length,P[Q]+q);continue}v.push(M[Q])}else{let rt=P[H-1]+M[H-1].length-tt;v.push(yh(o,M,P,Q,H,tt,rt,null,c))}x.push(tt+q-s)}}return T(t,e,i,n,0),(l||c)(v,x,a)}class LA{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Ln?this.setBuffer(t.context.buffer,t.index,e):t instanceof vi&&this.map.set(t.tree,e)}get(t){return t instanceof Ln?this.getBuffer(t.context.buffer,t.index):t instanceof vi?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class io{constructor(t,e,i,n,s=!1,a=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let n=[new io(0,t.length,t,0,!1,i)];for(let s of e)s.to>t.length&&n.push(s);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,a=t.length?t[0]:null;for(let l=0,c=0,u=0;;l++){let p=l=i)for(;a&&a.from=x.from||v<=x.to||u){let T=Math.max(x.from,c)-u,M=Math.min(x.to,v)-u;x=T>=M?null:new io(T,M,x.tree,x.offset+u,l>0,!!p)}if(x&&n.push(x),a.to>v)break;a=snew Qi(n.from,n.to)):[new Qi(0,0)]:[new Qi(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let s=n.advance();if(s)return s}}}class f0{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function NA(o){return(t,e,i,n)=>new g0(t,o,e,i,n)}class Np{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.from=s}}function Mp(o){if(!o.length||o.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(o))}class m0{constructor(t,e,i,n,s,a,l){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=a,this.prev=l,this.depth=0,this.ranges=[]}}const Ad=new de({perNode:!0});class g0{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Le(i.type,i.children,i.positions,i.length,i.propValues.concat([[Ad,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[de.mounted.id]=new Mr(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e=this.stoppedAt)l=!1;else if(t.hasNode(n)){if(e){let u=e.mounts.find(p=>p.frag.from<=n.from&&p.frag.to>=n.to&&p.mount.overlay);if(u)for(let p of u.mount.overlay){let v=p.from+u.pos,x=p.to+u.pos;v>=n.from&&x<=n.to&&!e.ranges.some(T=>T.fromv)&&e.ranges.push({from:v,to:x})}}l=!1}else if(i&&(a=v0(i.ranges,n.from,n.to)))l=a!=2;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.fromnew Qi(v.from-n.from,v.to-n.from)):null,n.tree,p.length?p[0].from:n.from)),s.overlay?p.length&&(i={ranges:p,depth:0,prev:i}):l=!1}}else if(e&&(c=e.predicate(n))&&(c===!0&&(c=new Qi(n.from,n.to)),c.from=0&&e.ranges[u].to==c.from?e.ranges[u]={from:e.ranges[u].from,to:c.to}:e.ranges.push(c)}if(l&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break t;if(e&&!--e.depth){let u=Dp(this.ranges,e.ranges);u.length&&(Mp(u),this.inner.splice(e.index,0,new Np(e.parser,e.parser.startParse(this.input,Rp(e.mounts,u),u),e.ranges.map(p=>new Qi(p.from-e.start,p.to-e.start)),e.target,u[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function v0(o,t,e){for(let i of o){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function Pp(o,t,e,i,n,s){if(t=t&&e.enter(i,1,ze.IgnoreOverlays|ze.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Le)e=e.children[0];else break}return!1}}class b0{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Ad))!==null&&e!==void 0?e:i.to,this.inner=new Op(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Ad))!==null&&t!==void 0?t:e.to,this.inner=new Op(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(i=s.tree)===null||i===void 0?void 0:i.prop(de.mounted);if(a&&a.parser==e)for(let l=this.fragI;l=s.to)break;c.tree==this.curFrag.tree&&n.push({frag:c,pos:s.from-c.offset,mount:a})}}}return n}}function Dp(o,t){let e=null,i=t;for(let n=1,s=0;n=l)break;c.to<=a||(e||(i=e=t.slice()),c.froml&&e.splice(s+1,0,new Qi(l,c.to))):c.to>l?e[s--]=new Qi(l,c.to):e.splice(s--,1))}}return i}function w0(o,t,e,i){let n=0,s=0,a=!1,l=!1,c=-1e9,u=[];for(;;){let p=n==o.length?1e9:a?o[n].to:o[n].from,v=s==t.length?1e9:l?t[s].to:t[s].from;if(a!=l){let x=Math.max(c,e),T=Math.min(p,v,i);xnew Qi(x.from+i,x.to+i)),v=w0(t,p,c,u);for(let x=0,T=c;;x++){let M=x==v.length,P=M?u:v[x].from;if(P>T&&e.push(new io(T,P,n.tree,-a,s.from>=T||s.openStart,s.to<=P||s.openEnd)),M)break;T=v[x].to}}else e.push(new io(c,u,n.tree,-a,s.from>=a||s.openStart,s.to<=l||s.openEnd))}return e}let _0=0;class Yi{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=_0++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof Yi&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let n=new Yi(i,[],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(t){let e=new wl(t);return i=>i.modified.indexOf(e)>-1?i:wl.get(i.base||i,i.modified.concat(e).sort((n,s)=>n.id-s.id))}}let x0=0;class wl{constructor(t){this.name=t,this.instances=[],this.id=x0++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&k0(e,l.modified));if(i)return i;let n=[],s=new Yi(t.name,n,t,e);for(let l of e)l.instances.push(s);let a=C0(e);for(let l of t.set)if(!l.modified.length)for(let c of a)n.push(wl.get(l,c));return s}}function k0(o,t){return o.length==t.length&&o.every((e,i)=>e==t[i])}function C0(o){let t=[[]];for(let e=0;ei.length-e.length)}function $0(o){let t=Object.create(null);for(let e in o){let i=o[e];Array.isArray(i)||(i=[i]);for(let n of e.split(" "))if(n){let s=[],a=2,l=n;for(let v=0;;){if(l=="..."&&v>0&&v+3==n.length){a=1;break}let x=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!x)throw new RangeError("Invalid path: "+n);if(s.push(x[0]=="*"?"":x[0][0]=='"'?JSON.parse(x[0]):x[0]),v+=x[0].length,v==n.length)break;let T=n[v++];if(v==n.length&&T=="!"){a=0;break}if(T!="/")throw new RangeError("Invalid path: "+n);l=n.slice(v)}let c=s.length-1,u=s[c];if(!u)throw new RangeError("Invalid path: "+n);let p=new _l(i,a,c>0?s.slice(0,c):null);t[u]=p.sort(t[u])}}return xg.add(t)}const xg=new de;class _l{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth{let a=n;for(let l of s)for(let c of l.set){let u=e[c.id];if(u){a=a?a+" "+u:u;break}}return a},scope:i}}function S0(o,t){let e=null;for(let i of o){let n=i.style(t);n&&(e=e?e+" "+n:n)}return e}function T0(o,t,e,i=0,n=o.length){let s=new E0(i,Array.isArray(t)?t:[t],e);s.highlightRange(o.cursor(),i,n,"",s.highlighters),s.flush(n)}class E0{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:a,from:l,to:c}=t;if(l>=i||c<=e)return;a.isTop&&(s=this.highlighters.filter(T=>!T.scope||T.scope(a)));let u=n,p=I0(t)||_l.empty,v=S0(s,p.tags);if(v&&(u&&(u+=" "),u+=v,p.mode==1&&(n+=(n?" ":"")+v)),this.startSpan(Math.max(e,l),u),p.opaque)return;let x=t.tree&&t.tree.prop(de.mounted);if(x&&x.overlay){let T=t.node.enter(x.overlay[0].from+l,1),M=this.highlighters.filter(F=>!F.scope||F.scope(x.tree.type)),P=t.firstChild();for(let F=0,R=l;;F++){let q=F=H||!t.nextSibling())););if(!q||H>i)break;R=q.to+l,R>e&&(this.highlightRange(T.cursor(),Math.max(e,q.from+l),Math.min(i,R),"",M),this.startSpan(Math.min(i,R),u))}P&&t.parent()}else if(t.firstChild()){x&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),u)}while(t.nextSibling());t.parent()}}}function I0(o){let t=o.type.prop(xg);for(;t&&t.context&&!o.matchContext(t.context);)t=t.next;return t||null}const It=Yi.define,Pa=It(),go=It(),Bp=It(go),zp=It(go),vo=It(),Oa=It(vo),Pc=It(vo),$n=It(),Oo=It($n),kn=It(),Cn=It(),Ld=It(),ar=It(Ld),Da=It(),Ot={comment:Pa,lineComment:It(Pa),blockComment:It(Pa),docComment:It(Pa),name:go,variableName:It(go),typeName:Bp,tagName:It(Bp),propertyName:zp,attributeName:It(zp),className:It(go),labelName:It(go),namespace:It(go),macroName:It(go),literal:vo,string:Oa,docString:It(Oa),character:It(Oa),attributeValue:It(Oa),number:Pc,integer:It(Pc),float:It(Pc),bool:It(vo),regexp:It(vo),escape:It(vo),color:It(vo),url:It(vo),keyword:kn,self:It(kn),null:It(kn),atom:It(kn),unit:It(kn),modifier:It(kn),operatorKeyword:It(kn),controlKeyword:It(kn),definitionKeyword:It(kn),moduleKeyword:It(kn),operator:Cn,derefOperator:It(Cn),arithmeticOperator:It(Cn),logicOperator:It(Cn),bitwiseOperator:It(Cn),compareOperator:It(Cn),updateOperator:It(Cn),definitionOperator:It(Cn),typeOperator:It(Cn),controlOperator:It(Cn),punctuation:Ld,separator:It(Ld),bracket:ar,angleBracket:It(ar),squareBracket:It(ar),paren:It(ar),brace:It(ar),content:$n,heading:Oo,heading1:It(Oo),heading2:It(Oo),heading3:It(Oo),heading4:It(Oo),heading5:It(Oo),heading6:It(Oo),contentSeparator:It($n),list:It($n),quote:It($n),emphasis:It($n),strong:It($n),link:It($n),monospace:It($n),strikethrough:It($n),inserted:It(),deleted:It(),changed:It(),invalid:It(),meta:Da,documentMeta:It(Da),annotation:It(Da),processingInstruction:It(Da),definition:Yi.defineModifier("definition"),constant:Yi.defineModifier("constant"),function:Yi.defineModifier("function"),standard:Yi.defineModifier("standard"),local:Yi.defineModifier("local"),special:Yi.defineModifier("special")};for(let o in Ot){let t=Ot[o];t instanceof Yi&&(t.name=o)}kg([{tag:Ot.link,class:"tok-link"},{tag:Ot.heading,class:"tok-heading"},{tag:Ot.emphasis,class:"tok-emphasis"},{tag:Ot.strong,class:"tok-strong"},{tag:Ot.keyword,class:"tok-keyword"},{tag:Ot.atom,class:"tok-atom"},{tag:Ot.bool,class:"tok-bool"},{tag:Ot.url,class:"tok-url"},{tag:Ot.labelName,class:"tok-labelName"},{tag:Ot.inserted,class:"tok-inserted"},{tag:Ot.deleted,class:"tok-deleted"},{tag:Ot.literal,class:"tok-literal"},{tag:Ot.string,class:"tok-string"},{tag:Ot.number,class:"tok-number"},{tag:[Ot.regexp,Ot.escape,Ot.special(Ot.string)],class:"tok-string2"},{tag:Ot.variableName,class:"tok-variableName"},{tag:Ot.local(Ot.variableName),class:"tok-variableName tok-local"},{tag:Ot.definition(Ot.variableName),class:"tok-variableName tok-definition"},{tag:Ot.special(Ot.variableName),class:"tok-variableName2"},{tag:Ot.definition(Ot.propertyName),class:"tok-propertyName tok-definition"},{tag:Ot.typeName,class:"tok-typeName"},{tag:Ot.namespace,class:"tok-namespace"},{tag:Ot.className,class:"tok-className"},{tag:Ot.macroName,class:"tok-macroName"},{tag:Ot.propertyName,class:"tok-propertyName"},{tag:Ot.operator,class:"tok-operator"},{tag:Ot.comment,class:"tok-comment"},{tag:Ot.meta,class:"tok-meta"},{tag:Ot.invalid,class:"tok-invalid"},{tag:Ot.punctuation,class:"tok-punctuation"}]);var Oc;const Fo=new de;function Cg(o){return Ft.define({combine:o?t=>t.concat(o):void 0})}const A0=new de;class zi{constructor(t,e,i=[],n=""){this.data=t,this.name=n,ve.prototype.hasOwnProperty("tree")||Object.defineProperty(ve.prototype,"tree",{get(){return Wi(this)}}),this.parser=e,this.extension=[So.of(this),ve.languageData.of((s,a,l)=>{let c=Fp(s,a,l),u=c.type.prop(Fo);if(!u)return[];let p=s.facet(u),v=c.type.prop(A0);if(v){let x=c.resolve(a-c.from,l);for(let T of v)if(T.test(x,s)){let M=s.facet(T.facet);return T.type=="replace"?M:M.concat(p)}}return p})].concat(i)}isActiveAt(t,e,i=-1){return Fp(t,e,i).type.prop(Fo)==this.data}findRegions(t){let e=t.facet(So);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(s,a)=>{if(s.prop(Fo)==this.data){i.push({from:a,to:a+s.length});return}let l=s.prop(de.mounted);if(l){if(l.tree.prop(Fo)==this.data){if(l.overlay)for(let c of l.overlay)i.push({from:c.from+a,to:c.to+a});else i.push({from:a,to:a+s.length});return}else if(l.overlay){let c=i.length;if(n(l.tree,l.overlay[0].from+a),i.length>c)return}}for(let c=0;ci.isTop?e:void 0)]}),t.name)}configure(t,e){return new Nd(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Wi(o){let t=o.field(zi.state,!1);return t?t.tree:Le.empty}function $g(o,t,e=50){var i;let n=(i=o.field(zi.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:t});let a=n.isDone(t)||n.work(e,t)?n.tree:null;return n.updateViewport(s),a}class L0{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let lr=null;class $s{constructor(t,e,i=[],n,s,a,l,c){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=a,this.skipped=l,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new $s(t,e,[],Le.empty,0,i,[],null)}startParse(){return this.parser.startParse(new L0(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=Le.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let n=Date.now()+t;t=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(io.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=lr;lr=this;try{return t()}finally{lr=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Wp(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:a,skipped:l}=this;if(this.takeTree(),!t.empty){let c=[];if(t.iterChangedRanges((u,p,v,x)=>c.push({fromA:u,toA:p,fromB:v,toB:x})),i=io.applyChanges(i,c),n=Le.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let p=t.mapPos(u.from,1),v=t.mapPos(u.to,-1);pt.from&&(this.fragments=Wp(this.fragments,n,s),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends _g{createParse(e,i,n){let s=n[0].from,a=n[n.length-1].to;return{parsedPos:s,advance(){let l=lr;if(l){for(let c of n)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=a,new Le(Ci.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return lr}}function Wp(o,t,e){return io.applyChanges(o,[{fromA:t,toA:e,fromB:t,toB:e}])}class Ss{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Ss(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=$s.create(t.facet(So).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Ss(i)}}zi.state=$i.define({create:Ss.init,update(o,t){for(let e of t.effects)if(e.is(zi.setState))return e.value;return t.startState.facet(So)!=t.state.facet(So)?Ss.init(t.state):o.apply(t)}});let Sg=o=>{let t=setTimeout(()=>o(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Sg=o=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(o,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Dc=typeof navigator<"u"&&!((Oc=navigator.scheduling)===null||Oc===void 0)&&Oc.isInputPending?()=>navigator.scheduling.isInputPending():null,N0=ti.fromClass(class{constructor(o){this.view=o,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(o){let t=this.view.state.field(zi.state).context;(t.updateViewport(o.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(o.docChanged||o.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:o}=this.view,t=o.field(zi.state);(t.tree!=t.context.tree||!t.context.isDone(o.doc.length))&&(this.working=Sg(this.work))}work(o){this.working=null;let t=Date.now();if(this.chunkEnd