@pyscript/core 0.6.7 → 0.6.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 (81) hide show
  1. package/dist/codemirror-1dOfKU91.js +1832 -0
  2. package/dist/{codemirror-BFaBdIfQ.js.map → codemirror-1dOfKU91.js.map} +1 -1
  3. package/dist/codemirror_commands-CKMxnUcp.js +1714 -0
  4. package/dist/codemirror_commands-CKMxnUcp.js.map +1 -0
  5. package/dist/codemirror_lang-python-D9DYtDWr.js +2462 -0
  6. package/dist/{codemirror_lang-python-DvjhpaK2.js.map → codemirror_lang-python-D9DYtDWr.js.map} +1 -1
  7. package/dist/codemirror_language-B5lTPv2c.js +5337 -0
  8. package/dist/{codemirror_language-4kk4Aqm3.js.map → codemirror_language-B5lTPv2c.js.map} +1 -1
  9. package/dist/codemirror_state-n1sFh2hh.js +3930 -0
  10. package/dist/{codemirror_state-1d1uncXx.js.map → codemirror_state-n1sFh2hh.js.map} +1 -1
  11. package/dist/codemirror_view-1a1gCrKZ.js +11428 -0
  12. package/dist/{codemirror_view-aIuSN42d.js.map → codemirror_view-1a1gCrKZ.js.map} +1 -1
  13. package/dist/core-D2ytnMSk.js +4349 -0
  14. package/dist/core-D2ytnMSk.js.map +1 -0
  15. package/dist/core.css +75 -1
  16. package/dist/core.js +1 -1
  17. package/dist/deprecations-manager-Cf_aFUPK.js +29 -0
  18. package/dist/{deprecations-manager-BWDz_-4h.js.map → deprecations-manager-Cf_aFUPK.js.map} +1 -1
  19. package/dist/donkey-Cc8svH2Q.js +170 -0
  20. package/dist/{donkey-DvIAJuTW.js.map → donkey-Cc8svH2Q.js.map} +1 -1
  21. package/dist/error-DWoeKPDI.js +59 -0
  22. package/dist/{error-CVKnHrMr.js.map → error-DWoeKPDI.js.map} +1 -1
  23. package/dist/index-BVFrv_QY.js +1911 -0
  24. package/dist/{index-DqgFLybq.js.map → index-BVFrv_QY.js.map} +1 -1
  25. package/dist/mpy-CQiuZcjW.js +255 -0
  26. package/dist/{mpy-DoOh7bKP.js.map → mpy-CQiuZcjW.js.map} +1 -1
  27. package/dist/py-BgH4mprx.js +182 -0
  28. package/dist/{py-D401PjM8.js.map → py-BgH4mprx.js.map} +1 -1
  29. package/dist/py-editor-Dzsa3rsF.js +433 -0
  30. package/dist/{py-editor-Dxs1clgy.js.map → py-editor-Dzsa3rsF.js.map} +1 -1
  31. package/dist/py-terminal-BX_wPoTi.js +61 -0
  32. package/dist/{py-terminal-eUGMSqwz.js.map → py-terminal-BX_wPoTi.js.map} +1 -1
  33. package/dist/storage.js +421 -1
  34. package/dist/storage.js.map +1 -1
  35. package/dist/toml-CkEFU7ly.js +103 -0
  36. package/dist/{toml-DiUM0_qs.js.map → toml-CkEFU7ly.js.map} +1 -1
  37. package/dist/toml-DTuPg5as.js +5 -0
  38. package/dist/toml-DTuPg5as.js.map +1 -0
  39. package/dist/xterm-eU6F6YKE.js +10 -0
  40. package/dist/xterm-eU6F6YKE.js.map +1 -0
  41. package/dist/xterm-readline-C7HDczqS.js +501 -0
  42. package/dist/xterm-readline-C7HDczqS.js.map +1 -0
  43. package/dist/xterm_addon-fit-Cotzxdkz.js +10 -0
  44. package/dist/xterm_addon-fit-Cotzxdkz.js.map +1 -0
  45. package/dist/xterm_addon-web-links-DoNfCjeX.js +10 -0
  46. package/dist/xterm_addon-web-links-DoNfCjeX.js.map +1 -0
  47. package/dist/zip-Cj6c-tjp.js +13 -0
  48. package/dist/zip-Cj6c-tjp.js.map +1 -0
  49. package/package.json +5 -5
  50. package/src/core.js +2 -2
  51. package/src/stdlib/pyscript.js +13 -13
  52. package/dist/codemirror-BFaBdIfQ.js +0 -2
  53. package/dist/codemirror_commands-CvnouHng.js +0 -2
  54. package/dist/codemirror_commands-CvnouHng.js.map +0 -1
  55. package/dist/codemirror_lang-python-DvjhpaK2.js +0 -2
  56. package/dist/codemirror_language-4kk4Aqm3.js +0 -2
  57. package/dist/codemirror_state-1d1uncXx.js +0 -2
  58. package/dist/codemirror_view-aIuSN42d.js +0 -2
  59. package/dist/core-S0XBQFwV.js +0 -2
  60. package/dist/core-S0XBQFwV.js.map +0 -1
  61. package/dist/deprecations-manager-BWDz_-4h.js +0 -2
  62. package/dist/donkey-DvIAJuTW.js +0 -2
  63. package/dist/error-CVKnHrMr.js +0 -2
  64. package/dist/index-DqgFLybq.js +0 -2
  65. package/dist/mpy-DoOh7bKP.js +0 -2
  66. package/dist/py-D401PjM8.js +0 -2
  67. package/dist/py-editor-Dxs1clgy.js +0 -2
  68. package/dist/py-terminal-eUGMSqwz.js +0 -2
  69. package/dist/toml-CvAfdf9_.js +0 -3
  70. package/dist/toml-CvAfdf9_.js.map +0 -1
  71. package/dist/toml-DiUM0_qs.js +0 -3
  72. package/dist/xterm-BY7uk_OU.js +0 -2
  73. package/dist/xterm-BY7uk_OU.js.map +0 -1
  74. package/dist/xterm-readline-CZfBw7ic.js +0 -2
  75. package/dist/xterm-readline-CZfBw7ic.js.map +0 -1
  76. package/dist/xterm_addon-fit--gyF3PcZ.js +0 -2
  77. package/dist/xterm_addon-fit--gyF3PcZ.js.map +0 -1
  78. package/dist/xterm_addon-web-links-Cnej-nJ6.js +0 -2
  79. package/dist/xterm_addon-web-links-Cnej-nJ6.js.map +0 -1
  80. package/dist/zip-Bf48tRr5.js +0 -2
  81. package/dist/zip-Bf48tRr5.js.map +0 -1
