x&&_.topP&&(P=v?_.top-g-2-m:_.bottom+m+2);if(this.position=="absolute"?(h.style.top=(P-i.parent.top)/s+"px",h.style.left=(x-i.parent.left)/n+"px"):(h.style.top=P/s+"px",h.style.left=x/n+"px"),d){let _=u.left+(y?O.x:-O.x)-(x+14-7);d.style.left=_/n+"px"}c.overlap!==!0&&o.push({left:x,top:P,right:C,bottom:P+g}),h.classList.toggle("cm-tooltip-above",v),h.classList.toggle("cm-tooltip-below",!v),c.positioned&&c.positioned(i.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 i of this.manager.tooltipViews)i.dom.style.top=en}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Uw=R.baseTheme({".cm-tooltip":{zIndex:100,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"}}}),Fw={x:0,y:0},Sn=A.define({enables:[Nc,Uw]}),go=A.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])}),Oo=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new mo(e,go,(t,r)=>this.createHostedView(t,r),t=>t.dom.remove())}createHostedView(e,t){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let r of this.manager.tooltipViews){let n=r[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},Hw=Sn.compute([go],i=>{let e=i.facet(go);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var r;return(r=t.end)!==null&&r!==void 0?r:t.pos})),create:Oo.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Mc=class{constructor(e,t,r,n,s){this.view=e,this.source=t,this.field=r,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.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 e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(n)).find(h=>h.from<=n&&h.to>=n),c=l&&l.dir==G.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>xe(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Nc),t=e?e.manager.tooltips.findIndex(r=>r.create==Oo.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!Gw(s.dom,e)||this.pending){let{pos:o}=n[0]||this.pending,a=(r=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!Yw(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=r=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Zs=4;function Gw(i,e){let t=i.getBoundingClientRect();return e.clientX>=t.left-Zs&&e.clientX<=t.right+Zs&&e.clientY>=t.top-Zs&&e.clientY<=t.bottom+Zs}function Yw(i,e,t,r,n,s){let o=i.scrollDOM.getBoundingClientRect(),a=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>r||o.rightn||Math.min(o.bottom,a)=e&&l<=t}function sm(i,e={}){let t=D.define(),r=re.define({create(){return[]},update(n,s){if(n.length&&(e.hideOnChange&&(s.docChanged||s.selection)?n=[]:e.hideOn&&(n=n.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of n){let l=s.changes.mapPos(a.pos,-1,ye.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}n=o}for(let o of s.effects)o.is(t)&&(n=o.value),o.is(Zw)&&(n=[]);return n},provide:n=>go.from(n)});return[r,se.define(n=>new Mc(n,i,r,t,e.hoverTime||300)),Hw]}function jc(i,e){let t=i.plugin(Nc);if(!t)return null;let r=t.manager.tooltips.indexOf(e);return r<0?null:t.manager.tooltipViews[r]}var Zw=D.define();var zd=A.define({combine(i){let e,t;for(let r of i)e=e||r.topContainer,t=t||r.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Mi(i,e){let t=i.plugin(om),r=t?t.specs.indexOf(e):-1;return r>-1?t.panels[r]:null}var om=se.fromClass(class{constructor(i){this.input=i.state.facet(Qi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(zd);this.top=new cr(i,!0,e.topContainer),this.bottom=new cr(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(zd);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new cr(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new cr(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Qi);if(t!=this.input){let r=t.filter(l=>l),n=[],s=[],o=[],a=[];for(let l of r){let c=this.specs.indexOf(l),h;c<0?(h=l(i.view),a.push(h)):(h=this.panels[c],h.update&&h.update(i)),n.push(h),(h.top?s:o).push(h)}this.specs=r,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>R.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),cr=class{constructor(e,t,r){this.view=e,this.top=t,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,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 t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Ud(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ud(e)}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 e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function Ud(i){let e=i.nextSibling;return i.remove(),e}var Qi=A.define({enables:om}),He=class extends ft{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};He.prototype.elementClass="";He.prototype.toDOM=void 0;He.prototype.mapMode=ye.TrackBefore;He.prototype.startSide=He.prototype.endSide=-1;He.prototype.point=!0;var ro=A.define(),Jw={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>z.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},fn=A.define();function Ic(i){return[am(),fn.of(Object.assign(Object.assign({},Jw),i))]}var _c=A.define({combine:i=>i.some(e=>e)});function am(i){let e=[Kw];return i&&i.fixed===!1&&e.push(_c.of(!0)),e}var Kw=se.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.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=i.state.facet(fn).map(e=>new yo(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(_c),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,r=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(r<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(_c)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=z.iter(this.view.state.facet(ro),this.view.viewport.from),r=[],n=this.gutters.map(s=>new Lc(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Le.Text&&o){Dc(t,r,a.from);for(let l of n)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of n)l.widget(this.view,a)}else if(s.type==Le.Text){Dc(t,r,s.from);for(let o of n)o.line(this.view,s,r)}else if(s.widget)for(let o of n)o.widget(this.view,s);for(let s of n)s.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(fn),t=i.state.facet(fn),r=i.docChanged||i.heightChanged||i.viewportChanged||!z.eq(i.startState.facet(ro),i.state.facet(ro),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(i)&&(r=!0);else{r=!0;let n=[];for(let s of t){let o=e.indexOf(s);o<0?n.push(new yo(this.view,s)):(this.gutters[o].update(i),n.push(this.gutters[o]))}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 r}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>R.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==G.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Fd(i){return Array.isArray(i)?i:[i]}function Dc(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var Lc=class{constructor(e,t,r){this.gutter=e,this.height=r,this.i=0,this.cursor=z.iter(e.markers,t.from)}addElement(e,t,r){let{gutter:n}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let a=new bo(e,o,s,r);n.elements.push(a),n.dom.appendChild(a.dom)}else n.elements[this.i].update(e,o,s,r);this.height=t.bottom,this.i++}line(e,t,r){let n=[];Dc(this.cursor,n,t.from),r.length&&(n=n.concat(r));let s=this.gutter.config.lineMarker(e,t,n);s&&n.unshift(s);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let r=this.gutter.config.widgetMarker(e,t.widget,t);r&&this.addElement(e,t,[r])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},yo=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in t.domEventHandlers)this.dom.addEventListener(r,n=>{let s=n.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=n.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[r](e,a,n)&&n.preventDefault()});this.markers=Fd(t.markers(e)),t.initialSpacer&&(this.spacer=new bo(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Fd(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let r=e.view.viewport;return!z.eq(this.markers,t,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},bo=class{constructor(e,t,r,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,r,n)}update(e,t,r,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),ev(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let r="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=ss(a,l,c)||o(a,l,c):o}return r}})}}),dn=class extends He{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Ul(i,e){return i.state.facet(hr).formatNumber(e,i.state)}var iv=fn.compute([hr],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(tv)},lineMarker(e,t,r){return r.some(n=>n.toDOM)?null:new dn(Ul(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(hr)!=e.state.facet(hr),initialSpacer(e){return new dn(Ul(e,Hd(e.state.doc.lines)))},updateSpacer(e,t){let r=Ul(t.view,Hd(t.view.state.doc.lines));return r==e.number?e:new dn(r)},domEventHandlers:i.facet(hr).domEventHandlers}));function lm(i={}){return[hr.of(i),am(),iv]}function Hd(i){let e=9;for(;e{let e=[],t=-1;for(let r of i.selection.ranges){let n=i.doc.lineAt(r.head).from;n>t&&(t=n,e.push(rv.range(n)))}return z.of(e)});function cm(){return nv}var sv=0,kn=class{constructor(e,t){this.from=e,this.to=t}},L=class{constructor(e={}){this.id=sv++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ee.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}};L.closedBy=new L({deserialize:i=>i.split(" ")});L.openedBy=new L({deserialize:i=>i.split(" ")});L.group=new L({deserialize:i=>i.split(" ")});L.isolate=new L({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});L.contextHash=new L({perNode:!0});L.lookAhead=new L({perNode:!0});L.mounted=new L({perNode:!0});var fr=class{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}static get(e){return e&&e.props&&e.props[L.mounted.id]}},ov=Object.create(null),Ee=class i{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):ov,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new i(e.name||"",t,e.id,r);if(e.props){for(let s of e.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");t[s[0].id]=s[1]}}return n}prop(e){return this.props[e.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(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(L.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return r=>{for(let n=r.prop(L.group),s=-1;s<(n?n.length:0);s++){let o=t[s<0?r.name:n[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Tn=class i{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|ae.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=n&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Yc(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,n)=>new i(this.type,t,r,n,this.propValues),e.makeTree||((t,r,n)=>new i(Ee.none,t,r,n)))}static build(e){return lv(e)}};ce.empty=new ce(Ee.none,[],[],0);var Wc=class i{constructor(e,t){this.buffer=e,this.index=t}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 i(this.buffer,this.index)}},ni=class i{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return Ee.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,r){let n=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function Pn(i,e,t,r){for(var n;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=c;e+=t){let h=a[e],u=l[e]+o.from;if(dm(n,r,u,u+h.length)){if(h instanceof ni){if(s&ae.ExcludeBuffers)continue;let f=h.findChild(0,h.buffer.length,t,r-u,n);if(f>-1)return new _i(new Uc(o,h,e,u),null,f)}else if(s&ae.IncludeAnonymous||!h.type.isAnonymous||Gc(h)){let f;if(!(s&ae.IgnoreMounts)&&(f=fr.get(h))&&!f.overlay)return new i(f.tree,u,e,o);let d=new i(h,u,e,o);return s&ae.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?h.children.length-1:0,t,r,n)}}}if(s&ae.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))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(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&ae.IgnoreOverlays)&&(n=fr.get(this._tree))&&n.overlay){let s=e-this.from;for(let{from:o,to:a}of n.overlay)if((t>0?o<=s:o=s:a>s))return new i(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}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 um(i,e,t,r){let n=i.cursor(),s=[];if(!n.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return s}for(;;){if(r!=null&&n.type.is(r))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return r==null?s:[]}}function zc(i,e,t=e.length-1){for(let r=i.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}var Uc=class{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}},_i=class i extends So{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(e,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return s<0?null:new i(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&ae.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,s=r.buffer[this.index+3];if(s>n){let o=r.buffer[this.index+1];e.push(r.slice(n,s,o)),t.push(0)}return new ce(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function pm(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let a=new ot(o.tree,o.overlay[0].from+s.from,-1,s);(n||(n=[r])).push(Pn(a,e,t,!1))}}return n?pm(n):r}var Cn=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ot)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return e?e instanceof ot?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);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(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?r&ae.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ae.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ae.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let n=r<0?0:this.stack[r]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(n)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&ae.IncludeAnonymous||a instanceof ni||!a.type.isAnonymous||Gc(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,r=s+1;break e}n=this.stack[--s]}for(let n=r;n=0;s--){if(s<0)return zc(this.node,e,n);let o=r[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}};function Gc(i){return i.children.some(e=>e instanceof ni||!e.type.isAnonymous||Gc(e))}function lv(i){var e;let{buffer:t,nodeSet:r,maxBufferLength:n=1024,reused:s=[],minRepeatType:o=r.types.length}=i,a=Array.isArray(t)?new Wc(t,t.length):t,l=r.types,c=0,h=0;function u(w,P,C,_,$,q){let{id:N,start:B,end:Y,size:I}=a,ne=h;for(;I<0;)if(a.next(),I==-1){let ge=s[N];C.push(ge),_.push(B-w);return}else if(I==-3){c=N;return}else if(I==-4){h=N;return}else throw new RangeError(`Unrecognized record size: ${I}`);let qe=l[N],Ve,We,Ke=B-w;if(Y-B<=n&&(We=g(a.pos-P,$))){let ge=new Uint16Array(We.size-We.skip),et=a.pos-We.size,yt=ge.length;for(;a.pos>et;)yt=O(We.start,ge,yt);Ve=new ni(ge,Y-We.start,r),Ke=We.start-w}else{let ge=a.pos-I;a.next();let et=[],yt=[],gi=N>=o?N:-1,zi=0,is=Y;for(;a.pos>ge;)gi>=0&&a.id==gi&&a.size>=0?(a.end<=is-n&&(m(et,yt,B,zi,a.end,is,gi,ne),zi=et.length,is=a.end),a.next()):q>2500?f(B,ge,et,yt):u(B,ge,et,yt,gi,q+1);if(gi>=0&&zi>0&&zi-1&&zi>0){let Qu=d(qe);Ve=Yc(qe,et,yt,0,et.length,0,Y-B,Qu,Qu)}else Ve=p(qe,et,yt,Y-B,ne-Y)}C.push(Ve),_.push(Ke)}function f(w,P,C,_){let $=[],q=0,N=-1;for(;a.pos>P;){let{id:B,start:Y,end:I,size:ne}=a;if(ne>4)a.next();else{if(N>-1&&Y=0;I-=3)B[ne++]=$[I],B[ne++]=$[I+1]-Y,B[ne++]=$[I+2]-Y,B[ne++]=ne;C.push(new ni(B,$[2]-Y,r)),_.push(Y-w)}}function d(w){return(P,C,_)=>{let $=0,q=P.length-1,N,B;if(q>=0&&(N=P[q])instanceof ce){if(!q&&N.type==w&&N.length==_)return N;(B=N.prop(L.lookAhead))&&($=C[q]+N.length+B)}return p(w,P,C,_,$)}}function m(w,P,C,_,$,q,N,B){let Y=[],I=[];for(;w.length>_;)Y.push(w.pop()),I.push(P.pop()+C-$);w.push(p(r.types[N],Y,I,q-$,B-q)),P.push($-C)}function p(w,P,C,_,$=0,q){if(c){let N=[L.contextHash,c];q=q?[N].concat(q):[N]}if($>25){let N=[L.lookAhead,$];q=q?[N].concat(q):[N]}return new ce(w,P,C,_,q)}function g(w,P){let C=a.fork(),_=0,$=0,q=0,N=C.end-n,B={size:0,start:0,skip:0};e:for(let Y=C.pos-w;C.pos>Y;){let I=C.size;if(C.id==P&&I>=0){B.size=_,B.start=$,B.skip=q,q+=4,_+=4,C.next();continue}let ne=C.pos-I;if(I<0||ne=o?4:0,Ve=C.start;for(C.next();C.pos>ne;){if(C.size<0)if(C.size==-3)qe+=4;else break e;else C.id>=o&&(qe+=4);C.next()}$=Ve,_+=I,q+=qe}return(P<0||_==w)&&(B.size=_,B.start=$,B.skip=q),B.size>4?B:void 0}function O(w,P,C){let{id:_,start:$,end:q,size:N}=a;if(a.next(),N>=0&&_4){let Y=a.pos-(N-4);for(;a.pos>Y;)C=O(w,P,C)}P[--C]=B,P[--C]=q-w,P[--C]=$-w,P[--C]=_}else N==-3?c=_:N==-4&&(h=_);return C}let y=[],x=[];for(;a.pos>0;)u(i.start||0,i.bufferStart||0,y,x,-1,0);let v=(e=i.length)!==null&&e!==void 0?e:y.length?x[0]+y[0].length:0;return new ce(l[i.topID],y.reverse(),x.reverse(),v)}var fm=new WeakMap;function xo(i,e){if(!i.isAnonymous||e instanceof ni||e.type!=i)return 1;let t=fm.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=i||!(r instanceof ce)){t=1;break}t+=xo(i,r)}fm.set(e,t)}return t}function Yc(i,e,t,r,n,s,o,a,l){let c=0;for(let m=r;m=h)break;P+=C}if(x==v+1){if(P>h){let C=m[v];d(C.children,C.positions,0,C.children.length,p[v]+y);continue}u.push(m[v])}else{let C=p[x-1]+m[x-1].length-w;u.push(Yc(i,m,p,v,x,w,C,null,l))}f.push(w+y-s)}}return d(e,t,r,n,0),(a||l)(u,f,o)}var ko=class{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof _i?this.setBuffer(e.context.buffer,e.index,t):e instanceof ot&&this.map.set(e.tree,t)}get(e){return e instanceof _i?this.getBuffer(e.context.buffer,e.index):e instanceof ot?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)}},Di=class i{constructor(e,t,r,n,s=!1,o=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let n=[new i(0,e.length,e,0,!1,r)];for(let s of t)s.to>e.length&&n.push(s);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let h=a=r)for(;o&&o.from=f.from||u<=f.to||c){let d=Math.max(f.from,l)-c,m=Math.min(f.to,u)-c;f=d>=m?null:new i(d,m,f.tree,f.offset+c,a>0,!!h)}if(f&&n.push(f),o.to>u)break;o=snew kn(n.from,n.to)):[new kn(0,0)]:[new kn(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let s=n.advance();if(s)return s}}},Hc=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 DP=new L({perNode:!0});var cv=0,Rt=class i{constructor(e,t,r){this.set=e,this.base=t,this.modified=r,this.id=cv++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let t=new i([],null,[]);if(t.set.push(t),e)for(let r of e.set)t.set.push(r);return t}static defineModifier(){let e=new Eo;return t=>t.modified.indexOf(e)>-1?t:Eo.get(t.base||t,t.modified.concat(e).sort((r,n)=>r.id-n.id))}},hv=0,Eo=class i{constructor(){this.instances=[],this.id=hv++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(a=>a.base==e&&uv(t,a.modified));if(r)return r;let n=[],s=new Rt(n,e,t);for(let a of t)a.instances.push(s);let o=fv(t);for(let a of e.set)if(!a.modified.length)for(let l of o)n.push(i.get(a,l));return s}};function uv(i,e){return i.length==e.length&&i.every((t,r)=>t==e[r])}function fv(i){let e=[[]];for(let t=0;tr.length-t.length)}function mr(i){let e=Object.create(null);for(let t in i){let r=i[t];Array.isArray(r)||(r=[r]);for(let n of t.split(" "))if(n){let s=[],o=2,a=n;for(let u=0;;){if(a=="..."&&u>0&&u+3==n.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+n);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==n.length)break;let d=n[u++];if(u==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);a=n.slice(u)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+n);let h=new pr(r,o,l>0?s.slice(0,l):null);e[c]=h.sort(e[c])}}return Om.add(e)}var Om=new L,pr=class{constructor(e,t,r,n){this.tags=e,this.mode=t,this.context=r,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=n;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function dv(i,e){let t=null;for(let r of i){let n=r.style(e);n&&(t=t?t+" "+n:n)}return t}function eh(i,e,t,r=0,n=i.length){let s=new Jc(r,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),r,n,"",s.highlighters),s.flush(n)}function th(i,e,t,r,n,s=0,o=i.length){let a=s;function l(c,h){if(!(c<=a)){for(let u=i.slice(a,c),f=0;;){let d=u.indexOf(`
+`,f),m=d<0?u.length:d;if(m>f&&r(u.slice(f,m),h),d<0)break;n(),f=d+1}a=c}}eh(e,t,(c,h,u)=>{l(c,""),l(h,u)},s,o),l(o,"")}var Jc=class{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,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,r,n,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=n,h=pv(e)||pr.empty,u=dv(s,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(n+=(n?" ":"")+u)),this.startSpan(Math.max(t,a),c),h.opaque)return;let f=e.tree&&e.tree.prop(L.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+a,1),m=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),p=e.firstChild();for(let g=0,O=a;;g++){let y=g=x||!e.nextSibling())););if(!y||x>r)break;O=y.to+a,O>t&&(this.highlightRange(d.cursor(),Math.max(t,y.from+a),Math.min(r,O),"",m),this.startSpan(Math.min(r,O),c))}p&&e.parent()}else if(e.firstChild()){f&&(n="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,n,s),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}};function pv(i){let e=i.type.prop(Om);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var E=Rt.define,To=E(),si=E(),mm=E(si),gm=E(si),oi=E(),Po=E(oi),Zc=E(oi),Et=E(),Li=E(Et),Pt=E(),Ct=E(),Kc=E(),En=E(Kc),Co=E(),b={comment:To,lineComment:E(To),blockComment:E(To),docComment:E(To),name:si,variableName:E(si),typeName:mm,tagName:E(mm),propertyName:gm,attributeName:E(gm),className:E(si),labelName:E(si),namespace:E(si),macroName:E(si),literal:oi,string:Po,docString:E(Po),character:E(Po),attributeValue:E(Po),number:Zc,integer:E(Zc),float:E(Zc),bool:E(oi),regexp:E(oi),escape:E(oi),color:E(oi),url:E(oi),keyword:Pt,self:E(Pt),null:E(Pt),atom:E(Pt),unit:E(Pt),modifier:E(Pt),operatorKeyword:E(Pt),controlKeyword:E(Pt),definitionKeyword:E(Pt),moduleKeyword:E(Pt),operator:Ct,derefOperator:E(Ct),arithmeticOperator:E(Ct),logicOperator:E(Ct),bitwiseOperator:E(Ct),compareOperator:E(Ct),updateOperator:E(Ct),definitionOperator:E(Ct),typeOperator:E(Ct),controlOperator:E(Ct),punctuation:Kc,separator:E(Kc),bracket:En,angleBracket:E(En),squareBracket:E(En),paren:E(En),brace:E(En),content:Et,heading:Li,heading1:E(Li),heading2:E(Li),heading3:E(Li),heading4:E(Li),heading5:E(Li),heading6:E(Li),contentSeparator:E(Et),list:E(Et),quote:E(Et),emphasis:E(Et),strong:E(Et),link:E(Et),monospace:E(Et),strikethrough:E(Et),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:Co,documentMeta:E(Co),annotation:E(Co),processingInstruction:E(Co),definition:Rt.defineModifier(),constant:Rt.defineModifier(),function:Rt.defineModifier(),standard:Rt.defineModifier(),local:Rt.defineModifier(),special:Rt.defineModifier()},VP=Rn([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);var ih,gr=new L;function mv(i){return A.define({combine:i?e=>e.concat(i):void 0})}var gv=new L,Ge=class{constructor(e,t,r=[],n=""){this.data=e,this.name=n,W.prototype.hasOwnProperty("tree")||Object.defineProperty(W.prototype,"tree",{get(){return he(this)}}),this.parser=t,this.extension=[ai.of(this),W.languageData.of((s,o,a)=>{let l=ym(s,o,a),c=l.type.prop(gr);if(!c)return[];let h=s.facet(c),u=l.type.prop(gv);if(u){let f=l.resolve(o-l.from,a);for(let d of u)if(d.test(f,s)){let m=s.facet(d.facet);return d.type=="replace"?m:m.concat(h)}}return h})].concat(r)}isActiveAt(e,t,r=-1){return ym(e,t,r).type.prop(gr)==this.data}findRegions(e){let t=e.facet(ai);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],n=(s,o)=>{if(s.prop(gr)==this.data){r.push({from:o,to:o+s.length});return}let a=s.prop(L.mounted);if(a){if(a.tree.prop(gr)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+s.length});return}else if(a.overlay){let l=r.length;if(n(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;lr.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function he(i){let e=i.field(Ge.state,!1);return e?e.tree:ce.empty}var oh=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 r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}},An=null,ah=class i{constructor(e,t,r=[],n,s,o,a,l){this.parser=e,this.state=t,this.fragments=r,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new i(e,t,[],ce.empty,0,r,[],null)}startParse(){return this.parser.startParse(new oh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ce.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;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(Di.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=An;An=this;try{return e()}finally{An=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=bm(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:n,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,f)=>l.push({fromA:c,toA:h,fromB:u,toB:f})),r=Di.applyChanges(r,l),n=ce.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=bm(this.fragments,n,s),this.skipped.splice(r--,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 dr{createParse(t,r,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let l=An;if(l){for(let c of n)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ce(Ee.none,[],[],o-s)},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 An}};function bm(i,e,t){return Di.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var Mn=class i{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),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=ah.create(e.facet(ai).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new i(r)}};Ge.state=re.define({create:Mn.init,update(i,e){for(let t of e.effects)if(t.is(Ge.setState))return t.value;return e.startState.facet(ai)!=e.state.facet(ai)?Mn.init(e.state):i.apply(e)}});var km=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(km=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var rh=typeof navigator<"u"&&(!((ih=navigator.scheduling)===null||ih===void 0)&&ih.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ov=se.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(Ge.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(Ge.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=km(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,l=s.context.work(()=>rh&&rh()||Date.now()>o,n+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ge.setState.of(new Mn(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>xe(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()}}}),ai=A.define({combine(i){return i.length?i[0]:null},enables:i=>[Ge.state,Ov,R.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]}),yr=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var yv=A.define(),br=A.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function _n(i){let e=i.facet(br);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function wr(i,e){let t="",r=i.tabSize,n=i.facet(br)[0];if(n==" "){for(;e>=r;)t+=" ",e-=r;n=" "}for(let s=0;s=e?bv(i,t,e):null}var qi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=_n(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return n!=null&&n>=r.from&&n<=r.to?s&&n==e?{text:"",from:e}:(t<0?n-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,t=e.length){return Xt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:n}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(n);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Dn=new L;function bv(i,e,t){let r=e.resolveStack(t),n=r.node.enterUnfinishedNodesBefore(t);if(n!=r.node){let s=[];for(let o=n;o!=r.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return Tm(r,i,t)}function Tm(i,e,t){for(let r=i;r;r=r.next){let n=vv(r.node);if(n)return n(lh.create(e,t,r))}return 0}function wv(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function vv(i){let e=i.type.prop(Dn);if(e)return e;let t=i.firstChild,r;if(t&&(r=t.type.prop(L.closedBy))){let n=i.lastChild,s=n&&r.indexOf(n.name)>-1;return o=>Pm(o,!0,1,void 0,s&&!wv(o)?n.from:void 0)}return i.parent==null?xv:null}function xv(){return 0}var lh=class i extends qi{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new i(e,t,r)}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 r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(Sv(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return Tm(this.context.next,this.base,this.pos)}};function Sv(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function kv(i){let e=i.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let n=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=n==null||n<=s.from?s.to:Math.min(s.to,n);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped)return l.fromPm(r,e,t,i)}function Pm(i,e,t,r,n){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||n==i.pos+o,l=e?kv(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}var Tv=200;function Cm(){return W.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:r}=i.newSelection.main,n=t.lineAt(r);if(r>n.from+Tv)return i;let s=t.sliceString(n.from,r);if(!e.some(c=>c.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==a)continue;a=h.from;let u=Mo(o,h.from);if(u==null)continue;let f=/^\s*/.exec(h.text)[0],d=wr(o,u);f!=d&&l.push({from:h.from,to:h.from+f.length,insert:d})}return l.length?[i,{changes:l,sequential:!0}]:i})}var Pv=A.define(),Ln=new L;function _o(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&a.from=e&&c.to>t&&(s=c)}}return s}function Ev(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ro(i,e,t){for(let r of i.facet(Pv)){let n=r(i,e,t);if(n)return n}return Cv(i,e,t)}function Em(i,e){let t=e.mapPos(i.from,1),r=e.mapPos(i.to,-1);return t>=r?void 0:{from:t,to:r}}var Do=D.define({map:Em}),qn=D.define({map:Em});function Rm(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(i.lineBlockAt(t));return e}var Vi=re.define({create(){return M.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)if(t.is(Do)&&!Rv(i,t.value.from,t.value.to)){let{preparePlaceholder:r}=e.state.facet(ph),n=r?M.replace({widget:new ch(r(e.state,t.value))}):wm;i=i.update({add:[n.range(t.value.from,t.value.to)]})}else t.is(qn)&&(i=i.update({filter:(r,n)=>t.value.from!=r||t.value.to!=n,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:r}=e.selection.main;i.between(r,r,(n,s)=>{nr&&(t=!0)}),t&&(i=i.update({filterFrom:r,filterTo:r,filter:(n,s)=>s<=r||n>=r}))}return i},provide:i=>R.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(r,n)=>{t.push(r,n)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t