@pyscript/core 0.3.7 → 0.3.9

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 (59) hide show
  1. package/dist/codemirror-3hMOlj_s.js +2 -0
  2. package/dist/codemirror-3hMOlj_s.js.map +1 -0
  3. package/dist/codemirror_commands-Y4OsE8Y2.js +2 -0
  4. package/dist/codemirror_commands-Y4OsE8Y2.js.map +1 -0
  5. package/dist/codemirror_lang-python-p0uky9oC.js +2 -0
  6. package/dist/codemirror_lang-python-p0uky9oC.js.map +1 -0
  7. package/dist/codemirror_language-U9l5bLBC.js +2 -0
  8. package/dist/codemirror_language-U9l5bLBC.js.map +1 -0
  9. package/dist/codemirror_state-zH-H1oSI.js +2 -0
  10. package/dist/codemirror_state-zH-H1oSI.js.map +1 -0
  11. package/dist/codemirror_view-tmIj4olz.js +2 -0
  12. package/dist/codemirror_view-tmIj4olz.js.map +1 -0
  13. package/dist/core-ifSZyON7.js +5 -0
  14. package/dist/core-ifSZyON7.js.map +1 -0
  15. package/dist/core.css +1 -1
  16. package/dist/core.js +1 -4
  17. package/dist/core.js.map +1 -1
  18. package/dist/deprecations-manager-u20LUlLl.js +2 -0
  19. package/dist/{deprecations-manager-uwH5iaZ9.js.map → deprecations-manager-u20LUlLl.js.map} +1 -1
  20. package/dist/error-ZSXf8h5x.js +2 -0
  21. package/dist/{error-96hMSEw8.js.map → error-ZSXf8h5x.js.map} +1 -1
  22. package/dist/index-qM2iyXcZ.js +2 -0
  23. package/dist/index-qM2iyXcZ.js.map +1 -0
  24. package/dist/py-editor-HVgDslnW.js +2 -0
  25. package/dist/py-editor-HVgDslnW.js.map +1 -0
  26. package/dist/py-terminal-lYFDY-Tg.js +2 -0
  27. package/dist/{py-terminal-qRUZOJY9.js.map → py-terminal-lYFDY-Tg.js.map} +1 -1
  28. package/dist/xterm-f2QfYNGL.js.map +1 -1
  29. package/dist/xterm-readline-ONk85xtH.js.map +1 -1
  30. package/dist/xterm.css +0 -1
  31. package/dist/xterm_addon-fit-E4yMPZTX.js.map +1 -1
  32. package/package.json +12 -5
  33. package/src/3rd-party/xterm-readline.js +0 -1
  34. package/src/3rd-party/xterm.css +0 -1
  35. package/src/3rd-party/xterm.js +0 -1
  36. package/src/3rd-party/xterm_addon-fit.js +0 -1
  37. package/src/config.js +38 -12
  38. package/src/core.css +38 -0
  39. package/src/exceptions.js +1 -1
  40. package/src/hooks.js +1 -1
  41. package/src/plugins/py-editor.js +229 -0
  42. package/src/plugins.js +1 -0
  43. package/src/stdlib/pyscript/magic_js.py +2 -1
  44. package/src/stdlib/pyscript.js +2 -2
  45. package/src/stdlib/pyweb/pydom.py +100 -0
  46. package/src/stdlib.js +7 -3
  47. package/types/3rd-party/codemirror.d.ts +1 -0
  48. package/types/3rd-party/codemirror_commands.d.ts +1 -0
  49. package/types/3rd-party/codemirror_lang-python.d.ts +1 -0
  50. package/types/3rd-party/codemirror_language.d.ts +1 -0
  51. package/types/3rd-party/codemirror_state.d.ts +1 -0
  52. package/types/3rd-party/codemirror_view.d.ts +1 -0
  53. package/types/plugins/py-editor.d.ts +2 -0
  54. package/types/plugins.d.ts +1 -0
  55. package/dist/deprecations-manager-uwH5iaZ9.js +0 -2
  56. package/dist/error-96hMSEw8.js +0 -2
  57. package/dist/py-terminal-qRUZOJY9.js +0 -2
  58. package/types/toml.d.ts +0 -12
  59. package/types/utils.d.ts +0 -1