@@ -1,2 +0,0 @@
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-1d1uncXx.js";import{V as h,l as f,E as u,a as c,W as d,p,D as g,G as m,S as b}from"./codemirror_view-aIuSN42d.js";const x=1024;let k=0;class y{constructor(t,e){this.from=t,this.to=e}}class w{constructor(t={}){this.id=k++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=A.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}w.closedBy=new w({deserialize:t=>t.split(" ")}),w.openedBy=new w({deserialize:t=>t.split(" ")}),w.group=new w({deserialize:t=>t.split(" ")}),w.isolate=new w({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),w.contextHash=new w({perNode:!0}),w.lookAhead=new w({perNode:!0}),w.mounted=new w({perNode:!0});class v{constructor(t,e,r){this.tree=t,this.overlay=e,this.parser=r}static get(t){return t&&t.props&&t.props[w.mounted.id]}}const S=Object.create(null);class A{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):S,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new A(t.name||"",e,t.id,r);if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(w.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(w.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}A.none=new A("",Object.create(null),0,8);class C{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let r of this.types){let n=null;for(let e of t){let t=e(r);t&&(n||(n=Object.assign({},r.props)),n[t[0].id]=t[1])}e.push(n?new A(r.name,n,r.id,r.flags):r)}return new C(e)}}const N=new WeakMap,P=new WeakMap;var I;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(I||(I={}));class T{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=v.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let r=t.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new F(this.topNode,t)}cursorAt(t,e=0,r=0){let n=N.get(this)||this.topNode,i=new F(n);return i.moveTo(t,e),N.set(this,i._tree),i}get topNode(){return new L(this,0,0,null)}resolve(t,e=0){let r=M(N.get(this)||this.topNode,t,e,!1);return N.set(this,r),r}resolveInner(t,e=0){let r=M(P.get(this)||this.topNode,t,e,!0);return P.set(this,r),r}resolveStack(t,e=0){return function(t,e,r){let n=t.resolveInner(e,r),i=null;for(let t=n instanceof L?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(i||(i=[n])).push(s.resolve(e,r)),t=s}else{let s=v.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new L(s.tree,s.overlay[0].from+t.from,-1,t);(i||(i=[n])).push(M(o,e,r,!1))}}return i?W(i):n}(this,t,e)}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t,s=t.mode||0,o=(s&I.IncludeAnonymous)>0;for(let t=this.cursor(s|I.IncludeAnonymous);;){let s=!1;if(t.from<=i&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&r&&(o||!t.type.isAnonymous)&&r(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:H(A.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new T(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new T(A.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=x,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(r)?new O(r,r.length):r,a=n.types,h=0,f=0;function u(t,e,r,x,k,y){let{id:w,start:v,end:S,size:A}=l,C=f,N=h;for(;A<0;){if(l.next(),-1==A){let e=s[w];return r.push(e),void x.push(v-t)}if(-3==A)return void(h=w);if(-4==A)return void(f=w);throw new RangeError(`Unrecognized record size: ${A}`)}let P,I,T=a[w],O=v-t;if(S-v<=i&&(I=m(l.pos-e,k))){let e=new Uint16Array(I.size-I.skip),r=l.pos-I.size,i=e.length;for(;l.pos>r;)i=b(I.start,e,i);P=new B(e,S-I.start,n),O=I.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,N),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,N),e.reverse(),r.reverse(),n>-1&&s>0){let t=d(T,N);P=H(T,e,r,0,e.length,0,S-v,t,t)}else P=g(T,e,r,S-v,C-S,N)}r.push(P),x.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,e){return(r,n,i)=>{let s,o,l=0,a=r.length-1;if(a>=0&&(s=r[a])instanceof T){if(!a&&s.type==t&&s.length==i)return s;(o=s.prop(w.lookAhead))&&(l=n[a]+s.length+o)}return g(t,r,n,i,l,e)}}function p(t,e,r,i,s,o,l,a,h){let f=[],u=[];for(;t.length>i;)f.push(t.pop()),u.push(e.pop()+r-s);t.push(g(n.types[l],f,u,o-s,a-o,h)),e.push(s-r)}function g(t,e,r,n,i,s,o){if(s){let t=[w.contextHash,s];o=o?[t].concat(o):[t]}if(i>25){let t=[w.lookAhead,i];o=o?[t].concat(o):[t]}return new T(t,e,r,n,o)}function m(t,e){let r=l.fork(),n=0,s=0,a=0,h=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-t;if(t<0||l<i||r.start<h)break;let u=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)break t;u+=4}else r.id>=o&&(u+=4);r.next()}s=c,n+=t,a+=u}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=a),f.size>4?f:void 0}function b(t,e,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=l.pos-(a-4);for(;l.pos>n;)r=b(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==a?h=n:-4==a&&(f=n);return r}let k=[],y=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,k,y,-1,0);let v=null!==(e=t.length)&&void 0!==e?e:k.length?y[0]+k[0].length:0;return new T(a[t.topID],k.reverse(),y.reverse(),v)}(t)}}T.empty=new T(A.none,[],[],0);class O{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new O(this.buffer,this.index)}}class B{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return A.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&!(_(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(t,e,r){let n=this.buffer,i=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){i[l++]=n[o++],i[l++]=n[o++]-r;let e=i[l++]=n[o++]-r;i[l++]=n[o++]-t,s=Math.max(s,e)}return new B(i,s,this.set)}}function _(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function M(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof L&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:I.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof L&&n.index<0&&(null===(i=o.enter(e,r,s))||void 0===i?void 0:i.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,r,s);if(!n)return t;t=n}}class D{cursor(t=0){return new F(this,t)}getChild(t,e=null,r=null){let n=E(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return E(this,t,e,r)}resolve(t,e=0){return M(this,t,e,!1)}resolveInner(t,e=0){return M(this,t,e,!0)}matchContext(t){return R(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),r=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(r=e,e=t.prevSibling):e=t}return r}get node(){return this}get next(){return this.parent}}class L extends D{constructor(t,e,r,n){super(),this._tree=t,this.from=e,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=e>0?o.length:-1;t!=a;t+=e){let a=o[t],h=l[t]+s.from;if(_(n,r,h,h+a.length))if(a instanceof B){if(i&I.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,r-h,n);if(o>-1)return new j(new z(s,a,t,h),null,o)}else if(i&I.IncludeAnonymous||!a.type.isAnonymous||V(a)){let o;if(!(i&I.IgnoreMounts)&&(o=v.get(a))&&!o.overlay)return new L(o.tree,h,t,s);let l=new L(a,h,t,s);return i&I.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,r,n)}}if(i&I.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,r=0){let n;if(!(r&I.IgnoreOverlays)&&(n=v.get(this._tree))&&n.overlay){let r=t-this.from;for(let{from:t,to:i}of n.overlay)if((e>0?t<=r:t<r)&&(e<0?i>=r:i>r))return new L(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function E(t,e,r,n){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(let t=!1;!t;)if(t=i.type.is(r),!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function R(t,e,r=e.length-1){for(let n=t;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}class z{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class j extends D{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,r){super(),this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new j(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r=0){if(r&I.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return i<0?null:new j(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new j(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new j(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];t.push(r.slice(n,i,s)),e.push(0)}return new T(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function W(t){if(!t.length)return null;let e=0,r=t[0];for(let n=1;n<t.length;n++){let i=t[n];(i.from>r.from||i.to<r.to)&&(r=i,e=n)}let n=r instanceof L&&r.index<0?null:r.parent,i=t.slice();return n?i[e]=n:i.splice(e,1),new U(i,r)}class U{constructor(t,e){this.heads=t,this.node=e}get next(){return W(this.heads)}}class F{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof L)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof L?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=this.mode){return this.buffer?!(r&I.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&I.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&I.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r._tree.children.length;n!=i;n+=t){let t=r._tree.children[n];if(this.mode&I.IncludeAnonymous||t instanceof B||!t.type.isAnonymous||V(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let t=r;t<this.stack.length;t++)e=new j(this.buffer,e,this.stack[t]);return this.bufferNode=new j(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(t){if(!this.buffer)return R(this.node.parent,t);let{buffer:e}=this.buffer,{types:r}=e.set;for(let n=t.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return R(this._tree,t,n);let s=r[e.buffer[this.stack[i]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function V(t){return t.children.some((t=>t instanceof B||!t.type.isAnonymous||V(t)))}const $=new WeakMap;function q(t,e){if(!t.isAnonymous||e instanceof B||e.type!=t)return 1;let r=$.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof T)){r=1;break}r+=q(t,n)}$.set(e,r)}return r}function H(t,e,r,n,i,s,o,l,a){let h=0;for(let r=n;r<i;r++)h+=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(H(t,r,n,i,h,d,e,null,a))}c.push(d+l-s)}}(e,r,n,i,0),(l||a)(u,c,o)}class G{constructor(){this.map=new WeakMap}setBuffer(t,e,r){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,r)}getBuffer(t,e){let r=this.map.get(t);return r&&r.get(e)}set(t,e){t instanceof j?this.setBuffer(t.context.buffer,t.index,e):t instanceof L&&this.map.set(t.tree,e)}get(t){return t instanceof j?this.getBuffer(t.context.buffer,t.index):t instanceof L?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class J{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new J(0,t.length,t,0,!1,r)];for(let r of e)r.to>t.length&&n.push(r);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,f=h?h.fromA:1e9;if(f-l>=r)for(;s&&s.from<f;){let e=s;if(l>=e.from||f<=e.to||a){let t=Math.max(e.from,l)-a,r=Math.min(e.to,f)-a;e=t>=r?null:new J(t,r,e.tree,e.offset+a,o>0,!!h)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class K{startParse(t,e,r){return"string"==typeof t&&(t=new Q(t)),r=r?r.length?r.map((t=>new y(t.from,t.to))):[new y(0,0)]:[new y(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}class Q{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new w({perNode:!0});let X=0;class Y{constructor(t,e,r,n){this.name=t,this.set=e,this.base=r,this.modified=n,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 r="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 n=new Y(r,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}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 r=e[0].instances.find((r=>{return r.base==t&&(n=e,i=r.modified,n.length==i.length&&n.every(((t,e)=>t==i[e])));var n,i}));if(r)return r;let n=[],i=new Y(t.name,n,t,e);for(let t of e)t.instances.push(i);let s=function(t){let e=[[]];for(let r=0;r<t.length;r++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(t[r]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)n.push(tt.get(e,t));return i}}function et(t){let e=Object.create(null);for(let r in t){let n=t[r];Array.isArray(n)||(n=[n]);for(let t of r.split(" "))if(t){let r=[],i=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){i=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+t);if(r.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){i=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=r.length-1,l=r[o];if(!l)throw new RangeError("Invalid path: "+t);let a=new nt(n,i,o>0?r.slice(0,o):null);e[l]=a.sort(e[l])}}return rt.add(e)}const rt=new w;class nt{constructor(t,e,r,n){this.tags=t,this.mode=e,this.context=r,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function it(t,e){let r=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)r[t.id]=e.class;else r[e.tag.id]=e.class;let{scope:n,all:i=null}=e||{};return{style:t=>{let e=i;for(let n of t)for(let t of n.set){let n=r[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function st(t,e,r,n=0,i=t.length){let s=new ot(n,Array.isArray(e)?e:[e],r);s.highlightRange(t.cursor(),n,i,"",s.highlighters),s.flush(i)}nt.empty=new nt([],2,null);class ot{constructor(t,e,r){this.at=t,this.highlighters=e,this.span=r,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,r,n,i){let{type:s,from:o,to:l}=t;if(o>=r||l<=e)return;s.isTop&&(i=this.highlighters.filter((t=>!t.scope||t.scope(s))));let a=n,h=function(t){let e=t.type.prop(rt);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||nt.empty,f=function(t,e){let r=null;for(let n of t){let t=n.style(e);t&&(r=r?r+" "+t:t)}return r}(i,h.tags);if(f&&(a&&(a+=" "),a+=f,1==h.mode&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,o),a),h.opaque)return;let u=t.tree&&t.tree.prop(w.mounted);if(u&&u.overlay){let s=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),f=t.firstChild();for(let c=0,d=o;;c++){let p=c<u.overlay.length?u.overlay[c]:null,g=p?p.from+o:l,m=Math.max(e,d),b=Math.min(r,g);if(m<b&&f)for(;t.from<b&&(this.highlightRange(t,m,b,n,i),this.startSpan(Math.min(b,t.to),a),!(t.to>=g)&&t.nextSibling()););if(!p||g>r)break;d=p.to+o,d>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(r,d),"",h),this.startSpan(Math.min(r,d),a))}f&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=r)break;this.highlightRange(t,e,r,n,i),this.startSpan(Math.min(r,t.to),a)}}while(t.nextSibling());t.parent()}}}const lt=Y.define,at=lt(),ht=lt(),ft=lt(ht),ut=lt(ht),ct=lt(),dt=lt(ct),pt=lt(ct),gt=lt(),mt=lt(gt),bt=lt(),xt=lt(),kt=lt(),yt=lt(kt),wt=lt(),vt={comment:at,lineComment:lt(at),blockComment:lt(at),docComment:lt(at),name:ht,variableName:lt(ht),typeName:ft,tagName:lt(ft),propertyName:ut,attributeName:lt(ut),className:lt(ht),labelName:lt(ht),namespace:lt(ht),macroName:lt(ht),literal:ct,string:dt,docString:lt(dt),character:lt(dt),attributeValue:lt(dt),number:pt,integer:lt(pt),float:lt(pt),bool:lt(ct),regexp:lt(ct),escape:lt(ct),color:lt(ct),url:lt(ct),keyword:bt,self:lt(bt),null:lt(bt),atom:lt(bt),unit:lt(bt),modifier:lt(bt),operatorKeyword:lt(bt),controlKeyword:lt(bt),definitionKeyword:lt(bt),moduleKeyword:lt(bt),operator:xt,derefOperator:lt(xt),arithmeticOperator:lt(xt),logicOperator:lt(xt),bitwiseOperator:lt(xt),compareOperator:lt(xt),updateOperator:lt(xt),definitionOperator:lt(xt),typeOperator:lt(xt),controlOperator:lt(xt),punctuation:kt,separator:lt(kt),bracket:yt,angleBracket:lt(yt),squareBracket:lt(yt),paren:lt(yt),brace:lt(yt),content:gt,heading:mt,heading1:lt(mt),heading2:lt(mt),heading3:lt(mt),heading4:lt(mt),heading5:lt(mt),heading6:lt(mt),contentSeparator:lt(gt),list:lt(gt),quote:lt(gt),emphasis:lt(gt),strong:lt(gt),link:lt(gt),monospace:lt(gt),strikethrough:lt(gt),inserted:lt(),deleted:lt(),changed:lt(),invalid:lt(),meta:wt,documentMeta:lt(wt),annotation:lt(wt),processingInstruction:lt(wt),definition:Y.defineModifier("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 vt){let e=vt[t];e instanceof Y&&(e.name=t)}var St;it([{tag:vt.link,class:"tok-link"},{tag:vt.heading,class:"tok-heading"},{tag:vt.emphasis,class:"tok-emphasis"},{tag:vt.strong,class:"tok-strong"},{tag:vt.keyword,class:"tok-keyword"},{tag:vt.atom,class:"tok-atom"},{tag:vt.bool,class:"tok-bool"},{tag:vt.url,class:"tok-url"},{tag:vt.labelName,class:"tok-labelName"},{tag:vt.inserted,class:"tok-inserted"},{tag:vt.deleted,class:"tok-deleted"},{tag:vt.literal,class:"tok-literal"},{tag:vt.string,class:"tok-string"},{tag:vt.number,class:"tok-number"},{tag:[vt.regexp,vt.escape,vt.special(vt.string)],class:"tok-string2"},{tag:vt.variableName,class:"tok-variableName"},{tag:vt.local(vt.variableName),class:"tok-variableName tok-local"},{tag:vt.definition(vt.variableName),class:"tok-variableName tok-definition"},{tag:vt.special(vt.variableName),class:"tok-variableName2"},{tag:vt.definition(vt.propertyName),class:"tok-propertyName tok-definition"},{tag:vt.typeName,class:"tok-typeName"},{tag:vt.namespace,class:"tok-namespace"},{tag:vt.className,class:"tok-className"},{tag:vt.macroName,class:"tok-macroName"},{tag:vt.propertyName,class:"tok-propertyName"},{tag:vt.operator,class:"tok-operator"},{tag:vt.comment,class:"tok-comment"},{tag:vt.meta,class:"tok-meta"},{tag:vt.invalid,class:"tok-invalid"},{tag:vt.punctuation,class:"tok-punctuation"}]);const At=new w;function Ct(e){return t.define({combine:e?t=>t.concat(e):void 0})}const Nt=new w;class Pt{constructor(t,r,n=[],i=""){this.data=t,this.name=i,e.prototype.hasOwnProperty("tree")||Object.defineProperty(e.prototype,"tree",{get(){return Ot(this)}}),this.parser=r,this.extension=[Wt.of(this),e.languageData.of(((t,e,r)=>{let n=It(t,e,r),i=n.type.prop(At);if(!i)return[];let s=t.facet(i),o=n.type.prop(Nt);if(o){let i=n.resolve(e-n.from,r);for(let e of o)if(e.test(i,t)){let r=t.facet(e.facet);return"replace"==e.type?r:r.concat(s)}}return s}))].concat(n)}isActiveAt(t,e,r=-1){return It(t,e,r).type.prop(At)==this.data}findRegions(t){let e=t.facet(Wt);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(At)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(w.mounted);if(i){if(i.tree.prop(At)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof T&&n(i,t.positions[r]+e)}};return n(Ot(t),0),r}get allowsNesting(){return!0}}function It(t,e,r){let n=t.facet(Wt),i=Ot(t).topNode;if(!n||n.allowsNesting)for(let t=i;t;t=t.enter(e,r,I.ExcludeBuffers))t.type.isTop&&(i=t);return i}Pt.setState=r.define();class Tt extends Pt{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=Ct(t.languageData);return new Tt(e,t.parser.configure({props:[At.add((t=>t.isTop?e:void 0))]}),t.name)}configure(t,e){return new Tt(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ot(t){let e=t.field(Pt.state,!1);return e?e.tree:T.empty}function Bt(t,e,r=50){var n;let i=null===(n=t.field(Pt.state,!1))||void 0===n?void 0:n.context;if(!i)return null;let s=i.viewport;i.updateViewport({from:0,to:e});let o=i.isDone(e)||i.work(r,e)?i.tree:null;return i.updateViewport(s),o}class _t{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let Mt=null;class Dt{constructor(t,e,r=[],n,i,s,o,l){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new Dt(t,e,[],T.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _t(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=T.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(J.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(J.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Mt;Mt=this;try{return t()}finally{Mt=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Lt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=J.applyChanges(r,e),n=T.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new Dt(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:r,to:n}=this.skipped[e];r<t.to&&n>t.from&&(this.fragments=Lt(this.fragments,r,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends K{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=Mt;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new T(A.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Mt}}function Lt(t,e,r){return J.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class Et{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new Et(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=Dt.create(t.facet(Wt).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new Et(r)}}Pt.state=n.define({create:Et.init,update(t,e){for(let t of e.effects)if(t.is(Pt.setState))return t.value;return e.startState.facet(Wt)!=e.state.facet(Wt)?Et.init(e.state):t.apply(e)}});let Rt=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Rt=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const zt="undefined"!=typeof navigator&&(null===(St=navigator.scheduling)||void 0===St?void 0:St.isInputPending)?()=>navigator.scheduling.isInputPending():null,jt=h.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Pt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Pt.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Rt(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(Pt.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!zt?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,l=i.context.work((()=>zt&&zt()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Pt.setState.of(new Et(i.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>f(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Wt=t.define({combine:t=>t.length?t[0]:null,enables:t=>[Pt.state,jt,u.contentAttributes.compute([t],(e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}}))]});class Ut{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ft{constructor(t,e,r,n,i,s=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=n,this.loadFunc=i,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{throw this.loading=null,t})))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ft(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let r of t)if(r.filename&&r.filename.test(e))return r;let r=/\.([^.]+)$/.exec(e);if(r)for(let e of t)if(e.extensions.indexOf(r[1])>-1)return e;return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let r of t)if(r.alias.some((t=>t==e)))return r;if(r)for(let r of t)for(let t of r.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return r}return null}}const Vt=t.define(),$t=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($t);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Ht(t,e){let r="",n=t.tabSize,i=t.facet($t)[0];if("\t"==i){for(;e>=n;)r+="\t",e-=n;i=" "}for(let t=0;t<e;t++)r+=i;return r}function Gt(t,r){t instanceof e&&(t=new Jt(t));for(let e of t.state.facet(Vt)){let n=e(t,r);if(void 0!==n)return n}let n=Ot(t.state);return n.length>=r?function(t,e,r){let n=e.resolveStack(r),i=n.node.enterUnfinishedNodesBefore(r);if(i!=n.node){let t=[];for(let e=i;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Qt(n,t,r)}(t,n,r):null}class Jt{constructor(t,e={}){this.state=t,this.options=e,this.unit=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 Kt=new w;function Qt(t,e,r){for(let n=t;n;n=n.next){let t=Xt(n.node);if(t)return t(Zt.create(e,r,n))}return 0}function Xt(t){let e=t.type.prop(Kt);if(e)return e;let r,n=t.firstChild;if(n&&(r=n.type.prop(w.closedBy))){let e=t.lastChild,n=e&&r.indexOf(e.name)>-1;return t=>re(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Yt:null}function Yt(){return 0}class Zt extends Jt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new Zt(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(te(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Qt(this.context.next,this.base,this.pos)}}function te(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function ee({closing:t,align:e=!0,units:r=1}){return n=>re(n,e,r,t)}function re(t,e,r,n,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||i==t.pos+o,a=e?function(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),o=null==i||i<=s.from?s.to:Math.min(s.to,i);for(let t=r.to;;){let i=e.childAfter(t);if(!i||i==n)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let t=/^ */.exec(s.text.slice(r.to-s.from))[0].length;return{from:r.from,to:r.to+t}}t=i.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*r)}function ne(){return e.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+200)return t;let s=r.sliceString(i.from,n);if(!e.some((t=>t.test(s))))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let r=Gt(o,e.from);if(null==r)continue;let n=/^\s*/.exec(e.text)[0],i=Ht(o,r);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[t,{changes:a,sequential:!0}]:t}))}const ie=t.define(),se=new w;function oe(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function le(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function ae(t,e,r){for(let n of t.facet(ie)){let i=n(t,e,r);if(i)return i}return function(t,e,r){let n=Ot(t);if(n.length<r)return null;let i=null;for(let s=n.resolveStack(r,1);s;s=s.next){let o=s.node;if(o.to<=r||o.from>r)continue;if(i&&o.from<e)break;let l=o.type.prop(se);if(l&&(o.to<n.length-50||n.length==t.doc.length||!le(o))){let n=l(o,t);n&&n.from<=r&&n.from>=e&&n.to>r&&(i=n)}}return i}(t,e,r)}function he(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}const fe=r.define({map:he}),ue=r.define({map:he});function ce(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some((t=>t.from<=r&&t.to>=r))||e.push(t.lineBlockAt(r));return e}const de=n.define({create:()=>c.none,update(t,e){t=t.map(e.changes);for(let r of e.effects)if(r.is(fe)&&!ge(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(Ce),i=n?c.replace({widget:new Te(n(e.state,r.value))}):Ie;t=t.update({add:[i.range(r.value.from,r.value.to)]})}else r.is(ue)&&(t=t.update({filter:(t,e)=>r.value.from!=t||r.value.to!=e,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){let r=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{t<n&&e>n&&(r=!0)})),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>u.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,((t,e)=>{r.push(t,e)})),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],i=t[r++];if("number"!=typeof n||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");e.push(Ie.range(n,i))}return c.set(e,!0)}});function pe(t,e,r){var n;let i=null;return null===(n=t.field(de,!1))||void 0===n||n.between(e,r,((t,e)=>{(!i||i.from>t)&&(i={from:t,to:e})})),i}function ge(t,e,r){let n=!1;return t.between(e,e,((t,i)=>{t==e&&i==r&&(n=!0)})),n}function me(t,e){return t.field(de,!1)?e:e.concat(r.appendConfig.of(Ne()))}const be=t=>{for(let e of ce(t)){let r=ae(t.state,e.from,e.to);if(r)return t.dispatch({effects:me(t.state,[fe.of(r),ke(t,r)])}),!0}return!1},xe=t=>{if(!t.state.field(de,!1))return!1;let e=[];for(let r of ce(t)){let n=pe(t.state,r.from,r.to);n&&e.push(ue.of(n),ke(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function ke(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return u.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}const ye=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let i=t.lineBlockAt(n),s=ae(e,i.from,i.to);s&&r.push(fe.of(s)),n=(s?t.lineBlockAt(s.to):i).to+1}return r.length&&t.dispatch({effects:me(t.state,r)}),!!r.length},we=t=>{let e=t.state.field(de,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,((t,e)=>{r.push(ue.of({from:t,to:e}))})),t.dispatch({effects:r}),!0};function ve(t,e){for(let r=e;;){let n=ae(t.state,r.from,r.to);if(n&&n.to>e.from)return n;if(!r.from)return null;r=t.lineBlockAt(r.from-1)}}const Se=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:be},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:xe},{key:"Ctrl-Alt-[",run:ye},{key:"Ctrl-Alt-]",run:we}],Ae={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ce=t.define({combine:t=>o(t,Ae)});function Ne(t){let e=[de,Me];return t&&e.push(Ce.of(t)),e}function Pe(t,e){let{state:r}=t,n=r.facet(Ce),i=e=>{let r=t.lineBlockAt(t.posAtDOM(e.target)),n=pe(t.state,r.from,r.to);n&&t.dispatch({effects:ue.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const Ie=c.replace({widget:new class extends d{toDOM(t){return Pe(t,null)}}});class Te extends d{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Pe(t,this.value)}}const Oe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Be extends m{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function _e(t={}){let e=Object.assign(Object.assign({},Oe),t),r=new Be(e,!0),n=new Be(e,!1),i=h.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(Wt)!=t.state.facet(Wt)||t.startState.field(de,!1)!=t.state.field(de,!1)||Ot(t.startState)!=Ot(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new a;for(let i of t.viewportLineBlocks){let s=pe(t.state,i.from,i.to)?n:ae(t.state,i.from,i.to)?r:null;s&&e.add(i.from,i.from,s)}return e.finish()}}),{domEventHandlers:o}=e;return[i,p({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(i))||void 0===e?void 0:e.markers)||s.empty},initialSpacer:()=>new Be(e,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(t,e,r)=>{if(o.click&&o.click(t,e,r))return!0;let n=pe(t.state,e.from,e.to);if(n)return t.dispatch({effects:ue.of(n)}),!0;let i=ae(t.state,e.from,e.to);return!!i&&(t.dispatch({effects:fe.of(i)}),!0)}})}),Ne()]}const Me=u.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class De{constructor(t,e){let r;function n(t){let e=b.newName();return(r||(r=Object.create(null)))["."+e]=t,e}this.specs=t;const i="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof Pt?t=>t.prop(At)==s.data:s?t=>t==s:void 0,this.style=it(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:i}).style,this.module=r?new b(r):null,this.themeType=e.themeType}static define(t,e){return new De(t,e||{})}}const Le=t.define(),Ee=t.define({combine:t=>t.length?[t[0]]:null});function Re(t){let e=t.facet(Le);return e.length?e:t.facet(Ee)}function ze(t,e){let r,n=[We];return t instanceof De&&(t.module&&n.push(u.styleModule.of(t.module)),r=t.themeType),(null==e?void 0:e.fallback)?n.push(Ee.of(t)):r?n.push(Le.computeN([u.darkTheme],(e=>e.facet(u.darkTheme)==("dark"==r)?[t]:[]))):n.push(Le.of(t)),n}class je{constructor(t){this.markCache=Object.create(null),this.tree=Ot(t.state),this.decorations=this.buildDeco(t,Re(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Ot(t.state),r=Re(t.state),n=r!=Re(t.startState),{viewport:i}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!n&&e.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)return c.none;let r=new a;for(let{from:n,to:i}of t.visibleRanges)st(this.tree,e,((t,e,n)=>{r.add(t,e,this.markCache[n]||(this.markCache[n]=c.mark({class:n})))}),n,i);return r.finish()}}const We=l.high(h.fromClass(je,{decorations:t=>t.decorations})),Ue=De.define([{tag:vt.meta,color:"#404740"},{tag:vt.link,textDecoration:"underline"},{tag:vt.heading,textDecoration:"underline",fontWeight:"bold"},{tag:vt.emphasis,fontStyle:"italic"},{tag:vt.strong,fontWeight:"bold"},{tag:vt.strikethrough,textDecoration:"line-through"},{tag:vt.keyword,color:"#708"},{tag:[vt.atom,vt.bool,vt.url,vt.contentSeparator,vt.labelName],color:"#219"},{tag:[vt.literal,vt.inserted],color:"#164"},{tag:[vt.string,vt.deleted],color:"#a11"},{tag:[vt.regexp,vt.escape,vt.special(vt.string)],color:"#e40"},{tag:vt.definition(vt.variableName),color:"#00f"},{tag:vt.local(vt.variableName),color:"#30a"},{tag:[vt.typeName,vt.namespace],color:"#085"},{tag:vt.className,color:"#167"},{tag:[vt.special(vt.variableName),vt.macroName],color:"#256"},{tag:vt.definition(vt.propertyName),color:"#00c"},{tag:vt.comment,color:"#940"},{tag:vt.invalid,color:"#f00"}]),Fe=u.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ve="()[]{}",$e=t.define({combine:t=>o(t,{afterCursor:!0,brackets:Ve,maxScanDistance:1e4,renderMatch:Ge})}),qe=c.mark({class:"cm-matchingBracket"}),He=c.mark({class:"cm-nonmatchingBracket"});function Ge(t){let e=[],r=t.matched?qe:He;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}const Je=[n.define({create:()=>c.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet($e);for(let t of e.state.selection.ranges){if(!t.empty)continue;let i=Ze(e.state,t.head,-1,n)||t.head>0&&Ze(e.state,t.head-1,1,n)||n.afterCursor&&(Ze(e.state,t.head,1,n)||t.head<e.state.doc.length&&Ze(e.state,t.head+1,-1,n));i&&(r=r.concat(n.renderMatch(i,e.state)))}return c.set(r,!0)},provide:t=>u.decorations.from(t)}),Fe];function Ke(t={}){return[$e.of(t),Je]}const Qe=new w;function Xe(t,e,r){let n=t.prop(e<0?w.openedBy:w.closedBy);if(n)return n;if(1==t.name.length){let n=r.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[r[n+e]]}return null}function Ye(t){let e=t.type.prop(Qe);return e?e(t.node):t}function Ze(t,e,r,n={}){let i=n.maxScanDistance||1e4,s=n.brackets||Ve,o=Ot(t),l=o.resolveInner(e,r);for(let n=l;n;n=n.parent){let i=Xe(n.type,r,s);if(i&&n.from<n.to){let o=Ye(n);if(o&&(r>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return tr(t,e,r,n,o,i,s)}}return function(t,e,r,n,i,s,o){let l=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=r>0)return null;let h={from:r<0?e-1:e,to:r>0?e+1:e},f=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let t=0;!f.next().done&&t<=s;){let s=f.value;r<0&&(t+=s.length);let l=e+t*r;for(let t=r>0?0:s.length-1,e=r>0?s.length:-1;t!=e;t+=r){let e=o.indexOf(s[t]);if(!(e<0||n.resolveInner(l+t,1).type!=i))if(e%2==0==r>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}r>0&&(t+=s.length)}return f.done?{start:h,matched:!1}:null}(t,e,r,o,l.type,i,s)}function tr(t,e,r,n,i,s,o){let l=n.parent,a={from:i.from,to:i.to},h=0,f=null==l?void 0:l.cursor();if(f&&(r<0?f.childBefore(n.from):f.childAfter(n.to)))do{if(r<0?f.to<=n.from:f.from>=n.to){if(0==h&&s.indexOf(f.type.name)>-1&&f.from<f.to){let t=Ye(f);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Xe(f.type,r,o))h++;else if(Xe(f.type,-r,o)){if(0==h){let t=Ye(f);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(r<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function er(t,e,r,n=0,i=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=i;for(let i=n;i<e;i++)9==t.charCodeAt(i)?s+=r-s%r:s++;return s}class rr{constructor(t,e,r,n){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,r=this.string.charAt(this.pos);if(e="string"==typeof t?r==t:r&&(t instanceof RegExp?t.test(r):t(r)),e)return++this.pos,r}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=er(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:er(this.string,null,this.tabSize)}match(t,e,r){if("string"==typeof t){let n=t=>r?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let r=this.string.slice(this.pos).match(t);return r&&r.index>0?null:(r&&!1!==e&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}}function nr(t){if("object"!=typeof t)return t;let e={};for(let r in t){let n=t[r];e[r]=n instanceof Array?n.slice():n}return e}const ir=new WeakMap;class sr extends Pt{constructor(t){let e,r=Ct(t.languageData),n={name:(i=t).name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||nr,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||fr};var i;super(r,new class extends K{createParse(t,r,n){return new ar(e,t,r,n)}},[Vt.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=A.define({id:ur.length,name:"Document",props:[At.add((()=>t))],top:!0});return ur.push(e),e}(r),e=this,this.streamParser=n,this.stateAfter=new w({perNode:!0}),this.tokenTable=t.tokenTable?new mr(n.tokenTable):br}static define(t){return new sr(t)}getIndent(t,e){let r,n=Ot(t.state),i=n.resolve(e);for(;i&&i.type!=this.topNode;)i=i.parent;if(!i)return null;let{overrideIndentation:s}=t.options;s&&(r=ir.get(t.state),null!=r&&r<e-1e4&&(r=void 0));let o,l,a=or(this,n,0,i.from,null!=r?r:e);if(a?(l=a.state,o=a.pos+1):(l=this.streamParser.startState(t.unit),o=0),e-o>1e4)return null;for(;o<e;){let r=t.state.doc.lineAt(o),n=Math.min(e,r.to);if(r.length){let e=s?s(r.from):-1,i=new rr(r.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;i.pos<n-r.from;)hr(this.streamParser.token,i,l)}else this.streamParser.blankLine(l,t.unit);if(n==e)break;o=r.to+1}let h=t.lineAt(e);return s&&null==r&&ir.set(t.state,h.from),this.streamParser.indent(l,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function or(t,e,r,n,i){let s=r>=n&&r+e.length<=i&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:r+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=r+e.positions[s],a=o instanceof T&&l<i&&or(t,o,l,n,i);if(a)return a}return null}function lr(t,e,r,n,i){if(i&&r<=0&&n>=e.length)return e;i||e.type!=t.topNode||(i=!0);for(let s=e.children.length-1;s>=0;s--){let o,l=e.positions[s],a=e.children[s];if(l<n&&a instanceof T){if(!(o=lr(t,a,r-l,n-l,i)))break;return i?new T(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),l+o.length):o}}return null}class ar{constructor(t,e,r,n){this.lang=t,this.input=e,this.fragments=r,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let i=Dt.get(),s=n[0].from,{state:o,tree:l}=function(t,e,r,n){for(let n of e){let e,i=n.from+(n.openStart?25:0),s=n.to-(n.openEnd?25:0),o=i<=r&&s>r&&or(t,n.tree,0-n.offset,r,s);if(o&&(e=lr(t,n.tree,r+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?qt(n):4),tree:T.empty}}(t,r,s,null==i?void 0:i.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);i&&this.parsedPos<i.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(qt(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=Dt.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=r)break;if(e=e.slice(0,n-(r-e.length)),t++,t==this.ranges.length)break;let i=this.ranges[t].from,s=this.lineAfter(i);e+=s,r=i+s.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){let n=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?n>i:n>=i)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,r,n,i){if(this.ranges.length>1){e+=i=this.skipGapsTo(e,i,1);let t=this.chunk.length;r+=i=this.skipGapsTo(r,i,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,r,n),i}parseLine(t){let{line:e,end:r}=this.nextLine(),n=0,{streamParser:i}=this.lang,s=new rr(e,t?t.state.tabSize:4,t?qt(t.state):2);if(s.eol())i.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=hr(i.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=T.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:cr,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new T(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new T(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function hr(t,e,r){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,r);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const fr=Object.create(null),ur=[A.none],cr=new C(ur),dr=[],pr=Object.create(null),gr=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])gr[t]=kr(fr,e);class mr{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),gr)}resolve(t){return t?this.table[t]||(this.table[t]=kr(this.extra,t)):0}}const br=new mr(fr);function xr(t,e){dr.indexOf(t)>-1||(dr.push(t),console.warn(e))}function kr(t,e){let r=[];for(let n of e.split(" ")){let e=[];for(let r of n.split(".")){let n=t[r]||vt[r];n?"function"==typeof n?e.length?e=e.map(n):xr(r,`Modifier ${r} used at start of tag`):e.length?xr(r,`Tag ${r} used as modifier`):e=Array.isArray(n)?n:[n]:xr(r,`Unknown highlighting tag ${r}`)}for(let t of e)r.push(t)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+r.map((t=>t.id)),s=pr[i];if(s)return s.id;let o=pr[i]=A.define({id:ur.length,name:n,props:[et({[n]:r})]});return ur.push(o),o.id}function yr(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function wr(t){for(let e=t.iter();!e.next().done;)if(yr(e.value))return!0;return!1}const vr=t.define({combine:t=>t.some((t=>t))});const Sr=h.fromClass(class{constructor(t){this.always=t.state.facet(vr)||t.textDirection!=g.LTR||t.state.facet(u.perLineTextDirection),this.hasRTL=!this.always&&wr(t.state.doc),this.tree=Ot(t.state),this.decorations=this.always||this.hasRTL?Ar(t,this.tree,this.always):c.none}update(t){let e=t.state.facet(vr)||t.view.textDirection!=g.LTR||t.state.facet(u.perLineTextDirection);if(e||this.hasRTL||!function(t){let e=!1;return t.iterChanges(((t,r,n,i,s)=>{!e&&wr(s)&&(e=!0)})),e}(t.changes)||(this.hasRTL=!0),!e&&!this.hasRTL)return;let r=Ot(t.state);(e!=this.always||r!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=r,this.always=e,this.decorations=Ar(t.view,r,e))}},{provide:t=>{function e(e){var r,n;return null!==(n=null===(r=e.plugin(t))||void 0===r?void 0:r.decorations)&&void 0!==n?n:c.none}return[u.outerDecorations.of(e),l.lowest(u.bidiIsolatedRanges.of(e))]}});function Ar(t,e,r){let n=new a,i=t.visibleRanges;r||(i=function(t,e){let r=e.iter(),n=0,i=[],s=null;for(let{from:e,to:o}of t)if(!(s&&s.to>e&&(e=s.to,e>=o)))for(n+r.value.length<e&&(r.next(e-(n+r.value.length)),n=e);;){let t=n,e=n+r.value.length;if(!r.lineBreak&&yr(r.value)&&(s&&s.to>t-10?s.to=Math.min(o,e):i.push(s={from:t,to:Math.min(o,e)})),e>=o)break;n=e,r.next()}return i}(i,t.state.doc));for(let{from:t,to:r}of i)e.iterate({enter:t=>{let e=t.type.prop(w.isolate);e&&n.add(t.from,t.to,Cr[e])},from:t,to:r});return n.finish()}const Cr={rtl:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:g.RTL}),ltr:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:g.LTR}),auto:c.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Nr=Object.freeze({__proto__:null,DocInput:_t,HighlightStyle:De,IndentContext:Jt,LRLanguage:Tt,Language:Pt,LanguageDescription:Ft,LanguageSupport:Ut,ParseContext:Dt,StreamLanguage:sr,StringStream:rr,TreeIndentContext:Zt,bidiIsolates:function(t={}){let e=[Sr];return t.alwaysIsolate&&e.push(vr.of(!0)),e},bracketMatching:Ke,bracketMatchingHandle:Qe,codeFolding:Ne,continuedIndent:function({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.baseIndent+(n?0:e*r.unit)}},defaultHighlightStyle:Ue,defineLanguageFacet:Ct,delimitedIndent:ee,ensureSyntaxTree:Bt,flatIndent:t=>t.baseIndent,foldAll:ye,foldCode:be,foldEffect:fe,foldGutter:_e,foldInside:oe,foldKeymap:Se,foldNodeProp:se,foldService:ie,foldState:de,foldable:ae,foldedRanges:function(t){return t.field(de,!1)||s.empty},forceParsing:function(t,e=t.viewport.to,r=100){let n=Bt(t.state,e,r);return n!=Ot(t.state)&&t.dispatch({}),!!n},getIndentUnit:qt,getIndentation:Gt,highlightingFor:function(t,e,r){let n=Re(t),i=null;if(n)for(let t of n)if(!t.scope||r&&t.scope(r)){let r=t.style(e);r&&(i=i?i+" "+r:r)}return i},indentNodeProp:Kt,indentOnInput:ne,indentRange:function(t,e,r){let n=Object.create(null),i=new Jt(t,{overrideIndentation:t=>{var e;return null!==(e=n[t])&&void 0!==e?e:-1}}),s=[];for(let o=e;o<=r;){let e=t.doc.lineAt(o);o=e.to+1;let r=Gt(i,e.from);if(null==r)continue;/\S/.test(e.text)||(r=0);let l=/^\s*/.exec(e.text)[0],a=Ht(t,r);l!=a&&(n[e.from]=r,s.push({from:e.from,to:e.from+l.length,insert:a}))}return t.changes(s)},indentService:Vt,indentString:Ht,indentUnit:$t,language:Wt,languageDataProp:At,matchBrackets:Ze,sublanguageProp:Nt,syntaxHighlighting:ze,syntaxParserRunning:function(t){var e;return(null===(e=t.plugin(jt))||void 0===e?void 0:e.isWorking())||!1},syntaxTree:Ot,syntaxTreeAvailable:function(t,e=t.doc.length){var r;return(null===(r=t.field(Pt.state,!1))||void 0===r?void 0:r.context.isDone(e))||!1},toggleFold:t=>{let e=[];for(let r of ce(t)){let n=pe(t.state,r.from,r.to);if(n)e.push(ue.of(n),ke(t,n,!1));else{let n=ve(t,r);n&&e.push(fe.of(n),ke(t,n))}}return e.length>0&&t.dispatch({effects:me(t.state,e)}),!!e.length},unfoldAll:we,unfoldCode:xe,unfoldEffect:ue});export{x as D,I,Tt as L,C as N,K as P,T,A as a,w as b,et as c,Kt as d,ee as e,se as f,oe as g,Ut as h,$t as i,G as j,_e as k,ne as l,ze as m,Ue as n,Ke as o,Se as p,Jt as q,Gt as r,Ot as s,vt as t,Ht as u,Ze as v,qt as w,Nr as x};
2
- //# sourceMappingURL=codemirror_language-4kk4Aqm3.js.map
@@ -1,2 +0,0 @@
1
- class t{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=a(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(e,this.length,s,1),n.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=a(this,t,e);let i=[];return this.decompose(t,e,i,0),n.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),i=new r(this),s=new r(t);for(let t=e,r=e;;){if(i.next(t),s.next(t),t=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(r+=i.value.length,i.done||r>=n)return!0}}iter(t=1){return new r(this,t)}iterRange(t,e=this.length){return new h(this,t,e)}iterLines(t,e){let n;if(null==t)n=this.iter();else{null==e&&(e=this.lines+1);let i=this.line(t).from;n=this.iterRange(i,Math.max(i,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new o(n)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(i){if(0==i.length)throw new RangeError("A document must have at least one line");return 1!=i.length||i[0]?i.length<=32?new e(i):n.from(e.split(i,[])):t.empty}}class e extends t{constructor(t,e=function(t){let e=-1;for(let n of t)e+=n.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,n,i){for(let s=0;;s++){let r=this.text[s],h=i+r.length;if((e?n:h)>=t)return new l(i,h,n,r);i=h+1,n++}}decompose(t,n,r,h){let o=t<=0&&n>=this.length?this:new e(s(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(1&h){let t=r.pop(),n=i(o.text,t.text.slice(),0,o.length);if(n.length<=32)r.push(new e(n,t.length+o.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(o)}replace(t,r,h){if(!(h instanceof e))return super.replace(t,r,h);[t,r]=a(this,t,r);let o=i(this.text,i(h.text,s(this.text,0,t)),r),l=this.length+h.length-(r-t);return o.length<=32?new e(o,l):n.from(e.split(o,[]),l)}sliceString(t,e=this.length,n="\n"){[t,e]=a(this,t,e);let i="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let h=this.text[r],o=s+h.length;s>t&&r&&(i+=n),t<o&&e>s&&(i+=h.slice(Math.max(0,t-s),e-s)),s=o+1}return i}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,n){let i=[],s=-1;for(let r of t)i.push(r),s+=r.length+1,32==i.length&&(n.push(new e(i,s)),i=[],s=-1);return s>-1&&n.push(new e(i,s)),n}}class n extends t{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,n,i){for(let s=0;;s++){let r=this.children[s],h=i+r.length,o=n+r.lines-1;if((e?o:h)>=t)return r.lineInner(t,e,n,i);i=h+1,n=o+1}}decompose(t,e,n,i){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let h=this.children[s],o=r+h.length;if(t<=o&&e>=r){let s=i&((r<=t?1:0)|(o>=e?2:0));r>=t&&o<=e&&!s?n.push(h):h.decompose(t-r,e-r,n,s)}r=o+1}}replace(t,e,i){if([t,e]=a(this,t,e),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let h=this.children[s],o=r+h.length;if(t>=r&&e<=o){let l=h.replace(t-r,e-r,i),a=this.lines-h.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[s]=l,new n(r,this.length-(e-t)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,n="\n"){[t,e]=a(this,t,e);let i="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let h=this.children[s],o=r+h.length;r>t&&s&&(i+=n),t<o&&e>r&&(i+=h.sliceString(t-r,e-r,n)),r=o+1}return i}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof n))return 0;let i=0,[s,r,h,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,r+=e){if(s==h||r==o)return i;let n=this.children[s],l=t.children[r];if(n!=l)return i+n.scanIdentical(l,e);i+=n.length+1}}static from(t,i=t.reduce(((t,e)=>t+e.length+1),-1)){let s=0;for(let e of t)s+=e.lines;if(s<32){let n=[];for(let e of t)e.flatten(n);return new e(n,i)}let r=Math.max(32,s>>5),h=r<<1,o=r>>1,l=[],a=0,c=-1,f=[];function u(t){let i;if(t.lines>h&&t instanceof n)for(let e of t.children)u(e);else t.lines>o&&(a>o||!a)?(g(),l.push(t)):t instanceof e&&a&&(i=f[f.length-1])instanceof e&&t.lines+i.lines<=32?(a+=t.lines,c+=t.length+1,f[f.length-1]=new e(i.text.concat(t.text),i.length+1+t.length)):(a+t.lines>r&&g(),a+=t.lines,c+=t.length+1,f.push(t))}function g(){0!=a&&(l.push(1==f.length?f[0]:n.from(f,c)),c=-1,a=f.length=0)}for(let e of t)u(e);return g(),1==l.length?l[0]:new n(l,i)}}function i(t,e,n=0,i=1e9){for(let s=0,r=0,h=!0;r<t.length&&s<=i;r++){let o=t[r],l=s+o.length;l>=n&&(l>i&&(o=o.slice(0,i-s)),s<n&&(o=o.slice(n-s)),h?(e[e.length-1]+=o,h=!1):e.push(o)),s=l+1}return e}function s(t,e,n){return i(t,[""],e,n)}t.empty=new e([""],0);class r{constructor(t,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof e?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],h=r>>1,o=s instanceof e?s.text.length:s.children.length;if(h==(n>0?o:0)){if(0==i)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(n>0?0:1)){if(this.offsets[i]+=n,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(s instanceof e){let e=s.text[h+(n<0?-1:0)];if(this.offsets[i]+=n,e.length>Math.max(0,t))return this.value=0==t?e:n>0?e.slice(t):e.slice(0,e.length-t),this;t-=e.length}else{let r=s.children[h+(n<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(n>0?1:(r instanceof e?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class h{constructor(t,e,n){this.value="",this.done=!1,this.cursor=new r(t,e>n?-1:1),this.pos=e>n?t.length:0,this.from=Math.min(e,n),this.to=Math.max(e,n)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;let{value:i}=this.cursor.next(t);return this.pos+=(i.length+t)*e,this.value=i.length<=n?i:e<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class o{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:n,value:i}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(t.prototype[Symbol.iterator]=function(){return this.iter()},r.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=o.prototype[Symbol.iterator]=function(){return this});class l{constructor(t,e,n,i){this.from=t,this.to=e,this.number=n,this.text=i}get length(){return this.to-this.from}}function a(t,e,n){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,n))]}let c="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let t=1;t<c.length;t++)c[t]+=c[t-1];function f(t){for(let e=1;e<c.length;e+=2)if(c[e]>t)return c[e-1]<=t;return!1}function u(t){return t>=127462&&t<=127487}function g(t,e,n=!0,i=!0){return(n?d:p)(t,e,i)}function d(t,e,n){if(e==t.length)return e;e&&m(t.charCodeAt(e))&&v(t.charCodeAt(e-1))&&e--;let i=x(t,e);for(e+=k(i);e<t.length;){let s=x(t,e);if(8205==i||8205==s||n&&f(s))e+=k(s),i=s;else{if(!u(s))break;{let n=0,i=e-2;for(;i>=0&&u(x(t,i));)n++,i-=2;if(n%2==0)break;e+=2}}}return e}function p(t,e,n){for(;e>0;){let i=d(t,e-2,n);if(i<e)return i;e--}return 0}function m(t){return t>=56320&&t<57344}function v(t){return t>=55296&&t<56320}function x(t,e){let n=t.charCodeAt(e);if(!v(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return m(i)?i-56320+(n-55296<<10)+65536:n}function w(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function k(t){return t<65536?1:2}const y=/\r\n?|\n/;var S=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(S||(S={}));class I{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,n=0,i=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(n,i,s),i+=s):i+=r,n+=s}}iterChangedRanges(t,e=!1){M(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];i<0?t.push(n,i):t.push(i,n)}return new I(t)}composeDesc(t){return this.empty?t:t.empty?this:O(this,t)}mapDesc(t,e=!1){return t.empty?this:A(this,t,e)}mapPos(t,e=-1,n=S.Simple){let i=0,s=0;for(let r=0;r<this.sections.length;){let h=this.sections[r++],o=this.sections[r++],l=i+h;if(o<0){if(l>t)return s+(t-i);s+=h}else{if(n!=S.Simple&&l>=t&&(n==S.TrackDel&&i<t&&l>t||n==S.TrackBefore&&i<t||n==S.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!h)return t==i||e<0?s:s+o;s+=o}i=l}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return s}touchesRange(t,e=t){for(let n=0,i=0;n<this.sections.length&&i<=e;){let s=i+this.sections[n++];if(this.sections[n++]>=0&&i<=e&&s>=t)return!(i<t&&s>e)||"cover";i=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];t+=(t?" ":"")+n+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new I(t)}static create(t){return new I(t)}}class b extends I{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return M(this,((e,n,i,s,r)=>t=t.replace(i,i+(n-e),r)),!1),t}mapDesc(t,e=!1){return A(this,t,e,!0)}invert(e){let n=this.sections.slice(),i=[];for(let s=0,r=0;s<n.length;s+=2){let h=n[s],o=n[s+1];if(o>=0){n[s]=o,n[s+1]=h;let l=s>>1;for(;i.length<l;)i.push(t.empty);i.push(h?e.slice(r,r+h):t.empty)}r+=h}return new b(n,i)}compose(t){return this.empty?t:t.empty?this:O(this,t,!0)}map(t,e=!1){return t.empty?this:A(this,t,e,!0)}iterChanges(t,e=!1){M(this,t,e)}get desc(){return I.create(this.sections)}filter(t){let e=[],n=[],i=[],s=new R(this);t:for(let r=0,h=0;;){let o=r==t.length?1e9:t[r++];for(;h<o||h==o&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,o-h);P(i,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;P(e,t,r),r>0&&E(n,e,s.text),s.forward(t),h+=t}let l=t[r++];for(;h<l;){if(s.done)break t;let t=Math.min(s.len,l-h);P(e,t,-1),P(i,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),h+=t}}return{changes:new b(e,n),filtered:I.create(i)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e],i=this.sections[e+1];i<0?t.push(n):0==i?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}static of(e,n,i){let s=[],r=[],h=0,o=null;function l(t=!1){if(!t&&!s.length)return;h<n&&P(s,n-h,-1);let e=new b(s,r);o=o?o.compose(e.map(o)):e,s=[],r=[],h=0}return function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof b){if(a.length!=n)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${n})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:c}=a;if(e>o||e<0||o>n)throw new RangeError(`Invalid change range ${e} to ${o} (in doc of length ${n})`);let f=c?"string"==typeof c?t.of(c.split(i||y)):c:t.empty,u=f.length;if(e==o&&0==u)return;e<h&&l(),e>h&&P(s,e-h,-1),P(s,o-e,u),E(r,s,f),h=o}}(e),l(!o),o}static empty(t){return new b(t?[t,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if("number"==typeof r)n.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)n.push(r[0],0);else{for(;i.length<s;)i.push(t.empty);i[s]=t.of(r.slice(1)),n.push(r[0],i[s].length)}}}return new b(n,i)}static createSet(t,e){return new b(t,e)}}function P(t,e,n,i=!1){if(0==e&&n<=0)return;let s=t.length-2;s>=0&&n<=0&&n==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=n:i?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function E(e,n,i){if(0==i.length)return;let s=n.length-2>>1;if(s<e.length)e[e.length-1]=e[e.length-1].append(i);else{for(;e.length<s;)e.push(t.empty);e.push(i)}}function M(e,n,i){let s=e.inserted;for(let r=0,h=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)r+=l,h+=l;else{let c=r,f=h,u=t.empty;for(;c+=l,f+=a,a&&s&&(u=u.append(s[o-2>>1])),!(i||o==e.sections.length||e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];n(r,c,h,f,u),r=c,h=f}}}function A(t,e,n,i=!1){let s=[],r=i?[]:null,h=new R(t),o=new R(e);for(let t=-1;;)if(-1==h.ins&&-1==o.ins){let t=Math.min(h.len,o.len);P(s,t,-1),h.forward(t),o.forward(t)}else if(o.ins>=0&&(h.ins<0||t==h.i||0==h.off&&(o.len<h.len||o.len==h.len&&!n))){let e=o.len;for(P(s,o.ins,-1);e;){let n=Math.min(h.len,e);h.ins>=0&&t<h.i&&h.len<=n&&(P(s,0,h.ins),r&&E(r,s,h.text),t=h.i),h.forward(n),e-=n}o.next()}else{if(!(h.ins>=0)){if(h.done&&o.done)return r?b.createSet(s,r):I.create(s);throw new Error("Mismatched change set lengths")}{let e=0,n=h.len;for(;n;)if(-1==o.ins){let t=Math.min(n,o.len);e+=t,n-=t,o.forward(t)}else{if(!(0==o.ins&&o.len<n))break;n-=o.len,o.next()}P(s,e,t<h.i?h.ins:0),r&&t<h.i&&E(r,s,h.text),t=h.i,h.forward(h.len-n)}}}function O(t,e,n=!1){let i=[],s=n?[]:null,r=new R(t),h=new R(e);for(let t=!1;;){if(r.done&&h.done)return s?b.createSet(i,s):I.create(i);if(0==r.ins)P(i,r.len,0,t),r.next();else if(0!=h.len||h.done){if(r.done||h.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,h.len),n=i.length;if(-1==r.ins){let n=-1==h.ins?-1:h.off?0:h.ins;P(i,e,n,t),s&&n&&E(s,i,h.text)}else-1==h.ins?(P(i,r.off?0:r.len,e,t),s&&E(s,i,r.textBit(e))):(P(i,r.off?0:r.len,h.off?0:h.ins,t),s&&!h.off&&E(s,i,h.text));t=(r.ins>e||h.ins>=0&&h.len>e)&&(t||i.length>n),r.forward2(e),h.forward(e)}}else P(i,0,h.ins,t),s&&E(s,i,h.text),h.next()}}class R{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?t.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?t.empty:n[i].slice(this.off,null==e?void 0:this.off+e)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class T{constructor(t,e,n){this.from=t,this.to=e,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let n,i;return this.empty?n=i=t.mapPos(this.from,e):(n=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new T(n,i,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e);let n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,n)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return C.range(t.anchor,t.head)}static create(t,e,n){return new T(t,e,n)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map((n=>n.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(t.ranges[n],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let n=this.ranges.slice();return n[e]=t,C.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new C(t.ranges.map((t=>T.fromJSON(t))),t.main)}static single(t,e=t){return new C([C.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<t.length;i++){let s=t[i];if(s.empty?s.from<=n:s.from<n)return C.normalized(t.slice(),e);n=s.to}return new C(t,e)}static cursor(t,e=0,n,i){return T.create(t,t,(0==e?0:e<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(t,e,n,i){let s=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return e<t?T.create(e,t,48|s):T.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let n=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(n);for(let n=1;n<t.length;n++){let i=t[n],s=t[n-1];if(i.empty?i.from<=s.to:i.from<s.to){let r=s.from,h=Math.max(i.to,s.to);n<=e&&e--,t.splice(--n,2,i.anchor>i.head?C.range(h,r):C.range(r,h))}}return new C(t,e)}}function N(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let F=0;class B{constructor(t,e,n,i,s){this.combine=t,this.compareInput=e,this.compare=n,this.isStatic=i,this.id=F++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new B(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:J),!!t.static,t.enables)}of(t){return new D([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new D(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new D(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(n=>e(n.field(t))))}}function J(t,e){return t==e||t.length==e.length&&t.every(((t,n)=>t===e[n]))}class D{constructor(t,e,n,i){this.dependencies=t,this.facet=e,this.type=n,this.value=i,this.id=F++}dynamicSlot(t){var e;let n=this.value,i=this.facet.compareInput,s=this.id,r=t[s]>>1,h=2==this.type,o=!1,l=!1,a=[];for(let n of this.dependencies)"doc"==n?o=!0:"selection"==n?l=!0:1&(null!==(e=t[n.id])&&void 0!==e?e:1)||a.push(t[n.id]);return{create:t=>(t.values[r]=n(t),1),update(t,e){if(o&&e.docChanged||l&&(e.docChanged||e.selection)||j(t,a)){let e=n(t);if(h?!L(e,t.values[r],i):!i(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let o,l=e.config.address[s];if(null!=l){let s=tt(e,l);if(this.dependencies.every((n=>n instanceof B?e.facet(n)===t.facet(n):!(n instanceof z)||e.field(n,!1)==t.field(n,!1)))||(h?L(o=n(t),s,i):i(o=n(t),s)))return t.values[r]=s,0}else o=n(t);return t.values[r]=o,1}}}}function L(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function j(t,e){let n=!1;for(let i of e)1&Z(t,i)&&(n=!0);return n}function q(t,e,n){let i=n.map((e=>t[e.id])),s=n.map((t=>t.type)),r=i.filter((t=>!(1&t))),h=t[e.id]>>1;function o(t){let n=[];for(let e=0;e<i.length;e++){let r=tt(t,i[e]);if(2==s[e])for(let t of r)n.push(t);else n.push(r)}return e.combine(n)}return{create(t){for(let e of i)Z(t,e);return t.values[h]=o(t),1},update(t,n){if(!j(t,r))return 0;let i=o(t);return e.compare(i,t.values[h])?0:(t.values[h]=i,1)},reconfigure(t,s){let r=j(t,i),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&J(n,l))return t.values[h]=a,0;let c=o(t);return e.compare(c,a)?(t.values[h]=a,0):(t.values[h]=c,1)}}}const $=B.define({static:!0});class z{constructor(t,e,n,i,s){this.id=t,this.createF=e,this.updateF=n,this.compareF=i,this.spec=s,this.provides=void 0}static define(t){let e=new z(F++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet($).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,n)=>{let i=t.values[e],s=this.updateF(i,n);return this.compareF(i,s)?0:(t.values[e]=s,1)},reconfigure:(t,n)=>null!=n.config.address[this.id]?(t.values[e]=n.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,$.of({field:this,create:t})]}get extension(){return this}}const V=4,_=3,W=2,U=1;function G(t){return e=>new K(e,t)}const H={highest:G(0),high:G(U),default:G(W),low:G(_),lowest:G(V)};class K{constructor(t,e){this.inner=t,this.prec=e}}class Q{of(t){return new X(this,t)}reconfigure(t){return Q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class X{constructor(t,e){this.compartment=t,this.inner=e}}class Y{constructor(t,e,n,i,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=n,this.address=i,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,n){let i=[],s=Object.create(null),r=new Map;for(let n of function(t,e,n){let i=[[],[],[],[],[]],s=new Map;function r(t,h){let o=s.get(t);if(null!=o){if(o<=h)return;let e=i[o].indexOf(t);e>-1&&i[o].splice(e,1),t instanceof X&&n.delete(t.compartment)}if(s.set(t,h),Array.isArray(t))for(let e of t)r(e,h);else if(t instanceof X){if(n.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=e.get(t.compartment)||t.inner;n.set(t.compartment,i),r(i,h)}else if(t instanceof K)r(t.inner,t.prec);else if(t instanceof z)i[h].push(t),t.provides&&r(t.provides,h);else if(t instanceof D)i[h].push(t),t.facet.extensions&&r(t.facet.extensions,W);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,h)}}return r(t,W),i.reduce(((t,e)=>t.concat(e)))}(t,e,r))n instanceof z?i.push(n):(s[n.facet.id]||(s[n.facet.id]=[])).push(n);let h=Object.create(null),o=[],l=[];for(let t of i)h[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==n?void 0:n.config.facets;for(let t in s){let e=s[t],i=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(h[i.id]=o.length<<1|1,J(r,e))o.push(n.facet(i));else{let t=i.combine(e.map((t=>t.value)));o.push(n&&i.compare(t,n.facet(i))?n.facet(i):t)}else{for(let t of e)0==t.type?(h[t.id]=o.length<<1|1,o.push(t.value)):(h[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));h[i.id]=l.length<<1,l.push((t=>q(t,i,e)))}}let c=l.map((t=>t(h)));return new Y(t,r,c,h,o,s)}}function Z(t,e){if(1&e)return 2;let n=e>>1,i=t.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function tt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const et=B.define(),nt=B.define({combine:t=>t.some((t=>t)),static:!0}),it=B.define({combine:t=>t.length?t[0]:void 0,static:!0}),st=B.define(),rt=B.define(),ht=B.define(),ot=B.define({combine:t=>!!t.length&&t[0]});class lt{constructor(t,e){this.type=t,this.value=e}static define(){return new at}}class at{of(t){return new lt(this,t)}}class ct{constructor(t){this.map=t}of(t){return new ft(this,t)}}class ft{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new ft(this.type,e)}is(t){return this.type==t}static define(t={}){return new ct(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let n=[];for(let i of t){let t=i.map(e);t&&n.push(t)}return n}}ft.reconfigure=ft.define(),ft.appendConfig=ft.define();class ut{constructor(t,e,n,i,s,r){this.startState=t,this.changes=e,this.selection=n,this.effects=i,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,n&&N(n,e.newLength),s.some((t=>t.type==ut.time))||(this.annotations=s.concat(ut.time.of(Date.now())))}static create(t,e,n,i,s,r){return new ut(t,e,n,i,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(ut.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function gt(t,e){let n=[];for(let i=0,s=0;;){let r,h;if(i<t.length&&(s==e.length||e[s]>=t[i]))r=t[i++],h=t[i++];else{if(!(s<e.length))return n;r=e[s++],h=e[s++]}!n.length||n[n.length-1]<r?n.push(r,h):n[n.length-1]<h&&(n[n.length-1]=h)}}function dt(t,e,n){var i;let s,r,h;return n?(s=e.changes,r=b.empty(e.changes.length),h=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),h=t.changes.compose(s)),{changes:h,selection:e.selection?e.selection.map(r):null===(i=t.selection)||void 0===i?void 0:i.map(s),effects:ft.mapEffects(t.effects,s).concat(ft.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function pt(t,e,n){let i=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(ut.userEvent.of(e.userEvent))),{changes:e.changes instanceof b?e.changes:b.of(e.changes||[],n,t.facet(it)),selection:i&&(i instanceof C?i:C.single(i.anchor,i.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function mt(t,e,n){let i=pt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(n=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(n=!1);let r=!!e[s].sequential;i=dt(i,pt(t,e[s],r?i.changes.newLength:t.doc.length),r)}let s=ut.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(t){let e=t.startState,n=e.facet(ht),i=t;for(let s=n.length-1;s>=0;s--){let r=n[s](t);r&&Object.keys(r).length&&(i=dt(i,pt(e,r,t.changes.newLength),!0))}return i==t?t:ut.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(t){let e=t.startState,n=!0;for(let i of e.facet(st)){let e=i(t);if(!1===e){n=!1;break}Array.isArray(e)&&(n=!0===n?e:gt(n,e))}if(!0!==n){let i,s;if(!1===n)s=t.changes.invertedDesc,i=b.empty(e.doc.length);else{let e=t.changes.filter(n);i=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=ut.create(e,i,t.selection&&t.selection.map(s),ft.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let i=e.facet(rt);for(let n=i.length-1;n>=0;n--){let s=i[n](t);t=s instanceof ut?s:Array.isArray(s)&&1==s.length&&s[0]instanceof ut?s[0]:mt(e,xt(s),!1)}return t}(s):s)}ut.time=lt.define(),ut.userEvent=lt.define(),ut.addToHistory=lt.define(),ut.remote=lt.define();const vt=[];function xt(t){return null==t?vt:Array.isArray(t)?t:[t]}var wt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(wt||(wt={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let yt;try{yt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function St(t){return e=>{if(!/\S/.test(e))return wt.Space;if(function(t){if(yt)return yt.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||kt.test(n)))return!0}return!1}(e))return wt.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return wt.Word;return wt.Other}}class It{constructor(t,e,n,i,s,r){this.config=t,this.doc=e,this.selection=n,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Z(this,t<<1);this.computeSlot=null}field(t,e=!0){let n=this.config.address[t.id];if(null!=n)return Z(this,n),tt(this,n);if(e)throw new RangeError("Field is not present in this state")}update(...t){return mt(this,t,!0)}applyTransaction(t){let e,n=this.config,{base:i,compartments:s}=n;for(let e of t.effects)e.is(Q.reconfigure)?(n&&(s=new Map,n.compartments.forEach(((t,e)=>s.set(e,t))),n=null),s.set(e.value.compartment,e.value.extension)):e.is(ft.reconfigure)?(n=null,i=e.value):e.is(ft.appendConfig)&&(n=null,i=xt(i).concat(e.value));if(n)e=t.startState.values.slice();else{n=Y.resolve(i,s,this),e=new It(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(nt)?t.newSelection:t.newSelection.asSingle();new It(n,t.newDoc,r,e,((e,n)=>n.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:C.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,n=t(e.ranges[0]),i=this.changes(n.changes),s=[n.range],r=xt(n.effects);for(let n=1;n<e.ranges.length;n++){let h=t(e.ranges[n]),o=this.changes(h.changes),l=o.map(i);for(let t=0;t<n;t++)s[t]=s[t].map(l);let a=i.mapDesc(o,!0);s.push(h.range.map(a)),i=i.compose(l),r=ft.mapEffects(r,l).concat(ft.mapEffects(xt(h.effects),a))}return{changes:i,selection:C.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof b?t:b.of(t,this.doc.length,this.facet(It.lineSeparator))}toText(e){return t.of(e.split(this.facet(It.lineSeparator)||y))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Z(this,e),tt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let n in t){let i=t[n];i instanceof z&&null!=this.config.address[i.id]&&(e[n]=i.spec.toJSON(this.field(t[n]),this))}return e}static fromJSON(t,e={},n){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let e in n)if(Object.prototype.hasOwnProperty.call(t,e)){let s=n[e],r=t[e];i.push(s.init((t=>s.spec.fromJSON(r,t))))}return It.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?i.concat([e.extensions]):i})}static create(e={}){let n=Y.resolve(e.extensions||[],new Map),i=e.doc instanceof t?e.doc:t.of((e.doc||"").split(n.staticFacet(It.lineSeparator)||y)),s=e.selection?e.selection instanceof C?e.selection:C.single(e.selection.anchor,e.selection.head):C.single(0);return N(s,i.length),n.staticFacet(nt)||(s=s.asSingle()),new It(n,i,s,n.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(It.tabSize)}get lineBreak(){return this.facet(It.lineSeparator)||"\n"}get readOnly(){return this.facet(ot)}phrase(t,...e){for(let e of this.facet(It.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>e.length?t:e[i-1]}))),t}languageDataAt(t,e,n=-1){let i=[];for(let s of this.facet(et))for(let r of s(this,e,n))Object.prototype.hasOwnProperty.call(r,t)&&i.push(r[t]);return i}charCategorizer(t){return St(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:n,length:i}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-n,h=t-n;for(;r>0;){let t=g(e,r,!1);if(s(e.slice(t,r))!=wt.Word)break;r=t}for(;h<i;){let t=g(e,h);if(s(e.slice(h,t))!=wt.Word)break;h=t}return r==h?null:C.range(r+n,h+n)}}function bt(t,e,n={}){let i={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=i[t];if(void 0===r)i[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(n,t))throw new Error("Config merge conflict for field "+t);i[t]=n[t](r,s)}}for(let t in e)void 0===i[t]&&(i[t]=e[t]);return i}It.allowMultipleSelections=nt,It.tabSize=B.define({combine:t=>t.length?t[0]:4}),It.lineSeparator=it,It.readOnly=ot,It.phrases=B.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every((n=>t[n]==e[n]))}}),It.languageData=et,It.changeFilter=st,It.transactionFilter=rt,It.transactionExtender=ht,Q.reconfigure=ft.define();class Pt{eq(t){return this==t}range(t,e=t){return Et.create(t,e,this)}}Pt.prototype.startSide=Pt.prototype.endSide=0,Pt.prototype.point=!1,Pt.prototype.mapMode=S.TrackDel;class Et{constructor(t,e,n){this.from=t,this.to=e,this.value=n}static create(t,e,n){return new Et(t,e,n)}}function Mt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class At{constructor(t,e,n,i){this.from=t,this.to=e,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(t,e,n,i=0){let s=n?this.to:this.from;for(let r=i,h=s.length;;){if(r==h)return r;let i=r+h>>1,o=s[i]-t||(n?this.value[i].endSide:this.value[i].startSide)-e;if(i==r)return o>=0?r:h;o>=0?h=i:r=i+1}}between(t,e,n,i){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(n,1e9,!1,s);s<r;s++)if(!1===i(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let n=[],i=[],s=[],r=-1,h=-1;for(let o=0;o<this.value.length;o++){let l,a,c=this.value[o],f=this.from[o]+t,u=this.to[o]+t;if(f==u){let t=e.mapPos(f,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(f,c.endSide),a<l))continue}else if(l=e.mapPos(f,c.startSide),a=e.mapPos(u,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(h=Math.max(h,a-l)),n.push(c),i.push(l-r),s.push(a-r))}return{mapped:n.length?new At(i,s,n,h):null,pos:r}}}class Ot{constructor(t,e,n,i){this.chunkPos=t,this.chunk=e,this.nextLayer=n,this.maxPoint=i}static create(t,e,n,i){return new Ot(t,e,n,i)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:n=!1,filterFrom:i=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(n&&(e=e.slice().sort(Mt)),this.isEmpty)return e.length?Ot.of(e):this;let h=new Ct(this,null,-1).goto(0),o=0,l=[],a=new Rt;for(;h.value||o<e.length;)if(o<e.length&&(h.from-e[o].from||h.startSide-e[o].value.startSide)>=0){let t=e[o++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==h.rangeIndex&&h.chunkIndex<this.chunk.length&&(o==e.length||this.chunkEnd(h.chunkIndex)<e[o].from)&&(!r||i>this.chunkEnd(h.chunkIndex)||s<this.chunkPos[h.chunkIndex])&&a.addChunk(this.chunkPos[h.chunkIndex],this.chunk[h.chunkIndex])?h.nextChunk():((!r||i>h.to||s<h.from||r(h.from,h.to,h.value))&&(a.addInner(h.from,h.to,h.value)||l.push(Et.create(h.from,h.to,h.value))),h.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Ot.empty:this.nextLayer.update({add:l,filter:r,filterFrom:i,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],n=[],i=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],h=this.chunk[s],o=t.touchesRange(r,r+h.length);if(!1===o)i=Math.max(i,h.maxPoint),e.push(h),n.push(t.mapPos(r));else if(!0===o){let{mapped:s,pos:o}=h.map(r,t);s&&(i=Math.max(i,s.maxPoint),e.push(s),n.push(o))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Ot(n,e,s||Ot.empty,i)}between(t,e,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],r=this.chunk[i];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,n))return}this.nextLayer.between(t,e,n)}}iter(t=0){return Nt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Nt.from(t).goto(e)}static compare(t,e,n,i,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=Tt(r,h,n),l=new Bt(r,o,s),a=new Bt(h,o,s);n.iterGaps(((t,e,n)=>Jt(l,t,a,e,n,i))),n.empty&&0==n.length&&Jt(l,0,a,0,0,i)}static eq(t,e,n=0,i){null==i&&(i=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let h=Tt(s,r),o=new Bt(s,h,0).goto(n),l=new Bt(r,h,0).goto(n);for(;;){if(o.to!=l.to||!Dt(o.active,l.active)||o.point&&(!l.point||!o.point.eq(l.point)))return!1;if(o.to>i)return!0;o.next(),l.next()}}static spans(t,e,n,i,s=-1){let r=new Bt(t,null,s).goto(e),h=e,o=r.openStart;for(;;){let t=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to),s=r.pointFrom<e?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,o);i.point(h,t,r.point,n,s,r.pointRank),o=Math.min(r.openEnd(t),n.length)}else t>h&&(i.span(h,t,r.active,o),o=r.openEnd(t));if(r.to>n)return o+(r.point&&r.to>n?1:0);h=r.to,r.next()}}static of(t,e=!1){let n=new Rt;for(let i of t instanceof Et?[t]:e?function(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let i=t[n];if(Mt(e,i)>0)return t.slice().sort(Mt);e=i}return t}(t):t)n.add(i.from,i.to,i.value);return n.finish()}static join(t){if(!t.length)return Ot.empty;let e=t[t.length-1];for(let n=t.length-2;n>=0;n--)for(let i=t[n];i!=Ot.empty;i=i.nextLayer)e=new Ot(i.chunkPos,i.chunk,e,Math.max(i.maxPoint,e.maxPoint));return e}}Ot.empty=new Ot([],[],null,-1),Ot.empty.nextLayer=Ot.empty;class Rt{finishChunk(t){this.chunks.push(new At(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,n){this.addInner(t,e,n)||(this.nextLayer||(this.nextLayer=new Rt)).add(t,e,n)}addInner(t,e,n){let i=t-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(t-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}finish(){return this.finishInner(Ot.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Ot.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Tt(t,e,n){let i=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&i.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=i.get(t.chunk[e]);null==r||(n?n.mapPos(r):r)!=t.chunkPos[e]||(null==n?void 0:n.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Ct{constructor(t,e,n,i=0){this.layer=t,this.skip=e,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Nt{constructor(t){this.heap=t}static from(t,e=null,n=-1){let i=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&i.push(new Ct(r,e,n,s));return 1==i.length?i[0]:new Nt(i)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let n of this.heap)n.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Ft(this.heap,t);return this.next(),this}forward(t,e){for(let n of this.heap)n.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Ft(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Ft(this.heap,0)}}}function Ft(t,e){for(let n=t[e];;){let i=1+(e<<1);if(i>=t.length)break;let s=t[i];if(i+1<t.length&&s.compare(t[i+1])>=0&&(s=t[i+1],i++),n.compare(s)<0)break;t[i]=n,t[e]=s,e=i}}class Bt{constructor(t,e,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nt.from(t,e,n)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Lt(this.active,t),Lt(this.activeTo,t),Lt(this.activeRank,t),this.minActive=qt(this.active,this.activeTo)}addActive(t){let e=0,{value:n,to:i,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||i-this.activeTo[e])>0;)e++;jt(this.active,e,n),jt(this.activeTo,e,i),jt(this.activeRank,e,s),t&&jt(t,e,this.cursor.from),this.minActive=qt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>t){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&Lt(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let e=n.length-1;e>=0&&n[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}openEnd(t){let e=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}function Jt(t,e,n,i,s,r){t.goto(e),n.goto(i);let h=i+s,o=i,l=i-e;for(;;){let e=t.to+l-n.to||t.endSide-n.endSide,i=e<0?t.to+l:n.to,s=Math.min(i,h);if(t.point||n.point?t.point&&n.point&&(t.point==n.point||t.point.eq(n.point))&&Dt(t.activeForPoint(t.to),n.activeForPoint(n.to))||r.comparePoint(o,s,t.point,n.point):s>o&&!Dt(t.active,n.active)&&r.compareRange(o,s,t.active,n.active),i>h)break;o=i,e<=0&&t.next(),e>=0&&n.next()}}function Dt(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!t[n].eq(e[n]))return!1;return!0}function Lt(t,e){for(let n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function jt(t,e,n){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=n}function qt(t,e){let n=-1,i=1e9;for(let s=0;s<e.length;s++)(e[s]-i||t[s].endSide-t[n].endSide)<0&&(n=s,i=e[s]);return n}function $t(t,e,n=t.length){let i=0;for(let s=0;s<n;)9==t.charCodeAt(s)?(i+=e-i%e,s++):(i++,s=g(t,s));return i}function zt(t,e,n,i){for(let i=0,s=0;;){if(s>=e)return i;if(i==t.length)break;s+=9==t.charCodeAt(i)?n-s%n:1,i=g(t,i)}return!0===i?-1:t.length}export{lt as Annotation,at as AnnotationType,I as ChangeDesc,b as ChangeSet,wt as CharCategory,Q as Compartment,C as EditorSelection,It as EditorState,B as Facet,l as Line,S as MapMode,H as Prec,Et as Range,Ot as RangeSet,Rt as RangeSetBuilder,Pt as RangeValue,T as SelectionRange,ft as StateEffect,ct as StateEffectType,z as StateField,t as Text,ut as Transaction,x as codePointAt,k as codePointSize,bt as combineConfig,$t as countColumn,g as findClusterBreak,zt as findColumn,w as fromCodePoint};
2
- //# sourceMappingURL=codemirror_state-1d1uncXx.js.map