import{Facetast,EditorStatease,StateEffectasr,StateFieldasn,countColumnasi,RangeSetass,combineConfigaso,Precasl,RangeSetBuilderasa}from"./codemirror_state-BKbyfKsm.js";import{Vash,lasf,Easu,aasc,Wasd,p,Dasg,Gasm,Sasb}from"./codemirror_view-C0PMO2z_.js";constx=1024;letk=0;classy{constructor(t,e){this.from=t,this.to=e}}classw{constructor(t={}){this.id=k++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{thrownewError("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)thrownewRangeError("Can't add per-node props to node types");return"function"!=typeoft&&(t=A.match(t)),e=>{letr=t(e);returnvoid0===r?null:[this,r]}}}w.closedBy=neww({deserialize:t=>t.split("")}),w.openedBy=neww({deserialize:t=>t.split("")}),w.group=neww({deserialize:t=>t.split("")}),w.isolate=neww({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)thrownewRangeError("Invalid value for isolate: "+t);returnt||"auto"}}),w.contextHash=neww({perNode:!0}),w.lookAhead=neww({perNode:!0}),w.mounted=neww({perNode:!0});classv{constructor(t,e,r){this.tree=t,this.overlay=e,this.parser=r}staticget(t){returnt&&t.props&&t.props[w.mounted.id]}}constS=Object.create(null);classA{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}staticdefine(t){lete=t.props&&t.props.length?Object.create(null):S,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=newA(t.name||"",e,t.id,r);if(t.props)for(letroft.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)thrownewRangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}returnn}prop(t){returnthis.props[t.id]}getisTop(){return(1&this.flags)>0}getisSkipped(){return(2&this.flags)>0}getisError(){return(4&this.flags)>0}getisAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeoft){if(this.name==t)return!0;lete=this.prop(w.group);return!!e&&e.indexOf(t)>-1}returnthis.id==t}staticmatch(t){lete=Object.create(null);for(letrint)for(letnofr.split(""))e[n]=t[r];returnt=>{for(letr=t.prop(w.group),n=-1;n<(r?r.length:0);n++){leti=e[n<0?t.name:r[n]];if(i)returni}}}}A.none=newA("",Object.create(null),0,8);classC{constructor(t){this.types=t;for(lete=0;e<t.length;e++)if(t[e].id!=e)thrownewRangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){lete=[];for(letrofthis.types){letn=null;for(leteoft){lett=e(r);t&&(n||(n=Object.assign({},r.props)),n[t[0].id]=t[1])}e.push(n?newA(r.name,n,r.id,r.flags):r)}returnnewC(e)}}constN=newWeakMap,P=newWeakMap;varI;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(I||(I={}));classT{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]ofi)this.props["number"==typeoft?t:t.id]=e}}toString(){lett=v.get(this);if(t&&!t.overlay)returnt.tree.toString();lete="";for(lettofthis.children){letr=t.toString();r&&(e&&(e+=","),e+=r)}returnthis.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){returnnewF(this.topNode,t)}cursorAt(t,e=0,r=0){letn=N.get(this)||this.topNode,i=newF(n);returni.moveTo(t,e),N.set(this,i._tree),i}gettopNode(){returnnewL(this,0,0,null)}resolve(t,e=0){letr=M(N.get(this)||this.topNode,t,e,!1);returnN.set(this,r),r}resolveInner(t,e=0){letr=M(P.get(this)||this.topNode,t,e,!0);returnP.set(this,r),r}resolveStack(t,e=0){returnfunction(t,e,r){letn=t.resolveInner(e,r),i=null;for(lett=ninstanceofL?n:n.context.parent;t;t=t.parent)if(t.index<0){lets=t.parent;(i||(i=[n])).push(s.resolve(e,r)),t=s}else{lets=v.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){leto=newL(s.tree,s.overlay[0].from+t.from,-1,t);(i||(i=[n])).push(M(o,e,r,!1))}}returni?W(i):n}(this,t,e)}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t,s=t.mode||0,o=(s&I.IncludeAnonymous)>0;for(lett=this.cursor(s|I.IncludeAnonymous);;){lets=!1;if(t.from<=i&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&r&&(o||!t.type.isAnonymous)&&r(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){returnt.perNode?this.props?this.props[t.id]:void0:this.type.prop(t)}getpropValues(){lett=[];if(this.props)for(leteinthis.props)t.push([+e,this.props[e]]);returnt}balance(t={}){returnthis.children.length<=8?this:H(A.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>newT(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>newT(A.none,t,e,r)))}staticbuild(t){returnfunction(t){vare;let{buffer:r,nodeSet:n,maxBufferLength:i=x,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(r)?newO(r,r.length):r,a=n.types,h=0,f=0;functionu(t,e,r,x,k,y){let{id:w,start:v,end:S,size:A}=l,C=f;for(;A<0;){if(l.next(),-1==A){lete=s[w];returnr.push(e),voidx.push(v-t)}if(-3==A)returnvoid(h=w);if(-4==A)returnvoid(f=w);thrownewRangeError(`Unrecognized record size: ${A}`)}letN,P,I=a[w],T=v-t;if(S-v<=i&&(P=m(l.pos-e,k))){lete=newUint16Array(P.size-P.skip),r=l.pos-P.size,i=e.length;for(;l.pos>r;)i=b(P.start,e,i);N=newB(e,S-P.start,n),T=P.start-t}else{lett=l.pos-A;l.next();lete=[],r=[],n=w>=o?w:-1,s=0,a=S;for(;l.pos>t;)n>=0&&l.id==n&&l.size>=0?(l.end<=a-i&&(p(e,r,v,s,l.end,a,n,C),s=e.length,a=l.end),l.next()):y>2500?c(v,t,e,r):u(v,t,e,r,n,y+1);if(n>=0&&s>0&&s<e.length&&p(e,r,v,s,v,a,n,C),e.reverse(),r.reverse(),n>-1&&s>0){lett=d(I);N=H(I,e,r,0,e.length,0,S-v,t,t)}elseN=g(I,e,r,S-v,C-S)}r.push(N),x.push(T)}functionc(t,e,r,s){leto=[],a=0,h=-1;for(;l.pos>e;){let{id:t,start:e,end:r,size:n}=l;if(n>4)l.next();else{if(h>-1&&e<h)break;h<0&&(h=r-i),o.push(t,e,r),a++,l.next()}}if(a){lete=newUint16Array(4*a),i=o[o.length-2];for(lett=o.length-3,r=0;t>=0;t-=3)e[r++]=o[t],e[r++]=o[t+1]-i,e[r++]=o[t+2]-i,e[r++]=r;r.push(newB(e,o[2]-i,n)),s.push(i-t)}}functiond(t){return(e,r,n)=>{leti,s,o=0,l=e.length-1;if(l>=0&&(i=e[l])instanceofT){if(!l&&i.type==t&&i.length==n)returni;(s=i.prop(w.lookAhead))&&(o=r[l]+i.length+s)}returng(t,e,r,n,o)}}functionp(t,e,r,i,s,o,l,a){leth=[],f=[];for(;t.length>i;)h.push(t.pop()),f.push(e.pop()+r-s);t.push(g(n.types[l],h,f,o-s,a-o)),e.push(s-r)}functiong(t,e,r,n,i=0,s){if(h){lett=[w.contextHash,h];s=s?[t].concat(s):[t]}if(i>25){lett=[w.lookAhead,i];s=s?[t].concat(s):[t]}returnnewT(t,e,r,n,s)}functionm(t,e){letr=l.fork(),n=0,s=0,a=0,h=r.end-i,f={size:0,start:0,skip:0};t:for(leti=r.pos-t;r.pos>i;){lett=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=a,a+=4,n+=4,r.next();continue}letl=r.pos-t;if(t<0||l<i||r.start<h)break;letu=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)breakt;u+=4}elser.id>=o&&(u+=4);r.next()}s=c,n+=t,a+=u}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=a),f.size>4?f:void0}functionb(t,e,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){leto=r;if(a>4){letn=l.pos-(a-4);for(;l.pos>n;)r=b(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==a?h=n:-4==a&&(f=n);returnr}letk=[],y=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,k,y,-1,0);letv=null!==(e=t.length)&&void0!==e?e:k.length?y[0]+k[0].length:0;returnnewT(a[t.topID],k.reverse(),y.reverse(),v)}(t)}}T.empty=newT(A.none,[],[],0);classO{constructor(t,e){this.buffer=t,this.index=e}getid(){returnthis.buffer[this.index-4]}getstart(){returnthis.buffer[this.index-3]}getend(){returnthis.buffer[this.index-2]}getsize(){returnthis.buffer[this.index-1]}getpos(){returnthis.index}next(){this.index-=4}fork(){returnnewO(this.buffer,this.index)}}classB{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}gettype(){returnA.none}toString(){lett=[];for(lete=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];returnt.join(",")}childString(t){lete=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))returni;lets=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];returni+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(letl=t;l!=e&&!(_(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);returno}slice(t,e,r){letn=this.buffer,i=newUint16Array(e-t),s=0;for(leto=t,l=0;o<e;){i[l++]=n[o++],i[l++]=n[o++]-r;lete=i[l++]=n[o++]-r;i[l++]=n[o++]-t,s=Math.max(s,e)}returnnewB(i,s,this.set)}}function_(t,e,r,n){switch(t){case-2:returnr<e;case-1:returnn>=e&&r<e;case0:returnr<e&&n>e;case1:returnr<=e&&n>e;case2:returnn>e;case4:return!0}}functionM(t,e,r,n){for(vari;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){lete=!n&&tinstanceofL&&t.index<0?null:t.parent;if(!e)returnt;t=e}lets=n?0:I.IgnoreOverlays;if(n)for(letn=t,o=n.parent;o;n=o,o=n.parent)ninstanceofL&&n.index<0&&(null===(i=o.enter(e,r,s))||void0===i?void0:i.from)!=n.from&&(t=o);for(;;){letn=t.enter(e,r,s);if(!n)returnt;t=n}}classD{cursor(t=0){returnnewF(this,t)}getChild(t,e=null,r=null){letn=E(this,t,e,r);returnn.length?n[0]:null}getChildren(t,e=null,r=null){returnE(this,t,e,r)}resolve(t,e=0){returnM(this,t,e,!1)}resolveInner(t,e=0){returnM(this,t,e,!0)}matchContext(t){returnR(this,t)}enterUnfinishedNodesBefore(t){lete=this.childBefore(t),r=this;for(;e;){lett=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(r=e,e=t.prevSibling):e=t}returnr}getnode(){returnthis}getnext(){returnthis.parent}}classLextendsD{constructor(t,e,r,n){super(),this._tree=t,this.from=e,this.index=r,this._parent=n}gettype(){returnthis._tree.type}getname(){returnthis._tree.type.name}getto(){returnthis.from+this._tree.length}nextChild(t,e,r,n,i=0){for(lets=this;;){for(let{children:o,positions:l}=s._tree,a=e>0?o.length:-1;t!=a;t+=e){leta=o[t],h=l[t]+s.from;if(_(n,r,h,h+a.length))if(ainstanceofB){if(i&I.ExcludeBuffers)continue;leto=a.findChild(0,a.buffer.length,e,r-h,n);if(o>-1)returnnewj(newz(s,a,t,h),null,o)}elseif(i&I.IncludeAnonymous||!a.type.isAnonymous||V(a)){leto;if(!(i&I.IgnoreMounts)&&(o=v.get(a))&&!o.overlay)returnnewL(o.tree,h,t,s);letl=newL(a,h,t,s);returni&I.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,r,n)}}if(i&I.IncludeAnonymous||!s.type.isAnonymous)returnnull;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)returnnull}}getfirstChild(){returnthis.nextChild(0,1,0,4)}getlastChild(){returnthis.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){returnthis.nextChild(0,1,t,2)}childBefore(t){returnthis.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,r=0){letn;if(!(r&I.IgnoreOverlays)&&(n=v.get(this._tree))&&n.overlay){letr=t-this.from;for(let{from:t,to:i}ofn.overlay)if((e>0?t<=r:t<r)&&(e<0?i>=r:i>r))returnnewL(n.tree,n.overlay[0].from+this.from,-1,this)}returnthis.nextChild(0,1,t,e,r)}nextSignificantParent(){lett=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;returnt}getparent(){returnthis._parent?this._parent.nextSignificantParent():null}getnextSibling(){returnthis._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}getprevSibling(){returnthis._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}gettree(){returnthis._tree}toTree(){returnthis._tree}toString(){returnthis._tree.toString()}}functionE(t,e,r,n){leti=t.cursor(),s=[];if(!i.firstChild())returns;if(null!=r)for(lett=!1;!t;)if(t=i.type.is(r),!i.nextSibling())returns;for(;;){if(null!=n&&i.type.is(n))returns;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())returnnull==n?s:[]}}functionR(t,e,r=e.length-1){for(letn=t.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}classz{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}classjextendsD{getname(){returnthis.type.name}getfrom(){returnthis.context.start+this.context.buffer.buffer[this.index+1]}getto(){returnthis.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,r){super(),this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);returni<0?null:newj(this.context,this,i)}getfirstChild(){returnthis.child(1,0,4)}getlastChild(){returnthis.child(-1,0,4)}childAfter(t){returnthis.child(1,t,2)}childBefore(t){returnthis.child(-1,t,-2)}enter(t,e,r=0){if(r&I.ExcludeBuffers)returnnull;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);returni<0?null:newj(this.context,this,i)}getparent(){returnthis._parent||this.context.parent.nextSignificantParent()}externalSibling(t){returnthis._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}getnextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];returne<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?newj(this.context,this._parent,e):this.externalSibling(1)}getprevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;returnthis.index==e?this.externalSibling(-1):newj(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}gettree(){returnnull}toTree(){lett=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){lets=r.buffer[this.index+1];t.push(r.slice(n,i,s)),e.push(0)}returnnewT(this.type,t,e,this.to-this.from)}toString(){returnthis.context.buffer.childString(this.index)}}functionW(t){if(!t.length)returnnull;lete=0,r=t[0];for(letn=1;n<t.length;n++){leti=t[n];(i.from>r.from||i.to<r.to)&&(r=i,e=n)}letn=rinstanceofL&&r.index<0?null:r.parent,i=t.slice();returnn?i[e]=n:i.splice(e,1),newU(i,r)}classU{constructor(t,e){this.heads=t,this.node=e}getnext(){returnW(this.heads)}}classF{getname(){returnthis.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,tinstanceofL)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(lete=t._parent;e;e=e._parent)this.stack.unshift(e.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)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;returnthis.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(tinstanceofL?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){returnthis.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)returnthis.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){returnthis.enterChild(1,0,4)}lastChild(){returnthis.enterChild(-1,0,4)}childAfter(t){returnthis.enterChild(1,t,2)}childBefore(t){returnthis.enterChild(-1,t,-2)}enter(t,e,r=this.mode){returnthis.buffer?!(r&I.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r))}parent(){if(!this.buffer)returnthis.yieldNode(this.mode&I.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)returnthis.yieldBuf(this.stack.pop());lett=this.mode&I.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();returnthis.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));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){lett=r<0?0:this.stack[r]+4;if(this.index!=t)returnthis.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{lett=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))returnthis.yieldBuf(t)}returnr<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){returnthis.sibling(1)}prevSibling(){returnthis.sibling(-1)}atLastNode(t){lete,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}elsefor(lett=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(letn=e+t,i=t<0?-1:r._tree.children.length;n!=i;n+=t){lett=r._tree.children[n];if(this.mode&I.IncludeAnonymous||tinstanceofB||!t.type.isAnonymous||V(t))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){returnthis.move(1,t)}prev(t=!0){returnthis.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<t))&&this.parent(););for(;this.enterChild(1,t,e););returnthis}getnode(){if(!this.buffer)returnthis._tree;lett=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(letn=this.index,i=this.stack.length;i>=0;){for(lets=t;s;s=s._parent)if(s.index==n){if(n==this.index)returns;e=s,r=i+1;breakt}n=this.stack[--i]}for(lett=r;t<this.stack.length;t++)e=newj(this.buffer,e,this.stack[t]);returnthis.bufferNode=newj(this.buffer,e,this.index)}gettree(){returnthis.buffer?null:this._tree._tree}iterate(t,e){for(letr=0;;){letn=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(t){if(!this.buffer)returnR(this.node,t);let{buffer:e}=this.buffer,{types:r}=e.set;for(letn=t.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)returnR(this.node,t,n);lets=r[e.buffer[this.stack[i]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}functionV(t){returnt.children.some((t=>tinstanceofB||!t.type.isAnonymous||V(t)))}constq=newWeakMap;function$(t,e){if(!t.isAnonymous||einstanceofB||e.type!=t)return1;letr=q.get(e);if(null==r){r=1;for(letnofe.children){if(n.type!=t||!(ninstanceofT)){r=1;break}r+=$(t,n)}q.set(e,r)}returnr}functionH(t,e,r,n,i,s,o,l,a){leth=0;for(letr=n;r<i;r++)h+=$(t,e[r]);letf=Math.ceil(1.5*h/8),u=[],c=[];returnfunctione(r,n,i,o,l){for(leth=i;h<o;){leti=h,d=n[h],p=$(t,r[h]);for(h++;h<o;h++){lete=$(t,r[h]);if(p+e>=f)break;p+=e}if(h==i+1){if(p>f){lett=r[i];e(t.children,t.positions,0,t.children.length,n[i]+l);continue}u.push(r[i])}else{lete=n[h-1]+r[h-1].length-d;u.push(H(t,r,n,i,h,d,e,null,a))}c.push(d+l-s)}}(e,r,n,i,0),(l||a)(u,c,o)}classG{constructor(){this.map=newWeakMap}setBuffer(t,e,r){letn=this.map.get(t);n||this.map.set(t,n=newMap),n.set(e,r)}getBuffer(t,e){letr=this.map.get(t);returnr&&r.get(e)}set(t,e){tinstanceofj?this.setBuffer(t.context.buffer,t.index,e):tinstanceofL&&this.map.set(t.tree,e)}get(t){returntinstanceofj?this.getBuffer(t.context.buffer,t.index):tinstanceofL?this.map.get(t.tree):void0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){returnt.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}classJ{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}getopenStart(){return(1&this.open)>0}getopenEnd(){return(2&this.open)>0}staticaddTree(t,e=[],r=!1){letn=[newJ(0,t.length,t,0,!1,r)];for(letrofe)r.to>t.length&&n.push(r);returnn}staticapplyChanges(t,e,r=128){if(!e.length)returnt;letn=[],i=1,s=t.length?t[0]:null;for(leto=0,l=0,a=0;;o++){leth=o<e.length?e[o]:null,f=h?h.fromA:1e9;if(f-l>=r)for(;s&&s.from<f;){lete=s;if(l>=e.from||f<=e.to||a){lett=Math.max(e.from,l)-a,r=Math.min(e.to,f)-a;e=t>=r?null:newJ(t,r,e.tree,e.offset+a,o>0,!!h)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}returnn}}classK{startParse(t,e,r){return"string"==typeoft&&(t=newQ(t)),r=r?r.length?r.map((t=>newy(t.from,t.to))):[newy(0,0)]:[newy(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){letn=this.startParse(t,e,r);for(;;){lett=n.advance();if(t)returnt}}}classQ{constructor(t){this.string=t}getlength(){returnthis.string.length}chunk(t){returnthis.string.slice(t)}getlineChunks(){return!1}read(t,e){returnthis.string.slice(t,e)}}neww({perNode:!0});letX=0;classY{constructor(t,e,r){this.set=t,this.base=e,this.modified=r,this.id=X++}staticdefine(t){if(null==t?void0:t.base)thrownewError("Can not derive from a modified tag");lete=newY([],null,[]);if(e.set.push(e),t)for(letroft.set)e.set.push(r);returne}staticdefineModifier(){lett=newtt;returne=>e.modified.indexOf(t)>-1?e:tt.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}letZ=0;classtt{constructor(){this.instances=[],this.id=Z++}staticget(t,e){if(!e.length)returnt;letr=e[0].instances.find((r=>{returnr.base==t&&(n=e,i=r.modified,n.length==i.length&&n.every(((t,e)=>t==i[e])));varn,i}));if(r)returnr;letn=[],i=newY(n,t,e);for(lettofe)t.instances.push(i);lets=function(t){lete=[[]];for(letr=0;r<t.length;r++)for(letn=0,i=e.length;n<i;n++)e.push(e[n].concat(t[r]));returne.sort(((t,e)=>e.length-t.length))}(e);for(leteoft.set)if(!e.modified.length)for(lettofs)n.push(tt.get(e,t));returni}}functionet(t){lete=Object.create(null);for(letrint){letn=t[r];Array.isArray(n)||(n=[n]);for(lettofr.split(""))if(t){letr=[],i=2,s=t;for(lete=0;;){if("..."==s&&e>0&&e+3==t.length){i=1;break}letn=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)thrownewRangeError("Invalid path: "+t);if(r.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;leto=t[e++];if(e==t.length&&"!"==o){i=0;break}if("/"!=o)thrownewRangeError("Invalid path: "+t);s=t.slice(e)}leto=r.length-1,l=r[o];if(!l)thrownewRangeError("Invalid path: "+t);leta=newnt(n,i,o>0?r.slice(0,o):null);e[l]=a.sort(e[l])}}returnrt.add(e)}constrt=neww;classnt{constructor(t,e,r,n){this.tags=t,this.mode=e,this.context=r,this.next=n}getopaque(){return0==this.mode}getinherit(){return1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}getdepth(){returnthis.context?this.context.length:0}}functionit(t,e){letr=Object.create(null);for(leteoft)if(Array.isArray(e.tag))for(lettofe.tag)r[t.id]=e.class;elser[e.tag.id]=e.class;let{scope:n,all:i=null}=e||{};return{style:t=>{lete=i;for(letnoft)for(lettofn.set){letn=r[t.id];if(n){e=e?e+""+n:n;break}}returne},scope:n}}functionst(t,e,r,n=0,i=t.length){lets=newot(n,Array.isArray(e)?e:[e],r);s.highlightRange(t.cursor(),n,i,"",s.highlighters),s.flush(i)}nt.empty=newnt([],2,null);classot{constructor(t,e,r){this.at=t,this.highlighters=e,this.span=r,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,r,n,i){let{type:s,from:o,to:l}=t;if(o>=r||l<=e)return;s.isTop&&(i=this.highlighters.filter((t=>!t.scope||t.scope(s))));leta=n,h=function(t){lete=t.type.prop(rt);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;returne||null}(t)||nt.empty,f=function(t,e){letr=null;for(letnoft){lett=n.style(e);t&&(r=r?r+""+t:t)}returnr}(i,h.tags);if(f&&(a&&(a+=""),a+=f,1==h.mode&&(n+=(n?"":"")+f)),this.startSpan(Math.max(e,o),a),h.opaque)return;letu=t.tree&&t.tree.prop(w.mounted);if(u&&u.overlay){lets=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),f=t.firstChild();for(letc=0,d=o;;c++){letp=c<u.overlay.length?u.overlay[c]:null,g=p?p.from+o:l,m=Math.max(e,d),b=Math.min(r,g);if(m<b&&f)for(;t.from<b&&(this.highlightRange(t,m,b,n,i),this.startSpan(Math.min(b,t.to),a),!(t.to>=g)&&t.nextSibling()););if(!p||g>r)break;d=p.to+o,d>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(r,d),"",h),this.startSpan(Math.min(r,d),a))}f&&t.parent()}elseif(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=r)break;this.highlightRange(t,e,r,n,i),this.startSpan(Math.min(r,t.to),a)}}while(t.nextSibling());t.parent()}}}constlt=Y.define,at=lt(),ht=lt(),ft=lt(ht),ut=lt(ht),ct=lt(),dt=lt(ct),pt=lt(ct),gt=lt(),mt=lt(gt),bt=lt(),xt=lt(),kt=lt(),yt=lt(kt),wt=lt(),vt={comment:at,lineComment:lt(at),blockComment:lt(at),docComment:lt(at),name:ht,variableName:lt(ht),typeName:ft,tagName:lt(ft),propertyName:ut,attributeName:lt(ut),className:lt(ht),labelName:lt(ht),namespace:lt(ht),macroName:lt(ht),literal:ct,string:dt,docString:lt(dt),character:lt(dt),attributeValue:lt(dt),number:pt,integer:lt(pt),float:lt(pt),bool:lt(ct),regexp:lt(ct),escape:lt(ct),color:lt(ct),url:lt(ct),keyword:bt,self:lt(bt),null:lt(bt),atom:lt(bt),unit:lt(bt),modifier:lt(bt),operatorKeyword:lt(bt),controlKeyword:lt(bt),definitionKeyword:lt(bt),moduleKeyword:lt(bt),operator:xt,derefOperator:lt(xt),arithmeticOperator:lt(xt),logicOperator:lt(xt),bitwiseOperator:lt(xt),compareOperator:lt(xt),updateOperator:lt(xt),definitionOperator:lt(xt),typeOperator:lt(xt),controlOperator:lt(xt),punctuation:kt,separator:lt(kt),bracket:yt,angleBracket:lt(yt),squareBracket:lt(yt),paren:lt(yt),brace:lt(yt),content:gt,heading:mt,heading1:lt(mt),heading2:lt(mt),heading3:lt(mt),heading4:lt(mt),heading5:lt(mt),heading6:lt(mt),contentSeparator:lt(gt),list:lt(gt),quote:lt(gt),emphasis:lt(gt),strong:lt(gt),link:lt(gt),monospace:lt(gt),strikethrough:lt(gt),inserted:lt(),deleted:lt(),changed:lt(),invalid:lt(),meta:wt,documentMeta:lt(wt),annotation:lt(wt),processingInstruction:lt(wt),definition:Y.defineModifier(),constant:Y.defineModifier(),function:Y.defineModifier(),standard:Y.defineModifier(),local:Y.defineModifier(),special:Y.defineModifier()};varSt;it([{tag:vt.link,class:"tok-link"},{tag:vt.heading,class:"tok-heading"},{tag:vt.emphasis,class:"tok-emphasis"},{tag:vt.strong,class:"tok-strong"},{tag:vt.keyword,class:"tok-keyword"},{tag:vt.atom,class:"tok-atom"},{tag:vt.bool,class:"tok-bool"},{tag:vt.url,class:"tok-url"},{tag:vt.labelName,class:"tok-labelName"},{tag:vt.inserted,class:"tok-inserted"},{tag:vt.deleted,class:"tok-deleted"},{tag:vt.literal,class:"tok-literal"},{tag:vt.string,class:"tok-string"},{tag:vt.number,class:"tok-number"},{tag:[vt.regexp,vt.escape,vt.special(vt.string)],class:"tok-string2"},{tag:vt.variableName,class:"tok-variableName"},{tag:vt.local(vt.variableName),class:"tok-variableName tok-local"},{tag:vt.definition(vt.variableName),class:"tok-variableName tok-definition"},{tag:vt.special(vt.variableName),class:"tok-variableName2"},{tag:vt.definition(vt.propertyName),class:"tok-propertyName tok-definition"},{tag:vt.typeName,class:"tok-typeName"},{tag:vt.namespace,class:"tok-namespace"},{tag:vt.className,class:"tok-className"},{tag:vt.macroName,class:"tok-macroName"},{tag:vt.propertyName,class:"tok-propertyName"},{tag:vt.operator,class:"tok-operator"},{tag:vt.comment,class:"tok-comment"},{tag:vt.meta,class:"tok-meta"},{tag:vt.invalid,class:"tok-invalid"},{tag:vt.punctuation,class:"tok-punctuation"}]);constAt=neww;functionCt(e){returnt.define({combine:e?t=>t.concat(e):void0})}constNt=neww;classPt{constructor(t,r,n=[],i=""){this.data=t,this.name=i,e.prototype.hasOwnProperty("tree")||Object.defineProperty(e.prototype,"tree",{get(){returnOt(this)}}),this.parser=r,this.extension=[Wt.of(this),e.languageData.of(((t,e,r)=>{letn=It(t,e,r),i=n.type.prop(At);if(!i)return[];lets=t.facet(i),o=n.type.prop(Nt);if(o){leti=n.resolve(e-n.from,r);for(leteofo)if(e.test(i,t)){letr=t.facet(e.facet);return"replace"==e.type?r:r.concat(s)}}returns}))].concat(n)}isActiveAt(t,e,r=-1){returnIt(t,e,r).type.prop(At)==this.data}findRegions(t){lete=t.facet(Wt);if((null==e?void0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];letr=[],n=(t,e)=>{if(t.prop(At)==this.data)returnvoidr.push({from:e,to:e+t.length});leti=t.prop(w.mounted);if(i){if(i.tree.prop(At)==this.data){if(i.overlay)for(lettofi.overlay)r.push({from:t.from+e,to:t.to+e});elser.push({from:e,to:e+t.length});return}if(i.overlay){lett=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(letr=0;r<t.children.length;r++){leti=t.children[r];iinstanceofT&&n(i,t.positions[r]+e)}};returnn(Ot(t),0),r}getallowsNesting(){return!0}}functionIt(t,e,r){letn=t.facet(Wt),i=Ot(t).topNode;if(!n||n.allowsNesting)for(lett=i;t;t=t.enter(e,r,I.ExcludeBuffers))t.type.isTop&&(i=t);returni}Pt.setState=r.define();classTtextendsPt{constructor(t,e,r){super(t,e,[],r),this.parser=e}staticdefine(t){lete=Ct(t.languageData);returnnewTt(e,t.parser.configure({props:[At.add((t=>t.isTop?e:void0))]}),t.name)}configure(t,e){returnnewTt(this.data,this.parser.configure(t),e||this.name)}getallowsNesting(){returnthis.parser.hasWrappers()}}functionOt(t){lete=t.field(Pt.state,!1);returne?e.tree:T.empty}functionBt(t,e,r=50){varn;leti=null===(n=t.field(Pt.state,!1))||void0===n?void0:n.context;if(!i)returnnull;lets=i.viewport;i.updateViewport({from:0,to:e});leto=i.isDone(e)||i.work(r,e)?i.tree:null;returni.updateViewport(s),o}class_t{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}getlength(){returnthis.doc.length}syncTo(t){returnthis.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){returnthis.syncTo(t),this.string}getlineChunks(){return!0}read(t,e){letr=this.cursorPos-this.string.length;returnt<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}letMt=null;classDt{constructor(t,e,r=[],n,i,s,o,l){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}staticcreate(t,e,r){returnnewDt(t,e,[],T.empty,0,r,[],null)}startParse(){returnthis.parser.startParse(new_t(this.state.doc),this.fragments)}work(t,e){returnnull!=e&&e>=this.state.doc.length&&(e=void0),this.tree!=T.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{varr;if("number"==typeoft){lete=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){letn=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(J.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){lett,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(J.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){lete=Mt;Mt=this;try{returnt()}finally{Mt=e}}withoutTempSkipped(t){for(lete;e=this.tempSkipped.pop();)t=Lt(t,e.from,e.to);returnt}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){lete=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=J.applyChanges(r,e),n=T.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(leteofthis.skipped){letr=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}returnnewDt(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;lete=this.skipped.length;for(lete=0;e<this.skipped.length;e++){let{from:r,to:n}=this.skipped[e];r<t.to&&n>t.from&&(this.fragments=Lt(this.fragments,r,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}staticgetSkippingParser(t){returnnewclassextendsK{createParse(e,r,n){leti=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){lete=Mt;if(e){for(lettofn)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}returnthis.parsedPos=s,newT(A.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);lete=this.fragments;returnthis.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}staticget(){returnMt}}functionLt(t,e,r){returnJ.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}classEt{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)returnthis;lete=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);returne.work(20,r)||e.takeTree(),newEt(e)}staticinit(t){lete=Math.min(3e3,t.doc.length),r=Dt.create(t.facet(Wt).parser,t,{from:0,to:e});returnr.work(20,e)||r.takeTree(),newEt(r)}}Pt.state=n.define({create:Et.init,update(t,e){for(lettofe.effects)if(t.is(Pt.setState))returnt.value;returne.startState.facet(Wt)!=e.state.facet(Wt)?Et.init(e.state):t.apply(e)}});letRt=t=>{lete=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeofrequestIdleCallback&&(Rt=t=>{lete=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});constzt="undefined"!=typeofnavigator&&(null===(St=navigator.scheduling)||void0===St?void0:St.isInputPending)?()=>navigator.scheduling.isInputPending():null,jt=h.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){lete=this.view.state.field(Pt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Pt.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Rt(this.work))}work(t){this.working=null;lete=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(Pt.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;lets=Date.now()+Math.min(this.chunkBudget,100,t&&!zt?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,l=i.context.work((()=>zt&&zt()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Pt.setState.of(newEt(i.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>f(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Wt=t.define({combine:t=>t.length?t[0]:null,enables:t=>[Pt.state,jt,u.contentAttributes.compute([t],(e=>{letr=e.facet(t);returnr&&r.name?{"data-language":r.name}:{}}))]});classUt{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}classFt{constructor(t,e,r,n,i,s=void0){this.name=t,this.alias=e,this.extensions=r,this.filename=n,this.loadFunc=i,this.support=s,this.loading=null}load(){returnthis.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{throwthis.loading=null,t})))}staticof(t){let{load:e,support:r}=t;if(!e){if(!r)thrownewRangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}returnnewFt(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,r)}staticmatchFilename(t,e){for(letroft)if(r.filename&&r.filename.test(e))returnr;letr=/\.([^.]+)$/.exec(e);if(r)for(leteoft)if(e.extensions.indexOf(r[1])>-1)returne;returnnull}staticmatchLanguageName(t,e,r=!0){e=e.toLowerCase();for(letroft)if(r.alias.some((t=>t==e)))returnr;if(r)for(letroft)for(lettofr.alias){letn=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))returnr}returnnull}}constVt=t.define(),qt=t.define({combine:t=>{if(!t.length)return"";lete=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))thrownewError("Invalid indent unit: "+JSON.stringify(t[0]));returne}});function$t(t){lete=t.facet(qt);return9==e.charCodeAt(0)?t.tabSize*e.length:e.length}functionHt(t,e){letr="",n=t.tabSize,i=t.facet(qt)[0];if("\t"==i){for(;e>=n;)r+="\t",e-=n;i=""}for(lett=0;t<e;t++)r+=i;returnr}functionGt(t,r){tinstanceofe&&(t=newJt(t));for(leteoft.state.facet(Vt)){letn=e(t,r);if(void0!==n)returnn}letn=Ot(t.state);returnn.length>=r?function(t,e,r){letn=e.resolveStack(r),i=n.node.enterUnfinishedNodesBefore(r);if(i!=n.node){lett=[];for(lete=i;e!=n.node;e=e.parent)t.push(e);for(lete=t.length-1;e>=0;e--)n={node:t[e],next:n}}returnQt(n,t,r)}(t,n,r):null}classJt{constructor(t,e={}){this.state=t,this.options=e,this.unit=$t(t)}lineAt(t,e=1){letr=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:i}=this.options;returnnull!=n&&n>=r.from&&n<=r.to?i&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:r.text.slice(n-r.from),from:n}:{text:r.text.slice(0,n-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:n}=this.lineAt(t,e);returnr.slice(t-n,Math.min(r.length,t+100-n))}column(t,e=1){let{text:r,from:n}=this.lineAt(t,e),i=this.countColumn(r,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;returns>-1&&(i+=s-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){returni(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:n}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){lett=i(n);if(t>-1)returnt}returnthis.countColumn(r,r.search(/\S|$/))}getsimulatedBreak(){returnthis.options.simulateBreak||null}}constKt=neww;functionQt(t,e,r){for(letn=t;n;n=n.next){lett=Xt(n.node);if(t)returnt(Zt.create(e,r,n))}return0}functionXt(t){lete=t.type.prop(Kt);if(e)returne;letr,n=t.firstChild;if(n&&(r=n.type.prop(w.closedBy))){lete=t.lastChild,n=e&&r.indexOf(e.name)>-1;returnt=>re(t,!0,1,void0,n&&!function(t){returnt.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void0)}returnnull==t.parent?Yt:null}functionYt(){return0}classZtextendsJt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}getnode(){returnthis.context.node}staticcreate(t,e,r){returnnewZt(t,e,r)}gettextAfter(){returnthis.textAfterPos(this.pos)}getbaseIndent(){returnthis.baseIndentFor(this.node)}baseIndentFor(t){lete=this.state.doc.lineAt(t.from);for(;;){letr=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(te(r,t))break;e=this.state.doc.lineAt(r.from)}returnthis.lineIndent(e.from)}continue(){returnQt(this.context.next,this.base,this.pos)}}functionte(t,e){for(letr=e;r;r=r.parent)if(t==r)return!0;return!1}functionee({closing:t,align:e=!0,units:r=1}){returnn=>re(n,e,r,t)}functionre(t,e,r,n,i){lets=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||i==t.pos+o,a=e?function(t){lete=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)returnnull;leti=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),o=null==i||i<=s.from?s.to:Math.min(s.to,i);for(lett=r.to;;){leti=e.childAfter(t);if(!i||i==n)returnnull;if(!i.type.isSkipped)returni.from<o?r:null;t=i.to}}(t):null;returna?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}functionne(){returne.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))returnt;lete=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)returnt;letr=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+200)returnt;lets=r.sliceString(i.from,n);if(!e.some((t=>t.test(s))))returnt;let{state:o}=t,l=-1,a=[];for(let{head:t}ofo.selection.ranges){lete=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;letr=Gt(o,e.from);if(null==r)continue;letn=/^\s*/.exec(e.text)[0],i=Ht(o,r);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}returna.length?[t,{changes:a,sequential:!0}]:t}))}constie=t.define(),se=neww;functionoe(t){lete=t.firstChild,r=t.lastChild;returne&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}functionle(t){lete=t.lastChild;returne&&e.to==t.to&&e.type.isError}functionae(t,e,r){for(letnoft.facet(ie)){leti=n(t,e,r);if(i)returni}returnfunction(t,e,r){letn=Ot(t);if(n.length<r)returnnull;leti=null;for(lets=n.resolveStack(r,1);s;s=s.next){leto=s.node;if(o.to<=r||o.from>r)continue;if(i&&o.from<e)break;letl=o.type.prop(se);if(l&&(o.to<n.length-50||n.length==t.doc.length||!le(o))){letn=l(o,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(i=n)}}returni}(t,e,r)}functionhe(t,e){letr=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);returnr>=n?void0:{from:r,to:n}}constfe=r.define({map:he}),ue=r.define({map:he});functionce(t){lete=[];for(let{head:r}oft.state.selection.ranges)e.some((t=>t.from<=r&&t.to>=r))||e.push(t.lineBlockAt(r));returne}constde=n.define({create:()=>c.none,update(t,e){t=t.map(e.changes);for(letrofe.effects)if(r.is(fe)&&!ge(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(Ce),i=n?c.replace({widget:newTe(n(e.state,r.value))}):Ie;t=t.update({add:[i.range(r.value.from,r.value.to)]})}elser.is(ue)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){letr=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{t<n&&e>n&&(r=!0)})),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}returnt},provide:t=>u.decorations.from(t),toJSON(t,e){letr=[];returnt.between(0,e.doc.length,((t,e)=>{r.push(t,e)})),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)thrownewRangeError("Invalid JSON for fold state");lete=[];for(letr=0;r<t.length;){letn=t[r++],i=t[r++];if("number"!=typeofn||"number"!=typeofi)thrownewRangeError("Invalid JSON for fold state");e.push(Ie.range(n,i))}returnc.set(e,!0)}});functionpe(t,e,r){varn;leti=null;returnnull===(n=t.field(de,!1))||void0===n||n.between(e,r,((t,e)=>{(!i||i.from>t)&&(i={from:t,to:e})})),i}functionge(t,e,r){letn=!1;returnt.between(e,e,((t,i)=>{t==e&&i==r&&(n=!0)})),n}functionme(t,e){returnt.field(de,!1)?e:e.concat(r.appendConfig.of(Ne()))}constbe=t=>{for(leteofce(t)){letr=ae(t.state,e.from,e.to);if(r)returnt.dispatch({effects:me(t.state,[fe.of(r),ke(t,r)])}),!0}return!1},xe=t=>{if(!t.state.field(de,!1))return!1;lete=[];for(letrofce(t)){letn=pe(t.state,r.from,r.to);n&&e.push(ue.of(n),ke(t,n,!1))}returne.length&&t.dispatch({effects:e}),e.length>0};functionke(t,e,r=!0){letn=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;returnu.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")}${n}${t.state.phrase("to")}${i}.`)}constye=t=>{let{state:e}=t,r=[];for(letn=0;n<e.doc.length;){leti=t.lineBlockAt(n),s=ae(e,i.from,i.to);s&&r.push(fe.of(s)),n=(s?t.lineBlockAt(s.to):i).to+1}returnr.length&&t.dispatch({effects:me(t.state,r)}),!!r.length},we=t=>{lete=t.state.field(de,!1);if(!e||!e.size)return!1;letr=[];returne.between(0,t.state.doc.length,((t,e)=>{r.push(ue.of({from:t,to:e}))})),t.dispatch({effects:r}),!0};functionve(t,e){for(letr=e;;){letn=ae(t.state,r.from,r.to);if(n&&n.to>e.from)returnn;if(!r.from)returnnull;r=t.lineBlockAt(r.from-1)}}constSe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:be},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:xe},{key:"Ctrl-Alt-[",run:ye},{key:"Ctrl-Alt-]",run:we}],Ae={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ce=t.define({combine:t=>o(t,Ae)});functionNe(t){lete=[de,Me];returnt&&e.push(Ce.of(t)),e}functionPe(t,e){let{state:r}=t,n=r.facet(Ce),i=e=>{letr=t.lineBlockAt(t.posAtDOM(e.target)),n=pe(t.state,r.from,r.to);n&&t.dispatch({effects:ue.of(n)}),e.preventDefault()};if(n.placeholderDOM)returnn.placeholderDOM(t,i,e);lets=document.createElement("span");returns.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}constIe=c.replace({widget:newclassextendsd{toDOM(t){returnPe(t,null)}}});classTeextendsd{constructor(t){super(),this.value=t}eq(t){returnthis.value==t.value}toDOM(t){returnPe(t,this.value)}}constOe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};classBeextendsm{constructor(t,e){super(),this.config=t,this.open=e}eq(t){returnthis.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)returnthis.config.markerDOM(this.open);lete=document.createElement("span");returne.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function_e(t={}){lete=Object.assign(Object.assign({},Oe),t),r=newBe(e,!0),n=newBe(e,!1),i=h.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(Wt)!=t.state.facet(Wt)||t.startState.field(de,!1)!=t.state.field(de,!1)||Ot(t.startState)!=Ot(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){lete=newa;for(letioft.viewportLineBlocks){lets=pe(t.state,i.from,i.to)?n:ae(t.state,i.from,i.to)?r:null;s&&e.add(i.from,i.from,s)}returne.finish()}}),{domEventHandlers:o}=e;return[i,p({class:"cm-foldGutter",markers(t){vare;return(null===(e=t.plugin(i))||void0===e?void0:e.markers)||s.empty},initialSpacer:()=>newBe(e,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(t,e,r)=>{if(o.click&&o.click(t,e,r))return!0;letn=pe(t.state,e.from,e.to);if(n)returnt.dispatch({effects:ue.of(n)}),!0;leti=ae(t.state,e.from,e.to);return!!i&&(t.dispatch({effects:fe.of(i)}),!0)}})}),Ne()]}constMe=u.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});classDe{constructor(t,e){letr;functionn(t){lete=b.newName();return(r||(r=Object.create(null)))["."+e]=t,e}this.specs=t;consti="string"==typeofe.all?e.all:e.all?n(e.all):void0,s=e.scope;this.scope=sinstanceofPt?t=>t.prop(At)==s.data:s?t=>t==s:void0,this.style=it(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:i}).style,this.module=r?newb(r):null,this.themeType=e.themeType}staticdefine(t,e){returnnewDe(t,e||{})}}constLe=t.define(),Ee=t.define({combine:t=>t.length?[t[0]]:null});functionRe(t){lete=t.facet(Le);returne.length?e:t.facet(Ee)}functionze(t,e){letr,n=[We];returntinstanceofDe&&(t.module&&n.push(u.styleModule.of(t.module)),r=t.themeType),(null==e?void0:e.fallback)?n.push(Ee.of(t)):r?n.push(Le.computeN([u.darkTheme],(e=>e.facet(u.darkTheme)==("dark"==r)?[t]:[]))):n.push(Le.of(t)),n}classje{constructor(t){this.markCache=Object.create(null),this.tree=Ot(t.state),this.decorations=this.buildDeco(t,Re(t.state)),this.decoratedTo=t.viewport.to}update(t){lete=Ot(t.state),r=Re(t.state),n=r!=Re(t.startState),{viewport:i}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!n&&e.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)returnc.none;letr=newa;for(let{from:n,to:i}oft.visibleRanges)st(this.tree,e,((t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=c.mark({class:n})))}),n,i);returnr.finish()}}constWe=l.high(h.fromClass(je,{decorations:t=>t.decorations})),Ue=De.define([{tag:vt.meta,color:"#404740"},{tag:vt.link,textDecoration:"underline"},{tag:vt.heading,textDecoration:"underline",fontWeight:"bold"},{tag:vt.emphasis,fontStyle:"italic"},{tag:vt.strong,fontWeight:"bold"},{tag:vt.strikethrough,textDecoration:"line-through"},{tag:vt.keyword,color:"#708"},{tag:[vt.atom,vt.bool,vt.url,vt.contentSeparator,vt.labelName],color:"#219"},{tag:[vt.literal,vt.inserted],color:"#164"},{tag:[vt.string,vt.deleted],color:"#a11"},{tag:[vt.regexp,vt.escape,vt.special(vt.string)],color:"#e40"},{tag:vt.definition(vt.variableName),color:"#00f"},{tag:vt.local(vt.variableName),color:"#30a"},{tag:[vt.typeName,vt.namespace],color:"#085"},{tag:vt.className,color:"#167"},{tag:[vt.special(vt.variableName),vt.macroName],color:"#256"},{tag:vt.definition(vt.propertyName),color:"#00c"},{tag:vt.comment,color:"#940"},{tag:vt.invalid,color:"#f00"}]),Fe=u.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ve="()[]{}",qe=t.define({combine:t=>o(t,{afterCursor:!0,brackets:Ve,maxScanDistance:1e4,renderMatch:Ge})}),$e=c.mark({class:"cm-matchingBracket"}),He=c.mark({class:"cm-nonmatchingBracket"});functionGe(t){lete=[],r=t.matched?$e:He;returne.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}constJe=[n.define({create:()=>c.none,update(t,e){if(!e.docChanged&&!e.selection)returnt;letr=[],n=e.state.facet(qe);for(lettofe.state.selection.ranges){if(!t.empty)continue;leti=Ze(e.state,t.head,-1,n)||t.head>0&&Ze(e.state,t.head-1,1,n)||n.afterCursor&&(Ze(e.state,t.head,1,n)||t.head<e.state.doc.length&&Ze(e.state,t.head+1,-1,n));i&&(r=r.concat(n.renderMatch(i,e.state)))}returnc.set(r,!0)},provide:t=>u.decorations.from(t)}),Fe];functionKe(t={}){return[qe.of(t),Je]}constQe=neww;functionXe(t,e,r){letn=t.prop(e<0?w.openedBy:w.closedBy);if(n)returnn;if(1==t.name.length){letn=r.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[r[n+e]]}returnnull}functionYe(t){lete=t.type.prop(Qe);returne?e(t.node):t}functionZe(t,e,r,n={}){leti=n.maxScanDistance||1e4,s=n.brackets||Ve,o=Ot(t),l=o.resolveInner(e,r);for(letn=l;n;n=n.parent){leti=Xe(n.type,r,s);if(i&&n.from<n.to){leto=Ye(n);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))returntr(t,e,r,n,o,i,s)}}returnfunction(t,e,r,n,i,s,o){letl=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=r>0)returnnull;leth={from:r<0?e-1:e,to:r>0?e+1:e},f=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(lett=0;!f.next().done&&t<=s;){lets=f.value;r<0&&(t+=s.length);letl=e+t*r;for(lett=r>0?0:s.length-1,e=r>0?s.length:-1;t!=e;t+=r){lete=o.indexOf(s[t]);if(!(e<0||n.resolveInner(l+t,1).type!=i))if(e%2==0==r>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}r>0&&(t+=s.length)}returnf.done?{start:h,matched:!1}:null}(t,e,r,o,l.type,i,s)}functiontr(t,e,r,n,i,s,o){letl=n.parent,a={from:i.from,to:i.to},h=0,f=null==l?void0:l.cursor();if(f&&(r<0?f.childBefore(n.from):f.childAfter(n.to)))do{if(r<0?f.to<=n.from:f.from>=n.to){if(0==h&&s.indexOf(f.type.name)>-1&&f.from<f.to){lett=Ye(f);return{start:a,end:t?{from:t.from,to:t.to}:void0,matched:!0}}if(Xe(f.type,r,o))h++;elseif(Xe(f.type,-r,o)){if(0==h){lett=Ye(f);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void0,matched:!1}}h--}}}while(r<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}functioner(t,e,r,n=0,i=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);lets=i;for(leti=n;i<e;i++)9==t.charCodeAt(i)?s+=r-s%r:s++;returns}classrr{constructor(t,e,r,n){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){returnthis.pos>=this.string.length}sol(){return0==this.pos}peek(){returnthis.string.charAt(this.pos)||void0}next(){if(this.pos<this.string.length)returnthis.string.charAt(this.pos++)}eat(t){lete,r=this.string.charAt(this.pos);if(e="string"==typeoft?r==t:r&&(tinstanceofRegExp?t.test(r):t(r)),e)return++this.pos,r}eatWhile(t){lete=this.pos;for(;this.eat(t););returnthis.pos>e}eatSpace(){lett=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;returnthis.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){lete=this.string.indexOf(t,this.pos);if(e>-1)returnthis.pos=e,!0}backUp(t){this.pos-=t}column(){returnthis.lastColumnPos<this.start&&(this.lastColumnValue=er(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){vart;returnnull!==(t=this.overrideIndent)&&void0!==t?t:er(this.string,null,this.tabSize)}match(t,e,r){if("string"==typeoft){letn=t=>r?t.toLowerCase():t;returnn(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{letr=this.string.slice(this.pos).match(t);returnr&&r.index>0?null:(r&&!1!==e&&(this.pos+=r[0].length),r)}}current(){returnthis.string.slice(this.start,this.pos)}}functionnr(t){if("object"!=typeoft)returnt;lete={};for(letrint){letn=t[r];e[r]=ninstanceofArray?n.slice():n}returne}constir=newWeakMap;classsrextendsPt{constructor(t){lete,r=Ct(t.languageData),n={name:(i=t).name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||nr,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||fr};vari;super(r,newclassextendsK{createParse(t,r,n){returnnewar(e,t,r,n)}},[Vt.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){lete=A.define({id:ur.length,name:"Document",props:[At.add((()=>t))],top:!0});returnur.push(e),e}(r),e=this,this.streamParser=n,this.stateAfter=neww({perNode:!0}),this.tokenTable=t.tokenTable?newmr(n.tokenTable):br}staticdefine(t){returnnewsr(t)}getIndent(t,e){letr,n=Ot(t.state),i=n.resolve(e);for(;i&&i.type!=this.topNode;)i=i.parent;if(!i)returnnull;let{overrideIndentation:s}=t.options;s&&(r=ir.get(t.state),null!=r&&r<e-1e4&&(r=void0));leto,l,a=or(this,n,0,i.from,null!=r?r:e);if(a?(l=a.state,o=a.pos+1):(l=this.streamParser.startState(t.unit),o=0),e-o>1e4)returnnull;for(;o<e;){letr=t.state.doc.lineAt(o),n=Math.min(e,r.to);if(r.length){lete=s?s(r.from):-1,i=newrr(r.text,t.state.tabSize,t.unit,e<0?void0:e);for(;i.pos<n-r.from;)hr(this.streamParser.token,i,l)}elsethis.streamParser.blankLine(l,t.unit);if(n==e)break;o=r.to+1}leth=t.lineAt(e);returns&&null==r&&ir.set(t.state,h.from),this.streamParser.indent(l,/^\s*(.*)/.exec(h.text)[1],t)}getallowsNesting(){return!1}}functionor(t,e,r,n,i){lets=r>=n&&r+e.length<=i&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:r+e.length};for(lets=e.children.length-1;s>=0;s--){leto=e.children[s],l=r+e.positions[s],a=oinstanceofT&&l<i&&or(t,o,l,n,i);if(a)returna}returnnull}functionlr(t,e,r,n,i){if(i&&r<=0&&n>=e.length)returne;i||e.type!=t.topNode||(i=!0);for(lets=e.children.length-1;s>=0;s--){leto,l=e.positions[s],a=e.children[s];if(l<n&&ainstanceofT){if(!(o=lr(t,a,r-l,n-l,i)))break;returni?newT(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),l+o.length):o}}returnnull}classar{constructor(t,e,r,n){this.lang=t,this.input=e,this.fragments=r,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void0,this.rangeIndex=0,this.to=n[n.length-1].to;leti=Dt.get(),s=n[0].from,{state:o,tree:l}=function(t,e,r,n){for(letnofe){lete,i=n.from+(n.openStart?25:0),s=n.to-(n.openEnd?25:0),o=i<=r&&s>r&&or(t,n.tree,0-n.offset,r,s);if(o&&(e=lr(t,n.tree,r+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?$t(n):4),tree:T.empty}}(t,r,s,null==i?void0:i.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(lett=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);i&&this.parsedPos<i.viewport.from-1e5&&(this.state=this.lang.streamParser.startState($t(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){lett=Dt.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);returnthis.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){lete=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{lett=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}returnt+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){lett=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(lett=this.rangeIndex;;){letn=this.ranges[t].to;if(n>=r)break;if(e=e.slice(0,n-(r-e.length)),t++,t==this.ranges.length)break;leti=this.ranges[t].from,s=this.lineAfter(i);e+=s,r=i+s.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){letn=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?n>i:n>=i)break;e+=this.ranges[++this.rangeIndex].from-n}returne}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,r,n,i){if(this.ranges.length>1){e+=i=this.skipGapsTo(e,i,1);lett=this.chunk.length;r+=i=this.skipGapsTo(r,i,-1),n+=this.chunk.length-t}returnthis.chunk.push(t,e,r,n),i}parseLine(t){let{line:e,end:r}=this.nextLine(),n=0,{streamParser:i}=this.lang,s=newrr(e,t?t.state.tabSize:4,t?$t(t.state):2);if(s.eol())i.blankLine(this.state,s.indentUnit);elsefor(;!s.eol();){lett=hr(i.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){lett=T.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:cr,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=newT(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void0,this.chunkStart=this.parsedPos}finish(){returnnewT(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}functionhr(t,e,r){e.start=e.pos;for(letn=0;n<10;n++){letn=t(e,r);if(e.pos>e.start)returnn}thrownewError("Stream parser failed to advance stream.")}constfr=Object.create(null),ur=[A.none],cr=newC(ur),dr=[],pr=Object.create(null),gr=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])gr[t]=kr(fr,e);classmr{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),gr)}resolve(t){returnt?this.table[t]||(this.table[t]=kr(this.extra,t)):0}}constbr=newmr(fr);functionxr(t,e){dr.indexOf(t)>-1||(dr.push(t),console.warn(e))}functionkr(t,e){letr=[];for(letnofe.split("")){lete=[];for(letrofn.split(".")){letn=t[r]||vt[r];n?"function"==typeofn?e.length?e=e.map(n):xr(r,`Modifier ${r} used at start of tag`):e.length?xr(r,`Tag ${r} used as modifier`):e=Array.isArray(n)?n:[n]:xr(r,`Unknown highlighting tag ${r}`)}for(lettofe)r.push(t)}if(!r.length)return0;letn=e.replace(/ /g,"_"),i=n+""+r.map((t=>t.id)),s=pr[i];if(s)returns.id;leto=pr[i]=A.define({id:ur.length,name:n,props:[et({[n]:r})]});returnur.push(o),o.id}functionyr(t){returnt.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}functionwr(t){for(lete=t.iter();!e.next().done;)if(yr(e.value))return!0;return!1}constvr=t.define({combine:t=>t.some((t=>t))});constSr=h.fromClass(class{constructor(t){this.always=t.state.facet(vr)||t.textDirection!=g.LTR||t.state.facet(u.perLineTextDirection),this.hasRTL=!this.always&&wr(t.state.doc),this.tree=Ot(t.state),this.decorations=this.always||this.hasRTL?Ar(t,this.tree,this.always):c.none}update(t){lete=t.state.facet(vr)||t.view.textDirection!=g.LTR||t.state.facet(u.perLineTextDirection);if(e||this.hasRTL||!function(t){lete=!1;returnt.iterChanges(((t,r,n,i,s)=>{!e&&wr(s)&&(e=!0)})),e}(t.changes)||(this.hasRTL=!0),!e&&!this.hasRTL)return;letr=Ot(t.state);(e!=this.always||r!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=r,this.always=e,this.decorations=Ar(t.view,r,e))}},{provide:t=>{functione(e){varr,n;returnnull!==(n=null===(r=e.plugin(t))||void0===r?void0:r.decorations)&&void0!==n?n:c.none}return[u.outerDecorations.of(e),l.lowest(u.bidiIsolatedRanges.of(e))]}});functionAr(t,e,r){letn=newa,i=t.visibleRanges;r||(i=function(t,e){letr=e.iter(),n=0,i=[],s=null;for(let{from:e,to:o}oft)for(e!=n&&(n<e&&r.next(e-n),n=e);;){lett=n,e=n+r.value.length;if(!r.lineBreak&&yr(r.value)&&(s&&s.to>t-10?s.to=Math.min(o,e):i.push(s={from:t,to:Math.min(o,e)})),n>=o)break;n=e,r.next()}returni}(i,t.state.doc));for(let{from:t,to:r}ofi)e.iterate({enter:t=>{lete=t.type.prop(w.isolate);e&&n.add(t.from,t.to,Cr[e])},from:t,to:r});returnn.finish()}constCr={rtl:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:g.RTL}),ltr:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:g.LTR}),auto:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};varNr=Object.freeze({__proto__:null,DocInput:_t,HighlightStyle:De,IndentContext:Jt,LRLanguage:Tt,Language:Pt,LanguageDescription:Ft,LanguageSupport:Ut,ParseContext:Dt,StreamLanguage:sr,StringStream:rr,TreeIndentContext:Zt,bidiIsolates:function(t={}){lete=[Sr];returnt.alwaysIsolate&&e.push(vr.of(!0)),e},bracketMatching:Ke,bracketMatchingHandle:Qe,codeFolding:Ne,continuedIndent:function({except:t,units:e=1}={}){returnr=>{letn=t&&t.test(r.textAfter);returnr.baseIndent+(n?0:e*r.unit)}},defaultHighlightStyle:Ue,defineLanguageFacet:Ct,delimitedIndent:ee,ensureSyntaxTree:Bt,flatIndent:t=>t.baseIndent,foldAll:ye,foldCode:be,foldEffect:fe,foldGutter:_e,foldInside:oe,foldKeymap:Se,foldNodeProp:se,foldService:ie,foldState:de,foldable:ae,foldedRanges:function(t){returnt.field(de,!1)||s.empty},forceParsing:function(t,e=t.viewport.to,r=100){letn=Bt(t.state,e,r);returnn!=Ot(t.state)&&t.dispatch({}),!!n},getIndentUnit:$t,getIndentation:Gt,highlightingFor:function(t,e,r){letn=Re(t),i=null;if(n)for(lettofn)if(!t.scope||r&&t.scope(r)){letr=t.style(e);r&&(i=i?i+""+r:r)}returni},indentNodeProp:Kt,indentOnInput:ne,indentRange:function(t,e,r){letn=Object.create(null),i=newJt(t,{overrideIndentation:t=>{vare;returnnull!==(e=n[t])&&void0!==e?e:-1}}),s=[];for(leto=e;o<=r;){lete=t.doc.lineAt(o);o=e.to+1;letr=Gt(i,e.from);if(null==r)continue;/\S/.test(e.text)||(r=0);letl=/^\s*/.exec(e.text)[0],a=Ht(t,r);l!=a&&(n[e.from]=r,s.push({from:e.from,to:e.from+l.length,insert:a}))}returnt.changes(s)},indentService:Vt,indentString:Ht,indentUnit:qt,language:Wt,languageDataProp:At,matchBrackets:Ze,sublanguageProp:Nt,syntaxHighlighting:ze,syntaxParserRunning:function(t){vare;return(null===(e=t.plugin(jt))||void0===e?void0:e.isWorking())||!1},syntaxTree:Ot,syntaxTreeAvailable:function(t,e=t.doc.length){varr;return(null===(r=t.field(Pt.state,!1))||void0===r?void0:r.context.isDone(e))||!1},toggleFold:t=>{lete=[];for(letrofce(t)){letn=pe(t.state,r.from,r.to);if(n)e.push(ue.of(n),ke(t,n,!1));else{letn=ve(t,r);n&&e.push(fe.of(n),ke(t,n))}}returne.length>0&&t.dispatch({effects:me(t.state,e)}),!!e.length},unfoldAll:we,unfoldCode:xe,unfoldEffect:ue});export{xasD,I,TtasL,CasN,KasP,T,Aasa,wasb,etasc,Ktasd,eease,seasf,oeasg,Utash,qtasi,Gasj,_eask,neasl,zeasm,Ueasn,Keaso,Seasp,Jtasq,Gtasr,Otass,vtast,Htasu,Zeasv,$tasw,Nrasx};//# sourceMappingURL=codemirror_language-_XiX6II0.js.map