@@ -0,0 +1,2 @@
1
+ import{Facet as t,EditorState as e,StateEffect as r,StateField as n,countColumn as i,RangeSet as s,combineConfig as o,Prec as l,RangeSetBuilder as a}from"./codemirror_state-zH-H1oSI.js";import{V as h,l as f,E as u,a as c,W as d,p,G as g,S as m}from"./codemirror_view-tmIj4olz.js";const b=1024;let x=0;class k{constructor(t,e){this.from=t,this.to=e}}class y{constructor(t={}){this.id=x++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=S.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}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.contextHash=new y({perNode:!0}),y.lookAhead=new y({perNode:!0}),y.mounted=new y({perNode:!0});class w{constructor(t,e,r){this.tree=t,this.overlay=e,this.parser=r}static get(t){return t&&t.props&&t.props[y.mounted.id]}}const v=Object.create(null);class S{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):v,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new S(t.name||"",e,t.id,r);if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(y.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(y.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}S.none=new S("",Object.create(null),0,8);class A{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let r of this.types){let n=null;for(let e of t){let t=e(r);t&&(n||(n=Object.assign({},r.props)),n[t[0].id]=t[1])}e.push(n?new S(r.name,n,r.id,r.flags):r)}return new A(e)}}const C=new WeakMap,N=new WeakMap;var P;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(P||(P={}));class I{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=w.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let r=t.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new U(this.topNode,t)}cursorAt(t,e=0,r=0){let n=C.get(this)||this.topNode,i=new U(n);return i.moveTo(t,e),C.set(this,i._tree),i}get topNode(){return new D(this,0,0,null)}resolve(t,e=0){let r=T(C.get(this)||this.topNode,t,e,!1);return C.set(this,r),r}resolveInner(t,e=0){let r=T(N.get(this)||this.topNode,t,e,!0);return N.set(this,r),r}resolveStack(t,e=0){return function(t,e,r){let n=t.resolveInner(e,r),i=null;for(let t=n instanceof D?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(i||(i=[n])).push(s.resolve(e,r)),t=s}else{let s=w.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new D(s.tree,s.overlay[0].from+t.from,-1,t);(i||(i=[n])).push(T(o,e,r,!1))}}return i?j(i):n}(this,t,e)}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t,s=t.mode||0,o=(s&P.IncludeAnonymous)>0;for(let t=this.cursor(s|P.IncludeAnonymous);;){let s=!1;if(t.from<=i&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&r&&(o||!t.type.isAnonymous)&&r(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:$(S.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new I(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new I(S.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=b,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(r)?new O(r,r.length):r,a=n.types,h=0,f=0;function u(t,e,r,b,k,y){let{id:w,start:v,end:S,size:A}=l,C=f;for(;A<0;){if(l.next(),-1==A){let e=s[w];return r.push(e),void b.push(v-t)}if(-3==A)return void(h=w);if(-4==A)return void(f=w);throw new RangeError(`Unrecognized record size: ${A}`)}let N,P,I=a[w],O=v-t;if(S-v<=i&&(P=m(l.pos-e,k))){let e=new Uint16Array(P.size-P.skip),r=l.pos-P.size,i=e.length;for(;l.pos>r;)i=x(P.start,e,i);N=new B(e,S-P.start,n),O=P.start-t}else{let t=l.pos-A;l.next();let e=[],r=[],n=w>=o?w:-1,s=0,a=S;for(;l.pos>t;)n>=0&&l.id==n&&l.size>=0?(l.end<=a-i&&(p(e,r,v,s,l.end,a,n,C),s=e.length,a=l.end),l.next()):y>2500?c(v,t,e,r):u(v,t,e,r,n,y+1);if(n>=0&&s>0&&s<e.length&&p(e,r,v,s,v,a,n,C),e.reverse(),r.reverse(),n>-1&&s>0){let t=d(I);N=$(I,e,r,0,e.length,0,S-v,t,t)}else N=g(I,e,r,S-v,C-S)}r.push(N),b.push(O)}function c(t,e,r,s){let o=[],a=0,h=-1;for(;l.pos>e;){let{id:t,start:e,end:r,size:n}=l;if(n>4)l.next();else{if(h>-1&&e<h)break;h<0&&(h=r-i),o.push(t,e,r),a++,l.next()}}if(a){let e=new Uint16Array(4*a),i=o[o.length-2];for(let t=o.length-3,r=0;t>=0;t-=3)e[r++]=o[t],e[r++]=o[t+1]-i,e[r++]=o[t+2]-i,e[r++]=r;r.push(new B(e,o[2]-i,n)),s.push(i-t)}}function d(t){return(e,r,n)=>{let i,s,o=0,l=e.length-1;if(l>=0&&(i=e[l])instanceof I){if(!l&&i.type==t&&i.length==n)return i;(s=i.prop(y.lookAhead))&&(o=r[l]+i.length+s)}return g(t,e,r,n,o)}}function p(t,e,r,i,s,o,l,a){let h=[],f=[];for(;t.length>i;)h.push(t.pop()),f.push(e.pop()+r-s);t.push(g(n.types[l],h,f,o-s,a-o)),e.push(s-r)}function g(t,e,r,n,i=0,s){if(h){let t=[y.contextHash,h];s=s?[t].concat(s):[t]}if(i>25){let t=[y.lookAhead,i];s=s?[t].concat(s):[t]}return new I(t,e,r,n,s)}function m(t,e){let r=l.fork(),n=0,s=0,a=0,h=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-t;if(t<0||l<i||r.start<h)break;let u=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)break t;u+=4}else r.id>=o&&(u+=4);r.next()}s=c,n+=t,a+=u}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=a),f.size>4?f:void 0}function x(t,e,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=l.pos-(a-4);for(;l.pos>n;)r=x(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==a?h=n:-4==a&&(f=n);return r}let k=[],w=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,k,w,-1,0);let v=null!==(e=t.length)&&void 0!==e?e:k.length?w[0]+k[0].length:0;return new I(a[t.topID],k.reverse(),w.reverse(),v)}(t)}}I.empty=new I(S.none,[],[],0);class O{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new O(this.buffer,this.index)}}class B{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return S.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&!(_(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(t,e,r){let n=this.buffer,i=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){i[l++]=n[o++],i[l++]=n[o++]-r;let e=i[l++]=n[o++]-r;i[l++]=n[o++]-t,s=Math.max(s,e)}return new B(i,s,this.set)}}function _(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function T(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof D&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:P.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof D&&n.index<0&&(null===(i=o.enter(e,r,s))||void 0===i?void 0:i.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,r,s);if(!n)return t;t=n}}class M{cursor(t=0){return new U(this,t)}getChild(t,e=null,r=null){let n=E(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return E(this,t,e,r)}resolve(t,e=0){return T(this,t,e,!1)}resolveInner(t,e=0){return T(this,t,e,!0)}matchContext(t){return L(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),r=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(r=e,e=t.prevSibling):e=t}return r}get node(){return this}get next(){return this.parent}}class D extends M{constructor(t,e,r,n){super(),this._tree=t,this.from=e,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=e>0?o.length:-1;t!=a;t+=e){let a=o[t],h=l[t]+s.from;if(_(n,r,h,h+a.length))if(a instanceof B){if(i&P.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,r-h,n);if(o>-1)return new z(new R(s,a,t,h),null,o)}else if(i&P.IncludeAnonymous||!a.type.isAnonymous||F(a)){let o;if(!(i&P.IgnoreMounts)&&(o=w.get(a))&&!o.overlay)return new D(o.tree,h,t,s);let l=new D(a,h,t,s);return i&P.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,r,n)}}if(i&P.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,r=0){let n;if(!(r&P.IgnoreOverlays)&&(n=w.get(this._tree))&&n.overlay){let r=t-this.from;for(let{from:t,to:i}of n.overlay)if((e>0?t<=r:t<r)&&(e<0?i>=r:i>r))return new D(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function E(t,e,r,n){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function L(t,e,r=e.length-1){for(let n=t.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}class R{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class z extends M{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,r){super(),this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new z(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r=0){if(r&P.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return i<0?null:new z(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new z(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 z(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];t.push(r.slice(n,i,s)),e.push(0)}return new I(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function j(t){if(!t.length)return null;let e=0,r=t[0];for(let n=1;n<t.length;n++){let i=t[n];(i.from>r.from||i.to<r.to)&&(r=i,e=n)}let n=r instanceof D&&r.index<0?null:r.parent,i=t.slice();return n?i[e]=n:i.splice(e,1),new W(i,r)}class W{constructor(t,e){this.heads=t,this.node=e}get next(){return j(this.heads)}}class U{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof D)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof D?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=this.mode){return this.buffer?!(r&P.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&P.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&P.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r._tree.children.length;n!=i;n+=t){let t=r._tree.children[n];if(this.mode&P.IncludeAnonymous||t instanceof B||!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,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let t=r;t<this.stack.length;t++)e=new z(this.buffer,e,this.stack[t]);return this.bufferNode=new z(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(t){if(!this.buffer)return L(this.node,t);let{buffer:e}=this.buffer,{types:r}=e.set;for(let n=t.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return L(this.node,t,n);let s=r[e.buffer[this.stack[i]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function F(t){return t.children.some((t=>t instanceof B||!t.type.isAnonymous||F(t)))}const V=new WeakMap;function q(t,e){if(!t.isAnonymous||e instanceof B||e.type!=t)return 1;let r=V.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof I)){r=1;break}r+=q(t,n)}V.set(e,r)}return r}function $(t,e,r,n,i,s,o,l,a){let h=0;for(let r=n;r<i;r++)h+=q(t,e[r]);let f=Math.ceil(1.5*h/8),u=[],c=[];return function e(r,n,i,o,l){for(let h=i;h<o;){let i=h,d=n[h],p=q(t,r[h]);for(h++;h<o;h++){let e=q(t,r[h]);if(p+e>=f)break;p+=e}if(h==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+l);continue}u.push(r[i])}else{let e=n[h-1]+r[h-1].length-d;u.push($(t,r,n,i,h,d,e,null,a))}c.push(d+l-s)}}(e,r,n,i,0),(l||a)(u,c,o)}class H{constructor(){this.map=new WeakMap}setBuffer(t,e,r){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,r)}getBuffer(t,e){let r=this.map.get(t);return r&&r.get(e)}set(t,e){t instanceof z?this.setBuffer(t.context.buffer,t.index,e):t instanceof D&&this.map.set(t.tree,e)}get(t){return t instanceof z?this.getBuffer(t.context.buffer,t.index):t instanceof D?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 G{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new G(0,t.length,t,0,!1,r)];for(let r of e)r.to>t.length&&n.push(r);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,f=h?h.fromA:1e9;if(f-l>=r)for(;s&&s.from<f;){let e=s;if(l>=e.from||f<=e.to||a){let t=Math.max(e.from,l)-a,r=Math.min(e.to,f)-a;e=t>=r?null:new G(t,r,e.tree,e.offset+a,o>0,!!h)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class J{startParse(t,e,r){return"string"==typeof t&&(t=new K(t)),r=r?r.length?r.map((t=>new k(t.from,t.to))):[new k(0,0)]:[new k(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}class K{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 Q=0;class X{constructor(t,e,r){this.set=t,this.base=e,this.modified=r,this.id=Q++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new X([],null,[]);if(e.set.push(e),t)for(let r of t.set)e.set.push(r);return e}static defineModifier(){let t=new Z;return e=>e.modified.indexOf(t)>-1?e:Z.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Y=0;class Z{constructor(){this.instances=[],this.id=Y++}static get(t,e){if(!e.length)return t;let r=e[0].instances.find((r=>{return r.base==t&&(n=e,i=r.modified,n.length==i.length&&n.every(((t,e)=>t==i[e])));var n,i}));if(r)return r;let n=[],i=new X(n,t,e);for(let t of e)t.instances.push(i);let s=function(t){let e=[[]];for(let r=0;r<t.length;r++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(t[r]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)n.push(Z.get(e,t));return i}}function tt(t){let e=Object.create(null);for(let r in t){let n=t[r];Array.isArray(n)||(n=[n]);for(let t of r.split(" "))if(t){let r=[],i=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){i=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+t);if(r.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){i=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=r.length-1,l=r[o];if(!l)throw new RangeError("Invalid path: "+t);let a=new rt(n,i,o>0?r.slice(0,o):null);e[l]=a.sort(e[l])}}return et.add(e)}const et=new y;class rt{constructor(t,e,r,n){this.tags=t,this.mode=e,this.context=r,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function nt(t,e){let r=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)r[t.id]=e.class;else r[e.tag.id]=e.class;let{scope:n,all:i=null}=e||{};return{style:t=>{let e=i;for(let n of t)for(let t of n.set){let n=r[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function it(t,e,r,n=0,i=t.length){let s=new st(n,Array.isArray(e)?e:[e],r);s.highlightRange(t.cursor(),n,i,"",s.highlighters),s.flush(i)}rt.empty=new rt([],2,null);class st{constructor(t,e,r){this.at=t,this.highlighters=e,this.span=r,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,r,n,i){let{type:s,from:o,to:l}=t;if(o>=r||l<=e)return;s.isTop&&(i=this.highlighters.filter((t=>!t.scope||t.scope(s))));let a=n,h=function(t){let e=t.type.prop(et);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||rt.empty,f=function(t,e){let r=null;for(let n of t){let t=n.style(e);t&&(r=r?r+" "+t:t)}return r}(i,h.tags);if(f&&(a&&(a+=" "),a+=f,1==h.mode&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,o),a),h.opaque)return;let u=t.tree&&t.tree.prop(y.mounted);if(u&&u.overlay){let s=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),f=t.firstChild();for(let c=0,d=o;;c++){let p=c<u.overlay.length?u.overlay[c]:null,g=p?p.from+o:l,m=Math.max(e,d),b=Math.min(r,g);if(m<b&&f)for(;t.from<b&&(this.highlightRange(t,m,b,n,i),this.startSpan(Math.min(b,t.to),a),!(t.to>=g)&&t.nextSibling()););if(!p||g>r)break;d=p.to+o,d>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(r,d),"",h),this.startSpan(Math.min(r,d),a))}f&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=r)break;this.highlightRange(t,e,r,n,i),this.startSpan(Math.min(r,t.to),a)}}while(t.nextSibling());t.parent()}}}const ot=X.define,lt=ot(),at=ot(),ht=ot(at),ft=ot(at),ut=ot(),ct=ot(ut),dt=ot(ut),pt=ot(),gt=ot(pt),mt=ot(),bt=ot(),xt=ot(),kt=ot(xt),yt=ot(),wt={comment:lt,lineComment:ot(lt),blockComment:ot(lt),docComment:ot(lt),name:at,variableName:ot(at),typeName:ht,tagName:ot(ht),propertyName:ft,attributeName:ot(ft),className:ot(at),labelName:ot(at),namespace:ot(at),macroName:ot(at),literal:ut,string:ct,docString:ot(ct),character:ot(ct),attributeValue:ot(ct),number:dt,integer:ot(dt),float:ot(dt),bool:ot(ut),regexp:ot(ut),escape:ot(ut),color:ot(ut),url:ot(ut),keyword:mt,self:ot(mt),null:ot(mt),atom:ot(mt),unit:ot(mt),modifier:ot(mt),operatorKeyword:ot(mt),controlKeyword:ot(mt),definitionKeyword:ot(mt),moduleKeyword:ot(mt),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:xt,separator:ot(xt),bracket:kt,angleBracket:ot(kt),squareBracket:ot(kt),paren:ot(kt),brace:ot(kt),content:pt,heading:gt,heading1:ot(gt),heading2:ot(gt),heading3:ot(gt),heading4:ot(gt),heading5:ot(gt),heading6:ot(gt),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:X.defineModifier(),constant:X.defineModifier(),function:X.defineModifier(),standard:X.defineModifier(),local:X.defineModifier(),special:X.defineModifier()};var vt;nt([{tag:wt.link,class:"tok-link"},{tag:wt.heading,class:"tok-heading"},{tag:wt.emphasis,class:"tok-emphasis"},{tag:wt.strong,class:"tok-strong"},{tag:wt.keyword,class:"tok-keyword"},{tag:wt.atom,class:"tok-atom"},{tag:wt.bool,class:"tok-bool"},{tag:wt.url,class:"tok-url"},{tag:wt.labelName,class:"tok-labelName"},{tag:wt.inserted,class:"tok-inserted"},{tag:wt.deleted,class:"tok-deleted"},{tag:wt.literal,class:"tok-literal"},{tag:wt.string,class:"tok-string"},{tag:wt.number,class:"tok-number"},{tag:[wt.regexp,wt.escape,wt.special(wt.string)],class:"tok-string2"},{tag:wt.variableName,class:"tok-variableName"},{tag:wt.local(wt.variableName),class:"tok-variableName tok-local"},{tag:wt.definition(wt.variableName),class:"tok-variableName tok-definition"},{tag:wt.special(wt.variableName),class:"tok-variableName2"},{tag:wt.definition(wt.propertyName),class:"tok-propertyName tok-definition"},{tag:wt.typeName,class:"tok-typeName"},{tag:wt.namespace,class:"tok-namespace"},{tag:wt.className,class:"tok-className"},{tag:wt.macroName,class:"tok-macroName"},{tag:wt.propertyName,class:"tok-propertyName"},{tag:wt.operator,class:"tok-operator"},{tag:wt.comment,class:"tok-comment"},{tag:wt.meta,class:"tok-meta"},{tag:wt.invalid,class:"tok-invalid"},{tag:wt.punctuation,class:"tok-punctuation"}]);const St=new y;function At(e){return t.define({combine:e?t=>t.concat(e):void 0})}const Ct=new y;class Nt{constructor(t,r,n=[],i=""){this.data=t,this.name=i,e.prototype.hasOwnProperty("tree")||Object.defineProperty(e.prototype,"tree",{get(){return Ot(this)}}),this.parser=r,this.extension=[jt.of(this),e.languageData.of(((t,e,r)=>{let n=Pt(t,e,r),i=n.type.prop(St);if(!i)return[];let s=t.facet(i),o=n.type.prop(Ct);if(o){let i=n.resolve(e-n.from,r);for(let e of o)if(e.test(i,t)){let r=t.facet(e.facet);return"replace"==e.type?r:r.concat(s)}}return s}))].concat(n)}isActiveAt(t,e,r=-1){return Pt(t,e,r).type.prop(St)==this.data}findRegions(t){let e=t.facet(jt);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(St)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(y.mounted);if(i){if(i.tree.prop(St)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof I&&n(i,t.positions[r]+e)}};return n(Ot(t),0),r}get allowsNesting(){return!0}}function Pt(t,e,r){let n=t.facet(jt),i=Ot(t).topNode;if(!n||n.allowsNesting)for(let t=i;t;t=t.enter(e,r,P.ExcludeBuffers))t.type.isTop&&(i=t);return i}Nt.setState=r.define();class It extends Nt{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=At(t.languageData);return new It(e,t.parser.configure({props:[St.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new It(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ot(t){let e=t.field(Nt.state,!1);return e?e.tree:I.empty}function Bt(t,e,r=50){var n;let i=null===(n=t.field(Nt.state,!1))||void 0===n?void 0:n.context;if(!i)return null;let s=i.viewport;i.updateViewport({from:0,to:e});let o=i.isDone(e)||i.work(r,e)?i.tree:null;return i.updateViewport(s),o}class _t{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let Tt=null;class Mt{constructor(t,e,r=[],n,i,s,o,l){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new Mt(t,e,[],I.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _t(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=I.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(G.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(G.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Tt;Tt=this;try{return t()}finally{Tt=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Dt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=G.applyChanges(r,e),n=I.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new Mt(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:r,to:n}=this.skipped[e];r<t.to&&n>t.from&&(this.fragments=Dt(this.fragments,r,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends J{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=Tt;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new I(S.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Tt}}function Dt(t,e,r){return G.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class Et{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new Et(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=Mt.create(t.facet(jt).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new Et(r)}}Nt.state=n.define({create:Et.init,update(t,e){for(let t of e.effects)if(t.is(Nt.setState))return t.value;return e.startState.facet(jt)!=e.state.facet(jt)?Et.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,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const Rt="undefined"!=typeof navigator&&(null===(vt=navigator.scheduling)||void 0===vt?void 0:vt.isInputPending)?()=>navigator.scheduling.isInputPending():null,zt=h.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Nt.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(Nt.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:r,viewport:{to:n}}=this.view,i=r.field(Nt.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!Rt?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,l=i.context.work((()=>Rt&&Rt()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Nt.setState.of(new Et(i.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>f(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),jt=t.define({combine:t=>t.length?t[0]:null,enables:t=>[Nt.state,zt,u.contentAttributes.compute([t],(e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}}))]});class Wt{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ut{constructor(t,e,r,n,i,s=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=n,this.loadFunc=i,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{throw this.loading=null,t})))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ut(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let r of t)if(r.filename&&r.filename.test(e))return r;let r=/\.([^.]+)$/.exec(e);if(r)for(let e of t)if(e.extensions.indexOf(r[1])>-1)return e;return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let r of t)if(r.alias.some((t=>t==e)))return r;if(r)for(let r of t)for(let t of r.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return r}return null}}const Ft=t.define(),Vt=t.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function qt(t){let e=t.facet(Vt);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function $t(t,e){let r="",n=t.tabSize,i=t.facet(Vt)[0];if("\t"==i){for(;e>=n;)r+="\t",e-=n;i=" "}for(let t=0;t<e;t++)r+=i;return r}function Ht(t,r){t instanceof e&&(t=new Gt(t));for(let e of t.state.facet(Ft)){let n=e(t,r);if(void 0!==n)return n}let n=Ot(t.state);return n.length>=r?function(t,e,r){let n=e.resolveStack(r),i=n.node.enterUnfinishedNodesBefore(r);if(i!=n.node){let t=[];for(let e=i;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Kt(n,t,r)}(t,n,r):null}class Gt{constructor(t,e={}){this.state=t,this.options=e,this.unit=qt(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:i}=this.options;return null!=n&&n>=r.from&&n<=r.to?i&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:r.text.slice(n-r.from),from:n}:{text:r.text.slice(0,n-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:n}=this.lineAt(t,e);return r.slice(t-n,Math.min(r.length,t+100-n))}column(t,e=1){let{text:r,from:n}=this.lineAt(t,e),i=this.countColumn(r,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(i+=s-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return i(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:n}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let t=i(n);if(t>-1)return t}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Jt=new y;function Kt(t,e,r){for(let n=t;n;n=n.next){let t=Qt(n.node);if(t)return t(Yt.create(e,r,n))}return 0}function Qt(t){let e=t.type.prop(Jt);if(e)return e;let r,n=t.firstChild;if(n&&(r=n.type.prop(y.closedBy))){let e=t.lastChild,n=e&&r.indexOf(e.name)>-1;return t=>ee(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Xt:null}function Xt(){return 0}class Yt extends Gt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new Yt(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(Zt(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Kt(this.context.next,this.base,this.pos)}}function Zt(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function te({closing:t,align:e=!0,units:r=1}){return n=>ee(n,e,r,t)}function ee(t,e,r,n,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||i==t.pos+o,a=e?function(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),o=null==i||i<=s.from?s.to:Math.min(s.to,i);for(let t=r.to;;){let i=e.childAfter(t);if(!i||i==n)return null;if(!i.type.isSkipped)return i.from<o?r:null;t=i.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}function re(){return e.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+200)return t;let s=r.sliceString(i.from,n);if(!e.some((t=>t.test(s))))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let r=Ht(o,e.from);if(null==r)continue;let n=/^\s*/.exec(e.text)[0],i=$t(o,r);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[t,{changes:a,sequential:!0}]:t}))}const ne=t.define(),ie=new y;function se(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function oe(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function le(t,e,r){for(let n of t.facet(ne)){let i=n(t,e,r);if(i)return i}return function(t,e,r){let n=Ot(t);if(n.length<r)return null;let i=null;for(let s=n.resolveStack(r,1);s;s=s.next){let o=s.node;if(o.to<=r||o.from>r)continue;if(i&&o.from<e)break;let l=o.type.prop(ie);if(l&&(o.to<n.length-50||n.length==t.doc.length||!oe(o))){let n=l(o,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(i=n)}}return i}(t,e,r)}function ae(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}const he=r.define({map:ae}),fe=r.define({map:ae});function ue(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some((t=>t.from<=r&&t.to>=r))||e.push(t.lineBlockAt(r));return e}const ce=n.define({create:()=>c.none,update(t,e){t=t.map(e.changes);for(let r of e.effects)if(r.is(he)&&!pe(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(Ae),i=n?c.replace({widget:new Ie(n(e.state,r.value))}):Pe;t=t.update({add:[i.range(r.value.from,r.value.to)]})}else r.is(fe)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){let r=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{t<n&&e>n&&(r=!0)})),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>u.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,((t,e)=>{r.push(t,e)})),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],i=t[r++];if("number"!=typeof n||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");e.push(Pe.range(n,i))}return c.set(e,!0)}});function de(t,e,r){var n;let i=null;return null===(n=t.field(ce,!1))||void 0===n||n.between(e,r,((t,e)=>{(!i||i.from>t)&&(i={from:t,to:e})})),i}function pe(t,e,r){let n=!1;return t.between(e,e,((t,i)=>{t==e&&i==r&&(n=!0)})),n}function ge(t,e){return t.field(ce,!1)?e:e.concat(r.appendConfig.of(Ce()))}const me=t=>{for(let e of ue(t)){let r=le(t.state,e.from,e.to);if(r)return t.dispatch({effects:ge(t.state,[he.of(r),xe(t,r)])}),!0}return!1},be=t=>{if(!t.state.field(ce,!1))return!1;let e=[];for(let r of ue(t)){let n=de(t.state,r.from,r.to);n&&e.push(fe.of(n),xe(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function xe(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return u.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}const ke=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let i=t.lineBlockAt(n),s=le(e,i.from,i.to);s&&r.push(he.of(s)),n=(s?t.lineBlockAt(s.to):i).to+1}return r.length&&t.dispatch({effects:ge(t.state,r)}),!!r.length},ye=t=>{let e=t.state.field(ce,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,((t,e)=>{r.push(fe.of({from:t,to:e}))})),t.dispatch({effects:r}),!0};function we(t,e){for(let r=e;;){let n=le(t.state,r.from,r.to);if(n&&n.to>e.from)return n;if(!r.from)return null;r=t.lineBlockAt(r.from-1)}}const ve=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:me},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:be},{key:"Ctrl-Alt-[",run:ke},{key:"Ctrl-Alt-]",run:ye}],Se={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ae=t.define({combine:t=>o(t,Se)});function Ce(t){let e=[ce,Te];return t&&e.push(Ae.of(t)),e}function Ne(t,e){let{state:r}=t,n=r.facet(Ae),i=e=>{let r=t.lineBlockAt(t.posAtDOM(e.target)),n=de(t.state,r.from,r.to);n&&t.dispatch({effects:fe.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const Pe=c.replace({widget:new class extends d{toDOM(t){return Ne(t,null)}}});class Ie extends d{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ne(t,this.value)}}const Oe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Be extends g{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function _e(t={}){let e=Object.assign(Object.assign({},Oe),t),r=new Be(e,!0),n=new Be(e,!1),i=h.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(jt)!=t.state.facet(jt)||t.startState.field(ce,!1)!=t.state.field(ce,!1)||Ot(t.startState)!=Ot(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new a;for(let i of t.viewportLineBlocks){let s=de(t.state,i.from,i.to)?n:le(t.state,i.from,i.to)?r:null;s&&e.add(i.from,i.from,s)}return e.finish()}}),{domEventHandlers:o}=e;return[i,p({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(i))||void 0===e?void 0:e.markers)||s.empty},initialSpacer:()=>new Be(e,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(t,e,r)=>{if(o.click&&o.click(t,e,r))return!0;let n=de(t.state,e.from,e.to);if(n)return t.dispatch({effects:fe.of(n)}),!0;let i=le(t.state,e.from,e.to);return!!i&&(t.dispatch({effects:he.of(i)}),!0)}})}),Ce()]}const Te=u.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Me{constructor(t,e){let r;function n(t){let e=m.newName();return(r||(r=Object.create(null)))["."+e]=t,e}this.specs=t;const i="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof Nt?t=>t.prop(St)==s.data:s?t=>t==s:void 0,this.style=nt(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:i}).style,this.module=r?new m(r):null,this.themeType=e.themeType}static define(t,e){return new Me(t,e||{})}}const De=t.define(),Ee=t.define({combine:t=>t.length?[t[0]]:null});function Le(t){let e=t.facet(De);return e.length?e:t.facet(Ee)}function Re(t,e){let r,n=[je];return t instanceof Me&&(t.module&&n.push(u.styleModule.of(t.module)),r=t.themeType),(null==e?void 0:e.fallback)?n.push(Ee.of(t)):r?n.push(De.computeN([u.darkTheme],(e=>e.facet(u.darkTheme)==("dark"==r)?[t]:[]))):n.push(De.of(t)),n}class ze{constructor(t){this.markCache=Object.create(null),this.tree=Ot(t.state),this.decorations=this.buildDeco(t,Le(t.state))}update(t){let e=Ot(t.state),r=Le(t.state),n=r!=Le(t.startState);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r))}buildDeco(t,e){if(!e||!this.tree.length)return c.none;let r=new a;for(let{from:n,to:i}of t.visibleRanges)it(this.tree,e,((t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=c.mark({class:n})))}),n,i);return r.finish()}}const je=l.high(h.fromClass(ze,{decorations:t=>t.decorations})),We=Me.define([{tag:wt.meta,color:"#404740"},{tag:wt.link,textDecoration:"underline"},{tag:wt.heading,textDecoration:"underline",fontWeight:"bold"},{tag:wt.emphasis,fontStyle:"italic"},{tag:wt.strong,fontWeight:"bold"},{tag:wt.strikethrough,textDecoration:"line-through"},{tag:wt.keyword,color:"#708"},{tag:[wt.atom,wt.bool,wt.url,wt.contentSeparator,wt.labelName],color:"#219"},{tag:[wt.literal,wt.inserted],color:"#164"},{tag:[wt.string,wt.deleted],color:"#a11"},{tag:[wt.regexp,wt.escape,wt.special(wt.string)],color:"#e40"},{tag:wt.definition(wt.variableName),color:"#00f"},{tag:wt.local(wt.variableName),color:"#30a"},{tag:[wt.typeName,wt.namespace],color:"#085"},{tag:wt.className,color:"#167"},{tag:[wt.special(wt.variableName),wt.macroName],color:"#256"},{tag:wt.definition(wt.propertyName),color:"#00c"},{tag:wt.comment,color:"#940"},{tag:wt.invalid,color:"#f00"}]),Ue=u.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Fe="()[]{}",Ve=t.define({combine:t=>o(t,{afterCursor:!0,brackets:Fe,maxScanDistance:1e4,renderMatch:He})}),qe=c.mark({class:"cm-matchingBracket"}),$e=c.mark({class:"cm-nonmatchingBracket"});function He(t){let e=[],r=t.matched?qe:$e;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}const Ge=[n.define({create:()=>c.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(Ve);for(let t of e.state.selection.ranges){if(!t.empty)continue;let i=Ye(e.state,t.head,-1,n)||t.head>0&&Ye(e.state,t.head-1,1,n)||n.afterCursor&&(Ye(e.state,t.head,1,n)||t.head<e.state.doc.length&&Ye(e.state,t.head+1,-1,n));i&&(r=r.concat(n.renderMatch(i,e.state)))}return c.set(r,!0)},provide:t=>u.decorations.from(t)}),Ue];function Je(t={}){return[Ve.of(t),Ge]}const Ke=new y;function Qe(t,e,r){let n=t.prop(e<0?y.openedBy:y.closedBy);if(n)return n;if(1==t.name.length){let n=r.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[r[n+e]]}return null}function Xe(t){let e=t.type.prop(Ke);return e?e(t.node):t}function Ye(t,e,r,n={}){let i=n.maxScanDistance||1e4,s=n.brackets||Fe,o=Ot(t),l=o.resolveInner(e,r);for(let n=l;n;n=n.parent){let i=Qe(n.type,r,s);if(i&&n.from<n.to){let o=Xe(n);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return Ze(t,e,r,n,o,i,s)}}return function(t,e,r,n,i,s,o){let l=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=r>0)return null;let h={from:r<0?e-1:e,to:r>0?e+1:e},f=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let t=0;!f.next().done&&t<=s;){let s=f.value;r<0&&(t+=s.length);let l=e+t*r;for(let t=r>0?0:s.length-1,e=r>0?s.length:-1;t!=e;t+=r){let e=o.indexOf(s[t]);if(!(e<0||n.resolveInner(l+t,1).type!=i))if(e%2==0==r>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}r>0&&(t+=s.length)}return f.done?{start:h,matched:!1}:null}(t,e,r,o,l.type,i,s)}function Ze(t,e,r,n,i,s,o){let l=n.parent,a={from:i.from,to:i.to},h=0,f=null==l?void 0:l.cursor();if(f&&(r<0?f.childBefore(n.from):f.childAfter(n.to)))do{if(r<0?f.to<=n.from:f.from>=n.to){if(0==h&&s.indexOf(f.type.name)>-1&&f.from<f.to){let t=Xe(f);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Qe(f.type,r,o))h++;else if(Qe(f.type,-r,o)){if(0==h){let t=Xe(f);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(r<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function tr(t,e,r,n=0,i=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=i;for(let i=n;i<e;i++)9==t.charCodeAt(i)?s+=r-s%r:s++;return s}class er{constructor(t,e,r,n){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,r=this.string.charAt(this.pos);if(e="string"==typeof t?r==t:r&&(t instanceof RegExp?t.test(r):t(r)),e)return++this.pos,r}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=tr(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:tr(this.string,null,this.tabSize)}match(t,e,r){if("string"==typeof t){let n=t=>r?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let r=this.string.slice(this.pos).match(t);return r&&r.index>0?null:(r&&!1!==e&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}}function rr(t){if("object"!=typeof t)return t;let e={};for(let r in t){let n=t[r];e[r]=n instanceof Array?n.slice():n}return e}const nr=new WeakMap;class ir extends Nt{constructor(t){let e,r=At(t.languageData),n={name:(i=t).name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||rr,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||hr};var i;super(r,new class extends J{createParse(t,r,n){return new lr(e,t,r,n)}},[Ft.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=S.define({id:fr.length,name:"Document",props:[St.add((()=>t))],top:!0});return fr.push(e),e}(r),e=this,this.streamParser=n,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new gr(n.tokenTable):mr}static define(t){return new ir(t)}getIndent(t,e){let r,n=Ot(t.state),i=n.resolve(e);for(;i&&i.type!=this.topNode;)i=i.parent;if(!i)return null;let{overrideIndentation:s}=t.options;s&&(r=nr.get(t.state),null!=r&&r<e-1e4&&(r=void 0));let o,l,a=sr(this,n,0,i.from,null!=r?r:e);if(a?(l=a.state,o=a.pos+1):(l=this.streamParser.startState(t.unit),o=0),e-o>1e4)return null;for(;o<e;){let r=t.state.doc.lineAt(o),n=Math.min(e,r.to);if(r.length){let e=s?s(r.from):-1,i=new er(r.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;i.pos<n-r.from;)ar(this.streamParser.token,i,l)}else this.streamParser.blankLine(l,t.unit);if(n==e)break;o=r.to+1}let h=t.lineAt(e);return s&&null==r&&nr.set(t.state,h.from),this.streamParser.indent(l,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function sr(t,e,r,n,i){let s=r>=n&&r+e.length<=i&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:r+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=r+e.positions[s],a=o instanceof I&&l<i&&sr(t,o,l,n,i);if(a)return a}return null}function or(t,e,r,n,i){if(i&&r<=0&&n>=e.length)return e;i||e.type!=t.topNode||(i=!0);for(let s=e.children.length-1;s>=0;s--){let o,l=e.positions[s],a=e.children[s];if(l<n&&a instanceof I){if(!(o=or(t,a,r-l,n-l,i)))break;return i?new I(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),l+o.length):o}}return null}class lr{constructor(t,e,r,n){this.lang=t,this.input=e,this.fragments=r,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let i=Mt.get(),s=n[0].from,{state:o,tree:l}=function(t,e,r,n){for(let n of e){let e,i=n.from+(n.openStart?25:0),s=n.to-(n.openEnd?25:0),o=i<=r&&s>r&&sr(t,n.tree,0-n.offset,r,s);if(o&&(e=or(t,n.tree,r+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?qt(n):4),tree:I.empty}}(t,r,s,null==i?void 0:i.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);i&&this.parsedPos<i.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(qt(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=Mt.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=r)break;if(e=e.slice(0,n-(r-e.length)),t++,t==this.ranges.length)break;let i=this.ranges[t].from,s=this.lineAfter(i);e+=s,r=i+s.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){let n=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?n>i:n>=i)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,r,n,i){if(this.ranges.length>1){e+=i=this.skipGapsTo(e,i,1);let t=this.chunk.length;r+=i=this.skipGapsTo(r,i,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,r,n),i}parseLine(t){let{line:e,end:r}=this.nextLine(),n=0,{streamParser:i}=this.lang,s=new er(e,t?t.state.tabSize:4,t?qt(t.state):2);if(s.eol())i.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=ar(i.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=I.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ur,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new I(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 I(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function ar(t,e,r){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,r);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const hr=Object.create(null),fr=[S.none],ur=new A(fr),cr=[],dr=Object.create(null),pr=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"]])pr[t]=xr(hr,e);class gr{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),pr)}resolve(t){return t?this.table[t]||(this.table[t]=xr(this.extra,t)):0}}const mr=new gr(hr);function br(t,e){cr.indexOf(t)>-1||(cr.push(t),console.warn(e))}function xr(t,e){let r=[];for(let n of e.split(" ")){let e=[];for(let r of n.split(".")){let n=t[r]||wt[r];n?"function"==typeof n?e.length?e=e.map(n):br(r,`Modifier ${r} used at start of tag`):e.length?br(r,`Tag ${r} used as modifier`):e=Array.isArray(n)?n:[n]:br(r,`Unknown highlighting tag ${r}`)}for(let t of e)r.push(t)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+r.map((t=>t.id)),s=dr[i];if(s)return s.id;let o=dr[i]=S.define({id:fr.length,name:n,props:[tt({[n]:r})]});return fr.push(o),o.id}var kr=Object.freeze({__proto__:null,DocInput:_t,HighlightStyle:Me,IndentContext:Gt,LRLanguage:It,Language:Nt,LanguageDescription:Ut,LanguageSupport:Wt,ParseContext:Mt,StreamLanguage:ir,StringStream:er,TreeIndentContext:Yt,bracketMatching:Je,bracketMatchingHandle:Ke,codeFolding:Ce,continuedIndent:function({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.baseIndent+(n?0:e*r.unit)}},defaultHighlightStyle:We,defineLanguageFacet:At,delimitedIndent:te,ensureSyntaxTree:Bt,flatIndent:t=>t.baseIndent,foldAll:ke,foldCode:me,foldEffect:he,foldGutter:_e,foldInside:se,foldKeymap:ve,foldNodeProp:ie,foldService:ne,foldState:ce,foldable:le,foldedRanges:function(t){return t.field(ce,!1)||s.empty},forceParsing:function(t,e=t.viewport.to,r=100){let n=Bt(t.state,e,r);return n!=Ot(t.state)&&t.dispatch({}),!!n},getIndentUnit:qt,getIndentation:Ht,highlightingFor:function(t,e,r){let n=Le(t),i=null;if(n)for(let t of n)if(!t.scope||r&&t.scope(r)){let r=t.style(e);r&&(i=i?i+" "+r:r)}return i},indentNodeProp:Jt,indentOnInput:re,indentRange:function(t,e,r){let n=Object.create(null),i=new Gt(t,{overrideIndentation:t=>{var e;return null!==(e=n[t])&&void 0!==e?e:-1}}),s=[];for(let o=e;o<=r;){let e=t.doc.lineAt(o);o=e.to+1;let r=Ht(i,e.from);if(null==r)continue;/\S/.test(e.text)||(r=0);let l=/^\s*/.exec(e.text)[0],a=$t(t,r);l!=a&&(n[e.from]=r,s.push({from:e.from,to:e.from+l.length,insert:a}))}return t.changes(s)},indentService:Ft,indentString:$t,indentUnit:Vt,language:jt,languageDataProp:St,matchBrackets:Ye,sublanguageProp:Ct,syntaxHighlighting:Re,syntaxParserRunning:function(t){var e;return(null===(e=t.plugin(zt))||void 0===e?void 0:e.isWorking())||!1},syntaxTree:Ot,syntaxTreeAvailable:function(t,e=t.doc.length){var r;return(null===(r=t.field(Nt.state,!1))||void 0===r?void 0:r.context.isDone(e))||!1},toggleFold:t=>{let e=[];for(let r of ue(t)){let n=de(t.state,r.from,r.to);if(n)e.push(fe.of(n),xe(t,n,!1));else{let n=we(t,r);n&&e.push(he.of(n),xe(t,n))}}return e.length>0&&t.dispatch({effects:ge(t.state,e)}),!!e.length},unfoldAll:ye,unfoldCode:be,unfoldEffect:fe});export{b as D,P as I,It as L,A as N,J as P,I as T,S as a,y as b,tt as c,Jt as d,te as e,ie as f,se as g,Wt as h,Vt as i,H as j,_e as k,re as l,Re as m,We as n,Je as o,ve as p,Gt as q,Ht as r,Ot as s,wt as t,$t as u,Ye as v,qt as w,kr as x};
2
+ //# sourceMappingURL=codemirror_language-U9l5bLBC.js.map