arize-phoenix 6.0.0__py3-none-any.whl → 6.2.0__py3-none-any.whl

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.

Potentially problematic release.


This version of arize-phoenix might be problematic. Click here for more details.

Files changed (25) hide show
  1. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/METADATA +7 -6
  2. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/RECORD +24 -23
  3. phoenix/config.py +4 -1
  4. phoenix/db/engines.py +1 -1
  5. phoenix/db/migrate.py +4 -1
  6. phoenix/metrics/wrappers.py +7 -1
  7. phoenix/server/api/mutations/chat_mutations.py +5 -0
  8. phoenix/server/api/subscriptions.py +6 -0
  9. phoenix/server/api/types/EmbeddingDimension.py +1 -1
  10. phoenix/server/static/.vite/manifest.json +40 -31
  11. phoenix/server/static/assets/{components-Bo-xjXoV.js → components-DrwPLMB6.js} +248 -183
  12. phoenix/server/static/assets/index-CTN-OfBU.js +93 -0
  13. phoenix/server/static/assets/{pages-BfYVoiUE.js → pages-Cmqh2i4E.js} +346 -344
  14. phoenix/server/static/assets/vendor-Cdrqqth8.js +894 -0
  15. phoenix/server/static/assets/{vendor-arizeai-gSIqhzZY.js → vendor-arizeai-BSCL03yQ.js} +1 -1
  16. phoenix/server/static/assets/{vendor-codemirror-fSYjW3f-.js → vendor-codemirror-Utqu7Snw.js} +5 -5
  17. phoenix/server/static/assets/{vendor-recharts-CVVyA2X0.js → vendor-recharts-CNNUvc5T.js} +1 -1
  18. phoenix/server/static/assets/{vendor-UNccFYqq.js → vendor-shiki-B6bHerDK.js} +5 -872
  19. phoenix/session/client.py +13 -4
  20. phoenix/version.py +1 -1
  21. phoenix/server/static/assets/index-i2KbnOZd.js +0 -101
  22. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/WHEEL +0 -0
  23. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/entry_points.txt +0 -0
  24. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/licenses/IP_NOTICE +0 -0
  25. {arize_phoenix-6.0.0.dist-info → arize_phoenix-6.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
1
- import{c1 as at,c2 as yf,c3 as bf,c4 as vf,y as m,c5 as kr,x as xf,c6 as Ae,c7 as Cr,c8 as Et,c9 as wf,ca as cn,cb as Sf,cc as kf,cd as Cf,ce as V,cf as qn,r as we,cg as Af,ch as Mf,ci as Tf,cj as Of,ck as Df,cl as Ql,cm as Ef,cn as Pf,co as Zl,cp as Bf,cq as ea,cr as Rf}from"./vendor-UNccFYqq.js";class B{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=$t(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),We.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=$t(this,e,t);let i=[];return this.decompose(e,t,i,0),We.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new ui(this),r=new ui(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ui(this,e)}iterRange(e,t=this.length){return new ta(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ia(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?B.empty:e.length<=32?new J(e):We.from(J.split(e,[]))}}class J extends B{constructor(e,t=Lf(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new If(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new J(oo(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=fn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new J(l,o.length+r.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=$t(this,e,t);let s=fn(this.text,fn(i.text,oo(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new J(s,r):We.from(J.split(s,[]),r)}sliceString(e,t=this.length,i=`
1
+ import{c2 as at,c3 as yf,c4 as bf,c5 as vf,y as m,c6 as kr,x as xf,c7 as Ae,c8 as Cr,c9 as Et,ca as wf,cb as cn,cc as Sf,cd as kf,ce as Cf,cf as V,cg as qn,r as we,ch as Af,ci as Mf,cj as Tf,ck as Of,cl as Ql,cm as Df,cn as Ef,co as Zl,cp as Pf,cq as ea,cr as Bf}from"./vendor-Cdrqqth8.js";import{m as Rf}from"./vendor-shiki-B6bHerDK.js";class B{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=$t(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),We.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=$t(this,e,t);let i=[];return this.decompose(e,t,i,0),We.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new ui(this),r=new ui(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new ui(this,e)}iterRange(e,t=this.length){return new ta(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ia(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?B.empty:e.length<=32?new J(e):We.from(J.split(e,[]))}}class J extends B{constructor(e,t=Lf(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new If(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new J(oo(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=fn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new J(l,o.length+r.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=$t(this,e,t);let s=fn(this.text,fn(i.text,oo(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new J(s,r):We.from(J.split(s,[]),r)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=$t(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new J(i,s)),i=[],s=-1);return s>-1&&t.push(new J(i,s)),t}}class We extends B{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let c=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?i.push(l):l.decompose(e-o,t-o,i,c)}o=a+1}}replace(e,t,i){if([e,t]=$t(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),c=this.lines-o.lines+a.lines;if(a.lines<c>>4&&a.lines>c>>6){let h=this.children.slice();return h[s]=a,new We(h,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=$t(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof We))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],c=e.children[r];if(a!=c)return i+a.scanIdentical(c,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new J(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,c=-1,h=[];function f(d){let p;if(d.lines>r&&d instanceof We)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof J&&a&&(p=h[h.length-1])instanceof J&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,h[h.length-1]=new J(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,c+=d.length+1,h.push(d))}function u(){a!=0&&(l.push(h.length==1?h[0]:We.from(h,c)),c=-1,a=h.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new We(l,t)}}B.empty=new J([""],0);function Lf(n){let e=-1;for(let t of n)e+=t.length+1;return e}function fn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function oo(n,e,t){return fn(n,[""],e,t)}class ui{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof J?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof J?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(s instanceof J){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class ta{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ui(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class ia{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(B.prototype[Symbol.iterator]=function(){return this.iter()},ui.prototype[Symbol.iterator]=ta.prototype[Symbol.iterator]=ia.prototype[Symbol.iterator]=function(){return this});class If{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function $t(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}let Lt="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(n=>n?parseInt(n,36):1);for(let n=1;n<Lt.length;n++)Lt[n]+=Lt[n-1];function Nf(n){for(let e=1;e<Lt.length;e+=2)if(Lt[e]>n)return Lt[e-1]<=n;return!1}function lo(n){return n>=127462&&n<=127487}const ao=8205;function se(n,e,t=!0,i=!0){return(t?na:Ff)(n,e,i)}function na(n,e,t){if(e==n.length)return e;e&&sa(n.charCodeAt(e))&&ra(n.charCodeAt(e-1))&&e--;let i=ie(n,e);for(e+=Se(i);e<n.length;){let s=ie(n,e);if(i==ao||s==ao||t&&Nf(s))e+=Se(s),i=s;else if(lo(s)){let r=0,o=e-2;for(;o>=0&&lo(ie(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Ff(n,e,t){for(;e>0;){let i=na(n,e-2,t);if(i<e)return i;e--}return 0}function sa(n){return n>=56320&&n<57344}function ra(n){return n>=55296&&n<56320}function ie(n,e){let t=n.charCodeAt(e);if(!ra(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return sa(i)?(t-55296<<10)+(i-56320)+65536:t}function Ar(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Se(n){return n<65536?1:2}const Ps=/\r\n?|\n/;var ee=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(ee||(ee={}));class Ke{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){Bs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new Ke(e)}composeDesc(e){return this.empty?e:e.empty?this:oa(this,e)}mapDesc(e,t=!1){return e.empty?this:Rs(this,e,t)}mapPos(e,t=-1,i=ee.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=s+l;if(a<0){if(c>e)return r+(e-s);r+=l}else{if(i!=ee.Simple&&c>=e&&(i==ee.TrackDel&&s<e&&c>e||i==ee.TrackBefore&&s<e||i==ee.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=c}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ke(e)}static create(e){return new Ke(e)}}class Z extends Ke{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Bs(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Rs(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(B.empty);i.push(o?e.slice(r,r+o):B.empty)}r+=o}return new Z(t,i)}compose(e){return this.empty?e:e.empty?this:oa(this,e,!0)}map(e,t=!1){return e.empty?this:Rs(this,e,t,!0)}iterChanges(e,t=!1){Bs(this,e,t)}get desc(){return Ke.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new bi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let h=Math.min(r.len,a-l);re(s,h,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;re(t,h,f),f>0&&nt(i,t,r.text),r.forward(h),l+=h}let c=e[o++];for(;l<c;){if(r.done)break e;let h=Math.min(r.len,c-l);re(t,h,-1),re(s,h,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(h),l+=h}}return{changes:new Z(t,i),filtered:Ke.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(h=!1){if(!h&&!s.length)return;o<t&&re(s,t-o,-1);let f=new Z(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function c(h){if(Array.isArray(h))for(let f of h)c(f);else if(h instanceof Z){if(h.length!=t)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${t})`);a(),l=l?l.compose(h.map(l)):h}else{let{from:f,to:u=f,insert:d}=h;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?B.of(d.split(i||Ps)):d:B.empty,g=p.length;if(f==u&&g==0)return;f<o&&a(),f>o&&re(s,f-o,-1),re(s,u-f,g),nt(r,s,p),o=u}}return c(e),a(!l),l}static empty(e){return new Z(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(B.empty);i[s]=B.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new Z(t,i)}static createSet(e,t){return new Z(e,t)}}function re(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function nt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(B.empty);n.push(t)}}function Bs(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let c=s,h=r,f=B.empty;for(;c+=l,h+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,c,r,h,f),s=c,r=h}}}function Rs(n,e,t,i=!1){let s=[],r=i?[]:null,o=new bi(n),l=new bi(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);re(s,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let c=l.len;for(re(s,l.ins,-1);c;){let h=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=h&&(re(s,0,o.ins),r&&nt(r,s,o.text),a=o.i),o.forward(h),c-=h}l.next()}else if(o.ins>=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let f=Math.min(h,l.len);c+=f,h-=f,l.forward(f)}else if(l.ins==0&&l.len<h)h-=l.len,l.next();else break;re(s,c,a<o.i?o.ins:0),r&&a<o.i&&nt(r,s,o.text),a=o.i,o.forward(o.len-h)}else{if(o.done&&l.done)return r?Z.createSet(s,r):Ke.create(s);throw new Error("Mismatched change set lengths")}}function oa(n,e,t=!1){let i=[],s=t?[]:null,r=new bi(n),o=new bi(e);for(let l=!1;;){if(r.done&&o.done)return s?Z.createSet(i,s):Ke.create(i);if(r.ins==0)re(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)re(i,0,o.ins,l),s&&nt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),c=i.length;if(r.ins==-1){let h=o.ins==-1?-1:o.off?0:o.ins;re(i,a,h,l),s&&h&&nt(s,i,o.text)}else o.ins==-1?(re(i,r.off?0:r.len,a,l),s&&nt(s,i,r.textBit(a))):(re(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&nt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>c),r.forward2(a),o.forward(a)}}}}class bi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?B.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?B.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class bt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new bt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return v.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return v.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return v.range(e.anchor,e.head)}static create(e,t,i){return new bt(e,t,i)}}class v{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:v.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new v([this.main],0)}addRange(e,t=!0){return v.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,v.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new v(e.ranges.map(t=>bt.fromJSON(t)),e.main)}static single(e,t=e){return new v([v.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return v.normalized(e.slice(),t);i=r.to}return new v(e,t)}static cursor(e,t=0,i,s){return bt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s){let r=(i??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?bt.create(t,e,48|r):bt.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?v.range(a,l):v.range(l,a))}}return new v(e,t)}}function la(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Mr=0;class A{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Mr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new A(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Tr),!!e.static,e.enables)}of(e){return new un([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Tr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class un{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Mr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,c=!1,h=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?c=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||h.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||c&&(u.docChanged||u.selection)||Ls(f,h)){let d=i(f);if(l?!ho(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let g=Cn(u,p);if(this.dependencies.every(y=>y instanceof A?u.facet(y)===f.facet(y):y instanceof X?u.field(y,!1)==f.field(y,!1):!0)||(l?ho(d=i(f),g,s):s(d=i(f),g)))return f.values[o]=g,0}else d=i(f);return f.values[o]=d,1}}}}function ho(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Ls(n,e){let t=!1;for(let i of e)di(n,i)&1&&(t=!0);return t}function Vf(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let c=[];for(let h=0;h<i.length;h++){let f=Cn(a,i[h]);if(s[h]==2)for(let u of f)c.push(u);else c.push(f)}return e.combine(c)}return{create(a){for(let c of i)di(a,c);return a.values[o]=l(a),1},update(a,c){if(!Ls(a,r))return 0;let h=l(a);return e.compare(h,a.values[o])?0:(a.values[o]=h,1)},reconfigure(a,c){let h=Ls(a,i),f=c.config.facets[e.id],u=c.facet(e);if(f&&!h&&Tr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const co=A.define({static:!0});class X{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new X(Mr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(co).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,co.of({field:this,create:e})]}get extension(){return this}}const mt={lowest:4,low:3,default:2,high:1,highest:0};function ti(n){return e=>new aa(e,n)}const dt={highest:ti(mt.highest),high:ti(mt.high),default:ti(mt.default),low:ti(mt.low),lowest:ti(mt.lowest)};class aa{constructor(e,t){this.inner=e,this.prec=t}}class Kn{of(e){return new Is(this,e)}reconfigure(e){return Kn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Is{constructor(e,t){this.compartment=e,this.inner=t}}class kn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Hf(e,t,o))u instanceof X?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],c=[];for(let u of s)l[u.id]=c.length<<1,c.push(d=>u.slot(d));let h=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,g=h&&h[u]||[];if(d.every(y=>y.type==0))if(l[p.id]=a.length<<1|1,Tr(g,d))a.push(i.facet(p));else{let y=p.combine(d.map(b=>b.value));a.push(i&&p.compare(y,i.facet(p))?i.facet(p):y)}else{for(let y of d)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=c.length<<1,c.push(b=>y.dynamicSlot(b)));l[p.id]=c.length<<1,c.push(y=>Vf(y,p,d))}}let f=c.map(u=>u(l));return new kn(e,o,f,l,a,r)}}function Hf(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let c=i[a].indexOf(o);c>-1&&i[a].splice(c,1),o instanceof Is&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let c of o)r(c,l);else if(o instanceof Is){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,l)}else if(o instanceof aa)r(o.inner,o.prec);else if(o instanceof X)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof un)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,mt.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,l)}}return r(n,mt.default),i.reduce((o,l)=>o.concat(l))}function di(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Cn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const ha=A.define(),Ns=A.define({combine:n=>n.some(e=>e),static:!0}),ca=A.define({combine:n=>n.length?n[0]:void 0,static:!0}),fa=A.define(),ua=A.define(),da=A.define(),pa=A.define({combine:n=>n.length?n[0]:!1});class Ie{constructor(e,t){this.type=e,this.value=t}static define(){return new Wf}}class Wf{of(e){return new Ie(this,e)}}class $f{constructor(e){this.map=e}of(e){return new D(this,e)}}class D{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new D(this.type,t)}is(e){return this.type==e}static define(e={}){return new $f(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}D.reconfigure=D.define();D.appendConfig=D.define();class Y{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&la(i,t.newLength),r.some(l=>l.type==Y.time)||(this.annotations=r.concat(Y.time.of(Date.now())))}static create(e,t,i,s,r,o){return new Y(e,t,i,s,r,o)}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(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Y.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Y.time=Ie.define();Y.userEvent=Ie.define();Y.addToHistory=Ie.define();Y.remote=Ie.define();function zf(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ma(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=Z.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:D.mapEffects(n.effects,s).concat(D.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Fs(n,e,t){let i=e.selection,s=It(e.annotations);return e.userEvent&&(s=s.concat(Y.userEvent.of(e.userEvent))),{changes:e.changes instanceof Z?e.changes:Z.of(e.changes||[],t,n.facet(ca)),selection:i&&(i instanceof v?i:v.single(i.anchor,i.head)),effects:It(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function ga(n,e,t){let i=Fs(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=ma(i,Fs(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=Y.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return qf(t?jf(s):s)}function jf(n){let e=n.startState,t=!0;for(let s of e.facet(fa)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:zf(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=Z.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=Y.create(e,s,n.selection&&n.selection.map(r),D.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(ua);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof Y?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Y?n=r[0]:n=ga(e,It(r),!1)}return n}function qf(n){let e=n.startState,t=e.facet(da),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=ma(i,Fs(e,r,n.changes.newLength),!0))}return i==n?n:Y.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Kf=[];function It(n){return n==null?Kf:Array.isArray(n)?n:[n]}var z=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(z||(z={}));const _f=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Vs;try{Vs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Jf(n){if(Vs)return Vs.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||_f.test(t)))return!0}return!1}function Uf(n){return e=>{if(!/\S/.test(e))return z.Space;if(Jf(e))return z.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return z.Word;return z.Other}}class P{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)di(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return di(this,i),Cn(this,i)}update(...e){return ga(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(Kn.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,c)=>s.set(c,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(D.reconfigure)?(t=null,i=l.value):l.is(D.appendConfig)&&(t=null,i=It(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=kn.resolve(i,s,this),r=new P(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(Ns)?e.newSelection:e.newSelection.asSingle();new P(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:v.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=It(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),h=c.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(h);let f=s.mapDesc(c,!0);r.push(a.range.map(f)),s=s.compose(h),o=D.mapEffects(o,h).concat(D.mapEffects(It(a.effects),f))}return{changes:s,selection:v.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Z?e:Z.of(e,this.doc.length,this.facet(P.lineSeparator))}toText(e){return B.of(e.split(this.facet(P.lineSeparator)||Ps))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(di(this,t),Cn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof X&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return P.create({doc:e.doc,selection:v.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=kn.resolve(e.extensions||[],new Map),i=e.doc instanceof B?e.doc:B.of((e.doc||"").split(t.staticFacet(P.lineSeparator)||Ps)),s=e.selection?e.selection instanceof v?e.selection:v.single(e.selection.anchor,e.selection.head):v.single(0);return la(s,i.length),t.staticFacet(Ns)||(s=s.asSingle()),new P(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(P.tabSize)}get lineBreak(){return this.facet(P.lineSeparator)||`
@@ -6,10 +6,10 @@ import{c1 as at,c2 as yf,c3 as bf,c4 as vf,y as m,c5 as kr,x as xf,c6 as Ae,c7 a
6
6
  `,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),c=n.visualLineSide(s,!t)}if(a){if(!a(h))return l}else{if(!i)return c;a=i(h)}l=c}}function Pu(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==z.Space&&(s=o),s==o}}function Bu(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return v.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(s,e.assoc||-1),h=n.documentTop;if(c)o==null&&(o=c.left-a.left),l=r<0?c.top:c.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+h}let f=a.left+o,u=i??n.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*r,g=eh(n,{x:f,y:p},!1,r);if(p<a.top||p>a.bottom||(r<0?g<s:g>s)){let y=n.docView.coordsForChar(g),b=!y||p<y.top?-1:1;return v.cursor(g,b,void 0,o)}}}function pn(n,e,t){for(;;){let i=0;for(let s of n)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=i||t||(e-r<o-e?-1:1);e=a<0?r:o,i=a}});if(!i)return e}}function cs(n,e,t){let i=pn(n.state.facet(Br).map(s=>s(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:v.cursor(i,i<t.from?1:-1)}class Ru{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,C.safari&&e.contentDOM.addEventListener("input",()=>null),C.gecko&&Yu(e.contentDOM.ownerDocument)}handleEvent(e){!$u(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Lu(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ih.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),C.android&&C.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return C.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=th.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||Iu.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Nt(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:C.safari&&!C.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Eo(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){ae(t.state,s)}}}function Lu(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec;if(s&&s.domEventHandlers)for(let r in s.domEventHandlers){let o=s.domEventHandlers[r];o&&t(r).handlers.push(Eo(i.value,o))}if(s&&s.domEventObservers)for(let r in s.domEventObservers){let o=s.domEventObservers[r];o&&t(r).observers.push(Eo(i.value,o))}}for(let i in Le)t(i).handlers.push(Le[i]);for(let i in Me)t(i).observers.push(Me[i]);return e}const th=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Iu="dthko",ih=[16,17,18,20,91,92,224,225],Ji=6;function Ui(n){return Math.max(0,n)*.7+8}function Nu(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class Fu{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Zf(e.contentDOM),this.atoms=e.state.facet(Br).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(P.allowMultipleSelections)&&Vu(e,t),this.dragging=Wu(e,t)&&rh(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Nu(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Qa(this.view);e.clientX-a.left<=s+Ji?t=-Ui(s-e.clientX):e.clientX+a.right>=o-Ji&&(t=Ui(e.clientX-o)),e.clientY-a.top<=r+Ji?i=-Ui(r-e.clientY):e.clientY+a.bottom>=l-Ji&&(i=Ui(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let s=e.ranges[i],r=null;if(s.empty){let o=pn(this.atoms,s.from,0);o!=s.from&&(r=v.cursor(o,-1))}else{let o=pn(this.atoms,s.from,-1),l=pn(this.atoms,s.to,1);(o!=s.from||l!=s.to)&&(r=v.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?v.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Vu(n,e){let t=n.state.facet(Va);return t.length?t[0](e):C.mac?e.metaKey:e.ctrlKey}function Hu(n,e){let t=n.state.facet(Ha);return t.length?t[0](e):C.mac?!e.altKey:!e.ctrlKey}function Wu(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=wi(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function $u(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=F.get(t))&&i.ignoreEvent(e))return!1;return!0}const Le=Object.create(null),Me=Object.create(null),nh=C.ie&&C.ie_version<15||C.ios&&C.webkit_version<604;function zu(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),sh(n,t.value)},50)}function sh(n,e){let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(tr!=null&&t.selection.ranges.every(a=>a.empty)&&tr==r.toString()){let a=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:f},range:v.cursor(c.from+f.length)}})}else o?i=t.changeByRange(a=>{let c=r.line(s++);return{changes:{from:a.from,to:a.to,insert:c.text},range:v.cursor(a.from+c.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Me.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Le.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Me.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Me.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Le.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Wa))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Ku(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Fu(n,e,t,i)),i&&n.observer.ignore(()=>{va(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}return!1};function Po(n,e,t,i){if(i==1)return v.cursor(e,t);if(i==2)return Au(n.state,e,t);{let s=G.find(n.docView,e),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<n.state.doc.length&&l==r.to&&l++,v.range(o,l)}}let Bo=(n,e,t)=>e>=t.top&&e<=t.bottom&&n>=t.left&&n<=t.right;function ju(n,e,t,i){let s=G.find(n.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Bo(t,i,o))return-1;let l=s.coordsAt(r,1);return l&&Bo(t,i,l)?1:o&&o.bottom>=i?-1:1}function Ro(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ju(n,t,e.clientX,e.clientY)}}const qu=C.ie&&C.ie_version<=11;let Lo=null,Io=0,No=0;function rh(n){if(!qu)return n.detail;let e=Lo,t=No;return Lo=n,No=Date.now(),Io=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Io+1)%3:1}function Ku(n,e){let t=Ro(n,e),i=rh(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=Ro(n,r),c,h=Po(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=Po(n,t.pos,t.bias,i),u=Math.min(f.from,h.from),d=Math.max(f.to,h.to);h=u<h.from?v.range(u,d):v.range(d,u)}return o?s.replaceRange(s.main.extend(h.from,h.to)):l&&i==1&&s.ranges.length>1&&(c=_u(s,a.pos))?c:l?s.addRange(h):v.create([h])}}}function _u(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:s}=n.ranges[t];if(i<=e&&s>=e)return v.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Le.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=v.range(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};Le.dragend=n=>(n.inputState.draggedContent=null,!1);function Fo(n,e,t,i){if(!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&Hu(n,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Le.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&Fo(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Fo(n,e,i,!0),!0}return!1};Le.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=nh?null:e.clipboardData;return t?(sh(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(zu(n),!1)};function Ju(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Uu(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let tr=null;Le.copy=Le.cut=(n,e)=>{let{text:t,ranges:i,linewise:s}=Uu(n.state);if(!t&&!s)return!1;tr=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=nh?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Ju(n,t),!1)};const oh=Ie.define();function lh(n,e){let t=[];for(let i of n.facet(ja)){let s=i(n,e);s&&t.push(s)}return t?n.update({effects:t,annotations:oh.of(!0)}):null}function ah(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=lh(n.state,e);t?n.dispatch(t):n.update([])}},10)}Me.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),ah(n)};Me.blur=n=>{n.observer.clearSelectionRange(),ah(n)};Me.compositionstart=Me.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Me.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,C.chrome&&C.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Me.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Le.beforeinput=(n,e)=>{var t;let i;if(C.chrome&&C.android&&(i=th.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return C.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),C.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Me.compositionend(n,e),20),!1};const Vo=new Set;function Yu(n){Vo.has(n)||(Vo.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Ho=["pre-wrap","normal","pre-line","break-spaces"];class Gu{constructor(e){this.lineWrapping=e,this.doc=B.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ho.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let s=e[i];s<0?i++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,i,s,r,o){let l=Ho.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let c=0;c<o.length;c++){let h=o[c];h<0?c++:this.heightSamples[Math.floor(h*10)]=!0}}return a}}class Xu{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class $e{constructor(e,t,i,s,r){this.from=e,this.length=t,this.top=i,this.height=s,this._content=r}get type(){return typeof this._content=="number"?he.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ft?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new $e(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var H=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(H||(H={}));const mn=.001;class ce{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>mn&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return ce.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:f}=s[l],u=r.lineAt(a,H.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=c?u:r.lineAt(c,H.ByPosNoHeight,i,0,0);for(f+=d.to-c,c=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,h=s[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,H.ByPosNoHeight,i,0,0));h+=u.from-a,a=u.from;let p=Rr.build(i.setDoc(o),e,h,f);r=r.replace(a,c,p)}return r.updateHeight(i,0)}static empty(){return new ye(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,s=0,r=0;for(;;)if(t==i)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Qu(ce.of(e.slice(0,t)),o,ce.of(e.slice(i)))}}ce.prototype.size=1;class hh extends ce{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,s){return new $e(s,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,s,r){return this.blockAt(0,i,s,r)}forEachLine(e,t,i,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ye extends hh{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,s){return new $e(s,this.length,i,this.height,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof ye||s instanceof te&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof te?s=new ye(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):ce.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class te extends ce{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let c=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),h=t.doc.lineAt(c),f=l+h.length*a,u=Math.max(i,e-f/2);return new $e(h.from,h.length,u,f,0)}else{let c=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:h,length:f}=t.doc.line(r+c);return new $e(h,f,i+l*c,l,0)}}lineAt(e,t,i,s,r){if(t==H.ByHeight)return this.blockAt(e,i,s,r);if(t==H.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new $e(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),c=i.doc.lineAt(e),h=l+c.length*a,f=c.number-o,u=s+l*f+a*(c.from-r-f);return new $e(c.from,c.length,Math.max(s,Math.min(u,s+this.height-h)),h,0)}forEachLine(e,t,i,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(i,r);for(let h=e,f=s;h<=t;){let u=i.doc.lineAt(h);if(h==e){let p=u.number-l;f+=a*p+c*(e-r-p)}let d=a+c*u.length;o(new $e(u.from,u.length,f,d,0)),f+=d,h=u.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let r=i[i.length-1];r instanceof te?i[i.length-1]=new te(r.length+s):i.push(null,new te(s-1))}if(e>0){let r=i[0];r instanceof te?i[0]=new te(e+r.length):i.unshift(new te(e-1),null)}return ce.of(i)}decomposeLeft(e,t){t.push(new te(e-1),null)}decomposeRight(e,t){t.push(null,new te(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new te(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let f=s.heights[s.index++];a==-1?a=f:Math.abs(f-a)>=mn&&(a=-2);let u=new ye(h,f);u.outdated=!1,o.push(u),l+=h+1}l<=r&&o.push(null,new te(r-l).updateHeight(e,l));let c=ce.of(o);return(a<0||Math.abs(c.height-this.height)>=mn||Math.abs(a-this.heightMetrics(e,t).perLine)>=mn)&&(e.heightChanged=!0),c}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Qu extends ce{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,i,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==H.ByHeight?e<o:e<l,c=a?this.left.lineAt(e,t,i,s,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let h=t==H.ByPosNoHeight?H.ByPosNoHeight:H.ByPos;return a?c.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,s,r).join(c)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,s,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let c=this.lineAt(a,H.ByPos,i,s,r);e<c.from&&this.left.forEachLine(e,c.from-1,i,s,r,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Wo(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),Wo(r,l)}return ce.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?ce.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Wo(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof te&&(i=n[e+1])instanceof te&&n.splice(e-1,3,new te(t.length+1+i.length))}const Zu=5;class Rr{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof ye?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ye(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new hh(o,s,i)):(o||r||s>=Zu)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ye(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new te(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ye)return e;let t=new ye(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ye)&&!this.isCovered?this.nodes.push(new ye(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let s of this.nodes)s instanceof ye&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(e,t,i,s){let r=new Rr(i,e);return R.spans(t,i,s,r,0),r.finish(i)}}function ed(n,e,t){let i=new td;return R.compare(n,e,t,i,0),i.changes}class td{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,s){(e<t||i&&i.heightRelevant||s&&s.heightRelevant)&&Us(e,t,this.changes,5)}}function id(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,s=i.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let c=n.parentNode;c&&c!=i.body;)if(c.nodeType==1){let h=c,f=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let u=h.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=c==n.parentNode?u.bottom:Math.min(a,u.bottom)}c=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function nd(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class fs{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],r=t[i];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return M.replace({widget:new sd(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class sd extends Ne{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class $o{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=zo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=W.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Pr).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Gu(t),this.stateDeco=e.facet(Si).filter(i=>typeof i!="function"),this.heightMap=ce.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle.setDoc(e.doc),[new Ce(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=M.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Yi(r,o))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?zo:new Lr(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(hi(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Si).filter(h=>typeof h!="function");let s=e.changedRanges,r=Ce.extendWithRanges(s,ed(i,this.stateDeco,e?e.changes:Z.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ka)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?W.RTL:W.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,h=0;if(l.width&&l.height){let{scaleX:S,scaleY:k}=ba(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=S,this.scaleY=k,c|=8,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=wa(e.scrollDOM);let p=(this.printing?nd:id)(t,this.paddingTop),g=p.top-this.pixelViewport.top,y=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(S)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:k,charWidth:O,textHeight:L}=e.docView.measureTextSize();o=k>0&&s.refresh(r,k,O,L,x/O,S),o&&(e.docView.minWidth=0,c|=8)}g>0&&y>0?h=Math.max(g,y):g<0&&y<0&&(h=Math.min(g,y)),s.heightChanged=!1;for(let k of this.viewports){let O=k.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?ce.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle,[new Ce(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Xu(k.from,O))}s.heightChanged&&(c|=2)}let T=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return T&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||T)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Yi(s.lineAt(o-i*1e3,H.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,H.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(c,H.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c<a.from?u=f.top:u=f.bottom-h,a=new Yi(s.lineAt(u-1e3/2,H.ByHeight,r,0,0).from,s.lineAt(u+h+1e3/2,H.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Yi(this.heightMap.lineAt(i,H.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,H.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,H.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,H.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let s of e)t.touchesRange(s.from,s.to)||i.push(new fs(t.mapPos(s.from),t.mapPos(s.to),s.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=W.LTR&&!i)return[];let l=[],a=(h,f,u,d)=>{if(f-h<r)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let b of g)if(b>h&&b<f){a(h,b-10,u,d),a(b+10,f,u,d);return}let y=od(e,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-h)<r&&Math.abs(b.to-f)<r&&!g.some(x=>b.from<x&&b.to>x));if(!y){if(f<u.to&&t&&i&&t.visibleRanges.some(b=>b.from<=f&&b.to>=f)){let b=t.moveToLineBoundary(v.cursor(f),!1,!0).head;b>h&&(f=b)}y=new fs(h,f,this.gapSize(u,h,f,d))}l.push(y)},c=h=>{if(h.length<o||h.type!=he.Text)return;let f=rd(h.from,h.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,y,b;if(u!=null){let x=Xi(f,u),T=((this.visibleBottom-this.visibleTop)/2+g)/h.height;y=x-T,b=x+T}else y=(this.visibleTop-h.top-g)/h.height,b=(this.visibleBottom-h.top+g)/h.height;d=Gi(f,y),p=Gi(f,b)}else{let g=f.total*this.heightOracle.charWidth,y=s*this.heightOracle.charWidth,b,x;if(u!=null){let T=Xi(f,u),S=((this.pixelViewport.right-this.pixelViewport.left)/2+y)/g;b=T-S,x=T+S}else b=(this.pixelViewport.left-y)/g,x=(this.pixelViewport.right+y)/g;d=Gi(f,b),p=Gi(f,x)}d>h.from&&a(h.from,d,h,f),p<h.to&&a(p,h.to,h,f)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(c):c(h);return l}gapSize(e,t,i,s){let r=Xi(s,i)-Xi(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){fs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=M.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];R.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||hi(this.heightMap.lineAt(e,H.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||hi(this.heightMap.lineAt(this.scaler.fromDOM(e),H.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return hi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Yi{constructor(e,t){this.from=e,this.to=t}}function rd(n,e,t){let i=[],s=n,r=0;return R.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(i.push({from:s,to:e}),r+=e-s),{total:r,ranges:i}}function Gi({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function Xi(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function od(n,e){for(let t of n)if(e(t))return t}const zo={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};class Lr{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let c=t.lineAt(l,H.ByPos,e,0,0).top,h=t.lineAt(a,H.ByPos,e,0,0).bottom;return s+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,s=r.domBottom}}eq(e){return e instanceof Lr?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function hi(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new $e(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(s=>hi(s,e)):n._content)}const Qi=A.define({combine:n=>n.join(" ")}),ir=A.define({combine:n=>n.indexOf(!0)>-1}),nr=at.newName(),ch=at.newName(),fh=at.newName(),uh={"&light":"."+ch,"&dark":"."+fh};function sr(n,e,t){return new at(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const ld=sr("."+nr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},uh),ci="￿";class ad{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(P.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ci}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==t)break;let l=F.get(s),a=F.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:An(s))||An(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&this.lineBreak(),s=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=F.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(hd(e,i.node,i.offset)?t:0))}}function hd(n,e,t){for(;;){if(!e||t<Xe(e))return!1;if(e==n)return!0;t=wt(e)+1,e=e.parentNode}}class jo{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class cd{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:dd(e),a=new ad(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=pd(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!zs(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!zs(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),h=e.viewport;if((C.ios||C.chrome)&&e.state.selection.main.empty&&a!=c&&(h.from>0||h.to<e.state.doc.length)){let f=Math.min(a,c),u=Math.max(a,c),d=h.from-f,p=h.to-u;(d==0||d==1||f==0)&&(p==0||p==-1||u==e.state.doc.length)&&(a=0,c=e.state.doc.length)}this.newSel=v.single(c,a)}}}function dh(n,e){let t,{newSel:i}=e,s=n.state.selection.main,r=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,c=null;(r===8||C.android&&e.text.length<l-o)&&(a=s.to,c="end");let h=ud(n.state.doc.sliceString(o,l,ci),e.text,a-o,c);h&&(C.chrome&&r==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==ci+ci&&h.toB--,t={from:o+h.from,to:o+h.toA,insert:B.of(e.text.slice(h.from,h.toB).split(ci))})}else i&&(!n.hasFocus&&n.state.facet(tt)||i.main.eq(s))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!s.empty&&i&&i.main.empty?t={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,s.to)}:t&&t.from>=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,s.to))}:(C.mac||C.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=v.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:B.of([" "])}):C.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
7
7
  `&&n.lineWrapping&&(i&&(i=v.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:B.of([" "])}),t)return ph(n,t,i,r);if(i&&!i.main.eq(s)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function ph(n,e,t,i=-1){if(C.ios&&n.inputState.flushIOSKey(e))return!0;let s=n.state.selection.main;if(C.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Nt(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&Nt(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Nt(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=fd(n,e,t));return n.state.facet(za).some(a=>a(n,e.from,e.to,r,l))||n.dispatch(l()),!0}function fd(n,e,t){let i,s=n.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.from<e.from?s.sliceDoc(r.from,e.from):"",a=r.to>e.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=s.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(s.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let c=n.state.sliceDoc(e.from,e.to),h,f=t&&Za(n,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);h={from:f.from,to:f.to-p}}else h=n.state.doc.lineAt(r.head);let u=r.to-e.to,d=r.to-r.from;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:a||p.map(l)};let g=p.to-u,y=g-c.length;if(p.to-p.from!=d||n.state.sliceDoc(y,g)!=c||p.to>=h.from&&p.from<=h.to)return{range:p};let b=s.changes({from:y,to:g,insert:e.insert}),x=p.to-r.to;return{changes:b,range:a?v.range(Math.max(0,a.anchor+x),Math.max(0,a.head+x)):p.map(b)}})}else i={changes:l,selection:a&&s.selection.replaceRange(a)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:o,scrollIntoView:!0})}function ud(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r<s&&n.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&n.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function dd(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new jo(t,i)),(s!=t||r!=i)&&e.push(new jo(s,r))),e}function pd(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?v.single(t+e,i+e):null}const md={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},us=C.ie&&C.ie_version<=11;class gd{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new eu,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(C.ie&&C.ie_version<=11||C.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(C.chrome&&C.chrome_version<126)&&(this.editContext=new bd(e),e.state.facet(tt)&&(e.contentDOM.editContext=this.editContext.editContext)),us&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(tt)?i.root.activeElement!=this.dom:!dn(i.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(C.ie&&C.ie_version<=11||C.android&&C.chrome)&&!i.state.selection.main.empty&&s.focusNode&&pi(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=wi(e.root);if(!t)return!1;let i=C.safari&&e.root.nodeType==11&&Gf(this.dom.ownerDocument)==this.dom&&yd(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=dn(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&iu(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,md),us&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),us&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Nt(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&dn(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new cd(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,s=dh(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=qo(t,e.previousSibling||e.target.previousSibling,-1),s=qo(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(tt)!=e.state.facet(tt)&&(e.view.contentDOM.editContext=e.state.facet(tt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function qo(n,e,t){for(;e;){let i=F.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function Ko(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor);return pi(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function yd(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ko(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Ko(n,t):null}class bd{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let{anchor:s}=e.state.selection.main,r={from:this.toEditorPos(i.updateRangeStart),to:this.toEditorPos(i.updateRangeEnd),insert:B.of(i.text.split(`
8
8
  `))};r.from==this.from&&s<this.from?r.from=s:r.to==this.to&&s>this.to&&(r.to=s),!(r.from==r.to&&!r.insert.length)&&(this.pendingContextChange=r,e.state.readOnly||ph(e,r,v.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(o!="None"&&l!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;s.push(M.mark({attributes:{style:a}}).range(this.toEditorPos(r.rangeStart),this.toEditorPos(r.rangeEnd)))}}e.dispatch({effects:Ja.of(M.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=wi(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,c)=>{if(i)return;let h=c.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class w{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(s=>t(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||tu(e.parent)||document,this.viewState=new $o(e.state||P.create(e)),e.scrollTo&&e.scrollTo.is(_i)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(li).map(i=>new as(i));for(let i of this.plugins)i.update(this);this.observer=new gd(this),this.inputState=new Ru(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ko(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof Y?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(oh))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=lh(r,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(P.phrases)!=this.state.facet(P.phrases))return this.setState(r);s=Tn.create(this,r,e),s.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new Ft(d.empty?d:v.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(_i)&&(f=d.value.clip(this.state))}this.viewState.update(s,f),this.bidiCache=On.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(ai)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Qi)!=s.state.facet(Qi)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Qs))try{u(s)}catch(d){ae(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!dh(this,h)&&c.force&&Nt(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new $o(e),this.plugins=e.facet(li).map(i=>new as(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new ko(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(li),i=e.state.facet(li);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new as(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){ae(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(wa(i))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return ae(this.state,p),_o}}),f=Tn.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(h[d]!=_o)try{let p=c[d];p.write&&p.write(h[d],this)}catch(p){ae(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(p>1||p<-1){s=s+p,i.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Qs))l(t)}get themeClasses(){return nr+" "+(this.state.facet(ir)?fh:ch)+" "+this.state.facet(Qi)}updateAttrs(){let e=Jo(this,Ua,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(tt)?"true":"false",class:"cm-content",style:`${C.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Jo(this,Pr,t);let i=this.observer.ignore(()=>{let s=Js(this.contentDOM,this.contentAttrs,t),r=Js(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(w.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(ai);let e=this.state.facet(w.cspNonce);at.mount(this.root,this.styleModules.concat(ld).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return cs(this,e,Do(this,e,t,i))}moveByGroup(e,t){return cs(this,e,Do(this,e,t,i=>Pu(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return v.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return Eu(this,e,t,i)}moveVertically(e,t,i){return cs(this,e,Bu(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),eh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[rt.find(r,e-s.from,-1,t)];return _n(i,o.dir==W.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(qa)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>vd)return Na(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Ia(r.isolates,i=So(this,e))))return r.order;i||(i=So(this,e));let s=pu(e.text,t,i);return this.bidiCache.push(new On(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||C.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{va(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return _i.of(new Ft(typeof e=="number"?v.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return _i.of(new Ft(v.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return _.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return _.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=at.newName(),s=[Qi.of(i),ai.of(sr(`.${i}`,e))];return t&&t.dark&&s.push(ir.of(!0)),s}static baseTheme(e){return dt.lowest(ai.of(sr("."+nr,e,uh)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&F.get(i)||F.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}w.styleModule=ai;w.inputHandler=za;w.scrollHandler=_a;w.focusChangeEffect=ja;w.perLineTextDirection=qa;w.exceptionSink=$a;w.updateListener=Qs;w.editable=tt;w.mouseSelectionStyle=Wa;w.dragMovesSelection=Ha;w.clickAddsSelectionRange=Va;w.decorations=Si;w.outerDecorations=Ya;w.atomicRanges=Br;w.bidiIsolatedRanges=Ga;w.scrollMargins=Xa;w.darkTheme=ir;w.cspNonce=A.define({combine:n=>n.length?n[0]:""});w.contentAttributes=Pr;w.editorAttributes=Ua;w.lineWrapping=w.contentAttributes.of({class:"cm-lineWrapping"});w.announce=D.define();const vd=4096,_o={};class On{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:W.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&i.push(new On(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Jo(n,e,t){for(let i=n.state.facet(e),s=i.length-1;s>=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&_s(o,t)}return t}const xd=C.mac?"mac":C.windows?"win":C.linux?"linux":"key";function wd(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return s&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Zi(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const Sd=dt.default(w.domEventHandlers({keydown(n,e){return gh(mh(e.state),n,e,"editor")}})),Gt=A.define({enables:Sd}),Uo=new WeakMap;function mh(n){let e=n.facet(Gt),t=Uo.get(e);return t||Uo.set(e,t=Ad(e.reduce((i,s)=>i.concat(s),[]))),t}function kd(n,e,t){return gh(mh(n.state),e,n,t)}let it=null;const Cd=4e3;function Ad(n,e=xd){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,c,h)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>wd(b,e));for(let b=1;b<p.length;b++){let x=p.slice(0,b).join(" ");s(x,!0),d[x]||(d[x]={preventDefault:!0,stopPropagation:!1,run:[T=>{let S=it={view:T,prefix:x,scope:o};return setTimeout(()=>{it==S&&(it=null)},Cd),!0}]})}let g=p.join(" ");s(g,!1);let y=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),c&&(y.preventDefault=!0),h&&(y.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in h)h[u].run.push(d=>f(d,rr))}let a=o[e]||o.key;if(a)for(let c of l)r(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let rr=null;function gh(n,e,t,i){rr=e;let s=yf(e),r=ie(s,0),o=Se(r)==s.length&&s!=" ",l="",a=!1,c=!1,h=!1;it&&it.view==t&&it.scope==i&&(l=it.prefix+" ",ih.indexOf(e.keyCode)<0&&(c=!0,it=null));let f=new Set,u=y=>{if(y){for(let b of y.run)if(!f.has(b)&&(f.add(b),b(t)))return y.stopPropagation&&(h=!0),!0;y.preventDefault&&(y.stopPropagation&&(h=!0),c=!0)}return!1},d=n[i],p,g;return d&&(u(d[l+Zi(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(C.windows&&e.ctrlKey&&e.altKey)&&(p=bf[e.keyCode])&&p!=s?(u(d[l+Zi(p,e,!0)])||e.shiftKey&&(g=vf[e.keyCode])!=s&&g!=p&&u(d[l+Zi(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Zi(s,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),c&&(a=!0),a&&h&&e.stopPropagation(),rr=null,a}class Ni{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=yh(e);return[new Ni(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return Md(e,t,i)}}function yh(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==W.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Yo(n,e,t,i){let s=n.coordsAtPos(e,t*2);if(!s)return i;let r=n.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=n.posAtCoords({x:r.left+1,y:o}),a=n.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Md(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==W.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=yh(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),f=l.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),u=l.right-(h?parseInt(h.paddingRight):0),d=er(n,i),p=er(n,s),g=d.type==he.Text?d:null,y=p.type==he.Text?p:null;if(g&&(n.lineWrapping||d.widgetLineBreaks)&&(g=Yo(n,i,1,g)),y&&(n.lineWrapping||p.widgetLineBreaks)&&(y=Yo(n,s,-1,y)),g&&y&&g.from==y.from&&g.to==y.to)return x(T(t.from,t.to,g));{let k=g?T(t.from,null,g):S(d,!1),O=y?T(null,t.to,y):S(p,!0),L=[];return(g||d).to<(y||p).from-(g&&y?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2<O.top?L.push(b(f,k.bottom,u,O.top)):k.bottom<O.top&&n.elementAtHeight((k.bottom+O.top)/2).type==he.Text&&(k.bottom=O.top=(k.bottom+O.top)/2),x(k).concat(L).concat(x(O))}function b(k,O,L,K){return new Ni(e,k-a.left,O-a.top-.01,L-k,K-O+.01)}function x({top:k,bottom:O,horizontal:L}){let K=[];for(let I=0;I<L.length;I+=2)K.push(b(L[I],k,L[I+1],O));return K}function T(k,O,L){let K=1e9,I=-1e9,fe=[];function Ue(De,Ve,xe,Q,Ee){let ue=n.coordsAtPos(De,De==L.to?-2:2),Pe=n.coordsAtPos(xe,xe==L.from?2:-2);!ue||!Pe||(K=Math.min(ue.top,Pe.top,K),I=Math.max(ue.bottom,Pe.bottom,I),Ee==W.LTR?fe.push(r&&Ve?f:ue.left,r&&Q?u:Pe.right):fe.push(!r&&Q?f:Pe.left,!r&&Ve?u:ue.right))}let Oe=k??L.from,et=O??L.to;for(let De of n.visibleRanges)if(De.to>Oe&&De.from<et)for(let Ve=Math.max(De.from,Oe),xe=Math.min(De.to,et);;){let Q=n.state.doc.lineAt(Ve);for(let Ee of n.bidiSpans(Q)){let ue=Ee.from+Q.from,Pe=Ee.to+Q.from;if(ue>=xe)break;Pe>Ve&&Ue(Math.max(ue,Ve),k==null&&ue<=Oe,Math.min(Pe,xe),O==null&&Pe>=et,Ee.dir)}if(Ve=Q.to+1,Ve>=xe)break}return fe.length==0&&Ue(Oe,k==null,et,O==null,n.textDirection),{top:K,bottom:I,horizontal:fe}}function S(k,O){let L=l.top+(O?k.top:k.bottom);return{top:L,bottom:L,horizontal:[]}}}function Td(n,e){return n.constructor==e.constructor&&n.eq(e)}class Od{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(gn)!=e.state.facet(gn)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(gn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Td(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const gn=A.define();function bh(n){return[_.define(e=>new Od(e,n)),gn.of(n)]}const vh=!C.ios,ki=A.define({combine(n){return _e(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Dd(n={}){return[ki.of(n),Ed,Pd,Bd,Ka.of(!0)]}function xh(n){return n.startState.facet(ki)!=n.state.facet(ki)}const Ed=bh({above:!0,markers(n){let{state:e}=n,t=e.facet(ki),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||vh:t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:v.cursor(s.head,s.head>s.anchor?-1:1);for(let a of Ni.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=xh(n);return t&&Go(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Go(e.state,n)},class:"cm-cursorLayer"});function Go(n,e){e.style.animationDuration=n.facet(ki).cursorBlinkRate+"ms"}const Pd=bh({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:Ni.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||xh(n)},class:"cm-selectionLayer"}),or={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};vh&&(or[".cm-line"].caretColor=or[".cm-content"].caretColor="transparent !important");const Bd=dt.highest(w.theme(or)),wh=D.define({map(n,e){return n==null?null:e.mapPos(n)}}),fi=X.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(wh)?i.value:t,n)}}),Rd=_.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(fi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(fi)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(fi),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(fi)!=n&&this.view.dispatch({effects:wh.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Ld(){return[fi,Rd]}function Xo(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function Id(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class Nd{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,c,h)=>s(h,c,c+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,c,h)=>{let f=i(l,a,c);f&&h(c,c+l[0].length,f)};else if(i)this.addMatch=(l,a,c,h)=>h(c,c+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new ct,i=t.add.bind(t);for(let{from:s,to:r}of Id(e,this.maxLength))Xo(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),s=Math.max(a,s))}),e.viewportChanged||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),c=a.to<l?e.state.doc.lineAt(l):a,h=Math.max(r.from,a.from),f=Math.min(r.to,c.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){h=o;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){f=l;break}}let u=[],d,p=(g,y,b)=>u.push(b.range(g,y));if(a==c)for(this.regexp.lastIndex=h-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,e,d.index+a.from,p);else Xo(e.state.doc,this.regexp,h,f,(g,y)=>this.addMatch(y,e,g,p));t=t.update({filterFrom:h,filterTo:f,filter:(g,y)=>g<h||y>f,add:u})}}return t}}const lr=/x/.unicode!=null?"gu":"g",Fd=new RegExp(`[\0-\b
9
- --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,lr),Vd={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ds=null;function Hd(){var n;if(ds==null&&typeof document<"u"&&document.body){let e=document.body.style;ds=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return ds||!1}const yn=A.define({combine(n){let e=_e(n,{render:null,specialChars:Fd,addSpecialChars:null});return(e.replaceTabs=!Hd())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,lr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,lr)),e}});function Wd(n={}){return[yn.of(n),$d()]}let Qo=null;function $d(){return Qo||(Qo=_.fromClass(class{constructor(n){this.view=n,this.decorations=M.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(yn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Nd({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=ie(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Yt(o.text,l,i-o.from);return M.replace({widget:new Kd((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=M.replace({widget:new qd(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(yn);n.startState.facet(yn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const zd="•";function jd(n){return n>=32?zd:n==10?"␤":String.fromCharCode(9216+n)}class qd extends Ne{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=jd(this.code),i=e.state.phrase("Control character")+" "+(Vd[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Kd extends Ne{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function _d(){return Ud}const Jd=M.line({class:"cm-activeLine"}),Ud=_.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Jd.range(s.from)),e=s.from)}return M.set(t)}},{decorations:n=>n.decorations});class Yd extends Ne{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?zt(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),s=_n(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function Gd(n){return _.fromClass(class{constructor(e){this.view=e,this.placeholder=n?M.set([M.widget({widget:new Yd(n),side:1}).range(0)]):M.none}get decorations(){return this.view.state.doc.length?M.none:this.placeholder}},{decorations:e=>e.decorations})}const ar=2e3;function Xd(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>ar||t.off>ar||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let c=n.doc.line(a);c.length<=l&&r.push(v.range(c.from+o,c.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let c=n.doc.line(a),h=$s(c.text,o,n.tabSize,!0);if(h<0)r.push(v.cursor(c.to));else{let f=$s(c.text,l,n.tabSize);r.push(v.range(c.from+h,c.from+f))}}}return r}function Qd(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Zo(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>ar?-1:s==i.length?Qd(n,e.clientX):Yt(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Zd(n,e){let t=Zo(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Zo(n,s);if(!l)return i;let a=Xd(n.state,t,l);return a.length?o?v.create(a.concat(i.ranges)):v.create(a):i}}:null}function ep(n){let e=t=>t.altKey&&t.button==0;return w.mouseSelectionStyle.of((t,i)=>e(i)?Zd(t,i):null)}const tp={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},ip={style:"cursor: crosshair"};function np(n={}){let[e,t]=tp[n.key||"Alt"],i=_.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,w.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?ip:null})]}const ni="-10000px";class Sh{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let c=r[a],h=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==c.create&&(h=f)}if(h<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let f=o[a]=this.tooltipViews[h];l&&(l[a]=t[h]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,c)=>t[c]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function sp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const ps=A.define({combine:n=>{var e,t,i;return{position:C.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||sp}}}),el=new WeakMap,Ir=_.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(ps);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Sh(n,Nr,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(ps);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ni,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(C.gecko)i=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==ni&&s.style.left=="0px"){let r=s.getBoundingClientRect();i=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}}if(i||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((s,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(ps).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:h}=c,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){h.style.top=ni;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,y=(e=el.get(c))!==null&&e!==void 0?e:u.bottom-u.top,b=c.offset||op,x=this.view.textDirection==W.LTR,T=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,f.left-g+(d?14:0)-b.x),i.right-g),S=this.above[l];!a.strictSide&&(S?f.top-(u.bottom-u.top)-b.y<i.top:f.bottom+(u.bottom-u.top)+b.y>i.bottom)&&S==i.bottom-f.bottom>f.top-i.top&&(S=this.above[l]=!S);let k=(S?f.top-i.top:i.bottom-f.bottom)-p;if(k<y&&c.resize!==!1){if(k<this.view.defaultLineHeight){h.style.top=ni;continue}el.set(c,y),h.style.height=(y=k)/r+"px"}else h.style.height&&(h.style.height="");let O=S?f.top-y-p-b.y:f.bottom+p+b.y,L=T+g;if(c.overlap!==!0)for(let K of o)K.left<L&&K.right>T&&K.top<O+y&&K.bottom>O&&(O=S?K.top-y-2-p:K.bottom+p+2);if(this.position=="absolute"?(h.style.top=(O-n.parent.top)/r+"px",h.style.left=(T-n.parent.left)/s+"px"):(h.style.top=O/r+"px",h.style.left=T/s+"px"),d){let K=f.left+(x?b.x:-b.x)-(T+14-7);d.style.left=K/s+"px"}c.overlap!==!0&&o.push({left:T,top:O,right:L,bottom:O+y}),h.classList.toggle("cm-tooltip-above",S),h.classList.toggle("cm-tooltip-below",!S),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=ni}},{eventObservers:{scroll(){this.maybeMeasure()}}}),rp=w.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),op={x:0,y:0},Nr=A.define({enables:[Ir,rp]}),Dn=A.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Un{static create(e){return new Un(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Sh(e,Dn,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const lp=Nr.compute([Dn],n=>{let e=n.facet(Dn);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Un.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class ap{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let s,r=1;if(i instanceof st)s=i.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let l=e.coordsAtPos(s);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),c=a&&a.dir==W.RTL?-1:1;r=t.x<l.left?-c:c}let o=this.source(e,s,r);if(o!=null&&o.then){let l=this.pending={pos:s};o.then(a=>{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>ae(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Ir),t=e?e.manager.tooltips.findIndex(i=>i.create==Un.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!hp(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!cp(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const en=4;function hp(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-en&&e.clientX<=t.right+en&&e.clientY>=t.top-en&&e.clientY<=t.bottom+en}function cp(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=n.posAtCoords({x:i,y:s},!1);return a>=e&&a<=t}function fp(n,e={}){let t=D.define(),i=X.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,ee.TrackDel);if(a!=null){let c=Object.assign(Object.create(null),l);c.pos=a,c.end!=null&&(c.end=r.changes.mapPos(c.end)),o.push(c)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(up)&&(s=[]);return s},provide:s=>Dn.from(s)});return[i,_.define(s=>new ap(s,n,i,t,e.hoverTime||300)),lp]}function kh(n,e){let t=n.plugin(Ir);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const up=D.define(),tl=A.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ci(n,e){let t=n.plugin(Ch),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Ch=_.fromClass(class{constructor(n){this.input=n.state.facet(Ai),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(tl);this.top=new tn(n,!0,e.topContainer),this.bottom=new tn(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(tl);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new tn(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new tn(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ai);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let c=this.specs.indexOf(a),h;c<0?(h=a(n.view),l.push(h)):(h=this.panels[c],h.update&&h.update(n)),s.push(h),(h.top?r:o).push(h)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>w.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class tn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=il(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=il(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function il(n){let e=n.nextSibling;return n.remove(),e}const Ai=A.define({enables:Ch});class Ze extends ht{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ze.prototype.elementClass="";Ze.prototype.toDOM=void 0;Ze.prototype.mapMode=ee.TrackBefore;Ze.prototype.startSide=Ze.prototype.endSide=-1;Ze.prototype.point=!0;const bn=A.define(),dp={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>R.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},gi=A.define();function pp(n){return[Ah(),gi.of(Object.assign(Object.assign({},dp),n))]}const nl=A.define({combine:n=>n.some(e=>e)});function Ah(n){return[mp]}const mp=_.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(gi).map(e=>new rl(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(nl),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(nl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=R.iter(this.view.state.facet(bn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new gp(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==he.Text&&o){hr(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==he.Text){hr(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(gi),t=n.state.facet(gi),i=n.docChanged||n.heightChanged||n.viewportChanged||!R.eq(n.startState.facet(bn),n.state.facet(bn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new rl(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>w.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==W.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function sl(n){return Array.isArray(n)?n:[n]}function hr(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class gp{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=R.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Mh(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];hr(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class rl{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=sl(t.markers(e)),t.initialSpacer&&(this.spacer=new Mh(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=sl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!R.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mh{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),yp(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,c=!1;if(a){let h=a.elementClass;h&&(i+=" "+h);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,c=!0;break}}else l=this.markers.length;for(;o<l;){let h=this.markers[o++];if(h.toDOM){h.destroy(s);let f=s.nextSibling;s.remove(),s=f}}if(!a)break;a.toDOM&&(c?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),c&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function yp(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const bp=A.define(),Pt=A.define({combine(n){return _e(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let r=i[s],o=t[s];i[s]=r?(l,a,c)=>r(l,a,c)||o(l,a,c):o}return i}})}});class ms extends Ze{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function gs(n,e){return n.state.facet(Pt).formatNumber(e,n.state)}const vp=gi.compute([Pt],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(bp)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new ms(gs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Pt)!=e.state.facet(Pt),initialSpacer(e){return new ms(gs(e,ol(e.state.doc.lines)))},updateSpacer(e,t){let i=gs(t.view,ol(t.view.state.doc.lines));return i==e.number?e:new ms(i)},domEventHandlers:n.facet(Pt).domEventHandlers}));function xp(n={}){return[Pt.of(n),Ah(),vp]}function ol(n){let e=9;for(;e<n;)e=e*10+9;return e}const wp=new class extends Ze{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Sp=bn.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(wp.range(s)))}return R.of(e)});function kp(){return Sp}var ys;const Bt=new Ae;function Th(n){return A.define({combine:n?e=>e.concat(n):void 0})}const Fr=new Ae;class Be{constructor(e,t,i=[],s=""){this.data=e,this.name=s,P.prototype.hasOwnProperty("tree")||Object.defineProperty(P.prototype,"tree",{get(){return j(this)}}),this.parser=t,this.extension=[ut.of(this),P.languageData.of((r,o,l)=>{let a=ll(r,o,l),c=a.type.prop(Bt);if(!c)return[];let h=r.facet(c),f=a.type.prop(Fr);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return ll(e,t,i).type.prop(Bt)==this.data}findRegions(e){let t=e.facet(ut);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Bt)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(Ae.mounted);if(l){if(l.tree.prop(Bt)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let c=r.children[a];c instanceof Et&&s(c,r.positions[a]+o)}};return s(j(e),0),i}get allowsNesting(){return!0}}Be.setState=D.define();function ll(n,e,t){let i=n.facet(ut),s=j(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(e,t,Cr.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Kt extends Be{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Th(e.languageData);return new Kt(t,e.parser.configure({props:[Bt.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Kt(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function j(n){let e=n.field(Be.state,!1);return e?e.tree:Et.empty}class Cp{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let si=null;class En{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new En(e,t,[],Et.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Cp(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Et.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(cn.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(cn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=si;si=this;try{return e()}finally{si=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=al(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,h,f,u)=>a.push({fromA:c,toA:h,fromB:f,toB:u})),i=cn.applyChanges(i,a),s=Et.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);h<f&&l.push({from:h,to:f})}}}return new En(this.parser,t,i,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<e.to&&r>e.from&&(this.fragments=al(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Sf{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=si;if(a){for(let c of s)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Et(kr.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return si}}function al(n,e,t){return cn.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class _t{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new _t(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=En.create(e.facet(ut).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new _t(i)}}Be.state=X.define({create:_t.init,update(n,e){for(let t of e.effects)if(t.is(Be.setState))return t.value;return e.startState.facet(ut)!=e.state.facet(ut)?_t.init(e.state):n.apply(e)}});let Oh=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Oh=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const bs=typeof navigator<"u"&&(!((ys=navigator.scheduling)===null||ys===void 0)&&ys.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ap=_.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Be.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Be.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Oh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Be.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!bs?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>bs&&bs()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Be.setState.of(new _t(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ae(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ut=A.define({combine(n){return n.length?n[0]:null},enables:n=>[Be.state,Ap,w.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Vr{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Mp=A.define(),Xt=A.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Pn(n){let e=n.facet(Xt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Mi(n,e){let t="",i=n.tabSize,s=n.facet(Xt)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Hr(n,e){n instanceof P&&(n=new Yn(n));for(let i of n.state.facet(Mp)){let s=i(n,e);if(s!==void 0)return s}let t=j(n.state);return t.length>=e?Tp(n,t,e):null}class Yn{constructor(e,t={}){this.state=e,this.options=t,this.unit=Pn(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Yt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Gn=new Ae;function Tp(n,e,t){let i=e.resolveStack(t),s=i.node.enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o!=i.node;o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Dh(i,n,t)}function Dh(n,e,t){for(let i=n;i;i=i.next){let s=Dp(i.node);if(s)return s(Wr.create(e,t,i))}return 0}function Op(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Dp(n){let e=n.type.prop(Gn);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Ae.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Eh(o,!0,1,void 0,r&&!Op(o)?s.from:void 0)}return n.parent==null?Ep:null}function Ep(){return 0}class Wr extends Yn{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Wr(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Pp(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Dh(this.context.next,this.base,this.pos)}}function Pp(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Bp(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function vn({closing:n,align:e=!0,units:t=1}){return i=>Eh(i,e,t,n)}function Eh(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?Bp(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Rp=n=>n.baseIndent;function yi({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Lp=200;function Ip(){return P.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+Lp)return n;let r=t.sliceString(s.from,i);if(!e.some(c=>c.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==l)continue;l=h.from;let f=Hr(o,h.from);if(f==null)continue;let u=/^\s*/.exec(h.text)[0],d=Mi(o,f);u!=d&&a.push({from:h.from,to:h.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const Np=A.define(),Xn=new Ae;function $r(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function Fp(n,e,t){let i=j(n);if(i.length<t)return null;let s=i.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(Xn);if(a&&(l.to<i.length-50||i.length==n.doc.length||!Vp(l))){let c=a(l,n);c&&c.from<=t&&c.from>=e&&c.to>t&&(r=c)}}return r}function Vp(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Bn(n,e,t){for(let i of n.facet(Np)){let s=i(n,e,t);if(s)return s}return Fp(n,e,t)}function Ph(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Qn=D.define({map:Ph}),Fi=D.define({map:Ph});function Bh(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Ct=X.define({create(){return M.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(Qn)&&!Hp(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(Ih),s=i?M.replace({widget:new _p(i(e.state,t.value))}):hl;n=n.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Fi)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{s<i&&r>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>w.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],s=n[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(hl.range(i,s))}return M.set(e,!0)}});function Rn(n,e,t){var i;let s=null;return(i=n.field(Ct,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Hp(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Rh(n,e){return n.field(Ct,!1)?e:e.concat(D.appendConfig.of(Nh()))}const Wp=n=>{for(let e of Bh(n)){let t=Bn(n.state,e.from,e.to);if(t)return n.dispatch({effects:Rh(n.state,[Qn.of(t),Lh(n,t)])}),!0}return!1},$p=n=>{if(!n.state.field(Ct,!1))return!1;let e=[];for(let t of Bh(n)){let i=Rn(n.state,t.from,t.to);i&&e.push(Fi.of(i),Lh(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Lh(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return w.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const zp=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let s=n.lineBlockAt(i),r=Bn(e,s.from,s.to);r&&t.push(Qn.of(r)),i=(r?n.lineBlockAt(r.to):s).to+1}return t.length&&n.dispatch({effects:Rh(n.state,t)}),!!t.length},jp=n=>{let e=n.state.field(Ct,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(Fi.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},qp=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Wp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:$p},{key:"Ctrl-Alt-[",run:zp},{key:"Ctrl-Alt-]",run:jp}],Kp={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ih=A.define({combine(n){return _e(n,Kp)}});function Nh(n){return[Ct,Yp]}function Fh(n,e){let{state:t}=n,i=t.facet(Ih),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=Rn(n.state,l.from,l.to);a&&n.dispatch({effects:Fi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const hl=M.replace({widget:new class extends Ne{toDOM(n){return Fh(n,null)}}});class _p extends Ne{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Fh(e,this.value)}}const Jp={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class vs extends Ze{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Up(n={}){let e=Object.assign(Object.assign({},Jp),n),t=new vs(e,!0),i=new vs(e,!1),s=_.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ut)!=o.state.facet(ut)||o.startState.field(Ct,!1)!=o.state.field(Ct,!1)||j(o.startState)!=j(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ct;for(let a of o.viewportLineBlocks){let c=Rn(o.state,a.from,a.to)?i:Bn(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:r}=e;return[s,pp({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||R.empty},initialSpacer(){return new vs(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let c=Rn(o.state,l.from,l.to);if(c)return o.dispatch({effects:Fi.of(c)}),!0;let h=Bn(o.state,l.from,l.to);return h?(o.dispatch({effects:Qn.of(h)}),!0):!1}})}),Nh()]}const Yp=w.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 At{constructor(e,t){this.specs=e;let i;function s(l){let a=at.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Be?l=>l.prop(Bt)==o.data:o?l=>l==o:void 0,this.style=wf(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new at(i):null,this.themeType=t.themeType}static define(e,t){return new At(e,t||{})}}const cr=A.define(),Vh=A.define({combine(n){return n.length?[n[0]]:null}});function xs(n){let e=n.facet(cr);return e.length?e:n.facet(Vh)}function Zn(n,e){let t=[Xp],i;return n instanceof At&&(n.module&&t.push(w.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Vh.of(n)):i?t.push(cr.computeN([w.darkTheme],s=>s.facet(w.darkTheme)==(i=="dark")?[n]:[])):t.push(cr.of(n)),t}class Gp{constructor(e){this.markCache=Object.create(null),this.tree=j(e.state),this.decorations=this.buildDeco(e,xs(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=j(e.state),i=xs(e.state),s=i!=xs(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return M.none;let i=new ct;for(let{from:s,to:r}of e.visibleRanges)kf(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=M.mark({class:a})))},s,r);return i.finish()}}const Xp=dt.high(_.fromClass(Gp,{decorations:n=>n.decorations})),Qp=At.define([{tag:m.meta,color:"#404740"},{tag:m.link,textDecoration:"underline"},{tag:m.heading,textDecoration:"underline",fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.keyword,color:"#708"},{tag:[m.atom,m.bool,m.url,m.contentSeparator,m.labelName],color:"#219"},{tag:[m.literal,m.inserted],color:"#164"},{tag:[m.string,m.deleted],color:"#a11"},{tag:[m.regexp,m.escape,m.special(m.string)],color:"#e40"},{tag:m.definition(m.variableName),color:"#00f"},{tag:m.local(m.variableName),color:"#30a"},{tag:[m.typeName,m.namespace],color:"#085"},{tag:m.className,color:"#167"},{tag:[m.special(m.variableName),m.macroName],color:"#256"},{tag:m.definition(m.propertyName),color:"#00c"},{tag:m.comment,color:"#940"},{tag:m.invalid,color:"#f00"}]),Zp=w.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Hh=1e4,Wh="()[]{}",$h=A.define({combine(n){return _e(n,{afterCursor:!0,brackets:Wh,maxScanDistance:Hh,renderMatch:im})}}),em=M.mark({class:"cm-matchingBracket"}),tm=M.mark({class:"cm-nonmatchingBracket"});function im(n){let e=[],t=n.matched?em:tm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const nm=X.define({create(){return M.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet($h);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=ze(e.state,s.head,-1,i)||s.head>0&&ze(e.state,s.head-1,1,i)||i.afterCursor&&(ze(e.state,s.head,1,i)||s.head<e.state.doc.length&&ze(e.state,s.head+1,-1,i));r&&(t=t.concat(i.renderMatch(r,e.state)))}return M.set(t,!0)},provide:n=>w.decorations.from(n)}),sm=[nm,Zp];function rm(n={}){return[$h.of(n),sm]}const om=new Ae;function fr(n,e,t){let i=n.prop(e<0?Ae.openedBy:Ae.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function ur(n){let e=n.type.prop(om);return e?e(n.node):n}function ze(n,e,t,i={}){let s=i.maxScanDistance||Hh,r=i.brackets||Wh,o=j(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=fr(a.type,t,r);if(c&&a.from<a.to){let h=ur(a);if(h&&(t>0?e>=h.from&&e<h.to:e>h.from&&e<=h.to))return lm(n,e,t,a,h,c,r)}}return am(n,e,t,o,l.type,s,r)}function lm(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},c=0,h=l==null?void 0:l.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from<h.to){let f=ur(h);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(fr(h.type,t,o))c++;else if(fr(h.type,-t,o)){if(c==0){let f=ur(h);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(t<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}function am(n,e,t,i,s,r,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!h.next().done&&u<=r;){let d=h.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,y=t>0?d.length:-1;g!=y;g+=t){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return h.done?{start:c,matched:!1}:null}const hm=Object.create(null),cl=[kr.none],fl=[],ul=Object.create(null),cm=Object.create(null);for(let[n,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"]])cm[n]=fm(hm,e);function ws(n,e){fl.indexOf(n)>-1||(fl.push(n),console.warn(e))}function fm(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let h=n[c]||m[c];h?typeof h=="function"?a.length?a=a.map(h):ws(c,`Modifier ${c} used at start of tag`):a.length?ws(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:ws(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=ul[s];if(r)return r.id;let o=ul[s]=kr.define({id:cl.length,name:i,props:[xf({[i]:t})]});return cl.push(o),o.id}W.RTL,W.LTR;const Eb=()=>n=>{try{JSON.parse(n.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=um(e,n.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function um(n,e){let t;return(t=n.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=n.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const dm=Kt.define({name:"json",parser:Cf.configure({props:[Gn.add({Object:yi({except:/^\s*\}/}),Array:yi({except:/^\s*\]/})}),Xn.add({"Object Array":$r})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Pb(){return new Vr(dm)}class pm{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class gt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(je).markerFilter;r&&(s=r(s,i));let o=M.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?M.widget({widget:new Cm(l),diagnostic:l}).range(l.from):M.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new gt(o,t,Jt(o))}}function Jt(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new pm(s,r,o.diagnostic),!1}),i}function mm(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(je).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(zr))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function zh(n,e){return n.field(ve,!1)?e:e.concat(D.appendConfig.of(_h))}function gm(n,e){return{effects:zh(n,[zr.of(e)])}}const zr=D.define(),jr=D.define(),jh=D.define(),ve=X.define({create(){return new gt(M.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Jt(t,n.selected.diagnostic,r)||Jt(t,null,r)}!t.size&&s&&e.state.facet(je).autoPanel&&(s=null),n=new gt(t,s,i)}for(let t of e.effects)if(t.is(zr)){let i=e.state.facet(je).autoPanel?t.value.length?Ti.open:null:n.panel;n=gt.init(t.value,i,e.state)}else t.is(jr)?n=new gt(n.diagnostics,t.value?Ti.open:null,n.selected):t.is(jh)&&(n=new gt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ai.from(n,e=>e.panel),w.decorations.from(n,e=>e.diagnostics)]}),ym=M.mark({class:"cm-lintRange cm-lintRange-active"});function bm(n,e,t){let{diagnostics:i}=n.state.field(ve),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0))&&(s.push(h.diagnostic),r=Math.min(a,r),o=Math.max(c,o))});let l=n.state.facet(je).tooltipFilter;return l&&(s=l(s,n.state)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:vm(n,s)}}}:null}function vm(n,e){return V("ul",{class:"cm-tooltip-lint"},e.map(t=>Kh(n,t,!1)))}const xm=n=>{let e=n.state.field(ve,!1);(!e||!e.panel)&&n.dispatch({effects:zh(n.state,[jr.of(!0)])});let t=Ci(n,Ti.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},dl=n=>{let e=n.state.field(ve,!1);return!e||!e.panel?!1:(n.dispatch({effects:jr.of(!1)}),!0)},wm=n=>{let e=n.state.field(ve,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Sm=[{key:"Mod-Shift-m",run:xm,preventDefault:!0},{key:"F8",run:wm}],km=_.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(je);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(je);t.length&&Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let s=i.reduce((r,o)=>r.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(gm(this.view.state,s))},i=>{ae(this.view.state,i)})}}update(n){let e=n.state.facet(je);(n.docChanged||e!=n.startState.facet(je)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),je=A.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},_e(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function Bb(n,e={}){return[je.of({source:n,config:e}),km,_h]}function qh(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Kh(n,e,t){var i;let s=t?qh(e.actions):[];return V("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},V("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=Jt(n.state.field(ve).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,f=h<0?c:[c.slice(0,h),V("u",c.slice(h,h+1)),c.slice(h+1)];return V("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&V("div",{class:"cm-diagnosticSource"},e.source))}class Cm extends Ne{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return V("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class pl{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Kh(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ti{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)dl(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=qh(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Jt(this.view.state.field(ve).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=V("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=V("div",{class:"cm-panel-lint"},this.list,V("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>dl(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ve).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ve),i=0,s=!1,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let c=-1,h;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){c=f;break}c<0?(h=new pl(this.view,a.diagnostic),this.items.splice(i,0,h),s=!0):(h=this.items[c],c>i&&(this.items.splice(i,c-i),s=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),r=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new pl(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ve),i=Jt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:jh.of(i)})}static open(e){return new Ti(e)}}function Am(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function nn(n){return Am(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Mm=w.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:nn("#d11")},".cm-lintRange-warning":{backgroundImage:nn("orange")},".cm-lintRange-info":{backgroundImage:nn("#999")},".cm-lintRange-hint":{backgroundImage:nn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),_h=[ve,w.decorations.compute([ve],n=>{let{selected:e,panel:t}=n.field(ve);return!e||!t||e.from==e.to?M.none:M.set([ym.range(e.from,e.to)])}),fp(bm,{hideOn:mm}),Mm];var Jh=n=>{var{theme:e,settings:t={},styles:i=[]}=n,s={".cm-gutters":{}},r={};t.background&&(r.backgroundColor=t.background),t.backgroundImage&&(r.backgroundImage=t.backgroundImage),t.foreground&&(r.color=t.foreground),t.fontSize&&(r.fontSize=t.fontSize),(t.background||t.foreground)&&(s["&"]=r),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var o={};t.gutterActiveForeground&&(o.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},o.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=o,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var l=w.theme(s,{dark:e==="dark"}),a=At.define(i),c=[l,Zn(a)];return c},Tm={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},Om=[{tag:[m.standard(m.tagName),m.tagName],color:"#116329"},{tag:[m.comment,m.bracket],color:"#6a737d"},{tag:[m.className,m.propertyName],color:"#6f42c1"},{tag:[m.variableName,m.attributeName,m.number,m.operator],color:"#005cc5"},{tag:[m.keyword,m.typeName,m.typeOperator,m.typeName],color:"#d73a49"},{tag:[m.string,m.meta,m.regexp],color:"#032f62"},{tag:[m.name,m.quote],color:"#22863a"},{tag:[m.heading,m.strong],color:"#24292e",fontWeight:"bold"},{tag:[m.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[m.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#e36209"},{tag:[m.url,m.escape,m.regexp,m.link],color:"#032f62"},{tag:m.link,textDecoration:"underline"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.invalid,color:"#cb2431"}],Dm=n=>{var{theme:e="light",settings:t={},styles:i=[]}={};return Jh({theme:e,settings:qn({},Tm,t),styles:[...Om,...i]})},Rb=Dm(),Em={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},Pm=[{tag:[m.standard(m.tagName),m.tagName],color:"#7ee787"},{tag:[m.comment,m.bracket],color:"#8b949e"},{tag:[m.className,m.propertyName],color:"#d2a8ff"},{tag:[m.variableName,m.attributeName,m.number,m.operator],color:"#79c0ff"},{tag:[m.keyword,m.typeName,m.typeOperator,m.typeName],color:"#ff7b72"},{tag:[m.string,m.meta,m.regexp],color:"#a5d6ff"},{tag:[m.name,m.quote],color:"#7ee787"},{tag:[m.heading,m.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[m.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[m.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#ffab70"},{tag:m.link,textDecoration:"underline"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.invalid,color:"#f97583"}],Bm=n=>{var{theme:e="dark",settings:t={},styles:i=[]}={};return Jh({theme:e,settings:qn({},Em,t),styles:[...Pm,...i]})};Bm();var Rm=n=>{var{theme:e,settings:t={},styles:i=[]}=n,s={".cm-gutters":{}},r={};t.background&&(r.backgroundColor=t.background),t.backgroundImage&&(r.backgroundImage=t.backgroundImage),t.foreground&&(r.color=t.foreground),t.fontSize&&(r.fontSize=t.fontSize),(t.background||t.foreground)&&(s["&"]=r),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var o={};t.gutterActiveForeground&&(o.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},o.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=o,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var l=w.theme(s,{dark:e==="dark"}),a=At.define(i),c=[l,Zn(a)];return c},Lm={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},Im=[{tag:m.keyword,color:"#5e81ac"},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:"#88c0d0"},{tag:[m.variableName],color:"#8fbcbb"},{tag:[m.function(m.variableName)],color:"#8fbcbb"},{tag:[m.labelName],color:"#81a1c1"},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:"#5e81ac"},{tag:[m.definition(m.name),m.separator],color:"#a3be8c"},{tag:[m.brace],color:"#8fbcbb"},{tag:[m.annotation],color:"#d30102"},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:"#b48ead"},{tag:[m.typeName,m.className],color:"#ebcb8b"},{tag:[m.operator,m.operatorKeyword],color:"#a3be8c"},{tag:[m.tagName],color:"#b48ead"},{tag:[m.squareBracket],color:"#bf616a"},{tag:[m.angleBracket],color:"#d08770"},{tag:[m.attributeName],color:"#ebcb8b"},{tag:[m.regexp],color:"#5e81ac"},{tag:[m.quote],color:"#b48ead"},{tag:[m.string],color:"#a3be8c"},{tag:m.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:"#8fbcbb"},{tag:[m.meta],color:"#88c0d0"},{tag:[m.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[m.comment],color:"#4c566a",fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:"#5e81ac"},{tag:m.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:"#5e81ac"},{tag:m.special(m.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:m.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[m.heading5,m.heading6],color:"#5e81ac"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#d08770"},{tag:[m.processingInstruction,m.inserted],color:"#8fbcbb"},{tag:[m.contentSeparator],color:"#ebcb8b"},{tag:m.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],Nm=n=>{var{theme:e="dark",settings:t={},styles:i=[]}={};return Rm({theme:e,settings:qn({},Lm,t),styles:[...Im,...i]})},Lb=Nm();const Fm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Kr(n.state,t.from);return i.line?Vm(n):i.block?Wm(n):!1};function qr(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const Vm=qr(jm,0),Hm=qr(Uh,0),Wm=qr((n,e)=>Uh(n,e,zm(e)),0);function Kr(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const ri=50;function $m(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-ri,i),o=n.sliceDoc(s,s+ri),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let h,f;s-i<=2*ri?h=f=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+ri),f=n.sliceDoc(s-ri,s));let u=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return h.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(h.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function zm(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function Uh(n,e,t=e.selection.ranges){let i=t.map(r=>Kr(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>$m(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:c,close:h}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:r}}return null}function jm(n,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:r,to:o}of t){let l=i.length,a=1e9,c=Kr(e,r).line;if(c){for(let h=r;h<=o;){let f=e.doc.lineAt(h);if(f.from>s&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}h=f.to+1}if(a<1e9)for(let h=l;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:c,empty:h,single:f}of i)(f||!h)&&r.push({from:l.from+c,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const dr=Ie.define(),qm=Ie.define(),Km=A.define(),Yh=A.define({combine(n){return _e(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Gh=X.define({create(){return qe.empty},update(n,e){let t=e.state.facet(Yh),i=e.annotation(dr);if(i){let a=me.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=Ln(h,h.length,t.minDepth,a):h=Zh(h,e.startState.selection),new qe(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(qm);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(Y.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=me.fromTransaction(e),o=e.annotation(Y.time),l=e.annotation(Y.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new qe(n.done.map(me.fromJSON),n.undone.map(me.fromJSON))}});function _m(n={}){return[Gh,Yh.of(n),w.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Xh:e.inputType=="historyRedo"?pr:null;return i?(e.preventDefault(),i(t)):!1}})]}function es(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Gh,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Xh=es(0,!1),pr=es(1,!1),Jm=es(0,!0),Um=es(1,!0);class me{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new me(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new me(e.changes&&Z.fromJSON(e.changes),[],e.mapped&&Ke.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let i=ke;for(let s of e.startState.facet(Km)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new me(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ke)}static selection(e){return new me(void 0,ke,void 0,void 0,e)}}function Ln(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function Ym(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],h=t[a++];l>=c&&o<=h&&(i=!0)}}),i}function Gm(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Qh(n,e){return n.length?e.length?n.concat(e):n:e}const ke=[],Xm=200;function Zh(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Xm));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Ln(n,n.length-1,1e9,t.setSelAfter(i)))}else return[me.selection([e])]}function Qm(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Ss(n,e){if(!n.length)return n;let t=n.length,i=ke;for(;t;){let s=Zm(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[me.selection(i)]:ke}function Zm(n,e,t){let i=Qh(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):ke,t);if(!n.changes)return me.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new me(s,D.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const eg=/^(input\.type|delete)($|\.)/;class qe{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new qe(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||eg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,Ym(l.changes,e.changes))||i=="input.type.compose")?o=Ln(o,o.length-1,s.minDepth,new me(e.changes.compose(l.changes),Qh(e.effects,l.effects),l.mapped,l.startSelection,ke)):o=Ln(o,o.length,s.minDepth,e),new qe(o,ke,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ke;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Gm(r[r.length-1],e)?this:new qe(Zh(this.done,e),this.undone,t,i)}addMapping(e){return new qe(Ss(this.done,e),Ss(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:dr.of({side:e,rest:Qm(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?ke:s.slice(0,s.length-1);return r.mapped&&(l=Ss(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:dr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}qe.empty=new qe(ke,ke);const tg=[{key:"Mod-z",run:Xh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:pr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:pr,preventDefault:!0},{key:"Mod-u",run:Jm,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Um,preventDefault:!0}];function Qt(n,e){return v.create(n.ranges.map(e),n.mainIndex)}function Je(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Fe({state:n,dispatch:e},t){let i=Qt(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Je(n,i)),!0)}function ts(n,e){return v.cursor(e?n.to:n.from)}function ec(n,e){return Fe(n,t=>t.empty?n.moveByChar(t,e):ts(t,e))}function le(n){return n.textDirectionAt(n.state.selection.main.head)==W.LTR}const tc=n=>ec(n,!le(n)),ic=n=>ec(n,le(n));function nc(n,e){return Fe(n,t=>t.empty?n.moveByGroup(t,e):ts(t,e))}const ig=n=>nc(n,!le(n)),ng=n=>nc(n,le(n));function sg(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function is(n,e,t){let i=j(n).resolveInner(e.head),s=t?Ae.closedBy:Ae.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;sg(n,c,s)?i=c:a=t?c.to:c.from}let r=i.type.prop(s),o,l;return r&&(o=t?ze(n,i.from,1):ze(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,v.cursor(l,t?-1:1)}const rg=n=>Fe(n,e=>is(n.state,e,!le(n))),og=n=>Fe(n,e=>is(n.state,e,le(n)));function sc(n,e){return Fe(n,t=>{if(!t.empty)return ts(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const rc=n=>sc(n,!1),oc=n=>sc(n,!0);function lc(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(w.scrollMargins)){let o=r(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function ac(n,e){let t=lc(n),{state:i}=n,s=Qt(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):ts(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(r=w.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Je(i,s),{effects:r}),!0}const ml=n=>ac(n,!1),mr=n=>ac(n,!0);function pt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=v.cursor(i.from+r))}return s}const lg=n=>Fe(n,e=>pt(n,e,!0)),ag=n=>Fe(n,e=>pt(n,e,!1)),hg=n=>Fe(n,e=>pt(n,e,!le(n))),cg=n=>Fe(n,e=>pt(n,e,le(n))),fg=n=>Fe(n,e=>v.cursor(n.lineBlockAt(e.head).from,1)),ug=n=>Fe(n,e=>v.cursor(n.lineBlockAt(e.head).to,-1));function dg(n,e,t){let i=!1,s=Qt(n.selection,r=>{let o=ze(n,r.head,-1)||ze(n,r.head,1)||r.head>0&&ze(n,r.head-1,1)||r.head<n.doc.length&&ze(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return v.cursor(l)});return i?(e(Je(n,s)),!0):!1}const pg=({state:n,dispatch:e})=>dg(n,e);function Te(n,e){let t=Qt(n.state.selection,i=>{let s=e(i);return v.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(Je(n.state,t)),!0)}function hc(n,e){return Te(n,t=>n.moveByChar(t,e))}const cc=n=>hc(n,!le(n)),fc=n=>hc(n,le(n));function uc(n,e){return Te(n,t=>n.moveByGroup(t,e))}const mg=n=>uc(n,!le(n)),gg=n=>uc(n,le(n)),yg=n=>Te(n,e=>is(n.state,e,!le(n))),bg=n=>Te(n,e=>is(n.state,e,le(n)));function dc(n,e){return Te(n,t=>n.moveVertically(t,e))}const pc=n=>dc(n,!1),mc=n=>dc(n,!0);function gc(n,e){return Te(n,t=>n.moveVertically(t,e,lc(n).height))}const gl=n=>gc(n,!1),yl=n=>gc(n,!0),vg=n=>Te(n,e=>pt(n,e,!0)),xg=n=>Te(n,e=>pt(n,e,!1)),wg=n=>Te(n,e=>pt(n,e,!le(n))),Sg=n=>Te(n,e=>pt(n,e,le(n))),kg=n=>Te(n,e=>v.cursor(n.lineBlockAt(e.head).from)),Cg=n=>Te(n,e=>v.cursor(n.lineBlockAt(e.head).to)),bl=({state:n,dispatch:e})=>(e(Je(n,{anchor:0})),!0),vl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.doc.length})),!0),xl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.selection.main.anchor,head:0})),!0),wl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Ag=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Mg=({state:n,dispatch:e})=>{let t=ns(n).map(({from:i,to:s})=>v.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:v.create(t),userEvent:"select"})),!0},Tg=({state:n,dispatch:e})=>{let t=Qt(n.selection,i=>{var s;let r=j(n).resolveStack(i.from,1);for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((s=l.parent)===null||s===void 0)&&s.parent))return v.range(l.to,l.from)}return i});return e(Je(n,t)),!0},Og=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=v.create([t.main]):t.main.empty||(i=v.create([v.cursor(t.main.head)])),i?(e(Je(n,i)),!0):!1};function Vi(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=sn(n,a,!1)):a>o&&(t="delete.forward",a=sn(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=sn(n,o,!1),l=sn(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:v.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?w.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function sn(n,e,t){if(n instanceof w)for(let i of n.state.facet(w.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const yc=(n,e,t)=>Vi(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let c=Yt(l,r.tabSize),h=c%Pn(r)||Pn(r);for(let f=0;f<h&&l[l.length-1-f]==" ";f++)s--;a=s}else a=se(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=se(o.text,a-o.from,!1,!1)+o.from);return a}),gr=n=>yc(n,!1,!0),bc=n=>yc(n,!0,!1),vc=(n,e)=>Vi(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=se(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),xc=n=>vc(n,!1),Dg=n=>vc(n,!0),Eg=n=>Vi(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Pg=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Bg=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Rg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:B.of(["",""])},range:v.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Lg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:se(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:se(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:v.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ns(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function wc(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of ns(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(v.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(v.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:v.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ig=({state:n,dispatch:e})=>wc(n,e,!1),Ng=({state:n,dispatch:e})=>wc(n,e,!0);function Sc(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of ns(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Fg=({state:n,dispatch:e})=>Sc(n,e,!1),Vg=({state:n,dispatch:e})=>Sc(n,e,!0),Hg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(ns(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=Qt(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Wg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=j(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(Ae.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const $g=kc(!1),zg=kc(!0);function kc(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Wg(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new Yn(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=Hr(c,r);for(h==null&&(h=Yt(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Mi(e,h)];return a&&f.push(Mi(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:B.of(f)},range:v.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function _r(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:v.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const jg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Yn(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=_r(n,(r,o,l)=>{let a=Hr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],h=Mi(n,a);(c!=h||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:h}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},Cc=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(_r(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Xt)})}),{userEvent:"input.indent"})),!0),Ac=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(_r(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Yt(s,n.tabSize),o=0,l=Mi(n,Math.max(0,r-Pn(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),qg=n=>(n.setTabFocusMode(),!0),Kg=[{key:"Ctrl-b",run:tc,shift:cc,preventDefault:!0},{key:"Ctrl-f",run:ic,shift:fc},{key:"Ctrl-p",run:rc,shift:pc},{key:"Ctrl-n",run:oc,shift:mc},{key:"Ctrl-a",run:fg,shift:kg},{key:"Ctrl-e",run:ug,shift:Cg},{key:"Ctrl-d",run:bc},{key:"Ctrl-h",run:gr},{key:"Ctrl-k",run:Eg},{key:"Ctrl-Alt-h",run:xc},{key:"Ctrl-o",run:Rg},{key:"Ctrl-t",run:Lg},{key:"Ctrl-v",run:mr}],_g=[{key:"ArrowLeft",run:tc,shift:cc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ig,shift:mg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:hg,shift:wg,preventDefault:!0},{key:"ArrowRight",run:ic,shift:fc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ng,shift:gg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cg,shift:Sg,preventDefault:!0},{key:"ArrowUp",run:rc,shift:pc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:bl,shift:xl},{mac:"Ctrl-ArrowUp",run:ml,shift:gl},{key:"ArrowDown",run:oc,shift:mc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:vl,shift:wl},{mac:"Ctrl-ArrowDown",run:mr,shift:yl},{key:"PageUp",run:ml,shift:gl},{key:"PageDown",run:mr,shift:yl},{key:"Home",run:ag,shift:xg,preventDefault:!0},{key:"Mod-Home",run:bl,shift:xl},{key:"End",run:lg,shift:vg,preventDefault:!0},{key:"Mod-End",run:vl,shift:wl},{key:"Enter",run:$g},{key:"Mod-a",run:Ag},{key:"Backspace",run:gr,shift:gr},{key:"Delete",run:bc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:xc},{key:"Mod-Delete",mac:"Alt-Delete",run:Dg},{mac:"Mod-Backspace",run:Pg},{mac:"Mod-Delete",run:Bg}].concat(Kg.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Jg=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:rg,shift:yg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:og,shift:bg},{key:"Alt-ArrowUp",run:Ig},{key:"Shift-Alt-ArrowUp",run:Fg},{key:"Alt-ArrowDown",run:Ng},{key:"Shift-Alt-ArrowDown",run:Vg},{key:"Escape",run:Og},{key:"Mod-Enter",run:zg},{key:"Alt-l",mac:"Ctrl-l",run:Mg},{key:"Mod-i",run:Tg,preventDefault:!0},{key:"Mod-[",run:Ac},{key:"Mod-]",run:Cc},{key:"Mod-Alt-\\",run:jg},{key:"Shift-Mod-k",run:Hg},{key:"Shift-Mod-\\",run:pg},{key:"Mod-/",run:Fm},{key:"Alt-A",run:Hm},{key:"Ctrl-m",mac:"Shift-Alt-m",run:qg}].concat(_g),Ug={key:"Tab",run:Cc,shift:Ac},Sl=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Ut{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(Sl(l)):Sl,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ie(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Ar(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Se(e);let s=this.normalize(t);for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,i){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:i}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this});const Mc={from:-1,to:-1,match:/.*/.exec("")},Jr="gm"+(/x/.unicode==null?"":"u");class Tc{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=Mc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Oc(e,t,i,s,r);this.re=new RegExp(t,Jr+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=In(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=In(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ks=new WeakMap;class Vt{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=ks.get(e);if(!s||s.from>=i||s.to<=t){let l=new Vt(t,e.sliceString(t,i));return ks.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),ks.set(e,new Vt(o,r)),new Vt(t,r.slice(t-o,i-o))}}class Oc{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=Mc,this.matchPos=In(e,s),this.re=new RegExp(t,Jr+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=Vt.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=In(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Vt.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Tc.prototype[Symbol.iterator]=Oc.prototype[Symbol.iterator]=function(){return this});function Yg(n){try{return new RegExp(n,Jr),!0}catch{return!1}}function In(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function yr(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=V("input",{class:"cm-textfield",name:"line",value:e}),i=V("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:Nn.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},V("label",n.state.phrase("Go to line"),": ",t)," ",V("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,c,h,f]=r,u=h?+h.slice(1):0,d=c?+c:l.number;if(c&&f){let y=d/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*y)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),g=v.cursor(p.from+Math.max(0,Math.min(u,p.length)));n.dispatch({effects:[Nn.of(!1),w.scrollIntoView(g.from,{y:"center"})],selection:g}),n.focus()}return{dom:i}}const Nn=D.define(),kl=X.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Nn)&&(n=t.value);return n},provide:n=>Ai.from(n,e=>e?yr:null)}),Gg=n=>{let e=Ci(n,yr);if(!e){let t=[Nn.of(!0)];n.state.field(kl,!1)==null&&t.push(D.appendConfig.of([kl,Xg])),n.dispatch({effects:t}),e=Ci(n,yr)}return e&&e.dom.querySelector("input").select(),!0},Xg=w.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Qg={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Zg=A.define({combine(n){return _e(n,Qg,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function e0(n){return[r0,s0]}const t0=M.mark({class:"cm-selectionMatch"}),i0=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Cl(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=z.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=z.Word)}function n0(n,e,t,i){return n(e.sliceDoc(t,t+1))==z.Word&&n(e.sliceDoc(i-1,i))==z.Word}const s0=_.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Zg),{state:t}=n,i=t.selection;if(i.ranges.length>1)return M.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return M.none;let a=t.wordAt(s.head);if(!a)return M.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return M.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Cl(o,t,s.from,s.to)&&n0(o,t,s.from,s.to)))return M.none}else if(r=t.sliceDoc(s.from,s.to),!r)return M.none}let l=[];for(let a of n.visibleRanges){let c=new Ut(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:h,to:f}=c.value;if((!o||Cl(o,t,h,f))&&(s.empty&&h<=s.from&&f>=s.to?l.push(i0.range(h,f)):(h>=s.to||f<=s.from)&&l.push(t0.range(h,f)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:n=>n.decorations}),r0=w.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),o0=({state:n,dispatch:e})=>{let{selection:t}=n,i=v.create(t.ranges.map(s=>n.wordAt(s.head)||v.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function l0(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Ut(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ut(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const a0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return o0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=l0(n,i);return s?(e(n.update({selection:n.selection.addRange(v.range(s.from,s.to),!1),effects:w.scrollIntoView(s.to)})),!0):!1},Zt=A.define({combine(n){return _e(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new x0(e),scrollToMatch:e=>w.scrollIntoView(e)})}});class Dc{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Yg(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
10
- `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new u0(this):new c0(this)}getCursor(e,t=0,i){let s=e.doc?e:P.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Ot(this,s,t,i):Tt(this,s,t,i)}}class Ec{constructor(e){this.spec=e}}function Tt(n,e,t,i){return new Ut(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?h0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function h0(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(Fn(s,t-r))!=z.Word||e(Vn(s,t-r))!=z.Word)&&(e(Vn(s,i-r))!=z.Word||e(Fn(s,i-r))!=z.Word))}class c0 extends Ec{constructor(e){super(e)}nextMatch(e,t,i){let s=Tt(this.spec,e,i,e.doc.length).nextOverlapping();return s.done&&(s=Tt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Tt(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Tt(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Tt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ot(n,e,t,i){return new Tc(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?f0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function Fn(n,e){return n.slice(se(n,e,!1),e)}function Vn(n,e){return n.slice(e,se(n,e))}function f0(n){return(e,t,i)=>!i[0].length||(n(Fn(i.input,i.index))!=z.Word||n(Vn(i.input,i.index))!=z.Word)&&(n(Vn(i.input,i.index+i[0].length))!=z.Word||n(Fn(i.input,i.index+i[0].length))!=z.Word)}class u0 extends Ec{nextMatch(e,t,i){let s=Ot(this.spec,e,i,e.doc.length).next();return s.done&&(s=Ot(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Ot(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=Ot(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ot(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Oi=D.define(),Ur=D.define(),ot=X.define({create(n){return new Cs(br(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Oi)?n=new Cs(t.value.create(),n.panel):t.is(Ur)&&(n=new Cs(n.query,t.value?Yr:null));return n},provide:n=>Ai.from(n,e=>e.panel)});class Cs{constructor(e,t){this.query=e,this.panel=t}}const d0=M.mark({class:"cm-searchMatch"}),p0=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),m0=_.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ot))}update(n){let e=n.state.field(ot);(e!=n.startState.field(ot)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return M.none;let{view:t}=this,i=new ct;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(c,h)=>{let f=t.state.selection.ranges.some(u=>u.from==c&&u.to==h);i.add(c,h,f?p0:d0)})}return i.finish()}},{decorations:n=>n.decorations});function Hi(n){return e=>{let t=e.state.field(ot,!1);return t&&t.query.spec.valid?n(e,t):Rc(e)}}const Hn=Hi((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=v.single(i.from,i.to),r=n.state.facet(Zt);return n.dispatch({selection:s,effects:[Gr(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Bc(n),!0}),Wn=Hi((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=v.single(s.from,s.to),o=n.state.facet(Zt);return n.dispatch({selection:r,effects:[Gr(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Bc(n),!0}),g0=Hi((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:v.create(t.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),y0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new Ut(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(v.range(l.value.from,l.value.to))}return e(n.update({selection:v.create(r,o),userEvent:"select.search.matches"})),!0},Al=Hi((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=[],l,a,c=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),c.push(w.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let h=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=v.single(r.from-h,r.to-h),c.push(Gr(n,r)),c.push(t.facet(Zt).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:c,userEvent:"input.replace"}),!0}),b0=Hi((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:w.announce.of(i),userEvent:"input.replace.all"}),!0});function Yr(n){return n.state.facet(Zt).createPanel(n)}function br(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(Zt);return new Dc({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function Pc(n){let e=Ci(n,Yr);return e&&e.dom.querySelector("[main-field]")}function Bc(n){let e=Pc(n);e&&e==n.root.activeElement&&e.select()}const Rc=n=>{let e=n.state.field(ot,!1);if(e&&e.panel){let t=Pc(n);if(t&&t!=n.root.activeElement){let i=br(n.state,e.query.spec);i.valid&&n.dispatch({effects:Oi.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ur.of(!0),e?Oi.of(br(n.state,e.query.spec)):D.appendConfig.of(S0)]});return!0},Lc=n=>{let e=n.state.field(ot,!1);if(!e||!e.panel)return!1;let t=Ci(n,Yr);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ur.of(!1)}),!0},v0=[{key:"Mod-f",run:Rc,scope:"editor search-panel"},{key:"F3",run:Hn,shift:Wn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Hn,shift:Wn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Lc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:y0},{key:"Mod-Alt-g",run:Gg},{key:"Mod-d",run:a0,preventDefault:!0}];class x0{constructor(e){this.view=e;let t=this.query=e.state.field(ot).query.spec;this.commit=this.commit.bind(this),this.searchField=V("input",{value:t.search,placeholder:ge(e,"Find"),"aria-label":ge(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=V("input",{value:t.replace,placeholder:ge(e,"Replace"),"aria-label":ge(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=V("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=V("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=V("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return V("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=V("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>Hn(e),[ge(e,"next")]),i("prev",()=>Wn(e),[ge(e,"previous")]),i("select",()=>g0(e),[ge(e,"all")]),V("label",null,[this.caseField,ge(e,"match case")]),V("label",null,[this.reField,ge(e,"regexp")]),V("label",null,[this.wordField,ge(e,"by word")]),...e.state.readOnly?[]:[V("br"),this.replaceField,i("replace",()=>Al(e),[ge(e,"replace")]),i("replaceAll",()=>b0(e),[ge(e,"replace all")])],V("button",{name:"close",onclick:()=>Lc(e),"aria-label":ge(e,"close"),type:"button"},["×"])])}commit(){let e=new Dc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Oi.of(e)}))}keydown(e){kd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Wn:Hn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Al(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Oi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Zt).top}}function ge(n,e){return n.state.phrase(e)}const rn=30,on=/[\s\.,:;?!]/;function Gr(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-rn),o=Math.min(s,t+rn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<rn;a++)if(!on.test(l[a+1])&&on.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-rn;a--)if(!on.test(l[a-1])&&on.test(l[a])){l=l.slice(0,a);break}}return w.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const w0=w.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),S0=[ot,dt.low(m0),w0];class Ic{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=j(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Fc(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function Ml(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function k0(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Ml(e)+Ml(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Xr(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:k0(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Nc(n,e){return t=>{for(let i=j(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Tl{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function lt(n){return n.selection.main.from}function Fc(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Vc=Ie.define();function C0(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:e},range:v.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Ol=new WeakMap;function A0(n){if(!Array.isArray(n))return n;let e=Ol.get(n);return e||Ol.set(n,e=Xr(n)),e}const $n=D.define(),Di=D.define();class M0{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=ie(e,t),s=Se(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(ie(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let x=ie(e,0),T=Se(x),S=T==e.length?0:-100;if(x!=t[0])if(x==i[0])S+=-200;else return!1;return this.ret(S,[0,T])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let x=0,T=Math.min(e.length,200);x<T&&c<a;){let S=ie(e,x);(S==t[c]||S==i[c])&&(s[c++]=x),x+=Se(S)}if(c<a)return!1}let h=0,f=0,u=!1,d=0,p=-1,g=-1,y=/[a-z]/.test(e),b=!0;for(let x=0,T=Math.min(e.length,200),S=0;x<T&&f<a;){let k=ie(e,x);l<0&&(h<a&&k==t[h]&&(r[h++]=x),d<a&&(k==t[d]||k==i[d]?(d==0&&(p=x),g=x+1,d++):d=0));let O,L=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(O=Ar(k))!=O.toLowerCase()?1:O!=O.toUpperCase()?2:0;(!x||L==1&&y||S==0&&L!=0)&&(t[f]==k||i[f]==k&&(u=!0)?o[f++]=x:o.length&&(b=!1)),S=L,x+=Se(k)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?!1:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?Se(ie(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}const ne=A.define({combine(n){return _e(n,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:T0,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Dl(e(i),t(i)),optionClass:(e,t)=>i=>Dl(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function Dl(n,e){return n?e?n+" "+e:n:e}function T0(n,e,t,i,s,r){let o=n.textDirection==W.RTL,l=o,a=!1,c="top",h,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))h=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let x=s.bottom-e.bottom;x>=g||x>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let y=(e.bottom-e.top)/r.offsetHeight,b=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/y}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function O0(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;c<r.length;){let h=r[c++],f=r[c++];h>a&&o.appendChild(document.createTextNode(l.slice(a,h)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(h,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function As(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class D0{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(ne);this.optionContent=O0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=As(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,f;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(f=/-(\d+)$/.exec(h.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(ne).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Di.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=As(r.length,o,e.state.facet(ne).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=As(t.options.length,t.selected,this.view.state.facet(ne).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>ae(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&P0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(ne).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:c}=l;if(c){let u=typeof c=="string"?c:c.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let f=this.optionClass(l);f&&(h.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function E0(n,e){return t=>new D0(t,n,e)}function P0(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function El(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function B0(n,e){let t=[],i=null,s=a=>{t.push(a);let{section:c}=a.completion;if(c){i||(i=[]);let h=typeof c=="string"?c:c.name;i.some(f=>f.name==h)||i.push(typeof c=="string"?{name:h}:c)}};for(let a of n)if(a.hasResult()){let c=a.result.getMatch;if(a.result.filter===!1)for(let h of a.result.options)s(new Tl(h,a.source,c?c(h):[],1e9-t.length));else{let h=new M0(e.sliceDoc(a.from,a.to));for(let f of a.result.options)if(h.match(f.label)){let u=f.displayLabel?c?c(f,h.matched):[]:h.matched;s(new Tl(f,a.source,u,h.score+(f.boost||0)))}}}if(i){let a=Object.create(null),c=0,h=(f,u)=>{var d,p;return((d=f.rank)!==null&&d!==void 0?d:1e9)-((p=u.rank)!==null&&p!==void 0?p:1e9)||(f.name<u.name?-1:1)};for(let f of i.sort(h))c-=1e5,a[f.name]=c;for(let f of t){let{section:u}=f.completion;u&&(f.score+=a[typeof u=="string"?u:u.name])}}let r=[],o=null,l=e.facet(ne).compareCompletions;for(let a of t.sort((c,h)=>h.score-c.score||l(c.completion,h.completion))){let c=a.completion;!o||o.label!=c.label||o.detail!=c.detail||o.type!=null&&c.type!=null&&o.type!=c.type||o.apply!=c.apply||o.boost!=c.boost?r.push(a):El(a.completion)>El(o)&&(r[r.length-1]=a),o=a.completion}return r}class Rt{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Rt(this.options,Pl(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r){let o=B0(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Rt(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(ne).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let c=0;c<o.length;c++)if(o[c].completion==a){l=c;break}}return new Rt(o,Pl(i,l),{pos:e.reduce((a,c)=>c.hasResult()?Math.min(a,c.from):a,1e8),create:F0,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Rt(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class zn{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new zn(I0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ne),r=(i.override||t.languageDataAt("autocomplete",lt(t)).map(A0)).map(l=>(this.active.find(c=>c.source==l)||new pe(l,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!R0(r,this.active)?o=Rt.build(r,t,this.id,o,i):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new pe(l.source,0):l));for(let l of e.effects)l.is(Wc)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new zn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:L0}}function R0(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const L0={"aria-autocomplete":"list"};function Pl(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const I0=[];function vr(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class pe{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=vr(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new pe(s.source,0));for(let r of e.effects)if(r.is($n))s=new pe(s.source,1,r.value?lt(e.state):-1);else if(r.is(Di))s=new pe(s.source,0);else if(r.is(Hc))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new pe(this.source,1)}handleChange(e){return e.changes.touchesRange(lt(e.startState))?new pe(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new pe(this.source,this.state,e.mapPos(this.explicitPos))}}class Ht extends pe{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=lt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&lt(e.startState)==this.from)return new pe(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),c;return N0(this.result.validFor,e.state,r,o)?new Ht(this.source,a,this.result,r,o):this.result.update&&(c=this.result.update(this.result,r,o,new Ic(e.state,l,a>=0)))?new Ht(this.source,a,c,c.from,(s=c.to)!==null&&s!==void 0?s:lt(e.state)):new pe(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new pe(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Ht(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function N0(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):Fc(n,!0).test(s)}const Hc=D.define({map(n,e){return n.map(t=>t.map(e))}}),Wc=D.define(),be=X.define({create(){return zn.start()},update(n,e){return n.update(e)},provide:n=>[Nr.from(n,e=>e.tooltip),w.contentAttributes.from(n,e=>e.attrs)]});function $c(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(be).active.find(s=>s.source==e.source);return i instanceof Ht?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},C0(n.state,t,i.from,i.to)),{annotations:Vc.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const F0=E0(be,$c);function ln(n,e="option"){return t=>{let i=t.state.field(be,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ne).interactionDelay)return!1;let s=1,r;e=="page"&&(r=kh(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Wc.of(l)}),!0}}const V0=n=>{let e=n.state.field(be,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(ne).interactionDelay?!1:$c(n,e.open.options[e.open.selected])},H0=n=>n.state.field(be,!1)?(n.dispatch({effects:$n.of(!0)}),!0):!1,W0=n=>{let e=n.state.field(be,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Di.of(null)}),!0)};class $0{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const z0=50,j0=1e3,q0=_.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(be).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(be);if(!n.selectionSet&&!n.docChanged&&n.startState.field(be)==e)return;let t=n.transactions.some(s=>(s.selection||s.docChanged)&&!vr(s));for(let s=0;s<this.running.length;s++){let r=this.running[s];if(t||r.updates.length+n.transactions.length>z0&&Date.now()-r.time>j0){for(let o of r.context.abortListeners)try{o()}catch(l){ae(this.view.state,l)}r.context.abortListeners=null,this.running.splice(s--,1)}else r.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(r=>r.is($n)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.state.facet(ne).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(r=>r.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of n.transactions)vr(s)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(be);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=lt(e),i=new Ic(e,t,n.explicitPos==t),s=new $0(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Di.of(null)}),ae(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ne);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=new Ht(s.active.source,s.active.explicitPos,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:lt(s.updates.length?s.updates[0].startState:this.view.state));for(let l of s.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let r=this.view.state.field(be).active.find(o=>o.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new pe(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:Hc.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(be,!1);if(e&&e.tooltip&&this.view.state.facet(ne).closeOnBlur){let t=e.open&&kh(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Di.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$n.of(!1)}),20),this.composing=0}}}),zc=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});let K0=class{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}},_0=class jc{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,ee.TrackDel),i=e.mapPos(this.to,1,ee.TrackDel);return t==null||i==null?null:new jc(this.field,t,i)}},J0=class qc{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let f=0;f<h;f++)c+=e.facet(Xt);s.push(t+c.length-h),a=c+a.slice(h)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new _0(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",c=-1;for(let h=0;h<t.length;h++)(l!=null?t[h].seq==l:a&&t[h].name==a)&&(c=h);if(c<0){let h=0;for(;h<t.length&&(l==null||t[h].seq!=null&&t[h].seq<l);)h++;t.splice(h,0,{seq:l,name:a}),c=h;for(let f of s)f.field>=c&&f.field++}s.push(new K0(c,i.length,r.index,r.index+a.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}for(let l;l=/\\([{}])/.exec(o);){o=o.slice(0,l.index)+l[1]+o.slice(l.index+l[0].length);for(let a of s)a.line==i.length&&a.from>l.index&&(a.from--,a.to--)}i.push(o)}return new qc(i,s)}},U0=M.widget({widget:new class extends Ne{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Y0=M.mark({class:"cm-snippetField"}),ss=class Kc{constructor(e,t){this.ranges=e,this.active=t,this.deco=M.set(e.map(i=>(i.from==i.to?U0:Y0).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Kc(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}};const Wi=D.define({map(n,e){return n&&n.map(e)}}),G0=D.define(),Ei=X.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Wi))return t.value;if(t.is(G0)&&n)return new ss(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>w.decorations.from(n,e=>e?e.deco:M.none)});function Qr(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function X0(n){let e=J0.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:B.of(o)},scrollIntoView:!0,annotations:i?[Vc.of(i),Y.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=Qr(l,0)),l.some(c=>c.field>0)){let c=new ss(l,0),h=a.effects=[Wi.of(c)];t.state.field(Ei,!1)===void 0&&h.push(D.appendConfig.of([Ei,iy,ny,zc]))}t.dispatch(t.state.update(a))}}function _c(n){return({state:e,dispatch:t})=>{let i=e.field(Ei,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:Qr(i.ranges,s),effects:Wi.of(r?null:new ss(i.ranges,s)),scrollIntoView:!0})),!0}}const Q0=({state:n,dispatch:e})=>n.field(Ei,!1)?(e(n.update({effects:Wi.of(null)})),!0):!1,Z0=_c(1),ey=_c(-1),ty=[{key:"Tab",run:Z0,shift:ey},{key:"Escape",run:Q0}],Bl=A.define({combine(n){return n.length?n[0]:ty}}),iy=dt.highest(Gt.compute([Bl],n=>n.facet(Bl)));function q(n,e){return Object.assign(Object.assign({},e),{apply:X0(n)})}const ny=w.domEventHandlers({mousedown(n,e){let t=e.state.field(Ei,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:Qr(t.ranges,s.field),effects:Wi.of(t.ranges.some(r=>r.field>s.field)?new ss(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Pi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},vt=D.define({map(n,e){let t=e.mapPos(n,-1,ee.TrackAfter);return t??void 0}}),Zr=new class extends ht{};Zr.startSide=1;Zr.endSide=-1;const Jc=X.define({create(){return R.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(vt)&&(n=n.update({add:[Zr.range(t.value,t.value+1)]}));return n}});function sy(){return[oy,Jc]}const Ms="()[]{}<>";function Uc(n){for(let e=0;e<Ms.length;e+=2)if(Ms.charCodeAt(e)==n)return Ms.charAt(e+1);return Ar(n<128?n:n+1)}function Yc(n,e){return n.languageDataAt("closeBrackets",e)[0]||Pi}const ry=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oy=w.inputHandler.of((n,e,t,i)=>{if((ry?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Se(ie(i,0))==1||e!=s.from||t!=s.to)return!1;let r=hy(n.state,i);return r?(n.dispatch(r),!0):!1}),ly=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Yc(n,n.selection.main.head).brackets||Pi.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=cy(n.doc,o.head);for(let a of i)if(a==l&&rs(n.doc,o.head)==Uc(ie(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:v.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},ay=[{key:"Backspace",run:ly}];function hy(n,e){let t=Yc(n,n.selection.main.head),i=t.brackets||Pi.brackets;for(let s of i){let r=Uc(ie(s,0));if(e==s)return r==s?dy(n,s,i.indexOf(s+s+s)>-1,t):fy(n,s,r,t.before||Pi.before);if(e==r&&Gc(n,n.selection.main.from))return uy(n,s,r)}return null}function Gc(n,e){let t=!1;return n.field(Jc).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function rs(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Se(ie(t,0)))}function cy(n,e){let t=n.sliceString(e-2,e);return Se(ie(t,0))==t.length?t:t.slice(1)}function fy(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:vt.of(o.to+e.length),range:v.range(o.anchor+e.length,o.head+e.length)};let l=rs(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:vt.of(o.head+e.length),range:v.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function uy(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&rs(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:v.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dy(n,e,t,i){let s=i.stringPrefixes||Pi.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:vt.of(l.to+e.length),range:v.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=rs(n.doc,a),h;if(c==e){if(Rl(n,a))return{changes:{insert:e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)};if(Gc(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:v.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=Ll(n,a-2*e.length,s))>-1&&Rl(n,h))return{changes:{insert:e+e+e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=z.Word&&Ll(n,a,s)>-1&&!py(n,a,e,s))return{changes:{insert:e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Rl(n,e){let t=j(n).resolveInner(e+1);return t.parent&&t.from==e}function py(n,e,t,i){let s=j(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function Ll(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=z.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=z.Word)return r}return-1}function my(n={}){return[be,ne.of(n),q0,gy,zc]}const Xc=[{key:"Ctrl-Space",run:H0},{key:"Escape",run:W0},{key:"ArrowDown",run:ln(!0)},{key:"ArrowUp",run:ln(!1)},{key:"PageDown",run:ln(!0,"page")},{key:"PageUp",run:ln(!1,"page")},{key:"Enter",run:V0}],gy=dt.highest(Gt.computeN([ne],n=>n.facet(ne).defaultKeymap?[Xc]:[]));var Il=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(ay)),e.defaultKeymap!==!1&&(i=i.concat(Jg)),e.searchKeymap!==!1&&(i=i.concat(v0)),e.historyKeymap!==!1&&(i=i.concat(tg)),e.foldKeymap!==!1&&(i=i.concat(qp)),e.completionKeymap!==!1&&(i=i.concat(Xc)),e.lintKeymap!==!1&&(i=i.concat(Sm));var s=[];return e.lineNumbers!==!1&&s.push(xp()),e.highlightActiveLineGutter!==!1&&s.push(kp()),e.highlightSpecialChars!==!1&&s.push(Wd()),e.history!==!1&&s.push(_m()),e.foldGutter!==!1&&s.push(Up()),e.drawSelection!==!1&&s.push(Dd()),e.dropCursor!==!1&&s.push(Ld()),e.allowMultipleSelections!==!1&&s.push(P.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(Ip()),e.syntaxHighlighting!==!1&&s.push(Zn(Qp,{fallback:!0})),e.bracketMatching!==!1&&s.push(rm()),e.closeBrackets!==!1&&s.push(sy()),e.autocompletion!==!1&&s.push(my()),e.rectangularSelection!==!1&&s.push(ep()),t!==!1&&s.push(np()),e.highlightActiveLine!==!1&&s.push(_d()),e.highlightSelectionMatches!==!1&&s.push(e0()),e.tabSize&&typeof e.tabSize=="number"&&s.push(Xt.of(" ".repeat(e.tabSize))),s.concat([Gt.of(i.flat())]).filter(Boolean)};const yy="#e5c07b",Nl="#e06c75",by="#56b6c2",vy="#ffffff",xn="#abb2bf",xr="#7d8799",xy="#61afef",wy="#98c379",Fl="#d19a66",Sy="#c678dd",ky="#21252b",Vl="#2c313a",Hl="#282c34",Ts="#353a42",Cy="#3E4451",Wl="#528bff",Ay=w.theme({"&":{color:xn,backgroundColor:Hl},".cm-content":{caretColor:Wl},".cm-cursor, .cm-dropCursor":{borderLeftColor:Wl},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Cy},".cm-panels":{backgroundColor:ky,color:xn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Hl,color:xr,border:"none"},".cm-activeLineGutter":{backgroundColor:Vl},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ts},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ts,borderBottomColor:Ts},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Vl,color:xn}}},{dark:!0}),My=At.define([{tag:m.keyword,color:Sy},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:Nl},{tag:[m.function(m.variableName),m.labelName],color:xy},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Fl},{tag:[m.definition(m.name),m.separator],color:xn},{tag:[m.typeName,m.className,m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:yy},{tag:[m.operator,m.operatorKeyword,m.url,m.escape,m.regexp,m.link,m.special(m.string)],color:by},{tag:[m.meta,m.comment],color:xr},{tag:m.strong,fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.link,color:xr,textDecoration:"underline"},{tag:m.heading,fontWeight:"bold",color:Nl},{tag:[m.atom,m.bool,m.special(m.variableName)],color:Fl},{tag:[m.processingInstruction,m.string,m.inserted],color:wy},{tag:m.invalid,color:vy}]),Ty=[Ay,Zn(My)];var Oy=w.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Dy=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:i=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(Gt.of([Ug])),l&&(typeof l=="boolean"?a.unshift(Il()):a.unshift(Il(l))),o&&a.unshift(Gd(o)),r){case"light":a.push(Oy);break;case"dark":a.push(Ty);break;case"none":break;default:a.push(r);break}return i===!1&&a.push(w.editable.of(!1)),s&&a.push(P.readOnly.of(!0)),[...a]},Ey=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)}),$l=Ie.define(),Py=[];function By(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=Py,autoFocus:a,theme:c="light",height:h=null,minHeight:f=null,maxHeight:u=null,width:d=null,minWidth:p=null,maxWidth:g=null,placeholder:y="",editable:b=!0,readOnly:x=!1,indentWithTab:T=!0,basicSetup:S=!0,root:k,initialState:O}=n,[L,K]=we.useState(),[I,fe]=we.useState(),[Ue,Oe]=we.useState(),et=w.theme({"&":{height:h,minHeight:f,maxHeight:u,width:d,minWidth:p,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),De=w.updateListener.of(Q=>{if(Q.docChanged&&typeof i=="function"&&!Q.transactions.some(Pe=>Pe.annotation($l))){var Ee=Q.state.doc,ue=Ee.toString();i(ue,Q)}s&&s(Ey(Q))}),Ve=Dy({theme:c,editable:b,readOnly:x,placeholder:y,indentWithTab:T,basicSetup:S}),xe=[De,et,...Ve];return o&&typeof o=="function"&&xe.push(w.updateListener.of(o)),xe=xe.concat(l),we.useEffect(()=>{if(L&&!Ue){var Q={doc:e,selection:t,extensions:xe},Ee=O?P.fromJSON(O.json,Q,O.fields):P.create(Q);if(Oe(Ee),!I){var ue=new w({state:Ee,parent:L,root:k});fe(ue),r&&r(ue,Ee)}}return()=>{I&&(Oe(void 0),fe(void 0))}},[L,Ue]),we.useEffect(()=>K(n.container),[n.container]),we.useEffect(()=>()=>{I&&(I.destroy(),fe(void 0))},[I]),we.useEffect(()=>{a&&I&&I.focus()},[a,I]),we.useEffect(()=>{I&&I.dispatch({effects:D.reconfigure.of(xe)})},[c,l,h,f,u,d,p,g,y,b,x,T,S,i,o]),we.useEffect(()=>{if(e!==void 0){var Q=I?I.state.doc.toString():"";I&&e!==Q&&I.dispatch({changes:{from:0,to:Q.length,insert:e||""},annotations:[$l.of(!0)]})}},[e,I]),{state:Ue,setState:Oe,view:I,setView:fe,container:L,setContainer:K}}var Ry=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ly=we.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,autoFocus:h,theme:f="light",height:u,minHeight:d,maxHeight:p,width:g,minWidth:y,maxWidth:b,basicSetup:x,placeholder:T,indentWithTab:S,editable:k,readOnly:O,root:L,initialState:K}=n,I=Af(n,Ry),fe=we.useRef(null),{state:Ue,view:Oe,container:et}=By({container:fe.current,root:L,value:i,autoFocus:h,theme:f,height:u,minHeight:d,maxHeight:p,width:g,minWidth:y,maxWidth:b,basicSetup:x,placeholder:T,indentWithTab:S,editable:k,readOnly:O,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,extensions:r,initialState:K});if(we.useImperativeHandle(e,()=>({editor:fe.current,state:Ue,view:Oe}),[fe,et,Ue,Oe]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var De=typeof f=="string"?"cm-theme-"+f:"cm-theme";return Mf.jsx("div",qn({ref:fe,className:""+De+(t?" "+t:"")},I))});Ly.displayName="CodeMirror";const Iy=Ie.define(),Ny=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Fy{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class eo{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,ee.TrackDel),i=e.mapPos(this.to,1,ee.TrackDel);return t==null||i==null?null:new eo(this.field,t,i)}}class to{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let f=0;f<h;f++)c+=e.facet(Xt);s.push(t+c.length-h),a=c+a.slice(h)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new eo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",c=-1,h=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:h&&t[f].name==h)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:h}),c=f;for(let u of s)u.field>=c&&u.field++}s.push(new Fy(c,i.length,r.index,r.index+h.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of s)h.line==i.length&&h.from>c&&(h.from--,h.to--);return a}),i.push(o)}return new to(i,s)}}let Vy=M.widget({widget:new class extends Ne{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Hy=M.mark({class:"cm-snippetField"});class ei{constructor(e,t){this.ranges=e,this.active=t,this.deco=M.set(e.map(i=>(i.from==i.to?Vy:Hy).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new ei(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const $i=D.define({map(n,e){return n&&n.map(e)}}),Wy=D.define(),Bi=X.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is($i))return t.value;if(t.is(Wy)&&n)return new ei(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>w.decorations.from(n,e=>e?e.deco:M.none)});function io(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function $y(n){let e=to.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:B.of(o)},scrollIntoView:!0,annotations:i?[Iy.of(i),Y.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=io(l,0)),l.some(c=>c.field>0)){let c=new ei(l,0),h=a.effects=[$i.of(c)];t.state.field(Bi,!1)===void 0&&h.push(D.appendConfig.of([Bi,_y,Uy,Ny]))}t.dispatch(t.state.update(a))}}function Qc(n){return({state:e,dispatch:t})=>{let i=e.field(Bi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:io(i.ranges,s),effects:$i.of(r?null:new ei(i.ranges,s)),scrollIntoView:!0})),!0}}const zy=({state:n,dispatch:e})=>n.field(Bi,!1)?(e(n.update({effects:$i.of(null)})),!0):!1,jy=Qc(1),qy=Qc(-1),Ky=[{key:"Tab",run:jy,shift:qy},{key:"Escape",run:zy}],zl=A.define({combine(n){return n.length?n[0]:Ky}}),_y=dt.highest(Gt.compute([zl],n=>n.facet(zl)));function Jy(n,e){return Object.assign(Object.assign({},e),{apply:$y(n)})}const Uy=w.domEventHandlers({mousedown(n,e){let t=e.state.field(Bi,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:io(t.ranges,s.field),effects:$i.of(t.ranges.some(r=>r.field>s.field)?new ei(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Zc=new class extends ht{};Zc.startSide=1;Zc.endSide=-1;const yt={log:(...n)=>{},warn:(...n)=>{}},E={STRING:"String",NUMBER:"Number",TRUE:"True",FALSE:"False",NULL:"Null",OBJECT:"Object",ARRAY:"Array",PROPERTY:"Property",PROPERTY_NAME:"PropertyName",PROPERTY_COLON:"PropertyColon",ITEM:"Item",JSON_TEXT:"JsonText",INVALID:"⚠"},Yy={Pair:E.PROPERTY,Key:E.PROPERTY_NAME,BlockSequence:E.ARRAY,BlockMapping:E.OBJECT,FlowSequence:E.ARRAY,FlowMapping:E.OBJECT,QuotedLiteral:E.STRING,Literal:E.STRING,Stream:E.JSON_TEXT,Document:E.OBJECT},Gy={File:E.JSON_TEXT},no=[E.STRING,E.NUMBER,E.TRUE,E.FALSE,E.NULL],ef=[E.OBJECT,E.ARRAY,E.ITEM],$={JSON5:"json5",JSON:"json4",YAML:"yaml"},U=(n,e)=>{var t,i;switch(e){case $.YAML:return(t=Yy[n])!==null&&t!==void 0?t:n;case $.JSON5:return(i=Gy[n])!==null&&i!==void 0?i:n;default:return n}};function tf(n,e,t){const i=[];for(let s=e;s!=null&&s.parent;s=s.parent)switch(U(s.parent.name,t)){case E.PROPERTY:{const r=wr(s.parent,E.PROPERTY_NAME,t);r&&i.unshift(Dt(n,r).replace(/[/~]/g,o=>o==="~"?"~0":"~1"));break}case E.ARRAY:{if(Qy(s,t)){const r=rf(s.parent,s,t);i.unshift(`${r}`)}break}}return i.unshift(""),i.join("/")}const nf=(n,e,t=-1,i)=>tf(n.doc,j(n).resolve(e,t),i),so=(n,e)=>{const t=j(n),i=new Map;return t.iterate({enter:s=>{var r,o,l,a,c,h,f,u;if([E.PROPERTY_NAME,E.OBJECT].includes(U(s.name,e))){const d=tf(n.doc,s.node,e),{from:p,to:g}=s.node;if(!(!((o=(r=s.node)===null||r===void 0?void 0:r.nextSibling)===null||o===void 0)&&o.node))return i.set(d,{keyFrom:p,keyTo:g}),!0;const y=e===$.JSON?(a=(l=s.node)===null||l===void 0?void 0:l.nextSibling)===null||a===void 0?void 0:a.node:(u=(f=(h=(c=s.node)===null||c===void 0?void 0:c.nextSibling)===null||h===void 0?void 0:h.node)===null||f===void 0?void 0:f.nextSibling)===null||u===void 0?void 0:u.node;if(!y)return i.set(d,{keyFrom:p,keyTo:g}),!0;const{from:b,to:x}=y;return i.set(d,{keyFrom:p,keyTo:g,valueFrom:b,valueTo:x}),!0}}}),i},Os=(n,e,t=-1)=>j(n).resolveInner(e,t),wn=n=>n.replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1"),Xy=n=>n.replace(/^"(.*)"$/,"'$1'"),Dt=(n,e,t=!0,i=!0)=>{const s=e?n.sliceString(e.from,e.to):"";return t?i?wn(s):s.replace(/(^["'])|(["']$)/g,""):s},sf=(n,e)=>{var t,i,s,r;return U(n.name,e)===E.INVALID&&(U((i=(t=n.prevSibling)===null||t===void 0?void 0:t.name)!==null&&i!==void 0?i:"",e)===E.PROPERTY_NAME||U((r=(s=n.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)===E.PROPERTY_COLON)},Sn=(n,e)=>no.includes(U(n.name,e))||sf(n,e),Qy=(n,e)=>[...no,...ef].includes(U(n.name,e))||sf(n,e),an=(n,e)=>{var t,i,s,r,o,l;return U(n.name,e)===E.PROPERTY_NAME||U(n.name,e)===E.INVALID&&(U((i=(t=n.prevSibling)===null||t===void 0?void 0:t.name)!==null&&i!==void 0?i:"",e)===E.PROPERTY||U((r=(s=n.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)==="{")||e===$.YAML&&U((l=(o=n.parent)===null||o===void 0?void 0:o.name)!==null&&l!==void 0?l:"",e)===E.OBJECT},zi=n=>{const e=[];let t=n.firstChild;for(;t;)t&&e.push(t),t=t==null?void 0:t.nextSibling;return e},Zy=(n,e,t)=>zi(n).filter(i=>U(i.name,t)===e),wr=(n,e,t)=>{var i;return(i=zi(n).find(s=>U(s.name,t)===e))!==null&&i!==void 0?i:null},jl=(n,e)=>zi(n).find(t=>Sn(t,e)),eb=(n,e)=>zi(n).filter(t=>no.includes(U(t.name,e))||ef.includes(U(t.name,e))),rf=(n,e,t)=>eb(n,t).findIndex(i=>i.from===e.from&&i.to===e.to),ql=(n,e,t,i=1/0)=>{let s=n;for(;s&&i>0;){if(U(s.name,t)===e)return s;s=s.parent,i--}return null},tb=D.define(),jn=X.define({create(){},update(n,e){for(const t of e.effects)if(t.is(tb))return t.value;return n}}),ro=n=>n.field(jn),Nb=n=>[jn.init(()=>n)],Sr=Tf({linkify:!0,typographer:!0});(async()=>{const n=await Of({themes:{light:"vitesse-light",dark:"vitesse-dark"}});Sr.use(n)})();function Wt(n,e=!0){return e?Sr.renderInline(n):Sr.render(n)}class ib{constructor(){this.completions=new Map,this.reservedKeys=new Set}reserve(e){this.reservedKeys.add(e)}add(e){this.reservedKeys.has(e.label)||this.completions.set(e.label,e)}}class nb{constructor(e){var t;this.opts=e,this.schema=null,this.mode=$.JSON,this.mode=(t=e.mode)!==null&&t!==void 0?t:$.JSON}doComplete(e){var t,i,s;const r=ro(e.state);if(this.schema=(t=this.expandSchemaProperty(r,r))!==null&&t!==void 0?t:r,!this.schema)return[];const o={from:e.pos,to:e.pos,options:[],filter:!1},l=e.state.doc.sliceString(0);let a=Os(e.state,e.pos),c=e.state.sliceDoc(a.from,e.pos).replace(/^(["'])/,"");if(!(Sn(a,this.mode)||an(a,this.mode))&&!e.explicit)return o;const h=Dt(e.state.doc,a),f=Dt(e.state.doc,a,!1);if(a&&(Sn(a,this.mode)||an(a,this.mode)))o.from=a.from,o.to=a.to;else{const g=e.matchBefore(/[A-Za-z0-9._]*/),y=e.pos-h.length;yt.log("xxx","overwriteStart after",y,"ctx.pos",e.pos,"word",g,"currentWord",h,"=>",l[y-1],"..",l[y],"..",l),o.from=a.name===E.INVALID?(i=g==null?void 0:g.from)!==null&&i!==void 0?i:e.pos:y,o.to=e.pos}const u=new ib;let d=!0;const p=ql(a,E.PROPERTY_NAME,this.mode);if(p&&(a=p),an(a,this.mode)){const g=a.parent;if(g){const y=jl(g,this.mode);d=!y||y.name===E.INVALID&&y.from-y.to===0||(y.parent?zi(y.parent).length<=1:!1),yt.log("xxx","addValue",d,jl(g,this.mode),a),a=(s=ql(g,E.OBJECT,this.mode))!==null&&s!==void 0?s:null}}if(yt.log("xxx",a,h,e,"node at pos",Os(e.state,e.pos)),a&&[E.OBJECT,E.JSON_TEXT].includes(U(a.name,this.mode))&&(an(Os(e.state,e.pos),this.mode)||p)){if(a.from===e.pos)return o;this.getPropertyCompletions(this.schema,e,a,u,d,f)}else{const g={};this.getValueCompletions(this.schema,e,g,u)}return o.options=Array.from(u.completions.values()).filter(g=>wn(g.label).startsWith(c)),yt.log("xxx","result",o,"prefix",c,"collector.completions",u.completions,"reservedKeys",u.reservedKeys),o}applySnippetCompletion(e){return Jy(typeof e.apply!="string"?e.label:e.apply,e)}getPropertyCompletions(e,t,i,s,r,o){Zy(i,E.PROPERTY,this.mode).forEach(c=>{const h=Dt(t.state.doc,wr(c,E.PROPERTY_NAME,this.mode));s.reserve(wn(h))}),this.getSchemas(e,t).forEach(c=>{if(typeof c!="object")return;const h=c.properties;h&&Object.entries(h).forEach(([u,d])=>{var p,g;if(typeof d=="object"){const y=(p=d.description)!==null&&p!==void 0?p:"",b=(g=d.type)!==null&&g!==void 0?g:"",x=Array.isArray(b)?b.toString():b,T={label:u,apply:this.getInsertTextForProperty(u,r,o,d),type:"property",detail:x,info:Wt(y)};s.add(this.applySnippetCompletion(T))}});const f=c.propertyNames;if(typeof f=="object"&&(f.enum&&f.enum.forEach(u=>{const d=u==null?void 0:u.toString();if(d){const p={label:d,apply:this.getInsertTextForProperty(d,r,o),type:"property"};s.add(this.applySnippetCompletion(p))}}),f.const)){const u=f.const.toString(),d={label:u,apply:this.getInsertTextForProperty(u,r,o),type:"property"};s.add(this.applySnippetCompletion(d))}})}getInsertTextForProperty(e,t,i,s){s=s&&this.expandSchemaProperty(s,this.schema);let r=this.getInsertTextForPropertyName(e,i);if(!t)return r;r+=": ";let o,l=0;if(typeof s=="object"){if(typeof s.default<"u")o||(o=this.getInsertTextForGuessedValue(s.default,"")),l++;else if(s.enum&&(!o&&s.enum.length===1&&(o=this.getInsertTextForGuessedValue(s.enum[0],"")),l+=s.enum.length),typeof s.const<"u"&&(o||(o=this.getInsertTextForGuessedValue(s.const,"")),l++),Array.isArray(s.examples)&&s.examples.length&&(o||(o=this.getInsertTextForGuessedValue(s.examples[0],"")),l+=s.examples.length),o===void 0&&l===0){let a=Array.isArray(s.type)?s.type[0]:s.type;switch(a||(s.properties?a="object":s.items&&(a="array")),a){case"boolean":o="#{}";break;case"string":o=this.getInsertTextForString("");break;case"object":switch(this.mode){case $.JSON5:o="{#{}}";break;case $.YAML:o="#{}";break;default:o="{#{}}";break}break;case"array":o="[#{}]";break;case"number":case"integer":o="#{0}";break;case"null":o="#{null}";break;default:o="#{}";break}}}return(!o||l>1)&&(o="#{}"),r+o}getInsertTextForPropertyName(e,t){switch(this.mode){case $.JSON5:case $.YAML:return t.startsWith('"')?`"${e}"`:t.startsWith("'")?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t="#"){switch(this.mode){case $.JSON5:return`'${t}{${e}}'`;case $.YAML:return`${t}{${e}}`;default:return`"${t}{${e}}"`}}getInsertTextForGuessedValue(e,t=""){switch(typeof e){case"object":return e===null?"${null}"+t:this.getInsertTextForValue(e,t);case"string":{let i=JSON.stringify(e);return i=i.substr(1,i.length-2),i=this.getInsertTextForPlainText(i),this.getInsertTextForString(i,"$")+t}case"number":case"boolean":return"${"+JSON.stringify(e)+"}"+t}return this.getInsertTextForValue(e,t)}getInsertTextForPlainText(e){return e.replace(/[\\$}]/g,"\\$&")}getInsertTextForValue(e,t){const i=JSON.stringify(e,null," ");return i==="{}"?"{#{}}"+t:i==="[]"?"[#{}]"+t:this.getInsertTextForPlainText(i+t)}getValueCompletions(e,t,i,s){let r=j(t.state).resolveInner(t.pos,-1),o=null,l;if(r&&Sn(r,this.mode)&&(o=r,r=r.parent),!r){this.addSchemaValueCompletions(e,i,s);return}if(U(r.name,this.mode)===E.PROPERTY){const c=wr(r,E.PROPERTY_NAME,this.mode);c&&(l=Dt(t.state.doc,c),r=r.parent)}if(r&&(l!==void 0||U(r.name,this.mode)===E.ARRAY)){const c=this.getSchemas(e,t);for(const h of c){if(typeof h!="object")return;if(U(r.name,this.mode)===E.ARRAY&&h.items){let f=s;if(h.uniqueItems&&(f=Object.assign(Object.assign({},f),{add(u){f.completions.has(u.label)||s.add(u)},reserve(u){s.reserve(u)}})),Array.isArray(h.items)){let u=0;if(o){const p=rf(r,o,this.mode);p>=0&&(u=p)}const d=h.items[u];d&&this.addSchemaValueCompletions(d,i,f)}else this.addSchemaValueCompletions(h.items,i,f)}if(l!==void 0){let f=!1;if(h.properties){const u=h.properties[l];u&&(f=!0,this.addSchemaValueCompletions(u,i,s))}if(h.patternProperties&&!f)for(const u of Object.keys(h.patternProperties)){const d=this.extendedRegExp(u);if(d!=null&&d.test(l)){f=!0;const p=h.patternProperties[u];p&&this.addSchemaValueCompletions(p,i,s)}}if(h.additionalProperties&&!f){const u=h.additionalProperties;this.addSchemaValueCompletions(u,i,s)}}i.boolean&&(this.addBooleanValueCompletion(!0,s),this.addBooleanValueCompletion(!1,s)),i.null&&this.addNullValueCompletion(s)}}return{valuePrefix:o?Dt(t.state.doc,o,!0,!1):""}}addSchemaValueCompletions(e,t,i){typeof e=="object"&&(this.addEnumValueCompletions(e,i),this.addDefaultValueCompletions(e,i),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)),Array.isArray(e.anyOf)&&e.anyOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)),Array.isArray(e.oneOf)&&e.oneOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)))}addDefaultValueCompletions(e,t,i=0){let s=!1;if(typeof e.default<"u"){let r=e.type,o=e.default;for(let a=i;a>0;a--)o=[o],r="array";const l=Object.assign(Object.assign({type:r==null?void 0:r.toString()},this.getAppliedValue(o)),{detail:"Default value"});t.add(l),s=!0}Array.isArray(e.examples)&&e.examples.forEach(r=>{let o=e.type,l=r;for(let a=i;a>0;a--)l=[l],o="array";t.add(Object.assign({type:o==null?void 0:o.toString()},this.getAppliedValue(l))),s=!0}),!s&&typeof e.items=="object"&&!Array.isArray(e.items)&&i<5&&this.addDefaultValueCompletions(e.items,t,i+1)}addEnumValueCompletions(e,t){var i,s;if(typeof e.const<"u"&&t.add(Object.assign(Object.assign({type:(i=e.type)===null||i===void 0?void 0:i.toString()},this.getAppliedValue(e.const)),{info:e.description})),Array.isArray(e.enum))for(let r=0,o=e.enum.length;r<o;r++){const l=e.enum[r];t.add(Object.assign(Object.assign({type:(s=e.type)===null||s===void 0?void 0:s.toString()},this.getAppliedValue(l)),{info:e.description}))}}addBooleanValueCompletion(e,t){t.add({type:"boolean",label:e?"true":"false"})}addNullValueCompletion(e){e.add({type:"null",label:"null"})}collectTypes(e,t){if(Array.isArray(e.enum)||typeof e.const<"u")return;const i=e.type;Array.isArray(i)?i.forEach(s=>t[s]=!0):i&&(t[i]=!0)}getSchemas(e,t){var i,s;const r=new Df(this.schema);let o=nf(t.state,t.pos,-1,this.mode),l=r.getSchema({pointer:o});return Ql(l)&&(l=(i=l.data)===null||i===void 0?void 0:i.schema),(!l||l.name==="UnknownPropertyError"||l.enum||l.type==="undefined")&&(o=o.replace(/\/[^/]*$/,"/"),l=r.getSchema({pointer:o})),yt.log("xxx","pointer..",JSON.stringify(o)),(!o||o==="/")&&(l=(s=this.expandSchemaProperty(e,e))!==null&&s!==void 0?s:e),l?Array.isArray(l.allOf)?[l,...l.allOf.map(a=>this.expandSchemaProperty(a,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(a=>this.expandSchemaProperty(a,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(a=>this.expandSchemaProperty(a,e))]:[l]:[]}expandSchemaProperty(e,t){if(typeof e=="object"&&e.$ref){const i=this.getReferenceSchema(t,e.$ref);if(typeof i=="object"){const s=Object.assign(Object.assign({},e),i);return Reflect.deleteProperty(s,"$ref"),s}}return e}getReferenceSchema(e,t){const i=t.split("/");let s=e;return i.forEach(r=>{if(r){if(r==="#"){s=e;return}typeof s=="object"&&(s=s[r])}}),s}getAppliedValue(e){const t=wn(JSON.stringify(e));switch(this.mode){case $.JSON5:return{label:t,apply:Xy(JSON.stringify(e))};case $.YAML:return{label:t,apply:t};default:return{label:t,apply:JSON.stringify(e)}}}getValueFromLabel(e){return JSON.parse(e)}extendedRegExp(e){let t="";e.startsWith("(?i)")&&(e=e.substring(4),t="i");try{return new RegExp(e,t+"u")}catch{try{return new RegExp(e,t)}catch{return}}}}function Fb(n={}){const e=new nb(n);return function(i){return e.doComplete(i)}}const Ri=(n,e)=>{const t=n.length>2;let i=n.map((s,r)=>{const o="`"+(e?e(s):s)+"`";return r===n.length-1?"or "+o:o});return t?i.join(", "):i.join(" ")};function of(n){let e=null;try{e=JSON.parse(n.doc.toString())}catch{}const t=so(n,$.JSON);return{data:e,pointers:t}}function Ye(n,e,t=[]){const i=document.createElement(n);return Object.entries(e).forEach(([s,r])=>{if(s==="text"){i.innerText=r;return}if(s==="inner"){i.innerHTML=r;return}i.setAttribute(s,r)}),t.forEach(s=>i.appendChild(s)),i}function sb(n){let e=null;try{e=Ef.parse(n.doc.toString())}catch{}const t=so(n,$.YAML);return{data:e,pointers:t}}function rb(n){let e=null;try{e=Pf.parse(n.doc.toString())}catch{}const t=so(n,$.JSON5);return{data:e,pointers:t}}const ob=n=>{switch(n){case $.JSON:return of;case $.JSON5:return rb;case $.YAML:return sb}},lb=n=>{var e,t,i;return!((e=n==null?void 0:n.data)===null||e===void 0)&&e.pointer&&((t=n==null?void 0:n.data)===null||t===void 0?void 0:t.pointer)!=="#"?n.data.pointer.slice(1):!((i=n==null?void 0:n.data)===null||i===void 0)&&i.property?`/${n.data.property}`:""},Vb=n=>n.startState.field(jn)!==n.state.field(jn);function Hb(n){const e=new hb(n);return t=>e.doValidation(t)}const ab=["NoAdditionalPropertiesError","RequiredPropertyError","InvalidPropertyNameError","ForbiddenPropertyError","UndefinedValueError"];class hb{constructor(e){var t,i,s,r;this.options=e,this.schema=null,this.mode=$.JSON,this.parser=of,this.rewriteError=o=>{var l,a,c,h,f;const u=o==null?void 0:o.data,d=u==null?void 0:u.errors;return o.code==="one-of-error"&&(d!=null&&d.length)?`Expected one of ${Ri(d,g=>g.data.expected)}`:o.code==="type-error"?`Expected \`${!((l=o==null?void 0:o.data)===null||l===void 0)&&l.expected&&Array.isArray((a=o==null?void 0:o.data)===null||a===void 0?void 0:a.expected)?Ri((c=o==null?void 0:o.data)===null||c===void 0?void 0:c.expected):(h=o==null?void 0:o.data)===null||h===void 0?void 0:h.expected}\` but received \`${(f=o==null?void 0:o.data)===null||f===void 0?void 0:f.received}\``:o.message.replaceAll("in `#` ","").replaceAll("at `#`","").replaceAll("/",".").replaceAll("#.","")},this.mode=(i=(t=this.options)===null||t===void 0?void 0:t.mode)!==null&&i!==void 0?i:$.JSON,this.parser=(r=(s=this.options)===null||s===void 0?void 0:s.jsonParser)!==null&&r!==void 0?r:ob(this.mode)}get schemaTitle(){var e,t,i;return(i=(t=(e=this.schema)===null||e===void 0?void 0:e.getSchema())===null||t===void 0?void 0:t.title)!==null&&i!==void 0?i:"json-schema"}doValidation(e){const t=ro(e.state);if(!t)return[];if(this.schema=new Zl(t),!this.schema)return[];const i=e.state.doc.toString();if(!(i!=null&&i.length))return[];const s=this.parser(e.state);let r=[];try{r=this.schema.validate(s.data)}catch{}return yt.log("xxx","validation errors",r,s.data),r.length?r.reduce((o,l)=>{const a=()=>{const f=this.rewriteError(l);o.push({from:0,to:0,message:f,severity:"error",source:this.schemaTitle,renderMessage:()=>{const u=Ye("div",{});return u.innerHTML=Wt(f),u}})},c=lb(l),h=s.pointers.get(c);if(l.name==="MaxPropertiesError"||l.name==="MinPropertiesError")a();else if(h){const f=ab.includes(l.name),u=this.rewriteError(l),d=f?h.keyFrom:h.valueFrom,p=f?h.keyTo:h.valueTo;p!==void 0&&d!==void 0&&o.push({from:d,to:p,message:u,renderMessage:()=>{const g=Ye("div",{});return g.innerHTML=Wt(u),g},severity:"error",source:this.schemaTitle})}else a();return o},[]):[]}}function Wb(n){const e=new cb(n);return async function(i,s,r){return e.doHover(i,s,r)}}function Kl(n){if(n.type)return n.$ref?`${n.$ref} (${n.type})`:n.type;if(n.$ref)return`${n.$ref}`}function Ds(n,e,t){return`${e}: ${Ri(n[e].map(i=>{try{const{data:s}=t.resolveRef({data:i,pointer:i.$ref});return Kl(s||i)}catch{return i.type}}))}`}class cb{constructor(e){var t,i;this.opts=e,this.schema=null,this.mode=$.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=(i=(t=this.opts)===null||t===void 0?void 0:t.mode)!==null&&i!==void 0?i:$.JSON}getDataForCursor(e,t,i){const s=ro(e.state);if(!s)return null;this.schema=new Zl(s);const r=nf(e.state,t,i,this.mode);let o;try{o=this.opts.parser(e.state.doc.toString())}catch{}if(!r)return null;let l=this.schema.getSchema({pointer:r,data:o,withSchemaWarning:!0});return Ql(l)&&(l!=null&&l.data.schema.$ref?l=this.schema.resolveRef(l):l=l==null?void 0:l.data.schema),{schema:l,pointer:r}}formatMessage(e){const{message:t,typeInfo:i}=e;return t?Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--description",inner:Wt(t,!1)}),Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("div",{class:"cm6-json-schema-hover--code",inner:Wt(i,!1)})])]):Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("code",{class:"cm6-json-schema-hover--code",inner:Wt(i,!1)})])])}getHoverTexts(e,t){let i="",s=null;const{schema:r}=e;return r.oneOf&&(i=Ds(r,"oneOf",t)),r.anyOf&&(i=Ds(r,"anyOf",t)),r.allOf&&(i=Ds(r,"allOf",t)),r.type&&(i=Array.isArray(r.type)?Ri(r.type):r.type),r.$ref&&(i=` Reference: ${r.$ref}`),r.enum&&(i=`\`enum\`: ${Ri(r.enum)}`),r.format&&(i+=`\`format\`: ${r.format}`),r.pattern&&(i+=`\`pattern\`: ${r.pattern}`),r.description&&(s=r.description),{message:s,typeInfo:i}}async doHover(e,t,i){var s,r,o,l;const a=t,c=t;try{const h=this.getDataForCursor(e,t,i);if(yt.log("cursorData",h),!(h!=null&&h.schema))return null;const u=((r=(s=this.opts)===null||s===void 0?void 0:s.getHoverTexts)!==null&&r!==void 0?r:this.getHoverTexts)(h,this.schema),p=((l=(o=this.opts)===null||o===void 0?void 0:o.formatHover)!==null&&l!==void 0?l:this.formatMessage)(u);return{pos:a,end:c,arrow:!0,above:!0,create:g=>({dom:p})}}catch{return null}}}const _l=new ea,lf=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function hn(n){return(e,t,i)=>{if(i)return!1;let s=e.node.getChild("VariableName");return s&&t(s,n),!0}}const fb={FunctionDefinition:hn("function"),ClassDefinition:hn("class"),ForStatement(n,e,t){if(t){for(let i=n.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")e(i,"variable");else if(i.name=="in")break}},ImportStatement(n,e){var t,i;let{node:s}=n,r=((t=s.firstChild)===null||t===void 0?void 0:t.name)=="from";for(let o=s.getChild("import");o;o=o.nextSibling)o.name=="VariableName"&&((i=o.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&e(o,r?"variable":"namespace")},AssignStatement(n,e){for(let t=n.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(n,e){for(let t=null,i=n.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(i,"variable"),t=i},CapturePattern:hn("variable"),AsPattern:hn("variable"),__proto__:null};function af(n,e){let t=_l.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(Cr.IncludeAnonymous).iterate(o=>{if(o.name){let l=fb[o.name];if(l&&l(o,r,s)||!s&&lf.has(o.name))return!1;s=!1}else if(o.to-o.from>8192){for(let l of af(n,o.node))i.push(l);return!1}}),_l.set(e,i),i}const Jl=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,hf=["String","FormatString","Comment","PropertyName"];function ub(n){let e=j(n.state).resolveInner(n.pos,-1);if(hf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Jl.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)lf.has(s.name)&&(i=i.concat(af(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Jl}}const db=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(n=>({label:n,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(n=>({label:n,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(n=>({label:n,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(n=>({label:n,type:"function"}))),pb=[q("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),q("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),q("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),q("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),q(`if \${}:
9
+ --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,lr),Vd={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ds=null;function Hd(){var n;if(ds==null&&typeof document<"u"&&document.body){let e=document.body.style;ds=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return ds||!1}const yn=A.define({combine(n){let e=_e(n,{render:null,specialChars:Fd,addSpecialChars:null});return(e.replaceTabs=!Hd())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,lr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,lr)),e}});function Wd(n={}){return[yn.of(n),$d()]}let Qo=null;function $d(){return Qo||(Qo=_.fromClass(class{constructor(n){this.view=n,this.decorations=M.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(yn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Nd({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=ie(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Yt(o.text,l,i-o.from);return M.replace({widget:new Kd((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=M.replace({widget:new qd(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(yn);n.startState.facet(yn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const zd="•";function jd(n){return n>=32?zd:n==10?"␤":String.fromCharCode(9216+n)}class qd extends Ne{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=jd(this.code),i=e.state.phrase("Control character")+" "+(Vd[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Kd extends Ne{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function _d(){return Ud}const Jd=M.line({class:"cm-activeLine"}),Ud=_.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Jd.range(s.from)),e=s.from)}return M.set(t)}},{decorations:n=>n.decorations});class Yd extends Ne{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?zt(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),s=_n(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function Gd(n){return _.fromClass(class{constructor(e){this.view=e,this.placeholder=n?M.set([M.widget({widget:new Yd(n),side:1}).range(0)]):M.none}get decorations(){return this.view.state.doc.length?M.none:this.placeholder}},{decorations:e=>e.decorations})}const ar=2e3;function Xd(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>ar||t.off>ar||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let c=n.doc.line(a);c.length<=l&&r.push(v.range(c.from+o,c.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let c=n.doc.line(a),h=$s(c.text,o,n.tabSize,!0);if(h<0)r.push(v.cursor(c.to));else{let f=$s(c.text,l,n.tabSize);r.push(v.range(c.from+h,c.from+f))}}}return r}function Qd(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Zo(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>ar?-1:s==i.length?Qd(n,e.clientX):Yt(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Zd(n,e){let t=Zo(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Zo(n,s);if(!l)return i;let a=Xd(n.state,t,l);return a.length?o?v.create(a.concat(i.ranges)):v.create(a):i}}:null}function ep(n){let e=t=>t.altKey&&t.button==0;return w.mouseSelectionStyle.of((t,i)=>e(i)?Zd(t,i):null)}const tp={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},ip={style:"cursor: crosshair"};function np(n={}){let[e,t]=tp[n.key||"Alt"],i=_.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,w.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?ip:null})]}const ni="-10000px";class Sh{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let c=r[a],h=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==c.create&&(h=f)}if(h<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let f=o[a]=this.tooltipViews[h];l&&(l[a]=t[h]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,c)=>t[c]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function sp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const ps=A.define({combine:n=>{var e,t,i;return{position:C.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||sp}}}),el=new WeakMap,Ir=_.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(ps);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Sh(n,Nr,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(ps);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ni,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(C.gecko)i=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==ni&&s.style.left=="0px"){let r=s.getBoundingClientRect();i=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}}if(i||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((s,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(ps).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:h}=c,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){h.style.top=ni;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,y=(e=el.get(c))!==null&&e!==void 0?e:u.bottom-u.top,b=c.offset||op,x=this.view.textDirection==W.LTR,T=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,f.left-g+(d?14:0)-b.x),i.right-g),S=this.above[l];!a.strictSide&&(S?f.top-(u.bottom-u.top)-b.y<i.top:f.bottom+(u.bottom-u.top)+b.y>i.bottom)&&S==i.bottom-f.bottom>f.top-i.top&&(S=this.above[l]=!S);let k=(S?f.top-i.top:i.bottom-f.bottom)-p;if(k<y&&c.resize!==!1){if(k<this.view.defaultLineHeight){h.style.top=ni;continue}el.set(c,y),h.style.height=(y=k)/r+"px"}else h.style.height&&(h.style.height="");let O=S?f.top-y-p-b.y:f.bottom+p+b.y,L=T+g;if(c.overlap!==!0)for(let K of o)K.left<L&&K.right>T&&K.top<O+y&&K.bottom>O&&(O=S?K.top-y-2-p:K.bottom+p+2);if(this.position=="absolute"?(h.style.top=(O-n.parent.top)/r+"px",h.style.left=(T-n.parent.left)/s+"px"):(h.style.top=O/r+"px",h.style.left=T/s+"px"),d){let K=f.left+(x?b.x:-b.x)-(T+14-7);d.style.left=K/s+"px"}c.overlap!==!0&&o.push({left:T,top:O,right:L,bottom:O+y}),h.classList.toggle("cm-tooltip-above",S),h.classList.toggle("cm-tooltip-below",!S),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=ni}},{eventObservers:{scroll(){this.maybeMeasure()}}}),rp=w.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),op={x:0,y:0},Nr=A.define({enables:[Ir,rp]}),Dn=A.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Un{static create(e){return new Un(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Sh(e,Dn,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const lp=Nr.compute([Dn],n=>{let e=n.facet(Dn);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Un.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class ap{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let s,r=1;if(i instanceof st)s=i.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let l=e.coordsAtPos(s);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),c=a&&a.dir==W.RTL?-1:1;r=t.x<l.left?-c:c}let o=this.source(e,s,r);if(o!=null&&o.then){let l=this.pending={pos:s};o.then(a=>{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>ae(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Ir),t=e?e.manager.tooltips.findIndex(i=>i.create==Un.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!hp(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!cp(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const en=4;function hp(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-en&&e.clientX<=t.right+en&&e.clientY>=t.top-en&&e.clientY<=t.bottom+en}function cp(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=n.posAtCoords({x:i,y:s},!1);return a>=e&&a<=t}function fp(n,e={}){let t=D.define(),i=X.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,ee.TrackDel);if(a!=null){let c=Object.assign(Object.create(null),l);c.pos=a,c.end!=null&&(c.end=r.changes.mapPos(c.end)),o.push(c)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(up)&&(s=[]);return s},provide:s=>Dn.from(s)});return[i,_.define(s=>new ap(s,n,i,t,e.hoverTime||300)),lp]}function kh(n,e){let t=n.plugin(Ir);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const up=D.define(),tl=A.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ci(n,e){let t=n.plugin(Ch),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Ch=_.fromClass(class{constructor(n){this.input=n.state.facet(Ai),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(tl);this.top=new tn(n,!0,e.topContainer),this.bottom=new tn(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(tl);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new tn(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new tn(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ai);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let c=this.specs.indexOf(a),h;c<0?(h=a(n.view),l.push(h)):(h=this.panels[c],h.update&&h.update(n)),s.push(h),(h.top?r:o).push(h)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>w.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class tn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=il(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=il(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function il(n){let e=n.nextSibling;return n.remove(),e}const Ai=A.define({enables:Ch});class Ze extends ht{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ze.prototype.elementClass="";Ze.prototype.toDOM=void 0;Ze.prototype.mapMode=ee.TrackBefore;Ze.prototype.startSide=Ze.prototype.endSide=-1;Ze.prototype.point=!0;const bn=A.define(),dp={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>R.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},gi=A.define();function pp(n){return[Ah(),gi.of(Object.assign(Object.assign({},dp),n))]}const nl=A.define({combine:n=>n.some(e=>e)});function Ah(n){return[mp]}const mp=_.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(gi).map(e=>new rl(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(nl),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(nl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=R.iter(this.view.state.facet(bn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new gp(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==he.Text&&o){hr(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==he.Text){hr(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(gi),t=n.state.facet(gi),i=n.docChanged||n.heightChanged||n.viewportChanged||!R.eq(n.startState.facet(bn),n.state.facet(bn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new rl(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>w.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==W.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function sl(n){return Array.isArray(n)?n:[n]}function hr(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class gp{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=R.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Mh(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];hr(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class rl{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=sl(t.markers(e)),t.initialSpacer&&(this.spacer=new Mh(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=sl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!R.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mh{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),yp(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,c=!1;if(a){let h=a.elementClass;h&&(i+=" "+h);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,c=!0;break}}else l=this.markers.length;for(;o<l;){let h=this.markers[o++];if(h.toDOM){h.destroy(s);let f=s.nextSibling;s.remove(),s=f}}if(!a)break;a.toDOM&&(c?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),c&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function yp(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const bp=A.define(),Pt=A.define({combine(n){return _e(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let r=i[s],o=t[s];i[s]=r?(l,a,c)=>r(l,a,c)||o(l,a,c):o}return i}})}});class ms extends Ze{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function gs(n,e){return n.state.facet(Pt).formatNumber(e,n.state)}const vp=gi.compute([Pt],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(bp)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new ms(gs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Pt)!=e.state.facet(Pt),initialSpacer(e){return new ms(gs(e,ol(e.state.doc.lines)))},updateSpacer(e,t){let i=gs(t.view,ol(t.view.state.doc.lines));return i==e.number?e:new ms(i)},domEventHandlers:n.facet(Pt).domEventHandlers}));function xp(n={}){return[Pt.of(n),Ah(),vp]}function ol(n){let e=9;for(;e<n;)e=e*10+9;return e}const wp=new class extends Ze{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Sp=bn.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(wp.range(s)))}return R.of(e)});function kp(){return Sp}var ys;const Bt=new Ae;function Th(n){return A.define({combine:n?e=>e.concat(n):void 0})}const Fr=new Ae;class Be{constructor(e,t,i=[],s=""){this.data=e,this.name=s,P.prototype.hasOwnProperty("tree")||Object.defineProperty(P.prototype,"tree",{get(){return j(this)}}),this.parser=t,this.extension=[ut.of(this),P.languageData.of((r,o,l)=>{let a=ll(r,o,l),c=a.type.prop(Bt);if(!c)return[];let h=r.facet(c),f=a.type.prop(Fr);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return ll(e,t,i).type.prop(Bt)==this.data}findRegions(e){let t=e.facet(ut);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Bt)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(Ae.mounted);if(l){if(l.tree.prop(Bt)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let c=r.children[a];c instanceof Et&&s(c,r.positions[a]+o)}};return s(j(e),0),i}get allowsNesting(){return!0}}Be.setState=D.define();function ll(n,e,t){let i=n.facet(ut),s=j(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(e,t,Cr.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Kt extends Be{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Th(e.languageData);return new Kt(t,e.parser.configure({props:[Bt.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Kt(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function j(n){let e=n.field(Be.state,!1);return e?e.tree:Et.empty}class Cp{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let si=null;class En{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new En(e,t,[],Et.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Cp(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Et.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(cn.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(cn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=si;si=this;try{return e()}finally{si=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=al(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,h,f,u)=>a.push({fromA:c,toA:h,fromB:f,toB:u})),i=cn.applyChanges(i,a),s=Et.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);h<f&&l.push({from:h,to:f})}}}return new En(this.parser,t,i,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<e.to&&r>e.from&&(this.fragments=al(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Sf{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=si;if(a){for(let c of s)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Et(kr.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return si}}function al(n,e,t){return cn.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class _t{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new _t(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=En.create(e.facet(ut).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new _t(i)}}Be.state=X.define({create:_t.init,update(n,e){for(let t of e.effects)if(t.is(Be.setState))return t.value;return e.startState.facet(ut)!=e.state.facet(ut)?_t.init(e.state):n.apply(e)}});let Oh=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Oh=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const bs=typeof navigator<"u"&&(!((ys=navigator.scheduling)===null||ys===void 0)&&ys.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ap=_.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Be.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Be.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Oh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Be.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!bs?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>bs&&bs()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Be.setState.of(new _t(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ae(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ut=A.define({combine(n){return n.length?n[0]:null},enables:n=>[Be.state,Ap,w.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Vr{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Mp=A.define(),Xt=A.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Pn(n){let e=n.facet(Xt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Mi(n,e){let t="",i=n.tabSize,s=n.facet(Xt)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Hr(n,e){n instanceof P&&(n=new Yn(n));for(let i of n.state.facet(Mp)){let s=i(n,e);if(s!==void 0)return s}let t=j(n.state);return t.length>=e?Tp(n,t,e):null}class Yn{constructor(e,t={}){this.state=e,this.options=t,this.unit=Pn(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Yt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Gn=new Ae;function Tp(n,e,t){let i=e.resolveStack(t),s=i.node.enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o!=i.node;o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Dh(i,n,t)}function Dh(n,e,t){for(let i=n;i;i=i.next){let s=Dp(i.node);if(s)return s(Wr.create(e,t,i))}return 0}function Op(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Dp(n){let e=n.type.prop(Gn);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Ae.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Eh(o,!0,1,void 0,r&&!Op(o)?s.from:void 0)}return n.parent==null?Ep:null}function Ep(){return 0}class Wr extends Yn{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Wr(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Pp(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Dh(this.context.next,this.base,this.pos)}}function Pp(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Bp(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function vn({closing:n,align:e=!0,units:t=1}){return i=>Eh(i,e,t,n)}function Eh(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?Bp(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Rp=n=>n.baseIndent;function yi({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Lp=200;function Ip(){return P.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+Lp)return n;let r=t.sliceString(s.from,i);if(!e.some(c=>c.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==l)continue;l=h.from;let f=Hr(o,h.from);if(f==null)continue;let u=/^\s*/.exec(h.text)[0],d=Mi(o,f);u!=d&&a.push({from:h.from,to:h.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const Np=A.define(),Xn=new Ae;function $r(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function Fp(n,e,t){let i=j(n);if(i.length<t)return null;let s=i.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(Xn);if(a&&(l.to<i.length-50||i.length==n.doc.length||!Vp(l))){let c=a(l,n);c&&c.from<=t&&c.from>=e&&c.to>t&&(r=c)}}return r}function Vp(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Bn(n,e,t){for(let i of n.facet(Np)){let s=i(n,e,t);if(s)return s}return Fp(n,e,t)}function Ph(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Qn=D.define({map:Ph}),Fi=D.define({map:Ph});function Bh(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Ct=X.define({create(){return M.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(Qn)&&!Hp(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(Ih),s=i?M.replace({widget:new _p(i(e.state,t.value))}):hl;n=n.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Fi)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{s<i&&r>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>w.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],s=n[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(hl.range(i,s))}return M.set(e,!0)}});function Rn(n,e,t){var i;let s=null;return(i=n.field(Ct,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Hp(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Rh(n,e){return n.field(Ct,!1)?e:e.concat(D.appendConfig.of(Nh()))}const Wp=n=>{for(let e of Bh(n)){let t=Bn(n.state,e.from,e.to);if(t)return n.dispatch({effects:Rh(n.state,[Qn.of(t),Lh(n,t)])}),!0}return!1},$p=n=>{if(!n.state.field(Ct,!1))return!1;let e=[];for(let t of Bh(n)){let i=Rn(n.state,t.from,t.to);i&&e.push(Fi.of(i),Lh(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Lh(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return w.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const zp=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let s=n.lineBlockAt(i),r=Bn(e,s.from,s.to);r&&t.push(Qn.of(r)),i=(r?n.lineBlockAt(r.to):s).to+1}return t.length&&n.dispatch({effects:Rh(n.state,t)}),!!t.length},jp=n=>{let e=n.state.field(Ct,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(Fi.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},qp=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Wp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:$p},{key:"Ctrl-Alt-[",run:zp},{key:"Ctrl-Alt-]",run:jp}],Kp={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ih=A.define({combine(n){return _e(n,Kp)}});function Nh(n){return[Ct,Yp]}function Fh(n,e){let{state:t}=n,i=t.facet(Ih),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=Rn(n.state,l.from,l.to);a&&n.dispatch({effects:Fi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const hl=M.replace({widget:new class extends Ne{toDOM(n){return Fh(n,null)}}});class _p extends Ne{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Fh(e,this.value)}}const Jp={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class vs extends Ze{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Up(n={}){let e=Object.assign(Object.assign({},Jp),n),t=new vs(e,!0),i=new vs(e,!1),s=_.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ut)!=o.state.facet(ut)||o.startState.field(Ct,!1)!=o.state.field(Ct,!1)||j(o.startState)!=j(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ct;for(let a of o.viewportLineBlocks){let c=Rn(o.state,a.from,a.to)?i:Bn(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:r}=e;return[s,pp({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||R.empty},initialSpacer(){return new vs(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let c=Rn(o.state,l.from,l.to);if(c)return o.dispatch({effects:Fi.of(c)}),!0;let h=Bn(o.state,l.from,l.to);return h?(o.dispatch({effects:Qn.of(h)}),!0):!1}})}),Nh()]}const Yp=w.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 At{constructor(e,t){this.specs=e;let i;function s(l){let a=at.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Be?l=>l.prop(Bt)==o.data:o?l=>l==o:void 0,this.style=wf(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new at(i):null,this.themeType=t.themeType}static define(e,t){return new At(e,t||{})}}const cr=A.define(),Vh=A.define({combine(n){return n.length?[n[0]]:null}});function xs(n){let e=n.facet(cr);return e.length?e:n.facet(Vh)}function Zn(n,e){let t=[Xp],i;return n instanceof At&&(n.module&&t.push(w.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Vh.of(n)):i?t.push(cr.computeN([w.darkTheme],s=>s.facet(w.darkTheme)==(i=="dark")?[n]:[])):t.push(cr.of(n)),t}class Gp{constructor(e){this.markCache=Object.create(null),this.tree=j(e.state),this.decorations=this.buildDeco(e,xs(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=j(e.state),i=xs(e.state),s=i!=xs(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return M.none;let i=new ct;for(let{from:s,to:r}of e.visibleRanges)kf(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=M.mark({class:a})))},s,r);return i.finish()}}const Xp=dt.high(_.fromClass(Gp,{decorations:n=>n.decorations})),Qp=At.define([{tag:m.meta,color:"#404740"},{tag:m.link,textDecoration:"underline"},{tag:m.heading,textDecoration:"underline",fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.keyword,color:"#708"},{tag:[m.atom,m.bool,m.url,m.contentSeparator,m.labelName],color:"#219"},{tag:[m.literal,m.inserted],color:"#164"},{tag:[m.string,m.deleted],color:"#a11"},{tag:[m.regexp,m.escape,m.special(m.string)],color:"#e40"},{tag:m.definition(m.variableName),color:"#00f"},{tag:m.local(m.variableName),color:"#30a"},{tag:[m.typeName,m.namespace],color:"#085"},{tag:m.className,color:"#167"},{tag:[m.special(m.variableName),m.macroName],color:"#256"},{tag:m.definition(m.propertyName),color:"#00c"},{tag:m.comment,color:"#940"},{tag:m.invalid,color:"#f00"}]),Zp=w.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Hh=1e4,Wh="()[]{}",$h=A.define({combine(n){return _e(n,{afterCursor:!0,brackets:Wh,maxScanDistance:Hh,renderMatch:im})}}),em=M.mark({class:"cm-matchingBracket"}),tm=M.mark({class:"cm-nonmatchingBracket"});function im(n){let e=[],t=n.matched?em:tm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const nm=X.define({create(){return M.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet($h);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=ze(e.state,s.head,-1,i)||s.head>0&&ze(e.state,s.head-1,1,i)||i.afterCursor&&(ze(e.state,s.head,1,i)||s.head<e.state.doc.length&&ze(e.state,s.head+1,-1,i));r&&(t=t.concat(i.renderMatch(r,e.state)))}return M.set(t,!0)},provide:n=>w.decorations.from(n)}),sm=[nm,Zp];function rm(n={}){return[$h.of(n),sm]}const om=new Ae;function fr(n,e,t){let i=n.prop(e<0?Ae.openedBy:Ae.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function ur(n){let e=n.type.prop(om);return e?e(n.node):n}function ze(n,e,t,i={}){let s=i.maxScanDistance||Hh,r=i.brackets||Wh,o=j(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=fr(a.type,t,r);if(c&&a.from<a.to){let h=ur(a);if(h&&(t>0?e>=h.from&&e<h.to:e>h.from&&e<=h.to))return lm(n,e,t,a,h,c,r)}}return am(n,e,t,o,l.type,s,r)}function lm(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},c=0,h=l==null?void 0:l.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from<h.to){let f=ur(h);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(fr(h.type,t,o))c++;else if(fr(h.type,-t,o)){if(c==0){let f=ur(h);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(t<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}function am(n,e,t,i,s,r,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!h.next().done&&u<=r;){let d=h.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,y=t>0?d.length:-1;g!=y;g+=t){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return h.done?{start:c,matched:!1}:null}const hm=Object.create(null),cl=[kr.none],fl=[],ul=Object.create(null),cm=Object.create(null);for(let[n,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"]])cm[n]=fm(hm,e);function ws(n,e){fl.indexOf(n)>-1||(fl.push(n),console.warn(e))}function fm(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let h=n[c]||m[c];h?typeof h=="function"?a.length?a=a.map(h):ws(c,`Modifier ${c} used at start of tag`):a.length?ws(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:ws(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=ul[s];if(r)return r.id;let o=ul[s]=kr.define({id:cl.length,name:i,props:[xf({[i]:t})]});return cl.push(o),o.id}W.RTL,W.LTR;const Pb=()=>n=>{try{JSON.parse(n.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=um(e,n.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function um(n,e){let t;return(t=n.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=n.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const dm=Kt.define({name:"json",parser:Cf.configure({props:[Gn.add({Object:yi({except:/^\s*\}/}),Array:yi({except:/^\s*\]/})}),Xn.add({"Object Array":$r})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Bb(){return new Vr(dm)}class pm{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class gt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(je).markerFilter;r&&(s=r(s,i));let o=M.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?M.widget({widget:new Cm(l),diagnostic:l}).range(l.from):M.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new gt(o,t,Jt(o))}}function Jt(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new pm(s,r,o.diagnostic),!1}),i}function mm(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(je).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(zr))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function zh(n,e){return n.field(ve,!1)?e:e.concat(D.appendConfig.of(_h))}function gm(n,e){return{effects:zh(n,[zr.of(e)])}}const zr=D.define(),jr=D.define(),jh=D.define(),ve=X.define({create(){return new gt(M.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Jt(t,n.selected.diagnostic,r)||Jt(t,null,r)}!t.size&&s&&e.state.facet(je).autoPanel&&(s=null),n=new gt(t,s,i)}for(let t of e.effects)if(t.is(zr)){let i=e.state.facet(je).autoPanel?t.value.length?Ti.open:null:n.panel;n=gt.init(t.value,i,e.state)}else t.is(jr)?n=new gt(n.diagnostics,t.value?Ti.open:null,n.selected):t.is(jh)&&(n=new gt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ai.from(n,e=>e.panel),w.decorations.from(n,e=>e.diagnostics)]}),ym=M.mark({class:"cm-lintRange cm-lintRange-active"});function bm(n,e,t){let{diagnostics:i}=n.state.field(ve),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0))&&(s.push(h.diagnostic),r=Math.min(a,r),o=Math.max(c,o))});let l=n.state.facet(je).tooltipFilter;return l&&(s=l(s,n.state)),s.length?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:vm(n,s)}}}:null}function vm(n,e){return V("ul",{class:"cm-tooltip-lint"},e.map(t=>Kh(n,t,!1)))}const xm=n=>{let e=n.state.field(ve,!1);(!e||!e.panel)&&n.dispatch({effects:zh(n.state,[jr.of(!0)])});let t=Ci(n,Ti.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},dl=n=>{let e=n.state.field(ve,!1);return!e||!e.panel?!1:(n.dispatch({effects:jr.of(!1)}),!0)},wm=n=>{let e=n.state.field(ve,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Sm=[{key:"Mod-Shift-m",run:xm,preventDefault:!0},{key:"F8",run:wm}],km=_.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(je);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(je);t.length&&Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let s=i.reduce((r,o)=>r.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(gm(this.view.state,s))},i=>{ae(this.view.state,i)})}}update(n){let e=n.state.facet(je);(n.docChanged||e!=n.startState.facet(je)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),je=A.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},_e(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function Rb(n,e={}){return[je.of({source:n,config:e}),km,_h]}function qh(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Kh(n,e,t){var i;let s=t?qh(e.actions):[];return V("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},V("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=Jt(n.state.field(ve).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,f=h<0?c:[c.slice(0,h),V("u",c.slice(h,h+1)),c.slice(h+1)];return V("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&V("div",{class:"cm-diagnosticSource"},e.source))}class Cm extends Ne{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return V("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class pl{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Kh(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ti{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)dl(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=qh(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Jt(this.view.state.field(ve).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=V("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=V("div",{class:"cm-panel-lint"},this.list,V("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>dl(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ve).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ve),i=0,s=!1,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let c=-1,h;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){c=f;break}c<0?(h=new pl(this.view,a.diagnostic),this.items.splice(i,0,h),s=!0):(h=this.items[c],c>i&&(this.items.splice(i,c-i),s=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),r=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new pl(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ve),i=Jt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:jh.of(i)})}static open(e){return new Ti(e)}}function Am(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function nn(n){return Am(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Mm=w.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:nn("#d11")},".cm-lintRange-warning":{backgroundImage:nn("orange")},".cm-lintRange-info":{backgroundImage:nn("#999")},".cm-lintRange-hint":{backgroundImage:nn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),_h=[ve,w.decorations.compute([ve],n=>{let{selected:e,panel:t}=n.field(ve);return!e||!t||e.from==e.to?M.none:M.set([ym.range(e.from,e.to)])}),fp(bm,{hideOn:mm}),Mm];var Jh=n=>{var{theme:e,settings:t={},styles:i=[]}=n,s={".cm-gutters":{}},r={};t.background&&(r.backgroundColor=t.background),t.backgroundImage&&(r.backgroundImage=t.backgroundImage),t.foreground&&(r.color=t.foreground),t.fontSize&&(r.fontSize=t.fontSize),(t.background||t.foreground)&&(s["&"]=r),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var o={};t.gutterActiveForeground&&(o.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},o.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=o,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var l=w.theme(s,{dark:e==="dark"}),a=At.define(i),c=[l,Zn(a)];return c},Tm={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},Om=[{tag:[m.standard(m.tagName),m.tagName],color:"#116329"},{tag:[m.comment,m.bracket],color:"#6a737d"},{tag:[m.className,m.propertyName],color:"#6f42c1"},{tag:[m.variableName,m.attributeName,m.number,m.operator],color:"#005cc5"},{tag:[m.keyword,m.typeName,m.typeOperator,m.typeName],color:"#d73a49"},{tag:[m.string,m.meta,m.regexp],color:"#032f62"},{tag:[m.name,m.quote],color:"#22863a"},{tag:[m.heading,m.strong],color:"#24292e",fontWeight:"bold"},{tag:[m.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[m.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#e36209"},{tag:[m.url,m.escape,m.regexp,m.link],color:"#032f62"},{tag:m.link,textDecoration:"underline"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.invalid,color:"#cb2431"}],Dm=n=>{var{theme:e="light",settings:t={},styles:i=[]}={};return Jh({theme:e,settings:qn({},Tm,t),styles:[...Om,...i]})},Lb=Dm(),Em={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},Pm=[{tag:[m.standard(m.tagName),m.tagName],color:"#7ee787"},{tag:[m.comment,m.bracket],color:"#8b949e"},{tag:[m.className,m.propertyName],color:"#d2a8ff"},{tag:[m.variableName,m.attributeName,m.number,m.operator],color:"#79c0ff"},{tag:[m.keyword,m.typeName,m.typeOperator,m.typeName],color:"#ff7b72"},{tag:[m.string,m.meta,m.regexp],color:"#a5d6ff"},{tag:[m.name,m.quote],color:"#7ee787"},{tag:[m.heading,m.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[m.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[m.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#ffab70"},{tag:m.link,textDecoration:"underline"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.invalid,color:"#f97583"}],Bm=n=>{var{theme:e="dark",settings:t={},styles:i=[]}={};return Jh({theme:e,settings:qn({},Em,t),styles:[...Pm,...i]})};Bm();var Rm=n=>{var{theme:e,settings:t={},styles:i=[]}=n,s={".cm-gutters":{}},r={};t.background&&(r.backgroundColor=t.background),t.backgroundImage&&(r.backgroundImage=t.backgroundImage),t.foreground&&(r.color=t.foreground),t.fontSize&&(r.fontSize=t.fontSize),(t.background||t.foreground)&&(s["&"]=r),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var o={};t.gutterActiveForeground&&(o.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},o.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=o,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var l=w.theme(s,{dark:e==="dark"}),a=At.define(i),c=[l,Zn(a)];return c},Lm={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},Im=[{tag:m.keyword,color:"#5e81ac"},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:"#88c0d0"},{tag:[m.variableName],color:"#8fbcbb"},{tag:[m.function(m.variableName)],color:"#8fbcbb"},{tag:[m.labelName],color:"#81a1c1"},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:"#5e81ac"},{tag:[m.definition(m.name),m.separator],color:"#a3be8c"},{tag:[m.brace],color:"#8fbcbb"},{tag:[m.annotation],color:"#d30102"},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:"#b48ead"},{tag:[m.typeName,m.className],color:"#ebcb8b"},{tag:[m.operator,m.operatorKeyword],color:"#a3be8c"},{tag:[m.tagName],color:"#b48ead"},{tag:[m.squareBracket],color:"#bf616a"},{tag:[m.angleBracket],color:"#d08770"},{tag:[m.attributeName],color:"#ebcb8b"},{tag:[m.regexp],color:"#5e81ac"},{tag:[m.quote],color:"#b48ead"},{tag:[m.string],color:"#a3be8c"},{tag:m.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:"#8fbcbb"},{tag:[m.meta],color:"#88c0d0"},{tag:[m.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[m.comment],color:"#4c566a",fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:"#5e81ac"},{tag:m.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:"#5e81ac"},{tag:m.special(m.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:m.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[m.heading5,m.heading6],color:"#5e81ac"},{tag:[m.atom,m.bool,m.special(m.variableName)],color:"#d08770"},{tag:[m.processingInstruction,m.inserted],color:"#8fbcbb"},{tag:[m.contentSeparator],color:"#ebcb8b"},{tag:m.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],Nm=n=>{var{theme:e="dark",settings:t={},styles:i=[]}={};return Rm({theme:e,settings:qn({},Lm,t),styles:[...Im,...i]})},Ib=Nm();const Fm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Kr(n.state,t.from);return i.line?Vm(n):i.block?Wm(n):!1};function qr(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const Vm=qr(jm,0),Hm=qr(Uh,0),Wm=qr((n,e)=>Uh(n,e,zm(e)),0);function Kr(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const ri=50;function $m(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-ri,i),o=n.sliceDoc(s,s+ri),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let h,f;s-i<=2*ri?h=f=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+ri),f=n.sliceDoc(s-ri,s));let u=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return h.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(h.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function zm(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function Uh(n,e,t=e.selection.ranges){let i=t.map(r=>Kr(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>$m(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:c,close:h}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:r}}return null}function jm(n,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:r,to:o}of t){let l=i.length,a=1e9,c=Kr(e,r).line;if(c){for(let h=r;h<=o;){let f=e.doc.lineAt(h);if(f.from>s&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}h=f.to+1}if(a<1e9)for(let h=l;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:c,empty:h,single:f}of i)(f||!h)&&r.push({from:l.from+c,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const dr=Ie.define(),qm=Ie.define(),Km=A.define(),Yh=A.define({combine(n){return _e(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Gh=X.define({create(){return qe.empty},update(n,e){let t=e.state.facet(Yh),i=e.annotation(dr);if(i){let a=me.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=Ln(h,h.length,t.minDepth,a):h=Zh(h,e.startState.selection),new qe(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(qm);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(Y.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=me.fromTransaction(e),o=e.annotation(Y.time),l=e.annotation(Y.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new qe(n.done.map(me.fromJSON),n.undone.map(me.fromJSON))}});function _m(n={}){return[Gh,Yh.of(n),w.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Xh:e.inputType=="historyRedo"?pr:null;return i?(e.preventDefault(),i(t)):!1}})]}function es(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Gh,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Xh=es(0,!1),pr=es(1,!1),Jm=es(0,!0),Um=es(1,!0);class me{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new me(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new me(e.changes&&Z.fromJSON(e.changes),[],e.mapped&&Ke.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let i=ke;for(let s of e.startState.facet(Km)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new me(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ke)}static selection(e){return new me(void 0,ke,void 0,void 0,e)}}function Ln(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function Ym(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],h=t[a++];l>=c&&o<=h&&(i=!0)}}),i}function Gm(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Qh(n,e){return n.length?e.length?n.concat(e):n:e}const ke=[],Xm=200;function Zh(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Xm));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Ln(n,n.length-1,1e9,t.setSelAfter(i)))}else return[me.selection([e])]}function Qm(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Ss(n,e){if(!n.length)return n;let t=n.length,i=ke;for(;t;){let s=Zm(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[me.selection(i)]:ke}function Zm(n,e,t){let i=Qh(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):ke,t);if(!n.changes)return me.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new me(s,D.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const eg=/^(input\.type|delete)($|\.)/;class qe{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new qe(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||eg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,Ym(l.changes,e.changes))||i=="input.type.compose")?o=Ln(o,o.length-1,s.minDepth,new me(e.changes.compose(l.changes),Qh(e.effects,l.effects),l.mapped,l.startSelection,ke)):o=Ln(o,o.length,s.minDepth,e),new qe(o,ke,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ke;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Gm(r[r.length-1],e)?this:new qe(Zh(this.done,e),this.undone,t,i)}addMapping(e){return new qe(Ss(this.done,e),Ss(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:dr.of({side:e,rest:Qm(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?ke:s.slice(0,s.length-1);return r.mapped&&(l=Ss(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:dr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}qe.empty=new qe(ke,ke);const tg=[{key:"Mod-z",run:Xh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:pr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:pr,preventDefault:!0},{key:"Mod-u",run:Jm,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Um,preventDefault:!0}];function Qt(n,e){return v.create(n.ranges.map(e),n.mainIndex)}function Je(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Fe({state:n,dispatch:e},t){let i=Qt(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Je(n,i)),!0)}function ts(n,e){return v.cursor(e?n.to:n.from)}function ec(n,e){return Fe(n,t=>t.empty?n.moveByChar(t,e):ts(t,e))}function le(n){return n.textDirectionAt(n.state.selection.main.head)==W.LTR}const tc=n=>ec(n,!le(n)),ic=n=>ec(n,le(n));function nc(n,e){return Fe(n,t=>t.empty?n.moveByGroup(t,e):ts(t,e))}const ig=n=>nc(n,!le(n)),ng=n=>nc(n,le(n));function sg(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function is(n,e,t){let i=j(n).resolveInner(e.head),s=t?Ae.closedBy:Ae.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;sg(n,c,s)?i=c:a=t?c.to:c.from}let r=i.type.prop(s),o,l;return r&&(o=t?ze(n,i.from,1):ze(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,v.cursor(l,t?-1:1)}const rg=n=>Fe(n,e=>is(n.state,e,!le(n))),og=n=>Fe(n,e=>is(n.state,e,le(n)));function sc(n,e){return Fe(n,t=>{if(!t.empty)return ts(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const rc=n=>sc(n,!1),oc=n=>sc(n,!0);function lc(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(w.scrollMargins)){let o=r(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function ac(n,e){let t=lc(n),{state:i}=n,s=Qt(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):ts(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(r=w.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Je(i,s),{effects:r}),!0}const ml=n=>ac(n,!1),mr=n=>ac(n,!0);function pt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=v.cursor(i.from+r))}return s}const lg=n=>Fe(n,e=>pt(n,e,!0)),ag=n=>Fe(n,e=>pt(n,e,!1)),hg=n=>Fe(n,e=>pt(n,e,!le(n))),cg=n=>Fe(n,e=>pt(n,e,le(n))),fg=n=>Fe(n,e=>v.cursor(n.lineBlockAt(e.head).from,1)),ug=n=>Fe(n,e=>v.cursor(n.lineBlockAt(e.head).to,-1));function dg(n,e,t){let i=!1,s=Qt(n.selection,r=>{let o=ze(n,r.head,-1)||ze(n,r.head,1)||r.head>0&&ze(n,r.head-1,1)||r.head<n.doc.length&&ze(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return v.cursor(l)});return i?(e(Je(n,s)),!0):!1}const pg=({state:n,dispatch:e})=>dg(n,e);function Te(n,e){let t=Qt(n.state.selection,i=>{let s=e(i);return v.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(Je(n.state,t)),!0)}function hc(n,e){return Te(n,t=>n.moveByChar(t,e))}const cc=n=>hc(n,!le(n)),fc=n=>hc(n,le(n));function uc(n,e){return Te(n,t=>n.moveByGroup(t,e))}const mg=n=>uc(n,!le(n)),gg=n=>uc(n,le(n)),yg=n=>Te(n,e=>is(n.state,e,!le(n))),bg=n=>Te(n,e=>is(n.state,e,le(n)));function dc(n,e){return Te(n,t=>n.moveVertically(t,e))}const pc=n=>dc(n,!1),mc=n=>dc(n,!0);function gc(n,e){return Te(n,t=>n.moveVertically(t,e,lc(n).height))}const gl=n=>gc(n,!1),yl=n=>gc(n,!0),vg=n=>Te(n,e=>pt(n,e,!0)),xg=n=>Te(n,e=>pt(n,e,!1)),wg=n=>Te(n,e=>pt(n,e,!le(n))),Sg=n=>Te(n,e=>pt(n,e,le(n))),kg=n=>Te(n,e=>v.cursor(n.lineBlockAt(e.head).from)),Cg=n=>Te(n,e=>v.cursor(n.lineBlockAt(e.head).to)),bl=({state:n,dispatch:e})=>(e(Je(n,{anchor:0})),!0),vl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.doc.length})),!0),xl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.selection.main.anchor,head:0})),!0),wl=({state:n,dispatch:e})=>(e(Je(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Ag=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Mg=({state:n,dispatch:e})=>{let t=ns(n).map(({from:i,to:s})=>v.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:v.create(t),userEvent:"select"})),!0},Tg=({state:n,dispatch:e})=>{let t=Qt(n.selection,i=>{var s;let r=j(n).resolveStack(i.from,1);for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((s=l.parent)===null||s===void 0)&&s.parent))return v.range(l.to,l.from)}return i});return e(Je(n,t)),!0},Og=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=v.create([t.main]):t.main.empty||(i=v.create([v.cursor(t.main.head)])),i?(e(Je(n,i)),!0):!1};function Vi(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=sn(n,a,!1)):a>o&&(t="delete.forward",a=sn(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=sn(n,o,!1),l=sn(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:v.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?w.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function sn(n,e,t){if(n instanceof w)for(let i of n.state.facet(w.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const yc=(n,e,t)=>Vi(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let c=Yt(l,r.tabSize),h=c%Pn(r)||Pn(r);for(let f=0;f<h&&l[l.length-1-f]==" ";f++)s--;a=s}else a=se(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=se(o.text,a-o.from,!1,!1)+o.from);return a}),gr=n=>yc(n,!1,!0),bc=n=>yc(n,!0,!1),vc=(n,e)=>Vi(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=se(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),xc=n=>vc(n,!1),Dg=n=>vc(n,!0),Eg=n=>Vi(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Pg=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Bg=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Rg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:B.of(["",""])},range:v.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Lg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:se(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:se(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:v.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ns(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function wc(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of ns(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(v.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(v.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:v.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ig=({state:n,dispatch:e})=>wc(n,e,!1),Ng=({state:n,dispatch:e})=>wc(n,e,!0);function Sc(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of ns(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Fg=({state:n,dispatch:e})=>Sc(n,e,!1),Vg=({state:n,dispatch:e})=>Sc(n,e,!0),Hg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(ns(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=Qt(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Wg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=j(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(Ae.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const $g=kc(!1),zg=kc(!0);function kc(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Wg(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new Yn(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=Hr(c,r);for(h==null&&(h=Yt(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Mi(e,h)];return a&&f.push(Mi(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:B.of(f)},range:v.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function _r(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:v.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const jg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Yn(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=_r(n,(r,o,l)=>{let a=Hr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],h=Mi(n,a);(c!=h||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:h}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},Cc=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(_r(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Xt)})}),{userEvent:"input.indent"})),!0),Ac=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(_r(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Yt(s,n.tabSize),o=0,l=Mi(n,Math.max(0,r-Pn(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),qg=n=>(n.setTabFocusMode(),!0),Kg=[{key:"Ctrl-b",run:tc,shift:cc,preventDefault:!0},{key:"Ctrl-f",run:ic,shift:fc},{key:"Ctrl-p",run:rc,shift:pc},{key:"Ctrl-n",run:oc,shift:mc},{key:"Ctrl-a",run:fg,shift:kg},{key:"Ctrl-e",run:ug,shift:Cg},{key:"Ctrl-d",run:bc},{key:"Ctrl-h",run:gr},{key:"Ctrl-k",run:Eg},{key:"Ctrl-Alt-h",run:xc},{key:"Ctrl-o",run:Rg},{key:"Ctrl-t",run:Lg},{key:"Ctrl-v",run:mr}],_g=[{key:"ArrowLeft",run:tc,shift:cc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ig,shift:mg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:hg,shift:wg,preventDefault:!0},{key:"ArrowRight",run:ic,shift:fc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ng,shift:gg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cg,shift:Sg,preventDefault:!0},{key:"ArrowUp",run:rc,shift:pc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:bl,shift:xl},{mac:"Ctrl-ArrowUp",run:ml,shift:gl},{key:"ArrowDown",run:oc,shift:mc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:vl,shift:wl},{mac:"Ctrl-ArrowDown",run:mr,shift:yl},{key:"PageUp",run:ml,shift:gl},{key:"PageDown",run:mr,shift:yl},{key:"Home",run:ag,shift:xg,preventDefault:!0},{key:"Mod-Home",run:bl,shift:xl},{key:"End",run:lg,shift:vg,preventDefault:!0},{key:"Mod-End",run:vl,shift:wl},{key:"Enter",run:$g},{key:"Mod-a",run:Ag},{key:"Backspace",run:gr,shift:gr},{key:"Delete",run:bc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:xc},{key:"Mod-Delete",mac:"Alt-Delete",run:Dg},{mac:"Mod-Backspace",run:Pg},{mac:"Mod-Delete",run:Bg}].concat(Kg.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Jg=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:rg,shift:yg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:og,shift:bg},{key:"Alt-ArrowUp",run:Ig},{key:"Shift-Alt-ArrowUp",run:Fg},{key:"Alt-ArrowDown",run:Ng},{key:"Shift-Alt-ArrowDown",run:Vg},{key:"Escape",run:Og},{key:"Mod-Enter",run:zg},{key:"Alt-l",mac:"Ctrl-l",run:Mg},{key:"Mod-i",run:Tg,preventDefault:!0},{key:"Mod-[",run:Ac},{key:"Mod-]",run:Cc},{key:"Mod-Alt-\\",run:jg},{key:"Shift-Mod-k",run:Hg},{key:"Shift-Mod-\\",run:pg},{key:"Mod-/",run:Fm},{key:"Alt-A",run:Hm},{key:"Ctrl-m",mac:"Shift-Alt-m",run:qg}].concat(_g),Ug={key:"Tab",run:Cc,shift:Ac},Sl=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Ut{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(Sl(l)):Sl,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ie(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Ar(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Se(e);let s=this.normalize(t);for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,i){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:i}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Ut.prototype[Symbol.iterator]=function(){return this});const Mc={from:-1,to:-1,match:/.*/.exec("")},Jr="gm"+(/x/.unicode==null?"":"u");class Tc{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=Mc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Oc(e,t,i,s,r);this.re=new RegExp(t,Jr+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=In(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=In(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ks=new WeakMap;class Vt{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=ks.get(e);if(!s||s.from>=i||s.to<=t){let l=new Vt(t,e.sliceString(t,i));return ks.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),ks.set(e,new Vt(o,r)),new Vt(t,r.slice(t-o,i-o))}}class Oc{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=Mc,this.matchPos=In(e,s),this.re=new RegExp(t,Jr+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=Vt.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=In(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Vt.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Tc.prototype[Symbol.iterator]=Oc.prototype[Symbol.iterator]=function(){return this});function Yg(n){try{return new RegExp(n,Jr),!0}catch{return!1}}function In(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function yr(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=V("input",{class:"cm-textfield",name:"line",value:e}),i=V("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:Nn.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},V("label",n.state.phrase("Go to line"),": ",t)," ",V("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,c,h,f]=r,u=h?+h.slice(1):0,d=c?+c:l.number;if(c&&f){let y=d/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*y)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),g=v.cursor(p.from+Math.max(0,Math.min(u,p.length)));n.dispatch({effects:[Nn.of(!1),w.scrollIntoView(g.from,{y:"center"})],selection:g}),n.focus()}return{dom:i}}const Nn=D.define(),kl=X.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Nn)&&(n=t.value);return n},provide:n=>Ai.from(n,e=>e?yr:null)}),Gg=n=>{let e=Ci(n,yr);if(!e){let t=[Nn.of(!0)];n.state.field(kl,!1)==null&&t.push(D.appendConfig.of([kl,Xg])),n.dispatch({effects:t}),e=Ci(n,yr)}return e&&e.dom.querySelector("input").select(),!0},Xg=w.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Qg={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Zg=A.define({combine(n){return _e(n,Qg,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function e0(n){return[r0,s0]}const t0=M.mark({class:"cm-selectionMatch"}),i0=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Cl(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=z.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=z.Word)}function n0(n,e,t,i){return n(e.sliceDoc(t,t+1))==z.Word&&n(e.sliceDoc(i-1,i))==z.Word}const s0=_.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Zg),{state:t}=n,i=t.selection;if(i.ranges.length>1)return M.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return M.none;let a=t.wordAt(s.head);if(!a)return M.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return M.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Cl(o,t,s.from,s.to)&&n0(o,t,s.from,s.to)))return M.none}else if(r=t.sliceDoc(s.from,s.to),!r)return M.none}let l=[];for(let a of n.visibleRanges){let c=new Ut(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:h,to:f}=c.value;if((!o||Cl(o,t,h,f))&&(s.empty&&h<=s.from&&f>=s.to?l.push(i0.range(h,f)):(h>=s.to||f<=s.from)&&l.push(t0.range(h,f)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:n=>n.decorations}),r0=w.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),o0=({state:n,dispatch:e})=>{let{selection:t}=n,i=v.create(t.ranges.map(s=>n.wordAt(s.head)||v.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function l0(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Ut(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ut(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const a0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return o0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=l0(n,i);return s?(e(n.update({selection:n.selection.addRange(v.range(s.from,s.to),!1),effects:w.scrollIntoView(s.to)})),!0):!1},Zt=A.define({combine(n){return _e(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new x0(e),scrollToMatch:e=>w.scrollIntoView(e)})}});class Dc{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Yg(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
10
+ `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new u0(this):new c0(this)}getCursor(e,t=0,i){let s=e.doc?e:P.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Ot(this,s,t,i):Tt(this,s,t,i)}}class Ec{constructor(e){this.spec=e}}function Tt(n,e,t,i){return new Ut(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?h0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function h0(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(Fn(s,t-r))!=z.Word||e(Vn(s,t-r))!=z.Word)&&(e(Vn(s,i-r))!=z.Word||e(Fn(s,i-r))!=z.Word))}class c0 extends Ec{constructor(e){super(e)}nextMatch(e,t,i){let s=Tt(this.spec,e,i,e.doc.length).nextOverlapping();return s.done&&(s=Tt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Tt(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Tt(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Tt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ot(n,e,t,i){return new Tc(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?f0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function Fn(n,e){return n.slice(se(n,e,!1),e)}function Vn(n,e){return n.slice(e,se(n,e))}function f0(n){return(e,t,i)=>!i[0].length||(n(Fn(i.input,i.index))!=z.Word||n(Vn(i.input,i.index))!=z.Word)&&(n(Vn(i.input,i.index+i[0].length))!=z.Word||n(Fn(i.input,i.index+i[0].length))!=z.Word)}class u0 extends Ec{nextMatch(e,t,i){let s=Ot(this.spec,e,i,e.doc.length).next();return s.done&&(s=Ot(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Ot(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=Ot(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Ot(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Oi=D.define(),Ur=D.define(),ot=X.define({create(n){return new Cs(br(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Oi)?n=new Cs(t.value.create(),n.panel):t.is(Ur)&&(n=new Cs(n.query,t.value?Yr:null));return n},provide:n=>Ai.from(n,e=>e.panel)});class Cs{constructor(e,t){this.query=e,this.panel=t}}const d0=M.mark({class:"cm-searchMatch"}),p0=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),m0=_.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ot))}update(n){let e=n.state.field(ot);(e!=n.startState.field(ot)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return M.none;let{view:t}=this,i=new ct;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(c,h)=>{let f=t.state.selection.ranges.some(u=>u.from==c&&u.to==h);i.add(c,h,f?p0:d0)})}return i.finish()}},{decorations:n=>n.decorations});function Hi(n){return e=>{let t=e.state.field(ot,!1);return t&&t.query.spec.valid?n(e,t):Rc(e)}}const Hn=Hi((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=v.single(i.from,i.to),r=n.state.facet(Zt);return n.dispatch({selection:s,effects:[Gr(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Bc(n),!0}),Wn=Hi((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=v.single(s.from,s.to),o=n.state.facet(Zt);return n.dispatch({selection:r,effects:[Gr(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Bc(n),!0}),g0=Hi((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:v.create(t.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),y0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new Ut(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(v.range(l.value.from,l.value.to))}return e(n.update({selection:v.create(r,o),userEvent:"select.search.matches"})),!0},Al=Hi((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=[],l,a,c=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),c.push(w.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let h=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=v.single(r.from-h,r.to-h),c.push(Gr(n,r)),c.push(t.facet(Zt).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:c,userEvent:"input.replace"}),!0}),b0=Hi((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:w.announce.of(i),userEvent:"input.replace.all"}),!0});function Yr(n){return n.state.facet(Zt).createPanel(n)}function br(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(Zt);return new Dc({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function Pc(n){let e=Ci(n,Yr);return e&&e.dom.querySelector("[main-field]")}function Bc(n){let e=Pc(n);e&&e==n.root.activeElement&&e.select()}const Rc=n=>{let e=n.state.field(ot,!1);if(e&&e.panel){let t=Pc(n);if(t&&t!=n.root.activeElement){let i=br(n.state,e.query.spec);i.valid&&n.dispatch({effects:Oi.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ur.of(!0),e?Oi.of(br(n.state,e.query.spec)):D.appendConfig.of(S0)]});return!0},Lc=n=>{let e=n.state.field(ot,!1);if(!e||!e.panel)return!1;let t=Ci(n,Yr);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ur.of(!1)}),!0},v0=[{key:"Mod-f",run:Rc,scope:"editor search-panel"},{key:"F3",run:Hn,shift:Wn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Hn,shift:Wn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Lc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:y0},{key:"Mod-Alt-g",run:Gg},{key:"Mod-d",run:a0,preventDefault:!0}];class x0{constructor(e){this.view=e;let t=this.query=e.state.field(ot).query.spec;this.commit=this.commit.bind(this),this.searchField=V("input",{value:t.search,placeholder:ge(e,"Find"),"aria-label":ge(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=V("input",{value:t.replace,placeholder:ge(e,"Replace"),"aria-label":ge(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=V("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=V("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=V("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return V("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=V("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>Hn(e),[ge(e,"next")]),i("prev",()=>Wn(e),[ge(e,"previous")]),i("select",()=>g0(e),[ge(e,"all")]),V("label",null,[this.caseField,ge(e,"match case")]),V("label",null,[this.reField,ge(e,"regexp")]),V("label",null,[this.wordField,ge(e,"by word")]),...e.state.readOnly?[]:[V("br"),this.replaceField,i("replace",()=>Al(e),[ge(e,"replace")]),i("replaceAll",()=>b0(e),[ge(e,"replace all")])],V("button",{name:"close",onclick:()=>Lc(e),"aria-label":ge(e,"close"),type:"button"},["×"])])}commit(){let e=new Dc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Oi.of(e)}))}keydown(e){kd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Wn:Hn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Al(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Oi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Zt).top}}function ge(n,e){return n.state.phrase(e)}const rn=30,on=/[\s\.,:;?!]/;function Gr(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-rn),o=Math.min(s,t+rn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<rn;a++)if(!on.test(l[a+1])&&on.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-rn;a--)if(!on.test(l[a-1])&&on.test(l[a])){l=l.slice(0,a);break}}return w.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const w0=w.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),S0=[ot,dt.low(m0),w0];class Ic{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=j(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Fc(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function Ml(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function k0(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Ml(e)+Ml(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Xr(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:k0(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Nc(n,e){return t=>{for(let i=j(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Tl{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function lt(n){return n.selection.main.from}function Fc(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Vc=Ie.define();function C0(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:e},range:v.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Ol=new WeakMap;function A0(n){if(!Array.isArray(n))return n;let e=Ol.get(n);return e||Ol.set(n,e=Xr(n)),e}const $n=D.define(),Di=D.define();class M0{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=ie(e,t),s=Se(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(ie(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let x=ie(e,0),T=Se(x),S=T==e.length?0:-100;if(x!=t[0])if(x==i[0])S+=-200;else return!1;return this.ret(S,[0,T])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let x=0,T=Math.min(e.length,200);x<T&&c<a;){let S=ie(e,x);(S==t[c]||S==i[c])&&(s[c++]=x),x+=Se(S)}if(c<a)return!1}let h=0,f=0,u=!1,d=0,p=-1,g=-1,y=/[a-z]/.test(e),b=!0;for(let x=0,T=Math.min(e.length,200),S=0;x<T&&f<a;){let k=ie(e,x);l<0&&(h<a&&k==t[h]&&(r[h++]=x),d<a&&(k==t[d]||k==i[d]?(d==0&&(p=x),g=x+1,d++):d=0));let O,L=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(O=Ar(k))!=O.toLowerCase()?1:O!=O.toUpperCase()?2:0;(!x||L==1&&y||S==0&&L!=0)&&(t[f]==k||i[f]==k&&(u=!0)?o[f++]=x:o.length&&(b=!1)),S=L,x+=Se(k)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?!1:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?Se(ie(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}const ne=A.define({combine(n){return _e(n,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:T0,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Dl(e(i),t(i)),optionClass:(e,t)=>i=>Dl(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function Dl(n,e){return n?e?n+" "+e:n:e}function T0(n,e,t,i,s,r){let o=n.textDirection==W.RTL,l=o,a=!1,c="top",h,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))h=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let x=s.bottom-e.bottom;x>=g||x>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let y=(e.bottom-e.top)/r.offsetHeight,b=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/y}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function O0(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;c<r.length;){let h=r[c++],f=r[c++];h>a&&o.appendChild(document.createTextNode(l.slice(a,h)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(h,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function As(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class D0{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(ne);this.optionContent=O0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=As(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,f;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(f=/-(\d+)$/.exec(h.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(ne).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Di.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=As(r.length,o,e.state.facet(ne).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=As(t.options.length,t.selected,this.view.state.facet(ne).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>ae(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&P0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(ne).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:c}=l;if(c){let u=typeof c=="string"?c:c.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let f=this.optionClass(l);f&&(h.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function E0(n,e){return t=>new D0(t,n,e)}function P0(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function El(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function B0(n,e){let t=[],i=null,s=a=>{t.push(a);let{section:c}=a.completion;if(c){i||(i=[]);let h=typeof c=="string"?c:c.name;i.some(f=>f.name==h)||i.push(typeof c=="string"?{name:h}:c)}};for(let a of n)if(a.hasResult()){let c=a.result.getMatch;if(a.result.filter===!1)for(let h of a.result.options)s(new Tl(h,a.source,c?c(h):[],1e9-t.length));else{let h=new M0(e.sliceDoc(a.from,a.to));for(let f of a.result.options)if(h.match(f.label)){let u=f.displayLabel?c?c(f,h.matched):[]:h.matched;s(new Tl(f,a.source,u,h.score+(f.boost||0)))}}}if(i){let a=Object.create(null),c=0,h=(f,u)=>{var d,p;return((d=f.rank)!==null&&d!==void 0?d:1e9)-((p=u.rank)!==null&&p!==void 0?p:1e9)||(f.name<u.name?-1:1)};for(let f of i.sort(h))c-=1e5,a[f.name]=c;for(let f of t){let{section:u}=f.completion;u&&(f.score+=a[typeof u=="string"?u:u.name])}}let r=[],o=null,l=e.facet(ne).compareCompletions;for(let a of t.sort((c,h)=>h.score-c.score||l(c.completion,h.completion))){let c=a.completion;!o||o.label!=c.label||o.detail!=c.detail||o.type!=null&&c.type!=null&&o.type!=c.type||o.apply!=c.apply||o.boost!=c.boost?r.push(a):El(a.completion)>El(o)&&(r[r.length-1]=a),o=a.completion}return r}class Rt{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Rt(this.options,Pl(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r){let o=B0(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Rt(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(ne).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let c=0;c<o.length;c++)if(o[c].completion==a){l=c;break}}return new Rt(o,Pl(i,l),{pos:e.reduce((a,c)=>c.hasResult()?Math.min(a,c.from):a,1e8),create:F0,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Rt(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class zn{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new zn(I0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ne),r=(i.override||t.languageDataAt("autocomplete",lt(t)).map(A0)).map(l=>(this.active.find(c=>c.source==l)||new pe(l,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!R0(r,this.active)?o=Rt.build(r,t,this.id,o,i):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new pe(l.source,0):l));for(let l of e.effects)l.is(Wc)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new zn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:L0}}function R0(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const L0={"aria-autocomplete":"list"};function Pl(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const I0=[];function vr(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class pe{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=vr(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new pe(s.source,0));for(let r of e.effects)if(r.is($n))s=new pe(s.source,1,r.value?lt(e.state):-1);else if(r.is(Di))s=new pe(s.source,0);else if(r.is(Hc))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new pe(this.source,1)}handleChange(e){return e.changes.touchesRange(lt(e.startState))?new pe(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new pe(this.source,this.state,e.mapPos(this.explicitPos))}}class Ht extends pe{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=lt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&lt(e.startState)==this.from)return new pe(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),c;return N0(this.result.validFor,e.state,r,o)?new Ht(this.source,a,this.result,r,o):this.result.update&&(c=this.result.update(this.result,r,o,new Ic(e.state,l,a>=0)))?new Ht(this.source,a,c,c.from,(s=c.to)!==null&&s!==void 0?s:lt(e.state)):new pe(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new pe(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Ht(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function N0(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):Fc(n,!0).test(s)}const Hc=D.define({map(n,e){return n.map(t=>t.map(e))}}),Wc=D.define(),be=X.define({create(){return zn.start()},update(n,e){return n.update(e)},provide:n=>[Nr.from(n,e=>e.tooltip),w.contentAttributes.from(n,e=>e.attrs)]});function $c(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(be).active.find(s=>s.source==e.source);return i instanceof Ht?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},C0(n.state,t,i.from,i.to)),{annotations:Vc.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const F0=E0(be,$c);function ln(n,e="option"){return t=>{let i=t.state.field(be,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ne).interactionDelay)return!1;let s=1,r;e=="page"&&(r=kh(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Wc.of(l)}),!0}}const V0=n=>{let e=n.state.field(be,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(ne).interactionDelay?!1:$c(n,e.open.options[e.open.selected])},H0=n=>n.state.field(be,!1)?(n.dispatch({effects:$n.of(!0)}),!0):!1,W0=n=>{let e=n.state.field(be,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Di.of(null)}),!0)};class $0{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const z0=50,j0=1e3,q0=_.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(be).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(be);if(!n.selectionSet&&!n.docChanged&&n.startState.field(be)==e)return;let t=n.transactions.some(s=>(s.selection||s.docChanged)&&!vr(s));for(let s=0;s<this.running.length;s++){let r=this.running[s];if(t||r.updates.length+n.transactions.length>z0&&Date.now()-r.time>j0){for(let o of r.context.abortListeners)try{o()}catch(l){ae(this.view.state,l)}r.context.abortListeners=null,this.running.splice(s--,1)}else r.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(r=>r.is($n)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.state.facet(ne).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(r=>r.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of n.transactions)vr(s)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(be);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=lt(e),i=new Ic(e,t,n.explicitPos==t),s=new $0(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Di.of(null)}),ae(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ne);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=new Ht(s.active.source,s.active.explicitPos,s.done,s.done.from,(n=s.done.to)!==null&&n!==void 0?n:lt(s.updates.length?s.updates[0].startState:this.view.state));for(let l of s.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let r=this.view.state.field(be).active.find(o=>o.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new pe(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:Hc.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(be,!1);if(e&&e.tooltip&&this.view.state.facet(ne).closeOnBlur){let t=e.open&&kh(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Di.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$n.of(!1)}),20),this.composing=0}}}),zc=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});let K0=class{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}},_0=class jc{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,ee.TrackDel),i=e.mapPos(this.to,1,ee.TrackDel);return t==null||i==null?null:new jc(this.field,t,i)}},J0=class qc{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let f=0;f<h;f++)c+=e.facet(Xt);s.push(t+c.length-h),a=c+a.slice(h)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new _0(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",c=-1;for(let h=0;h<t.length;h++)(l!=null?t[h].seq==l:a&&t[h].name==a)&&(c=h);if(c<0){let h=0;for(;h<t.length&&(l==null||t[h].seq!=null&&t[h].seq<l);)h++;t.splice(h,0,{seq:l,name:a}),c=h;for(let f of s)f.field>=c&&f.field++}s.push(new K0(c,i.length,r.index,r.index+a.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}for(let l;l=/\\([{}])/.exec(o);){o=o.slice(0,l.index)+l[1]+o.slice(l.index+l[0].length);for(let a of s)a.line==i.length&&a.from>l.index&&(a.from--,a.to--)}i.push(o)}return new qc(i,s)}},U0=M.widget({widget:new class extends Ne{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Y0=M.mark({class:"cm-snippetField"}),ss=class Kc{constructor(e,t){this.ranges=e,this.active=t,this.deco=M.set(e.map(i=>(i.from==i.to?U0:Y0).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Kc(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}};const Wi=D.define({map(n,e){return n&&n.map(e)}}),G0=D.define(),Ei=X.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Wi))return t.value;if(t.is(G0)&&n)return new ss(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>w.decorations.from(n,e=>e?e.deco:M.none)});function Qr(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function X0(n){let e=J0.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:B.of(o)},scrollIntoView:!0,annotations:i?[Vc.of(i),Y.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=Qr(l,0)),l.some(c=>c.field>0)){let c=new ss(l,0),h=a.effects=[Wi.of(c)];t.state.field(Ei,!1)===void 0&&h.push(D.appendConfig.of([Ei,iy,ny,zc]))}t.dispatch(t.state.update(a))}}function _c(n){return({state:e,dispatch:t})=>{let i=e.field(Ei,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:Qr(i.ranges,s),effects:Wi.of(r?null:new ss(i.ranges,s)),scrollIntoView:!0})),!0}}const Q0=({state:n,dispatch:e})=>n.field(Ei,!1)?(e(n.update({effects:Wi.of(null)})),!0):!1,Z0=_c(1),ey=_c(-1),ty=[{key:"Tab",run:Z0,shift:ey},{key:"Escape",run:Q0}],Bl=A.define({combine(n){return n.length?n[0]:ty}}),iy=dt.highest(Gt.compute([Bl],n=>n.facet(Bl)));function q(n,e){return Object.assign(Object.assign({},e),{apply:X0(n)})}const ny=w.domEventHandlers({mousedown(n,e){let t=e.state.field(Ei,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:Qr(t.ranges,s.field),effects:Wi.of(t.ranges.some(r=>r.field>s.field)?new ss(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Pi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},vt=D.define({map(n,e){let t=e.mapPos(n,-1,ee.TrackAfter);return t??void 0}}),Zr=new class extends ht{};Zr.startSide=1;Zr.endSide=-1;const Jc=X.define({create(){return R.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(vt)&&(n=n.update({add:[Zr.range(t.value,t.value+1)]}));return n}});function sy(){return[oy,Jc]}const Ms="()[]{}<>";function Uc(n){for(let e=0;e<Ms.length;e+=2)if(Ms.charCodeAt(e)==n)return Ms.charAt(e+1);return Ar(n<128?n:n+1)}function Yc(n,e){return n.languageDataAt("closeBrackets",e)[0]||Pi}const ry=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oy=w.inputHandler.of((n,e,t,i)=>{if((ry?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Se(ie(i,0))==1||e!=s.from||t!=s.to)return!1;let r=hy(n.state,i);return r?(n.dispatch(r),!0):!1}),ly=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Yc(n,n.selection.main.head).brackets||Pi.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=cy(n.doc,o.head);for(let a of i)if(a==l&&rs(n.doc,o.head)==Uc(ie(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:v.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},ay=[{key:"Backspace",run:ly}];function hy(n,e){let t=Yc(n,n.selection.main.head),i=t.brackets||Pi.brackets;for(let s of i){let r=Uc(ie(s,0));if(e==s)return r==s?dy(n,s,i.indexOf(s+s+s)>-1,t):fy(n,s,r,t.before||Pi.before);if(e==r&&Gc(n,n.selection.main.from))return uy(n,s,r)}return null}function Gc(n,e){let t=!1;return n.field(Jc).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function rs(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Se(ie(t,0)))}function cy(n,e){let t=n.sliceString(e-2,e);return Se(ie(t,0))==t.length?t:t.slice(1)}function fy(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:vt.of(o.to+e.length),range:v.range(o.anchor+e.length,o.head+e.length)};let l=rs(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:vt.of(o.head+e.length),range:v.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function uy(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&rs(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:v.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dy(n,e,t,i){let s=i.stringPrefixes||Pi.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:vt.of(l.to+e.length),range:v.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=rs(n.doc,a),h;if(c==e){if(Rl(n,a))return{changes:{insert:e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)};if(Gc(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:v.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=Ll(n,a-2*e.length,s))>-1&&Rl(n,h))return{changes:{insert:e+e+e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=z.Word&&Ll(n,a,s)>-1&&!py(n,a,e,s))return{changes:{insert:e+e,from:a},effects:vt.of(a+e.length),range:v.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Rl(n,e){let t=j(n).resolveInner(e+1);return t.parent&&t.from==e}function py(n,e,t,i){let s=j(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function Ll(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=z.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=z.Word)return r}return-1}function my(n={}){return[be,ne.of(n),q0,gy,zc]}const Xc=[{key:"Ctrl-Space",run:H0},{key:"Escape",run:W0},{key:"ArrowDown",run:ln(!0)},{key:"ArrowUp",run:ln(!1)},{key:"PageDown",run:ln(!0,"page")},{key:"PageUp",run:ln(!1,"page")},{key:"Enter",run:V0}],gy=dt.highest(Gt.computeN([ne],n=>n.facet(ne).defaultKeymap?[Xc]:[]));var Il=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(ay)),e.defaultKeymap!==!1&&(i=i.concat(Jg)),e.searchKeymap!==!1&&(i=i.concat(v0)),e.historyKeymap!==!1&&(i=i.concat(tg)),e.foldKeymap!==!1&&(i=i.concat(qp)),e.completionKeymap!==!1&&(i=i.concat(Xc)),e.lintKeymap!==!1&&(i=i.concat(Sm));var s=[];return e.lineNumbers!==!1&&s.push(xp()),e.highlightActiveLineGutter!==!1&&s.push(kp()),e.highlightSpecialChars!==!1&&s.push(Wd()),e.history!==!1&&s.push(_m()),e.foldGutter!==!1&&s.push(Up()),e.drawSelection!==!1&&s.push(Dd()),e.dropCursor!==!1&&s.push(Ld()),e.allowMultipleSelections!==!1&&s.push(P.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(Ip()),e.syntaxHighlighting!==!1&&s.push(Zn(Qp,{fallback:!0})),e.bracketMatching!==!1&&s.push(rm()),e.closeBrackets!==!1&&s.push(sy()),e.autocompletion!==!1&&s.push(my()),e.rectangularSelection!==!1&&s.push(ep()),t!==!1&&s.push(np()),e.highlightActiveLine!==!1&&s.push(_d()),e.highlightSelectionMatches!==!1&&s.push(e0()),e.tabSize&&typeof e.tabSize=="number"&&s.push(Xt.of(" ".repeat(e.tabSize))),s.concat([Gt.of(i.flat())]).filter(Boolean)};const yy="#e5c07b",Nl="#e06c75",by="#56b6c2",vy="#ffffff",xn="#abb2bf",xr="#7d8799",xy="#61afef",wy="#98c379",Fl="#d19a66",Sy="#c678dd",ky="#21252b",Vl="#2c313a",Hl="#282c34",Ts="#353a42",Cy="#3E4451",Wl="#528bff",Ay=w.theme({"&":{color:xn,backgroundColor:Hl},".cm-content":{caretColor:Wl},".cm-cursor, .cm-dropCursor":{borderLeftColor:Wl},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Cy},".cm-panels":{backgroundColor:ky,color:xn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Hl,color:xr,border:"none"},".cm-activeLineGutter":{backgroundColor:Vl},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ts},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ts,borderBottomColor:Ts},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Vl,color:xn}}},{dark:!0}),My=At.define([{tag:m.keyword,color:Sy},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:Nl},{tag:[m.function(m.variableName),m.labelName],color:xy},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Fl},{tag:[m.definition(m.name),m.separator],color:xn},{tag:[m.typeName,m.className,m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:yy},{tag:[m.operator,m.operatorKeyword,m.url,m.escape,m.regexp,m.link,m.special(m.string)],color:by},{tag:[m.meta,m.comment],color:xr},{tag:m.strong,fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.link,color:xr,textDecoration:"underline"},{tag:m.heading,fontWeight:"bold",color:Nl},{tag:[m.atom,m.bool,m.special(m.variableName)],color:Fl},{tag:[m.processingInstruction,m.string,m.inserted],color:wy},{tag:m.invalid,color:vy}]),Ty=[Ay,Zn(My)];var Oy=w.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Dy=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:i=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(Gt.of([Ug])),l&&(typeof l=="boolean"?a.unshift(Il()):a.unshift(Il(l))),o&&a.unshift(Gd(o)),r){case"light":a.push(Oy);break;case"dark":a.push(Ty);break;case"none":break;default:a.push(r);break}return i===!1&&a.push(w.editable.of(!1)),s&&a.push(P.readOnly.of(!0)),[...a]},Ey=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)}),$l=Ie.define(),Py=[];function By(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=Py,autoFocus:a,theme:c="light",height:h=null,minHeight:f=null,maxHeight:u=null,width:d=null,minWidth:p=null,maxWidth:g=null,placeholder:y="",editable:b=!0,readOnly:x=!1,indentWithTab:T=!0,basicSetup:S=!0,root:k,initialState:O}=n,[L,K]=we.useState(),[I,fe]=we.useState(),[Ue,Oe]=we.useState(),et=w.theme({"&":{height:h,minHeight:f,maxHeight:u,width:d,minWidth:p,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),De=w.updateListener.of(Q=>{if(Q.docChanged&&typeof i=="function"&&!Q.transactions.some(Pe=>Pe.annotation($l))){var Ee=Q.state.doc,ue=Ee.toString();i(ue,Q)}s&&s(Ey(Q))}),Ve=Dy({theme:c,editable:b,readOnly:x,placeholder:y,indentWithTab:T,basicSetup:S}),xe=[De,et,...Ve];return o&&typeof o=="function"&&xe.push(w.updateListener.of(o)),xe=xe.concat(l),we.useEffect(()=>{if(L&&!Ue){var Q={doc:e,selection:t,extensions:xe},Ee=O?P.fromJSON(O.json,Q,O.fields):P.create(Q);if(Oe(Ee),!I){var ue=new w({state:Ee,parent:L,root:k});fe(ue),r&&r(ue,Ee)}}return()=>{I&&(Oe(void 0),fe(void 0))}},[L,Ue]),we.useEffect(()=>K(n.container),[n.container]),we.useEffect(()=>()=>{I&&(I.destroy(),fe(void 0))},[I]),we.useEffect(()=>{a&&I&&I.focus()},[a,I]),we.useEffect(()=>{I&&I.dispatch({effects:D.reconfigure.of(xe)})},[c,l,h,f,u,d,p,g,y,b,x,T,S,i,o]),we.useEffect(()=>{if(e!==void 0){var Q=I?I.state.doc.toString():"";I&&e!==Q&&I.dispatch({changes:{from:0,to:Q.length,insert:e||""},annotations:[$l.of(!0)]})}},[e,I]),{state:Ue,setState:Oe,view:I,setView:fe,container:L,setContainer:K}}var Ry=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ly=we.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,autoFocus:h,theme:f="light",height:u,minHeight:d,maxHeight:p,width:g,minWidth:y,maxWidth:b,basicSetup:x,placeholder:T,indentWithTab:S,editable:k,readOnly:O,root:L,initialState:K}=n,I=Af(n,Ry),fe=we.useRef(null),{state:Ue,view:Oe,container:et}=By({container:fe.current,root:L,value:i,autoFocus:h,theme:f,height:u,minHeight:d,maxHeight:p,width:g,minWidth:y,maxWidth:b,basicSetup:x,placeholder:T,indentWithTab:S,editable:k,readOnly:O,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,extensions:r,initialState:K});if(we.useImperativeHandle(e,()=>({editor:fe.current,state:Ue,view:Oe}),[fe,et,Ue,Oe]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var De=typeof f=="string"?"cm-theme-"+f:"cm-theme";return Mf.jsx("div",qn({ref:fe,className:""+De+(t?" "+t:"")},I))});Ly.displayName="CodeMirror";const Iy=Ie.define(),Ny=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Fy{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class eo{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,ee.TrackDel),i=e.mapPos(this.to,1,ee.TrackDel);return t==null||i==null?null:new eo(this.field,t,i)}}class to{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let f=0;f<h;f++)c+=e.facet(Xt);s.push(t+c.length-h),a=c+a.slice(h)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new eo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",c=-1,h=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:h&&t[f].name==h)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:h}),c=f;for(let u of s)u.field>=c&&u.field++}s.push(new Fy(c,i.length,r.index,r.index+h.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of s)h.line==i.length&&h.from>c&&(h.from--,h.to--);return a}),i.push(o)}return new to(i,s)}}let Vy=M.widget({widget:new class extends Ne{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Hy=M.mark({class:"cm-snippetField"});class ei{constructor(e,t){this.ranges=e,this.active=t,this.deco=M.set(e.map(i=>(i.from==i.to?Vy:Hy).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new ei(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const $i=D.define({map(n,e){return n&&n.map(e)}}),Wy=D.define(),Bi=X.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is($i))return t.value;if(t.is(Wy)&&n)return new ei(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>w.decorations.from(n,e=>e?e.deco:M.none)});function io(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function $y(n){let e=to.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:B.of(o)},scrollIntoView:!0,annotations:i?[Iy.of(i),Y.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=io(l,0)),l.some(c=>c.field>0)){let c=new ei(l,0),h=a.effects=[$i.of(c)];t.state.field(Bi,!1)===void 0&&h.push(D.appendConfig.of([Bi,_y,Uy,Ny]))}t.dispatch(t.state.update(a))}}function Qc(n){return({state:e,dispatch:t})=>{let i=e.field(Bi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:io(i.ranges,s),effects:$i.of(r?null:new ei(i.ranges,s)),scrollIntoView:!0})),!0}}const zy=({state:n,dispatch:e})=>n.field(Bi,!1)?(e(n.update({effects:$i.of(null)})),!0):!1,jy=Qc(1),qy=Qc(-1),Ky=[{key:"Tab",run:jy,shift:qy},{key:"Escape",run:zy}],zl=A.define({combine(n){return n.length?n[0]:Ky}}),_y=dt.highest(Gt.compute([zl],n=>n.facet(zl)));function Jy(n,e){return Object.assign(Object.assign({},e),{apply:$y(n)})}const Uy=w.domEventHandlers({mousedown(n,e){let t=e.state.field(Bi,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:io(t.ranges,s.field),effects:$i.of(t.ranges.some(r=>r.field>s.field)?new ei(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Zc=new class extends ht{};Zc.startSide=1;Zc.endSide=-1;const yt={log:(...n)=>{},warn:(...n)=>{}},E={STRING:"String",NUMBER:"Number",TRUE:"True",FALSE:"False",NULL:"Null",OBJECT:"Object",ARRAY:"Array",PROPERTY:"Property",PROPERTY_NAME:"PropertyName",PROPERTY_COLON:"PropertyColon",ITEM:"Item",JSON_TEXT:"JsonText",INVALID:"⚠"},Yy={Pair:E.PROPERTY,Key:E.PROPERTY_NAME,BlockSequence:E.ARRAY,BlockMapping:E.OBJECT,FlowSequence:E.ARRAY,FlowMapping:E.OBJECT,QuotedLiteral:E.STRING,Literal:E.STRING,Stream:E.JSON_TEXT,Document:E.OBJECT},Gy={File:E.JSON_TEXT},no=[E.STRING,E.NUMBER,E.TRUE,E.FALSE,E.NULL],ef=[E.OBJECT,E.ARRAY,E.ITEM],$={JSON5:"json5",JSON:"json4",YAML:"yaml"},U=(n,e)=>{var t,i;switch(e){case $.YAML:return(t=Yy[n])!==null&&t!==void 0?t:n;case $.JSON5:return(i=Gy[n])!==null&&i!==void 0?i:n;default:return n}};function tf(n,e,t){const i=[];for(let s=e;s!=null&&s.parent;s=s.parent)switch(U(s.parent.name,t)){case E.PROPERTY:{const r=wr(s.parent,E.PROPERTY_NAME,t);r&&i.unshift(Dt(n,r).replace(/[/~]/g,o=>o==="~"?"~0":"~1"));break}case E.ARRAY:{if(Qy(s,t)){const r=rf(s.parent,s,t);i.unshift(`${r}`)}break}}return i.unshift(""),i.join("/")}const nf=(n,e,t=-1,i)=>tf(n.doc,j(n).resolve(e,t),i),so=(n,e)=>{const t=j(n),i=new Map;return t.iterate({enter:s=>{var r,o,l,a,c,h,f,u;if([E.PROPERTY_NAME,E.OBJECT].includes(U(s.name,e))){const d=tf(n.doc,s.node,e),{from:p,to:g}=s.node;if(!(!((o=(r=s.node)===null||r===void 0?void 0:r.nextSibling)===null||o===void 0)&&o.node))return i.set(d,{keyFrom:p,keyTo:g}),!0;const y=e===$.JSON?(a=(l=s.node)===null||l===void 0?void 0:l.nextSibling)===null||a===void 0?void 0:a.node:(u=(f=(h=(c=s.node)===null||c===void 0?void 0:c.nextSibling)===null||h===void 0?void 0:h.node)===null||f===void 0?void 0:f.nextSibling)===null||u===void 0?void 0:u.node;if(!y)return i.set(d,{keyFrom:p,keyTo:g}),!0;const{from:b,to:x}=y;return i.set(d,{keyFrom:p,keyTo:g,valueFrom:b,valueTo:x}),!0}}}),i},Os=(n,e,t=-1)=>j(n).resolveInner(e,t),wn=n=>n.replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1"),Xy=n=>n.replace(/^"(.*)"$/,"'$1'"),Dt=(n,e,t=!0,i=!0)=>{const s=e?n.sliceString(e.from,e.to):"";return t?i?wn(s):s.replace(/(^["'])|(["']$)/g,""):s},sf=(n,e)=>{var t,i,s,r;return U(n.name,e)===E.INVALID&&(U((i=(t=n.prevSibling)===null||t===void 0?void 0:t.name)!==null&&i!==void 0?i:"",e)===E.PROPERTY_NAME||U((r=(s=n.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)===E.PROPERTY_COLON)},Sn=(n,e)=>no.includes(U(n.name,e))||sf(n,e),Qy=(n,e)=>[...no,...ef].includes(U(n.name,e))||sf(n,e),an=(n,e)=>{var t,i,s,r,o,l;return U(n.name,e)===E.PROPERTY_NAME||U(n.name,e)===E.INVALID&&(U((i=(t=n.prevSibling)===null||t===void 0?void 0:t.name)!==null&&i!==void 0?i:"",e)===E.PROPERTY||U((r=(s=n.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)==="{")||e===$.YAML&&U((l=(o=n.parent)===null||o===void 0?void 0:o.name)!==null&&l!==void 0?l:"",e)===E.OBJECT},zi=n=>{const e=[];let t=n.firstChild;for(;t;)t&&e.push(t),t=t==null?void 0:t.nextSibling;return e},Zy=(n,e,t)=>zi(n).filter(i=>U(i.name,t)===e),wr=(n,e,t)=>{var i;return(i=zi(n).find(s=>U(s.name,t)===e))!==null&&i!==void 0?i:null},jl=(n,e)=>zi(n).find(t=>Sn(t,e)),eb=(n,e)=>zi(n).filter(t=>no.includes(U(t.name,e))||ef.includes(U(t.name,e))),rf=(n,e,t)=>eb(n,t).findIndex(i=>i.from===e.from&&i.to===e.to),ql=(n,e,t,i=1/0)=>{let s=n;for(;s&&i>0;){if(U(s.name,t)===e)return s;s=s.parent,i--}return null},tb=D.define(),jn=X.define({create(){},update(n,e){for(const t of e.effects)if(t.is(tb))return t.value;return n}}),ro=n=>n.field(jn),Fb=n=>[jn.init(()=>n)],Sr=Tf({linkify:!0,typographer:!0});(async()=>{const n=await Rf({themes:{light:"vitesse-light",dark:"vitesse-dark"}});Sr.use(n)})();function Wt(n,e=!0){return e?Sr.renderInline(n):Sr.render(n)}class ib{constructor(){this.completions=new Map,this.reservedKeys=new Set}reserve(e){this.reservedKeys.add(e)}add(e){this.reservedKeys.has(e.label)||this.completions.set(e.label,e)}}class nb{constructor(e){var t;this.opts=e,this.schema=null,this.mode=$.JSON,this.mode=(t=e.mode)!==null&&t!==void 0?t:$.JSON}doComplete(e){var t,i,s;const r=ro(e.state);if(this.schema=(t=this.expandSchemaProperty(r,r))!==null&&t!==void 0?t:r,!this.schema)return[];const o={from:e.pos,to:e.pos,options:[],filter:!1},l=e.state.doc.sliceString(0);let a=Os(e.state,e.pos),c=e.state.sliceDoc(a.from,e.pos).replace(/^(["'])/,"");if(!(Sn(a,this.mode)||an(a,this.mode))&&!e.explicit)return o;const h=Dt(e.state.doc,a),f=Dt(e.state.doc,a,!1);if(a&&(Sn(a,this.mode)||an(a,this.mode)))o.from=a.from,o.to=a.to;else{const g=e.matchBefore(/[A-Za-z0-9._]*/),y=e.pos-h.length;yt.log("xxx","overwriteStart after",y,"ctx.pos",e.pos,"word",g,"currentWord",h,"=>",l[y-1],"..",l[y],"..",l),o.from=a.name===E.INVALID?(i=g==null?void 0:g.from)!==null&&i!==void 0?i:e.pos:y,o.to=e.pos}const u=new ib;let d=!0;const p=ql(a,E.PROPERTY_NAME,this.mode);if(p&&(a=p),an(a,this.mode)){const g=a.parent;if(g){const y=jl(g,this.mode);d=!y||y.name===E.INVALID&&y.from-y.to===0||(y.parent?zi(y.parent).length<=1:!1),yt.log("xxx","addValue",d,jl(g,this.mode),a),a=(s=ql(g,E.OBJECT,this.mode))!==null&&s!==void 0?s:null}}if(yt.log("xxx",a,h,e,"node at pos",Os(e.state,e.pos)),a&&[E.OBJECT,E.JSON_TEXT].includes(U(a.name,this.mode))&&(an(Os(e.state,e.pos),this.mode)||p)){if(a.from===e.pos)return o;this.getPropertyCompletions(this.schema,e,a,u,d,f)}else{const g={};this.getValueCompletions(this.schema,e,g,u)}return o.options=Array.from(u.completions.values()).filter(g=>wn(g.label).startsWith(c)),yt.log("xxx","result",o,"prefix",c,"collector.completions",u.completions,"reservedKeys",u.reservedKeys),o}applySnippetCompletion(e){return Jy(typeof e.apply!="string"?e.label:e.apply,e)}getPropertyCompletions(e,t,i,s,r,o){Zy(i,E.PROPERTY,this.mode).forEach(c=>{const h=Dt(t.state.doc,wr(c,E.PROPERTY_NAME,this.mode));s.reserve(wn(h))}),this.getSchemas(e,t).forEach(c=>{if(typeof c!="object")return;const h=c.properties;h&&Object.entries(h).forEach(([u,d])=>{var p,g;if(typeof d=="object"){const y=(p=d.description)!==null&&p!==void 0?p:"",b=(g=d.type)!==null&&g!==void 0?g:"",x=Array.isArray(b)?b.toString():b,T={label:u,apply:this.getInsertTextForProperty(u,r,o,d),type:"property",detail:x,info:Wt(y)};s.add(this.applySnippetCompletion(T))}});const f=c.propertyNames;if(typeof f=="object"&&(f.enum&&f.enum.forEach(u=>{const d=u==null?void 0:u.toString();if(d){const p={label:d,apply:this.getInsertTextForProperty(d,r,o),type:"property"};s.add(this.applySnippetCompletion(p))}}),f.const)){const u=f.const.toString(),d={label:u,apply:this.getInsertTextForProperty(u,r,o),type:"property"};s.add(this.applySnippetCompletion(d))}})}getInsertTextForProperty(e,t,i,s){s=s&&this.expandSchemaProperty(s,this.schema);let r=this.getInsertTextForPropertyName(e,i);if(!t)return r;r+=": ";let o,l=0;if(typeof s=="object"){if(typeof s.default<"u")o||(o=this.getInsertTextForGuessedValue(s.default,"")),l++;else if(s.enum&&(!o&&s.enum.length===1&&(o=this.getInsertTextForGuessedValue(s.enum[0],"")),l+=s.enum.length),typeof s.const<"u"&&(o||(o=this.getInsertTextForGuessedValue(s.const,"")),l++),Array.isArray(s.examples)&&s.examples.length&&(o||(o=this.getInsertTextForGuessedValue(s.examples[0],"")),l+=s.examples.length),o===void 0&&l===0){let a=Array.isArray(s.type)?s.type[0]:s.type;switch(a||(s.properties?a="object":s.items&&(a="array")),a){case"boolean":o="#{}";break;case"string":o=this.getInsertTextForString("");break;case"object":switch(this.mode){case $.JSON5:o="{#{}}";break;case $.YAML:o="#{}";break;default:o="{#{}}";break}break;case"array":o="[#{}]";break;case"number":case"integer":o="#{0}";break;case"null":o="#{null}";break;default:o="#{}";break}}}return(!o||l>1)&&(o="#{}"),r+o}getInsertTextForPropertyName(e,t){switch(this.mode){case $.JSON5:case $.YAML:return t.startsWith('"')?`"${e}"`:t.startsWith("'")?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t="#"){switch(this.mode){case $.JSON5:return`'${t}{${e}}'`;case $.YAML:return`${t}{${e}}`;default:return`"${t}{${e}}"`}}getInsertTextForGuessedValue(e,t=""){switch(typeof e){case"object":return e===null?"${null}"+t:this.getInsertTextForValue(e,t);case"string":{let i=JSON.stringify(e);return i=i.substr(1,i.length-2),i=this.getInsertTextForPlainText(i),this.getInsertTextForString(i,"$")+t}case"number":case"boolean":return"${"+JSON.stringify(e)+"}"+t}return this.getInsertTextForValue(e,t)}getInsertTextForPlainText(e){return e.replace(/[\\$}]/g,"\\$&")}getInsertTextForValue(e,t){const i=JSON.stringify(e,null," ");return i==="{}"?"{#{}}"+t:i==="[]"?"[#{}]"+t:this.getInsertTextForPlainText(i+t)}getValueCompletions(e,t,i,s){let r=j(t.state).resolveInner(t.pos,-1),o=null,l;if(r&&Sn(r,this.mode)&&(o=r,r=r.parent),!r){this.addSchemaValueCompletions(e,i,s);return}if(U(r.name,this.mode)===E.PROPERTY){const c=wr(r,E.PROPERTY_NAME,this.mode);c&&(l=Dt(t.state.doc,c),r=r.parent)}if(r&&(l!==void 0||U(r.name,this.mode)===E.ARRAY)){const c=this.getSchemas(e,t);for(const h of c){if(typeof h!="object")return;if(U(r.name,this.mode)===E.ARRAY&&h.items){let f=s;if(h.uniqueItems&&(f=Object.assign(Object.assign({},f),{add(u){f.completions.has(u.label)||s.add(u)},reserve(u){s.reserve(u)}})),Array.isArray(h.items)){let u=0;if(o){const p=rf(r,o,this.mode);p>=0&&(u=p)}const d=h.items[u];d&&this.addSchemaValueCompletions(d,i,f)}else this.addSchemaValueCompletions(h.items,i,f)}if(l!==void 0){let f=!1;if(h.properties){const u=h.properties[l];u&&(f=!0,this.addSchemaValueCompletions(u,i,s))}if(h.patternProperties&&!f)for(const u of Object.keys(h.patternProperties)){const d=this.extendedRegExp(u);if(d!=null&&d.test(l)){f=!0;const p=h.patternProperties[u];p&&this.addSchemaValueCompletions(p,i,s)}}if(h.additionalProperties&&!f){const u=h.additionalProperties;this.addSchemaValueCompletions(u,i,s)}}i.boolean&&(this.addBooleanValueCompletion(!0,s),this.addBooleanValueCompletion(!1,s)),i.null&&this.addNullValueCompletion(s)}}return{valuePrefix:o?Dt(t.state.doc,o,!0,!1):""}}addSchemaValueCompletions(e,t,i){typeof e=="object"&&(this.addEnumValueCompletions(e,i),this.addDefaultValueCompletions(e,i),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)),Array.isArray(e.anyOf)&&e.anyOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)),Array.isArray(e.oneOf)&&e.oneOf.forEach(s=>this.addSchemaValueCompletions(s,t,i)))}addDefaultValueCompletions(e,t,i=0){let s=!1;if(typeof e.default<"u"){let r=e.type,o=e.default;for(let a=i;a>0;a--)o=[o],r="array";const l=Object.assign(Object.assign({type:r==null?void 0:r.toString()},this.getAppliedValue(o)),{detail:"Default value"});t.add(l),s=!0}Array.isArray(e.examples)&&e.examples.forEach(r=>{let o=e.type,l=r;for(let a=i;a>0;a--)l=[l],o="array";t.add(Object.assign({type:o==null?void 0:o.toString()},this.getAppliedValue(l))),s=!0}),!s&&typeof e.items=="object"&&!Array.isArray(e.items)&&i<5&&this.addDefaultValueCompletions(e.items,t,i+1)}addEnumValueCompletions(e,t){var i,s;if(typeof e.const<"u"&&t.add(Object.assign(Object.assign({type:(i=e.type)===null||i===void 0?void 0:i.toString()},this.getAppliedValue(e.const)),{info:e.description})),Array.isArray(e.enum))for(let r=0,o=e.enum.length;r<o;r++){const l=e.enum[r];t.add(Object.assign(Object.assign({type:(s=e.type)===null||s===void 0?void 0:s.toString()},this.getAppliedValue(l)),{info:e.description}))}}addBooleanValueCompletion(e,t){t.add({type:"boolean",label:e?"true":"false"})}addNullValueCompletion(e){e.add({type:"null",label:"null"})}collectTypes(e,t){if(Array.isArray(e.enum)||typeof e.const<"u")return;const i=e.type;Array.isArray(i)?i.forEach(s=>t[s]=!0):i&&(t[i]=!0)}getSchemas(e,t){var i,s;const r=new Of(this.schema);let o=nf(t.state,t.pos,-1,this.mode),l=r.getSchema({pointer:o});return Ql(l)&&(l=(i=l.data)===null||i===void 0?void 0:i.schema),(!l||l.name==="UnknownPropertyError"||l.enum||l.type==="undefined")&&(o=o.replace(/\/[^/]*$/,"/"),l=r.getSchema({pointer:o})),yt.log("xxx","pointer..",JSON.stringify(o)),(!o||o==="/")&&(l=(s=this.expandSchemaProperty(e,e))!==null&&s!==void 0?s:e),l?Array.isArray(l.allOf)?[l,...l.allOf.map(a=>this.expandSchemaProperty(a,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(a=>this.expandSchemaProperty(a,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(a=>this.expandSchemaProperty(a,e))]:[l]:[]}expandSchemaProperty(e,t){if(typeof e=="object"&&e.$ref){const i=this.getReferenceSchema(t,e.$ref);if(typeof i=="object"){const s=Object.assign(Object.assign({},e),i);return Reflect.deleteProperty(s,"$ref"),s}}return e}getReferenceSchema(e,t){const i=t.split("/");let s=e;return i.forEach(r=>{if(r){if(r==="#"){s=e;return}typeof s=="object"&&(s=s[r])}}),s}getAppliedValue(e){const t=wn(JSON.stringify(e));switch(this.mode){case $.JSON5:return{label:t,apply:Xy(JSON.stringify(e))};case $.YAML:return{label:t,apply:t};default:return{label:t,apply:JSON.stringify(e)}}}getValueFromLabel(e){return JSON.parse(e)}extendedRegExp(e){let t="";e.startsWith("(?i)")&&(e=e.substring(4),t="i");try{return new RegExp(e,t+"u")}catch{try{return new RegExp(e,t)}catch{return}}}}function Vb(n={}){const e=new nb(n);return function(i){return e.doComplete(i)}}const Ri=(n,e)=>{const t=n.length>2;let i=n.map((s,r)=>{const o="`"+(e?e(s):s)+"`";return r===n.length-1?"or "+o:o});return t?i.join(", "):i.join(" ")};function of(n){let e=null;try{e=JSON.parse(n.doc.toString())}catch{}const t=so(n,$.JSON);return{data:e,pointers:t}}function Ye(n,e,t=[]){const i=document.createElement(n);return Object.entries(e).forEach(([s,r])=>{if(s==="text"){i.innerText=r;return}if(s==="inner"){i.innerHTML=r;return}i.setAttribute(s,r)}),t.forEach(s=>i.appendChild(s)),i}function sb(n){let e=null;try{e=Df.parse(n.doc.toString())}catch{}const t=so(n,$.YAML);return{data:e,pointers:t}}function rb(n){let e=null;try{e=Ef.parse(n.doc.toString())}catch{}const t=so(n,$.JSON5);return{data:e,pointers:t}}const ob=n=>{switch(n){case $.JSON:return of;case $.JSON5:return rb;case $.YAML:return sb}},lb=n=>{var e,t,i;return!((e=n==null?void 0:n.data)===null||e===void 0)&&e.pointer&&((t=n==null?void 0:n.data)===null||t===void 0?void 0:t.pointer)!=="#"?n.data.pointer.slice(1):!((i=n==null?void 0:n.data)===null||i===void 0)&&i.property?`/${n.data.property}`:""},Hb=n=>n.startState.field(jn)!==n.state.field(jn);function Wb(n){const e=new hb(n);return t=>e.doValidation(t)}const ab=["NoAdditionalPropertiesError","RequiredPropertyError","InvalidPropertyNameError","ForbiddenPropertyError","UndefinedValueError"];class hb{constructor(e){var t,i,s,r;this.options=e,this.schema=null,this.mode=$.JSON,this.parser=of,this.rewriteError=o=>{var l,a,c,h,f;const u=o==null?void 0:o.data,d=u==null?void 0:u.errors;return o.code==="one-of-error"&&(d!=null&&d.length)?`Expected one of ${Ri(d,g=>g.data.expected)}`:o.code==="type-error"?`Expected \`${!((l=o==null?void 0:o.data)===null||l===void 0)&&l.expected&&Array.isArray((a=o==null?void 0:o.data)===null||a===void 0?void 0:a.expected)?Ri((c=o==null?void 0:o.data)===null||c===void 0?void 0:c.expected):(h=o==null?void 0:o.data)===null||h===void 0?void 0:h.expected}\` but received \`${(f=o==null?void 0:o.data)===null||f===void 0?void 0:f.received}\``:o.message.replaceAll("in `#` ","").replaceAll("at `#`","").replaceAll("/",".").replaceAll("#.","")},this.mode=(i=(t=this.options)===null||t===void 0?void 0:t.mode)!==null&&i!==void 0?i:$.JSON,this.parser=(r=(s=this.options)===null||s===void 0?void 0:s.jsonParser)!==null&&r!==void 0?r:ob(this.mode)}get schemaTitle(){var e,t,i;return(i=(t=(e=this.schema)===null||e===void 0?void 0:e.getSchema())===null||t===void 0?void 0:t.title)!==null&&i!==void 0?i:"json-schema"}doValidation(e){const t=ro(e.state);if(!t)return[];if(this.schema=new Zl(t),!this.schema)return[];const i=e.state.doc.toString();if(!(i!=null&&i.length))return[];const s=this.parser(e.state);let r=[];try{r=this.schema.validate(s.data)}catch{}return yt.log("xxx","validation errors",r,s.data),r.length?r.reduce((o,l)=>{const a=()=>{const f=this.rewriteError(l);o.push({from:0,to:0,message:f,severity:"error",source:this.schemaTitle,renderMessage:()=>{const u=Ye("div",{});return u.innerHTML=Wt(f),u}})},c=lb(l),h=s.pointers.get(c);if(l.name==="MaxPropertiesError"||l.name==="MinPropertiesError")a();else if(h){const f=ab.includes(l.name),u=this.rewriteError(l),d=f?h.keyFrom:h.valueFrom,p=f?h.keyTo:h.valueTo;p!==void 0&&d!==void 0&&o.push({from:d,to:p,message:u,renderMessage:()=>{const g=Ye("div",{});return g.innerHTML=Wt(u),g},severity:"error",source:this.schemaTitle})}else a();return o},[]):[]}}function $b(n){const e=new cb(n);return async function(i,s,r){return e.doHover(i,s,r)}}function Kl(n){if(n.type)return n.$ref?`${n.$ref} (${n.type})`:n.type;if(n.$ref)return`${n.$ref}`}function Ds(n,e,t){return`${e}: ${Ri(n[e].map(i=>{try{const{data:s}=t.resolveRef({data:i,pointer:i.$ref});return Kl(s||i)}catch{return i.type}}))}`}class cb{constructor(e){var t,i;this.opts=e,this.schema=null,this.mode=$.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=(i=(t=this.opts)===null||t===void 0?void 0:t.mode)!==null&&i!==void 0?i:$.JSON}getDataForCursor(e,t,i){const s=ro(e.state);if(!s)return null;this.schema=new Zl(s);const r=nf(e.state,t,i,this.mode);let o;try{o=this.opts.parser(e.state.doc.toString())}catch{}if(!r)return null;let l=this.schema.getSchema({pointer:r,data:o,withSchemaWarning:!0});return Ql(l)&&(l!=null&&l.data.schema.$ref?l=this.schema.resolveRef(l):l=l==null?void 0:l.data.schema),{schema:l,pointer:r}}formatMessage(e){const{message:t,typeInfo:i}=e;return t?Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--description",inner:Wt(t,!1)}),Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("div",{class:"cm6-json-schema-hover--code",inner:Wt(i,!1)})])]):Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("code",{class:"cm6-json-schema-hover--code",inner:Wt(i,!1)})])])}getHoverTexts(e,t){let i="",s=null;const{schema:r}=e;return r.oneOf&&(i=Ds(r,"oneOf",t)),r.anyOf&&(i=Ds(r,"anyOf",t)),r.allOf&&(i=Ds(r,"allOf",t)),r.type&&(i=Array.isArray(r.type)?Ri(r.type):r.type),r.$ref&&(i=` Reference: ${r.$ref}`),r.enum&&(i=`\`enum\`: ${Ri(r.enum)}`),r.format&&(i+=`\`format\`: ${r.format}`),r.pattern&&(i+=`\`pattern\`: ${r.pattern}`),r.description&&(s=r.description),{message:s,typeInfo:i}}async doHover(e,t,i){var s,r,o,l;const a=t,c=t;try{const h=this.getDataForCursor(e,t,i);if(yt.log("cursorData",h),!(h!=null&&h.schema))return null;const u=((r=(s=this.opts)===null||s===void 0?void 0:s.getHoverTexts)!==null&&r!==void 0?r:this.getHoverTexts)(h,this.schema),p=((l=(o=this.opts)===null||o===void 0?void 0:o.formatHover)!==null&&l!==void 0?l:this.formatMessage)(u);return{pos:a,end:c,arrow:!0,above:!0,create:g=>({dom:p})}}catch{return null}}}const _l=new ea,lf=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function hn(n){return(e,t,i)=>{if(i)return!1;let s=e.node.getChild("VariableName");return s&&t(s,n),!0}}const fb={FunctionDefinition:hn("function"),ClassDefinition:hn("class"),ForStatement(n,e,t){if(t){for(let i=n.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")e(i,"variable");else if(i.name=="in")break}},ImportStatement(n,e){var t,i;let{node:s}=n,r=((t=s.firstChild)===null||t===void 0?void 0:t.name)=="from";for(let o=s.getChild("import");o;o=o.nextSibling)o.name=="VariableName"&&((i=o.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&e(o,r?"variable":"namespace")},AssignStatement(n,e){for(let t=n.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(n,e){for(let t=null,i=n.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(i,"variable"),t=i},CapturePattern:hn("variable"),AsPattern:hn("variable"),__proto__:null};function af(n,e){let t=_l.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(Cr.IncludeAnonymous).iterate(o=>{if(o.name){let l=fb[o.name];if(l&&l(o,r,s)||!s&&lf.has(o.name))return!1;s=!1}else if(o.to-o.from>8192){for(let l of af(n,o.node))i.push(l);return!1}}),_l.set(e,i),i}const Jl=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,hf=["String","FormatString","Comment","PropertyName"];function ub(n){let e=j(n.state).resolveInner(n.pos,-1);if(hf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Jl.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)lf.has(s.name)&&(i=i.concat(af(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Jl}}const db=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(n=>({label:n,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(n=>({label:n,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(n=>({label:n,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(n=>({label:n,type:"function"}))),pb=[q("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),q("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),q("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),q("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),q(`if \${}:
11
11
 
12
- `,{label:"if",detail:"block",type:"keyword"}),q("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),q("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),q("import ${module}",{label:"import",detail:"statement",type:"keyword"}),q("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],mb=Nc(hf,Xr(db.concat(pb)));function Ul(n,e){let t=n.baseIndentFor(e),i=n.lineAt(n.pos,-1),s=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&n.node.to<s+100&&!/\S/.test(n.state.sliceDoc(s,n.node.to))&&n.lineIndent(n.pos,-1)<=t||/^\s*(else:|elif |except |finally:)/.test(n.textAfter)&&n.lineIndent(n.pos,-1)>t?null:t+n.unit}const Es=Kt.define({name:"python",parser:Bf.configure({props:[Gn.add({Body:n=>{var e;return(e=Ul(n,n.node))!==null&&e!==void 0?e:n.continue()},IfStatement:n=>/^\s*(else:|elif )/.test(n.textAfter)?n.baseIndent:n.continue(),TryStatement:n=>/^\s*(except |finally:|else:)/.test(n.textAfter)?n.baseIndent:n.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":vn({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":vn({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":vn({closing:"]"}),"String FormatString":()=>null,Script:n=>{if(n.pos+/\s*/.exec(n.textAfter)[0].length>=n.node.to){let e=null;for(let t=n.node,i=t.to;t=t.lastChild,!(!t||t.to!=i);)t.type.name=="Body"&&(e=t);if(e){let t=Ul(n,e);if(t!=null)return t}}return n.continue()}}),Xn.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":$r,Body:(n,e)=>({from:n.from+1,to:n.to-(n.to==e.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/}});function $b(){return new Vr(Es,[Es.data.of({autocomplete:ub}),Es.data.of({autocomplete:mb})])}const cf=[q("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),q("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),q("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),q("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),q("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),q(`try {
12
+ `,{label:"if",detail:"block",type:"keyword"}),q("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),q("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),q("import ${module}",{label:"import",detail:"statement",type:"keyword"}),q("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],mb=Nc(hf,Xr(db.concat(pb)));function Ul(n,e){let t=n.baseIndentFor(e),i=n.lineAt(n.pos,-1),s=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&n.node.to<s+100&&!/\S/.test(n.state.sliceDoc(s,n.node.to))&&n.lineIndent(n.pos,-1)<=t||/^\s*(else:|elif |except |finally:)/.test(n.textAfter)&&n.lineIndent(n.pos,-1)>t?null:t+n.unit}const Es=Kt.define({name:"python",parser:Pf.configure({props:[Gn.add({Body:n=>{var e;return(e=Ul(n,n.node))!==null&&e!==void 0?e:n.continue()},IfStatement:n=>/^\s*(else:|elif )/.test(n.textAfter)?n.baseIndent:n.continue(),TryStatement:n=>/^\s*(except |finally:|else:)/.test(n.textAfter)?n.baseIndent:n.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":vn({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":vn({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":vn({closing:"]"}),"String FormatString":()=>null,Script:n=>{if(n.pos+/\s*/.exec(n.textAfter)[0].length>=n.node.to){let e=null;for(let t=n.node,i=t.to;t=t.lastChild,!(!t||t.to!=i);)t.type.name=="Body"&&(e=t);if(e){let t=Ul(n,e);if(t!=null)return t}}return n.continue()}}),Xn.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":$r,Body:(n,e)=>({from:n.from+1,to:n.to-(n.to==e.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/}});function zb(){return new Vr(Es,[Es.data.of({autocomplete:ub}),Es.data.of({autocomplete:mb})])}const cf=[q("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),q("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),q("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),q("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),q("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),q(`try {
13
13
  \${}
14
14
  } catch (\${error}) {
15
15
  \${}
@@ -21,4 +21,4 @@ import{c1 as at,c2 as yf,c3 as bf,c4 as vf,y as m,c5 as kr,x as xf,c6 as Ae,c7 a
21
21
  constructor(\${params}) {
22
22
  \${}
23
23
  }
24
- }`,{label:"class",detail:"definition",type:"keyword"}),q('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),q('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],gb=cf.concat([q("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),q("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),q("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Yl=new ea,ff=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function oi(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const yb=["FunctionDeclaration"],bb={FunctionDeclaration:oi("function"),ClassDeclaration:oi("class"),ClassExpression:()=>!0,EnumDeclaration:oi("constant"),TypeAliasDeclaration:oi("type"),NamespaceDeclaration:oi("namespace"),VariableDefinition(n,e){n.matchContext(yb)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function uf(n,e){let t=Yl.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(Cr.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=bb[o.name];if(l&&l(o,r)||ff.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of uf(n,o.node))i.push(l);return!1}}),Yl.set(e,i),i}const Gl=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,df=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function vb(n){let e=j(n.state).resolveInner(n.pos,-1);if(df.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Gl.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)ff.has(s.name)&&(i=i.concat(uf(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Gl}}const xt=Kt.define({name:"javascript",parser:Rf.configure({props:[Gn.add({IfStatement:yi({except:/^\s*({|else\b)/}),TryStatement:yi({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Rp,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:vn({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":yi({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Xn.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":$r,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),pf={test:n=>/^JSX/.test(n.name),facet:Th({commentTokens:{block:{open:"{/*",close:"*/}"}}})},xb=xt.configure({dialect:"ts"},"typescript"),wb=xt.configure({dialect:"jsx",props:[Fr.add(n=>n.isTop?[pf]:void 0)]}),Sb=xt.configure({dialect:"jsx ts",props:[Fr.add(n=>n.isTop?[pf]:void 0)]},"typescript");let mf=n=>({label:n,type:"keyword"});const gf="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(mf),kb=gf.concat(["declare","implements","private","protected","public"].map(mf));function zb(n={}){let e=n.jsx?n.typescript?Sb:wb:n.typescript?xb:xt,t=n.typescript?gb.concat(kb):cf.concat(gf);return new Vr(e,[xt.data.of({autocomplete:Nc(df,Xr(t))}),xt.data.of({autocomplete:vb}),n.jsx?Mb:[]])}function Cb(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function Xl(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const Ab=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Mb=w.inputHandler.of((n,e,t,i,s)=>{if((Ab?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!xt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var c;let{head:h}=a,f=j(o).resolveInner(h-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(h-1,h)!=i||f.name=="JSXAttributeValue"&&f.to>h)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:"</>"}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==h-2&&((u=Xl(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let g=`${u}>`;return{range:v.cursor(h+g.length,-1),changes:{from:h,insert:g}}}}else if(i==">"){let d=Cb(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(u=Xl(o.doc,d,h)))return{range:a,changes:{from:h,insert:`</${u}>`}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});export{w as E,Kt as L,Ly as R,Vr as a,Hb as b,dm as c,Fb as d,fp as e,Wb as f,Rb as g,Vb as h,Pb as i,Eb as j,zb as k,Bb as l,Gt as m,Lb as n,my as o,$b as p,Nb as s};
24
+ }`,{label:"class",detail:"definition",type:"keyword"}),q('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),q('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],gb=cf.concat([q("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),q("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),q("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Yl=new ea,ff=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function oi(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const yb=["FunctionDeclaration"],bb={FunctionDeclaration:oi("function"),ClassDeclaration:oi("class"),ClassExpression:()=>!0,EnumDeclaration:oi("constant"),TypeAliasDeclaration:oi("type"),NamespaceDeclaration:oi("namespace"),VariableDefinition(n,e){n.matchContext(yb)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function uf(n,e){let t=Yl.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(Cr.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=bb[o.name];if(l&&l(o,r)||ff.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of uf(n,o.node))i.push(l);return!1}}),Yl.set(e,i),i}const Gl=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,df=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function vb(n){let e=j(n.state).resolveInner(n.pos,-1);if(df.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Gl.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)ff.has(s.name)&&(i=i.concat(uf(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Gl}}const xt=Kt.define({name:"javascript",parser:Bf.configure({props:[Gn.add({IfStatement:yi({except:/^\s*({|else\b)/}),TryStatement:yi({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Rp,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:vn({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":yi({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Xn.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":$r,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),pf={test:n=>/^JSX/.test(n.name),facet:Th({commentTokens:{block:{open:"{/*",close:"*/}"}}})},xb=xt.configure({dialect:"ts"},"typescript"),wb=xt.configure({dialect:"jsx",props:[Fr.add(n=>n.isTop?[pf]:void 0)]}),Sb=xt.configure({dialect:"jsx ts",props:[Fr.add(n=>n.isTop?[pf]:void 0)]},"typescript");let mf=n=>({label:n,type:"keyword"});const gf="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(mf),kb=gf.concat(["declare","implements","private","protected","public"].map(mf));function jb(n={}){let e=n.jsx?n.typescript?Sb:wb:n.typescript?xb:xt,t=n.typescript?gb.concat(kb):cf.concat(gf);return new Vr(e,[xt.data.of({autocomplete:Nc(df,Xr(t))}),xt.data.of({autocomplete:vb}),n.jsx?Mb:[]])}function Cb(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function Xl(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const Ab=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Mb=w.inputHandler.of((n,e,t,i,s)=>{if((Ab?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!xt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var c;let{head:h}=a,f=j(o).resolveInner(h-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(h-1,h)!=i||f.name=="JSXAttributeValue"&&f.to>h)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:"</>"}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==h-2&&((u=Xl(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let g=`${u}>`;return{range:v.cursor(h+g.length,-1),changes:{from:h,insert:g}}}}else if(i==">"){let d=Cb(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(u=Xl(o.doc,d,h)))return{range:a,changes:{from:h,insert:`</${u}>`}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});export{w as E,Kt as L,Ly as R,Vr as a,Wb as b,dm as c,Vb as d,fp as e,$b as f,Lb as g,Hb as h,Bb as i,Pb as j,jb as k,Rb as l,Gt as m,Ib as n,my as o,zb as p,Fb as s};