@streamline-pulse/formkrafter-wc 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +3 -3
  2. package/dist/components/fk-brick-render.js +1 -1
  3. package/dist/components/fk-code-editor.js +1 -1
  4. package/dist/components/fk-data-grid.js +1 -1
  5. package/dist/components/fk-file-input.js +1 -1
  6. package/dist/components/fk-form-builder.js +1 -1
  7. package/dist/components/fk-form-render.js +1 -1
  8. package/dist/components/fk-property-panel.js +1 -1
  9. package/dist/components/fk-rules-editor.js +1 -1
  10. package/dist/components/fk-select-input.js +1 -1
  11. package/dist/components/fk-stepper.js +1 -1
  12. package/dist/components/fk-tabs.js +1 -1
  13. package/dist/components/index.js +1 -1
  14. package/dist/components/p-38x7HHH5.js +12 -0
  15. package/dist/components/{p-tTJg_I4V.js → p-8ZeGXEsz.js} +1 -1
  16. package/dist/components/{p-CjnF4RZI.js → p-B7Wn62C3.js} +1 -1
  17. package/dist/components/{p-BpkKcCCr.js → p-B87l6fG8.js} +1 -1
  18. package/dist/components/{p-Bey6yx4S.js → p-CBWGephQ.js} +1 -1
  19. package/dist/components/{p-CeeVZgCr.js → p-ChORrvt0.js} +1 -1
  20. package/dist/{formkrafter-wc/p-CehxuHtl.js → components/p-CtXlkz3R.js} +1 -1
  21. package/dist/components/{p-C0Y8qh8R.js → p-CzZHZjz2.js} +1 -1
  22. package/dist/components/{p-tSZpD5I-.js → p-DRAcLQJd.js} +1 -1
  23. package/dist/components/p-DX8WH8Dt.js +1 -0
  24. package/dist/{formkrafter-wc/p-DlqnIm46.js → components/p-DZTNUdkF.js} +1 -1
  25. package/dist/components/{p-BietHxaT.js → p-Do6vaAvb.js} +1 -1
  26. package/dist/components/p-Ptnsxtwv.js +1 -0
  27. package/dist/components/{p-CIzLjMz0.js → p-YFczER4B.js} +1 -1
  28. package/dist/components/p-jUqF8CGO.js +1 -0
  29. package/dist/components/{p-_64WINOr.js → p-p20GeeQY.js} +1 -1
  30. package/dist/components/{p-BkqqQX6U.js → p-x9Ll7hS1.js} +1 -1
  31. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
  32. package/dist/formkrafter-wc/index.esm.js +1 -1
  33. package/dist/formkrafter-wc/p-7c143286.entry.js +1 -0
  34. package/dist/formkrafter-wc/p-C7yLpAp-.js +12 -0
  35. package/dist/{components/p-CehxuHtl.js → formkrafter-wc/p-CtXlkz3R.js} +1 -1
  36. package/dist/formkrafter-wc/{p-C0Y8qh8R.js → p-CzZHZjz2.js} +1 -1
  37. package/dist/{components/p-DlqnIm46.js → formkrafter-wc/p-DZTNUdkF.js} +1 -1
  38. package/dist/formkrafter-wc/{p-BietHxaT.js → p-Do6vaAvb.js} +1 -1
  39. package/dist/formkrafter-wc/{p-WWmY5Z05.js → p-NJy5rYft.js} +1 -1
  40. package/dist/formkrafter-wc/p-jUqF8CGO.js +1 -0
  41. package/package.json +8 -6
  42. package/dist/components/p-Bj48EXdM.js +0 -1
  43. package/dist/components/p-DwN4nM7G.js +0 -1
  44. package/dist/components/p-RzeBwfwG.js +0 -1
  45. package/dist/components/p-l7ULqDJ3.js +0 -12
  46. package/dist/formkrafter-wc/p-C5tYszq2.js +0 -12
  47. package/dist/formkrafter-wc/p-RzeBwfwG.js +0 -1
  48. package/dist/formkrafter-wc/p-bf962b94.entry.js +0 -1
