mirror of
https://github.com/open-webui/open-webui
synced 2024-11-26 05:51:12 +00:00
3 lines
63 KiB
JavaScript
3 lines
63 KiB
JavaScript
import{Facet as t,EditorState as e,StateEffect as r,StateField as n,countColumn as i,RangeSet as s,combineConfig as o,Prec as l,RangeSetBuilder as a}from"./codemirror_state-BKbyfKsm.js";import{V as h,l as f,E as u,a as c,W as d,p,D as g,G as m,S as b}from"./codemirror_view-C0PMO2z_.js";const x=1024;let k=0;class y{constructor(t,e){this.from=t,this.to=e}}class w{constructor(t={}){this.id=k++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=A.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}w.closedBy=new w({deserialize:t=>t.split(" ")}),w.openedBy=new w({deserialize:t=>t.split(" ")}),w.group=new w({deserialize:t=>t.split(" ")}),w.isolate=new w({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),w.contextHash=new w({perNode:!0}),w.lookAhead=new w({perNode:!0}),w.mounted=new w({perNode:!0});class v{constructor(t,e,r){this.tree=t,this.overlay=e,this.parser=r}static get(t){return t&&t.props&&t.props[w.mounted.id]}}const S=Object.create(null);class A{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=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=new A(t.name||"",e,t.id,r);if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(w.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(w.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}A.none=new A("",Object.create(null),0,8);class C{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let r of this.types){let n=null;for(let e of t){let t=e(r);t&&(n||(n=Object.assign({},r.props)),n[t[0].id]=t[1])}e.push(n?new A(r.name,n,r.id,r.flags):r)}return new C(e)}}const N=new WeakMap,P=new WeakMap;var I;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(I||(I={}));class T{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]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=v.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let r=t.toString();r&&(e&&(e+=","),e+=r)}return this.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){return new F(this.topNode,t)}cursorAt(t,e=0,r=0){let n=N.get(this)||this.topNode,i=new F(n);return i.moveTo(t,e),N.set(this,i._tree),i}get topNode(){return new L(this,0,0,null)}resolve(t,e=0){let r=M(N.get(this)||this.topNode,t,e,!1);return N.set(this,r),r}resolveInner(t,e=0){let r=M(P.get(this)||this.topNode,t,e,!0);return P.set(this,r),r}resolveStack(t,e=0){return function(t,e,r){let n=t.resolveInner(e,r),i=null;for(let t=n instanceof L?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(i||(i=[n])).push(s.resolve(e,r)),t=s}else{let s=v.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new L(s.tree,s.overlay[0].from+t.from,-1,t);(i||(i=[n])).push(M(o,e,r,!1))}}return i?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(let t=this.cursor(s|I.IncludeAnonymous);;){let s=!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){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:H(A.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new T(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new T(A.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=x,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(r)?new O(r,r.length):r,a=n.types,h=0,f=0;function u(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){let e=s[w];return r.push(e),void x.push(v-t)}if(-3==A)return void(h=w);if(-4==A)return void(f=w);throw new RangeError(`Unrecognized record size: ${A}`)}let N,P,I=a[w],T=v-t;if(S-v<=i&&(P=m(l.pos-e,k))){let e=new Uint16Array(P.size-P.skip),r=l.pos-P.size,i=e.length;for(;l.pos>r;)i=b(P.start,e,i);N=new B(e,S-P.start,n),T=P.start-t}else{let t=l.pos-A;l.next();let e=[],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){let t=d(I);N=H(I,e,r,0,e.length,0,S-v,t,t)}else N=g(I,e,r,S-v,C-S)}r.push(N),x.push(T)}function c(t,e,r,s){let o=[],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){let e=new Uint16Array(4*a),i=o[o.length-2];for(let t=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(new B(e,o[2]-i,n)),s.push(i-t)}}function d(t){return(e,r,n)=>{let i,s,o=0,l=e.length-1;if(l>=0&&(i=e[l])instanceof T){if(!l&&i.type==t&&i.length==n)return i;(s=i.prop(w.lookAhead))&&(o=r[l]+i.length+s)}return g(t,e,r,n,o)}}function p(t,e,r,i,s,o,l,a){let h=[],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)}function g(t,e,r,n,i=0,s){if(h){let t=[w.contextHash,h];s=s?[t].concat(s):[t]}if(i>25){let t=[w.lookAhead,i];s=s?[t].concat(s):[t]}return new T(t,e,r,n,s)}function m(t,e){let r=l.fork(),n=0,s=0,a=0,h=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-t;if(t<0||l<i||r.start<h)break;let u=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)break t;u+=4}else r.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:void 0}function b(t,e,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=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);return r}let k=[],y=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,k,y,-1,0);let v=null!==(e=t.length)&&void 0!==e?e:k.length?y[0]+k[0].length:0;return new T(a[t.topID],k.reverse(),y.reverse(),v)}(t)}}T.empty=new T(A.none,[],[],0);class O{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new O(this.buffer,this.index)}}class B{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return A.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=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))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&!(_(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(t,e,r){let n=this.buffer,i=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){i[l++]=n[o++],i[l++]=n[o++]-r;let e=i[l++]=n[o++]-r;i[l++]=n[o++]-t,s=Math.max(s,e)}return new B(i,s,this.set)}}function _(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function M(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof L&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:I.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof L&&n.index<0&&(null===(i=o.enter(e,r,s))||void 0===i?void 0:i.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,r,s);if(!n)return t;t=n}}class D{cursor(t=0){return new F(this,t)}getChild(t,e=null,r=null){let n=E(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return E(this,t,e,r)}resolve(t,e=0){return M(this,t,e,!1)}resolveInner(t,e=0){return M(this,t,e,!0)}matchContext(t){return R(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),r=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(r=e,e=t.prevSibling):e=t}return r}get node(){return this}get next(){return this.parent}}class L extends D{constructor(t,e,r,n){super(),this._tree=t,this.from=e,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=e>0?o.length:-1;t!=a;t+=e){let a=o[t],h=l[t]+s.from;if(_(n,r,h,h+a.length))if(a instanceof B){if(i&I.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,r-h,n);if(o>-1)return new j(new z(s,a,t,h),null,o)}else if(i&I.IncludeAnonymous||!a.type.isAnonymous||V(a)){let o;if(!(i&I.IgnoreMounts)&&(o=v.get(a))&&!o.overlay)return new L(o.tree,h,t,s);let l=new L(a,h,t,s);return i&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)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,r=0){let n;if(!(r&I.IgnoreOverlays)&&(n=v.get(this._tree))&&n.overlay){let r=t-this.from;for(let{from:t,to:i}of n.overlay)if((e>0?t<=r:t<r)&&(e<0?i>=r:i>r))return new L(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function E(t,e,r,n){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(let t=!1;!t;)if(t=i.type.is(r),!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function R(t,e,r=e.length-1){for(let n=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}class z{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class j extends D{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,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);return i<0?null:new j(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r=0){if(r&I.ExcludeBuffers)return null;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);return i<0?null:new j(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new j(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new j(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];t.push(r.slice(n,i,s)),e.push(0)}return new T(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function W(t){if(!t.length)return null;let e=0,r=t[0];for(let n=1;n<t.length;n++){let i=t[n];(i.from>r.from||i.to<r.to)&&(r=i,e=n)}let n=r instanceof L&&r.index<0?null:r.parent,i=t.slice();return n?i[e]=n:i.splice(e,1),new U(i,r)}class U{constructor(t,e){this.heads=t,this.node=e}get next(){return W(this.heads)}}class F{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof L)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=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;return this.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&&(t instanceof L?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.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(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=this.mode){return this.buffer?!(r&I.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r))}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 t=this.mode&I.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=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(let n=e+t,i=t<0?-1:r._tree.children.length;n!=i;n+=t){let t=r._tree.children[n];if(this.mode&I.IncludeAnonymous||t instanceof B||!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){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let t=r;t<this.stack.length;t++)e=new j(this.buffer,e,this.stack[t]);return this.bufferNode=new j(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let r=0;;){let n=!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)return R(this.node,t);let{buffer:e}=this.buffer,{types:r}=e.set;for(let n=t.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return R(this.node,t,n);let s=r[e.buffer[this.stack[i]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function V(t){return t.children.some((t=>t instanceof B||!t.type.isAnonymous||V(t)))}const q=new WeakMap;function $(t,e){if(!t.isAnonymous||e instanceof B||e.type!=t)return 1;let r=q.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof T)){r=1;break}r+=$(t,n)}q.set(e,r)}return r}function H(t,e,r,n,i,s,o,l,a){let h=0;for(let r=n;r<i;r++)h+=$(t,e[r]);let f=Math.ceil(1.5*h/8),u=[],c=[];return function e(r,n,i,o,l){for(let h=i;h<o;){let i=h,d=n[h],p=$(t,r[h]);for(h++;h<o;h++){let e=$(t,r[h]);if(p+e>=f)break;p+=e}if(h==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+l);continue}u.push(r[i])}else{let e=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)}class G{constructor(){this.map=new WeakMap}setBuffer(t,e,r){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,r)}getBuffer(t,e){let r=this.map.get(t);return r&&r.get(e)}set(t,e){t instanceof j?this.setBuffer(t.context.buffer,t.index,e):t instanceof L&&this.map.set(t.tree,e)}get(t){return t instanceof j?this.getBuffer(t.context.buffer,t.index):t instanceof L?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class J{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)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new J(0,t.length,t,0,!1,r)];for(let r of e)r.to>t.length&&n.push(r);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,f=h?h.fromA:1e9;if(f-l>=r)for(;s&&s.from<f;){let e=s;if(l>=e.from||f<=e.to||a){let t=Math.max(e.from,l)-a,r=Math.min(e.to,f)-a;e=t>=r?null:new J(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}return n}}class K{startParse(t,e,r){return"string"==typeof t&&(t=new Q(t)),r=r?r.length?r.map((t=>new y(t.from,t.to))):[new y(0,0)]:[new y(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}class Q{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new w({perNode:!0});let X=0;class Y{constructor(t,e,r){this.set=t,this.base=e,this.modified=r,this.id=X++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Y([],null,[]);if(e.set.push(e),t)for(let r of t.set)e.set.push(r);return e}static defineModifier(){let t=new tt;return e=>e.modified.indexOf(t)>-1?e:tt.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Z=0;class tt{constructor(){this.instances=[],this.id=Z++}static get(t,e){if(!e.length)return t;let r=e[0].instances.find((r=>{return r.base==t&&(n=e,i=r.modified,n.length==i.length&&n.every(((t,e)=>t==i[e])));var n,i}));if(r)return r;let n=[],i=new Y(n,t,e);for(let t of e)t.instances.push(i);let s=function(t){let e=[[]];for(let r=0;r<t.length;r++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(t[r]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)n.push(tt.get(e,t));return i}}function et(t){let e=Object.create(null);for(let r in t){let n=t[r];Array.isArray(n)||(n=[n]);for(let t of r.split(" "))if(t){let r=[],i=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){i=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("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;let o=t[e++];if(e==t.length&&"!"==o){i=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=r.length-1,l=r[o];if(!l)throw new RangeError("Invalid path: "+t);let a=new nt(n,i,o>0?r.slice(0,o):null);e[l]=a.sort(e[l])}}return rt.add(e)}const rt=new w;class nt{constructor(t,e,r,n){this.tags=t,this.mode=e,this.context=r,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function it(t,e){let r=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)r[t.id]=e.class;else r[e.tag.id]=e.class;let{scope:n,all:i=null}=e||{};return{style:t=>{let e=i;for(let n of t)for(let t of n.set){let n=r[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function st(t,e,r,n=0,i=t.length){let s=new ot(n,Array.isArray(e)?e:[e],r);s.highlightRange(t.cursor(),n,i,"",s.highlighters),s.flush(i)}nt.empty=new nt([],2,null);class ot{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))));let a=n,h=function(t){let e=t.type.prop(rt);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||nt.empty,f=function(t,e){let r=null;for(let n of t){let t=n.style(e);t&&(r=r?r+" "+t:t)}return r}(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;let u=t.tree&&t.tree.prop(w.mounted);if(u&&u.overlay){let s=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(let c=0,d=o;;c++){let p=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()}else if(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()}}}const lt=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()};var St;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"}]);const At=new w;function Ct(e){return t.define({combine:e?t=>t.concat(e):void 0})}const Nt=new w;class Pt{constructor(t,r,n=[],i=""){this.data=t,this.name=i,e.prototype.hasOwnProperty("tree")||Object.defineProperty(e.prototype,"tree",{get(){return Ot(this)}}),this.parser=r,this.extension=[Wt.of(this),e.languageData.of(((t,e,r)=>{let n=It(t,e,r),i=n.type.prop(At);if(!i)return[];let s=t.facet(i),o=n.type.prop(Nt);if(o){let i=n.resolve(e-n.from,r);for(let e of o)if(e.test(i,t)){let r=t.facet(e.facet);return"replace"==e.type?r:r.concat(s)}}return s}))].concat(n)}isActiveAt(t,e,r=-1){return It(t,e,r).type.prop(At)==this.data}findRegions(t){let e=t.facet(Wt);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(At)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(w.mounted);if(i){if(i.tree.prop(At)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof T&&n(i,t.positions[r]+e)}};return n(Ot(t),0),r}get allowsNesting(){return!0}}function It(t,e,r){let n=t.facet(Wt),i=Ot(t).topNode;if(!n||n.allowsNesting)for(let t=i;t;t=t.enter(e,r,I.ExcludeBuffers))t.type.isTop&&(i=t);return i}Pt.setState=r.define();class Tt extends Pt{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=Ct(t.languageData);return new Tt(e,t.parser.configure({props:[At.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new Tt(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ot(t){let e=t.field(Pt.state,!1);return e?e.tree:T.empty}function Bt(t,e,r=50){var n;let i=null===(n=t.field(Pt.state,!1))||void 0===n?void 0:n.context;if(!i)return null;let s=i.viewport;i.updateViewport({from:0,to:e});let o=i.isDone(e)||i.work(r,e)?i.tree:null;return i.updateViewport(s),o}class _t{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let Mt=null;class Dt{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=[]}static create(t,e,r){return new Dt(t,e,[],T.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _t(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=T.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof t){let e=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);;){let n=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)&&void 0!==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(){let t,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){let e=Mt;Mt=this;try{return t()}finally{Mt=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Lt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];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(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new Dt(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;let e=this.skipped.length;for(let e=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})}static getSkippingParser(t){return new class extends K{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=Mt;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new T(A.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Mt}}function Lt(t,e,r){return J.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class Et{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new Et(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=Dt.create(t.facet(Wt).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new Et(r)}}Pt.state=n.define({create:Et.init,update(t,e){for(let t of e.effects)if(t.is(Pt.setState))return t.value;return e.startState.facet(Wt)!=e.state.facet(Wt)?Et.init(e.state):t.apply(e)}});let Rt=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Rt=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const zt="undefined"!=typeof navigator&&(null===(St=navigator.scheduling)||void 0===St?void 0: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){let e=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;let e=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;let s=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(new Et(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=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}}))]});class Ut{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ft{constructor(t,e,r,n,i,s=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=n,this.loadFunc=i,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{throw this.loading=null,t})))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ft(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let r of t)if(r.filename&&r.filename.test(e))return r;let r=/\.([^.]+)$/.exec(e);if(r)for(let e of t)if(e.extensions.indexOf(r[1])>-1)return e;return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let r of t)if(r.alias.some((t=>t==e)))return r;if(r)for(let r of t)for(let t of r.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return r}return null}}const Vt=t.define(),qt=t.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function $t(t){let e=t.facet(qt);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Ht(t,e){let r="",n=t.tabSize,i=t.facet(qt)[0];if("\t"==i){for(;e>=n;)r+="\t",e-=n;i=" "}for(let t=0;t<e;t++)r+=i;return r}function Gt(t,r){t instanceof e&&(t=new Jt(t));for(let e of t.state.facet(Vt)){let n=e(t,r);if(void 0!==n)return n}let n=Ot(t.state);return n.length>=r?function(t,e,r){let n=e.resolveStack(r),i=n.node.enterUnfinishedNodesBefore(r);if(i!=n.node){let t=[];for(let e=i;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Qt(n,t,r)}(t,n,r):null}class Jt{constructor(t,e={}){this.state=t,this.options=e,this.unit=$t(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:i}=this.options;return null!=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);return r.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;return s>-1&&(i+=s-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return i(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:n}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let t=i(n);if(t>-1)return t}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Kt=new w;function Qt(t,e,r){for(let n=t;n;n=n.next){let t=Xt(n.node);if(t)return t(Zt.create(e,r,n))}return 0}function Xt(t){let e=t.type.prop(Kt);if(e)return e;let r,n=t.firstChild;if(n&&(r=n.type.prop(w.closedBy))){let e=t.lastChild,n=e&&r.indexOf(e.name)>-1;return t=>re(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Yt:null}function Yt(){return 0}class Zt extends Jt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new Zt(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=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)}return this.lineIndent(e.from)}continue(){return Qt(this.context.next,this.base,this.pos)}}function te(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function ee({closing:t,align:e=!0,units:r=1}){return n=>re(n,e,r,t)}function re(t,e,r,n,i){let s=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){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),o=null==i||i<=s.from?s.to:Math.min(s.to,i);for(let t=r.to;;){let i=e.childAfter(t);if(!i||i==n)return null;if(!i.type.isSkipped)return i.from<o?r:null;t=i.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}function ne(){return e.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+200)return t;let s=r.sliceString(i.from,n);if(!e.some((t=>t.test(s))))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let r=Gt(o,e.from);if(null==r)continue;let n=/^\s*/.exec(e.text)[0],i=Ht(o,r);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[t,{changes:a,sequential:!0}]:t}))}const ie=t.define(),se=new w;function oe(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function le(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function ae(t,e,r){for(let n of t.facet(ie)){let i=n(t,e,r);if(i)return i}return function(t,e,r){let n=Ot(t);if(n.length<r)return null;let i=null;for(let s=n.resolveStack(r,1);s;s=s.next){let o=s.node;if(o.to<=r||o.from>r)continue;if(i&&o.from<e)break;let l=o.type.prop(se);if(l&&(o.to<n.length-50||n.length==t.doc.length||!le(o))){let n=l(o,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(i=n)}}return i}(t,e,r)}function he(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}const fe=r.define({map:he}),ue=r.define({map:he});function ce(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some((t=>t.from<=r&&t.to>=r))||e.push(t.lineBlockAt(r));return e}const de=n.define({create:()=>c.none,update(t,e){t=t.map(e.changes);for(let r of e.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:new Te(n(e.state,r.value))}):Ie;t=t.update({add:[i.range(r.value.from,r.value.to)]})}else r.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){let r=!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}))}return t},provide:t=>u.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,((t,e)=>{r.push(t,e)})),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],i=t[r++];if("number"!=typeof n||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");e.push(Ie.range(n,i))}return c.set(e,!0)}});function pe(t,e,r){var n;let i=null;return null===(n=t.field(de,!1))||void 0===n||n.between(e,r,((t,e)=>{(!i||i.from>t)&&(i={from:t,to:e})})),i}function ge(t,e,r){let n=!1;return t.between(e,e,((t,i)=>{t==e&&i==r&&(n=!0)})),n}function me(t,e){return t.field(de,!1)?e:e.concat(r.appendConfig.of(Ne()))}const be=t=>{for(let e of ce(t)){let r=ae(t.state,e.from,e.to);if(r)return t.dispatch({effects:me(t.state,[fe.of(r),ke(t,r)])}),!0}return!1},xe=t=>{if(!t.state.field(de,!1))return!1;let e=[];for(let r of ce(t)){let n=pe(t.state,r.from,r.to);n&&e.push(ue.of(n),ke(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function ke(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return u.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}const ye=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let i=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}return r.length&&t.dispatch({effects:me(t.state,r)}),!!r.length},we=t=>{let e=t.state.field(de,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,((t,e)=>{r.push(ue.of({from:t,to:e}))})),t.dispatch({effects:r}),!0};function ve(t,e){for(let r=e;;){let n=ae(t.state,r.from,r.to);if(n&&n.to>e.from)return n;if(!r.from)return null;r=t.lineBlockAt(r.from-1)}}const Se=[{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)});function Ne(t){let e=[de,Me];return t&&e.push(Ce.of(t)),e}function Pe(t,e){let{state:r}=t,n=r.facet(Ce),i=e=>{let r=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)return n.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const Ie=c.replace({widget:new class extends d{toDOM(t){return Pe(t,null)}}});class Te extends d{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Pe(t,this.value)}}const Oe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Be extends m{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function _e(t={}){let e=Object.assign(Object.assign({},Oe),t),r=new Be(e,!0),n=new Be(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){let e=new a;for(let i of t.viewportLineBlocks){let s=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)}return e.finish()}}),{domEventHandlers:o}=e;return[i,p({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(i))||void 0===e?void 0:e.markers)||s.empty},initialSpacer:()=>new Be(e,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(t,e,r)=>{if(o.click&&o.click(t,e,r))return!0;let n=pe(t.state,e.from,e.to);if(n)return t.dispatch({effects:ue.of(n)}),!0;let i=ae(t.state,e.from,e.to);return!!i&&(t.dispatch({effects:fe.of(i)}),!0)}})}),Ne()]}const Me=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"}});class De{constructor(t,e){let r;function n(t){let e=b.newName();return(r||(r=Object.create(null)))["."+e]=t,e}this.specs=t;const i="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof Pt?t=>t.prop(At)==s.data:s?t=>t==s:void 0,this.style=it(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:i}).style,this.module=r?new b(r):null,this.themeType=e.themeType}static define(t,e){return new De(t,e||{})}}const Le=t.define(),Ee=t.define({combine:t=>t.length?[t[0]]:null});function Re(t){let e=t.facet(Le);return e.length?e:t.facet(Ee)}function ze(t,e){let r,n=[We];return t instanceof De&&(t.module&&n.push(u.styleModule.of(t.module)),r=t.themeType),(null==e?void 0: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}class je{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){let e=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)return c.none;let r=new a;for(let{from:n,to:i}of t.visibleRanges)st(this.tree,e,((t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=c.mark({class:n})))}),n,i);return r.finish()}}const We=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"});function Ge(t){let e=[],r=t.matched?$e:He;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}const Je=[n.define({create:()=>c.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(qe);for(let t of e.state.selection.ranges){if(!t.empty)continue;let i=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)))}return c.set(r,!0)},provide:t=>u.decorations.from(t)}),Fe];function Ke(t={}){return[qe.of(t),Je]}const Qe=new w;function Xe(t,e,r){let n=t.prop(e<0?w.openedBy:w.closedBy);if(n)return n;if(1==t.name.length){let n=r.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[r[n+e]]}return null}function Ye(t){let e=t.type.prop(Qe);return e?e(t.node):t}function Ze(t,e,r,n={}){let i=n.maxScanDistance||1e4,s=n.brackets||Ve,o=Ot(t),l=o.resolveInner(e,r);for(let n=l;n;n=n.parent){let i=Xe(n.type,r,s);if(i&&n.from<n.to){let o=Ye(n);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return tr(t,e,r,n,o,i,s)}}return function(t,e,r,n,i,s,o){let l=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=r>0)return null;let h={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(let t=0;!f.next().done&&t<=s;){let s=f.value;r<0&&(t+=s.length);let l=e+t*r;for(let t=r>0?0:s.length-1,e=r>0?s.length:-1;t!=e;t+=r){let e=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)}return f.done?{start:h,matched:!1}:null}(t,e,r,o,l.type,i,s)}function tr(t,e,r,n,i,s,o){let l=n.parent,a={from:i.from,to:i.to},h=0,f=null==l?void 0: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){let t=Ye(f);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Xe(f.type,r,o))h++;else if(Xe(f.type,-r,o)){if(0==h){let t=Ye(f);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(r<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function er(t,e,r,n=0,i=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=i;for(let i=n;i<e;i++)9==t.charCodeAt(i)?s+=r-s%r:s++;return s}class rr{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(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,r=this.string.charAt(this.pos);if(e="string"==typeof t?r==t:r&&(t instanceof RegExp?t.test(r):t(r)),e)return++this.pos,r}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=er(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:er(this.string,null,this.tabSize)}match(t,e,r){if("string"==typeof t){let n=t=>r?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let r=this.string.slice(this.pos).match(t);return r&&r.index>0?null:(r&&!1!==e&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}}function nr(t){if("object"!=typeof t)return t;let e={};for(let r in t){let n=t[r];e[r]=n instanceof Array?n.slice():n}return e}const ir=new WeakMap;class sr extends Pt{constructor(t){let e,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};var i;super(r,new class extends K{createParse(t,r,n){return new ar(e,t,r,n)}},[Vt.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=A.define({id:ur.length,name:"Document",props:[At.add((()=>t))],top:!0});return ur.push(e),e}(r),e=this,this.streamParser=n,this.stateAfter=new w({perNode:!0}),this.tokenTable=t.tokenTable?new mr(n.tokenTable):br}static define(t){return new sr(t)}getIndent(t,e){let r,n=Ot(t.state),i=n.resolve(e);for(;i&&i.type!=this.topNode;)i=i.parent;if(!i)return null;let{overrideIndentation:s}=t.options;s&&(r=ir.get(t.state),null!=r&&r<e-1e4&&(r=void 0));let o,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)return null;for(;o<e;){let r=t.state.doc.lineAt(o),n=Math.min(e,r.to);if(r.length){let e=s?s(r.from):-1,i=new rr(r.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;i.pos<n-r.from;)hr(this.streamParser.token,i,l)}else this.streamParser.blankLine(l,t.unit);if(n==e)break;o=r.to+1}let h=t.lineAt(e);return s&&null==r&&ir.set(t.state,h.from),this.streamParser.indent(l,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function or(t,e,r,n,i){let s=r>=n&&r+e.length<=i&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:r+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=r+e.positions[s],a=o instanceof T&&l<i&&or(t,o,l,n,i);if(a)return a}return null}function lr(t,e,r,n,i){if(i&&r<=0&&n>=e.length)return e;i||e.type!=t.topNode||(i=!0);for(let s=e.children.length-1;s>=0;s--){let o,l=e.positions[s],a=e.children[s];if(l<n&&a instanceof T){if(!(o=lr(t,a,r-l,n-l,i)))break;return i?new T(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),l+o.length):o}}return null}class ar{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=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let i=Dt.get(),s=n[0].from,{state:o,tree:l}=function(t,e,r,n){for(let n of e){let e,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?void 0:i.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=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(){let t=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);return this.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){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=r)break;if(e=e.slice(0,n-(r-e.length)),t++,t==this.ranges.length)break;let i=this.ranges[t].from,s=this.lineAfter(i);e+=s,r=i+s.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){let n=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?n>i:n>=i)break;e+=this.ranges[++this.rangeIndex].from-n}return e}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);let t=this.chunk.length;r+=i=this.skipGapsTo(r,i,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,r,n),i}parseLine(t){let{line:e,end:r}=this.nextLine(),n=0,{streamParser:i}=this.lang,s=new rr(e,t?t.state.tabSize:4,t?$t(t.state):2);if(s.eol())i.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=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(){let t=T.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:cr,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new T(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=void 0,this.chunkStart=this.parsedPos}finish(){return new T(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function hr(t,e,r){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,r);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const fr=Object.create(null),ur=[A.none],cr=new C(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);class mr{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),gr)}resolve(t){return t?this.table[t]||(this.table[t]=kr(this.extra,t)):0}}const br=new mr(fr);function xr(t,e){dr.indexOf(t)>-1||(dr.push(t),console.warn(e))}function kr(t,e){let r=[];for(let n of e.split(" ")){let e=[];for(let r of n.split(".")){let n=t[r]||vt[r];n?"function"==typeof n?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(let t of e)r.push(t)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+r.map((t=>t.id)),s=pr[i];if(s)return s.id;let o=pr[i]=A.define({id:ur.length,name:n,props:[et({[n]:r})]});return ur.push(o),o.id}function yr(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function wr(t){for(let e=t.iter();!e.next().done;)if(yr(e.value))return!0;return!1}const vr=t.define({combine:t=>t.some((t=>t))});const Sr=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){let e=t.state.facet(vr)||t.view.textDirection!=g.LTR||t.state.facet(u.perLineTextDirection);if(e||this.hasRTL||!function(t){let e=!1;return t.iterChanges(((t,r,n,i,s)=>{!e&&wr(s)&&(e=!0)})),e}(t.changes)||(this.hasRTL=!0),!e&&!this.hasRTL)return;let r=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=>{function e(e){var r,n;return null!==(n=null===(r=e.plugin(t))||void 0===r?void 0:r.decorations)&&void 0!==n?n:c.none}return[u.outerDecorations.of(e),l.lowest(u.bidiIsolatedRanges.of(e))]}});function Ar(t,e,r){let n=new a,i=t.visibleRanges;r||(i=function(t,e){let r=e.iter(),n=0,i=[],s=null;for(let{from:e,to:o}of t)for(e!=n&&(n<e&&r.next(e-n),n=e);;){let t=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()}return i}(i,t.state.doc));for(let{from:t,to:r}of i)e.iterate({enter:t=>{let e=t.type.prop(w.isolate);e&&n.add(t.from,t.to,Cr[e])},from:t,to:r});return n.finish()}const Cr={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})};var Nr=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={}){let e=[Sr];return t.alwaysIsolate&&e.push(vr.of(!0)),e},bracketMatching:Ke,bracketMatchingHandle:Qe,codeFolding:Ne,continuedIndent:function({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.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){return t.field(de,!1)||s.empty},forceParsing:function(t,e=t.viewport.to,r=100){let n=Bt(t.state,e,r);return n!=Ot(t.state)&&t.dispatch({}),!!n},getIndentUnit:$t,getIndentation:Gt,highlightingFor:function(t,e,r){let n=Re(t),i=null;if(n)for(let t of n)if(!t.scope||r&&t.scope(r)){let r=t.style(e);r&&(i=i?i+" "+r:r)}return i},indentNodeProp:Kt,indentOnInput:ne,indentRange:function(t,e,r){let n=Object.create(null),i=new Jt(t,{overrideIndentation:t=>{var e;return null!==(e=n[t])&&void 0!==e?e:-1}}),s=[];for(let o=e;o<=r;){let e=t.doc.lineAt(o);o=e.to+1;let r=Gt(i,e.from);if(null==r)continue;/\S/.test(e.text)||(r=0);let l=/^\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}))}return t.changes(s)},indentService:Vt,indentString:Ht,indentUnit:qt,language:Wt,languageDataProp:At,matchBrackets:Ze,sublanguageProp:Nt,syntaxHighlighting:ze,syntaxParserRunning:function(t){var e;return(null===(e=t.plugin(jt))||void 0===e?void 0:e.isWorking())||!1},syntaxTree:Ot,syntaxTreeAvailable:function(t,e=t.doc.length){var r;return(null===(r=t.field(Pt.state,!1))||void 0===r?void 0:r.context.isDone(e))||!1},toggleFold:t=>{let e=[];for(let r of ce(t)){let n=pe(t.state,r.from,r.to);if(n)e.push(ue.of(n),ke(t,n,!1));else{let n=ve(t,r);n&&e.push(fe.of(n),ke(t,n))}}return e.length>0&&t.dispatch({effects:me(t.state,e)}),!!e.length},unfoldAll:we,unfoldCode:xe,unfoldEffect:ue});export{x as D,I,Tt as L,C as N,K as P,T,A as a,w as b,et as c,Kt as d,ee as e,se as f,oe as g,Ut as h,qt as i,G as j,_e as k,ne as l,ze as m,Ue as n,Ke as o,Se as p,Jt as q,Gt as r,Ot as s,vt as t,Ht as u,Ze as v,$t as w,Nr as x};
|
||
//# sourceMappingURL=codemirror_language-_XiX6II0.js.map
|