summaryrefslogtreecommitdiff
path: root/assets/cm/chunk-JULZPKSW.js
diff options
context:
space:
mode:
authorHizbu Azka <hanifan.azka@gmail.com>2026-10-21 14:31:59 +0700
committerHizbu Azka <hanifan.azka@gmail.com>2026-10-21 15:11:13 +0700
commit976c0d950461ab884a9d107659d3ba103d8cb269 (patch)
treee86016b3d1c966fb3c11f16c52b99f0de56a5b94 /assets/cm/chunk-JULZPKSW.js
parent8ad5216903950b5e3785b3729068ca48bd5232e0 (diff)
selfhost cm, add dark theme
Diffstat (limited to 'assets/cm/chunk-JULZPKSW.js')
-rw-r--r--assets/cm/chunk-JULZPKSW.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/assets/cm/chunk-JULZPKSW.js b/assets/cm/chunk-JULZPKSW.js
new file mode 100644
index 0000000..1ee907f
--- /dev/null
+++ b/assets/cm/chunk-JULZPKSW.js
@@ -0,0 +1,3 @@
+import{O as Et,R as Rt,a as et,b as tt,d as R,f as ke,h as Dt,i as ce,l as F}from"./chunk-I3OVNVKL.js";import{A as Re,B as Ot,l as W,m as Qe,n as Xe,s as me,v as ue,w as Ye,z as Ze}from"./chunk-7PWEZHZB.js";function _t(r,e,t,n=0,i=0){e==null&&(e=r.search(/[^\s\u00a0]/),e==-1&&(e=r.length));let s=i;for(let l=n;l<e;l++)r.charCodeAt(l)==9?s+=t-s%t:s++;return s}var de=class{constructor(e,t,n,i){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=_t(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:_t(this.string,null,this.tabSize)}match(e,t,n){if(typeof e=="string"){let i=l=>n?l.toLowerCase():l,s=this.string.substr(this.pos,e.length);return i(s)==i(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&t!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}};var In=0,be=class{constructor(e,t){this.from=e,this.to=t}},k=class{constructor(e={}){this.id=In++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=_.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};k.closedBy=new k({deserialize:r=>r.split(" ")});k.openedBy=new k({deserialize:r=>r.split(" ")});k.group=new k({deserialize:r=>r.split(" ")});k.isolate=new k({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});k.contextHash=new k({perNode:!0});k.lookAhead=new k({perNode:!0});k.mounted=new k({perNode:!0});var se=class{constructor(e,t,n,i=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=i}static get(e){return e&&e.props&&e.props[k.mounted.id]}},Bn=Object.create(null),_=class r{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):Bn,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new r(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),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 i}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(k.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return n=>{for(let i=n.prop(k.group),s=-1;s<(i?i.length:0);s++){let l=t[s<0?n.name:i[s]];if(l)return l}}}};_.none=new _("",Object.create(null),0,8);var Fe=class r{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let s of e){let l=s(n);if(l){i||(i=Object.assign({},n.props));let o=l[1],a=l[0];a.combine&&a.id in i&&(o=a.combine(i[a.id],o)),i[a.id]=o}}t.push(i?new _(n.name,i,n.id,n.flags):n)}return new r(t)}},_e=new WeakMap,Lt=new WeakMap,I;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(I||(I={}));var A=class r{constructor(e,t,n,i,s){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[l,o]of s)this.props[typeof l=="number"?l:l.id]=o}}toString(){let e=se.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let i=n.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new we(this.topNode,e)}cursorAt(e,t=0,n=0){let i=_e.get(this)||this.topNode,s=new we(i);return s.moveTo(e,t),_e.set(this,s._tree),s}get topNode(){return new q(this,0,0,null)}resolve(e,t=0){let n=ye(_e.get(this)||this.topNode,e,t,!1);return _e.set(this,n),n}resolveInner(e,t=0){let n=ye(Lt.get(this)||this.topNode,e,t,!0);return Lt.set(this,n),n}resolveStack(e,t=0){return Mn(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:s=this.length}=e,l=e.mode||0,o=(l&I.IncludeAnonymous)>0;for(let a=this.cursor(l|I.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=i&&(!o&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(o||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!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:at(_.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,i)=>new r(this.type,t,n,i,this.propValues),e.makeTree||((t,n,i)=>new r(_.none,t,n,i)))}static build(e){return On(e)}};A.empty=new A(_.none,[],[],0);var nt=class r{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 r(this.buffer,this.index)}},Y=class r{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return _.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let l=[];for(;e<n;)l.push(this.childString(e)),e=this.buffer[e+3];return s+"("+l.join(",")+")"}findChild(e,t,n,i,s){let{buffer:l}=this,o=-1;for(let a=e;a!=t&&!(jt(s,i,l[a+1],l[a+2])&&(o=a,n>0));a=l[a+3]);return o}slice(e,t,n){let i=this.buffer,s=new Uint16Array(t-e),l=0;for(let o=e,a=0;o<t;){s[a++]=i[o++],s[a++]=i[o++]-n;let h=s[a++]=i[o++]-n;s[a++]=i[o++]-e,l=Math.max(l,h)}return new r(s,l,this.set)}};function jt(r,e,t,n){switch(r){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function ye(r,e,t,n){for(var i;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let l=!n&&r instanceof q&&r.index<0?null:r.parent;if(!l)return r;r=l}let s=n?0:I.IgnoreOverlays;if(n)for(let l=r,o=l.parent;o;l=o,o=l.parent)l instanceof q&&l.index<0&&((i=o.enter(e,t,s))===null||i===void 0?void 0:i.from)!=l.from&&(r=o);for(;;){let l=r.enter(e,t,s);if(!l)return r;r=l}}var ze=class{cursor(e=0){return new we(this,e)}getChild(e,t=null,n=null){let i=Ft(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return Ft(this,e,t,n)}resolve(e,t=0){return ye(this,e,t,!1)}resolveInner(e,t=0){return ye(this,e,t,!0)}matchContext(e){return rt(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}get node(){return this}get next(){return this.parent}},q=class r extends ze{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,s=0){for(let l=this;;){for(let{children:o,positions:a}=l._tree,h=t>0?o.length:-1;e!=h;e+=t){let f=o[e],d=a[e]+l.from,g;if(!(!(s&I.EnterBracketed&&f instanceof A&&(g=se.get(f))&&!g.overlay&&g.bracketed&&n>=d&&n<=d+f.length)&&!jt(i,n,d,d+f.length))){if(f instanceof Y){if(s&I.ExcludeBuffers)continue;let b=f.findChild(0,f.buffer.length,t,n-d,i);if(b>-1)return new xe(new it(l,f,e,d),null,b)}else if(s&I.IncludeAnonymous||!f.type.isAnonymous||ot(f)){let b;if(!(s&I.IgnoreMounts)&&(b=se.get(f))&&!b.overlay)return new r(b.tree,d,e,l);let w=new r(f,d,e,l);return s&I.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?f.children.length-1:0,t,n,i,s)}}}if(s&I.IncludeAnonymous||!l.type.isAnonymous||(l.index>=0?e=l.index+t:e=t<0?-1:l._parent._tree.children.length,l=l._parent,!l))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)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let i;if(!(n&I.IgnoreOverlays)&&(i=se.get(this._tree))&&i.overlay){let s=e-this.from,l=n&I.EnterBracketed&&i.bracketed;for(let{from:o,to:a}of i.overlay)if((t>0||l?o<=s:o<s)&&(t<0||l?a>=s:a>s))return new r(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 Ft(r,e,t,n){let i=r.cursor(),s=[];if(!i.firstChild())return s;if(t!=null){for(let l=!1;!l;)if(l=i.type.is(t),!i.nextSibling())return s}for(;;){if(n!=null&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return n==null?s:[]}}function rt(r,e,t=e.length-1){for(let n=r;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var it=class{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}},xe=class r extends ze{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,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new r(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)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&I.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new r(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 r(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 r(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,s=n.buffer[this.index+3];if(s>i){let l=n.buffer[this.index+1];e.push(n.slice(i,s,l)),t.push(0)}return new A(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ut(r){if(!r.length)return null;let e=0,t=r[0];for(let s=1;s<r.length;s++){let l=r[s];(l.from>t.from||l.to<t.to)&&(t=l,e=s)}let n=t instanceof q&&t.index<0?null:t.parent,i=r.slice();return n?i[e]=n:i.splice(e,1),new st(i,t)}var st=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ut(this.heads)}};function Mn(r,e,t){let n=r.resolveInner(e,t),i=null;for(let s=n instanceof q?n:n.context.parent;s;s=s.parent)if(s.index<0){let l=s.parent;(i||(i=[n])).push(l.resolve(e,t)),s=l}else{let l=se.get(s.tree);if(l&&l.overlay&&l.overlay[0].from<=e&&l.overlay[l.overlay.length-1].to>=e){let o=new q(l.tree,l.overlay[0].from+s.from,-1,s);(i||(i=[n])).push(ye(o,e,t,!1))}}return i?Ut(i):n}var we=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~I.EnterBracketed,e instanceof q)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return e?e instanceof q?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);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,n=this.mode){return this.buffer?n&I.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&I.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&I.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,n=this.stack.length-1;if(e<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<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,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,l=e<0?-1:n._tree.children.length;s!=l;s+=e){let o=n._tree.children[s];if(this.mode&I.IncludeAnonymous||o instanceof Y||!o.type.isAnonymous||ot(o))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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let l=e;l;l=l._parent)if(l.index==i){if(i==this.index)return l;t=l,n=s+1;break e}i=this.stack[--s]}for(let i=n;i<this.stack.length;i++)t=new xe(this.buffer,t,this.stack[i]);return this.bufferNode=new xe(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return rt(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return rt(this._tree,e,i);let l=n[t.buffer[this.stack[s]]];if(!l.isAnonymous){if(e[i]&&e[i]!=l.name)return!1;i--}}return!0}};function ot(r){return r.children.some(e=>e instanceof Y||!e.type.isAnonymous||ot(e))}function On(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:i=1024,reused:s=[],minRepeatType:l=n.types.length}=r,o=Array.isArray(t)?new nt(t,t.length):t,a=n.types,h=0,f=0;function d(x,C,p,P,v,N){let{id:y,start:m,end:S,size:T}=o,O=f,X=h;if(T<0)if(o.next(),T==-1){let Q=s[y];p.push(Q),P.push(m-x);return}else if(T==-3){h=y;return}else if(T==-4){f=y;return}else throw new RangeError(`Unrecognized record size: ${T}`);let ge=a[y],De,re,Bt=m-x;if(S-m<=i&&(re=j(o.pos-C,v))){let Q=new Uint16Array(re.size-re.skip),U=o.pos-re.size,$=Q.length;for(;o.pos>U;)$=E(re.start,Q,$);De=new Y(Q,S-re.start,n),Bt=re.start-x}else{let Q=o.pos-T;o.next();let U=[],$=[],ie=y>=l?y:-1,fe=0,Ee=S;for(;o.pos>Q;)ie>=0&&o.id==ie&&o.size>=0?(o.end<=Ee-i&&(w(U,$,m,fe,o.end,Ee,ie,O,X),fe=U.length,Ee=o.end),o.next()):N>2500?g(m,Q,U,$):d(m,Q,U,$,ie,N+1);if(ie>=0&&fe>0&&fe<U.length&&w(U,$,m,fe,m,Ee,ie,O,X),U.reverse(),$.reverse(),ie>-1&&fe>0){let Mt=b(ge,X);De=at(ge,U,$,0,U.length,0,S-m,Mt,Mt)}else De=M(ge,U,$,S-m,O-S,X)}p.push(De),P.push(Bt)}function g(x,C,p,P){let v=[],N=0,y=-1;for(;o.pos>C;){let{id:m,start:S,end:T,size:O}=o;if(O>4)o.next();else{if(y>-1&&S<y)break;y<0&&(y=T-i),v.push(m,S,T),N++,o.next()}}if(N){let m=new Uint16Array(N*4),S=v[v.length-2];for(let T=v.length-3,O=0;T>=0;T-=3)m[O++]=v[T],m[O++]=v[T+1]-S,m[O++]=v[T+2]-S,m[O++]=O;p.push(new Y(m,v[2]-S,n)),P.push(S-x)}}function b(x,C){return(p,P,v)=>{let N=0,y=p.length-1,m,S;if(y>=0&&(m=p[y])instanceof A){if(!y&&m.type==x&&m.length==v)return m;(S=m.prop(k.lookAhead))&&(N=P[y]+m.length+S)}return M(x,p,P,v,N,C)}}function w(x,C,p,P,v,N,y,m,S){let T=[],O=[];for(;x.length>P;)T.push(x.pop()),O.push(C.pop()+p-v);x.push(M(n.types[y],T,O,N-v,m-N,S)),C.push(v-p)}function M(x,C,p,P,v,N,y){if(N){let m=[k.contextHash,N];y=y?[m].concat(y):[m]}if(v>25){let m=[k.lookAhead,v];y=y?[m].concat(y):[m]}return new A(x,C,p,P,y)}function j(x,C){let p=o.fork(),P=0,v=0,N=0,y=p.end-i,m={size:0,start:0,skip:0};e:for(let S=p.pos-x;p.pos>S;){let T=p.size;if(p.id==C&&T>=0){m.size=P,m.start=v,m.skip=N,N+=4,P+=4,p.next();continue}let O=p.pos-T;if(T<0||O<S||p.start<y)break;let X=p.id>=l?4:0,ge=p.start;for(p.next();p.pos>O;){if(p.size<0)if(p.size==-3||p.size==-4)X+=4;else break e;else p.id>=l&&(X+=4);p.next()}v=ge,P+=T,N+=X}return(C<0||P==x)&&(m.size=P,m.start=v,m.skip=N),m.size>4?m:void 0}function E(x,C,p){let{id:P,start:v,end:N,size:y}=o;if(o.next(),y>=0&&P<l){let m=p;if(y>4){let S=o.pos-(y-4);for(;o.pos>S;)p=E(x,C,p)}C[--p]=m,C[--p]=N-x,C[--p]=v-x,C[--p]=P}else y==-3?h=P:y==-4&&(f=P);return p}let L=[],B=[];for(;o.pos>0;)d(r.start||0,r.bufferStart||0,L,B,-1,0);let V=(e=r.length)!==null&&e!==void 0?e:L.length?B[0]+L[0].length:0;return new A(a[r.topID],L.reverse(),B.reverse(),V)}var zt=new WeakMap;function Le(r,e){if(!r.isAnonymous||e instanceof Y||e.type!=r)return 1;let t=zt.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof A)){t=1;break}t+=Le(r,n)}zt.set(e,t)}return t}function at(r,e,t,n,i,s,l,o,a){let h=0;for(let w=n;w<i;w++)h+=Le(r,e[w]);let f=Math.ceil(h*1.5/8),d=[],g=[];function b(w,M,j,E,L){for(let B=j;B<E;){let V=B,x=M[B],C=Le(r,w[B]);for(B++;B<E;B++){let p=Le(r,w[B]);if(C+p>=f)break;C+=p}if(B==V+1){if(C>f){let p=w[V];b(p.children,p.positions,0,p.children.length,M[V]+L);continue}d.push(w[V])}else{let p=M[B-1]+w[B-1].length-x;d.push(at(r,w,M,V,B,x,p,null,a))}g.push(x+L-s)}}return b(e,t,n,i,0),(o||a)(d,g,l)}var le=class r{constructor(e,t,n,i,s=!1,l=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(s?1:0)|(l?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let i=[new r(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&i.push(s);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],s=1,l=e.length?e[0]:null;for(let o=0,a=0,h=0;;o++){let f=o<t.length?t[o]:null,d=f?f.fromA:1e9;if(d-a>=n)for(;l&&l.from<d;){let g=l;if(a>=g.from||d<=g.to||h){let b=Math.max(g.from,a)-h,w=Math.min(g.to,d)-h;g=b>=w?null:new r(b,w,g.tree,g.offset+h,o>0,!!f)}if(g&&i.push(g),l.to>d)break;l=s<e.length?e[s++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return i}},ve=class{startParse(e,t,n){return typeof e=="string"&&(e=new lt(e)),n=n?n.length?n.map(i=>new be(i.from,i.to)):[new be(0,0)]:[new be(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let s=i.advance();if(s)return s}}},lt=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 Ir=new k({perNode:!0});var Dn=0,H=class r{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=Dn++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof r&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let i=new r(n,[],null,[]);if(i.set.push(i),t)for(let s of t.set)i.set.push(s);return i}static defineModifier(e){let t=new He(e);return n=>n.modified.indexOf(t)>-1?n:He.get(n.base||n,n.modified.concat(t).sort((i,s)=>i.id-s.id))}},En=0,He=class r{constructor(e){this.name=e,this.instances=[],this.id=En++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(o=>o.base==e&&Rn(t,o.modified));if(n)return n;let i=[],s=new H(e.name,i,e,t);for(let o of t)o.instances.push(s);let l=_n(t);for(let o of e.set)if(!o.modified.length)for(let a of l)i.push(r.get(o,a));return s}};function Rn(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function _n(r){let e=[[]];for(let t=0;t<r.length;t++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(r[t]));return e.sort((t,n)=>n.length-t.length)}function Vt(r){let e=Object.create(null);for(let t in r){let n=r[t];Array.isArray(n)||(n=[n]);for(let i of t.split(" "))if(i){let s=[],l=2,o=i;for(let d=0;;){if(o=="..."&&d>0&&d+3==i.length){l=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!g)throw new RangeError("Invalid path: "+i);if(s.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),d+=g[0].length,d==i.length)break;let b=i[d++];if(d==i.length&&b=="!"){l=0;break}if(b!="/")throw new RangeError("Invalid path: "+i);o=i.slice(d)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+i);let f=new ae(n,l,a>0?s.slice(0,a):null);e[h]=f.sort(e[h])}}return $t.add(e)}var $t=new k({combine(r,e){let t,n,i;for(;r||e;){if(!r||e&&r.depth<=e.depth?(i=e,e=e.next):(i=r,r=r.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let s=new ae(i.tags,i.mode,i.context);t?t.next=s:n=s,t=s}return n}}),ae=class{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};ae.empty=new ae([],2,null);function ct(r,e){let t=Object.create(null);for(let s of r)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let l of s.tag)t[l.id]=s.class;let{scope:n,all:i=null}=e||{};return{style:s=>{let l=i;for(let o of s)for(let a of o.set){let h=t[a.id];if(h){l=l?l+" "+h:h;break}}return l},scope:n}}function Ln(r,e){let t=null;for(let n of r){let i=n.style(e);i&&(t=t?t+" "+i:i)}return t}function qt(r,e,t,n=0,i=r.length){let s=new ft(n,Array.isArray(e)?e:[e],t);s.highlightRange(r.cursor(),n,i,"",s.highlighters),s.flush(i)}var ft=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,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,n,i,s){let{type:l,from:o,to:a}=e;if(o>=n||a<=t)return;l.isTop&&(s=this.highlighters.filter(b=>!b.scope||b.scope(l)));let h=i,f=Fn(e)||ae.empty,d=Ln(s,f.tags);if(d&&(h&&(h+=" "),h+=d,f.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(t,o),h),f.opaque)return;let g=e.tree&&e.tree.prop(k.mounted);if(g&&g.overlay){let b=e.node.enter(g.overlay[0].from+o,1),w=this.highlighters.filter(j=>!j.scope||j.scope(g.tree.type)),M=e.firstChild();for(let j=0,E=o;;j++){let L=j<g.overlay.length?g.overlay[j]:null,B=L?L.from+o:a,V=Math.max(t,E),x=Math.min(n,B);if(V<x&&M)for(;e.from<x&&(this.highlightRange(e,V,x,i,s),this.startSpan(Math.min(x,e.to),h),!(e.to>=B||!e.nextSibling())););if(!L||B>n)break;E=L.to+o,E>t&&(this.highlightRange(b.cursor(),Math.max(t,L.from+o),Math.min(n,E),"",w),this.startSpan(Math.min(n,E),h))}M&&e.parent()}else if(e.firstChild()){g&&(i="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}};function Fn(r){let e=r.type.prop($t);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var u=H.define,je=u(),Z=u(),Wt=u(Z),Ht=u(Z),ee=u(),Ue=u(ee),ht=u(ee),K=u(),oe=u(K),G=u(),J=u(),ut=u(),Se=u(ut),We=u(),c={comment:je,lineComment:u(je),blockComment:u(je),docComment:u(je),name:Z,variableName:u(Z),typeName:Wt,tagName:u(Wt),propertyName:Ht,attributeName:u(Ht),className:u(Z),labelName:u(Z),namespace:u(Z),macroName:u(Z),literal:ee,string:Ue,docString:u(Ue),character:u(Ue),attributeValue:u(Ue),number:ht,integer:u(ht),float:u(ht),bool:u(ee),regexp:u(ee),escape:u(ee),color:u(ee),url:u(ee),keyword:G,self:u(G),null:u(G),atom:u(G),unit:u(G),modifier:u(G),operatorKeyword:u(G),controlKeyword:u(G),definitionKeyword:u(G),moduleKeyword:u(G),operator:J,derefOperator:u(J),arithmeticOperator:u(J),logicOperator:u(J),bitwiseOperator:u(J),compareOperator:u(J),updateOperator:u(J),definitionOperator:u(J),typeOperator:u(J),controlOperator:u(J),punctuation:ut,separator:u(ut),bracket:Se,angleBracket:u(Se),squareBracket:u(Se),paren:u(Se),brace:u(Se),content:K,heading:oe,heading1:u(oe),heading2:u(oe),heading3:u(oe),heading4:u(oe),heading5:u(oe),heading6:u(oe),contentSeparator:u(K),list:u(K),quote:u(K),emphasis:u(K),strong:u(K),link:u(K),monospace:u(K),strikethrough:u(K),inserted:u(),deleted:u(),changed:u(),invalid:u(),meta:We,documentMeta:u(We),annotation:u(We),processingInstruction:u(We),definition:H.defineModifier("definition"),constant:H.defineModifier("constant"),function:H.defineModifier("function"),standard:H.defineModifier("standard"),local:H.defineModifier("local"),special:H.defineModifier("special")};for(let r in c){let e=c[r];e instanceof H&&(e.name=r)}var Or=ct([{tag:c.link,class:"tok-link"},{tag:c.heading,class:"tok-heading"},{tag:c.emphasis,class:"tok-emphasis"},{tag:c.strong,class:"tok-strong"},{tag:c.keyword,class:"tok-keyword"},{tag:c.atom,class:"tok-atom"},{tag:c.bool,class:"tok-bool"},{tag:c.url,class:"tok-url"},{tag:c.labelName,class:"tok-labelName"},{tag:c.inserted,class:"tok-inserted"},{tag:c.deleted,class:"tok-deleted"},{tag:c.literal,class:"tok-literal"},{tag:c.string,class:"tok-string"},{tag:c.number,class:"tok-number"},{tag:[c.regexp,c.escape,c.special(c.string)],class:"tok-string2"},{tag:c.variableName,class:"tok-variableName"},{tag:c.local(c.variableName),class:"tok-variableName tok-local"},{tag:c.definition(c.variableName),class:"tok-variableName tok-definition"},{tag:c.special(c.variableName),class:"tok-variableName2"},{tag:c.definition(c.propertyName),class:"tok-propertyName tok-definition"},{tag:c.typeName,class:"tok-typeName"},{tag:c.namespace,class:"tok-namespace"},{tag:c.className,class:"tok-className"},{tag:c.macroName,class:"tok-macroName"},{tag:c.propertyName,class:"tok-propertyName"},{tag:c.operator,class:"tok-operator"},{tag:c.comment,class:"tok-comment"},{tag:c.meta,class:"tok-meta"},{tag:c.invalid,class:"tok-invalid"},{tag:c.punctuation,class:"tok-punctuation"}]);var dt,he=new k;function on(r){return W.define({combine:r?e=>e.concat(r):void 0})}var zn=new k,D=class{constructor(e,t,n=[],i=""){this.data=e,this.name=i,ue.prototype.hasOwnProperty("tree")||Object.defineProperty(ue.prototype,"tree",{get(){return z(this)}}),this.parser=t,this.extension=[te.of(this),ue.languageData.of((s,l,o)=>{let a=Gt(s,l,o),h=a.type.prop(he);if(!h)return[];let f=s.facet(h),d=a.type.prop(zn);if(d){let g=a.resolve(l-a.from,o);for(let b of d)if(b.test(g,s)){let w=s.facet(b.facet);return b.type=="replace"?w:w.concat(f)}}return f})].concat(n)}isActiveAt(e,t,n=-1){return Gt(e,t,n).type.prop(he)==this.data}findRegions(e){let t=e.facet(te);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(s,l)=>{if(s.prop(he)==this.data){n.push({from:l,to:l+s.length});return}let o=s.prop(k.mounted);if(o){if(o.tree.prop(he)==this.data){if(o.overlay)for(let a of o.overlay)n.push({from:a.from+l,to:a.to+l});else n.push({from:l,to:l+s.length});return}else if(o.overlay){let a=n.length;if(i(o.tree,o.overlay[0].from+l),n.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof A&&i(h,s.positions[a]+l)}};return i(z(e),0),n}get allowsNesting(){return!0}};D.setState=me.define();function Gt(r,e,t){let n=r.facet(te),i=z(r).topNode;if(!n||n.allowsNesting)for(let s=i;s;s=s.enter(e,t,I.ExcludeBuffers|I.EnterBracketed))s.type.isTop&&(i=s);return i}var Jt=class r extends D{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=on(e.languageData);return new r(t,e.parser.configure({props:[he.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function z(r){let e=r.field(D.state,!1);return e?e.tree:A.empty}function jn(r,e,t=50){var n;let i=(n=r.field(D.state,!1))===null||n===void 0?void 0:n.context;if(!i)return null;let s=i.viewport;i.updateViewport({from:0,to:e});let l=i.isDone(e)||i.work(t,e)?i.tree:null;return i.updateViewport(s),l}function jr(r,e=r.doc.length){var t;return((t=r.field(D.state,!1))===null||t===void 0?void 0:t.context.isDone(e))||!1}function Ur(r,e=r.viewport.to,t=100){let n=jn(r.state,e,t);return n!=z(r.state)&&r.dispatch({}),!!n}function Wr(r){var e;return((e=r.plugin(hn))===null||e===void 0?void 0:e.isWorking())||!1}var mt=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 n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Ae=null,Te=class r{constructor(e,t,n=[],i,s,l,o,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=s,this.viewport=l,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new r(e,t,[],A.empty,0,n,[],null)}startParse(){return this.parser.startParse(new mt(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=A.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(le.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(le.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ae;Ae=this;try{return e()}finally{Ae=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Kt(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:s,viewport:l,skipped:o}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,d,g)=>a.push({fromA:h,toA:f,fromB:d,toB:g})),n=le.applyChanges(n,a),i=A.empty,s=0,l={from:e.mapPos(l.from,-1),to:e.mapPos(l.to,1)},this.skipped.length){o=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),d=e.mapPos(h.to,-1);f<d&&o.push({from:f,to:d})}}}return new r(this.parser,t,n,i,s,l,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:i,to:s}=this.skipped[n];i<e.to&&s>e.from&&(this.fragments=Kt(this.fragments,i,s),this.skipped.splice(n--,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 ve{createParse(t,n,i){let s=i[0].from,l=i[i.length-1].to;return{parsedPos:s,advance(){let a=Ae;if(a){for(let h of i)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=l,new A(_.none,[],[],l-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 Ae}};function Kt(r,e,t){return le.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var Pe=class r{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new r(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Te.create(e.facet(te).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new r(n)}};D.state=Qe.define({create:Pe.init,update(r,e){for(let t of e.effects)if(t.is(D.setState))return t.value;return e.startState.facet(te)!=e.state.facet(te)?Pe.init(e.state):r.apply(e)}});var an=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(an=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var pt=typeof navigator<"u"&&(!((dt=navigator.scheduling)===null||dt===void 0)&&dt.isInputPending)?()=>navigator.scheduling.isInputPending():null,hn=ce.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(D.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(D.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=an(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,s=n.field(D.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let l=Date.now()+Math.min(this.chunkBudget,100,e&&!pt?Math.max(25,e.timeRemaining()-5):1e9),o=s.context.treeLen<i&&n.doc.length>i+1e3,a=s.context.work(()=>pt&&pt()||Date.now()>l,i+(o?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:D.setState.of(new Pe(s.context))})),this.chunkBudget>0&&!(a&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Dt(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()}}}),te=W.define({combine(r){return r.length?r[0]:null},enables:r=>[D.state,hn,F.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]}),Qt=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Xt=class r{constructor(e,t,n,i,s,l=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=i,this.loadFunc=s,this.support=l,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:n}=e;if(!t){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(n)}return new r(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,t,n)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let n=/\.([^.]+)$/.exec(t);if(n){for(let i of e)if(i.extensions.indexOf(n[1])>-1)return i}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some(s=>s==t))return i;if(n)for(let i of e)for(let s of i.alias){let l=t.indexOf(s);if(l>-1&&(s.length>2||!/\w/.test(t[l-1])&&!/\w/.test(t[l+s.length])))return i}return null}},Un=W.define(),fn=W.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function qe(r){let e=r.facet(fn);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function un(r,e){let t="",n=r.tabSize,i=r.facet(fn)[0];if(i==" "){for(;e>=n;)t+=" ",e-=n;i=" "}for(let s=0;s<e;s++)t+=i;return t}function cn(r,e){r instanceof ue&&(r=new Ne(r));for(let n of r.state.facet(Un)){let i=n(r,e);if(i!==void 0)return i}let t=z(r.state);return t.length>=e?Wn(r,t,e):null}function Vr(r,e,t){let n=Object.create(null),i=new Ne(r,{overrideIndentation:l=>{var o;return(o=n[l])!==null&&o!==void 0?o:-1}}),s=[];for(let l=e;l<=t;){let o=r.doc.lineAt(l);l=o.to+1;let a=cn(i,o.from);if(a==null)continue;/\S/.test(o.text)||(a=0);let h=/^\s*/.exec(o.text)[0],f=un(r,a);h!=f&&(n[o.from]=a,s.push({from:o.from,to:o.from+h.length,insert:f}))}return r.changes(s)}var Ne=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=qe(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=n.from&&i<=n.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.countColumn(n,e-i),l=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return l>-1&&(s+=l-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Ot(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let l=s(i);if(l>-1)return l}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},dn=new k;function Wn(r,e,t){let n=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=n.node){let s=[];for(let l=i;l&&!(l.from<n.node.from||l.to>n.node.to||l.from==n.node.from&&l.type==n.node.type);l=l.parent)s.push(l);for(let l=s.length-1;l>=0;l--)n={node:s[l],next:n}}return pn(n,r,t)}function pn(r,e,t){for(let n=r;n;n=n.next){let i=Vn(n.node);if(i)return i(kt.create(e,t,n))}return 0}function Hn(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function Vn(r){let e=r.type.prop(dn);if(e)return e;let t=r.firstChild,n;if(t&&(n=t.type.prop(k.closedBy))){let i=r.lastChild,s=i&&n.indexOf(i.name)>-1;return l=>gn(l,!0,1,void 0,s&&!Hn(l)?i.from:void 0)}return r.parent==null?$n:null}function $n(){return 0}var kt=class r extends Ne{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new r(e,t,n)}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 n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(qn(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return pn(this.context.next,this.base,this.pos)}};function qn(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function Gn(r){let e=r.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let i=r.options.simulateBreak,s=r.state.doc.lineAt(t.from),l=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let o=t.to;;){let a=e.childAfter(o);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=l)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}o=a.to}}function $r({closing:r,align:e=!0,units:t=1}){return n=>gn(n,e,t,r)}function gn(r,e,t,n,i){let s=r.textAfter,l=s.match(/^\s*/)[0].length,o=n&&s.slice(l,l+n.length)==n||i==r.pos+l,a=e?Gn(r):null;return a?o?r.column(a.from):r.column(a.to):r.baseIndent+(o?0:r.unit*t)}var qr=r=>r.baseIndent;function Gr({except:r,units:e=1}={}){return t=>{let n=r&&r.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}var Jn=200;function Jr(){return ue.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:n}=r.newSelection.main,i=t.lineAt(n);if(n>i.from+Jn)return r;let s=t.sliceString(i.from,n);if(!e.some(h=>h.test(s)))return r;let{state:l}=r,o=-1,a=[];for(let{head:h}of l.selection.ranges){let f=l.doc.lineAt(h);if(f.from==o)continue;o=f.from;let d=cn(l,f.from);if(d==null)continue;let g=/^\s*/.exec(f.text)[0],b=un(l,d);g!=b&&a.push({from:f.from,to:f.from+g.length,insert:b})}return a.length?[r,{changes:a,sequential:!0}]:r})}var Kn=W.define(),Qn=new k;function Kr(r){let e=r.firstChild,t=r.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?r.to:t.from}:null}function Xn(r,e,t){let n=z(r);if(n.length<t)return null;let i=n.resolveStack(t,1),s=null;for(let l=i;l;l=l.next){let o=l.node;if(o.to<=t||o.from>t)continue;if(s&&o.from<e)break;let a=o.type.prop(Qn);if(a&&(o.to<n.length-50||n.length==r.doc.length||!Yn(o))){let h=a(o,r);h&&h.from<=t&&h.from>=e&&h.to>t&&(s=h)}}return s}function Yn(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function Ie(r,e,t){for(let n of r.facet(Kn)){let i=n(r,e,t);if(i)return i}return Xn(r,e,t)}function mn(r,e){let t=e.mapPos(r.from,1),n=e.mapPos(r.to,-1);return t>=n?void 0:{from:t,to:n}}var Oe=me.define({map:mn}),pe=me.define({map:mn});function Ct(r){let e=[];for(let{head:t}of r.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(r.lineBlockAt(t));return e}var ne=Qe.define({create(){return R.none},update(r,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,i)=>r=Yt(r,n,i)),r=r.map(e.changes);let t=[];for(let n of e.effects)n.is(Oe)&&!Zn(r,n.value.from,n.value.to)?t.push(n.value):n.is(pe)&&(r=r.update({filter:(i,s)=>n.value.from!=i||n.value.to!=s,filterFrom:n.value.from,filterTo:n.value.to}));if(t.length){let{preparePlaceholder:n}=e.state.facet(Pt),i=t.map(s=>(n?R.replace({widget:new bt(n(e.state,s))}):Zt).range(s.from,s.to));r=r.update({add:i})}return e.selection&&(r=Yt(r,e.selection.main.head)),r},provide:r=>F.decorations.from(r),toJSON(r,e){let t=[];return r.between(0,e.doc.length,(n,i)=>{t.push(n,i)}),t},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<r.length;){let n=r[t++],i=r[t++];if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(Zt.range(n,i))}return R.set(e,!0)}});function Yt(r,e,t=e){let n=!1;return r.between(e,t,(i,s)=>{i<t&&s>e&&(n=!0)}),n?r.update({filterFrom:e,filterTo:t,filter:(i,s)=>i>=t||s<=e}):r}function Qr(r){return r.field(ne,!1)||Ze.empty}function Be(r,e,t){var n;let i=null;return(n=r.field(ne,!1))===null||n===void 0||n.between(e,t,(s,l)=>{(!i||i.from>s)&&(i={from:s,to:l})}),i}function Zn(r,e,t){let n=!1;return r.between(e,e,(i,s)=>{i==e&&s==t&&(n=!0)}),n}function Tt(r,e){return r.field(ne,!1)?e:e.concat(me.appendConfig.of(kn()))}var er=r=>{for(let e of Ct(r)){let t=Ie(r.state,e.from,e.to);if(t)return r.dispatch({effects:Tt(r.state,[Oe.of(t),Ge(r,t)])}),!0}return!1},tr=r=>{if(!r.state.field(ne,!1))return!1;let e=[];for(let t of Ct(r)){let n=Be(r.state,t.from,t.to);n&&e.push(pe.of(n),Ge(r,n,!1))}return e.length&&r.dispatch({effects:e}),e.length>0};function Ge(r,e,t=!0){let n=r.state.doc.lineAt(e.from).number,i=r.state.doc.lineAt(e.to).number;return F.announce.of(`${r.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${r.state.phrase("to")} ${i}.`)}var nr=r=>{let{state:e}=r,t=[];for(let n=0;n<e.doc.length;){let i=r.lineBlockAt(n),s=Ie(e,i.from,i.to);s&&t.push(Oe.of(s)),n=(s?r.lineBlockAt(s.to):i).to+1}return t.length&&r.dispatch({effects:Tt(r.state,t)}),!!t.length},rr=r=>{let e=r.state.field(ne,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,r.state.doc.length,(n,i)=>{t.push(pe.of({from:n,to:i}))}),r.dispatch({effects:t}),!0};function ir(r,e){for(let t=e;;){let n=Ie(r.state,t.from,t.to);if(n&&n.to>e.from)return n;if(!t.from)return null;t=r.lineBlockAt(t.from-1)}}var Xr=r=>{let e=[];for(let t of Ct(r)){let n=Be(r.state,t.from,t.to);if(n)e.push(pe.of(n),Ge(r,n,!1));else{let i=ir(r,t);i&&e.push(Oe.of(i),Ge(r,i))}}return e.length>0&&r.dispatch({effects:Tt(r.state,e)}),!!e.length},Yr=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:er},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:tr},{key:"Ctrl-Alt-[",run:nr},{key:"Ctrl-Alt-]",run:rr}],sr={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},Pt=W.define({combine(r){return Ye(r,sr)}});function kn(r){let e=[ne,or];return r&&e.push(Pt.of(r)),e}function bn(r,e){let{state:t}=r,n=t.facet(Pt),i=l=>{let o=r.lineBlockAt(r.posAtDOM(l.target)),a=Be(r.state,o.from,o.to);a&&r.dispatch({effects:pe.of(a)}),l.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(r,i,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}var Zt=R.replace({widget:new class extends tt{toDOM(r){return bn(r,null)}}}),bt=class extends tt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return bn(e,this.value)}},lr={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Ce=class extends Et{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function Zr(r={}){let e={...lr,...r},t=new Ce(e,!0),n=new Ce(e,!1),i=ce.fromClass(class{constructor(l){this.from=l.viewport.from,this.markers=this.buildMarkers(l)}update(l){(l.docChanged||l.viewportChanged||l.startState.facet(te)!=l.state.facet(te)||l.startState.field(ne,!1)!=l.state.field(ne,!1)||z(l.startState)!=z(l.state)||e.foldingChanged(l))&&(this.markers=this.buildMarkers(l.view))}buildMarkers(l){let o=new Re;for(let a of l.viewportLineBlocks){let h=Be(l.state,a.from,a.to)?n:Ie(l.state,a.from,a.to)?t:null;h&&o.add(a.from,a.from,h)}return o.finish()}}),{domEventHandlers:s}=e;return[i,Rt({class:"cm-foldGutter",markers(l){var o;return((o=l.plugin(i))===null||o===void 0?void 0:o.markers)||Ze.empty},initialSpacer(){return new Ce(e,!1)},domEventHandlers:{...s,click:(l,o,a)=>{if(s.click&&s.click(l,o,a))return!0;let h=Be(l.state,o.from,o.to);if(h)return l.dispatch({effects:pe.of(h)}),!0;let f=Ie(l.state,o.from,o.to);return f?(l.dispatch({effects:Oe.of(f)}),!0):!1}}}),kn()]}var or=F.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"}}),Je=class r{constructor(e,t){this.specs=e;let n;function i(o){let a=et.newName();return(n||(n=Object.create(null)))["."+a]=o,a}let s=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,l=t.scope;this.scope=l instanceof D?o=>o.prop(he)==l.data:l?o=>o==l:void 0,this.style=ct(e.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=n?new et(n):null,this.themeType=t.themeType}static define(e,t){return new r(e,t||{})}},yt=W.define(),yn=W.define({combine(r){return r.length?[r[0]]:null}});function $e(r){let e=r.facet(yt);return e.length?e:r.facet(yn)}function ei(r,e){let t=[ar],n;return r instanceof Je&&(r.module&&t.push(F.styleModule.of(r.module)),n=r.themeType),e?.fallback?t.push(yn.of(r)):n?t.push(yt.computeN([F.darkTheme],i=>i.facet(F.darkTheme)==(n=="dark")?[r]:[])):t.push(yt.of(r)),t}function ti(r,e,t){let n=$e(r),i=null;if(n){for(let s of n)if(!s.scope||t&&s.scope(t)){let l=s.style(e);l&&(i=i?i+" "+l:l)}}return i}var xt=class{constructor(e){this.markCache=Object.create(null),this.tree=z(e.state),this.decorations=this.buildDeco(e,$e(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=z(e.state),n=$e(e.state),i=n!=$e(e.startState),{viewport:s}=e.view,l=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&l>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=l):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return R.none;let n=new Re;for(let{from:i,to:s}of e.visibleRanges)qt(this.tree,t,(l,o,a)=>{n.add(l,o,this.markCache[a]||(this.markCache[a]=R.mark({class:a})))},i,s);return n.finish()}},ar=Xe.high(ce.fromClass(xt,{decorations:r=>r.decorations})),ni=Je.define([{tag:c.meta,color:"#404740"},{tag:c.link,textDecoration:"underline"},{tag:c.heading,textDecoration:"underline",fontWeight:"bold"},{tag:c.emphasis,fontStyle:"italic"},{tag:c.strong,fontWeight:"bold"},{tag:c.strikethrough,textDecoration:"line-through"},{tag:c.keyword,color:"#708"},{tag:[c.atom,c.bool,c.url,c.contentSeparator,c.labelName],color:"#219"},{tag:[c.literal,c.inserted],color:"#164"},{tag:[c.string,c.deleted],color:"#a11"},{tag:[c.regexp,c.escape,c.special(c.string)],color:"#e40"},{tag:c.definition(c.variableName),color:"#00f"},{tag:c.local(c.variableName),color:"#30a"},{tag:[c.typeName,c.namespace],color:"#085"},{tag:c.className,color:"#167"},{tag:[c.special(c.variableName),c.macroName],color:"#256"},{tag:c.definition(c.propertyName),color:"#00c"},{tag:c.comment,color:"#940"},{tag:c.invalid,color:"#f00"}]),hr=F.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),xn=1e4,wn="()[]{}",vn=W.define({combine(r){return Ye(r,{afterCursor:!0,brackets:wn,maxScanDistance:xn,renderMatch:cr})}}),fr=R.mark({class:"cm-matchingBracket"}),ur=R.mark({class:"cm-nonmatchingBracket"});function cr(r){let e=[],t=r.matched?fr:ur;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}function en(r){let e=[],t=r.facet(vn);for(let n of r.selection.ranges){if(!n.empty)continue;let i=Ve(r,n.head,-1,t)||n.head>0&&Ve(r,n.head-1,1,t)||t.afterCursor&&(Ve(r,n.head,1,t)||n.head<r.doc.length&&Ve(r,n.head+1,-1,t));i&&(e=e.concat(t.renderMatch(i,r)))}return R.set(e,!0)}var dr=ce.fromClass(class{constructor(r){this.paused=!1,this.decorations=en(r.state)}update(r){(r.docChanged||r.selectionSet||this.paused)&&(r.view.composing?(this.decorations=this.decorations.map(r.changes),this.paused=!0):(this.decorations=en(r.state),this.paused=!1))}},{decorations:r=>r.decorations}),pr=[dr,hr];function ri(r={}){return[vn.of(r),pr]}var gr=new k;function wt(r,e,t){let n=r.prop(e<0?k.openedBy:k.closedBy);if(n)return n;if(r.name.length==1){let i=t.indexOf(r.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function vt(r){let e=r.type.prop(gr);return e?e(r.node):r}function Ve(r,e,t,n={}){let i=n.maxScanDistance||xn,s=n.brackets||wn,l=z(r),o=l.resolveInner(e,t);for(let a=o;a;a=a.parent){let h=wt(a.type,t,s);if(h&&a.from<a.to){let f=vt(a);if(f&&(t>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return mr(r,e,t,a,f,h,s)}}return kr(r,e,t,l,o.type,i,s)}function mr(r,e,t,n,i,s,l){let o=n.parent,a={from:i.from,to:i.to},h=0,f=o?.cursor();if(f&&(t<0?f.childBefore(n.from):f.childAfter(n.to)))do if(t<0?f.to<=n.from:f.from>=n.to){if(h==0&&s.indexOf(f.type.name)>-1&&f.from<f.to){let d=vt(f);return{start:a,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(wt(f.type,t,l))h++;else if(wt(f.type,-t,l)){if(h==0){let d=vt(f);return{start:a,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}h--}}while(t<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function kr(r,e,t,n,i,s,l){if(t<0?!e:e==r.doc.length)return null;let o=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),a=l.indexOf(o);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},f=r.doc.iterRange(e,t>0?r.doc.length:0),d=0;for(let g=0;!f.next().done&&g<=s;){let b=f.value;t<0&&(g+=b.length);let w=e+g*t;for(let M=t>0?0:b.length-1,j=t>0?b.length:-1;M!=j;M+=t){let E=l.indexOf(b[M]);if(!(E<0||n.resolveInner(w+M,1).type!=i))if(E%2==0==t>0)d++;else{if(d==1)return{start:h,end:{from:w+M,to:w+M+1},matched:E>>1==a>>1};d--}}t>0&&(g+=b.length)}return f.done?{start:h,matched:!1}:null}function br(r){return{name:r.name||"",token:r.token,blankLine:r.blankLine||(()=>{}),startState:r.startState||(()=>!0),copyState:r.copyState||yr,indent:r.indent||(()=>null),languageData:r.languageData||{},tokenTable:r.tokenTable||It,mergeTokens:r.mergeTokens!==!1}}function yr(r){if(typeof r!="object")return r;let e={};for(let t in r){let n=r[t];e[t]=n instanceof Array?n.slice():n}return e}var tn=new WeakMap,nn=class r extends D{constructor(e){let t=on(e.languageData),n=br(e),i,s=new class extends ve{createParse(l,o,a){return new St(i,l,o,a)}};super(t,s,[],e.name),this.topNode=Sr(t,this),i=this,this.streamParser=n,this.stateAfter=new k({perNode:!0}),this.tokenTable=e.tokenTable?new Ke(n.tokenTable):vr}static define(e){return new r(e)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=tn.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let i=Nt(this,e.node.tree,e.node.from,e.node.from,t??e.pos),s,l;if(i?(l=i.state,s=i.pos+1):(l=this.streamParser.startState(e.unit),s=e.node.from),e.pos-s>1e4)return null;for(;s<e.pos;){let a=e.state.doc.lineAt(s),h=Math.min(e.pos,a.to);if(a.length){let f=n?n(a.from):-1,d=new de(a.text,e.state.tabSize,e.unit,f<0?void 0:f);for(;d.pos<h-a.from;)An(this.streamParser.token,d,l)}else this.streamParser.blankLine(l,e.unit);if(h==e.pos)break;s=a.to+1}let o=e.lineAt(e.pos);return n&&t==null&&tn.set(e.state,o.from),this.streamParser.indent(l,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Nt(r,e,t,n,i){let s=t>=n&&t+e.length<=i&&e.prop(r.stateAfter);if(s)return{state:r.streamParser.copyState(s),pos:t+e.length};for(let l=e.children.length-1;l>=0;l--){let o=e.children[l],a=t+e.positions[l],h=o instanceof A&&a<i&&Nt(r,o,a,n,i);if(h)return h}return null}function Sn(r,e,t,n,i){if(i&&t<=0&&n>=e.length)return e;!i&&t==0&&e.type==r.topNode&&(i=!0);for(let s=e.children.length-1;s>=0;s--){let l=e.positions[s],o=e.children[s],a;if(l<n&&o instanceof A){if(!(a=Sn(r,o,t-l,n-l,i)))break;return i?new A(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),l+a.length):a}}return null}function xr(r,e,t,n,i){for(let s of e){let l=s.from+(s.openStart?25:0),o=s.to-(s.openEnd?25:0),a=l<=t&&o>t&&Nt(r,s.tree,0-s.offset,t,o),h;if(a&&a.pos<=n&&(h=Sn(r,s.tree,t+s.offset,a.pos+s.offset,!1)))return{state:a.state,tree:h}}return{state:r.streamParser.startState(i?qe(i):4),tree:A.empty}}var St=class{constructor(e,t,n,i){this.lang=e,this.input=t,this.fragments=n,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let s=Te.get(),l=i[0].from,{state:o,tree:a}=xr(e,n,l,this.to,s?.state);this.state=o,this.parsedPos=this.chunkStart=l+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&i.some(h=>h.from<=s.viewport.from&&h.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(qe(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=Te.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
+`&&(t="");else{let n=t.indexOf(`
+`);n>-1&&(t=t.slice(0,n))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let i=this.rangeIndex;;){let s=this.ranges[i].to;if(s>=n||(t=t.slice(0,s-(n-t.length)),i++,i==this.ranges.length))break;let l=this.ranges[i].from,o=this.lineAfter(l);t+=o,n=l+o.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let i=this.ranges[this.rangeIndex].to,s=e+t;if(n>0?i>s:i>=s)break;let l=this.ranges[++this.rangeIndex].from;t+=l-i}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,i){let s=4;if(this.ranges.length>1){i=this.skipGapsTo(t,i,1),t+=i;let o=this.chunk.length;i=this.skipGapsTo(n,i,-1),n+=i,s+=this.chunk.length-o}let l=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&l>=0&&this.chunk[l]==e&&this.chunk[l+2]==t?this.chunk[l+2]=n:this.chunk.push(e,t,n,s),i}parseLine(e){let{line:t,end:n}=this.nextLine(),i=0,{streamParser:s}=this.lang,l=new de(t,e?e.state.tabSize:4,e?qe(e.state):2);if(l.eol())s.blankLine(this.state,l.indentUnit);else for(;!l.eol();){let o=An(s.token,l,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+l.start,this.parsedPos+l.pos,i)),l.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=A.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:wr,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new A(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new A(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function An(r,e,t){e.start=e.pos;for(let n=0;n<10;n++){let i=r(e,t);if(e.pos>e.start)return i}throw new Error("Stream parser failed to advance stream.")}var It=Object.create(null),Me=[_.none],wr=new Fe(Me),rn=[],sn=Object.create(null),Cn=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Cn[r]=Tn(It,e);var Ke=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Cn)}resolve(e){return e?this.table[e]||(this.table[e]=Tn(this.extra,e)):0}},vr=new Ke(It);function gt(r,e){rn.indexOf(r)>-1||(rn.push(r),console.warn(e))}function Tn(r,e){let t=[];for(let o of e.split(" ")){let a=[];for(let h of o.split(".")){let f=r[h]||c[h];f?typeof f=="function"?a.length?a=a.map(f):gt(h,`Modifier ${h} used at start of tag`):a.length?gt(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:gt(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+t.map(o=>o.id),s=sn[i];if(s)return s.id;let l=sn[i]=_.define({id:Me.length,name:n,props:[Vt({[n]:t})]});return Me.push(l),l.id}function Sr(r,e){let t=_.define({id:Me.length,name:"Document",props:[he.add(()=>r),dn.add(()=>n=>e.getIndent(n))],top:!0});return Me.push(t),t}function Pn(r){return r.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(r)}function Nn(r){for(let e=r.iter();!e.next().done;)if(Pn(e.value))return!0;return!1}function Ar(r){let e=!1;return r.iterChanges((t,n,i,s,l)=>{!e&&Nn(l)&&(e=!0)}),e}var At=W.define({combine:r=>r.some(e=>e)});function ii(r={}){let e=[Cr];return r.alwaysIsolate&&e.push(At.of(!0)),e}var Cr=ce.fromClass(class{constructor(r){this.always=r.state.facet(At)||r.textDirection!=ke.LTR||r.state.facet(F.perLineTextDirection),this.hasRTL=!this.always&&Nn(r.state.doc),this.tree=z(r.state),this.decorations=this.always||this.hasRTL?ln(r,this.tree,this.always):R.none}update(r){let e=r.state.facet(At)||r.view.textDirection!=ke.LTR||r.state.facet(F.perLineTextDirection);if(!e&&!this.hasRTL&&Ar(r.changes)&&(this.hasRTL=!0),!e&&!this.hasRTL)return;let t=z(r.state);(e!=this.always||t!=this.tree||r.docChanged||r.viewportChanged)&&(this.tree=t,this.always=e,this.decorations=ln(r.view,t,e))}},{provide:r=>{function e(t){var n,i;return(i=(n=t.plugin(r))===null||n===void 0?void 0:n.decorations)!==null&&i!==void 0?i:R.none}return[F.outerDecorations.of(e),Xe.lowest(F.bidiIsolatedRanges.of(e))]}});function ln(r,e,t){let n=new Re,i=r.visibleRanges;t||(i=Tr(i,r.state.doc));for(let{from:s,to:l}of i)e.iterate({enter:o=>{let a=o.type.prop(k.isolate);a&&n.add(o.from,o.to,Pr[a])},from:s,to:l});return n.finish()}function Tr(r,e){let t=e.iter(),n=0,i=[],s=null;for(let{from:l,to:o}of r)if(!(s&&s.to>l&&(l=s.to,l>=o)))for(n+t.value.length<l&&(t.next(l-(n+t.value.length)),n=l);;){let a=n,h=n+t.value.length;if(!t.lineBreak&&Pn(t.value)&&(s&&s.to>a-10?s.to=Math.min(o,h):i.push(s={from:a,to:Math.min(o,h)})),h>=o)break;n=h,t.next()}return i}var Pr={rtl:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ke.RTL}),ltr:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ke.LTR}),auto:R.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};export{k as a,c as b,de as c,he as d,on as e,zn as f,D as g,Jt as h,z as i,jn as j,jr as k,Ur as l,Wr as m,mt as n,Te as o,te as p,Qt as q,Xt as r,Un as s,fn as t,qe as u,un as v,cn as w,Vr as x,Ne as y,dn as z,kt as A,$r as B,qr as C,Gr as D,Jr as E,Kn as F,Qn as G,Kr as H,Ie as I,Oe as J,pe as K,ne as L,Qr as M,er as N,tr as O,nr as P,rr as Q,Xr as R,Yr as S,kn as T,Zr as U,Je as V,ei as W,ti as X,ni as Y,ri as Z,gr as _,Ve as $,nn as aa,ii as ba};