@@ -1 +1 @@
1
- import{StateEffect as t,Facet as e,StateField as i,countColumn as r,EditorState as n,RangeSetBuilder as s,RangeSet as l,Prec as o,combineConfig as h}from"./p-DtcM1yw5.js";import{V as u,E as a,b as f,a as c,S as d,D as g,G as p,W as m,l as w}from"./p-RzeBwfwG.js";const b=1024;let k=0;class v{constructor(t,e){this.from=t,this.to=e}}class y{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")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=N.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}y.closedBy=new y({deserialize:t=>t.split(" ")}),y.openedBy=new y({deserialize:t=>t.split(" ")}),y.group=new y({deserialize:t=>t.split(" ")}),y.isolate=new y({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),y.contextHash=new y({perNode:!0}),y.lookAhead=new y({perNode:!0}),y.mounted=new y({perNode:!0});class x{constructor(t,e,i,r=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[y.mounted.id]}}const S=Object.create(null);class N{constructor(t,e,i,r=0){this.name=t,this.props=e,this.id=i,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):S,i=new N(t.name||"",e,t.id,(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0));if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(i)),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 i}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(y.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let r of i.split(" "))e[r]=t[i];return t=>{for(let i=t.prop(y.group),r=-1;r<(i?i.length:0);r++){let n=e[r<0?t.name:i[r]];if(n)return n}}}}N.none=new N("",Object.create(null),0,8);class M{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 i of this.types){let r=null;for(let e of t){let t=e(i);if(t){r||(r=Object.assign({},i.props));let e=t[1],n=t[0];n.combine&&n.id in r&&(e=n.combine(r[n.id],e)),r[n.id]=e}}e.push(r?new N(i.name,r,i.id,i.flags):i)}return new M(e)}}const C=new WeakMap,O=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",t[t.EnterBracketed=16]="EnterBracketed"}(I||(I={}));class A{constructor(t,e,i,r,n){if(this.type=t,this.children=e,this.positions=i,this.length=r,this.props=null,n&&n.length){this.props=Object.create(null);for(let[t,e]of n)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=x.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 q(this.topNode,t)}cursorAt(t,e=0,i=0){let r=C.get(this)||this.topNode,n=new q(r);return n.moveTo(t,e),C.set(this,n._tree),n}get topNode(){return new P(this,0,0,null)}resolve(t,e=0){let i=B(C.get(this)||this.topNode,t,e,!1);return C.set(this,i),i}resolveInner(t,e=0){let i=B(O.get(this)||this.topNode,t,e,!0);return O.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let r=t.resolveInner(e,i),n=null;for(let t=r instanceof P?r:r.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(n||(n=[r])).push(s.resolve(e,i)),t=s}else{let s=x.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let l=new P(s.tree,s.overlay[0].from+t.from,-1,t);(n||(n=[r])).push(B(l,e,i,!1))}}return n?$(n):r}(this,t,e)}iterate(t){let{enter:e,leave:i,from:r=0,to:n=this.length}=t,s=t.mode||0,l=(s&I.IncludeAnonymous)>0;for(let t=this.cursor(s|I.IncludeAnonymous);;){let s=!1;if(t.from<=n&&t.to>=r&&(!l&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(l||!t.type.isAnonymous)&&i(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:G(N.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new A(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new A(N.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:r,maxBufferLength:n=b,reused:s=[],minRepeatType:l=r.types.length}=t,o=Array.isArray(i)?new T(i,i.length):i,h=r.types,u=0,a=0;function f(t,e,i,m,w,b){let{id:k,start:v,end:x,size:S}=o,N=a,M=u;if(S<0){if(o.next(),-1==S)return i.push(s[k]),void m.push(v-t);if(-3==S)return void(u=k);if(-4==S)return void(a=k);throw new RangeError(`Unrecognized record size: ${S}`)}let C,O,I=h[k],T=v-t;if(x-v<=n&&(O=function(t,e){let i=o.fork(),r=0,s=0,h=0,u=i.end-n,a={size:0,start:0,skip:0};t:for(let n=i.pos-t;i.pos>n;){let t=i.size;if(i.id==e&&t>=0){a.size=r,a.start=s,a.skip=h,h+=4,r+=4,i.next();continue}let o=i.pos-t;if(t<0||o<n||i.start<u)break;let f=i.id>=l?4:0,c=i.start;for(i.next();i.pos>o;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;f+=4}else i.id>=l&&(f+=4);i.next()}s=c,r+=t,h+=f}return(e<0||r==t)&&(a.size=r,a.start=s,a.skip=h),a.size>4?a:void 0}(o.pos-e,w))){let e=new Uint16Array(O.size-O.skip),i=o.pos-O.size,n=e.length;for(;o.pos>i;)n=p(O.start,e,n);C=new D(e,x-O.start,r),T=O.start-t}else{let t=o.pos-S;o.next();let e=[],i=[],r=k>=l?k:-1,s=0,h=x;for(;o.pos>t;)r>=0&&o.id==r&&o.size>=0?(o.end<=h-n&&(d(e,i,v,s,o.end,h,r,N,M),s=e.length,h=o.end),o.next()):b>2500?c(v,t,e,i):f(v,t,e,i,r,b+1);if(r>=0&&s>0&&s<e.length&&d(e,i,v,s,v,h,r,N,M),e.reverse(),i.reverse(),r>-1&&s>0){let t=function(t,e){return(i,r,n)=>{let s,l,o=0,h=i.length-1;if(h>=0&&(s=i[h])instanceof A){if(!h&&s.type==t&&s.length==n)return s;(l=s.prop(y.lookAhead))&&(o=r[h]+s.length+l)}return g(t,i,r,n,o,e)}}(I,M);C=G(I,e,i,0,e.length,0,x-v,t,t)}else C=g(I,e,i,x-v,N-x,M)}i.push(C),m.push(T)}function c(t,e,i,s){let l=[],h=0,u=-1;for(;o.pos>e;){let{id:t,start:e,end:i,size:r}=o;if(r>4)o.next();else{if(u>-1&&e<u)break;u<0&&(u=i-n),l.push(t,e,i),h++,o.next()}}if(h){let e=new Uint16Array(4*h),n=l[l.length-2];for(let t=l.length-3,i=0;t>=0;t-=3)e[i++]=l[t],e[i++]=l[t+1]-n,e[i++]=l[t+2]-n,e[i++]=i;i.push(new D(e,l[2]-n,r)),s.push(n-t)}}function d(t,e,i,n,s,l,o,h,u){let a=[],f=[];for(;t.length>n;)a.push(t.pop()),f.push(e.pop()+i-s);t.push(g(r.types[o],a,f,l-s,h-l,u)),e.push(s-i)}function g(t,e,i,r,n,s,l){if(s){let t=[y.contextHash,s];l=l?[t].concat(l):[t]}if(n>25){let t=[y.lookAhead,n];l=l?[t].concat(l):[t]}return new A(t,e,i,r,l)}function p(t,e,i){let{id:r,start:n,end:s,size:h}=o;if(o.next(),h>=0&&r<l){let l=i;if(h>4){let r=o.pos-(h-4);for(;o.pos>r;)i=p(t,e,i)}e[--i]=l,e[--i]=s-t,e[--i]=n-t,e[--i]=r}else-3==h?u=r:-4==h&&(a=r);return i}let m=[],w=[];for(;o.pos>0;)f(t.start||0,t.bufferStart||0,m,w,-1,0);let k=null!==(e=t.length)&&void 0!==e?e:m.length?w[0]+m[0].length:0;return new A(h[t.topID],m.reverse(),w.reverse(),k)}(t)}}A.empty=new A(N.none,[],[],0);class T{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 T(this.buffer,this.index)}}class D{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return N.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+3],i=this.set.types[this.buffer[t]],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),e==(t+=4))return r;let n=[];for(;t<e;)n.push(this.childString(t)),t=this.buffer[t+3];return r+"("+n.join(",")+")"}findChild(t,e,i,r,n){let{buffer:s}=this,l=-1;for(let o=t;o!=e&&!(E(n,r,s[o+1],s[o+2])&&(l=o,i>0));o=s[o+3]);return l}slice(t,e,i){let r=this.buffer,n=new Uint16Array(e-t),s=0;for(let l=t,o=0;l<e;){n[o++]=r[l++],n[o++]=r[l++]-i;let e=n[o++]=r[l++]-i;n[o++]=r[l++]-t,s=Math.max(s,e)}return new D(n,s,this.set)}}function E(t,e,i,r){switch(t){case-2:return i<e;case-1:return r>=e&&i<e;case 0:return i<e&&r>e;case 1:return i<=e&&r>e;case 2:return r>e;case 4:return!0}}function B(t,e,i,r){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!r&&t instanceof P&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=r?0:I.IgnoreOverlays;if(r)for(let r=t,l=r.parent;l;r=l,l=r.parent)r instanceof P&&r.index<0&&(null===(n=l.enter(e,i,s))||void 0===n?void 0:n.from)!=r.from&&(t=l);for(;;){let r=t.enter(e,i,s);if(!r)return t;t=r}}class j{cursor(t=0){return new q(this,t)}getChild(t,e=null,i=null){let r=R(this,t,e,i);return r.length?r[0]:null}getChildren(t,e=null,i=null){return R(this,t,e,i)}resolve(t,e=0){return B(this,t,e,!1)}resolveInner(t,e=0){return B(this,t,e,!0)}matchContext(t){return L(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class P extends j{constructor(t,e,i,r){super(),this._tree=t,this.from=e,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,r,n=0){for(let s=this;;){for(let{children:l,positions:o}=s._tree,h=e>0?l.length:-1;t!=h;t+=e){let h,u=l[t],a=o[t]+s.from;if(n&I.EnterBracketed&&u instanceof A&&(h=x.get(u))&&!h.overlay&&h.bracketed&&i>=a&&i<=a+u.length||E(r,i,a,a+u.length))if(u instanceof D){if(n&I.ExcludeBuffers)continue;let l=u.findChild(0,u.buffer.length,e,i-a,r);if(l>-1)return new W(new z(s,u,t,a),null,l)}else if(n&I.IncludeAnonymous||!u.type.isAnonymous||F(u)){let l;if(!(n&I.IgnoreMounts)&&(l=x.get(u))&&!l.overlay)return new P(l.tree,a,t,s);let o=new P(u,a,t,s);return n&I.IncludeAnonymous||!o.type.isAnonymous?o:o.nextChild(e<0?u.children.length-1:0,e,i,r,n)}}if(n&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)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let r;if(!(i&I.IgnoreOverlays)&&(r=x.get(this._tree))&&r.overlay){let n=t-this.from,s=i&I.EnterBracketed&&r.bracketed;for(let{from:t,to:i}of r.overlay)if((e>0||s?t<=n:t<n)&&(e<0||s?i>=n:i>n))return new P(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function R(t,e,i,r){let n=t.cursor(),s=[];if(!n.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return s;for(;;){if(null!=r&&n.type.is(r))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return null==r?s:[]}}function L(t,e,i=e.length-1){for(let r=t;i>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}class z{constructor(t,e,i,r){this.parent=t,this.buffer=e,this.index=i,this.start=r}}class W extends j{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new W(this.context,this,n)}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)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&I.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new W(this.context,this,n)}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 W(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 W(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];return n>r&&(t.push(i.slice(r,n,i.buffer[this.index+1])),e.push(0)),new A(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function $(t){if(!t.length)return null;let e=0,i=t[0];for(let r=1;r<t.length;r++){let n=t[r];(n.from>i.from||n.to<i.to)&&(i=n,e=r)}let r=i instanceof P&&i.index<0?null:i.parent,n=t.slice();return r?n[e]=r:n.splice(e,1),new U(n,i)}class U{constructor(t,e){this.heads=t,this.node=e}get next(){return $(this.heads)}}class q{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~I.EnterBracketed,t instanceof P)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:i,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return!!t&&(t instanceof P?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,i);return!(n<0)&&(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&I.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}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,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+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<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<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,i,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(r.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=r)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let r=e+t,n=t<0?-1:i._tree.children.length;r!=n;r+=t){let t=i._tree.children[r];if(this.mode&I.IncludeAnonymous||t instanceof D||!t.type.isAnonymous||F(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,i=0;if(t&&t.context==this.buffer)t:for(let r=this.index,n=this.stack.length;n>=0;){for(let s=t;s;s=s._parent)if(s.index==r){if(r==this.index)return s;e=s,i=n+1;break t}r=this.stack[--n]}for(let t=i;t<this.stack.length;t++)e=new W(this.buffer,e,this.stack[t]);return this.bufferNode=new W(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let r=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(t){if(!this.buffer)return L(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let r=t.length-1,n=this.stack.length-1;r>=0;n--){if(n<0)return L(this._tree,t,r);let s=i[e.buffer[this.stack[n]]];if(!s.isAnonymous){if(t[r]&&t[r]!=s.name)return!1;r--}}return!0}}function F(t){return t.children.some((t=>t instanceof D||!t.type.isAnonymous||F(t)))}const H=new WeakMap;function J(t,e){if(!t.isAnonymous||e instanceof D||e.type!=t)return 1;let i=H.get(e);if(null==i){i=1;for(let r of e.children){if(r.type!=t||!(r instanceof A)){i=1;break}i+=J(t,r)}H.set(e,i)}return i}function G(t,e,i,r,n,s,l,o,h){let u=0;for(let i=r;i<n;i++)u+=J(t,e[i]);let a=Math.ceil(1.5*u/8),f=[],c=[];return function e(i,r,n,l,o){for(let u=n;u<l;){let n=u,d=r[u],g=J(t,i[u]);for(u++;u<l;u++){let e=J(t,i[u]);if(g+e>=a)break;g+=e}if(u==n+1){if(g>a){let t=i[n];e(t.children,t.positions,0,t.children.length,r[n]+o);continue}f.push(i[n])}else f.push(G(t,i,r,n,u,d,r[u-1]+i[u-1].length-d,null,h));c.push(d+o-s)}}(e,i,r,n,0),(o||h)(f,c,l)}class _{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof W?this.setBuffer(t.context.buffer,t.index,e):t instanceof P&&this.map.set(t.tree,e)}get(t){return t instanceof W?this.getBuffer(t.context.buffer,t.index):t instanceof P?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 K{constructor(t,e,i,r,n=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=r,this.open=(n?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let r=[new K(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&r.push(i);return r}static applyChanges(t,e,i=128){if(!e.length)return t;let r=[],n=1,s=t.length?t[0]:null;for(let l=0,o=0,h=0;;l++){let u=l<e.length?e[l]:null,a=u?u.fromA:1e9;if(a-o>=i)for(;s&&s.from<a;){let e=s;if(o>=e.from||a<=e.to||h){let t=Math.max(e.from,o)-h,i=Math.min(e.to,a)-h;e=t>=i?null:new K(t,i,e.tree,e.offset+h,l>0,!!u)}if(e&&r.push(e),s.to>a)break;s=n<t.length?t[n++]:null}if(!u)break;o=u.toA,h=u.toA-u.toB}return r}}class V{startParse(t,e,i){return"string"==typeof t&&(t=new Q(t)),i=i?i.length?i.map((t=>new v(t.from,t.to))):[new v(0,0)]:[new v(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let r=this.startParse(t,e,i);for(;;){let t=r.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 y({perNode:!0});let X=0;class Y{constructor(t,e,i,r){this.name=t,this.set=e,this.base=i,this.modified=r,this.id=X++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof Y&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let r=new Y(i,[],null,[]);if(r.set.push(r),e)for(let t of e.set)r.set.push(t);return r}static defineModifier(t){let e=new tt(t);return t=>t.modified.indexOf(e)>-1?t:tt.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let Z=0;class tt{constructor(t){this.name=t,this.instances=[],this.id=Z++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(r=e).length==(n=i.modified).length&&r.every(((t,e)=>t==n[e]));var r,n}));if(i)return i;let r=[],n=new Y(t.name,r,t,e);for(let t of e)t.instances.push(n);let s=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let r=0,n=e.length;r<n;r++)e.push(e[r].concat(t[i]));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)r.push(tt.get(e,t));return n}}function et(t){let e=Object.create(null);for(let i in t){let r=t[i];Array.isArray(r)||(r=[r]);for(let t of i.split(" "))if(t){let i=[],n=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){n=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!r)throw new RangeError("Invalid path: "+t);if(i.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),e+=r[0].length,e==t.length)break;let l=t[e++];if(e==t.length&&"!"==l){n=0;break}if("/"!=l)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let l=i.length-1,o=i[l];if(!o)throw new RangeError("Invalid path: "+t);let h=new rt(r,n,l>0?i.slice(0,l):null);e[o]=h.sort(e[o])}}return it.add(e)}const it=new y({combine(t,e){let i,r,n;for(;t||e;){if(!t||e&&t.depth>=e.depth?(n=e,e=e.next):(n=t,t=t.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let s=new rt(n.tags,n.mode,n.context);i?i.next=s:r=s,i=s}return r}});class rt{constructor(t,e,i,r){this.tags=t,this.mode=e,this.context=i,this.next=r}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 nt(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:r,all:n=null}=e||{};return{style:t=>{let e=n;for(let r of t)for(let t of r.set){let r=i[t.id];if(r){e=e?e+" "+r:r;break}}return e},scope:r}}function st(t,e,i,r=0,n=t.length){let s=new lt(r,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),r,n,"",s.highlighters),s.flush(n)}rt.empty=new rt([],2,null);class lt{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,r,n){let{type:s,from:l,to:o}=t;if(l>=i||o<=e)return;s.isTop&&(n=this.highlighters.filter((t=>!t.scope||t.scope(s))));let h=r,u=function(t){let e=t.type.prop(it);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||rt.empty,a=function(t,e){let i=null;for(let r of t){let t=r.style(e);t&&(i=i?i+" "+t:t)}return i}(n,u.tags);if(a&&(h&&(h+=" "),h+=a,1==u.mode&&(r+=(r?" ":"")+a)),this.startSpan(Math.max(e,l),h),u.opaque)return;let f=t.tree&&t.tree.prop(y.mounted);if(f&&f.overlay){let s=t.node.enter(f.overlay[0].from+l,1),u=this.highlighters.filter((t=>!t.scope||t.scope(f.tree.type))),a=t.firstChild();for(let c=0,d=l;;c++){let g=c<f.overlay.length?f.overlay[c]:null,p=g?g.from+l:o,m=Math.max(e,d),w=Math.min(i,p);if(m<w&&a)for(;t.from<w&&(this.highlightRange(t,m,w,r,n),this.startSpan(Math.min(w,t.to),h),!(t.to>=p)&&t.nextSibling()););if(!g||p>i)break;d=g.to+l,d>e&&(this.highlightRange(s.cursor(),Math.max(e,g.from+l),Math.min(i,d),"",u),this.startSpan(Math.min(i,d),h))}a&&t.parent()}else if(t.firstChild()){f&&(r="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,r,n),this.startSpan(Math.min(i,t.to),h)}}while(t.nextSibling());t.parent()}}}const ot=Y.define,ht=ot(),ut=ot(),at=ot(ut),ft=ot(ut),ct=ot(),dt=ot(ct),gt=ot(ct),pt=ot(),mt=ot(pt),wt=ot(),bt=ot(),kt=ot(),vt=ot(kt),yt=ot(),xt={comment:ht,lineComment:ot(ht),blockComment:ot(ht),docComment:ot(ht),name:ut,variableName:ot(ut),typeName:at,tagName:ot(at),propertyName:ft,attributeName:ot(ft),className:ot(ut),labelName:ot(ut),namespace:ot(ut),macroName:ot(ut),literal:ct,string:dt,docString:ot(dt),character:ot(dt),attributeValue:ot(dt),number:gt,integer:ot(gt),float:ot(gt),bool:ot(ct),regexp:ot(ct),escape:ot(ct),color:ot(ct),url:ot(ct),keyword:wt,self:ot(wt),null:ot(wt),atom:ot(wt),unit:ot(wt),modifier:ot(wt),operatorKeyword:ot(wt),controlKeyword:ot(wt),definitionKeyword:ot(wt),moduleKeyword:ot(wt),operator:bt,derefOperator:ot(bt),arithmeticOperator:ot(bt),logicOperator:ot(bt),bitwiseOperator:ot(bt),compareOperator:ot(bt),updateOperator:ot(bt),definitionOperator:ot(bt),typeOperator:ot(bt),controlOperator:ot(bt),punctuation:kt,separator:ot(kt),bracket:vt,angleBracket:ot(vt),squareBracket:ot(vt),paren:ot(vt),brace:ot(vt),content:pt,heading:mt,heading1:ot(mt),heading2:ot(mt),heading3:ot(mt),heading4:ot(mt),heading5:ot(mt),heading6:ot(mt),contentSeparator:ot(pt),list:ot(pt),quote:ot(pt),emphasis:ot(pt),strong:ot(pt),link:ot(pt),monospace:ot(pt),strikethrough:ot(pt),inserted:ot(),deleted:ot(),changed:ot(),invalid:ot(),meta:yt,documentMeta:ot(yt),annotation:ot(yt),processingInstruction:ot(yt),definition:Y.defineModifier("definition"),constant:Y.defineModifier("constant"),function:Y.defineModifier("function"),standard:Y.defineModifier("standard"),local:Y.defineModifier("local"),special:Y.defineModifier("special")};for(let t in xt){let e=xt[t];e instanceof Y&&(e.name=t)}var St;nt([{tag:xt.link,class:"tok-link"},{tag:xt.heading,class:"tok-heading"},{tag:xt.emphasis,class:"tok-emphasis"},{tag:xt.strong,class:"tok-strong"},{tag:xt.keyword,class:"tok-keyword"},{tag:xt.atom,class:"tok-atom"},{tag:xt.bool,class:"tok-bool"},{tag:xt.url,class:"tok-url"},{tag:xt.labelName,class:"tok-labelName"},{tag:xt.inserted,class:"tok-inserted"},{tag:xt.deleted,class:"tok-deleted"},{tag:xt.literal,class:"tok-literal"},{tag:xt.string,class:"tok-string"},{tag:xt.number,class:"tok-number"},{tag:[xt.regexp,xt.escape,xt.special(xt.string)],class:"tok-string2"},{tag:xt.variableName,class:"tok-variableName"},{tag:xt.local(xt.variableName),class:"tok-variableName tok-local"},{tag:xt.definition(xt.variableName),class:"tok-variableName tok-definition"},{tag:xt.special(xt.variableName),class:"tok-variableName2"},{tag:xt.definition(xt.propertyName),class:"tok-propertyName tok-definition"},{tag:xt.typeName,class:"tok-typeName"},{tag:xt.namespace,class:"tok-namespace"},{tag:xt.className,class:"tok-className"},{tag:xt.macroName,class:"tok-macroName"},{tag:xt.propertyName,class:"tok-propertyName"},{tag:xt.operator,class:"tok-operator"},{tag:xt.comment,class:"tok-comment"},{tag:xt.meta,class:"tok-meta"},{tag:xt.invalid,class:"tok-invalid"},{tag:xt.punctuation,class:"tok-punctuation"}]);const Nt=new y;function Mt(t){return e.define({combine:t?e=>e.concat(t):void 0})}const Ct=new y;class Ot{constructor(t,e,i=[],r=""){this.data=t,this.name=r,n.prototype.hasOwnProperty("tree")||Object.defineProperty(n.prototype,"tree",{get(){return Tt(this)}}),this.parser=e,this.extension=[$t.of(this),n.languageData.of(((t,e,i)=>{let r=It(t,e,i),n=r.type.prop(Nt);if(!n)return[];let s=t.facet(n),l=r.type.prop(Ct);if(l){let n=r.resolve(e-r.from,i);for(let e of l)if(e.test(n,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return It(t,e,i).type.prop(Nt)==this.data}findRegions(t){let e=t.facet($t);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],r=(t,e)=>{if(t.prop(Nt)==this.data)return void i.push({from:e,to:e+t.length});let n=t.prop(y.mounted);if(n){if(n.tree.prop(Nt)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(n.overlay){let t=i.length;if(r(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let n=t.children[i];n instanceof A&&r(n,t.positions[i]+e)}};return r(Tt(t),0),i}get allowsNesting(){return!0}}function It(t,e,i){let r=t.facet($t),n=Tt(t).topNode;if(!r||r.allowsNesting)for(let t=n;t;t=t.enter(e,i,I.ExcludeBuffers|I.EnterBracketed))t.type.isTop&&(n=t);return n}Ot.setState=t.define();class At extends Ot{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Mt(t.languageData);return new At(e,t.parser.configure({props:[Nt.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new At(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Tt(t){let e=t.field(Ot.state,!1);return e?e.tree:A.empty}function Dt(t,e,i=50){var r;let n=null===(r=t.field(Ot.state,!1))||void 0===r?void 0:r.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:e});let l=n.isDone(e)||n.work(i,e)?n.tree:null;return n.updateViewport(s),l}class Et{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Bt=null;class jt{constructor(t,e,i=[],r,n,s,l,o){this.parser=t,this.state=e,this.fragments=i,this.tree=r,this.treeLen=n,this.viewport=s,this.skipped=l,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new jt(t,e,[],A.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Et(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=A.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;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 r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(K.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=r,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(K.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Bt;Bt=this;try{return t()}finally{Bt=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Pt(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:r,treeLen:n,viewport:s,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,r,n)=>e.push({fromA:t,toA:i,fromB:r,toB:n}))),i=K.applyChanges(i,e),r=A.empty,n=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){l=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);i<r&&l.push({from:i,to:r})}}}return new jt(this.parser,e,i,r,n,s,l,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:i,to:r}=this.skipped[e];i<t.to&&r>t.from&&(this.fragments=Pt(this.fragments,i,r),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 V{createParse(e,i,r){let n=r[0].from,s=r[r.length-1].to;return{parsedPos:n,advance(){let e=Bt;if(e){for(let t of r)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new A(N.none,[],[],s-n)},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 Bt}}function Pt(t,e,i){return K.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Rt{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Rt(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=jt.create(t.facet($t).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Rt(i)}}Ot.state=i.define({create:Rt.init,update(t,e){for(let t of e.effects)if(t.is(Ot.setState))return t.value;return e.startState.facet($t)!=e.state.facet($t)?Rt.init(e.state):t.apply(e)}});let Lt=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Lt=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const zt="undefined"!=typeof navigator&&(null===(St=navigator.scheduling)||void 0===St?void 0:St.isInputPending)?()=>navigator.scheduling.isInputPending():null,Wt=u.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(Ot.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(Ot.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Lt(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:i,viewport:{to:r}}=this.view,n=i.field(Ot.state);if(n.tree==n.context.tree&&n.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!zt?Math.max(25,t.timeRemaining()-5):1e9),l=n.context.treeLen<r&&i.doc.length>r+1e3,o=n.context.work((()=>zt&&zt()||Date.now()>s),r+(l?0:1e5));this.chunkBudget-=Date.now()-e,(o||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:Ot.setState.of(new Rt(n.context))})),this.chunkBudget>0&&(!o||l)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>w(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()}}}),$t=e.define({combine:t=>t.length?t[0]:null,enables:t=>[Ot.state,Wt,a.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class Ut{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class qt{constructor(t,e,i,r,n,s){this.name=t,this.alias=e,this.extensions=i,this.filename=r,this.loadFunc=n,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:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new qt(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let i of t)if(i.filename&&i.filename.test(e))return i;let i=/\.([^.]+)$/.exec(e);if(i)for(let e of t)if(e.extensions.indexOf(i[1])>-1)return e;return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let i of t)if(i.alias.some((t=>t==e)))return i;if(i)for(let i of t)for(let t of i.alias){let r=e.indexOf(t);if(r>-1&&(t.length>2||!/\w/.test(e[r-1])&&!/\w/.test(e[r+t.length])))return i}return null}}const Ft=e.define(),Ht=e.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 Jt(t){let e=t.facet(Ht);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Gt(t,e){let i="",r=t.tabSize,n=t.facet(Ht)[0];if("\t"==n){for(;e>=r;)i+="\t",e-=r;n=" "}for(let t=0;t<e;t++)i+=n;return i}function _t(t,e){t instanceof n&&(t=new Kt(t));for(let i of t.state.facet(Ft)){let r=i(t,e);if(void 0!==r)return r}let i=Tt(t.state);return i.length>=e?function(t,e,i){let r=e.resolveStack(i),n=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(n!=r.node){let t=[];for(let e=n;e&&!(e.from<r.node.from||e.to>r.node.to||e.from==r.node.from&&e.type==r.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)r={node:t[e],next:r}}return Qt(r,t,i)}(t,i,e):null}class Kt{constructor(t,e={}){this.state=t,this.options=e,this.unit=Jt(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:n}=this.options;return null!=r&&r>=i.from&&r<=i.to?n&&r==t?{text:"",from:t}:(e<0?r<t:r<=t)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(t,e);return i.slice(t-r,Math.min(i.length,t+100-r))}column(t,e=1){let{text:i,from:r}=this.lineAt(t,e),n=this.countColumn(i,t-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(n+=s-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return r(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:r}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let t=n(r);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vt=new y;function Qt(t,e,i){for(let r=t;r;r=r.next){let t=Xt(r.node);if(t)return t(Zt.create(e,i,r))}return 0}function Xt(t){let e=t.type.prop(Vt);if(e)return e;let i,r=t.firstChild;if(r&&(i=r.type.prop(y.closedBy))){let e=t.lastChild,r=e&&i.indexOf(e.name)>-1;return t=>ie(t,!0,1,void 0,r&&!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 Kt{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Zt(t,e,i)}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 i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(te(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Qt(this.context.next,this.base,this.pos)}}function te(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function ee({closing:t,align:e=!0,units:i=1}){return r=>ie(r,e,i,t)}function ie(t,e,i,r,n){let s=t.textAfter,l=s.match(/^\s*/)[0].length,o=r&&s.slice(l,l+r.length)==r||n==t.pos+l,h=e?function(t){let e=t.node,i=e.childAfter(e.from),r=e.lastChild;if(!i)return null;let n=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),l=null==n||n<=s.from?s.to:Math.min(s.to,n);for(let t=i.to;;){let n=e.childAfter(t);if(!n||n==r)return null;if(!n.type.isSkipped){if(n.from>=l)return null;let t=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+t}}t=n.to}}(t):null;return h?t.column(o?h.from:h.to):t.baseIndent+(o?0:t.unit*i)}const re=t=>t.baseIndent;function ne({except:t,units:e=1}={}){return i=>{let r=t&&t.test(i.textAfter);return i.baseIndent+(r?0:e*i.unit)}}const se=e.define(),le=new y;function oe(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function he(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function ue(t,e,i){for(let r of t.facet(se)){let n=r(t,e,i);if(n)return n}return function(t,e,i){let r=Tt(t);if(r.length<i)return null;let n=null;for(let s=r.resolveStack(i,1);s;s=s.next){let l=s.node;if(l.to<=i||l.from>i)continue;if(n&&l.from<e)break;let o=l.type.prop(le);if(o&&(l.to<r.length-50||r.length==t.doc.length||!he(l))){let r=o(l,t);r&&r.from<=i&&r.from>=e&&r.to>i&&(n=r)}}return n}(t,e,i)}function ae(t,e){let i=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return i>=r?void 0:{from:i,to:r}}const fe=t.define({map:ae}),ce=t.define({map:ae});function de(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some((t=>t.from<=i&&t.to>=i))||e.push(t.lineBlockAt(i));return e}const ge=i.define({create:()=>c.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges(((e,i)=>t=pe(t,e,i))),t=t.map(e.changes);let i=[];for(let r of e.effects)r.is(fe)&&!we(t,r.value.from,r.value.to)?i.push(r.value):r.is(ce)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));if(i.length){let{preparePlaceholder:r}=e.state.facet(Oe),n=i.map((t=>(r?c.replace({widget:new De(r(e.state,t))}):Te).range(t.from,t.to)));t=t.update({add:n})}return e.selection&&(t=pe(t,e.selection.main.head)),t},provide:t=>a.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,((t,e)=>{i.push(t,e)})),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let r=t[i++],n=t[i++];if("number"!=typeof r||"number"!=typeof n)throw new RangeError("Invalid JSON for fold state");e.push(Te.range(r,n))}return c.set(e,!0)}});function pe(t,e,i=e){let r=!1;return t.between(e,i,((t,n)=>{t<i&&n>e&&(r=!0)})),r?t.update({filterFrom:e,filterTo:i,filter:(t,r)=>t>=i||r<=e}):t}function me(t,e,i){var r;let n=null;return null===(r=t.field(ge,!1))||void 0===r||r.between(e,i,((t,e)=>{(!n||n.from>t)&&(n={from:t,to:e})})),n}function we(t,e,i){let r=!1;return t.between(e,e,((t,n)=>{t==e&&n==i&&(r=!0)})),r}function be(e,i){return e.field(ge,!1)?i:i.concat(t.appendConfig.of(Ie()))}const ke=t=>{for(let e of de(t)){let i=ue(t.state,e.from,e.to);if(i)return t.dispatch({effects:be(t.state,[fe.of(i),ye(t,i)])}),!0}return!1},ve=t=>{if(!t.state.field(ge,!1))return!1;let e=[];for(let i of de(t)){let r=me(t.state,i.from,i.to);r&&e.push(ce.of(r),ye(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function ye(t,e,i=!0){let r=t.state.doc.lineAt(e.from).number,n=t.state.doc.lineAt(e.to).number;return a.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${n}.`)}const xe=t=>{let{state:e}=t,i=[];for(let r=0;r<e.doc.length;){let n=t.lineBlockAt(r),s=ue(e,n.from,n.to);s&&i.push(fe.of(s)),r=(s?t.lineBlockAt(s.to):n).to+1}return i.length&&t.dispatch({effects:be(t.state,i)}),!!i.length},Se=t=>{let e=t.state.field(ge,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push(ce.of({from:t,to:e}))})),t.dispatch({effects:i}),!0};function Ne(t,e){for(let i=e;;){let r=ue(t.state,i.from,i.to);if(r&&r.to>e.from)return r;if(!i.from)return null;i=t.lineBlockAt(i.from-1)}}const Me=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:ke},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ve},{key:"Ctrl-Alt-[",run:xe},{key:"Ctrl-Alt-]",run:Se}],Ce={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Oe=e.define({combine:t=>h(t,Ce)});function Ie(t){let e=[ge,je];return t&&e.push(Oe.of(t)),e}function Ae(t,e){let{state:i}=t,r=i.facet(Oe),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),r=me(t.state,i.from,i.to);r&&t.dispatch({effects:ce.of(r)}),e.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,n,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const Te=c.replace({widget:new class extends m{toDOM(t){return Ae(t,null)}}});class De extends m{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ae(t,this.value)}}const Ee={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Be extends p{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}}const je=a.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 Pe{constructor(t,e){let i;function r(t){let e=d.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const n="string"==typeof e.all?e.all:e.all?r(e.all):void 0,s=e.scope;this.scope=s instanceof Ot?t=>t.prop(Nt)==s.data:s?t=>t==s:void 0,this.style=nt(t.map((t=>({tag:t.tag,class:t.class||r(Object.assign({},t,{tag:null}))}))),{all:n}).style,this.module=i?new d(i):null,this.themeType=e.themeType}static define(t,e){return new Pe(t,e||{})}}const Re=e.define(),Le=e.define({combine:t=>t.length?[t[0]]:null});function ze(t){let e=t.facet(Re);return e.length?e:t.facet(Le)}function We(t,e){let i,r=[Ue];return t instanceof Pe&&(t.module&&r.push(a.styleModule.of(t.module)),i=t.themeType),r.push((null==e?void 0:e.fallback)?Le.of(t):i?Re.computeN([a.darkTheme],(e=>e.facet(a.darkTheme)==("dark"==i)?[t]:[])):Re.of(t)),r}class $e{constructor(t){this.markCache=Object.create(null),this.tree=Tt(t.state),this.decorations=this.buildDeco(t,ze(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Tt(t.state),i=ze(t.state),r=i!=ze(t.startState),{viewport:n}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!r&&e.type==this.tree.type&&s>=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||r)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return c.none;let i=new s;for(let{from:r,to:n}of t.visibleRanges)st(this.tree,e,((t,e,r)=>{i.add(t,e,this.markCache[r]||(this.markCache[r]=c.mark({class:r})))}),r,n);return i.finish()}}const Ue=o.high(u.fromClass($e,{decorations:t=>t.decorations})),qe=Pe.define([{tag:xt.meta,color:"#404740"},{tag:xt.link,textDecoration:"underline"},{tag:xt.heading,textDecoration:"underline",fontWeight:"bold"},{tag:xt.emphasis,fontStyle:"italic"},{tag:xt.strong,fontWeight:"bold"},{tag:xt.strikethrough,textDecoration:"line-through"},{tag:xt.keyword,color:"#708"},{tag:[xt.atom,xt.bool,xt.url,xt.contentSeparator,xt.labelName],color:"#219"},{tag:[xt.literal,xt.inserted],color:"#164"},{tag:[xt.string,xt.deleted],color:"#a11"},{tag:[xt.regexp,xt.escape,xt.special(xt.string)],color:"#e40"},{tag:xt.definition(xt.variableName),color:"#00f"},{tag:xt.local(xt.variableName),color:"#30a"},{tag:[xt.typeName,xt.namespace],color:"#085"},{tag:xt.className,color:"#167"},{tag:[xt.special(xt.variableName),xt.macroName],color:"#256"},{tag:xt.definition(xt.propertyName),color:"#00c"},{tag:xt.comment,color:"#940"},{tag:xt.invalid,color:"#f00"}]),Fe=a.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),He="()[]{}",Je=e.define({combine:t=>h(t,{afterCursor:!0,brackets:He,maxScanDistance:1e4,renderMatch:Ke})}),Ge=c.mark({class:"cm-matchingBracket"}),_e=c.mark({class:"cm-nonmatchingBracket"});function Ke(t){let e=[],i=t.matched?Ge:_e;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}function Ve(t){let e=[],i=t.facet(Je);for(let r of t.selection.ranges){if(!r.empty)continue;let n=ti(t,r.head,-1,i)||r.head>0&&ti(t,r.head-1,1,i)||i.afterCursor&&(ti(t,r.head,1,i)||r.head<t.doc.length&&ti(t,r.head+1,-1,i));n&&(e=e.concat(i.renderMatch(n,t)))}return c.set(e,!0)}const Qe=[u.fromClass(class{constructor(t){this.paused=!1,this.decorations=Ve(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Ve(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Fe],Xe=new y;function Ye(t,e,i){let r=t.prop(e<0?y.openedBy:y.closedBy);if(r)return r;if(1==t.name.length){let r=i.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[i[r+e]]}return null}function Ze(t){let e=t.type.prop(Xe);return e?e(t.node):t}function ti(t,e,i,r={}){let n=r.maxScanDistance||1e4,s=r.brackets||He,l=Tt(t),o=l.resolveInner(e,i);for(let t=o;t;t=t.parent){let r=Ye(t.type,i,s);if(r&&t.from<t.to){let n=Ze(t);if(n&&(i>0?e>=n.from&&e<n.to:e>n.from&&e<=n.to))return ei(0,0,i,t,n,r,s)}}return function(t,e,i,r,n,s,l){if(i<0?!e:e==t.doc.length)return null;let o=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=l.indexOf(o);if(h<0||h%2==0!=i>0)return null;let u={from:i<0?e-1:e,to:i>0?e+1:e},a=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!a.next().done&&t<=s;){let s=a.value;i<0&&(t+=s.length);let o=e+t*i;for(let t=i>0?0:s.length-1,e=i>0?s.length:-1;t!=e;t+=i){let e=l.indexOf(s[t]);if(!(e<0||r.resolveInner(o+t,1).type!=n))if(e%2==0==i>0)f++;else{if(1==f)return{start:u,end:{from:o+t,to:o+t+1},matched:e>>1==h>>1};f--}}i>0&&(t+=s.length)}return a.done?{start:u,matched:!1}:null}(t,e,i,l,o.type,n,s)}function ei(t,e,i,r,n,s,l){let o=r.parent,h={from:n.from,to:n.to},u=0,a=null==o?void 0:o.cursor();if(a&&(i<0?a.childBefore(r.from):a.childAfter(r.to)))do{if(i<0?a.to<=r.from:a.from>=r.to){if(0==u&&s.indexOf(a.type.name)>-1&&a.from<a.to){let t=Ze(a);return{start:h,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Ye(a.type,i,l))u++;else if(Ye(a.type,-i,l)){if(0==u){let t=Ze(a);return{start:h,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}u--}}}while(i<0?a.prevSibling():a.nextSibling());return{start:h,matched:!1}}function ii(t,e,i,r=0,n=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=n;for(let n=r;n<e;n++)9==t.charCodeAt(n)?s+=i-s%i:s++;return s}class ri{constructor(t,e,i,r){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=r,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,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}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=ii(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:ii(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let r=t=>i?t.toLowerCase():t;return r(this.string.substr(this.pos,t.length))==r(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function ni(t){if("object"!=typeof t)return t;let e={};for(let i in t){let r=t[i];e[i]=r instanceof Array?r.slice():r}return e}const si=new WeakMap;class li extends Ot{constructor(t){let e,i=Mt(t.languageData),r={name:(n=t).name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||ni,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||fi,mergeTokens:!1!==n.mergeTokens};var n;super(i,new class extends V{createParse(t,i,r){return new ui(e,t,i,r)}},[],t.name),this.topNode=function(t,e){let i=N.define({id:ci.length,name:"Document",props:[Nt.add((()=>t)),Vt.add((()=>t=>e.getIndent(t)))],top:!0});return ci.push(i),i}(i,this),e=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new wi(r.tokenTable):bi}static define(t){return new li(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=si.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let r,n,s=oi(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(s?(n=s.state,r=s.pos+1):(n=this.streamParser.startState(t.unit),r=t.node.from),t.pos-r>1e4)return null;for(;r<t.pos;){let e=t.state.doc.lineAt(r),s=Math.min(t.pos,e.to);if(e.length){let r=i?i(e.from):-1,l=new ri(e.text,t.state.tabSize,t.unit,r<0?void 0:r);for(;l.pos<s-e.from;)ai(this.streamParser.token,l,n)}else this.streamParser.blankLine(n,t.unit);if(s==t.pos)break;r=e.to+1}let l=t.lineAt(t.pos);return i&&null==e&&si.set(t.state,l.from),this.streamParser.indent(n,/^\s*(.*)/.exec(l.text)[1],t)}get allowsNesting(){return!1}}function oi(t,e,i,r,n){let s=i>=r&&i+e.length<=n&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let s=e.children.length-1;s>=0;s--){let l=e.children[s],o=i+e.positions[s],h=l instanceof A&&o<n&&oi(t,l,o,r,n);if(h)return h}return null}function hi(t,e,i,r,n){if(n&&i<=0&&r>=e.length)return e;n||0!=i||e.type!=t.topNode||(n=!0);for(let s=e.children.length-1;s>=0;s--){let l,o=e.positions[s],h=e.children[s];if(o<r&&h instanceof A){if(!(l=hi(t,h,i-o,r-o,n)))break;return n?new A(e.type,e.children.slice(0,s).concat(l),e.positions.slice(0,s+1),o+l.length):l}}return null}class ui{constructor(t,e,i,r){this.lang=t,this.input=e,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let n=jt.get(),s=r[0].from,{state:l,tree:o}=function(t,e,i,r,n){for(let n of e){let e,s=n.to-(n.openEnd?25:0),l=n.from+(n.openStart?25:0)<=i&&s>i&&oi(t,n.tree,0-n.offset,i,s);if(l&&l.pos<=r&&(e=hi(t,n.tree,i+n.offset,l.pos+n.offset,!1)))return{state:l.state,tree:e}}return{state:t.streamParser.startState(n?Jt(n):4),tree:A.empty}}(t,i,s,this.to,null==n?void 0:n.state);this.state=l,this.parsedPos=this.chunkStart=s+o.length;for(let t=0;t<o.children.length;t++)this.chunks.push(o.children[t]),this.chunkPos.push(o.positions[t]);n&&this.parsedPos<n.viewport.from-1e5&&r.some((t=>t.from<=n.viewport.from&&t.to>=n.viewport.from))&&(this.state=this.lang.streamParser.startState(Jt(n.state)),n.skipUntilInView(this.parsedPos,n.viewport.from),this.parsedPos=n.viewport.from),this.moveRangeIndex()}advance(){let t=jt.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+512);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)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),i=t+e.length;for(let t=this.rangeIndex;;){let r=this.ranges[t].to;if(r>=i)break;if(e=e.slice(0,r-(i-e.length)),t++,t==this.ranges.length)break;let n=this.ranges[t].from,s=this.lineAfter(n);e+=s,i=n+s.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let r=this.ranges[this.rangeIndex].to,n=t+e;if(i>0?r>n:r>=n)break;e+=this.ranges[++this.rangeIndex].from-r}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,r){let n=4;if(this.ranges.length>1){e+=r=this.skipGapsTo(e,r,1);let t=this.chunk.length;i+=r=this.skipGapsTo(i,r,-1),n+=this.chunk.length-t}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==n&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==e?this.chunk[s+2]=i:this.chunk.push(t,e,i,n),r}parseLine(t){let{line:e,end:i}=this.nextLine(),r=0,{streamParser:n}=this.lang,s=new ri(e,t?t.state.tabSize:4,t?Jt(t.state):2);if(s.eol())n.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=ai(n.token,s,this.state);if(t&&(r=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,r)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=A.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:di,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new A(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 A(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function ai(t,e,i){e.start=e.pos;for(let r=0;r<10;r++){let r=t(e,i);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}const fi=Object.create(null),ci=[N.none],di=new M(ci),gi=[],pi=Object.create(null),mi=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"]])mi[t]=vi(fi,e);class wi{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),mi)}resolve(t){return t?this.table[t]||(this.table[t]=vi(this.extra,t)):0}}const bi=new wi(fi);function ki(t,e){gi.indexOf(t)>-1||(gi.push(t),console.warn(e))}function vi(t,e){let i=[];for(let r of e.split(" ")){let e=[];for(let i of r.split(".")){let r=t[i]||xt[i];r?"function"==typeof r?e.length?e=e.map(r):ki(i,`Modifier ${i} used at start of tag`):e.length?ki(i,`Tag ${i} used as modifier`):e=Array.isArray(r)?r:[r]:ki(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let r=e.replace(/ /g,"_"),n=r+" "+i.map((t=>t.id)),s=pi[n];if(s)return s.id;let l=pi[n]=N.define({id:ci.length,name:r,props:[et({[r]:i})]});return ci.push(l),l.id}function yi(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function xi(t){for(let e=t.iter();!e.next().done;)if(yi(e.value))return!0;return!1}const Si=e.define({combine:t=>t.some((t=>t))}),Ni=u.fromClass(class{constructor(t){this.always=t.state.facet(Si)||t.textDirection!=g.LTR||t.state.facet(a.perLineTextDirection),this.hasRTL=!this.always&&xi(t.state.doc),this.tree=Tt(t.state),this.decorations=this.always||this.hasRTL?Mi(t,this.tree,this.always):c.none}update(t){let e=t.state.facet(Si)||t.view.textDirection!=g.LTR||t.state.facet(a.perLineTextDirection);if(e||this.hasRTL||!function(t){let e=!1;return t.iterChanges(((t,i,r,n,s)=>{!e&&xi(s)&&(e=!0)})),e}(t.changes)||(this.hasRTL=!0),!e&&!this.hasRTL)return;let i=Tt(t.state);(e!=this.always||i!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=i,this.always=e,this.decorations=Mi(t.view,i,e))}},{provide:t=>{function e(e){var i,r;return null!==(r=null===(i=e.plugin(t))||void 0===i?void 0:i.decorations)&&void 0!==r?r:c.none}return[a.outerDecorations.of(e),o.lowest(a.bidiIsolatedRanges.of(e))]}});function Mi(t,e,i){let r=new s,n=t.visibleRanges;i||(n=function(t,e){let i=e.iter(),r=0,n=[],s=null;for(let{from:e,to:l}of t)if(!(s&&s.to>e&&(e=s.to,e>=l)))for(r+i.value.length<e&&(i.next(e-(r+i.value.length)),r=e);;){let t=r,e=r+i.value.length;if(!i.lineBreak&&yi(i.value)&&(s&&s.to>t-10?s.to=Math.min(l,e):n.push(s={from:t,to:Math.min(l,e)})),e>=l)break;r=e,i.next()}return n}(n,t.state.doc));for(let{from:t,to:i}of n)e.iterate({enter:t=>{let e=t.type.prop(y.isolate);e&&r.add(t.from,t.to,Ci[e])},from:t,to:i});return r.finish()}const Ci={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 Oi=Object.freeze({__proto__:null,DocInput:Et,HighlightStyle:Pe,IndentContext:Kt,LRLanguage:At,Language:Ot,LanguageDescription:qt,LanguageSupport:Ut,ParseContext:jt,StreamLanguage:li,StringStream:ri,TreeIndentContext:Zt,bidiIsolates:function(t={}){let e=[Ni];return t.alwaysIsolate&&e.push(Si.of(!0)),e},bracketMatching:function(t={}){return[Je.of(t),Qe]},bracketMatchingHandle:Xe,codeFolding:Ie,continuedIndent:ne,defaultHighlightStyle:qe,defineLanguageFacet:Mt,delimitedIndent:ee,ensureSyntaxTree:Dt,flatIndent:re,foldAll:xe,foldCode:ke,foldEffect:fe,foldGutter:function(t={}){let e={...Ee,...t},i=new Be(e,!0),r=new Be(e,!1),n=u.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet($t)!=t.state.facet($t)||t.startState.field(ge,!1)!=t.state.field(ge,!1)||Tt(t.startState)!=Tt(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new s;for(let n of t.viewportLineBlocks){let s=me(t.state,n.from,n.to)?r:ue(t.state,n.from,n.to)?i:null;s&&e.add(n.from,n.from,s)}return e.finish()}}),{domEventHandlers:o}=e;return[n,f({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.markers)||l.empty},initialSpacer:()=>new Be(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let r=me(t.state,e.from,e.to);if(r)return t.dispatch({effects:ce.of(r)}),!0;let n=ue(t.state,e.from,e.to);return!!n&&(t.dispatch({effects:fe.of(n)}),!0)}}}),Ie()]},foldInside:oe,foldKeymap:Me,foldNodeProp:le,foldService:se,foldState:ge,foldable:ue,foldedRanges:function(t){return t.field(ge,!1)||l.empty},forceParsing:function(t,e=t.viewport.to,i=100){let r=Dt(t.state,e,i);return r!=Tt(t.state)&&t.dispatch({}),!!r},getIndentUnit:Jt,getIndentation:_t,highlightingFor:function(t,e,i){let r=ze(t),n=null;if(r)for(let t of r)if(!t.scope||i&&t.scope(i)){let i=t.style(e);i&&(n=n?n+" "+i:i)}return n},indentNodeProp:Vt,indentOnInput:function(){return n.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 i=t.newDoc,{head:r}=t.newSelection.main,n=i.lineAt(r);if(r>n.from+200)return t;let s=i.sliceString(n.from,r);if(!e.some((t=>t.test(s))))return t;let{state:l}=t,o=-1,h=[];for(let{head:t}of l.selection.ranges){let e=l.doc.lineAt(t);if(e.from==o)continue;o=e.from;let i=_t(l,e.from);if(null==i)continue;let r=/^\s*/.exec(e.text)[0],n=Gt(l,i);r!=n&&h.push({from:e.from,to:e.from+r.length,insert:n})}return h.length?[t,{changes:h,sequential:!0}]:t}))},indentRange:function(t,e,i){let r=Object.create(null),n=new Kt(t,{overrideIndentation:t=>{var e;return null!==(e=r[t])&&void 0!==e?e:-1}}),s=[];for(let l=e;l<=i;){let e=t.doc.lineAt(l);l=e.to+1;let i=_t(n,e.from);if(null==i)continue;/\S/.test(e.text)||(i=0);let o=/^\s*/.exec(e.text)[0],h=Gt(t,i);o!=h&&(r[e.from]=i,s.push({from:e.from,to:e.from+o.length,insert:h}))}return t.changes(s)},indentService:Ft,indentString:Gt,indentUnit:Ht,language:$t,languageDataProp:Nt,matchBrackets:ti,sublanguageProp:Ct,syntaxHighlighting:We,syntaxParserRunning:function(t){var e;return(null===(e=t.plugin(Wt))||void 0===e?void 0:e.isWorking())||!1},syntaxTree:Tt,syntaxTreeAvailable:function(t,e=t.doc.length){var i;return(null===(i=t.field(Ot.state,!1))||void 0===i?void 0:i.context.isDone(e))||!1},toggleFold:t=>{let e=[];for(let i of de(t)){let r=me(t.state,i.from,i.to);if(r)e.push(ce.of(r),ye(t,r,!1));else{let r=Ne(t,i);r&&e.push(fe.of(r),ye(t,r))}}return e.length>0&&t.dispatch({effects:be(t.state,e)}),!!e.length},unfoldAll:Se,unfoldCode:ve,unfoldEffect:ce});export{b as D,Pe as H,Kt as I,At as L,y as N,V as P,A as T,Jt as a,Ht as b,We as c,M as d,N as e,I as f,_t as g,et as h,Gt as i,Ut as j,Vt as k,le as l,ti as m,ne as n,ee as o,re as p,oe as q,Ct as r,Tt as s,xt as t,Mt as u,_ as v,Oi as w}
1
+ import{StateEffect as t,Facet as e,StateField as i,countColumn as r,EditorState as n,RangeSetBuilder as s,RangeSet as l,Prec as o,combineConfig as h}from"./p-DtcM1yw5.js";import{V as u,E as a,b as f,a as c,S as d,D as g,G as p,W as m,l as w}from"./p-jUqF8CGO.js";const b=1024;let k=0;class v{constructor(t,e){this.from=t,this.to=e}}class y{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")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=N.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}y.closedBy=new y({deserialize:t=>t.split(" ")}),y.openedBy=new y({deserialize:t=>t.split(" ")}),y.group=new y({deserialize:t=>t.split(" ")}),y.isolate=new y({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),y.contextHash=new y({perNode:!0}),y.lookAhead=new y({perNode:!0}),y.mounted=new y({perNode:!0});class x{constructor(t,e,i,r=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[y.mounted.id]}}const S=Object.create(null);class N{constructor(t,e,i,r=0){this.name=t,this.props=e,this.id=i,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):S,i=new N(t.name||"",e,t.id,(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0));if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(i)),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 i}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(y.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let r of i.split(" "))e[r]=t[i];return t=>{for(let i=t.prop(y.group),r=-1;r<(i?i.length:0);r++){let n=e[r<0?t.name:i[r]];if(n)return n}}}}N.none=new N("",Object.create(null),0,8);class M{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 i of this.types){let r=null;for(let e of t){let t=e(i);if(t){r||(r=Object.assign({},i.props));let e=t[1],n=t[0];n.combine&&n.id in r&&(e=n.combine(r[n.id],e)),r[n.id]=e}}e.push(r?new N(i.name,r,i.id,i.flags):i)}return new M(e)}}const C=new WeakMap,O=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",t[t.EnterBracketed=16]="EnterBracketed"}(I||(I={}));class A{constructor(t,e,i,r,n){if(this.type=t,this.children=e,this.positions=i,this.length=r,this.props=null,n&&n.length){this.props=Object.create(null);for(let[t,e]of n)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=x.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 q(this.topNode,t)}cursorAt(t,e=0,i=0){let r=C.get(this)||this.topNode,n=new q(r);return n.moveTo(t,e),C.set(this,n._tree),n}get topNode(){return new P(this,0,0,null)}resolve(t,e=0){let i=B(C.get(this)||this.topNode,t,e,!1);return C.set(this,i),i}resolveInner(t,e=0){let i=B(O.get(this)||this.topNode,t,e,!0);return O.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let r=t.resolveInner(e,i),n=null;for(let t=r instanceof P?r:r.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(n||(n=[r])).push(s.resolve(e,i)),t=s}else{let s=x.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let l=new P(s.tree,s.overlay[0].from+t.from,-1,t);(n||(n=[r])).push(B(l,e,i,!1))}}return n?$(n):r}(this,t,e)}iterate(t){let{enter:e,leave:i,from:r=0,to:n=this.length}=t,s=t.mode||0,l=(s&I.IncludeAnonymous)>0;for(let t=this.cursor(s|I.IncludeAnonymous);;){let s=!1;if(t.from<=n&&t.to>=r&&(!l&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(l||!t.type.isAnonymous)&&i(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:G(N.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new A(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new A(N.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:r,maxBufferLength:n=b,reused:s=[],minRepeatType:l=r.types.length}=t,o=Array.isArray(i)?new T(i,i.length):i,h=r.types,u=0,a=0;function f(t,e,i,m,w,b){let{id:k,start:v,end:x,size:S}=o,N=a,M=u;if(S<0){if(o.next(),-1==S)return i.push(s[k]),void m.push(v-t);if(-3==S)return void(u=k);if(-4==S)return void(a=k);throw new RangeError(`Unrecognized record size: ${S}`)}let C,O,I=h[k],T=v-t;if(x-v<=n&&(O=function(t,e){let i=o.fork(),r=0,s=0,h=0,u=i.end-n,a={size:0,start:0,skip:0};t:for(let n=i.pos-t;i.pos>n;){let t=i.size;if(i.id==e&&t>=0){a.size=r,a.start=s,a.skip=h,h+=4,r+=4,i.next();continue}let o=i.pos-t;if(t<0||o<n||i.start<u)break;let f=i.id>=l?4:0,c=i.start;for(i.next();i.pos>o;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;f+=4}else i.id>=l&&(f+=4);i.next()}s=c,r+=t,h+=f}return(e<0||r==t)&&(a.size=r,a.start=s,a.skip=h),a.size>4?a:void 0}(o.pos-e,w))){let e=new Uint16Array(O.size-O.skip),i=o.pos-O.size,n=e.length;for(;o.pos>i;)n=p(O.start,e,n);C=new D(e,x-O.start,r),T=O.start-t}else{let t=o.pos-S;o.next();let e=[],i=[],r=k>=l?k:-1,s=0,h=x;for(;o.pos>t;)r>=0&&o.id==r&&o.size>=0?(o.end<=h-n&&(d(e,i,v,s,o.end,h,r,N,M),s=e.length,h=o.end),o.next()):b>2500?c(v,t,e,i):f(v,t,e,i,r,b+1);if(r>=0&&s>0&&s<e.length&&d(e,i,v,s,v,h,r,N,M),e.reverse(),i.reverse(),r>-1&&s>0){let t=function(t,e){return(i,r,n)=>{let s,l,o=0,h=i.length-1;if(h>=0&&(s=i[h])instanceof A){if(!h&&s.type==t&&s.length==n)return s;(l=s.prop(y.lookAhead))&&(o=r[h]+s.length+l)}return g(t,i,r,n,o,e)}}(I,M);C=G(I,e,i,0,e.length,0,x-v,t,t)}else C=g(I,e,i,x-v,N-x,M)}i.push(C),m.push(T)}function c(t,e,i,s){let l=[],h=0,u=-1;for(;o.pos>e;){let{id:t,start:e,end:i,size:r}=o;if(r>4)o.next();else{if(u>-1&&e<u)break;u<0&&(u=i-n),l.push(t,e,i),h++,o.next()}}if(h){let e=new Uint16Array(4*h),n=l[l.length-2];for(let t=l.length-3,i=0;t>=0;t-=3)e[i++]=l[t],e[i++]=l[t+1]-n,e[i++]=l[t+2]-n,e[i++]=i;i.push(new D(e,l[2]-n,r)),s.push(n-t)}}function d(t,e,i,n,s,l,o,h,u){let a=[],f=[];for(;t.length>n;)a.push(t.pop()),f.push(e.pop()+i-s);t.push(g(r.types[o],a,f,l-s,h-l,u)),e.push(s-i)}function g(t,e,i,r,n,s,l){if(s){let t=[y.contextHash,s];l=l?[t].concat(l):[t]}if(n>25){let t=[y.lookAhead,n];l=l?[t].concat(l):[t]}return new A(t,e,i,r,l)}function p(t,e,i){let{id:r,start:n,end:s,size:h}=o;if(o.next(),h>=0&&r<l){let l=i;if(h>4){let r=o.pos-(h-4);for(;o.pos>r;)i=p(t,e,i)}e[--i]=l,e[--i]=s-t,e[--i]=n-t,e[--i]=r}else-3==h?u=r:-4==h&&(a=r);return i}let m=[],w=[];for(;o.pos>0;)f(t.start||0,t.bufferStart||0,m,w,-1,0);let k=null!==(e=t.length)&&void 0!==e?e:m.length?w[0]+m[0].length:0;return new A(h[t.topID],m.reverse(),w.reverse(),k)}(t)}}A.empty=new A(N.none,[],[],0);class T{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 T(this.buffer,this.index)}}class D{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return N.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+3],i=this.set.types[this.buffer[t]],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),e==(t+=4))return r;let n=[];for(;t<e;)n.push(this.childString(t)),t=this.buffer[t+3];return r+"("+n.join(",")+")"}findChild(t,e,i,r,n){let{buffer:s}=this,l=-1;for(let o=t;o!=e&&!(E(n,r,s[o+1],s[o+2])&&(l=o,i>0));o=s[o+3]);return l}slice(t,e,i){let r=this.buffer,n=new Uint16Array(e-t),s=0;for(let l=t,o=0;l<e;){n[o++]=r[l++],n[o++]=r[l++]-i;let e=n[o++]=r[l++]-i;n[o++]=r[l++]-t,s=Math.max(s,e)}return new D(n,s,this.set)}}function E(t,e,i,r){switch(t){case-2:return i<e;case-1:return r>=e&&i<e;case 0:return i<e&&r>e;case 1:return i<=e&&r>e;case 2:return r>e;case 4:return!0}}function B(t,e,i,r){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!r&&t instanceof P&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=r?0:I.IgnoreOverlays;if(r)for(let r=t,l=r.parent;l;r=l,l=r.parent)r instanceof P&&r.index<0&&(null===(n=l.enter(e,i,s))||void 0===n?void 0:n.from)!=r.from&&(t=l);for(;;){let r=t.enter(e,i,s);if(!r)return t;t=r}}class j{cursor(t=0){return new q(this,t)}getChild(t,e=null,i=null){let r=R(this,t,e,i);return r.length?r[0]:null}getChildren(t,e=null,i=null){return R(this,t,e,i)}resolve(t,e=0){return B(this,t,e,!1)}resolveInner(t,e=0){return B(this,t,e,!0)}matchContext(t){return L(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class P extends j{constructor(t,e,i,r){super(),this._tree=t,this.from=e,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,r,n=0){for(let s=this;;){for(let{children:l,positions:o}=s._tree,h=e>0?l.length:-1;t!=h;t+=e){let h,u=l[t],a=o[t]+s.from;if(n&I.EnterBracketed&&u instanceof A&&(h=x.get(u))&&!h.overlay&&h.bracketed&&i>=a&&i<=a+u.length||E(r,i,a,a+u.length))if(u instanceof D){if(n&I.ExcludeBuffers)continue;let l=u.findChild(0,u.buffer.length,e,i-a,r);if(l>-1)return new W(new U(s,u,t,a),null,l)}else if(n&I.IncludeAnonymous||!u.type.isAnonymous||F(u)){let l;if(!(n&I.IgnoreMounts)&&(l=x.get(u))&&!l.overlay)return new P(l.tree,a,t,s);let o=new P(u,a,t,s);return n&I.IncludeAnonymous||!o.type.isAnonymous?o:o.nextChild(e<0?u.children.length-1:0,e,i,r,n)}}if(n&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)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let r;if(!(i&I.IgnoreOverlays)&&(r=x.get(this._tree))&&r.overlay){let n=t-this.from,s=i&I.EnterBracketed&&r.bracketed;for(let{from:t,to:i}of r.overlay)if((e>0||s?t<=n:t<n)&&(e<0||s?i>=n:i>n))return new P(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function R(t,e,i,r){let n=t.cursor(),s=[];if(!n.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return s;for(;;){if(null!=r&&n.type.is(r))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return null==r?s:[]}}function L(t,e,i=e.length-1){for(let r=t;i>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}class U{constructor(t,e,i,r){this.parent=t,this.buffer=e,this.index=i,this.start=r}}class W extends j{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new W(this.context,this,n)}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)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&I.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new W(this.context,this,n)}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 W(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 W(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];return n>r&&(t.push(i.slice(r,n,i.buffer[this.index+1])),e.push(0)),new A(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function $(t){if(!t.length)return null;let e=0,i=t[0];for(let r=1;r<t.length;r++){let n=t[r];(n.from>i.from||n.to<i.to)&&(i=n,e=r)}let r=i instanceof P&&i.index<0?null:i.parent,n=t.slice();return r?n[e]=r:n.splice(e,1),new z(n,i)}class z{constructor(t,e){this.heads=t,this.node=e}get next(){return $(this.heads)}}class q{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~I.EnterBracketed,t instanceof P)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:i,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return!!t&&(t instanceof P?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,i);return!(n<0)&&(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&I.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}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,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+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<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<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,i,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(r.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=r)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let r=e+t,n=t<0?-1:i._tree.children.length;r!=n;r+=t){let t=i._tree.children[r];if(this.mode&I.IncludeAnonymous||t instanceof D||!t.type.isAnonymous||F(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,i=0;if(t&&t.context==this.buffer)t:for(let r=this.index,n=this.stack.length;n>=0;){for(let s=t;s;s=s._parent)if(s.index==r){if(r==this.index)return s;e=s,i=n+1;break t}r=this.stack[--n]}for(let t=i;t<this.stack.length;t++)e=new W(this.buffer,e,this.stack[t]);return this.bufferNode=new W(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let r=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(t){if(!this.buffer)return L(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let r=t.length-1,n=this.stack.length-1;r>=0;n--){if(n<0)return L(this._tree,t,r);let s=i[e.buffer[this.stack[n]]];if(!s.isAnonymous){if(t[r]&&t[r]!=s.name)return!1;r--}}return!0}}function F(t){return t.children.some((t=>t instanceof D||!t.type.isAnonymous||F(t)))}const H=new WeakMap;function J(t,e){if(!t.isAnonymous||e instanceof D||e.type!=t)return 1;let i=H.get(e);if(null==i){i=1;for(let r of e.children){if(r.type!=t||!(r instanceof A)){i=1;break}i+=J(t,r)}H.set(e,i)}return i}function G(t,e,i,r,n,s,l,o,h){let u=0;for(let i=r;i<n;i++)u+=J(t,e[i]);let a=Math.ceil(1.5*u/8),f=[],c=[];return function e(i,r,n,l,o){for(let u=n;u<l;){let n=u,d=r[u],g=J(t,i[u]);for(u++;u<l;u++){let e=J(t,i[u]);if(g+e>=a)break;g+=e}if(u==n+1){if(g>a){let t=i[n];e(t.children,t.positions,0,t.children.length,r[n]+o);continue}f.push(i[n])}else f.push(G(t,i,r,n,u,d,r[u-1]+i[u-1].length-d,null,h));c.push(d+o-s)}}(e,i,r,n,0),(o||h)(f,c,l)}class _{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof W?this.setBuffer(t.context.buffer,t.index,e):t instanceof P&&this.map.set(t.tree,e)}get(t){return t instanceof W?this.getBuffer(t.context.buffer,t.index):t instanceof P?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 K{constructor(t,e,i,r,n=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=r,this.open=(n?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let r=[new K(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&r.push(i);return r}static applyChanges(t,e,i=128){if(!e.length)return t;let r=[],n=1,s=t.length?t[0]:null;for(let l=0,o=0,h=0;;l++){let u=l<e.length?e[l]:null,a=u?u.fromA:1e9;if(a-o>=i)for(;s&&s.from<a;){let e=s;if(o>=e.from||a<=e.to||h){let t=Math.max(e.from,o)-h,i=Math.min(e.to,a)-h;e=t>=i?null:new K(t,i,e.tree,e.offset+h,l>0,!!u)}if(e&&r.push(e),s.to>a)break;s=n<t.length?t[n++]:null}if(!u)break;o=u.toA,h=u.toA-u.toB}return r}}class V{startParse(t,e,i){return"string"==typeof t&&(t=new Q(t)),i=i?i.length?i.map((t=>new v(t.from,t.to))):[new v(0,0)]:[new v(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let r=this.startParse(t,e,i);for(;;){let t=r.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 y({perNode:!0});let X=0;class Y{constructor(t,e,i,r){this.name=t,this.set=e,this.base=i,this.modified=r,this.id=X++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof Y&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let r=new Y(i,[],null,[]);if(r.set.push(r),e)for(let t of e.set)r.set.push(t);return r}static defineModifier(t){let e=new tt(t);return t=>t.modified.indexOf(e)>-1?t:tt.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let Z=0;class tt{constructor(t){this.name=t,this.instances=[],this.id=Z++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(r=e).length==(n=i.modified).length&&r.every(((t,e)=>t==n[e]));var r,n}));if(i)return i;let r=[],n=new Y(t.name,r,t,e);for(let t of e)t.instances.push(n);let s=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let r=0,n=e.length;r<n;r++)e.push(e[r].concat(t[i]));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)r.push(tt.get(e,t));return n}}function et(t){let e=Object.create(null);for(let i in t){let r=t[i];Array.isArray(r)||(r=[r]);for(let t of i.split(" "))if(t){let i=[],n=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){n=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!r)throw new RangeError("Invalid path: "+t);if(i.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),e+=r[0].length,e==t.length)break;let l=t[e++];if(e==t.length&&"!"==l){n=0;break}if("/"!=l)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let l=i.length-1,o=i[l];if(!o)throw new RangeError("Invalid path: "+t);let h=new rt(r,n,l>0?i.slice(0,l):null);e[o]=h.sort(e[o])}}return it.add(e)}const it=new y({combine(t,e){let i,r,n;for(;t||e;){if(!t||e&&t.depth>=e.depth?(n=e,e=e.next):(n=t,t=t.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let s=new rt(n.tags,n.mode,n.context);i?i.next=s:r=s,i=s}return r}});class rt{constructor(t,e,i,r){this.tags=t,this.mode=e,this.context=i,this.next=r}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 nt(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:r,all:n=null}=e||{};return{style:t=>{let e=n;for(let r of t)for(let t of r.set){let r=i[t.id];if(r){e=e?e+" "+r:r;break}}return e},scope:r}}function st(t,e,i,r=0,n=t.length){let s=new lt(r,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),r,n,"",s.highlighters),s.flush(n)}rt.empty=new rt([],2,null);class lt{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,r,n){let{type:s,from:l,to:o}=t;if(l>=i||o<=e)return;s.isTop&&(n=this.highlighters.filter((t=>!t.scope||t.scope(s))));let h=r,u=function(t){let e=t.type.prop(it);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||rt.empty,a=function(t,e){let i=null;for(let r of t){let t=r.style(e);t&&(i=i?i+" "+t:t)}return i}(n,u.tags);if(a&&(h&&(h+=" "),h+=a,1==u.mode&&(r+=(r?" ":"")+a)),this.startSpan(Math.max(e,l),h),u.opaque)return;let f=t.tree&&t.tree.prop(y.mounted);if(f&&f.overlay){let s=t.node.enter(f.overlay[0].from+l,1),u=this.highlighters.filter((t=>!t.scope||t.scope(f.tree.type))),a=t.firstChild();for(let c=0,d=l;;c++){let g=c<f.overlay.length?f.overlay[c]:null,p=g?g.from+l:o,m=Math.max(e,d),w=Math.min(i,p);if(m<w&&a)for(;t.from<w&&(this.highlightRange(t,m,w,r,n),this.startSpan(Math.min(w,t.to),h),!(t.to>=p)&&t.nextSibling()););if(!g||p>i)break;d=g.to+l,d>e&&(this.highlightRange(s.cursor(),Math.max(e,g.from+l),Math.min(i,d),"",u),this.startSpan(Math.min(i,d),h))}a&&t.parent()}else if(t.firstChild()){f&&(r="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,r,n),this.startSpan(Math.min(i,t.to),h)}}while(t.nextSibling());t.parent()}}}const ot=Y.define,ht=ot(),ut=ot(),at=ot(ut),ft=ot(ut),ct=ot(),dt=ot(ct),gt=ot(ct),pt=ot(),mt=ot(pt),wt=ot(),bt=ot(),kt=ot(),vt=ot(kt),yt=ot(),xt={comment:ht,lineComment:ot(ht),blockComment:ot(ht),docComment:ot(ht),name:ut,variableName:ot(ut),typeName:at,tagName:ot(at),propertyName:ft,attributeName:ot(ft),className:ot(ut),labelName:ot(ut),namespace:ot(ut),macroName:ot(ut),literal:ct,string:dt,docString:ot(dt),character:ot(dt),attributeValue:ot(dt),number:gt,integer:ot(gt),float:ot(gt),bool:ot(ct),regexp:ot(ct),escape:ot(ct),color:ot(ct),url:ot(ct),keyword:wt,self:ot(wt),null:ot(wt),atom:ot(wt),unit:ot(wt),modifier:ot(wt),operatorKeyword:ot(wt),controlKeyword:ot(wt),definitionKeyword:ot(wt),moduleKeyword:ot(wt),operator:bt,derefOperator:ot(bt),arithmeticOperator:ot(bt),logicOperator:ot(bt),bitwiseOperator:ot(bt),compareOperator:ot(bt),updateOperator:ot(bt),definitionOperator:ot(bt),typeOperator:ot(bt),controlOperator:ot(bt),punctuation:kt,separator:ot(kt),bracket:vt,angleBracket:ot(vt),squareBracket:ot(vt),paren:ot(vt),brace:ot(vt),content:pt,heading:mt,heading1:ot(mt),heading2:ot(mt),heading3:ot(mt),heading4:ot(mt),heading5:ot(mt),heading6:ot(mt),contentSeparator:ot(pt),list:ot(pt),quote:ot(pt),emphasis:ot(pt),strong:ot(pt),link:ot(pt),monospace:ot(pt),strikethrough:ot(pt),inserted:ot(),deleted:ot(),changed:ot(),invalid:ot(),meta:yt,documentMeta:ot(yt),annotation:ot(yt),processingInstruction:ot(yt),definition:Y.defineModifier("definition"),constant:Y.defineModifier("constant"),function:Y.defineModifier("function"),standard:Y.defineModifier("standard"),local:Y.defineModifier("local"),special:Y.defineModifier("special")};for(let t in xt){let e=xt[t];e instanceof Y&&(e.name=t)}var St;nt([{tag:xt.link,class:"tok-link"},{tag:xt.heading,class:"tok-heading"},{tag:xt.emphasis,class:"tok-emphasis"},{tag:xt.strong,class:"tok-strong"},{tag:xt.keyword,class:"tok-keyword"},{tag:xt.atom,class:"tok-atom"},{tag:xt.bool,class:"tok-bool"},{tag:xt.url,class:"tok-url"},{tag:xt.labelName,class:"tok-labelName"},{tag:xt.inserted,class:"tok-inserted"},{tag:xt.deleted,class:"tok-deleted"},{tag:xt.literal,class:"tok-literal"},{tag:xt.string,class:"tok-string"},{tag:xt.number,class:"tok-number"},{tag:[xt.regexp,xt.escape,xt.special(xt.string)],class:"tok-string2"},{tag:xt.variableName,class:"tok-variableName"},{tag:xt.local(xt.variableName),class:"tok-variableName tok-local"},{tag:xt.definition(xt.variableName),class:"tok-variableName tok-definition"},{tag:xt.special(xt.variableName),class:"tok-variableName2"},{tag:xt.definition(xt.propertyName),class:"tok-propertyName tok-definition"},{tag:xt.typeName,class:"tok-typeName"},{tag:xt.namespace,class:"tok-namespace"},{tag:xt.className,class:"tok-className"},{tag:xt.macroName,class:"tok-macroName"},{tag:xt.propertyName,class:"tok-propertyName"},{tag:xt.operator,class:"tok-operator"},{tag:xt.comment,class:"tok-comment"},{tag:xt.meta,class:"tok-meta"},{tag:xt.invalid,class:"tok-invalid"},{tag:xt.punctuation,class:"tok-punctuation"}]);const Nt=new y;function Mt(t){return e.define({combine:t?e=>e.concat(t):void 0})}const Ct=new y;class Ot{constructor(t,e,i=[],r=""){this.data=t,this.name=r,n.prototype.hasOwnProperty("tree")||Object.defineProperty(n.prototype,"tree",{get(){return Tt(this)}}),this.parser=e,this.extension=[$t.of(this),n.languageData.of(((t,e,i)=>{let r=It(t,e,i),n=r.type.prop(Nt);if(!n)return[];let s=t.facet(n),l=r.type.prop(Ct);if(l){let n=r.resolve(e-r.from,i);for(let e of l)if(e.test(n,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return It(t,e,i).type.prop(Nt)==this.data}findRegions(t){let e=t.facet($t);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],r=(t,e)=>{if(t.prop(Nt)==this.data)return void i.push({from:e,to:e+t.length});let n=t.prop(y.mounted);if(n){if(n.tree.prop(Nt)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(n.overlay){let t=i.length;if(r(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let n=t.children[i];n instanceof A&&r(n,t.positions[i]+e)}};return r(Tt(t),0),i}get allowsNesting(){return!0}}function It(t,e,i){let r=t.facet($t),n=Tt(t).topNode;if(!r||r.allowsNesting)for(let t=n;t;t=t.enter(e,i,I.ExcludeBuffers|I.EnterBracketed))t.type.isTop&&(n=t);return n}Ot.setState=t.define();class At extends Ot{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Mt(t.languageData);return new At(e,t.parser.configure({props:[Nt.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new At(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Tt(t){let e=t.field(Ot.state,!1);return e?e.tree:A.empty}function Dt(t,e,i=50){var r;let n=null===(r=t.field(Ot.state,!1))||void 0===r?void 0:r.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:e});let l=n.isDone(e)||n.work(i,e)?n.tree:null;return n.updateViewport(s),l}class Et{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Bt=null;class jt{constructor(t,e,i=[],r,n,s,l,o){this.parser=t,this.state=e,this.fragments=i,this.tree=r,this.treeLen=n,this.viewport=s,this.skipped=l,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new jt(t,e,[],A.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Et(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=A.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;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 r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(K.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=r,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(K.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Bt;Bt=this;try{return t()}finally{Bt=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Pt(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:r,treeLen:n,viewport:s,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,r,n)=>e.push({fromA:t,toA:i,fromB:r,toB:n}))),i=K.applyChanges(i,e),r=A.empty,n=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){l=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);i<r&&l.push({from:i,to:r})}}}return new jt(this.parser,e,i,r,n,s,l,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:i,to:r}=this.skipped[e];i<t.to&&r>t.from&&(this.fragments=Pt(this.fragments,i,r),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 V{createParse(e,i,r){let n=r[0].from,s=r[r.length-1].to;return{parsedPos:n,advance(){let e=Bt;if(e){for(let t of r)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new A(N.none,[],[],s-n)},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 Bt}}function Pt(t,e,i){return K.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Rt{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Rt(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=jt.create(t.facet($t).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Rt(i)}}Ot.state=i.define({create:Rt.init,update(t,e){for(let t of e.effects)if(t.is(Ot.setState))return t.value;return e.startState.facet($t)!=e.state.facet($t)?Rt.init(e.state):t.apply(e)}});let Lt=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Lt=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Ut="undefined"!=typeof navigator&&(null===(St=navigator.scheduling)||void 0===St?void 0:St.isInputPending)?()=>navigator.scheduling.isInputPending():null,Wt=u.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(Ot.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(Ot.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Lt(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:i,viewport:{to:r}}=this.view,n=i.field(Ot.state);if(n.tree==n.context.tree&&n.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!Ut?Math.max(25,t.timeRemaining()-5):1e9),l=n.context.treeLen<r&&i.doc.length>r+1e3,o=n.context.work((()=>Ut&&Ut()||Date.now()>s),r+(l?0:1e5));this.chunkBudget-=Date.now()-e,(o||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:Ot.setState.of(new Rt(n.context))})),this.chunkBudget>0&&(!o||l)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>w(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()}}}),$t=e.define({combine:t=>t.length?t[0]:null,enables:t=>[Ot.state,Wt,a.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class zt{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class qt{constructor(t,e,i,r,n,s){this.name=t,this.alias=e,this.extensions=i,this.filename=r,this.loadFunc=n,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:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new qt(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let i of t)if(i.filename&&i.filename.test(e))return i;let i=/\.([^.]+)$/.exec(e);if(i)for(let e of t)if(e.extensions.indexOf(i[1])>-1)return e;return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let i of t)if(i.alias.some((t=>t==e)))return i;if(i)for(let i of t)for(let t of i.alias){let r=e.indexOf(t);if(r>-1&&(t.length>2||!/\w/.test(e[r-1])&&!/\w/.test(e[r+t.length])))return i}return null}}const Ft=e.define(),Ht=e.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 Jt(t){let e=t.facet(Ht);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Gt(t,e){let i="",r=t.tabSize,n=t.facet(Ht)[0];if("\t"==n){for(;e>=r;)i+="\t",e-=r;n=" "}for(let t=0;t<e;t++)i+=n;return i}function _t(t,e){t instanceof n&&(t=new Kt(t));for(let i of t.state.facet(Ft)){let r=i(t,e);if(void 0!==r)return r}let i=Tt(t.state);return i.length>=e?function(t,e,i){let r=e.resolveStack(i),n=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(n!=r.node){let t=[];for(let e=n;e&&!(e.from<r.node.from||e.to>r.node.to||e.from==r.node.from&&e.type==r.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)r={node:t[e],next:r}}return Qt(r,t,i)}(t,i,e):null}class Kt{constructor(t,e={}){this.state=t,this.options=e,this.unit=Jt(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:n}=this.options;return null!=r&&r>=i.from&&r<=i.to?n&&r==t?{text:"",from:t}:(e<0?r<t:r<=t)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(t,e);return i.slice(t-r,Math.min(i.length,t+100-r))}column(t,e=1){let{text:i,from:r}=this.lineAt(t,e),n=this.countColumn(i,t-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(n+=s-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return r(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:r}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let t=n(r);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vt=new y;function Qt(t,e,i){for(let r=t;r;r=r.next){let t=Xt(r.node);if(t)return t(Zt.create(e,i,r))}return 0}function Xt(t){let e=t.type.prop(Vt);if(e)return e;let i,r=t.firstChild;if(r&&(i=r.type.prop(y.closedBy))){let e=t.lastChild,r=e&&i.indexOf(e.name)>-1;return t=>ie(t,!0,1,void 0,r&&!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 Kt{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Zt(t,e,i)}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 i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(te(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Qt(this.context.next,this.base,this.pos)}}function te(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function ee({closing:t,align:e=!0,units:i=1}){return r=>ie(r,e,i,t)}function ie(t,e,i,r,n){let s=t.textAfter,l=s.match(/^\s*/)[0].length,o=r&&s.slice(l,l+r.length)==r||n==t.pos+l,h=e?function(t){let e=t.node,i=e.childAfter(e.from),r=e.lastChild;if(!i)return null;let n=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),l=null==n||n<=s.from?s.to:Math.min(s.to,n);for(let t=i.to;;){let n=e.childAfter(t);if(!n||n==r)return null;if(!n.type.isSkipped){if(n.from>=l)return null;let t=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+t}}t=n.to}}(t):null;return h?t.column(o?h.from:h.to):t.baseIndent+(o?0:t.unit*i)}const re=t=>t.baseIndent;function ne({except:t,units:e=1}={}){return i=>{let r=t&&t.test(i.textAfter);return i.baseIndent+(r?0:e*i.unit)}}const se=e.define(),le=new y;function oe(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function he(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function ue(t,e,i){for(let r of t.facet(se)){let n=r(t,e,i);if(n)return n}return function(t,e,i){let r=Tt(t);if(r.length<i)return null;let n=null;for(let s=r.resolveStack(i,1);s;s=s.next){let l=s.node;if(l.to<=i||l.from>i)continue;if(n&&l.from<e)break;let o=l.type.prop(le);if(o&&(l.to<r.length-50||r.length==t.doc.length||!he(l))){let r=o(l,t);r&&r.from<=i&&r.from>=e&&r.to>i&&(n=r)}}return n}(t,e,i)}function ae(t,e){let i=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return i>=r?void 0:{from:i,to:r}}const fe=t.define({map:ae}),ce=t.define({map:ae});function de(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some((t=>t.from<=i&&t.to>=i))||e.push(t.lineBlockAt(i));return e}const ge=i.define({create:()=>c.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges(((e,i)=>t=pe(t,e,i))),t=t.map(e.changes);let i=[];for(let r of e.effects)r.is(fe)&&!we(t,r.value.from,r.value.to)?i.push(r.value):r.is(ce)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));if(i.length){let{preparePlaceholder:r}=e.state.facet(Oe),n=i.map((t=>(r?c.replace({widget:new De(r(e.state,t))}):Te).range(t.from,t.to)));t=t.update({add:n})}return e.selection&&(t=pe(t,e.selection.main.head)),t},provide:t=>a.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,((t,e)=>{i.push(t,e)})),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let r=t[i++],n=t[i++];if("number"!=typeof r||"number"!=typeof n)throw new RangeError("Invalid JSON for fold state");e.push(Te.range(r,n))}return c.set(e,!0)}});function pe(t,e,i=e){let r=!1;return t.between(e,i,((t,n)=>{t<i&&n>e&&(r=!0)})),r?t.update({filterFrom:e,filterTo:i,filter:(t,r)=>t>=i||r<=e}):t}function me(t,e,i){var r;let n=null;return null===(r=t.field(ge,!1))||void 0===r||r.between(e,i,((t,e)=>{(!n||n.from>t)&&(n={from:t,to:e})})),n}function we(t,e,i){let r=!1;return t.between(e,e,((t,n)=>{t==e&&n==i&&(r=!0)})),r}function be(e,i){return e.field(ge,!1)?i:i.concat(t.appendConfig.of(Ie()))}const ke=t=>{for(let e of de(t)){let i=ue(t.state,e.from,e.to);if(i)return t.dispatch({effects:be(t.state,[fe.of(i),ye(t,i)])}),!0}return!1},ve=t=>{if(!t.state.field(ge,!1))return!1;let e=[];for(let i of de(t)){let r=me(t.state,i.from,i.to);r&&e.push(ce.of(r),ye(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function ye(t,e,i=!0){let r=t.state.doc.lineAt(e.from).number,n=t.state.doc.lineAt(e.to).number;return a.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${n}.`)}const xe=t=>{let{state:e}=t,i=[];for(let r=0;r<e.doc.length;){let n=t.lineBlockAt(r),s=ue(e,n.from,n.to);s&&i.push(fe.of(s)),r=(s?t.lineBlockAt(s.to):n).to+1}return i.length&&t.dispatch({effects:be(t.state,i)}),!!i.length},Se=t=>{let e=t.state.field(ge,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push(ce.of({from:t,to:e}))})),t.dispatch({effects:i}),!0};function Ne(t,e){for(let i=e;;){let r=ue(t.state,i.from,i.to);if(r&&r.to>e.from)return r;if(!i.from)return null;i=t.lineBlockAt(i.from-1)}}const Me=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:ke},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ve},{key:"Ctrl-Alt-[",run:xe},{key:"Ctrl-Alt-]",run:Se}],Ce={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Oe=e.define({combine:t=>h(t,Ce)});function Ie(t){let e=[ge,je];return t&&e.push(Oe.of(t)),e}function Ae(t,e){let{state:i}=t,r=i.facet(Oe),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),r=me(t.state,i.from,i.to);r&&t.dispatch({effects:ce.of(r)}),e.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,n,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const Te=c.replace({widget:new class extends m{toDOM(t){return Ae(t,null)}}});class De extends m{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ae(t,this.value)}}const Ee={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Be extends p{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}}const je=a.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 Pe{constructor(t,e){let i;function r(t){let e=d.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const n="string"==typeof e.all?e.all:e.all?r(e.all):void 0,s=e.scope;this.scope=s instanceof Ot?t=>t.prop(Nt)==s.data:s?t=>t==s:void 0,this.style=nt(t.map((t=>({tag:t.tag,class:t.class||r(Object.assign({},t,{tag:null}))}))),{all:n}).style,this.module=i?new d(i):null,this.themeType=e.themeType}static define(t,e){return new Pe(t,e||{})}}const Re=e.define(),Le=e.define({combine:t=>t.length?[t[0]]:null});function Ue(t){let e=t.facet(Re);return e.length?e:t.facet(Le)}function We(t,e){let i,r=[ze];return t instanceof Pe&&(t.module&&r.push(a.styleModule.of(t.module)),i=t.themeType),r.push((null==e?void 0:e.fallback)?Le.of(t):i?Re.computeN([a.darkTheme],(e=>e.facet(a.darkTheme)==("dark"==i)?[t]:[])):Re.of(t)),r}class $e{constructor(t){this.markCache=Object.create(null),this.tree=Tt(t.state),this.decorations=this.buildDeco(t,Ue(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Tt(t.state),i=Ue(t.state),r=i!=Ue(t.startState),{viewport:n}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!r&&e.type==this.tree.type&&s>=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||r)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return c.none;let i=new s;for(let{from:r,to:n}of t.visibleRanges)st(this.tree,e,((t,e,r)=>{i.add(t,e,this.markCache[r]||(this.markCache[r]=c.mark({class:r})))}),r,n);return i.finish()}}const ze=o.high(u.fromClass($e,{decorations:t=>t.decorations})),qe=Pe.define([{tag:xt.meta,color:"#404740"},{tag:xt.link,textDecoration:"underline"},{tag:xt.heading,textDecoration:"underline",fontWeight:"bold"},{tag:xt.emphasis,fontStyle:"italic"},{tag:xt.strong,fontWeight:"bold"},{tag:xt.strikethrough,textDecoration:"line-through"},{tag:xt.keyword,color:"#708"},{tag:[xt.atom,xt.bool,xt.url,xt.contentSeparator,xt.labelName],color:"#219"},{tag:[xt.literal,xt.inserted],color:"#164"},{tag:[xt.string,xt.deleted],color:"#a11"},{tag:[xt.regexp,xt.escape,xt.special(xt.string)],color:"#e40"},{tag:xt.definition(xt.variableName),color:"#00f"},{tag:xt.local(xt.variableName),color:"#30a"},{tag:[xt.typeName,xt.namespace],color:"#085"},{tag:xt.className,color:"#167"},{tag:[xt.special(xt.variableName),xt.macroName],color:"#256"},{tag:xt.definition(xt.propertyName),color:"#00c"},{tag:xt.comment,color:"#940"},{tag:xt.invalid,color:"#f00"}]),Fe=a.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),He="()[]{}",Je=e.define({combine:t=>h(t,{afterCursor:!0,brackets:He,maxScanDistance:1e4,renderMatch:Ke})}),Ge=c.mark({class:"cm-matchingBracket"}),_e=c.mark({class:"cm-nonmatchingBracket"});function Ke(t){let e=[],i=t.matched?Ge:_e;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}function Ve(t){let e=[],i=t.facet(Je);for(let r of t.selection.ranges){if(!r.empty)continue;let n=ti(t,r.head,-1,i)||r.head>0&&ti(t,r.head-1,1,i)||i.afterCursor&&(ti(t,r.head,1,i)||r.head<t.doc.length&&ti(t,r.head+1,-1,i));n&&(e=e.concat(i.renderMatch(n,t)))}return c.set(e,!0)}const Qe=[u.fromClass(class{constructor(t){this.paused=!1,this.decorations=Ve(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=Ve(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Fe],Xe=new y;function Ye(t,e,i){let r=t.prop(e<0?y.openedBy:y.closedBy);if(r)return r;if(1==t.name.length){let r=i.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[i[r+e]]}return null}function Ze(t){let e=t.type.prop(Xe);return e?e(t.node):t}function ti(t,e,i,r={}){let n=r.maxScanDistance||1e4,s=r.brackets||He,l=Tt(t),o=l.resolveInner(e,i);for(let t=o;t;t=t.parent){let r=Ye(t.type,i,s);if(r&&t.from<t.to){let n=Ze(t);if(n&&(i>0?e>=n.from&&e<n.to:e>n.from&&e<=n.to))return ei(0,0,i,t,n,r,s)}}return function(t,e,i,r,n,s,l){if(i<0?!e:e==t.doc.length)return null;let o=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=l.indexOf(o);if(h<0||h%2==0!=i>0)return null;let u={from:i<0?e-1:e,to:i>0?e+1:e},a=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!a.next().done&&t<=s;){let s=a.value;i<0&&(t+=s.length);let o=e+t*i;for(let t=i>0?0:s.length-1,e=i>0?s.length:-1;t!=e;t+=i){let e=l.indexOf(s[t]);if(!(e<0||r.resolveInner(o+t,1).type!=n))if(e%2==0==i>0)f++;else{if(1==f)return{start:u,end:{from:o+t,to:o+t+1},matched:e>>1==h>>1};f--}}i>0&&(t+=s.length)}return a.done?{start:u,matched:!1}:null}(t,e,i,l,o.type,n,s)}function ei(t,e,i,r,n,s,l){let o=r.parent,h={from:n.from,to:n.to},u=0,a=null==o?void 0:o.cursor();if(a&&(i<0?a.childBefore(r.from):a.childAfter(r.to)))do{if(i<0?a.to<=r.from:a.from>=r.to){if(0==u&&s.indexOf(a.type.name)>-1&&a.from<a.to){let t=Ze(a);return{start:h,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Ye(a.type,i,l))u++;else if(Ye(a.type,-i,l)){if(0==u){let t=Ze(a);return{start:h,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}u--}}}while(i<0?a.prevSibling():a.nextSibling());return{start:h,matched:!1}}function ii(t,e,i,r=0,n=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=n;for(let n=r;n<e;n++)9==t.charCodeAt(n)?s+=i-s%i:s++;return s}class ri{constructor(t,e,i,r){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=r,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,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}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=ii(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:ii(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let r=t=>i?t.toLowerCase():t;return r(this.string.substr(this.pos,t.length))==r(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function ni(t){if("object"!=typeof t)return t;let e={};for(let i in t){let r=t[i];e[i]=r instanceof Array?r.slice():r}return e}const si=new WeakMap;class li extends Ot{constructor(t){let e,i=Mt(t.languageData),r={name:(n=t).name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||ni,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||fi,mergeTokens:!1!==n.mergeTokens};var n;super(i,new class extends V{createParse(t,i,r){return new ui(e,t,i,r)}},[],t.name),this.topNode=function(t,e){let i=N.define({id:ci.length,name:"Document",props:[Nt.add((()=>t)),Vt.add((()=>t=>e.getIndent(t)))],top:!0});return ci.push(i),i}(i,this),e=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new wi(r.tokenTable):bi}static define(t){return new li(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=si.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let r,n,s=oi(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(s?(n=s.state,r=s.pos+1):(n=this.streamParser.startState(t.unit),r=t.node.from),t.pos-r>1e4)return null;for(;r<t.pos;){let e=t.state.doc.lineAt(r),s=Math.min(t.pos,e.to);if(e.length){let r=i?i(e.from):-1,l=new ri(e.text,t.state.tabSize,t.unit,r<0?void 0:r);for(;l.pos<s-e.from;)ai(this.streamParser.token,l,n)}else this.streamParser.blankLine(n,t.unit);if(s==t.pos)break;r=e.to+1}let l=t.lineAt(t.pos);return i&&null==e&&si.set(t.state,l.from),this.streamParser.indent(n,/^\s*(.*)/.exec(l.text)[1],t)}get allowsNesting(){return!1}}function oi(t,e,i,r,n){let s=i>=r&&i+e.length<=n&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let s=e.children.length-1;s>=0;s--){let l=e.children[s],o=i+e.positions[s],h=l instanceof A&&o<n&&oi(t,l,o,r,n);if(h)return h}return null}function hi(t,e,i,r,n){if(n&&i<=0&&r>=e.length)return e;n||0!=i||e.type!=t.topNode||(n=!0);for(let s=e.children.length-1;s>=0;s--){let l,o=e.positions[s],h=e.children[s];if(o<r&&h instanceof A){if(!(l=hi(t,h,i-o,r-o,n)))break;return n?new A(e.type,e.children.slice(0,s).concat(l),e.positions.slice(0,s+1),o+l.length):l}}return null}class ui{constructor(t,e,i,r){this.lang=t,this.input=e,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let n=jt.get(),s=r[0].from,{state:l,tree:o}=function(t,e,i,r,n){for(let n of e){let e,s=n.to-(n.openEnd?25:0),l=n.from+(n.openStart?25:0)<=i&&s>i&&oi(t,n.tree,0-n.offset,i,s);if(l&&l.pos<=r&&(e=hi(t,n.tree,i+n.offset,l.pos+n.offset,!1)))return{state:l.state,tree:e}}return{state:t.streamParser.startState(n?Jt(n):4),tree:A.empty}}(t,i,s,this.to,null==n?void 0:n.state);this.state=l,this.parsedPos=this.chunkStart=s+o.length;for(let t=0;t<o.children.length;t++)this.chunks.push(o.children[t]),this.chunkPos.push(o.positions[t]);n&&this.parsedPos<n.viewport.from-1e5&&r.some((t=>t.from<=n.viewport.from&&t.to>=n.viewport.from))&&(this.state=this.lang.streamParser.startState(Jt(n.state)),n.skipUntilInView(this.parsedPos,n.viewport.from),this.parsedPos=n.viewport.from),this.moveRangeIndex()}advance(){let t=jt.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+512);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)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),i=t+e.length;for(let t=this.rangeIndex;;){let r=this.ranges[t].to;if(r>=i)break;if(e=e.slice(0,r-(i-e.length)),t++,t==this.ranges.length)break;let n=this.ranges[t].from,s=this.lineAfter(n);e+=s,i=n+s.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let r=this.ranges[this.rangeIndex].to,n=t+e;if(i>0?r>n:r>=n)break;e+=this.ranges[++this.rangeIndex].from-r}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,r){let n=4;if(this.ranges.length>1){e+=r=this.skipGapsTo(e,r,1);let t=this.chunk.length;i+=r=this.skipGapsTo(i,r,-1),n+=this.chunk.length-t}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==n&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==e?this.chunk[s+2]=i:this.chunk.push(t,e,i,n),r}parseLine(t){let{line:e,end:i}=this.nextLine(),r=0,{streamParser:n}=this.lang,s=new ri(e,t?t.state.tabSize:4,t?Jt(t.state):2);if(s.eol())n.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=ai(n.token,s,this.state);if(t&&(r=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,r)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=A.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:di,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new A(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 A(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function ai(t,e,i){e.start=e.pos;for(let r=0;r<10;r++){let r=t(e,i);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}const fi=Object.create(null),ci=[N.none],di=new M(ci),gi=[],pi=Object.create(null),mi=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"]])mi[t]=vi(fi,e);class wi{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),mi)}resolve(t){return t?this.table[t]||(this.table[t]=vi(this.extra,t)):0}}const bi=new wi(fi);function ki(t,e){gi.indexOf(t)>-1||(gi.push(t),console.warn(e))}function vi(t,e){let i=[];for(let r of e.split(" ")){let e=[];for(let i of r.split(".")){let r=t[i]||xt[i];r?"function"==typeof r?e.length?e=e.map(r):ki(i,`Modifier ${i} used at start of tag`):e.length?ki(i,`Tag ${i} used as modifier`):e=Array.isArray(r)?r:[r]:ki(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let r=e.replace(/ /g,"_"),n=r+" "+i.map((t=>t.id)),s=pi[n];if(s)return s.id;let l=pi[n]=N.define({id:ci.length,name:r,props:[et({[r]:i})]});return ci.push(l),l.id}function yi(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function xi(t){for(let e=t.iter();!e.next().done;)if(yi(e.value))return!0;return!1}const Si=e.define({combine:t=>t.some((t=>t))}),Ni=u.fromClass(class{constructor(t){this.always=t.state.facet(Si)||t.textDirection!=g.LTR||t.state.facet(a.perLineTextDirection),this.hasRTL=!this.always&&xi(t.state.doc),this.tree=Tt(t.state),this.decorations=this.always||this.hasRTL?Mi(t,this.tree,this.always):c.none}update(t){let e=t.state.facet(Si)||t.view.textDirection!=g.LTR||t.state.facet(a.perLineTextDirection);if(e||this.hasRTL||!function(t){let e=!1;return t.iterChanges(((t,i,r,n,s)=>{!e&&xi(s)&&(e=!0)})),e}(t.changes)||(this.hasRTL=!0),!e&&!this.hasRTL)return;let i=Tt(t.state);(e!=this.always||i!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=i,this.always=e,this.decorations=Mi(t.view,i,e))}},{provide:t=>{function e(e){var i,r;return null!==(r=null===(i=e.plugin(t))||void 0===i?void 0:i.decorations)&&void 0!==r?r:c.none}return[a.outerDecorations.of(e),o.lowest(a.bidiIsolatedRanges.of(e))]}});function Mi(t,e,i){let r=new s,n=t.visibleRanges;i||(n=function(t,e){let i=e.iter(),r=0,n=[],s=null;for(let{from:e,to:l}of t)if(!(s&&s.to>e&&(e=s.to,e>=l)))for(r+i.value.length<e&&(i.next(e-(r+i.value.length)),r=e);;){let t=r,e=r+i.value.length;if(!i.lineBreak&&yi(i.value)&&(s&&s.to>t-10?s.to=Math.min(l,e):n.push(s={from:t,to:Math.min(l,e)})),e>=l)break;r=e,i.next()}return n}(n,t.state.doc));for(let{from:t,to:i}of n)e.iterate({enter:t=>{let e=t.type.prop(y.isolate);e&&r.add(t.from,t.to,Ci[e])},from:t,to:i});return r.finish()}const Ci={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 Oi=Object.freeze({__proto__:null,DocInput:Et,HighlightStyle:Pe,IndentContext:Kt,LRLanguage:At,Language:Ot,LanguageDescription:qt,LanguageSupport:zt,ParseContext:jt,StreamLanguage:li,StringStream:ri,TreeIndentContext:Zt,bidiIsolates:function(t={}){let e=[Ni];return t.alwaysIsolate&&e.push(Si.of(!0)),e},bracketMatching:function(t={}){return[Je.of(t),Qe]},bracketMatchingHandle:Xe,codeFolding:Ie,continuedIndent:ne,defaultHighlightStyle:qe,defineLanguageFacet:Mt,delimitedIndent:ee,ensureSyntaxTree:Dt,flatIndent:re,foldAll:xe,foldCode:ke,foldEffect:fe,foldGutter:function(t={}){let e={...Ee,...t},i=new Be(e,!0),r=new Be(e,!1),n=u.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet($t)!=t.state.facet($t)||t.startState.field(ge,!1)!=t.state.field(ge,!1)||Tt(t.startState)!=Tt(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new s;for(let n of t.viewportLineBlocks){let s=me(t.state,n.from,n.to)?r:ue(t.state,n.from,n.to)?i:null;s&&e.add(n.from,n.from,s)}return e.finish()}}),{domEventHandlers:o}=e;return[n,f({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.markers)||l.empty},initialSpacer:()=>new Be(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let r=me(t.state,e.from,e.to);if(r)return t.dispatch({effects:ce.of(r)}),!0;let n=ue(t.state,e.from,e.to);return!!n&&(t.dispatch({effects:fe.of(n)}),!0)}}}),Ie()]},foldInside:oe,foldKeymap:Me,foldNodeProp:le,foldService:se,foldState:ge,foldable:ue,foldedRanges:function(t){return t.field(ge,!1)||l.empty},forceParsing:function(t,e=t.viewport.to,i=100){let r=Dt(t.state,e,i);return r!=Tt(t.state)&&t.dispatch({}),!!r},getIndentUnit:Jt,getIndentation:_t,highlightingFor:function(t,e,i){let r=Ue(t),n=null;if(r)for(let t of r)if(!t.scope||i&&t.scope(i)){let i=t.style(e);i&&(n=n?n+" "+i:i)}return n},indentNodeProp:Vt,indentOnInput:function(){return n.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 i=t.newDoc,{head:r}=t.newSelection.main,n=i.lineAt(r);if(r>n.from+200)return t;let s=i.sliceString(n.from,r);if(!e.some((t=>t.test(s))))return t;let{state:l}=t,o=-1,h=[];for(let{head:t}of l.selection.ranges){let e=l.doc.lineAt(t);if(e.from==o)continue;o=e.from;let i=_t(l,e.from);if(null==i)continue;let r=/^\s*/.exec(e.text)[0],n=Gt(l,i);r!=n&&h.push({from:e.from,to:e.from+r.length,insert:n})}return h.length?[t,{changes:h,sequential:!0}]:t}))},indentRange:function(t,e,i){let r=Object.create(null),n=new Kt(t,{overrideIndentation:t=>{var e;return null!==(e=r[t])&&void 0!==e?e:-1}}),s=[];for(let l=e;l<=i;){let e=t.doc.lineAt(l);l=e.to+1;let i=_t(n,e.from);if(null==i)continue;/\S/.test(e.text)||(i=0);let o=/^\s*/.exec(e.text)[0],h=Gt(t,i);o!=h&&(r[e.from]=i,s.push({from:e.from,to:e.from+o.length,insert:h}))}return t.changes(s)},indentService:Ft,indentString:Gt,indentUnit:Ht,language:$t,languageDataProp:Nt,matchBrackets:ti,sublanguageProp:Ct,syntaxHighlighting:We,syntaxParserRunning:function(t){var e;return(null===(e=t.plugin(Wt))||void 0===e?void 0:e.isWorking())||!1},syntaxTree:Tt,syntaxTreeAvailable:function(t,e=t.doc.length){var i;return(null===(i=t.field(Ot.state,!1))||void 0===i?void 0:i.context.isDone(e))||!1},toggleFold:t=>{let e=[];for(let i of de(t)){let r=me(t.state,i.from,i.to);if(r)e.push(ce.of(r),ye(t,r,!1));else{let r=Ne(t,i);r&&e.push(fe.of(r),ye(t,r))}}return e.length>0&&t.dispatch({effects:be(t.state,e)}),!!e.length},unfoldAll:Se,unfoldCode:ve,unfoldEffect:ce});export{b as D,Pe as H,Kt as I,At as L,y as N,V as P,A as T,Jt as a,Ht as b,We as c,M as d,N as e,I as f,_t as g,et as h,Gt as i,zt as j,Vt as k,le as l,ti as m,ne as n,ee as o,re as p,oe as q,Ct as r,Tt as s,xt as t,Mt as u,_ as v,Oi as w}
@@ -1 +1 @@
1
- import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-RzeBwfwG.js";import{s as O,b as $}from"./p-CehxuHtl.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function S(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function C(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class L{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function j(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const B=t.define();function F(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class H{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const U=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:_,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>K(t(i),e(i)),optionClass:(t,e)=>i=>K(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function K(t,e){return t?e?t+" "+e:t:e}function _(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const q=o.define();function G(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class N{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(U);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=G(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:q.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(U).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=G(o.length,r,t.state.facet(U).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=G(e.options.length,e.selected,this.view.state.facet(U).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(U).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Q(t,e){return i=>new N(i,t,e)}function X(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class J{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new J(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(U);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new L(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new H(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new L(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):X(t.completion)>X(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(U).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new J(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new J(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new J(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(U),n=(i.override||e.languageDataAt("autocomplete",j(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=J.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(q)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(B);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(j(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=j(t.state);if(s>r||!n||2&e&&(j(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:j(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...F(t.state,i,n.from,n.to),annotations:B.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=Q(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(U).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:q.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(U).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(U);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(U).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=j(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(U).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(U),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=j(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(U).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[B.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function St(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const Ct=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),Lt=St(1),jt=St(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Bt(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Ft=[{key:"Tab",run:Lt,shift:jt},{key:"Escape",run:Ct}],Rt=e.define({combine:t=>t.length?t[0]:Ft}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ht=Object.create(null);function Ut(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function Kt(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of Kt(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ut(s,i,l,c,o-r);r+=s.length+1}}else Ut(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const _t=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=Kt(t.state.doc,function(t){return Ht[t]||(Ht[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},qt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gt=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Nt=new class extends d{};Nt.startSide=1,Nt.endSide=-1;const Qt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(Gt)&&(t=t.update({add:[Nt.range(i.value,i.value+1)]}));return t}});function Xt(){return[ee,Qt]}const Jt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Jt.charCodeAt(e)==t)return Jt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||qt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||qt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||qt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||qt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Qt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:Gt.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:Gt.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||qt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:Gt.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,U.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([U],(t=>t.facet(U).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return q.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,Ct as clearSnippet,Xt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,_t as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Bt as hasPrevSnippetField,S as ifIn,C as ifNotIn,oe as insertBracket,F as insertCompletionText,ht as moveCompletionSelection,Lt as nextSnippetField,B as pickedCompletion,jt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}
1
+ import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-jUqF8CGO.js";import{s as O,b as $}from"./p-CtXlkz3R.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function C(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function S(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class j{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function L(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const F=t.define();function B(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class U{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const H=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:K,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>q(t(i),e(i)),optionClass:(t,e)=>i=>q(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function q(t,e){return t?e?t+" "+e:t:e}function K(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const X=o.define();function _(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class G{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(H);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=_(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:X.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(H).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=_(o.length,r,t.state.facet(H).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=_(e.options.length,e.selected,this.view.state.facet(H).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(H).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function N(t,e){return i=>new G(i,t,e)}function Q(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class J{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new J(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(H);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new j(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new U(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new j(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):Q(t.completion)>Q(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(H).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new J(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new J(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new J(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(H),n=(i.override||e.languageDataAt("autocomplete",L(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=J.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(X)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(F);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(L(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=L(t.state);if(s>r||!n||2&e&&(L(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:L(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...B(t.state,i,n.from,n.to),annotations:F.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=N(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(H).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:X.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(H).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(H);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=L(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(H),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=L(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(H).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[F.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function Ct(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const St=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),jt=Ct(1),Lt=Ct(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Ft(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Bt=[{key:"Tab",run:jt,shift:Lt},{key:"Escape",run:St}],Rt=e.define({combine:t=>t.length?t[0]:Bt}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ut=Object.create(null);function Ht(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function qt(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of qt(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ht(s,i,l,c,o-r);r+=s.length+1}}else Ht(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const Kt=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=qt(t.state.doc,function(t){return Ut[t]||(Ut[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},Xt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_t=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Gt=new class extends d{};Gt.startSide=1,Gt.endSide=-1;const Nt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(_t)&&(t=t.update({add:[Gt.range(i.value,i.value+1)]}));return t}});function Qt(){return[ee,Nt]}const Jt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Jt.charCodeAt(e)==t)return Jt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||Xt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||Xt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||Xt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||Xt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Nt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:_t.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:_t.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||Xt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:_t.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,H.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([H],(t=>t.facet(H).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return X.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,St as clearSnippet,Qt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,Kt as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Ft as hasPrevSnippetField,C as ifIn,S as ifNotIn,oe as insertBracket,B as insertCompletionText,ht as moveCompletionSelection,jt as nextSnippetField,F as pickedCompletion,Lt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}