arize-phoenix 11.38.0__py3-none-any.whl → 12.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 (84) hide show
  1. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/METADATA +3 -3
  2. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/RECORD +83 -58
  3. phoenix/config.py +1 -11
  4. phoenix/db/bulk_inserter.py +8 -0
  5. phoenix/db/facilitator.py +1 -1
  6. phoenix/db/helpers.py +202 -33
  7. phoenix/db/insertion/dataset.py +7 -0
  8. phoenix/db/insertion/document_annotation.py +1 -1
  9. phoenix/db/insertion/helpers.py +2 -2
  10. phoenix/db/insertion/session_annotation.py +176 -0
  11. phoenix/db/insertion/span_annotation.py +1 -1
  12. phoenix/db/insertion/trace_annotation.py +1 -1
  13. phoenix/db/insertion/types.py +29 -3
  14. phoenix/db/migrations/versions/01a8342c9cdf_add_user_id_on_datasets.py +40 -0
  15. phoenix/db/migrations/versions/0df286449799_add_session_annotations_table.py +105 -0
  16. phoenix/db/migrations/versions/272b66ff50f8_drop_single_indices.py +119 -0
  17. phoenix/db/migrations/versions/58228d933c91_dataset_labels.py +67 -0
  18. phoenix/db/migrations/versions/699f655af132_experiment_tags.py +57 -0
  19. phoenix/db/migrations/versions/735d3d93c33e_add_composite_indices.py +41 -0
  20. phoenix/db/migrations/versions/ab513d89518b_add_user_id_on_dataset_versions.py +40 -0
  21. phoenix/db/migrations/versions/d0690a79ea51_users_on_experiments.py +40 -0
  22. phoenix/db/migrations/versions/deb2c81c0bb2_dataset_splits.py +139 -0
  23. phoenix/db/migrations/versions/e76cbd66ffc3_add_experiments_dataset_examples.py +87 -0
  24. phoenix/db/models.py +306 -46
  25. phoenix/server/api/context.py +15 -2
  26. phoenix/server/api/dataloaders/__init__.py +8 -2
  27. phoenix/server/api/dataloaders/dataset_example_splits.py +40 -0
  28. phoenix/server/api/dataloaders/dataset_labels.py +36 -0
  29. phoenix/server/api/dataloaders/session_annotations_by_session.py +29 -0
  30. phoenix/server/api/dataloaders/table_fields.py +2 -2
  31. phoenix/server/api/dataloaders/trace_annotations_by_trace.py +27 -0
  32. phoenix/server/api/helpers/playground_clients.py +66 -35
  33. phoenix/server/api/helpers/playground_users.py +26 -0
  34. phoenix/server/api/input_types/{SpanAnnotationFilter.py → AnnotationFilter.py} +22 -14
  35. phoenix/server/api/input_types/CreateProjectSessionAnnotationInput.py +37 -0
  36. phoenix/server/api/input_types/UpdateAnnotationInput.py +34 -0
  37. phoenix/server/api/mutations/__init__.py +8 -0
  38. phoenix/server/api/mutations/chat_mutations.py +8 -3
  39. phoenix/server/api/mutations/dataset_label_mutations.py +291 -0
  40. phoenix/server/api/mutations/dataset_mutations.py +5 -0
  41. phoenix/server/api/mutations/dataset_split_mutations.py +423 -0
  42. phoenix/server/api/mutations/project_session_annotations_mutations.py +161 -0
  43. phoenix/server/api/queries.py +53 -0
  44. phoenix/server/api/routers/auth.py +5 -5
  45. phoenix/server/api/routers/oauth2.py +5 -23
  46. phoenix/server/api/routers/v1/__init__.py +2 -0
  47. phoenix/server/api/routers/v1/annotations.py +320 -0
  48. phoenix/server/api/routers/v1/datasets.py +5 -0
  49. phoenix/server/api/routers/v1/experiments.py +10 -3
  50. phoenix/server/api/routers/v1/sessions.py +111 -0
  51. phoenix/server/api/routers/v1/traces.py +1 -2
  52. phoenix/server/api/routers/v1/users.py +7 -0
  53. phoenix/server/api/subscriptions.py +5 -2
  54. phoenix/server/api/types/Dataset.py +8 -0
  55. phoenix/server/api/types/DatasetExample.py +18 -0
  56. phoenix/server/api/types/DatasetLabel.py +23 -0
  57. phoenix/server/api/types/DatasetSplit.py +32 -0
  58. phoenix/server/api/types/Experiment.py +0 -4
  59. phoenix/server/api/types/Project.py +16 -0
  60. phoenix/server/api/types/ProjectSession.py +88 -3
  61. phoenix/server/api/types/ProjectSessionAnnotation.py +68 -0
  62. phoenix/server/api/types/Prompt.py +18 -1
  63. phoenix/server/api/types/Span.py +5 -5
  64. phoenix/server/api/types/Trace.py +61 -0
  65. phoenix/server/app.py +13 -14
  66. phoenix/server/cost_tracking/model_cost_manifest.json +132 -2
  67. phoenix/server/dml_event.py +13 -0
  68. phoenix/server/static/.vite/manifest.json +39 -39
  69. phoenix/server/static/assets/{components-BQPHTBfv.js → components-BG6v0EM8.js} +705 -385
  70. phoenix/server/static/assets/{index-BL5BMgJU.js → index-CSVcULw1.js} +13 -13
  71. phoenix/server/static/assets/{pages-C0Y17J0T.js → pages-DgaM7kpM.js} +1356 -1155
  72. phoenix/server/static/assets/{vendor-BdjZxMii.js → vendor-BqTEkGQU.js} +183 -183
  73. phoenix/server/static/assets/{vendor-arizeai-CHYlS8jV.js → vendor-arizeai-DlOj0PQQ.js} +15 -24
  74. phoenix/server/static/assets/{vendor-codemirror-Di6t4HnH.js → vendor-codemirror-B2PHH5yZ.js} +3 -3
  75. phoenix/server/static/assets/{vendor-recharts-C9wCDYj3.js → vendor-recharts-CKsi4IjN.js} +1 -1
  76. phoenix/server/static/assets/{vendor-shiki-MNnmOotP.js → vendor-shiki-DN26BkKE.js} +1 -1
  77. phoenix/server/utils.py +74 -0
  78. phoenix/session/session.py +25 -5
  79. phoenix/version.py +1 -1
  80. phoenix/server/api/dataloaders/experiment_repetition_counts.py +0 -39
  81. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/WHEEL +0 -0
  82. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/entry_points.txt +0 -0
  83. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/licenses/IP_NOTICE +0 -0
  84. {arize_phoenix-11.38.0.dist-info → arize_phoenix-12.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-MNnmOotP.js","assets/vendor-BdjZxMii.js","assets/vendor-three-BLWp5bic.js","assets/vendor-BGzfc4EU.css"])))=>i.map(i=>d[i]);
2
- import{dp as Uf,dq as tt,dr as Yf,ds as Gf,dt as Xf,du as Oe,dv as Fe,dw as Gn,dx as dt,dy as Ma,dz as Zt,dA as Ea,dB as Ta,aP as E,aO as Oa,dC as Qf,dD as G,dE as Da,r as Me,dF as Zf,dG as eu,dH as tu,dI as Pa,dJ as iu,dK as vs,dL as Ra,dM as nu,dN as su,dO as ru,dP as Ba,dQ as La,dR as ou,dS as Ia,dT as lu}from"./vendor-BdjZxMii.js";import{c as au,f as hu}from"./vendor-shiki-MNnmOotP.js";var xs={},Bo;function cu(){return Bo||(Bo=1,(function(i){var e=Uf();class t{lineAt(h){if(h<0||h>this.length)throw new RangeError(`Invalid position ${h} in document of length ${this.length}`);return this.lineInner(h,!1,1,0)}line(h){if(h<1||h>this.lines)throw new RangeError(`Invalid line number ${h} in ${this.lines}-line document`);return this.lineInner(h,!0,1,0)}replace(h,u,d){[h,u]=g(this,h,u);let m=[];return this.decompose(0,h,m,2),d.length&&d.decompose(0,d.length,m,3),this.decompose(u,this.length,m,1),s.from(m,this.length-(u-h)+d.length)}append(h){return this.replace(this.length,this.length,h)}slice(h,u=this.length){[h,u]=g(this,h,u);let d=[];return this.decompose(h,u,d,0),s.from(d,u-h)}eq(h){if(h==this)return!0;if(h.length!=this.length||h.lines!=this.lines)return!1;let u=this.scanIdentical(h,1),d=this.length-this.scanIdentical(h,-1),m=new a(this),b=new a(h);for(let S=u,w=u;;){if(m.next(S),b.next(S),S=0,m.lineBreak!=b.lineBreak||m.done!=b.done||m.value!=b.value)return!1;if(w+=m.value.length,m.done||w>=d)return!0}}iter(h=1){return new a(this,h)}iterRange(h,u=this.length){return new f(this,h,u)}iterLines(h,u){let d;if(h==null)d=this.iter();else{u==null&&(u=this.lines+1);let m=this.line(h).from;d=this.iterRange(m,Math.max(m,u==this.lines+1?this.length:u<=1?0:this.line(u-1).to))}return new c(d)}toString(){return this.sliceString(0)}toJSON(){let h=[];return this.flatten(h),h}constructor(){}static of(h){if(h.length==0)throw new RangeError("A document must have at least one line");return h.length==1&&!h[0]?t.empty:h.length<=32?new n(h):s.from(n.split(h,[]))}}class n extends t{constructor(h,u=r(h)){super(),this.text=h,this.length=u}get lines(){return this.text.length}get children(){return null}lineInner(h,u,d,m){for(let b=0;;b++){let S=this.text[b],w=m+S.length;if((u?d:w)>=h)return new p(m,w,d,S);m=w+1,d++}}decompose(h,u,d,m){let b=h<=0&&u>=this.length?this:new n(l(this.text,h,u),Math.min(u,this.length)-Math.max(0,h));if(m&1){let S=d.pop(),w=o(b.text,S.text.slice(),0,b.length);if(w.length<=32)d.push(new n(w,S.length+b.length));else{let A=w.length>>1;d.push(new n(w.slice(0,A)),new n(w.slice(A)))}}else d.push(b)}replace(h,u,d){if(!(d instanceof n))return super.replace(h,u,d);[h,u]=g(this,h,u);let m=o(this.text,o(d.text,l(this.text,0,h)),u),b=this.length+d.length-(u-h);return m.length<=32?new n(m,b):s.from(n.split(m,[]),b)}sliceString(h,u=this.length,d=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-DN26BkKE.js","assets/vendor-BqTEkGQU.js","assets/vendor-three-BLWp5bic.js","assets/vendor-BGzfc4EU.css"])))=>i.map(i=>d[i]);
2
+ import{ds as Uf,dt as tt,du as Yf,dv as Gf,dw as Xf,dx as Oe,dy as Fe,dz as Gn,dA as dt,dB as Ma,dC as Zt,dD as Ea,dE as Ta,A as E,z as Oa,dF as Qf,dG as G,dH as Da,r as Me,dI as Zf,dJ as eu,dK as tu,dL as Pa,dM as iu,dN as vs,dO as Ra,dP as nu,dQ as su,dR as ru,dS as Ba,dT as La,dU as ou,dV as Ia,dW as lu}from"./vendor-BqTEkGQU.js";import{c as au,f as hu}from"./vendor-shiki-DN26BkKE.js";var xs={},Bo;function cu(){return Bo||(Bo=1,(function(i){var e=Uf();class t{lineAt(h){if(h<0||h>this.length)throw new RangeError(`Invalid position ${h} in document of length ${this.length}`);return this.lineInner(h,!1,1,0)}line(h){if(h<1||h>this.lines)throw new RangeError(`Invalid line number ${h} in ${this.lines}-line document`);return this.lineInner(h,!0,1,0)}replace(h,u,d){[h,u]=g(this,h,u);let m=[];return this.decompose(0,h,m,2),d.length&&d.decompose(0,d.length,m,3),this.decompose(u,this.length,m,1),s.from(m,this.length-(u-h)+d.length)}append(h){return this.replace(this.length,this.length,h)}slice(h,u=this.length){[h,u]=g(this,h,u);let d=[];return this.decompose(h,u,d,0),s.from(d,u-h)}eq(h){if(h==this)return!0;if(h.length!=this.length||h.lines!=this.lines)return!1;let u=this.scanIdentical(h,1),d=this.length-this.scanIdentical(h,-1),m=new a(this),b=new a(h);for(let S=u,w=u;;){if(m.next(S),b.next(S),S=0,m.lineBreak!=b.lineBreak||m.done!=b.done||m.value!=b.value)return!1;if(w+=m.value.length,m.done||w>=d)return!0}}iter(h=1){return new a(this,h)}iterRange(h,u=this.length){return new f(this,h,u)}iterLines(h,u){let d;if(h==null)d=this.iter();else{u==null&&(u=this.lines+1);let m=this.line(h).from;d=this.iterRange(m,Math.max(m,u==this.lines+1?this.length:u<=1?0:this.line(u-1).to))}return new c(d)}toString(){return this.sliceString(0)}toJSON(){let h=[];return this.flatten(h),h}constructor(){}static of(h){if(h.length==0)throw new RangeError("A document must have at least one line");return h.length==1&&!h[0]?t.empty:h.length<=32?new n(h):s.from(n.split(h,[]))}}class n extends t{constructor(h,u=r(h)){super(),this.text=h,this.length=u}get lines(){return this.text.length}get children(){return null}lineInner(h,u,d,m){for(let b=0;;b++){let S=this.text[b],w=m+S.length;if((u?d:w)>=h)return new p(m,w,d,S);m=w+1,d++}}decompose(h,u,d,m){let b=h<=0&&u>=this.length?this:new n(l(this.text,h,u),Math.min(u,this.length)-Math.max(0,h));if(m&1){let S=d.pop(),w=o(b.text,S.text.slice(),0,b.length);if(w.length<=32)d.push(new n(w,S.length+b.length));else{let A=w.length>>1;d.push(new n(w.slice(0,A)),new n(w.slice(A)))}}else d.push(b)}replace(h,u,d){if(!(d instanceof n))return super.replace(h,u,d);[h,u]=g(this,h,u);let m=o(this.text,o(d.text,l(this.text,0,h)),u),b=this.length+d.length-(u-h);return m.length<=32?new n(m,b):s.from(n.split(m,[]),b)}sliceString(h,u=this.length,d=`
3
3
  `){[h,u]=g(this,h,u);let m="";for(let b=0,S=0;b<=u&&S<this.text.length;S++){let w=this.text[S],A=b+w.length;b>h&&S&&(m+=d),h<A&&u>b&&(m+=w.slice(Math.max(0,h-b),u-b)),b=A+1}return m}flatten(h){for(let u of this.text)h.push(u)}scanIdentical(){return 0}static split(h,u){let d=[],m=-1;for(let b of h)d.push(b),m+=b.length+1,d.length==32&&(u.push(new n(d,m)),d=[],m=-1);return m>-1&&u.push(new n(d,m)),u}}class s extends t{constructor(h,u){super(),this.children=h,this.length=u,this.lines=0;for(let d of h)this.lines+=d.lines}lineInner(h,u,d,m){for(let b=0;;b++){let S=this.children[b],w=m+S.length,A=d+S.lines-1;if((u?A:w)>=h)return S.lineInner(h,u,d,m);m=w+1,d=A+1}}decompose(h,u,d,m){for(let b=0,S=0;S<=u&&b<this.children.length;b++){let w=this.children[b],A=S+w.length;if(h<=A&&u>=S){let O=m&((S<=h?1:0)|(A>=u?2:0));S>=h&&A<=u&&!O?d.push(w):w.decompose(h-S,u-S,d,O)}S=A+1}}replace(h,u,d){if([h,u]=g(this,h,u),d.lines<this.lines)for(let m=0,b=0;m<this.children.length;m++){let S=this.children[m],w=b+S.length;if(h>=b&&u<=w){let A=S.replace(h-b,u-b,d),O=this.lines-S.lines+A.lines;if(A.lines<O>>4&&A.lines>O>>6){let D=this.children.slice();return D[m]=A,new s(D,this.length-(u-h)+d.length)}return super.replace(b,w,A)}b=w+1}return super.replace(h,u,d)}sliceString(h,u=this.length,d=`
4
4
  `){[h,u]=g(this,h,u);let m="";for(let b=0,S=0;b<this.children.length&&S<=u;b++){let w=this.children[b],A=S+w.length;S>h&&b&&(m+=d),h<A&&u>S&&(m+=w.sliceString(h-S,u-S,d)),S=A+1}return m}flatten(h){for(let u of this.children)u.flatten(h)}scanIdentical(h,u){if(!(h instanceof s))return 0;let d=0,[m,b,S,w]=u>0?[0,0,this.children.length,h.children.length]:[this.children.length-1,h.children.length-1,-1,-1];for(;;m+=u,b+=u){if(m==S||b==w)return d;let A=this.children[m],O=h.children[b];if(A!=O)return d+A.scanIdentical(O,u);d+=A.length+1}}static from(h,u=h.reduce((d,m)=>d+m.length+1,-1)){let d=0;for(let W of h)d+=W.lines;if(d<32){let W=[];for(let Z of h)Z.flatten(W);return new n(W,u)}let m=Math.max(32,d>>5),b=m<<1,S=m>>1,w=[],A=0,O=-1,D=[];function B(W){let Z;if(W.lines>b&&W instanceof s)for(let Je of W.children)B(Je);else W.lines>S&&(A>S||!A)?($(),w.push(W)):W instanceof n&&A&&(Z=D[D.length-1])instanceof n&&W.lines+Z.lines<=32?(A+=W.lines,O+=W.length+1,D[D.length-1]=new n(Z.text.concat(W.text),Z.length+1+W.length)):(A+W.lines>m&&$(),A+=W.lines,O+=W.length+1,D.push(W))}function $(){A!=0&&(w.push(D.length==1?D[0]:s.from(D,O)),O=-1,A=D.length=0)}for(let W of h)B(W);return $(),w.length==1?w[0]:new s(w,u)}}t.empty=new n([""],0);function r(x){let h=-1;for(let u of x)h+=u.length+1;return h}function o(x,h,u=0,d=1e9){for(let m=0,b=0,S=!0;b<x.length&&m<=d;b++){let w=x[b],A=m+w.length;A>=u&&(A>d&&(w=w.slice(0,d-m)),m<u&&(w=w.slice(u-m)),S?(h[h.length-1]+=w,S=!1):h.push(w)),m=A+1}return h}function l(x,h,u){return o(x,[""],h,u)}class a{constructor(h,u=1){this.dir=u,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[h],this.offsets=[u>0?1:(h instanceof n?h.text.length:h.children.length)<<1]}nextInner(h,u){for(this.done=this.lineBreak=!1;;){let d=this.nodes.length-1,m=this.nodes[d],b=this.offsets[d],S=b>>1,w=m instanceof n?m.text.length:m.children.length;if(S==(u>0?w:0)){if(d==0)return this.done=!0,this.value="",this;u>0&&this.offsets[d-1]++,this.nodes.pop(),this.offsets.pop()}else if((b&1)==(u>0?0:1)){if(this.offsets[d]+=u,h==0)return this.lineBreak=!0,this.value=`
5
5
  `,this;h--}else if(m instanceof n){let A=m.text[S+(u<0?-1:0)];if(this.offsets[d]+=u,A.length>Math.max(0,h))return this.value=h==0?A:u>0?A.slice(h):A.slice(0,A.length-h),this;h-=A.length}else{let A=m.children[S+(u<0?-1:0)];h>A.length?(h-=A.length,this.offsets[d]+=u):(u<0&&this.offsets[d]--,this.nodes.push(A),this.offsets.push(u>0?1:(A instanceof n?A.text.length:A.children.length)<<1))}}}next(h=0){return h<0&&(this.nextInner(-h,-this.dir),h=this.value.length),this.nextInner(h,this.dir)}}class f{constructor(h,u,d){this.value="",this.done=!1,this.cursor=new a(h,u>d?-1:1),this.pos=u>d?h.length:0,this.from=Math.min(u,d),this.to=Math.max(u,d)}nextInner(h,u){if(u<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;h+=Math.max(0,u<0?this.pos-this.to:this.from-this.pos);let d=u<0?this.pos-this.from:this.to-this.pos;h>d&&(h=d),d-=h;let{value:m}=this.cursor.next(h);return this.pos+=(m.length+h)*u,this.value=m.length<=d?m:u<0?m.slice(m.length-d):m.slice(0,d),this.done=!this.value,this}next(h=0){return h<0?h=Math.max(h,this.from-this.pos):h>0&&(h=Math.min(h,this.to-this.pos)),this.nextInner(h,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class c{constructor(h){this.inner=h,this.afterBreak=!0,this.value="",this.done=!1}next(h=0){let{done:u,lineBreak:d,value:m}=this.inner.next(h);return u&&this.afterBreak?(this.value="",this.afterBreak=!1):u?(this.done=!0,this.value=""):d?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=m,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=function(){return this.iter()},a.prototype[Symbol.iterator]=f.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class p{constructor(h,u,d,m){this.from=h,this.to=u,this.number=d,this.text=m}get length(){return this.to-this.from}}function g(x,h,u){return h=Math.max(0,Math.min(x.length,h)),[h,Math.max(h,Math.min(x.length,u))]}function v(x,h,u=!0,d=!0){return e.findClusterBreak(x,h,u,d)}function k(x){return x>=56320&&x<57344}function C(x){return x>=55296&&x<56320}function M(x,h){let u=x.charCodeAt(h);if(!C(u)||h+1==x.length)return u;let d=x.charCodeAt(h+1);return k(d)?(u-55296<<10)+(d-56320)+65536:u}function T(x){return x<=65535?String.fromCharCode(x):(x-=65536,String.fromCharCode((x>>10)+55296,(x&1023)+56320))}function P(x){return x<65536?1:2}const F=/\r\n?|\n/;i.MapMode=void 0,(function(x){x[x.Simple=0]="Simple",x[x.TrackDel=1]="TrackDel",x[x.TrackBefore=2]="TrackBefore",x[x.TrackAfter=3]="TrackAfter"})(i.MapMode||(i.MapMode={}));class I{constructor(h){this.sections=h}get length(){let h=0;for(let u=0;u<this.sections.length;u+=2)h+=this.sections[u];return h}get newLength(){let h=0;for(let u=0;u<this.sections.length;u+=2){let d=this.sections[u+1];h+=d<0?this.sections[u]:d}return h}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(h){for(let u=0,d=0,m=0;u<this.sections.length;){let b=this.sections[u++],S=this.sections[u++];S<0?(h(d,m,b),m+=b):m+=S,d+=b}}iterChangedRanges(h,u=!1){Y(this,h,u)}get invertedDesc(){let h=[];for(let u=0;u<this.sections.length;){let d=this.sections[u++],m=this.sections[u++];m<0?h.push(d,m):h.push(m,d)}return new I(h)}composeDesc(h){return this.empty?h:h.empty?this:me(this,h)}mapDesc(h,u=!1){return h.empty?this:_(this,h,u)}mapPos(h,u=-1,d=i.MapMode.Simple){let m=0,b=0;for(let S=0;S<this.sections.length;){let w=this.sections[S++],A=this.sections[S++],O=m+w;if(A<0){if(O>h)return b+(h-m);b+=w}else{if(d!=i.MapMode.Simple&&O>=h&&(d==i.MapMode.TrackDel&&m<h&&O>h||d==i.MapMode.TrackBefore&&m<h||d==i.MapMode.TrackAfter&&O>h))return null;if(O>h||O==h&&u<0&&!w)return h==m||u<0?b:b+A;b+=A}m=O}if(h>m)throw new RangeError(`Position ${h} is out of range for changeset of length ${m}`);return b}touchesRange(h,u=h){for(let d=0,m=0;d<this.sections.length&&m<=u;){let b=this.sections[d++],S=this.sections[d++],w=m+b;if(S>=0&&m<=u&&w>=h)return m<h&&w>u?"cover":!0;m=w}return!1}toString(){let h="";for(let u=0;u<this.sections.length;){let d=this.sections[u++],m=this.sections[u++];h+=(h?" ":"")+d+(m>=0?":"+m:"")}return h}toJSON(){return this.sections}static fromJSON(h){if(!Array.isArray(h)||h.length%2||h.some(u=>typeof u!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new I(h)}static create(h){return new I(h)}}class R extends I{constructor(h,u){super(h),this.inserted=u}apply(h){if(this.length!=h.length)throw new RangeError("Applying change set to a document with the wrong length");return Y(this,(u,d,m,b,S)=>h=h.replace(m,m+(d-u),S),!1),h}mapDesc(h,u=!1){return _(this,h,u,!0)}invert(h){let u=this.sections.slice(),d=[];for(let m=0,b=0;m<u.length;m+=2){let S=u[m],w=u[m+1];if(w>=0){u[m]=w,u[m+1]=S;let A=m>>1;for(;d.length<A;)d.push(t.empty);d.push(S?h.slice(b,b+S):t.empty)}b+=S}return new R(u,d)}compose(h){return this.empty?h:h.empty?this:me(this,h,!0)}map(h,u=!1){return h.empty?this:_(this,h,u,!0)}iterChanges(h,u=!1){Y(this,h,u)}get desc(){return I.create(this.sections)}filter(h){let u=[],d=[],m=[],b=new Ae(this);e:for(let S=0,w=0;;){let A=S==h.length?1e9:h[S++];for(;w<A||w==A&&b.len==0;){if(b.done)break e;let D=Math.min(b.len,A-w);N(m,D,-1);let B=b.ins==-1?-1:b.off==0?b.ins:0;N(u,D,B),B>0&&z(d,u,b.text),b.forward(D),w+=D}let O=h[S++];for(;w<O;){if(b.done)break e;let D=Math.min(b.len,O-w);N(u,D,-1),N(m,D,b.ins==-1?-1:b.off==0?b.ins:0),b.forward(D),w+=D}}return{changes:new R(u,d),filtered:I.create(m)}}toJSON(){let h=[];for(let u=0;u<this.sections.length;u+=2){let d=this.sections[u],m=this.sections[u+1];m<0?h.push(d):m==0?h.push([d]):h.push([d].concat(this.inserted[u>>1].toJSON()))}return h}static of(h,u,d){let m=[],b=[],S=0,w=null;function A(D=!1){if(!D&&!m.length)return;S<u&&N(m,u-S,-1);let B=new R(m,b);w=w?w.compose(B.map(w)):B,m=[],b=[],S=0}function O(D){if(Array.isArray(D))for(let B of D)O(B);else if(D instanceof R){if(D.length!=u)throw new RangeError(`Mismatched change set length (got ${D.length}, expected ${u})`);A(),w=w?w.compose(D.map(w)):D}else{let{from:B,to:$=B,insert:W}=D;if(B>$||B<0||$>u)throw new RangeError(`Invalid change range ${B} to ${$} (in doc of length ${u})`);let Z=W?typeof W=="string"?t.of(W.split(d||F)):W:t.empty,Je=Z.length;if(B==$&&Je==0)return;B<S&&A(),B>S&&N(m,B-S,-1),N(m,$-B,Je),z(b,m,Z),S=$}}return O(h),A(!w),w}static empty(h){return new R(h?[h,-1]:[],[])}static fromJSON(h){if(!Array.isArray(h))throw new RangeError("Invalid JSON representation of ChangeSet");let u=[],d=[];for(let m=0;m<h.length;m++){let b=h[m];if(typeof b=="number")u.push(b,-1);else{if(!Array.isArray(b)||typeof b[0]!="number"||b.some((S,w)=>w&&typeof S!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(b.length==1)u.push(b[0],0);else{for(;d.length<m;)d.push(t.empty);d[m]=t.of(b.slice(1)),u.push(b[0],d[m].length)}}}return new R(u,d)}static createSet(h,u){return new R(h,u)}}function N(x,h,u,d=!1){if(h==0&&u<=0)return;let m=x.length-2;m>=0&&u<=0&&u==x[m+1]?x[m]+=h:m>=0&&h==0&&x[m]==0?x[m+1]+=u:d?(x[m]+=h,x[m+1]+=u):x.push(h,u)}function z(x,h,u){if(u.length==0)return;let d=h.length-2>>1;if(d<x.length)x[x.length-1]=x[x.length-1].append(u);else{for(;x.length<d;)x.push(t.empty);x.push(u)}}function Y(x,h,u){let d=x.inserted;for(let m=0,b=0,S=0;S<x.sections.length;){let w=x.sections[S++],A=x.sections[S++];if(A<0)m+=w,b+=w;else{let O=m,D=b,B=t.empty;for(;O+=w,D+=A,A&&d&&(B=B.append(d[S-2>>1])),!(u||S==x.sections.length||x.sections[S+1]<0);)w=x.sections[S++],A=x.sections[S++];h(m,O,b,D,B),m=O,b=D}}}function _(x,h,u,d=!1){let m=[],b=d?[]:null,S=new Ae(x),w=new Ae(h);for(let A=-1;;){if(S.done&&w.len||w.done&&S.len)throw new Error("Mismatched change set lengths");if(S.ins==-1&&w.ins==-1){let O=Math.min(S.len,w.len);N(m,O,-1),S.forward(O),w.forward(O)}else if(w.ins>=0&&(S.ins<0||A==S.i||S.off==0&&(w.len<S.len||w.len==S.len&&!u))){let O=w.len;for(N(m,w.ins,-1);O;){let D=Math.min(S.len,O);S.ins>=0&&A<S.i&&S.len<=D&&(N(m,0,S.ins),b&&z(b,m,S.text),A=S.i),S.forward(D),O-=D}w.next()}else if(S.ins>=0){let O=0,D=S.len;for(;D;)if(w.ins==-1){let B=Math.min(D,w.len);O+=B,D-=B,w.forward(B)}else if(w.ins==0&&w.len<D)D-=w.len,w.next();else break;N(m,O,A<S.i?S.ins:0),b&&A<S.i&&z(b,m,S.text),A=S.i,S.forward(S.len-D)}else{if(S.done&&w.done)return b?R.createSet(m,b):I.create(m);throw new Error("Mismatched change set lengths")}}}function me(x,h,u=!1){let d=[],m=u?[]:null,b=new Ae(x),S=new Ae(h);for(let w=!1;;){if(b.done&&S.done)return m?R.createSet(d,m):I.create(d);if(b.ins==0)N(d,b.len,0,w),b.next();else if(S.len==0&&!S.done)N(d,0,S.ins,w),m&&z(m,d,S.text),S.next();else{if(b.done||S.done)throw new Error("Mismatched change set lengths");{let A=Math.min(b.len2,S.len),O=d.length;if(b.ins==-1){let D=S.ins==-1?-1:S.off?0:S.ins;N(d,A,D,w),m&&D&&z(m,d,S.text)}else S.ins==-1?(N(d,b.off?0:b.len,A,w),m&&z(m,d,b.textBit(A))):(N(d,b.off?0:b.len,S.off?0:S.ins,w),m&&!S.off&&z(m,d,S.text));w=(b.ins>A||S.ins>=0&&S.len>A)&&(w||d.length>O),b.forward2(A),S.forward(A)}}}}class Ae{constructor(h){this.set=h,this.i=0,this.next()}next(){let{sections:h}=this.set;this.i<h.length?(this.len=h[this.i++],this.ins=h[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:h}=this.set,u=this.i-2>>1;return u>=h.length?t.empty:h[u]}textBit(h){let{inserted:u}=this.set,d=this.i-2>>1;return d>=u.length&&!h?t.empty:u[d].slice(this.off,h==null?void 0:this.off+h)}forward(h){h==this.len?this.next():(this.len-=h,this.off+=h)}forward2(h){this.ins==-1?this.forward(h):h==this.ins?this.next():(this.ins-=h,this.off+=h)}}class he{constructor(h,u,d){this.from=h,this.to=u,this.flags=d}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 h=this.flags&7;return h==7?null:h}get goalColumn(){let h=this.flags>>6;return h==16777215?void 0:h}map(h,u=-1){let d,m;return this.empty?d=m=h.mapPos(this.from,u):(d=h.mapPos(this.from,1),m=h.mapPos(this.to,-1)),d==this.from&&m==this.to?this:new he(d,m,this.flags)}extend(h,u=h){if(h<=this.anchor&&u>=this.anchor)return q.range(h,u);let d=Math.abs(h-this.anchor)>Math.abs(u-this.anchor)?h:u;return q.range(this.anchor,d)}eq(h,u=!1){return this.anchor==h.anchor&&this.head==h.head&&(!u||!this.empty||this.assoc==h.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(h){if(!h||typeof h.anchor!="number"||typeof h.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return q.range(h.anchor,h.head)}static create(h,u,d){return new he(h,u,d)}}class q{constructor(h,u){this.ranges=h,this.mainIndex=u}map(h,u=-1){return h.empty?this:q.create(this.ranges.map(d=>d.map(h,u)),this.mainIndex)}eq(h,u=!1){if(this.ranges.length!=h.ranges.length||this.mainIndex!=h.mainIndex)return!1;for(let d=0;d<this.ranges.length;d++)if(!this.ranges[d].eq(h.ranges[d],u))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new q([this.main],0)}addRange(h,u=!0){return q.create([h].concat(this.ranges),u?0:this.mainIndex+1)}replaceRange(h,u=this.mainIndex){let d=this.ranges.slice();return d[u]=h,q.create(d,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(h=>h.toJSON()),main:this.mainIndex}}static fromJSON(h){if(!h||!Array.isArray(h.ranges)||typeof h.main!="number"||h.main>=h.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new q(h.ranges.map(u=>he.fromJSON(u)),h.main)}static single(h,u=h){return new q([q.range(h,u)],0)}static create(h,u=0){if(h.length==0)throw new RangeError("A selection needs at least one range");for(let d=0,m=0;m<h.length;m++){let b=h[m];if(b.empty?b.from<=d:b.from<d)return q.normalized(h.slice(),u);d=b.to}return new q(h,u)}static cursor(h,u=0,d,m){return he.create(h,h,(u==0?0:u<0?8:16)|(d==null?7:Math.min(6,d))|(m??16777215)<<6)}static range(h,u,d,m){let b=(d??16777215)<<6|(m==null?7:Math.min(6,m));return u<h?he.create(u,h,48|b):he.create(h,u,(u>h?8:0)|b)}static normalized(h,u=0){let d=h[u];h.sort((m,b)=>m.from-b.from),u=h.indexOf(d);for(let m=1;m<h.length;m++){let b=h[m],S=h[m-1];if(b.empty?b.from<=S.to:b.from<S.to){let w=S.from,A=Math.max(b.to,S.to);m<=u&&u--,h.splice(--m,2,b.anchor>b.head?q.range(A,w):q.range(w,A))}}return new q(h,u)}}function ue(x,h){for(let u of x.ranges)if(u.to>h)throw new RangeError("Selection points outside of document")}let ge=0;class X{constructor(h,u,d,m,b){this.combine=h,this.compareInput=u,this.compare=d,this.isStatic=m,this.id=ge++,this.default=h([]),this.extensions=typeof b=="function"?b(this):b}get reader(){return this}static define(h={}){return new X(h.combine||(u=>u),h.compareInput||((u,d)=>u===d),h.compare||(h.combine?(u,d)=>u===d:ye),!!h.static,h.enables)}of(h){return new be([],this,0,h)}compute(h,u){if(this.isStatic)throw new Error("Can't compute a static facet");return new be(h,this,1,u)}computeN(h,u){if(this.isStatic)throw new Error("Can't compute a static facet");return new be(h,this,2,u)}from(h,u){return u||(u=d=>d),this.compute([h],d=>u(d.field(h)))}}function ye(x,h){return x==h||x.length==h.length&&x.every((u,d)=>u===h[d])}class be{constructor(h,u,d,m){this.dependencies=h,this.facet=u,this.type=d,this.value=m,this.id=ge++}dynamicSlot(h){var u;let d=this.value,m=this.facet.compareInput,b=this.id,S=h[b]>>1,w=this.type==2,A=!1,O=!1,D=[];for(let B of this.dependencies)B=="doc"?A=!0:B=="selection"?O=!0:(((u=h[B.id])!==null&&u!==void 0?u:1)&1)==0&&D.push(h[B.id]);return{create(B){return B.values[S]=d(B),1},update(B,$){if(A&&$.docChanged||O&&($.docChanged||$.selection)||re(B,D)){let W=d(B);if(w?!ne(W,B.values[S],m):!m(W,B.values[S]))return B.values[S]=W,1}return 0},reconfigure:(B,$)=>{let W,Z=$.config.address[b];if(Z!=null){let Je=Xi($,Z);if(this.dependencies.every(fe=>fe instanceof X?$.facet(fe)===B.facet(fe):fe instanceof St?$.field(fe,!1)==B.field(fe,!1):!0)||(w?ne(W=d(B),Je,m):m(W=d(B),Je)))return B.values[S]=Je,0}else W=d(B);return B.values[S]=W,1}}}}function ne(x,h,u){if(x.length!=h.length)return!1;for(let d=0;d<x.length;d++)if(!u(x[d],h[d]))return!1;return!0}function re(x,h){let u=!1;for(let d of h)li(x,d)&1&&(u=!0);return u}function st(x,h,u){let d=u.map(A=>x[A.id]),m=u.map(A=>A.type),b=d.filter(A=>!(A&1)),S=x[h.id]>>1;function w(A){let O=[];for(let D=0;D<d.length;D++){let B=Xi(A,d[D]);if(m[D]==2)for(let $ of B)O.push($);else O.push(B)}return h.combine(O)}return{create(A){for(let O of d)li(A,O);return A.values[S]=w(A),1},update(A,O){if(!re(A,b))return 0;let D=w(A);return h.compare(D,A.values[S])?0:(A.values[S]=D,1)},reconfigure(A,O){let D=re(A,d),B=O.config.facets[h.id],$=O.facet(h);if(B&&!D&&ye(u,B))return A.values[S]=$,0;let W=w(A);return h.compare(W,$)?(A.values[S]=$,0):(A.values[S]=W,1)}}}const ht=X.define({static:!0});class St{constructor(h,u,d,m,b){this.id=h,this.createF=u,this.updateF=d,this.compareF=m,this.spec=b,this.provides=void 0}static define(h){let u=new St(ge++,h.create,h.update,h.compare||((d,m)=>d===m),h);return h.provide&&(u.provides=h.provide(u)),u}create(h){let u=h.facet(ht).find(d=>d.field==this);return((u==null?void 0:u.create)||this.createF)(h)}slot(h){let u=h[this.id]>>1;return{create:d=>(d.values[u]=this.create(d),1),update:(d,m)=>{let b=d.values[u],S=this.updateF(b,m);return this.compareF(b,S)?0:(d.values[u]=S,1)},reconfigure:(d,m)=>{let b=d.facet(ht),S=m.facet(ht),w;return(w=b.find(A=>A.field==this))&&w!=S.find(A=>A.field==this)?(d.values[u]=w.create(d),1):m.config.address[this.id]!=null?(d.values[u]=m.field(this),0):(d.values[u]=this.create(d),1)}}}init(h){return[this,ht.of({field:this,create:h})]}get extension(){return this}}const vt={lowest:4,low:3,default:2,high:1,highest:0};function ri(x){return h=>new bo(h,x)}const If={highest:ri(vt.highest),high:ri(vt.high),default:ri(vt.default),low:ri(vt.low),lowest:ri(vt.lowest)};class bo{constructor(h,u){this.inner=h,this.prec=u}}class oi{of(h){return new fs(this,h)}reconfigure(h){return oi.reconfigure.of({compartment:this,extension:h})}get(h){return h.config.compartments.get(this)}}class fs{constructor(h,u){this.compartment=h,this.inner=u}}class Gi{constructor(h,u,d,m,b,S){for(this.base=h,this.compartments=u,this.dynamicSlots=d,this.address=m,this.staticValues=b,this.facets=S,this.statusTemplate=[];this.statusTemplate.length<d.length;)this.statusTemplate.push(0)}staticFacet(h){let u=this.address[h.id];return u==null?h.default:this.staticValues[u>>1]}static resolve(h,u,d){let m=[],b=Object.create(null),S=new Map;for(let $ of Nf(h,u,S))$ instanceof St?m.push($):(b[$.facet.id]||(b[$.facet.id]=[])).push($);let w=Object.create(null),A=[],O=[];for(let $ of m)w[$.id]=O.length<<1,O.push(W=>$.slot(W));let D=d==null?void 0:d.config.facets;for(let $ in b){let W=b[$],Z=W[0].facet,Je=D&&D[$]||[];if(W.every(fe=>fe.type==0))if(w[Z.id]=A.length<<1|1,ye(Je,W))A.push(d.facet(Z));else{let fe=Z.combine(W.map(Ss=>Ss.value));A.push(d&&Z.compare(fe,d.facet(Z))?d.facet(Z):fe)}else{for(let fe of W)fe.type==0?(w[fe.id]=A.length<<1|1,A.push(fe.value)):(w[fe.id]=O.length<<1,O.push(Ss=>fe.dynamicSlot(Ss)));w[Z.id]=O.length<<1,O.push(fe=>st(fe,Z,W))}}let B=O.map($=>$(w));return new Gi(h,S,B,w,A,b)}}function Nf(x,h,u){let d=[[],[],[],[],[]],m=new Map;function b(S,w){let A=m.get(S);if(A!=null){if(A<=w)return;let O=d[A].indexOf(S);O>-1&&d[A].splice(O,1),S instanceof fs&&u.delete(S.compartment)}if(m.set(S,w),Array.isArray(S))for(let O of S)b(O,w);else if(S instanceof fs){if(u.has(S.compartment))throw new RangeError("Duplicate use of compartment in extensions");let O=h.get(S.compartment)||S.inner;u.set(S.compartment,O),b(O,w)}else if(S instanceof bo)b(S.inner,S.prec);else if(S instanceof St)d[w].push(S),S.provides&&b(S.provides,w);else if(S instanceof be)d[w].push(S),S.facet.extensions&&b(S.facet.extensions,vt.default);else{let O=S.extension;if(!O)throw new Error(`Unrecognized extension value in extension set (${S}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);b(O,w)}}return b(x,vt.default),d.reduce((S,w)=>S.concat(w))}function li(x,h){if(h&1)return 2;let u=h>>1,d=x.status[u];if(d==4)throw new Error("Cyclic dependency between fields and/or facets");if(d&2)return d;x.status[u]=4;let m=x.computeSlot(x,x.config.dynamicSlots[u]);return x.status[u]=2|m}function Xi(x,h){return h&1?x.config.staticValues[h>>1]:x.values[h>>1]}const So=X.define(),us=X.define({combine:x=>x.some(h=>h),static:!0}),vo=X.define({combine:x=>x.length?x[0]:void 0,static:!0}),xo=X.define(),wo=X.define(),ko=X.define(),Co=X.define({combine:x=>x.length?x[0]:!1});class Tt{constructor(h,u){this.type=h,this.value=u}static define(){return new Ao}}class Ao{of(h){return new Tt(this,h)}}class Mo{constructor(h){this.map=h}of(h){return new Se(this,h)}}class Se{constructor(h,u){this.type=h,this.value=u}map(h){let u=this.type.map(this.value,h);return u===void 0?void 0:u==this.value?this:new Se(this.type,u)}is(h){return this.type==h}static define(h={}){return new Mo(h.map||(u=>u))}static mapEffects(h,u){if(!h.length)return h;let d=[];for(let m of h){let b=m.map(u);b&&d.push(b)}return d}}Se.reconfigure=Se.define(),Se.appendConfig=Se.define();class ve{constructor(h,u,d,m,b,S){this.startState=h,this.changes=u,this.selection=d,this.effects=m,this.annotations=b,this.scrollIntoView=S,this._doc=null,this._state=null,d&&ue(d,u.newLength),b.some(w=>w.type==ve.time)||(this.annotations=b.concat(ve.time.of(Date.now())))}static create(h,u,d,m,b,S){return new ve(h,u,d,m,b,S)}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(h){for(let u of this.annotations)if(u.type==h)return u.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(h){let u=this.annotation(ve.userEvent);return!!(u&&(u==h||u.length>h.length&&u.slice(0,h.length)==h&&u[h.length]=="."))}}ve.time=Tt.define(),ve.userEvent=Tt.define(),ve.addToHistory=Tt.define(),ve.remote=Tt.define();function Ff(x,h){let u=[];for(let d=0,m=0;;){let b,S;if(d<x.length&&(m==h.length||h[m]>=x[d]))b=x[d++],S=x[d++];else if(m<h.length)b=h[m++],S=h[m++];else return u;!u.length||u[u.length-1]<b?u.push(b,S):u[u.length-1]<S&&(u[u.length-1]=S)}}function Eo(x,h,u){var d;let m,b,S;return u?(m=h.changes,b=R.empty(h.changes.length),S=x.changes.compose(h.changes)):(m=h.changes.map(x.changes),b=x.changes.mapDesc(h.changes,!0),S=x.changes.compose(m)),{changes:S,selection:h.selection?h.selection.map(b):(d=x.selection)===null||d===void 0?void 0:d.map(m),effects:Se.mapEffects(x.effects,m).concat(Se.mapEffects(h.effects,b)),annotations:x.annotations.length?x.annotations.concat(h.annotations):h.annotations,scrollIntoView:x.scrollIntoView||h.scrollIntoView}}function ds(x,h,u){let d=h.selection,m=Ot(h.annotations);return h.userEvent&&(m=m.concat(ve.userEvent.of(h.userEvent))),{changes:h.changes instanceof R?h.changes:R.of(h.changes||[],u,x.facet(vo)),selection:d&&(d instanceof q?d:q.single(d.anchor,d.head)),effects:Ot(h.effects),annotations:m,scrollIntoView:!!h.scrollIntoView}}function To(x,h,u){let d=ds(x,h.length?h[0]:{},x.doc.length);h.length&&h[0].filter===!1&&(u=!1);for(let b=1;b<h.length;b++){h[b].filter===!1&&(u=!1);let S=!!h[b].sequential;d=Eo(d,ds(x,h[b],S?d.changes.newLength:x.doc.length),S)}let m=ve.create(x,d.changes,d.selection,d.effects,d.annotations,d.scrollIntoView);return Hf(u?Vf(m):m)}function Vf(x){let h=x.startState,u=!0;for(let m of h.facet(xo)){let b=m(x);if(b===!1){u=!1;break}Array.isArray(b)&&(u=u===!0?b:Ff(u,b))}if(u!==!0){let m,b;if(u===!1)b=x.changes.invertedDesc,m=R.empty(h.doc.length);else{let S=x.changes.filter(u);m=S.changes,b=S.filtered.mapDesc(S.changes).invertedDesc}x=ve.create(h,m,x.selection&&x.selection.map(b),Se.mapEffects(x.effects,b),x.annotations,x.scrollIntoView)}let d=h.facet(wo);for(let m=d.length-1;m>=0;m--){let b=d[m](x);b instanceof ve?x=b:Array.isArray(b)&&b.length==1&&b[0]instanceof ve?x=b[0]:x=To(h,Ot(b),!1)}return x}function Hf(x){let h=x.startState,u=h.facet(ko),d=x;for(let m=u.length-1;m>=0;m--){let b=u[m](x);b&&Object.keys(b).length&&(d=Eo(d,ds(h,b,x.changes.newLength),!0))}return d==x?x:ve.create(h,x.changes,x.selection,d.effects,d.annotations,d.scrollIntoView)}const $f=[];function Ot(x){return x==null?$f:Array.isArray(x)?x:[x]}i.CharCategory=void 0,(function(x){x[x.Word=0]="Word",x[x.Space=1]="Space",x[x.Other=2]="Other"})(i.CharCategory||(i.CharCategory={}));const Wf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ps;try{ps=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function zf(x){if(ps)return ps.test(x);for(let h=0;h<x.length;h++){let u=x[h];if(/\w/.test(u)||u>"€"&&(u.toUpperCase()!=u.toLowerCase()||Wf.test(u)))return!0}return!1}function qf(x){return h=>{if(!/\S/.test(h))return i.CharCategory.Space;if(zf(h))return i.CharCategory.Word;for(let u=0;u<x.length;u++)if(h.indexOf(x[u])>-1)return i.CharCategory.Word;return i.CharCategory.Other}}class oe{constructor(h,u,d,m,b,S){this.config=h,this.doc=u,this.selection=d,this.values=m,this.status=h.statusTemplate.slice(),this.computeSlot=b,S&&(S._state=this);for(let w=0;w<this.config.dynamicSlots.length;w++)li(this,w<<1);this.computeSlot=null}field(h,u=!0){let d=this.config.address[h.id];if(d==null){if(u)throw new RangeError("Field is not present in this state");return}return li(this,d),Xi(this,d)}update(...h){return To(this,h,!0)}applyTransaction(h){let u=this.config,{base:d,compartments:m}=u;for(let w of h.effects)w.is(oi.reconfigure)?(u&&(m=new Map,u.compartments.forEach((A,O)=>m.set(O,A)),u=null),m.set(w.value.compartment,w.value.extension)):w.is(Se.reconfigure)?(u=null,d=w.value):w.is(Se.appendConfig)&&(u=null,d=Ot(d).concat(w.value));let b;u?b=h.startState.values.slice():(u=Gi.resolve(d,m,this),b=new oe(u,this.doc,this.selection,u.dynamicSlots.map(()=>null),(A,O)=>O.reconfigure(A,this),null).values);let S=h.startState.facet(us)?h.newSelection:h.newSelection.asSingle();new oe(u,h.newDoc,S,b,(w,A)=>A.update(w,h),h)}replaceSelection(h){return typeof h=="string"&&(h=this.toText(h)),this.changeByRange(u=>({changes:{from:u.from,to:u.to,insert:h},range:q.cursor(u.from+h.length)}))}changeByRange(h){let u=this.selection,d=h(u.ranges[0]),m=this.changes(d.changes),b=[d.range],S=Ot(d.effects);for(let w=1;w<u.ranges.length;w++){let A=h(u.ranges[w]),O=this.changes(A.changes),D=O.map(m);for(let $=0;$<w;$++)b[$]=b[$].map(D);let B=m.mapDesc(O,!0);b.push(A.range.map(B)),m=m.compose(D),S=Se.mapEffects(S,D).concat(Se.mapEffects(Ot(A.effects),B))}return{changes:m,selection:q.create(b,u.mainIndex),effects:S}}changes(h=[]){return h instanceof R?h:R.of(h,this.doc.length,this.facet(oe.lineSeparator))}toText(h){return t.of(h.split(this.facet(oe.lineSeparator)||F))}sliceDoc(h=0,u=this.doc.length){return this.doc.sliceString(h,u,this.lineBreak)}facet(h){let u=this.config.address[h.id];return u==null?h.default:(li(this,u),Xi(this,u))}toJSON(h){let u={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(h)for(let d in h){let m=h[d];m instanceof St&&this.config.address[m.id]!=null&&(u[d]=m.spec.toJSON(this.field(h[d]),this))}return u}static fromJSON(h,u={},d){if(!h||typeof h.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let m=[];if(d){for(let b in d)if(Object.prototype.hasOwnProperty.call(h,b)){let S=d[b],w=h[b];m.push(S.init(A=>S.spec.fromJSON(w,A)))}}return oe.create({doc:h.doc,selection:q.fromJSON(h.selection),extensions:u.extensions?m.concat([u.extensions]):m})}static create(h={}){let u=Gi.resolve(h.extensions||[],new Map),d=h.doc instanceof t?h.doc:t.of((h.doc||"").split(u.staticFacet(oe.lineSeparator)||F)),m=h.selection?h.selection instanceof q?h.selection:q.single(h.selection.anchor,h.selection.head):q.single(0);return ue(m,d.length),u.staticFacet(us)||(m=m.asSingle()),new oe(u,d,m,u.dynamicSlots.map(()=>null),(b,S)=>S.create(b),null)}get tabSize(){return this.facet(oe.tabSize)}get lineBreak(){return this.facet(oe.lineSeparator)||`
@@ -8,7 +8,7 @@ import{dp as Uf,dq as tt,dr as Yf,ds as Gf,dt as Xf,du as Oe,dv as Fe,dw as Gn,d
8
8
  `&&i.lineWrapping&&(n&&(n=y.EditorSelection.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:y.Text.of([" "])}),t)return zr(i,t,n,r);if(n&&!n.main.eq(s)){let o=!1,l="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),l=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function zr(i,e,t,n=-1){if(V.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(V.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&i.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ht(i.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&Ht(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Ht(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=Qu(i,e,t));return i.state.facet(oh).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function Qu(i,e,t){let n,s=i.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)&&i.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):"";n=s.replaceSelection(i.state.toText(l+e.insert.sliceString(0,void 0,i.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&&i.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let f=i.state.sliceDoc(e.from,e.to),c,p=t&&gh(i,t.main.head);if(p){let k=e.insert.length-(e.to-e.from);c={from:p.from,to:p.to-k}}else c=i.state.doc.lineAt(r.head);let g=r.to-e.to,v=r.to-r.from;n=s.changeByRange(k=>{if(k.from==r.from&&k.to==r.to)return{changes:l,range:a||k.map(l)};let C=k.to-g,M=C-f.length;if(k.to-k.from!=v||i.state.sliceDoc(M,C)!=f||k.to>=c.from&&k.from<=c.to)return{range:k};let T=s.changes({from:M,to:C,insert:e.insert}),P=k.to-r.to;return{changes:T,range:a?y.EditorSelection.range(Math.max(0,a.anchor+P),Math.max(0,a.head+P)):k.map(T)}})}else n={changes:l,selection:a&&s.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:o,scrollIntoView:!0})}function Zu(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r<s&&i.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&i.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 ed(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}=i.observer.selectionRange;return t&&(e.push(new Jo(t,n)),(s!=t||r!=n)&&e.push(new Jo(s,r))),e}function td(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?y.EditorSelection.single(t+e,n+e):null}class id{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,V.safari&&e.contentDOM.addEventListener("input",()=>null),V.gecko&&bd(e.contentDOM.ownerDocument)}handleEvent(e){!cd(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,t);for(let s of n.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=nd(e),n=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=n[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 n)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&&vh.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),V.android&&V.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return V.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Sh.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||sd.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,Ht(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:V.safari&&!V.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 Uo(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){ke(t.state,s)}}}function nd(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let s=n.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(Uo(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Uo(n.value,a))}}for(let n in je)t(n).handlers.push(je[n]);for(let n in $e)t(n).observers.push($e[n]);return e}const Sh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],sd="dthko",vh=[16,17,18,20,91,92,224,225],nn=6;function sn(i){return Math.max(0,i)*.7+8}function rd(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class od{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=du(e.contentDOM),this.atoms=e.state.facet($r).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(y.EditorState.allowMultipleSelections)&&ld(e,t),this.dragging=hd(e,t)&&kh(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&&rd(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=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=Wr(this.view);e.clientX-a.left<=s+nn?t=-sn(s-e.clientX):e.clientX+a.right>=o-nn&&(t=sn(e.clientX-o)),e.clientY-a.top<=r+nn?n=-sn(r-e.clientY):e.clientY+a.bottom>=l-nn&&(n=sn(e.clientY-l)),this.setScrollSpeed(t,n)}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 n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=xn(this.atoms,s.from,0);o!=s.from&&(r=y.EditorSelection.cursor(o,-1))}else{let o=xn(this.atoms,s.from,-1),l=xn(this.atoms,s.to,1);(o!=s.from||l!=s.to)&&(r=y.EditorSelection.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?y.EditorSelection.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,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 ld(i,e){let t=i.state.facet(ih);return t.length?t[0](e):V.mac?e.metaKey:e.ctrlKey}function ad(i,e){let t=i.state.facet(nh);return t.length?t[0](e):V.mac?!e.altKey:!e.ctrlKey}function hd(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Mi(i.root);if(!n||n.rangeCount==0)return!0;let s=n.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 cd(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=J.get(t))&&n.ignoreEvent(e))return!1;return!0}const je=Object.create(null),$e=Object.create(null),xh=V.ie&&V.ie_version<15||V.ios&&V.webkit_version<604;function fd(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),wh(i,t.value)},50)}function Qn(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function wh(i,e){e=Qn(i.state,Fr,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(cr!=null&&t.selection.ranges.every(a=>a.empty)&&cr==r.toString()){let a=-1;n=t.changeByRange(f=>{let c=t.doc.lineAt(f.from);if(c.from==a)return{range:f};a=c.from;let p=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:p},range:y.EditorSelection.cursor(f.from+p.length)}})}else o?n=t.changeByRange(a=>{let f=r.line(s++);return{changes:{from:a.from,to:a.to,insert:f.text},range:y.EditorSelection.cursor(a.from+f.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}$e.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};je.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);$e.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};$e.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};je.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(sh))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=pd(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new od(i,e,t,n)),n&&i.observer.ignore(()=>{Fa(i.contentDOM);let r=i.root.activeElement;r&&!r.contains(i.contentDOM)&&r.blur()});let s=i.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}return!1};function Yo(i,e,t,n){if(n==1)return y.EditorSelection.cursor(e,t);if(n==2)return Wu(i.state,e,t);{let s=ce.find(i.docView,e),r=i.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<i.state.doc.length&&l==r.to&&l++,y.EditorSelection.range(o,l)}}let Go=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function ud(i,e,t,n){let s=ce.find(i.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&&Go(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&Go(t,n,l)?1:o&&o.bottom>=n?-1:1}function Xo(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ud(i,t,e.clientX,e.clientY)}}const dd=V.ie&&V.ie_version<=11;let Qo=null,Zo=0,el=0;function kh(i){if(!dd)return i.detail;let e=Qo,t=el;return Qo=i,el=Date.now(),Zo=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Zo+1)%3:1}function pd(i,e){let t=Xo(i,e),n=kh(e),s=i.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=Xo(i,r),f,c=Yo(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let p=Yo(i,t.pos,t.bias,n),g=Math.min(p.from,c.from),v=Math.max(p.to,c.to);c=g<c.from?y.EditorSelection.range(g,v):y.EditorSelection.range(v,g)}return o?s.replaceRange(s.main.extend(c.from,c.to)):l&&n==1&&s.ranges.length>1&&(f=md(s,a.pos))?f:l?s.addRange(c):y.EditorSelection.create([c])}}}function md(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:s}=i.ranges[t];if(n<=e&&s>=e)return y.EditorSelection.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}je.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let s=i.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=y.EditorSelection.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Qn(i.state,Vr,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};je.dragend=i=>(i.inputState.draggedContent=null,!1);function tl(i,e,t,n){if(t=Qn(i.state,Fr,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&ad(i,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}je.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),s=0,r=()=>{++s==t.length&&tl(i,e,n.filter(o=>o!=null).join(i.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)||(n[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return tl(i,e,n,!0),!0}return!1};je.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=xh?null:e.clipboardData;return t?(wh(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(fd(i),!1)};function gd(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function yd(i){let e=[],t=[],n=!1;for(let s of i.selection.ranges)s.empty||(e.push(i.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of i.selection.ranges){let o=i.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),s=o.number}n=!0}return{text:Qn(i,Vr,e.join(i.lineBreak)),ranges:t,linewise:n}}let cr=null;je.copy=je.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=yd(i.state);if(!t&&!s)return!1;cr=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=xh?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(gd(i,t),!1)};const Ch=y.Annotation.define();function Ah(i,e){let t=[];for(let n of i.facet(lh)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:Ch.of(!0)}):null}function Mh(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Ah(i.state,e);t?i.dispatch(t):i.update([])}},10)}$e.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Mh(i)};$e.blur=i=>{i.observer.clearSelectionRange(),Mh(i)};$e.compositionstart=$e.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};$e.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,V.chrome&&V.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};$e.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};je.beforeinput=(i,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),f=i.posAtDOM(l.endContainer,l.endOffset);return zr(i,{from:a,to:f,insert:i.state.toText(r)},null),!0}}let s;if(V.chrome&&V.android&&(s=Sh.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return V.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),V.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>$e.compositionend(i,e),20),!1};const il=new Set;function bd(i){il.has(i)||(il.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const nl=["pre-wrap","normal","pre-line","break-spaces"];let Jt=!1;function sl(){Jt=!1}class Sd{constructor(e){this.lineWrapping=e,this.doc=y.Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return nl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,n,s,r,o){let l=nl.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let f=0;f<o.length;f++){let c=o[f];c<0?f++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class vd{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Ge{constructor(e,t,n,s,r){this.from=e,this.length=t,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?Ee.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 gt?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 Ge(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Q=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(Q||(Q={}));const wn=.001;class Te{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>wn&&(Jt=!0),this.height=e)}replace(e,t,n){return Te.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let r=this,o=n.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:f,fromB:c,toB:p}=s[l],g=r.lineAt(a,Q.ByPosNoHeight,n.setDoc(t),0,0),v=g.to>=f?g:r.lineAt(f,Q.ByPosNoHeight,n,0,0);for(p+=v.to-f,f=v.to;l>0&&g.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,a<g.from&&(g=r.lineAt(a,Q.ByPosNoHeight,n,0,0));c+=g.from-a,a=g.from;let k=qr.build(n.setDoc(o),e,c,p);r=Bn(r,r.replace(a,f,k))}return r.updateHeight(n,0)}static empty(){return new Le(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,s=0,r=0;for(;;)if(t==n)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),n+=1+l.break,s-=l.size}else if(r>s*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--n];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new xd(Te.of(e.slice(0,t)),o,Te.of(e.slice(n)))}}function Bn(i,e){return i==e?i:(i.constructor!=e.constructor&&(Jt=!0),e)}Te.prototype.size=1;class Eh extends Te{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new Ge(s,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,s,r){return this.blockAt(0,n,s,r)}forEachLine(e,t,n,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,s,r))}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Le extends Eh{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new Ge(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof Le||s instanceof de&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof de?s=new Le(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Te.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(n||this.outdated)&&this.setHeight(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 de extends Te{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-n+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:n,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,n,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let f=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),c=t.doc.lineAt(f),p=l+c.length*a,g=Math.max(n,e-p/2);return new Ge(c.from,c.length,g,p,0)}else{let f=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:c,length:p}=t.doc.line(r+f);return new Ge(c,p,n+l*f,l,0)}}lineAt(e,t,n,s,r){if(t==Q.ByHeight)return this.blockAt(e,n,s,r);if(t==Q.ByPosNoHeight){let{from:v,to:k}=n.doc.lineAt(e);return new Ge(v,k-v,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),f=n.doc.lineAt(e),c=l+f.length*a,p=f.number-o,g=s+l*p+a*(f.from-r-p);return new Ge(f.from,f.length,Math.max(s,Math.min(g,s+this.height-c)),c,0)}forEachLine(e,t,n,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:f}=this.heightMetrics(n,r);for(let c=e,p=s;c<=t;){let g=n.doc.lineAt(c);if(c==e){let k=g.number-l;p+=a*k+f*(e-r-k)}let v=a+f*g.length;o(new Ge(g.from,g.length,p,v,0)),p+=v,c=g.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof de?n[n.length-1]=new de(r.length+s):n.push(null,new de(s-1))}if(e>0){let r=n[0];r instanceof de?n[0]=new de(e+r.length):n.unshift(new de(e-1),null)}return Te.of(n)}decomposeLeft(e,t){t.push(new de(e-1),null)}decomposeRight(e,t){t.push(null,new de(this.length-e-1))}updateHeight(e,t=0,n=!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 de(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let p=s.heights[s.index++];a==-1?a=p:Math.abs(p-a)>=wn&&(a=-2);let g=new Le(c,p);g.outdated=!1,o.push(g),l+=c+1}l<=r&&o.push(null,new de(r-l).updateHeight(e,l));let f=Te.of(o);return(a<0||Math.abs(f.height-this.height)>=wn||Math.abs(a-this.heightMetrics(e,t).perLine)>=wn)&&(Jt=!0),Bn(this,f)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class xd extends Te{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,s){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,n,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==Q.ByHeight?e<o:e<l,f=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?f.to<l:f.from>l))return f;let c=t==Q.ByPosNoHeight?Q.ByPosNoHeight:Q.ByPos;return a?f.join(this.right.lineAt(l,c,n,o,l)):this.left.lineAt(l,c,n,s,r).join(f)}forEachLine(e,t,n,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,n,s,r,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let f=this.lineAt(a,Q.ByPos,n,s,r);e<f.from&&this.left.forEachLine(e,f.from-1,n,s,r,o),f.to>=e&&f.from<=t&&o(f),t>f.to&&this.right.forEachLine(f.to+1,t,n,l,a,o)}}replace(e,t,n){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of n)r.push(l);if(e>0&&rl(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),rl(r,l)}return Te.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<n&&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?Te.of(this.break?[e,null,t]:[e,t]):(this.left=Bn(this.left,e),this.right=Bn(this.right,t),this.setHeight(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,n=!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,n,s):r.updateHeight(e,t,n),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,n,s):o.updateHeight(e,l,n),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 rl(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof de&&(n=i[e+1])instanceof de&&i.splice(e-1,3,new de(t.length+1+n.length))}const wd=5;class qr{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 n=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Le?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Le(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Eh(o,s,n)):(o||r||s>=wd)&&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 Le(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new de(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Le)return e;let t=new Le(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,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Le)&&!this.isCovered?this.nodes.push(new Le(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof Le&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new qr(n,e);return y.RangeSet.spans(t,n,s,r,0),r.finish(n)}}function kd(i,e,t){let n=new Cd;return y.RangeSet.compare(i,e,t,n,0),n.changes}class Cd{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&vn(e,t,this.changes,5)}}function Ad(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,s=n.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 f=i.parentNode;f&&f!=n.body;)if(f.nodeType==1){let c=f,p=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&p.overflow!="visible"){let g=c.getBoundingClientRect();r=Math.max(r,g.left),o=Math.min(o,g.right),l=Math.max(l,g.top),a=Math.min(f==i.parentNode?s.innerHeight:a,g.bottom)}f=p.position=="absolute"||p.position=="fixed"?c.offsetParent:c.parentNode}else if(f.nodeType==11)f=f.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 Md(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Ed(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ms{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return H.replace({widget:new Td(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Td extends _e{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 ol{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=ll,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=U.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Hr).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Sd(t),this.stateDeco=e.facet(Ei).filter(n=>typeof n!="function"),this.heightMap=Te.empty().applyChanges(this.stateDeco,y.Text.empty,this.heightOracle.setDoc(e.doc),[new He(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=H.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?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 rn(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?ll:new jr(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(Si(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Ei).filter(c=>typeof c!="function");let s=e.changedRanges,r=He.extendWithRanges(s,kd(n,this.stateDeco,e?e.changes:y.ChangeSet.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);sl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Jt)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);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 f=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(f||!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(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(hh)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?U.RTL:U.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 f=0,c=0;if(l.width&&l.height){let{scaleX:I,scaleY:R}=Na(t,l);(I>.005&&Math.abs(this.scaleX-I)>.005||R>.005&&Math.abs(this.scaleY-R)>.005)&&(this.scaleX=I,this.scaleY=R,f|=16,o=a=!0)}let p=(parseInt(n.paddingTop)||0)*this.scaleY,g=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=g)&&(this.paddingTop=p,this.paddingBottom=g,f|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=16);let v=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=v&&(this.scrollAnchorHeight=-1,this.scrollTop=v),this.scrolledToBottom=Ha(e.scrollDOM);let k=(this.printing?Ed:Ad)(t,this.paddingTop),C=k.top-this.pixelViewport.top,M=k.bottom-this.pixelViewport.bottom;this.pixelViewport=k;let T=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(T!=this.inView&&(this.inView=T,T&&(a=!0)),!this.inView&&!this.scrollTarget&&!Md(e.dom))return 0;let P=l.width;if((this.contentDOMWidth!=P||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,f|=16),a){let I=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(I)&&(o=!0),o||s.lineWrapping&&Math.abs(P-this.contentDOMWidth)>s.charWidth){let{lineHeight:R,charWidth:N,textHeight:z}=e.docView.measureTextSize();o=R>0&&s.refresh(r,R,N,z,Math.max(5,P/N),I),o&&(e.docView.minWidth=0,f|=16)}C>0&&M>0?c=Math.max(C,M):C<0&&M<0&&(c=Math.min(C,M)),sl();for(let R of this.viewports){let N=R.from==this.viewport.from?I:e.docView.measureVisibleLineHeights(R);this.heightMap=(o?Te.empty().applyChanges(this.stateDeco,y.Text.empty,this.heightOracle,[new He(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new vd(R.from,N))}Jt&&(f|=2)}let F=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return F&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),f|=this.updateForViewport()),(f&2||F)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new rn(s.lineAt(o-n*1e3,Q.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,Q.ByHeight,r,0,0).to);if(t){let{head:f}=t.range;if(f<a.from||f>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=s.lineAt(f,Q.ByPos,r,0,0),g;t.y=="center"?g=(p.top+p.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&f<a.from?g=p.top:g=p.bottom-c,a=new rn(s.lineAt(g-1e3/2,Q.ByHeight,r,0,0).from,s.lineAt(g+c+1e3/2,Q.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new rn(this.heightMap.lineAt(n,Q.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,Q.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,Q.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,Q.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new Ms(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=U.LTR&&!n)return[];let l=[],a=(c,p,g,v)=>{if(p-c<r)return;let k=this.state.selection.main,C=[k.from];k.empty||C.push(k.to);for(let T of C)if(T>c&&T<p){a(c,T-10,g,v),a(T+10,p,g,v);return}let M=Dd(e,T=>T.from>=g.from&&T.to<=g.to&&Math.abs(T.from-c)<r&&Math.abs(T.to-p)<r&&!C.some(P=>T.from<P&&T.to>P));if(!M){if(p<g.to&&t&&n&&t.visibleRanges.some(F=>F.from<=p&&F.to>=p)){let F=t.moveToLineBoundary(y.EditorSelection.cursor(p),!1,!0).head;F>c&&(p=F)}let T=this.gapSize(g,c,p,v),P=n||T<2e6?T:2e6;M=new Ms(c,p,T,P)}l.push(M)},f=c=>{if(c.length<o||c.type!=Ee.Text)return;let p=Od(c.from,c.to,this.stateDeco);if(p.total<o)return;let g=this.scrollTarget?this.scrollTarget.range.head:null,v,k;if(n){let C=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,M,T;if(g!=null){let P=ln(p,g),F=((this.visibleBottom-this.visibleTop)/2+C)/c.height;M=P-F,T=P+F}else M=(this.visibleTop-c.top-C)/c.height,T=(this.visibleBottom-c.top+C)/c.height;v=on(p,M),k=on(p,T)}else{let C=p.total*this.heightOracle.charWidth,M=s*this.heightOracle.charWidth,T=0;if(C>2e6)for(let N of e)N.from>=c.from&&N.from<c.to&&N.size!=N.displaySize&&N.from*this.heightOracle.charWidth+T<this.pixelViewport.left&&(T=N.size-N.displaySize);let P=this.pixelViewport.left+T,F=this.pixelViewport.right+T,I,R;if(g!=null){let N=ln(p,g),z=((F-P)/2+M)/C;I=N-z,R=N+z}else I=(P-M)/C,R=(F+M)/C;v=on(p,I),k=on(p,R)}v>c.from&&a(c.from,v,c,p),k<c.to&&a(k,c.to,c,p)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(f):f(c);return l}gapSize(e,t,n,s){let r=ln(s,n)-ln(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Ms.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=H.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];y.RangeSet.spans(t,this.viewport.from,this.viewport.to,{span(r,o){n.push({from:r,to:o})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let r=0;r<n.length&&!(s&8);r++){let o=this.visibleRanges[r],l=n[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Si(this.heightMap.lineAt(e,Q.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)||Si(this.heightMap.lineAt(this.scaler.fromDOM(e),Q.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 Si(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 rn{constructor(e,t){this.from=e,this.to=t}}function Od(i,e,t){let n=[],s=i,r=0;return y.RangeSet.spans(t,i,e,{span(){},point(o,l){o>s&&(n.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function on({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(n<=l)return r+n;n-=l}}function ln(i,e){let t=0;for(let{from:n,to:s}of i.ranges){if(e<=s){t+=e-n;break}t+=s-n}return t/i.total}function Dd(i,e){for(let t of i)if(e(t))return t}const ll={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class jr{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let f=t.lineAt(l,Q.ByPos,e,0,0).top,c=t.lineAt(a,Q.ByPos,e,0,0).bottom;return s+=c-f,{from:l,to:a,top:f,bottom:c,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,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof jr?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function Si(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Ge(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>Si(s,e)):i._content)}const an=y.Facet.define({combine:i=>i.join(" ")}),fr=y.Facet.define({combine:i=>i.indexOf(!0)>-1}),ur=tt.newName(),Th=tt.newName(),Oh=tt.newName(),Dh={"&light":"."+Th,"&dark":"."+Oh};function dr(i,e,t){return new tt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return i;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):i+" "+n}})}const Pd=dr("."+ur,{"&":{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,overflowAnchor:"none"},".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:"#ddd"},".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",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&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-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".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"}},Dh),Rd={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Es=V.ie&&V.ie_version<=11;class Bd{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new pu,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 n of t)this.queue.push(n);(V.ie&&V.ie_version<=11||V.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&V.android&&e.constructor.EDIT_CONTEXT!==!1&&!(V.chrome&&V.chrome_version<126)&&(this.editContext=new Id(e),e.state.facet(rt)&&(e.contentDOM.editContext=this.editContext.editContext)),Es&&(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.type)&&!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,n)=>t!=e[n]))){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:n}=this,s=this.selectionRange;if(n.state.facet(rt)?n.root.activeElement!=this.dom:!Sn(this.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(V.ie&&V.ie_version<=11||V.android&&V.chrome)&&!n.state.selection.main.empty&&s.focusNode&&wi(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Mi(e.root);if(!t)return!1;let n=V.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Ld(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=Sn(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&gu(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),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 n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.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,Rd),Es&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Es&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;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&&Ht(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||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.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,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&Sn(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 Xu(this.view,e,t,n);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 n=this.view.state,s=bh(this.view,t);return this.view.state==n&&(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 n=al(t,e.previousSibling||e.target.previousSibling,-1),s=al(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):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?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(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?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(rt)!=e.state.facet(rt)&&(e.view.contentDOM.editContext=e.state.facet(rt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.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 al(i,e,t){for(;e;){let n=J.get(e);if(n&&n.parent==i)return n;let s=e.parentNode;e=s!=i.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function hl(i,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return wi(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function Ld(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return hl(i,s)}let t=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?hl(i,t):null}class Id{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=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=n=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let f={from:l,to:a,insert:y.Text.of(n.text.split(`
9
9
  `))};if(f.from==this.from&&r<this.from?f.from=r:f.to==this.to&&r>this.to&&(f.to=r),f.from==f.to&&!f.insert.length){let c=y.EditorSelection.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));c.main.eq(s)||e.dispatch({selection:c,userEvent:"select"});return}if((V.mac||V.android)&&f.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:y.Text.of([n.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let c=this.to-this.from+(f.to-f.from+f.insert.length);zr(e,f,y.EditorSelection.single(this.toEditorPos(n.selectionStart,c),this.toEditorPos(n.selectionEnd,c)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.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(n.rangeStart,s)},this.handlers.textformatupdate=n=>{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(o!="None"&&l!="None"){let a=this.toEditorPos(r.rangeStart),f=this.toEditorPos(r.rangeEnd);if(a<f){let c=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;s.push(H.mark({attributes:{style:c}}).range(a,f))}}}e.dispatch({effects:fh.of(H.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Mi(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,f)=>{if(n)return;let c=f.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(f)){s=this.pendingContextChange=null,t+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+f.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),f.toString()),this.to+=c}t+=c}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(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)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}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,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,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,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class L{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;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:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||mu(e.parent)||document,this.viewState=new ol(e.state||y.EditorState.create(e)),e.scrollTo&&e.scrollTo.is(tn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(It).map(s=>new ks(s));for(let s of this.plugins)s.update(this);this.observer=new Bd(this),this.inputState=new id(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Wo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof y.Transaction?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,n=!1,s,r=this.state;for(let g of e){if(g.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=g.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(g=>g.annotation(Ch))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ah(r,o),a||(l=1));let f=this.observer.delayedAndroidKey,c=null;if(f?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(y.EditorState.phrases)!=this.state.facet(y.EditorState.phrases))return this.setState(r);s=Rn.create(this,r,e),s.flags|=l;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(p&&(p=p.map(g.changes)),g.scrollIntoView){let{main:v}=g.state.selection;p=new $t(v.empty?v:y.EditorSelection.cursor(v.head,v.head>v.anchor?-1:1))}for(let v of g.effects)v.is(tn)&&(p=v.value.clip(this.state))}this.viewState.update(s,p),this.bidiCache=Ln.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(yi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(an)!=s.state.facet(an)&&(this.viewState.mustMeasureContent=!0),(t||n||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let g of this.state.facet(lr))try{g(s)}catch(v){ke(this.state,v,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!bh(this,c)&&f.force&&Ht(this.contentDOM,f.key,f.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 n of this.plugins)n.destroy(this);this.viewState=new ol(e),this.plugins=e.facet(It).map(n=>new ks(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Wo(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(It),n=e.state.facet(It);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new ks(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!=n&&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(n){ke(this.state,n,"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,n=this.scrollDOM,s=n.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(Ha(n))r=-1,o=this.viewState.heightMap.height;else{let v=this.viewState.scrollAnchorAt(s);r=v.from,o=v.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 f=[];a&4||([this.measureRequests,f]=[f,this.measureRequests]);let c=f.map(v=>{try{return v.read(this)}catch(k){return ke(this.state,k),cl}}),p=Rn.create(this,this.state,[]),g=!1;p.flags|=a,t?t.flags|=a:t=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),g=this.docView.update(p),g&&this.docViewUpdate());for(let v=0;v<f.length;v++)if(c[v]!=cl)try{let k=f[v];k.write&&k.write(c[v],this)}catch(k){ke(this.state,k)}if(g&&this.docView.updateSelection(!0),!p.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 k=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(k>1||k<-1){s=s+k,n.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(lr))l(t)}get themeClasses(){return ur+" "+(this.state.facet(fr)?Oh:Th)+" "+this.state.facet(an)}updateAttrs(){let e=fl(this,uh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(rt)?"true":"false",class:"cm-content",style:`${V.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),fl(this,Hr,t);let n=this.observer.ignore(()=>{let s=ir(this.contentDOM,this.contentAttrs,t),r=ir(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(L.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(yi);let e=this.state.facet(L.cspNonce);tt.mount(this.root,this.styleModules.concat(Pd).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.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==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,n){return As(this,e,Ko(this,e,t,n))}moveByGroup(e,t){return As(this,e,Ko(this,e,t,n=>Ju(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return y.EditorSelection.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return Ku(this,e,t,n)}moveVertically(e,t,n){return As(this,e,Uu(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),yh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[ut.find(r,e-s.from,-1,t)];return $i(n,o.dir==U.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(ah)||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>Nd)return eh(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Za(r.isolates,n=$o(this,e))))return r.order;n||(n=$o(this,e));let s=Du(e.text,t,n);return this.bidiCache.push(new Ln(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||V.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Fa(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 tn.of(new $t(typeof e=="number"?y.EditorSelection.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return tn.of(new $t(y.EditorSelection.cursor(n.from),"start","start",n.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 te.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return te.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=tt.newName(),s=[an.of(n),yi.of(dr(`.${n}`,e))];return t&&t.dark&&s.push(fr.of(!0)),s}static baseTheme(e){return y.Prec.lowest(yi.of(dr("."+ur,e,Dh)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&J.get(n)||J.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}L.styleModule=yi;L.inputHandler=oh;L.clipboardInputFilter=Fr;L.clipboardOutputFilter=Vr;L.scrollHandler=ch;L.focusChangeEffect=lh;L.perLineTextDirection=ah;L.exceptionSink=rh;L.updateListener=lr;L.editable=rt;L.mouseSelectionStyle=sh;L.dragMovesSelection=nh;L.clickAddsSelectionRange=ih;L.decorations=Ei;L.outerDecorations=dh;L.atomicRanges=$r;L.bidiIsolatedRanges=ph;L.scrollMargins=mh;L.darkTheme=fr;L.cspNonce=y.Facet.define({combine:i=>i.length?i[0]:""});L.contentAttributes=Hr;L.editorAttributes=uh;L.lineWrapping=L.contentAttributes.of({class:"cm-lineWrapping"});L.announce=y.StateEffect.define();const Nd=4096,cl={};class Ln{constructor(e,t,n,s,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:U.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)&&n.push(new Ln(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function fl(i,e,t){for(let n=i.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&tr(o,t)}return t}const Fd=V.mac?"mac":V.windows?"win":V.linux?"linux":"key";function Vd(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const f=t[a];if(/^(cmd|meta|m)$/i.test(f))l=!0;else if(/^a(lt)?$/i.test(f))s=!0;else if(/^(c|ctrl|control)$/i.test(f))r=!0;else if(/^s(hift)?$/i.test(f))o=!0;else if(/^mod$/i.test(f))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+f)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function hn(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const Hd=y.Prec.default(L.domEventHandlers({keydown(i,e){return Rh(Ph(e.state),i,e,"editor")}})),ei=y.Facet.define({enables:Hd}),ul=new WeakMap;function Ph(i){let e=i.facet(ei),t=ul.get(e);return t||ul.set(e,t=zd(e.reduce((n,s)=>n.concat(s),[]))),t}function $d(i,e,t){return Rh(Ph(i.state),e,i,t)}let ct=null;const Wd=4e3;function zd(i,e=Fd){let t=Object.create(null),n=Object.create(null),s=(o,l)=>{let a=n[o];if(a==null)n[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,f,c)=>{var p,g;let v=t[o]||(t[o]=Object.create(null)),k=l.split(/ (?!$)/).map(T=>Vd(T,e));for(let T=1;T<k.length;T++){let P=k.slice(0,T).join(" ");s(P,!0),v[P]||(v[P]={preventDefault:!0,stopPropagation:!1,run:[F=>{let I=ct={view:F,prefix:P,scope:o};return setTimeout(()=>{ct==I&&(ct=null)},Wd),!0}]})}let C=k.join(" ");s(C,!1);let M=v[C]||(v[C]={preventDefault:!1,stopPropagation:!1,run:((g=(p=v._any)===null||p===void 0?void 0:p.run)===null||g===void 0?void 0:g.slice())||[]});a&&M.run.push(a),f&&(M.preventDefault=!0),c&&(M.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of l){let c=t[f]||(t[f]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=o;for(let g in c)c[g].run.push(v=>p(v,pr))}let a=o[e]||o.key;if(a)for(let f of l)r(f,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(f,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let pr=null;function Rh(i,e,t,n){pr=e;let s=Yf(e),r=y.codePointAt(s,0),o=y.codePointSize(r)==s.length&&s!=" ",l="",a=!1,f=!1,c=!1;ct&&ct.view==t&&ct.scope==n&&(l=ct.prefix+" ",vh.indexOf(e.keyCode)<0&&(f=!0,ct=null));let p=new Set,g=M=>{if(M){for(let T of M.run)if(!p.has(T)&&(p.add(T),T(t)))return M.stopPropagation&&(c=!0),!0;M.preventDefault&&(M.stopPropagation&&(c=!0),f=!0)}return!1},v=i[n],k,C;return v&&(g(v[l+hn(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(V.windows&&e.ctrlKey&&e.altKey)&&!(V.mac&&e.altKey&&!e.ctrlKey)&&(k=Gf[e.keyCode])&&k!=s?(g(v[l+hn(k,e,!0)])||e.shiftKey&&(C=Xf[e.keyCode])!=s&&C!=k&&g(v[l+hn(C,e,!1)]))&&(a=!0):o&&e.shiftKey&&g(v[l+hn(s,e,!0)])&&(a=!0),!a&&g(v._any)&&(a=!0)),f&&(a=!0),a&&c&&e.stopPropagation(),pr=null,a}class qi{constructor(e,t,n,s,r){this.className=e,this.left=t,this.top=n,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,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=Bh(e);return[new qi(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return qd(e,t,n)}}function Bh(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==U.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function dl(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let r=i.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=i.posAtCoords({x:r.left+1,y:o}),a=i.posAtCoords({x:r.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function qd(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),r=i.textDirection==U.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Bh(i),f=o.querySelector(".cm-line"),c=f&&window.getComputedStyle(f),p=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),g=l.right-(c?parseInt(c.paddingRight):0),v=hr(i,n,1),k=hr(i,s,-1),C=v.type==Ee.Text?v:null,M=k.type==Ee.Text?k:null;if(C&&(i.lineWrapping||v.widgetLineBreaks)&&(C=dl(i,n,1,C)),M&&(i.lineWrapping||k.widgetLineBreaks)&&(M=dl(i,s,-1,M)),C&&M&&C.from==M.from&&C.to==M.to)return P(F(t.from,t.to,C));{let R=C?F(t.from,null,C):I(v,!1),N=M?F(null,t.to,M):I(k,!0),z=[];return(C||v).to<(M||k).from-(C&&M?1:0)||v.widgetLineBreaks>1&&R.bottom+i.defaultLineHeight/2<N.top?z.push(T(p,R.bottom,g,N.top)):R.bottom<N.top&&i.elementAtHeight((R.bottom+N.top)/2).type==Ee.Text&&(R.bottom=N.top=(R.bottom+N.top)/2),P(R).concat(z).concat(P(N))}function T(R,N,z,Y){return new qi(e,R-a.left,N-a.top,z-R,Y-N)}function P({top:R,bottom:N,horizontal:z}){let Y=[];for(let _=0;_<z.length;_+=2)Y.push(T(z[_],R,z[_+1],N));return Y}function F(R,N,z){let Y=1e9,_=-1e9,me=[];function Ae(ue,ge,X,ye,be){let ne=i.coordsAtPos(ue,ue==z.to?-2:2),re=i.coordsAtPos(X,X==z.from?2:-2);!ne||!re||(Y=Math.min(ne.top,re.top,Y),_=Math.max(ne.bottom,re.bottom,_),be==U.LTR?me.push(r&&ge?p:ne.left,r&&ye?g:re.right):me.push(!r&&ye?p:re.left,!r&&ge?g:ne.right))}let he=R??z.from,q=N??z.to;for(let ue of i.visibleRanges)if(ue.to>he&&ue.from<q)for(let ge=Math.max(ue.from,he),X=Math.min(ue.to,q);;){let ye=i.state.doc.lineAt(ge);for(let be of i.bidiSpans(ye)){let ne=be.from+ye.from,re=be.to+ye.from;if(ne>=X)break;re>ge&&Ae(Math.max(ne,ge),R==null&&ne<=he,Math.min(re,X),N==null&&re>=q,be.dir)}if(ge=ye.to+1,ge>=X)break}return me.length==0&&Ae(he,R==null,q,N==null,i.textDirection),{top:Y,bottom:_,horizontal:me}}function I(R,N){let z=l.top+(N?R.top:R.bottom);return{top:z,bottom:z,horizontal:[]}}}function jd(i,e){return i.constructor==e.constructor&&i.eq(e)}class _d{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(kn)!=e.state.facet(kn)&&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,n=e.facet(kn);for(;t<n.length&&n[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,n)=>!jd(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):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 kn=y.Facet.define();function Lh(i){return[te.define(e=>new _d(e,i)),kn.of(i)]}const Ti=y.Facet.define({combine(i){return y.combineConfig(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Kd(i={}){return[Ti.of(i),Jd,Ud,Yd,hh.of(!0)]}function Ih(i){return i.startState.facet(Ti)!=i.state.facet(Ti)}const Jd=Lh({above:!0,markers(i){let{state:e}=i,t=e.facet(Ti),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:y.EditorSelection.cursor(s.head,s.head>s.anchor?-1:1);for(let a of qi.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ih(i);return t&&pl(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){pl(e.state,i)},class:"cm-cursorLayer"});function pl(i,e){e.style.animationDuration=i.facet(Ti).cursorBlinkRate+"ms"}const Ud=Lh({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:qi.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Ih(i)},class:"cm-selectionLayer"}),Yd=y.Prec.highest(L.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Nh=y.StateEffect.define({map(i,e){return i==null?null:e.mapPos(i)}}),vi=y.StateField.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(Nh)?n.value:t,i)}}),Gd=te.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(vi);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"),(i.startState.field(vi)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(vi),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(vi)!=i&&this.view.dispatch({effects:Nh.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Xd(){return[vi,Gd]}function ml(i,e,t,n,s){e.lastIndex=0;for(let r=i.iterRange(t,n),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 Qd(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:r}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),r=Math.min(i.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class Zd{constructor(e){const{regexp:t,decoration:n,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,f,c)=>s(c,f,f+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,f,c)=>{let p=n(l,a,f);p&&c(f,f+l[0].length,p)};else if(n)this.addMatch=(l,a,f,c)=>c(f,f+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new y.RangeSetBuilder,n=t.add.bind(t);for(let{from:s,to:r}of Qd(e,this.maxLength))ml(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),s=Math.max(a,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),f=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),p=Math.min(r.to,f.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<f.to;l++)if(this.boundary.test(f.text[l-f.from])){p=l;break}}let g=[],v,k=(C,M,T)=>g.push(T.range(C,M));if(a==f)for(this.regexp.lastIndex=c-a.from;(v=this.regexp.exec(a.text))&&v.index<p-a.from;)this.addMatch(v,e,v.index+a.from,k);else ml(e.state.doc,this.regexp,c,p,(C,M)=>this.addMatch(M,e,C,k));t=t.update({filterFrom:c,filterTo:p,filter:(C,M)=>C<c||M>p,add:g})}}return t}}const mr=/x/.unicode!=null?"gu":"g",ep=new RegExp(`[\0-\b
10
10
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,mr),tp={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 Ts=null;function ip(){var i;if(Ts==null&&typeof document<"u"&&document.body){let e=document.body.style;Ts=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Ts||!1}const Cn=y.Facet.define({combine(i){let e=y.combineConfig(i,{render:null,specialChars:ep,addSpecialChars:null});return(e.replaceTabs=!ip())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,mr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,mr)),e}});function np(i={}){return[Cn.of(i),sp()]}let gl=null;function sp(){return gl||(gl=te.fromClass(class{constructor(i){this.view=i,this.decorations=H.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(Cn)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new Zd({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=y.codePointAt(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=y.countColumn(o.text,l,n-o.from);return H.replace({widget:new ap((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=H.replace({widget:new lp(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(Cn);i.startState.facet(Cn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const rp="•";function op(i){return i>=32?rp:i==10?"␤":String.fromCharCode(9216+i)}class lp extends _e{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=op(this.code),n=e.state.phrase("Control character")+" "+(tp[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class ap extends _e{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 hp(){return fp}const cp=H.line({class:"cm-activeLine"}),fp=te.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(cp.range(s.from)),e=s.from)}return H.set(t)}},{decorations:i=>i.decorations});class up extends _e{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?jt(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=$i(t[0],n.direction!="rtl"),r=parseInt(n.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 dp(i){let e=te.fromClass(class{constructor(t){this.view=t,this.placeholder=i?H.set([H.widget({widget:new up(i),side:1}).range(0)]):H.none}get decorations(){return this.view.state.doc.length?H.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,L.contentAttributes.of({"aria-placeholder":i})]:e}const gr=2e3;function pp(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>gr||t.off>gr||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=s;a++){let f=i.doc.line(a);f.length<=l&&r.push(y.EditorSelection.range(f.from+o,f.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=s;a++){let f=i.doc.line(a),c=y.findColumn(f.text,o,i.tabSize,!0);if(c<0)r.push(y.EditorSelection.cursor(f.to));else{let p=y.findColumn(f.text,l,i.tabSize);r.push(y.EditorSelection.range(f.from+c,f.from+p))}}}return r}function mp(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function yl(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,r=s>gr?-1:s==n.length?mp(i,e.clientX):y.countColumn(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function gp(i,e){let t=yl(i,e),n=i.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)},n=n.map(s.changes)}},get(s,r,o){let l=yl(i,s);if(!l)return n;let a=pp(i.state,t,l);return a.length?o?y.EditorSelection.create(a.concat(n.ranges)):y.EditorSelection.create(a):n}}:null}function yp(i){let e=(t=>t.altKey&&t.button==0);return L.mouseSelectionStyle.of((t,n)=>e(n)?gp(t,n):null)}const bp={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Sp={style:"cursor: crosshair"};function vp(i={}){let[e,t]=bp[i.key||"Alt"],n=te.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[n,L.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?Sp:null})]}const ui="-10000px";class Fh{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,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=n(o,r))}update(e,t){var n;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 f=r[a],c=-1;if(f){for(let p=0;p<this.tooltips.length;p++){let g=this.tooltips[p];g&&g.create==f.create&&(c=p)}if(c<0)o[a]=this.createTooltipView(f,a?o[a-1]:null),l&&(l[a]=!!f.above);else{let p=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),p.update&&p.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,f)=>t[f]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function xp(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Os=y.Facet.define({combine:i=>{var e,t,n;return{position:V.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||xp}}}),bl=new WeakMap,_r=te.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Os);this.position=e.position,this.parent=e.parent,this.classes=i.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 Fh(i,Kr,(t,n)=>this.createTooltip(t,n),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(),i.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 i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Os);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.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(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.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=ui,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);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 i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(V.gecko)t=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==ui&&r.style.left=="0px"){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(i=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=Wr(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Os).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:r}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],f=this.manager.tooltipViews[l],{dom:c}=f,p=i.pos[l],g=i.size[l];if(!p||a.clip!==!1&&(p.bottom<=Math.max(t.top,n.top)||p.top>=Math.min(t.bottom,n.bottom)||p.right<Math.max(t.left,n.left)-.1||p.left>Math.min(t.right,n.right)+.1)){c.style.top=ui;continue}let v=a.arrow?f.dom.querySelector(".cm-tooltip-arrow"):null,k=v?7:0,C=g.right-g.left,M=(e=bl.get(f))!==null&&e!==void 0?e:g.bottom-g.top,T=f.offset||kp,P=this.view.textDirection==U.LTR,F=g.width>n.right-n.left?P?n.left:n.right-g.width:P?Math.max(n.left,Math.min(p.left-(v?14:0)+T.x,n.right-C)):Math.min(Math.max(n.left,p.left-C+(v?14:0)-T.x),n.right-C),I=this.above[l];!a.strictSide&&(I?p.top-M-k-T.y<n.top:p.bottom+M+k+T.y>n.bottom)&&I==n.bottom-p.bottom>p.top-n.top&&(I=this.above[l]=!I);let R=(I?p.top-n.top:n.bottom-p.bottom)-k;if(R<M&&f.resize!==!1){if(R<this.view.defaultLineHeight){c.style.top=ui;continue}bl.set(f,M),c.style.height=(M=R)/r+"px"}else c.style.height&&(c.style.height="");let N=I?p.top-M-k-T.y:p.bottom+k+T.y,z=F+C;if(f.overlap!==!0)for(let Y of o)Y.left<z&&Y.right>F&&Y.top<N+M&&Y.bottom>N&&(N=I?Y.top-M-2-k:Y.bottom+k+2);if(this.position=="absolute"?(c.style.top=(N-i.parent.top)/r+"px",Sl(c,(F-i.parent.left)/s)):(c.style.top=N/r+"px",Sl(c,F/s)),v){let Y=p.left+(P?T.x:-T.x)-(F+14-7);v.style.left=Y/s+"px"}f.overlap!==!0&&o.push({left:F,top:N,right:z,bottom:N+M}),c.classList.toggle("cm-tooltip-above",I),c.classList.toggle("cm-tooltip-below",!I),f.positioned&&f.positioned(i.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 i of this.manager.tooltipViews)i.dom.style.top=ui}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Sl(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const wp=L.baseTheme({".cm-tooltip":{zIndex:500,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:"14px",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"}}}),kp={x:0,y:0},Kr=y.Facet.define({enables:[_r,wp]}),In=y.Facet.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class Zn{static create(e){return new Zn(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Fh(e,In,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}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 n of this.manager.tooltipViews){let s=n[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 Cp=Kr.compute([In],i=>{let e=i.facet(In);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Zn.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Ap{constructor(e,t,n,s,r){this.view=e,this.source=t,this.field=n,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,n=e.docView.nearest(t.target);if(!n)return;let s,r=1;if(n instanceof ft)s=n.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(c=>c.from<=s&&c.to>=s),f=a&&a.dir==U.RTL?-1:1;r=t.x<l.left?-f:f}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=>ke(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(_r),t=e?e.manager.tooltips.findIndex(n=>n.create==Zn.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;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&&!Mp(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Ep(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:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.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 cn=4;function Mp(i,e){let{left:t,right:n,top:s,bottom:r}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-cn&&e.clientX<=n+cn&&e.clientY>=s-cn&&e.clientY<=r+cn}function Ep(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=i.posAtCoords({x:n,y:s},!1);return a>=e&&a<=t}function Tp(i,e={}){let t=y.StateEffect.define(),n=y.StateField.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,y.MapMode.TrackDel);if(a!=null){let f=Object.assign(Object.create(null),l);f.pos=a,f.end!=null&&(f.end=r.changes.mapPos(f.end)),o.push(f)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(Op)&&(s=[]);return s},provide:s=>In.from(s)});return{active:n,extension:[n,te.define(s=>new Ap(s,i,n,t,e.hoverTime||300)),Cp]}}function Vh(i,e){let t=i.plugin(_r);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const Op=y.StateEffect.define(),vl=y.Facet.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Oi(i,e){let t=i.plugin(Hh),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Hh=te.fromClass(class{constructor(i){this.input=i.state.facet(Di),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(vl);this.top=new fn(i,!0,e.topContainer),this.bottom=new fn(i,!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(i){let e=i.state.facet(vl);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new fn(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new fn(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Di);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let f=this.specs.indexOf(a),c;f<0?(c=a(i.view),l.push(c)):(c=this.panels[f],c.update&&c.update(i)),s.push(c),(c.top?r:o).push(c)}this.specs=n,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 n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>L.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class fn{constructor(e,t,n){this.view=e,this.top=t,this.container=n,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=xl(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=xl(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 xl(i){let e=i.nextSibling;return i.remove(),e}const Di=y.Facet.define({enables:Hh});class at extends y.RangeValue{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}at.prototype.elementClass="";at.prototype.toDOM=void 0;at.prototype.mapMode=y.MapMode.TrackBefore;at.prototype.startSide=at.prototype.endSide=-1;at.prototype.point=!0;const An=y.Facet.define(),Dp=y.Facet.define(),Pp={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>y.RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Ci=y.Facet.define();function Rp(i){return[$h(),Ci.of({...Pp,...i})]}const wl=y.Facet.define({combine:i=>i.some(e=>e)});function $h(i){return[Bp]}const Bp=te.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(Ci).map(e=>new Cl(i,e)),this.fixed=!i.state.facet(wl);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(wl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=y.RangeSet.iter(this.view.state.facet(An),this.view.viewport.from),n=[],s=this.gutters.map(r=>new Lp(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==Ee.Text&&o){yr(t,n,l.from);for(let a of s)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==Ee.Text){yr(t,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(Ci),t=i.state.facet(Ci),n=i.docChanged||i.heightChanged||i.viewportChanged||!y.RangeSet.eq(i.startState.facet(An),i.state.facet(An),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Cl(this.view,r)):(this.gutters[o].update(i),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)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>L.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==U.LTR?{left:n,right:s}:{right:n,left:s}})});function kl(i){return Array.isArray(i)?i:[i]}function yr(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Lp{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=y.RangeSet.iter(e.markers,t.from)}addElement(e,t,n){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 Wh(e,o,r,n);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];yr(this.cursor,s,t.from),n.length&&(s=s.concat(n));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 n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let r of e.state.facet(Dp)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Cl{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 n in t.domEventHandlers)this.dom.addEventListener(n,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[n](e,l,s)&&s.preventDefault()});this.markers=kl(t.markers(e)),t.initialSpacer&&(this.spacer=new Wh(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=kl(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 n=e.view.viewport;return!y.RangeSet.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Wh{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Ip(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,f=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let p=o;p<this.markers.length;p++)if(this.markers[p].compare(a)){l=p,f=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let p=s.nextSibling;s.remove(),s=p}}if(!a)break;a.toDOM&&(f?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),f&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function Ip(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const Np=y.Facet.define(),Fp=y.Facet.define(),Nt=y.Facet.define({combine(i){return y.combineConfig(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let s in t){let r=n[s],o=t[s];n[s]=r?(l,a,f)=>r(l,a,f)||o(l,a,f):o}return n}})}});class Ds extends at{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ps(i,e){return i.state.facet(Nt).formatNumber(e,i.state)}const Vp=Ci.compute([Nt],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Np)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new Ds(Ps(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(Fp)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Nt)!=e.state.facet(Nt),initialSpacer(e){return new Ds(Ps(e,Al(e.state.doc.lines)))},updateSpacer(e,t){let n=Ps(t.view,Al(t.view.state.doc.lines));return n==e.number?e:new Ds(n)},domEventHandlers:i.facet(Nt).domEventHandlers,side:"before"}));function Hp(i={}){return[Nt.of(i),$h(),Vp]}function Al(i){let e=9;for(;e<i;)e=e*10+9;return e}const $p=new class extends at{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Wp=An.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push($p.range(s)))}return y.RangeSet.of(e)});function zp(){return Wp}var Rs;const Ft=new Oe;function zh(i){return y.Facet.define({combine:i?e=>e.concat(i):void 0})}const Jr=new Oe;let ze=class{constructor(e,t,n=[],s=""){this.data=e,this.name=s,y.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(y.EditorState.prototype,"tree",{get(){return ie(this)}}),this.parser=t,this.extension=[yt.of(this),y.EditorState.languageData.of((r,o,l)=>{let a=Ml(r,o,l),f=a.type.prop(Ft);if(!f)return[];let c=r.facet(f),p=a.type.prop(Jr);if(p){let g=a.resolve(o-a.from,l);for(let v of p)if(v.test(g,r)){let k=r.facet(v.facet);return v.type=="replace"?k:k.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Ml(e,t,n).type.prop(Ft)==this.data}findRegions(e){let t=e.facet(yt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(Ft)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(Oe.mounted);if(l){if(l.tree.prop(Ft)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let f=r.children[a];f instanceof Fe&&s(f,r.positions[a]+o)}};return s(ie(e),0),n}get allowsNesting(){return!0}};ze.setState=y.StateEffect.define();function Ml(i,e,t){let n=i.facet(yt),s=ie(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Gn.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Ut extends ze{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=zh(e.languageData);return new Ut(t,e.parser.configure({props:[Ft.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Ut(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ie(i){let e=i.field(ze.state,!1);return e?e.tree:Fe.empty}let qp=class{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 n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},di=null,jp=class br{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new br(e,t,[],Fe.empty,0,n,[],null)}startParse(){return this.parser.startParse(new qp(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Fe.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;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(dt.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n: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(dt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=di;di=this;try{return e()}finally{di=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=El(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((f,c,p,g)=>a.push({fromA:f,toA:c,fromB:p,toB:g})),n=dt.applyChanges(n,a),s=Fe.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let c=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);c<p&&l.push({from:c,to:p})}}}return new br(this.parser,t,n,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 n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=El(this.fragments,s,r),this.skipped.splice(n--,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 Ma{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=di;if(a){for(let f of s)a.tempSkipped.push(f);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Fe(Zt.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 di}};function El(i,e,t){return dt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}let Sr=class vr{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),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new vr(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=jp.create(e.facet(yt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new vr(n)}};ze.state=y.StateField.define({create:Sr.init,update(i,e){for(let t of e.effects)if(t.is(ze.setState))return t.value;return e.startState.facet(yt)!=e.state.facet(yt)?Sr.init(e.state):i.apply(e)}});let qh=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(qh=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Bs=typeof navigator<"u"&&(!((Rs=navigator.scheduling)===null||Rs===void 0)&&Rs.isInputPending)?()=>navigator.scheduling.isInputPending():null,_p=te.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(ze.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(ze.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qh(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:n,viewport:{to:s}}=this.view,r=n.field(ze.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&&n.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:ze.setState.of(new Sr(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=>ke(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()}}}),yt=y.Facet.define({combine(i){return i.length?i[0]:null},enables:i=>[ze.state,_p,L.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class Ur{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Kp=y.Facet.define(),ti=y.Facet.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Nn(i){let e=i.facet(ti);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Pi(i,e){let t="",n=i.tabSize,s=i.facet(ti)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Yr(i,e){i instanceof y.EditorState&&(i=new es(i));for(let n of i.state.facet(Kp)){let s=n(i,e);if(s!==void 0)return s}let t=ie(i.state);return t.length>=e?Jp(i,t,e):null}class es{constructor(e,t={}){this.state=e,this.options=t,this.unit=Nn(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return y.countColumn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ts=new Oe;function Jp(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let r=[];for(let o=s;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return jh(n,i,t)}function jh(i,e,t){for(let n=i;n;n=n.next){let s=Yp(n.node);if(s)return s(Gr.create(e,t,n))}return 0}function Up(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Yp(i){let e=i.type.prop(ts);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(Oe.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>_h(o,!0,1,void 0,r&&!Up(o)?s.from:void 0)}return i.parent==null?Gp:null}function Gp(){return 0}class Gr extends es{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new Gr(e,t,n)}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 n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Xp(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return jh(this.context.next,this.base,this.pos)}}function Xp(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Qp(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,r=i.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==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let f=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+f}}l=a.to}}function Mn({closing:i,align:e=!0,units:t=1}){return n=>_h(n,e,t,i)}function _h(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==i.pos+o,a=e?Qp(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}const Zp=i=>i.baseIndent;function Ai({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const em=200;function tm(){return y.EditorState.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+em)return i;let r=t.sliceString(s.from,n);if(!e.some(f=>f.test(r)))return i;let{state:o}=i,l=-1,a=[];for(let{head:f}of o.selection.ranges){let c=o.doc.lineAt(f);if(c.from==l)continue;l=c.from;let p=Yr(o,c.from);if(p==null)continue;let g=/^\s*/.exec(c.text)[0],v=Pi(o,p);g!=v&&a.push({from:c.from,to:c.from+g.length,insert:v})}return a.length?[i,{changes:a,sequential:!0}]:i})}const im=y.Facet.define(),is=new Oe;function Xr(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function nm(i,e,t){let n=ie(i);if(n.length<t)return null;let s=n.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(is);if(a&&(l.to<n.length-50||n.length==i.doc.length||!sm(l))){let f=a(l,i);f&&f.from<=t&&f.from>=e&&f.to>t&&(r=f)}}return r}function sm(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Fn(i,e,t){for(let n of i.facet(im)){let s=n(i,e,t);if(s)return s}return nm(i,e,t)}function Kh(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const ns=y.StateEffect.define({map:Kh}),ji=y.StateEffect.define({map:Kh});function Jh(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const Et=y.StateField.define({create(){return H.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Tl(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(ns)&&!rm(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(Gh),s=n?H.replace({widget:new um(n(e.state,t.value))}):Ol;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(ji)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=Tl(i,e.selection.main.head)),i},provide:i=>L.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<i.length;){let n=i[t++],s=i[t++];if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Ol.range(n,s))}return H.set(e,!0)}});function Tl(i,e,t=e){let n=!1;return i.between(e,t,(s,r)=>{s<t&&r>e&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):i}function Vn(i,e,t){var n;let s=null;return(n=i.field(Et,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function rm(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function Uh(i,e){return i.field(Et,!1)?e:e.concat(y.StateEffect.appendConfig.of(Xh()))}const om=i=>{for(let e of Jh(i)){let t=Fn(i.state,e.from,e.to);if(t)return i.dispatch({effects:Uh(i.state,[ns.of(t),Yh(i,t)])}),!0}return!1},lm=i=>{if(!i.state.field(Et,!1))return!1;let e=[];for(let t of Jh(i)){let n=Vn(i.state,t.from,t.to);n&&e.push(ji.of(n),Yh(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function Yh(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return L.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const am=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Fn(e,s.from,s.to);r&&t.push(ns.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:Uh(i.state,t)}),!!t.length},hm=i=>{let e=i.state.field(Et,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(ji.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},cm=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:om},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:lm},{key:"Ctrl-Alt-[",run:am},{key:"Ctrl-Alt-]",run:hm}],fm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Gh=y.Facet.define({combine(i){return y.combineConfig(i,fm)}});function Xh(i){return[Et,mm]}function Qh(i,e){let{state:t}=i,n=t.facet(Gh),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Vn(i.state,l.from,l.to);a&&i.dispatch({effects:ji.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Ol=H.replace({widget:new class extends _e{toDOM(i){return Qh(i,null)}}});class um extends _e{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Qh(e,this.value)}}const dm={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ls extends at{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 pm(i={}){let e={...dm,...i},t=new Ls(e,!0),n=new Ls(e,!1),s=te.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(yt)!=o.state.facet(yt)||o.startState.field(Et,!1)!=o.state.field(Et,!1)||ie(o.startState)!=ie(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new y.RangeSetBuilder;for(let a of o.viewportLineBlocks){let f=Vn(o.state,a.from,a.to)?n:Fn(o.state,a.from,a.to)?t:null;f&&l.add(a.from,a.from,f)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Rp({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||y.RangeSet.empty},initialSpacer(){return new Ls(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let f=Vn(o.state,l.from,l.to);if(f)return o.dispatch({effects:ji.of(f)}),!0;let c=Fn(o.state,l.from,l.to);return c?(o.dispatch({effects:ns.of(c)}),!0):!1}}}),Xh()]}const mm=L.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"}});let Qr=class Zh{constructor(e,t){this.specs=e;let n;function s(l){let a=tt.newName();return(n||(n=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 ze?l=>l.prop(Ft)==o.data:o?l=>l==o:void 0,this.style=Ea(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new tt(n):null,this.themeType=t.themeType}static define(e,t){return new Zh(e,t||{})}};const xr=y.Facet.define(),ec=y.Facet.define({combine(i){return i.length?[i[0]]:null}});function Is(i){let e=i.facet(xr);return e.length?e:i.facet(ec)}function tc(i,e){let t=[ym],n;return i instanceof Qr&&(i.module&&t.push(L.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(ec.of(i)):n?t.push(xr.computeN([L.darkTheme],s=>s.facet(L.darkTheme)==(n=="dark")?[i]:[])):t.push(xr.of(i)),t}let gm=class{constructor(e){this.markCache=Object.create(null),this.tree=ie(e.state),this.decorations=this.buildDeco(e,Is(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ie(e.state),n=Is(e.state),s=n!=Is(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,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return H.none;let n=new y.RangeSetBuilder;for(let{from:s,to:r}of e.visibleRanges)Ta(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=H.mark({class:a})))},s,r);return n.finish()}};const ym=y.Prec.high(te.fromClass(gm,{decorations:i=>i.decorations})),bm=Qr.define([{tag:E.meta,color:"#404740"},{tag:E.link,textDecoration:"underline"},{tag:E.heading,textDecoration:"underline",fontWeight:"bold"},{tag:E.emphasis,fontStyle:"italic"},{tag:E.strong,fontWeight:"bold"},{tag:E.strikethrough,textDecoration:"line-through"},{tag:E.keyword,color:"#708"},{tag:[E.atom,E.bool,E.url,E.contentSeparator,E.labelName],color:"#219"},{tag:[E.literal,E.inserted],color:"#164"},{tag:[E.string,E.deleted],color:"#a11"},{tag:[E.regexp,E.escape,E.special(E.string)],color:"#e40"},{tag:E.definition(E.variableName),color:"#00f"},{tag:E.local(E.variableName),color:"#30a"},{tag:[E.typeName,E.namespace],color:"#085"},{tag:E.className,color:"#167"},{tag:[E.special(E.variableName),E.macroName],color:"#256"},{tag:E.definition(E.propertyName),color:"#00c"},{tag:E.comment,color:"#940"},{tag:E.invalid,color:"#f00"}]),Sm=L.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ic=1e4,nc="()[]{}",sc=y.Facet.define({combine(i){return y.combineConfig(i,{afterCursor:!0,brackets:nc,maxScanDistance:ic,renderMatch:wm})}}),vm=H.mark({class:"cm-matchingBracket"}),xm=H.mark({class:"cm-nonmatchingBracket"});function wm(i){let e=[],t=i.matched?vm:xm;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const km=y.StateField.define({create(){return H.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(sc);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=Xe(e.state,s.head,-1,n)||s.head>0&&Xe(e.state,s.head-1,1,n)||n.afterCursor&&(Xe(e.state,s.head,1,n)||s.head<e.state.doc.length&&Xe(e.state,s.head+1,-1,n));r&&(t=t.concat(n.renderMatch(r,e.state)))}return H.set(t,!0)},provide:i=>L.decorations.from(i)}),Cm=[km,Sm];function Am(i={}){return[sc.of(i),Cm]}const Mm=new Oe;function wr(i,e,t){let n=i.prop(e<0?Oe.openedBy:Oe.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function kr(i){let e=i.type.prop(Mm);return e?e(i.node):i}function Xe(i,e,t,n={}){let s=n.maxScanDistance||ic,r=n.brackets||nc,o=ie(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let f=wr(a.type,t,r);if(f&&a.from<a.to){let c=kr(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return Em(i,e,t,a,c,f,r)}}return Tm(i,e,t,o,l.type,s,r)}function Em(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},f=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(f==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let p=kr(c);return{start:a,end:p?{from:p.from,to:p.to}:void 0,matched:!0}}else if(wr(c.type,t,o))f++;else if(wr(c.type,-t,o)){if(f==0){let p=kr(c);return{start:a,end:p&&p.from<p.to?{from:p.from,to:p.to}:void 0,matched:!1}}f--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Tm(i,e,t,n,s,r,o){let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let f={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),p=0;for(let g=0;!c.next().done&&g<=r;){let v=c.value;t<0&&(g+=v.length);let k=e+g*t;for(let C=t>0?0:v.length-1,M=t>0?v.length:-1;C!=M;C+=t){let T=o.indexOf(v[C]);if(!(T<0||n.resolveInner(k+C,1).type!=s))if(T%2==0==t>0)p++;else{if(p==1)return{start:f,end:{from:k+C,to:k+C+1},matched:T>>1==a>>1};p--}}t>0&&(g+=v.length)}return c.done?{start:f,matched:!1}:null}const Om=Object.create(null),Dl=[Zt.none],Pl=[],Rl=Object.create(null),Dm=Object.create(null);for(let[i,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"]])Dm[i]=Pm(Om,e);function Ns(i,e){Pl.indexOf(i)>-1||(Pl.push(i),console.warn(e))}function Pm(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let f of l.split(".")){let c=i[f]||E[f];c?typeof c=="function"?a.length?a=a.map(c):Ns(f,`Modifier ${f} used at start of tag`):a.length?Ns(f,`Tag ${f} used as modifier`):a=Array.isArray(c)?c:[c]:Ns(f,`Unknown highlighting tag ${f}`)}for(let f of a)t.push(f)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=Rl[s];if(r)return r.id;let o=Rl[s]=Zt.define({id:Dl.length,name:n,props:[Oa({[n]:t})]});return Dl.push(o),o.id}U.RTL,U.LTR;const Rm=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=eo(i.state,t.from);return n.line?Bm(i):n.block?Im(i):!1};function Zr(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const Bm=Zr(Vm,0),Lm=Zr(rc,0),Im=Zr((i,e)=>rc(i,e,Fm(e)),0);function eo(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const pi=50;function Nm(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-pi,n),o=i.sliceDoc(s,s+pi),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,f=r.length-l;if(r.slice(f-e.length,f)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,p;s-n<=2*pi?c=p=i.sliceDoc(n,s):(c=i.sliceDoc(n,n+pi),p=i.sliceDoc(s-pi,s));let g=/^\s*/.exec(c)[0].length,v=/\s*$/.exec(p)[0].length,k=p.length-v-t.length;return c.slice(g,g+e.length)==e&&p.slice(k,k+t.length)==t?{open:{pos:n+g+e.length,margin:/\s/.test(c.charAt(g+e.length))?1:0},close:{pos:s-v-t.length,margin:/\s/.test(p.charAt(k-1))?1:0}}:null}function Fm(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function rc(i,e,t=e.selection.ranges){let n=t.map(r=>eo(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>Nm(e,n[o],r.from,r.to));if(i!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(i!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=n[o],{open:f,close:c}=l;r.push({from:f.pos-a.open.length,to:f.pos+f.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function Vm(i,e,t=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of t){let l=n.length,a=1e9,f=eo(e,r).line;if(f){for(let c=r;c<=o;){let p=e.doc.lineAt(c);if(p.from>s&&(r==o||o>p.from)){s=p.from;let g=/^\s*/.exec(p.text)[0].length,v=g==p.length,k=p.text.slice(g,g+f.length)==f?g:-1;g<p.text.length&&g<a&&(a=g),n.push({line:p,comment:k,token:f,indent:g,empty:v,single:!1})}c=p.to+1}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=!0)}}if(i!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:f,empty:c,single:p}of n)(p||!c)&&r.push({from:l.from+f,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let f=o.from+l,c=f+a.length;o.text[c-o.from]==" "&&c++,r.push({from:f,to:c})}return{changes:r}}return null}const Cr=y.Annotation.define(),Hm=y.Annotation.define(),$m=y.Facet.define(),oc=y.Facet.define({combine(i){return y.combineConfig(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),lc=y.StateField.define({create(){return Qe.empty},update(i,e){let t=e.state.facet(oc),n=e.annotation(Cr);if(n){let a=Re.fromTransaction(e,n.selection),f=n.side,c=f==0?i.undone:i.done;return a?c=Hn(c,c.length,t.minDepth,a):c=cc(c,e.startState.selection),new Qe(f==0?n.rest:c,f==0?c:n.rest)}let s=e.annotation(Hm);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(y.Transaction.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=Re.fromTransaction(e),o=e.annotation(y.Transaction.time),l=e.annotation(y.Transaction.userEvent);return r?i=i.addChanges(r,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Qe(i.done.map(Re.fromJSON),i.undone.map(Re.fromJSON))}});function Wm(i={}){return[lc,oc.of(i),L.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?ac:e.inputType=="historyRedo"?Ar:null;return n?(e.preventDefault(),n(t)):!1}})]}function ss(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(lc,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const ac=ss(0,!1),Ar=ss(1,!1),zm=ss(0,!0),qm=ss(1,!0);class Re{constructor(e,t,n,s,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Re(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;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:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Re(e.changes&&y.ChangeSet.fromJSON(e.changes),[],e.mapped&&y.ChangeDesc.fromJSON(e.mapped),e.startSelection&&y.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(y.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=Ve;for(let s of e.startState.facet($m)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new Re(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Ve)}static selection(e){return new Re(void 0,Ve,void 0,void 0,e)}}function Hn(i,e,t,n){let s=e+1>t+20?e-t-1:0,r=i.slice(s,e);return r.push(n),r}function jm(i,e){let t=[],n=!1;return i.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let f=t[a++],c=t[a++];l>=f&&o<=c&&(n=!0)}}),n}function _m(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function hc(i,e){return i.length?e.length?i.concat(e):i:e}const Ve=[],Km=200;function cc(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Km));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Hn(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Re.selection([e])]}function Jm(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Fs(i,e){if(!i.length)return i;let t=i.length,n=Ve;for(;t;){let s=Um(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=i.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Re.selection(n)]:Ve}function Um(i,e,t){let n=hc(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):Ve,t);if(!i.changes)return Re.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new Re(s,y.StateEffect.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const Ym=/^(input\.type|delete)($|\.)/;class Qe{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Qe(this.done,this.undone):this}addChanges(e,t,n,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||Ym.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,jm(l.changes,e.changes))||n=="input.type.compose")?o=Hn(o,o.length-1,s.minDepth,new Re(e.changes.compose(l.changes),hc(y.StateEffect.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ve)):o=Hn(o,o.length,s.minDepth,e),new Qe(o,Ve,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ve;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&_m(r[r.length-1],e)?this:new Qe(cc(this.done,e),this.undone,t,n)}addMapping(e){return new Qe(Fs(this.done,e),Fs(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){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(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Cr.of({side:e,rest:Jm(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?Ve:s.slice(0,s.length-1);return r.mapped&&(l=Fs(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Cr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Qe.empty=new Qe(Ve,Ve);const Gm=[{key:"Mod-z",run:ac,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ar,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ar,preventDefault:!0},{key:"Mod-u",run:zm,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:qm,preventDefault:!0}];function ii(i,e){return y.EditorSelection.create(i.ranges.map(e),i.mainIndex)}function nt(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ke({state:i,dispatch:e},t){let n=ii(i.selection,t);return n.eq(i.selection,!0)?!1:(e(nt(i,n)),!0)}function rs(i,e){return y.EditorSelection.cursor(e?i.to:i.from)}function fc(i,e){return Ke(i,t=>t.empty?i.moveByChar(t,e):rs(t,e))}function Ce(i){return i.textDirectionAt(i.state.selection.main.head)==U.LTR}const uc=i=>fc(i,!Ce(i)),dc=i=>fc(i,Ce(i));function pc(i,e){return Ke(i,t=>t.empty?i.moveByGroup(t,e):rs(t,e))}const Xm=i=>pc(i,!Ce(i)),Qm=i=>pc(i,Ce(i));function Zm(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function os(i,e,t){let n=ie(i).resolveInner(e.head),s=t?Oe.closedBy:Oe.openedBy;for(let a=e.head;;){let f=t?n.childAfter(a):n.childBefore(a);if(!f)break;Zm(i,f,s)?n=f:a=t?f.to:f.from}let r=n.type.prop(s),o,l;return r&&(o=t?Xe(i,n.from,1):Xe(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,y.EditorSelection.cursor(l,t?-1:1)}const eg=i=>Ke(i,e=>os(i.state,e,!Ce(i))),tg=i=>Ke(i,e=>os(i.state,e,Ce(i)));function mc(i,e){return Ke(i,t=>{if(!t.empty)return rs(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const gc=i=>mc(i,!1),yc=i=>mc(i,!0);function bc(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(L.scrollMargins)){let o=r(i);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}s=i.scrollDOM.clientHeight-t-n}else s=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,s-5)}}function Sc(i,e){let t=bc(i),{state:n}=i,s=ii(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):rs(o,e));if(s.eq(n.selection))return!1;let r;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,f=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<f&&(r=L.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(nt(n,s),{effects:r}),!0}const Bl=i=>Sc(i,!1),Mr=i=>Sc(i,!0);function bt(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let r=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=y.EditorSelection.cursor(n.from+r))}return s}const ig=i=>Ke(i,e=>bt(i,e,!0)),ng=i=>Ke(i,e=>bt(i,e,!1)),sg=i=>Ke(i,e=>bt(i,e,!Ce(i))),rg=i=>Ke(i,e=>bt(i,e,Ce(i))),og=i=>Ke(i,e=>y.EditorSelection.cursor(i.lineBlockAt(e.head).from,1)),lg=i=>Ke(i,e=>y.EditorSelection.cursor(i.lineBlockAt(e.head).to,-1));function ag(i,e,t){let n=!1,s=ii(i.selection,r=>{let o=Xe(i,r.head,-1)||Xe(i,r.head,1)||r.head>0&&Xe(i,r.head-1,1)||r.head<i.doc.length&&Xe(i,r.head+1,-1);if(!o||!o.end)return r;n=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return y.EditorSelection.cursor(l)});return n?(e(nt(i,s)),!0):!1}const hg=({state:i,dispatch:e})=>ag(i,e);function We(i,e){let t=ii(i.state.selection,n=>{let s=e(n);return y.EditorSelection.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(nt(i.state,t)),!0)}function vc(i,e){return We(i,t=>i.moveByChar(t,e))}const xc=i=>vc(i,!Ce(i)),wc=i=>vc(i,Ce(i));function kc(i,e){return We(i,t=>i.moveByGroup(t,e))}const cg=i=>kc(i,!Ce(i)),fg=i=>kc(i,Ce(i)),ug=i=>We(i,e=>os(i.state,e,!Ce(i))),dg=i=>We(i,e=>os(i.state,e,Ce(i)));function Cc(i,e){return We(i,t=>i.moveVertically(t,e))}const Ac=i=>Cc(i,!1),Mc=i=>Cc(i,!0);function Ec(i,e){return We(i,t=>i.moveVertically(t,e,bc(i).height))}const Ll=i=>Ec(i,!1),Il=i=>Ec(i,!0),pg=i=>We(i,e=>bt(i,e,!0)),mg=i=>We(i,e=>bt(i,e,!1)),gg=i=>We(i,e=>bt(i,e,!Ce(i))),yg=i=>We(i,e=>bt(i,e,Ce(i))),bg=i=>We(i,e=>y.EditorSelection.cursor(i.lineBlockAt(e.head).from)),Sg=i=>We(i,e=>y.EditorSelection.cursor(i.lineBlockAt(e.head).to)),Nl=({state:i,dispatch:e})=>(e(nt(i,{anchor:0})),!0),Fl=({state:i,dispatch:e})=>(e(nt(i,{anchor:i.doc.length})),!0),Vl=({state:i,dispatch:e})=>(e(nt(i,{anchor:i.selection.main.anchor,head:0})),!0),Hl=({state:i,dispatch:e})=>(e(nt(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),vg=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),xg=({state:i,dispatch:e})=>{let t=ls(i).map(({from:n,to:s})=>y.EditorSelection.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:y.EditorSelection.create(t),userEvent:"select"})),!0},wg=({state:i,dispatch:e})=>{let t=ii(i.selection,n=>{let s=ie(i),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return y.EditorSelection.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(nt(i,t)),!0)},kg=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=y.EditorSelection.create([t.main]):t.main.empty||(n=y.EditorSelection.create([y.EditorSelection.cursor(t.main.head)])),n?(e(nt(i,n)),!0):!1};function _i(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=un(i,a,!1)):a>o&&(t="delete.forward",a=un(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=un(i,o,!1),l=un(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:y.EditorSelection.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(i.dispatch(n.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?L.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function un(i,e,t){if(i instanceof L)for(let n of i.state.facet(L.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Tc=(i,e,t)=>_i(i,n=>{let s=n.from,{state:r}=i,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 f=y.countColumn(l,r.tabSize),c=f%Nn(r)||Nn(r);for(let p=0;p<c&&l[l.length-1-p]==" ";p++)s--;a=s}else a=y.findClusterBreak(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=y.findClusterBreak(o.text,a-o.from,!1,!1)+o.from);return a}),Er=i=>Tc(i,!1,!0),Oc=i=>Tc(i,!0,!1),Dc=(i,e)=>_i(i,t=>{let n=t.head,{state:s}=i,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==t.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=y.findClusterBreak(r.text,n-r.from,e)+r.from,f=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),c=o(f);if(l!=null&&c!=l)break;(f!=" "||n!=t.head)&&(l=c),n=a}return n}),Pc=i=>Dc(i,!1),Cg=i=>Dc(i,!0),Ag=i=>_i(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Mg=i=>_i(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Eg=i=>_i(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Tg=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:y.Text.of(["",""])},range:y.EditorSelection.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Og=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,r=i.doc.lineAt(s),o=s==r.from?s-1:y.findClusterBreak(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:y.findClusterBreak(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:i.doc.slice(s,l).append(i.doc.slice(o,s))},range:y.EditorSelection.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ls(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),r=i.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=i.doc.lineAt(n.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});t=r.number+1}return e}function Rc(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of ls(i)){if(t?r.to==i.doc.length:r.from==0)continue;let o=i.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+i.lineBreak});for(let a of r.ranges)s.push(y.EditorSelection.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:i.lineBreak+o.text});for(let a of r.ranges)s.push(y.EditorSelection.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:y.EditorSelection.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Dg=({state:i,dispatch:e})=>Rc(i,e,!1),Pg=({state:i,dispatch:e})=>Rc(i,e,!0);function Bc(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of ls(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Rg=({state:i,dispatch:e})=>Bc(i,e,!1),Bg=({state:i,dispatch:e})=>Bc(i,e,!0),Lg=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(ls(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=ii(e.selection,s=>{let r;if(i.lineWrapping){let o=i.lineBlockAt(s.head),l=i.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,r)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Ig(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ie(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(Oe.closedBy))&&r.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const $l=Lc(!1),Ng=Lc(!0);function Lc(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!i&&r==o&&Ig(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let f=new es(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Yr(f,r);for(c==null&&(c=y.countColumn(/^\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 p=["",Pi(e,c)];return a&&p.push(Pi(e,f.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:y.Text.of(p)},range:y.EditorSelection.cursor(r+1+p[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function to(i,e){let t=-1;return i.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,s,n),t=l.number),o=l.to+1}let r=i.changes(s);return{changes:s,range:y.EditorSelection.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const Fg=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new es(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=to(i,(r,o,l)=>{let a=Yr(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let f=/^\s*/.exec(r.text)[0],c=Pi(i,a);(f!=c||l.from<r.from+f.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+f.length,insert:c}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},Ic=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(to(i,(t,n)=>{n.push({from:t.from,insert:i.facet(ti)})}),{userEvent:"input.indent"})),!0),Nc=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(to(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=y.countColumn(s,i.tabSize),o=0,l=Pi(i,Math.max(0,r-Nn(i)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Vg=i=>(i.setTabFocusMode(),!0),Hg=[{key:"Ctrl-b",run:uc,shift:xc,preventDefault:!0},{key:"Ctrl-f",run:dc,shift:wc},{key:"Ctrl-p",run:gc,shift:Ac},{key:"Ctrl-n",run:yc,shift:Mc},{key:"Ctrl-a",run:og,shift:bg},{key:"Ctrl-e",run:lg,shift:Sg},{key:"Ctrl-d",run:Oc},{key:"Ctrl-h",run:Er},{key:"Ctrl-k",run:Ag},{key:"Ctrl-Alt-h",run:Pc},{key:"Ctrl-o",run:Tg},{key:"Ctrl-t",run:Og},{key:"Ctrl-v",run:Mr}],$g=[{key:"ArrowLeft",run:uc,shift:xc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Xm,shift:cg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:sg,shift:gg,preventDefault:!0},{key:"ArrowRight",run:dc,shift:wc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Qm,shift:fg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rg,shift:yg,preventDefault:!0},{key:"ArrowUp",run:gc,shift:Ac,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Nl,shift:Vl},{mac:"Ctrl-ArrowUp",run:Bl,shift:Ll},{key:"ArrowDown",run:yc,shift:Mc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Fl,shift:Hl},{mac:"Ctrl-ArrowDown",run:Mr,shift:Il},{key:"PageUp",run:Bl,shift:Ll},{key:"PageDown",run:Mr,shift:Il},{key:"Home",run:ng,shift:mg,preventDefault:!0},{key:"Mod-Home",run:Nl,shift:Vl},{key:"End",run:ig,shift:pg,preventDefault:!0},{key:"Mod-End",run:Fl,shift:Hl},{key:"Enter",run:$l,shift:$l},{key:"Mod-a",run:vg},{key:"Backspace",run:Er,shift:Er},{key:"Delete",run:Oc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pc},{key:"Mod-Delete",mac:"Alt-Delete",run:Cg},{mac:"Mod-Backspace",run:Mg},{mac:"Mod-Delete",run:Eg}].concat(Hg.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),Wg=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:eg,shift:ug},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:tg,shift:dg},{key:"Alt-ArrowUp",run:Dg},{key:"Shift-Alt-ArrowUp",run:Rg},{key:"Alt-ArrowDown",run:Pg},{key:"Shift-Alt-ArrowDown",run:Bg},{key:"Escape",run:kg},{key:"Mod-Enter",run:Ng},{key:"Alt-l",mac:"Ctrl-l",run:xg},{key:"Mod-i",run:wg,preventDefault:!0},{key:"Mod-[",run:Nc},{key:"Mod-]",run:Ic},{key:"Mod-Alt-\\",run:Fg},{key:"Shift-Mod-k",run:Lg},{key:"Shift-Mod-\\",run:hg},{key:"Mod-/",run:Rm},{key:"Alt-A",run:Lm},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Vg}].concat($g),zg={key:"Tab",run:Ic,shift:Nc},cS=()=>i=>{try{JSON.parse(i.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=qg(e,i.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function qg(i,e){let t;return(t=i.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=i.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const jg=Ut.define({name:"json",parser:Qf.configure({props:[ts.add({Object:Ai({except:/^\s*\}/}),Array:Ai({except:/^\s*\]/})}),is.add({"Object Array":Xr})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function fS(){return new Ur(jg)}class Wl{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class xt{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(Ze).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((c,p)=>c.from-p.from||c.to-p.to),o=new y.RangeSetBuilder,l=[],a=0;for(let c=0;;){let p=c==r.length?null:r[c];if(!p&&!l.length)break;let g,v;for(l.length?(g=a,v=l.reduce((C,M)=>Math.min(C,M.to),p&&p.from>g?p.from:1e8)):(g=p.from,v=p.to,l.push(p),c++);c<r.length;){let C=r[c];if(C.from==g&&(C.to>C.from||C.to==g))l.push(C),c++,v=Math.min(C.to,v);else{v=Math.min(C.from,v);break}}let k=r0(l);if(l.some(C=>C.from==C.to||C.from==C.to-1&&n.doc.lineAt(C.from).to==C.from))o.add(g,g,H.widget({widget:new t0(k),diagnostics:l.slice()}));else{let C=l.reduce((M,T)=>T.markClass?M+" "+T.markClass:M,"");o.add(g,v,H.mark({class:"cm-lintRange cm-lintRange-"+k+C,diagnostics:l.slice(),inclusiveEnd:l.some(M=>M.to>v)}))}a=v;for(let C=0;C<l.length;C++)l[C].to<=a&&l.splice(C--,1)}let f=o.finish();return new xt(f,t,Yt(f))}}function Yt(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new Wl(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new Wl(n.from,r,n.diagnostic)}}),n}function _g(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(Ze).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(io))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function Fc(i,e){return i.field(Ne,!1)?e:e.concat(y.StateEffect.appendConfig.of(Wc))}function Kg(i,e){return{effects:Fc(i,[io.of(e)])}}const io=y.StateEffect.define(),no=y.StateEffect.define(),Vc=y.StateEffect.define(),Ne=y.StateField.define({create(){return new xt(H.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=Yt(t,i.selected.diagnostic,r)||Yt(t,null,r)}!t.size&&s&&e.state.facet(Ze).autoPanel&&(s=null),i=new xt(t,s,n)}for(let t of e.effects)if(t.is(io)){let n=e.state.facet(Ze).autoPanel?t.value.length?Ri.open:null:i.panel;i=xt.init(t.value,n,e.state)}else t.is(no)?i=new xt(i.diagnostics,t.value?Ri.open:null,i.selected):t.is(Vc)&&(i=new xt(i.diagnostics,i.panel,t.value));return i},provide:i=>[Di.from(i,e=>e.panel),L.decorations.from(i,e=>e.diagnostics)]}),Jg=H.mark({class:"cm-lintRange cm-lintRange-active"});function Ug(i,e,t){let{diagnostics:n}=i.state.field(Ne),s,r=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,f,{spec:c})=>{if(e>=a&&e<=f&&(a==f||(e>a||t>0)&&(e<f||t<0)))return s=c.diagnostics,r=a,o=f,!1});let l=i.state.facet(Ze).tooltipFilter;return s&&l&&(s=l(s,i.state)),s?{pos:r,end:o,above:i.state.doc.lineAt(r).to<o,create(){return{dom:Yg(i,s)}}}:null}function Yg(i,e){return G("ul",{class:"cm-tooltip-lint"},e.map(t=>$c(i,t,!1)))}const Gg=i=>{let e=i.state.field(Ne,!1);(!e||!e.panel)&&i.dispatch({effects:Fc(i.state,[no.of(!0)])});let t=Oi(i,Ri.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},zl=i=>{let e=i.state.field(Ne,!1);return!e||!e.panel?!1:(i.dispatch({effects:no.of(!1)}),!0)},Xg=i=>{let e=i.state.field(Ne,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Qg=[{key:"Mod-Shift-m",run:Gg,preventDefault:!0},{key:"F8",run:Xg}],Zg=te.fromClass(class{constructor(i){this.view=i,this.timeout=-1,this.set=!0;let{delay:e}=i.state.facet(Ze);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let i=Date.now();if(i<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-i);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Ze);t.length&&e0(t.map(n=>Promise.resolve(n(this.view))),n=>{this.view.state.doc==e.doc&&this.view.dispatch(Kg(this.view.state,n.reduce((s,r)=>s.concat(r))))},n=>{ke(this.view.state,n)})}}update(i){let e=i.state.facet(Ze);(i.docChanged||e!=i.startState.facet(Ze)||e.needsRefresh&&e.needsRefresh(i))&&(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)}});function e0(i,e,t){let n=[],s=-1;for(let r of i)r.then(o=>{n.push(o),clearTimeout(s),n.length==i.length?e(n):s=setTimeout(()=>e(n),200)},t)}const Ze=y.Facet.define({combine(i){return Object.assign({sources:i.map(e=>e.source).filter(e=>e!=null)},y.combineConfig(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function uS(i,e={}){return[Ze.of({source:i,config:e}),Zg,Wc]}function Hc(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function $c(i,e,t){var n;let s=t?Hc(e.actions):[];return G("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},G("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,o)=>{let l=!1,a=g=>{if(g.preventDefault(),l)return;l=!0;let v=Yt(i.state.field(Ne).diagnostics,e);v&&r.apply(i,v.from,v.to)},{name:f}=r,c=s[o]?f.indexOf(s[o]):-1,p=c<0?f:[f.slice(0,c),G("u",f.slice(c,c+1)),f.slice(c+1)];return G("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${f}${c<0?"":` (access key "${s[o]})"`}.`},p)}),e.source&&G("div",{class:"cm-diagnosticSource"},e.source))}class t0 extends _e{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return G("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ql{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=$c(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ri{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)zl(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=Hc(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Yt(this.view.state.field(Ne).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=G("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=G("div",{class:"cm-panel-lint"},this.list,G("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>zl(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ne).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(Ne),n=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:f})=>{for(let c of f.diagnostics){if(o.has(c))continue;o.add(c);let p=-1,g;for(let v=n;v<this.items.length;v++)if(this.items[v].diagnostic==c){p=v;break}p<0?(g=new ql(this.view,c),this.items.splice(n,0,g),s=!0):(g=this.items[p],p>n&&(this.items.splice(n,p-n),s=!0)),t&&g.diagnostic==t.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),r=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),n++}});n<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 ql(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:l,panel:a})=>{let f=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/f:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/f)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ne),n=Yt(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Vc.of(n)})}static open(e){return new Ri(e)}}function i0(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function dn(i){return i0(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const n0=L.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:dn("#d11")},".cm-lintRange-warning":{backgroundImage:dn("orange")},".cm-lintRange-info":{backgroundImage:dn("#999")},".cm-lintRange-hint":{backgroundImage:dn("#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}}});function s0(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function r0(i){let e="hint",t=1;for(let n of i){let s=s0(n.severity);s>t&&(t=s,e=n.severity)}return e}const Wc=[Ne,L.decorations.compute([Ne],i=>{let{selected:e,panel:t}=i.field(Ne);return!e||!t||e.from==e.to?H.none:H.set([Jg.range(e.from,e.to)])}),Tp(Ug,{hideOn:_g}),n0];var zc=i=>{var{theme:e,settings:t={},styles:n=[]}=i,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=L.theme(s,{dark:e==="dark"}),a=Qr.define(n),f=[l,tc(a)];return f},o0={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},l0=[{tag:[E.standard(E.tagName),E.tagName],color:"#116329"},{tag:[E.comment,E.bracket],color:"#6a737d"},{tag:[E.className,E.propertyName],color:"#6f42c1"},{tag:[E.variableName,E.attributeName,E.number,E.operator],color:"#005cc5"},{tag:[E.keyword,E.typeName,E.typeOperator,E.typeName],color:"#d73a49"},{tag:[E.string,E.meta,E.regexp],color:"#032f62"},{tag:[E.name,E.quote],color:"#22863a"},{tag:[E.heading,E.strong],color:"#24292e",fontWeight:"bold"},{tag:[E.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[E.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[E.atom,E.bool,E.special(E.variableName)],color:"#e36209"},{tag:[E.url,E.escape,E.regexp,E.link],color:"#032f62"},{tag:E.link,textDecoration:"underline"},{tag:E.strikethrough,textDecoration:"line-through"},{tag:E.invalid,color:"#cb2431"}],a0=i=>{var{theme:e="light",settings:t={},styles:n=[]}={};return zc({theme:e,settings:Da({},o0,t),styles:[...l0,...n]})},dS=a0(),h0={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},c0=[{tag:[E.standard(E.tagName),E.tagName],color:"#7ee787"},{tag:[E.comment,E.bracket],color:"#8b949e"},{tag:[E.className,E.propertyName],color:"#d2a8ff"},{tag:[E.variableName,E.attributeName,E.number,E.operator],color:"#79c0ff"},{tag:[E.keyword,E.typeName,E.typeOperator,E.typeName],color:"#ff7b72"},{tag:[E.string,E.meta,E.regexp],color:"#a5d6ff"},{tag:[E.name,E.quote],color:"#7ee787"},{tag:[E.heading,E.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[E.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[E.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[E.atom,E.bool,E.special(E.variableName)],color:"#ffab70"},{tag:E.link,textDecoration:"underline"},{tag:E.strikethrough,textDecoration:"line-through"},{tag:E.invalid,color:"#f97583"}],f0=i=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return zc({theme:e,settings:Da({},h0,t),styles:[...c0,...n]})},pS=f0();const jl=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class Gt{constructor(e,t,n=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(n,s),this.bufferStart=n,this.normalize=r?l=>r(jl(l)):jl,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 y.codePointAt(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=y.fromCodePoint(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=y.codePointSize(e);let s=this.normalize(t);for(let r=0,o=n;;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==n&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,n){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:n}:(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:n}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Gt.prototype[Symbol.iterator]=function(){return this});const qc={from:-1,to:-1,match:/.*/.exec("")},so="gm"+(/x/.unicode==null?"":"u");class jc{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=qc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new _c(e,t,n,s,r);this.re=new RegExp(t,so+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=$n(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 n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=$n(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,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 Vs=new WeakMap;class Wt{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=Vs.get(e);if(!s||s.from>=n||s.to<=t){let l=new Wt(t,e.sliceString(t,n));return Vs.set(e,l),l}if(s.from==t&&s.to==n)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<n&&(r+=e.sliceString(s.to,n)),Vs.set(e,new Wt(o,r)),new Wt(t,r.slice(t-o,n-o))}}class _c{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=qc,this.matchPos=$n(e,s),this.re=new RegExp(t,so+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=Wt.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 n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=$n(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Wt.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(jc.prototype[Symbol.iterator]=_c.prototype[Symbol.iterator]=function(){return this});function u0(i){try{return new RegExp(i,so),!0}catch{return!1}}function $n(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}function Tr(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=G("input",{class:"cm-textfield",name:"line",value:e}),n=G("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),i.dispatch({effects:Wn.of(!1)}),i.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},G("label",i.state.phrase("Go to line"),": ",t)," ",G("button",{class:"cm-button",type:"submit"},i.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=i,l=o.doc.lineAt(o.selection.main.head),[,a,f,c,p]=r,g=c?+c.slice(1):0,v=f?+f:l.number;if(f&&p){let M=v/100;a&&(M=M*(a=="-"?-1:1)+l.number/o.doc.lines),v=Math.round(o.doc.lines*M)}else f&&a&&(v=v*(a=="-"?-1:1)+l.number);let k=o.doc.line(Math.max(1,Math.min(o.doc.lines,v))),C=y.EditorSelection.cursor(k.from+Math.max(0,Math.min(g,k.length)));i.dispatch({effects:[Wn.of(!1),L.scrollIntoView(C.from,{y:"center"})],selection:C}),i.focus()}return{dom:n}}const Wn=y.StateEffect.define(),_l=y.StateField.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(Wn)&&(i=t.value);return i},provide:i=>Di.from(i,e=>e?Tr:null)}),d0=i=>{let e=Oi(i,Tr);if(!e){let t=[Wn.of(!0)];i.state.field(_l,!1)==null&&t.push(y.StateEffect.appendConfig.of([_l,p0])),i.dispatch({effects:t}),e=Oi(i,Tr)}return e&&e.dom.querySelector("input").select(),!0},p0=L.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),m0={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g0=y.Facet.define({combine(i){return y.combineConfig(i,m0,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function y0(i){return[w0,x0]}const b0=H.mark({class:"cm-selectionMatch"}),S0=H.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Kl(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=y.CharCategory.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=y.CharCategory.Word)}function v0(i,e,t,n){return i(e.sliceDoc(t,t+1))==y.CharCategory.Word&&i(e.sliceDoc(n-1,n))==y.CharCategory.Word}const x0=te.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(g0),{state:t}=i,n=t.selection;if(n.ranges.length>1)return H.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return H.none;let a=t.wordAt(s.head);if(!a)return H.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 H.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Kl(o,t,s.from,s.to)&&v0(o,t,s.from,s.to)))return H.none}else if(r=t.sliceDoc(s.from,s.to),!r)return H.none}let l=[];for(let a of i.visibleRanges){let f=new Gt(t.doc,r,a.from,a.to);for(;!f.next().done;){let{from:c,to:p}=f.value;if((!o||Kl(o,t,c,p))&&(s.empty&&c<=s.from&&p>=s.to?l.push(S0.range(c,p)):(c>=s.to||p<=s.from)&&l.push(b0.range(c,p)),l.length>e.maxMatches))return H.none}}return H.set(l)}},{decorations:i=>i.decorations}),w0=L.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),k0=({state:i,dispatch:e})=>{let{selection:t}=i,n=y.EditorSelection.create(t.ranges.map(s=>i.wordAt(s.head)||y.EditorSelection.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function C0(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Gt(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Gt(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(r){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const A0=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return k0({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=C0(i,n);return s?(e(i.update({selection:i.selection.addRange(y.EditorSelection.range(s.from,s.to),!1),effects:L.scrollIntoView(s.to)})),!0):!1},ni=y.Facet.define({combine(i){return y.combineConfig(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new F0(e),scrollToMatch:e=>L.scrollIntoView(e)})}});class Kc{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||u0(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
11
- `:n=="r"?"\r":n=="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 O0(this):new E0(this)}getCursor(e,t=0,n){let s=e.doc?e:y.EditorState.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Bt(this,s,t,n):Rt(this,s,t,n)}}class Jc{constructor(e){this.spec=e}}function Rt(i,e,t,n){return new Gt(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?M0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function M0(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(zn(s,t-r))!=y.CharCategory.Word||e(qn(s,t-r))!=y.CharCategory.Word)&&(e(qn(s,n-r))!=y.CharCategory.Word||e(zn(s,n-r))!=y.CharCategory.Word))}class E0 extends Jc{constructor(e){super(e)}nextMatch(e,t,n){let s=Rt(this.spec,e,n,e.doc.length).nextOverlapping();return s.done&&(s=Rt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Rt(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,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Rt(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Rt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Bt(i,e,t,n){return new jc(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?T0(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function zn(i,e){return i.slice(y.findClusterBreak(i,e,!1),e)}function qn(i,e){return i.slice(e,y.findClusterBreak(i,e))}function T0(i){return(e,t,n)=>!n[0].length||(i(zn(n.input,n.index))!=y.CharCategory.Word||i(qn(n.input,n.index))!=y.CharCategory.Word)&&(i(qn(n.input,n.index+n[0].length))!=y.CharCategory.Word||i(zn(n.input,n.index+n[0].length))!=y.CharCategory.Word)}class O0 extends Jc{nextMatch(e,t,n){let s=Bt(this.spec,e,n,e.doc.length).next();return s.done&&(s=Bt(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Bt(this.spec,e,r,n),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,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n<e.match.length?e.match[n]:t)}matchAll(e,t){let n=Bt(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Bt(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Bi=y.StateEffect.define(),ro=y.StateEffect.define(),pt=y.StateField.define({create(i){return new Hs(Or(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Bi)?i=new Hs(t.value.create(),i.panel):t.is(ro)&&(i=new Hs(i.query,t.value?oo:null));return i},provide:i=>Di.from(i,e=>e.panel)});class Hs{constructor(e,t){this.query=e,this.panel=t}}const D0=H.mark({class:"cm-searchMatch"}),P0=H.mark({class:"cm-searchMatch cm-searchMatch-selected"}),R0=te.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(pt))}update(i){let e=i.state.field(pt);(e!=i.startState.field(pt)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return H.none;let{view:t}=this,n=new y.RangeSetBuilder;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-500;)a=r[++s].to;i.highlight(t.state,l,a,(f,c)=>{let p=t.state.selection.ranges.some(g=>g.from==f&&g.to==c);n.add(f,c,p?P0:D0)})}return n.finish()}},{decorations:i=>i.decorations});function Ki(i){return e=>{let t=e.state.field(pt,!1);return t&&t.query.spec.valid?i(e,t):Gc(e)}}const jn=Ki((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=y.EditorSelection.single(n.from,n.to),r=i.state.facet(ni);return i.dispatch({selection:s,effects:[lo(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),Yc(i),!0}),_n=Ki((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=y.EditorSelection.single(s.from,s.to),o=i.state.facet(ni);return i.dispatch({selection:r,effects:[lo(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),Yc(i),!0}),B0=Ki((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:y.EditorSelection.create(t.map(n=>y.EditorSelection.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),L0=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new Gt(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(y.EditorSelection.range(l.value.from,l.value.to))}return e(i.update({selection:y.EditorSelection.create(r,o),userEvent:"select.search.matches"})),!0},Jl=Ki((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=[],l,a,f=[];if(r.from==n&&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),f.push(L.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=y.EditorSelection.single(r.from-c,r.to-c),f.push(lo(i,r)),f.push(t.facet(ni).scrollToMatch(l.main,i))}return i.dispatch({changes:o,selection:l,effects:f,userEvent:"input.replace"}),!0}),I0=Ki((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.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 n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:L.announce.of(n),userEvent:"input.replace.all"}),!0});function oo(i){return i.state.facet(ni).createPanel(i)}function Or(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let f=i.facet(ni);return new Kc({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:f.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:f.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:f.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:f.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:f.wholeWord})}function Uc(i){let e=Oi(i,oo);return e&&e.dom.querySelector("[main-field]")}function Yc(i){let e=Uc(i);e&&e==i.root.activeElement&&e.select()}const Gc=i=>{let e=i.state.field(pt,!1);if(e&&e.panel){let t=Uc(i);if(t&&t!=i.root.activeElement){let n=Or(i.state,e.query.spec);n.valid&&i.dispatch({effects:Bi.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[ro.of(!0),e?Bi.of(Or(i.state,e.query.spec)):y.StateEffect.appendConfig.of(H0)]});return!0},Xc=i=>{let e=i.state.field(pt,!1);if(!e||!e.panel)return!1;let t=Oi(i,oo);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:ro.of(!1)}),!0},N0=[{key:"Mod-f",run:Gc,scope:"editor search-panel"},{key:"F3",run:jn,shift:_n,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jn,shift:_n,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:L0},{key:"Mod-Alt-g",run:d0},{key:"Mod-d",run:A0,preventDefault:!0}];class F0{constructor(e){this.view=e;let t=this.query=e.state.field(pt).query.spec;this.commit=this.commit.bind(this),this.searchField=G("input",{value:t.search,placeholder:Be(e,"Find"),"aria-label":Be(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=G("input",{value:t.replace,placeholder:Be(e,"Replace"),"aria-label":Be(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=G("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=G("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=G("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return G("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=G("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>jn(e),[Be(e,"next")]),n("prev",()=>_n(e),[Be(e,"previous")]),n("select",()=>B0(e),[Be(e,"all")]),G("label",null,[this.caseField,Be(e,"match case")]),G("label",null,[this.reField,Be(e,"regexp")]),G("label",null,[this.wordField,Be(e,"by word")]),...e.state.readOnly?[]:[G("br"),this.replaceField,n("replace",()=>Jl(e),[Be(e,"replace")]),n("replaceAll",()=>I0(e),[Be(e,"replace all")])],G("button",{name:"close",onclick:()=>Xc(e),"aria-label":Be(e,"close"),type:"button"},["×"])])}commit(){let e=new Kc({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:Bi.of(e)}))}keydown(e){$d(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?_n:jn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Jl(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Bi)&&!n.value.eq(this.query)&&this.setQuery(n.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(ni).top}}function Be(i,e){return i.state.phrase(e)}const pn=30,mn=/[\s\.,:;?!]/;function lo(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-pn),o=Math.min(s,t+pn),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<pn;a++)if(!mn.test(l[a+1])&&mn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-pn;a--)if(!mn.test(l[a-1])&&mn.test(l[a])){l=l.slice(0,a);break}}return L.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const V0=L.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"}}),H0=[pt,y.Prec.low(R0),V0];class Qc{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=ie(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),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),r=s.search(ef(e,!1));return r<0?null:{from:n+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 Ul(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function $0(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let n=Ul(e)+Ul(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ao(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:$0(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Zc(i,e){return t=>{for(let n=ie(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class Yl{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function mt(i){return i.selection.main.from}function ef(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",r=n[n.length-1]!="$";return!s&&!r?i:new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const tf=y.Annotation.define();function W0(i,e,t,n){let{main:s}=i.selection,r=t-s.from,o=n-s.from;return Object.assign(Object.assign({},i.changeByRange(l=>l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n)?{range:l}:{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:e},range:y.EditorSelection.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Gl=new WeakMap;function z0(i){if(!Array.isArray(i))return i;let e=Gl.get(i);return e||Gl.set(i,e=ao(i)),e}const Kn=y.StateEffect.define(),Li=y.StateEffect.define();class q0{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 n=y.codePointAt(e,t),s=y.codePointSize(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(y.codePointAt(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:n,any:s,precise:r,byWord:o}=this;if(t.length==1){let P=y.codePointAt(e,0),F=y.codePointSize(P),I=F==e.length?0:-100;if(P!=t[0])if(P==n[0])I+=-200;else return!1;return this.ret(I,[0,F])}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,f=0;if(l<0){for(let P=0,F=Math.min(e.length,200);P<F&&f<a;){let I=y.codePointAt(e,P);(I==t[f]||I==n[f])&&(s[f++]=P),P+=y.codePointSize(I)}if(f<a)return!1}let c=0,p=0,g=!1,v=0,k=-1,C=-1,M=/[a-z]/.test(e),T=!0;for(let P=0,F=Math.min(e.length,200),I=0;P<F&&p<a;){let R=y.codePointAt(e,P);l<0&&(c<a&&R==t[c]&&(r[c++]=P),v<a&&(R==t[v]||R==n[v]?(v==0&&(k=P),C=P+1,v++):v=0));let N,z=R<255?R>=48&&R<=57||R>=97&&R<=122?2:R>=65&&R<=90?1:0:(N=y.fromCodePoint(R))!=N.toLowerCase()?1:N!=N.toUpperCase()?2:0;(!P||z==1&&M||I==0&&z!=0)&&(t[p]==R||n[p]==R&&(g=!0)?o[p++]=P:o.length&&(T=!1)),I=z,P+=y.codePointSize(R)}return p==a&&o[0]==0&&T?this.result(-100+(g?-200:0),o,e):v==a&&k==0?this.ret(-200-e.length+(C==e.length?0:-100),[0,C]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):v==a?this.ret(-900-e.length,[k,C]):p==a?this.result(-100+(g?-200:0)+-700+(T?0:-1100),o,e):t.length==2?!1:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],r=0;for(let o of t){let l=o+(this.astral?y.codePointSize(y.codePointAt(n,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-n.length,s)}}const pe=y.Facet.define({combine(i){return y.combineConfig(i,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:j0,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)=>n=>Xl(e(n),t(n)),optionClass:(e,t)=>n=>Xl(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})}});function Xl(i,e){return i?e?i+" "+e:i:e}function j0(i,e,t,n,s,r){let o=i.textDirection==U.RTL,l=o,a=!1,f="top",c,p,g=e.left-s.left,v=s.right-e.right,k=n.right-n.left,C=n.bottom-n.top;if(l&&g<Math.min(k,v)?l=!1:!l&&v<Math.min(k,g)&&(l=!0),k<=(l?g:v))c=Math.max(s.top,Math.min(t.top,s.bottom-C))-e.top,p=Math.min(400,l?g:v);else{a=!0,p=Math.min(400,(o?e.right:s.right-e.left)-30);let P=s.bottom-e.bottom;P>=C||P>e.top?c=t.bottom-e.top:(f="bottom",c=e.bottom-t.top)}let M=(e.bottom-e.top)/r.offsetHeight,T=(e.right-e.left)/r.offsetWidth;return{style:`${f}: ${c/M}px; max-width: ${p/T}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function _0(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let f=0;f<r.length;){let c=r[f++],p=r[f++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(l.slice(c,p))),g.className="cm-completionMatchedText",a=p}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function $s(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class K0{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,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(pe);this.optionContent=_0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=$s(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:f}=e.state.field(t).open;for(let c=a.target,p;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(p=/-(\d+)$/.exec(c.id))&&+p[1]<f.length){this.applyCompletion(e,f[+p[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(pe).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Li.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 n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:r,selected:o,disabled:l}=n.open;(!s.open||s.open.options!=r)&&(this.range=$s(r.length,o,e.state.facet(pe).maxRenderedOptions),this.showOptions(r,n.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 n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);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=$s(t.options.length,t.selected,this.view.state.facet(pe).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:s}=n;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(n);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>ke(this.view.state,o,"completion info")):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;n.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&U0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=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(pe).positionInfo(this.view,t,s,n,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,n){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=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:f}=l;if(f){let g=typeof f=="string"?f:f.name;if(g!=r&&(o>n.from||n.from==0))if(r=g,typeof f!="string"&&f.header)s.appendChild(f.header(f));else{let v=s.appendChild(document.createElement("completion-section"));v.textContent=g}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let p=this.optionClass(l);p&&(c.className=p);for(let g of this.optionContent){let v=g(l,this.view.state,this.view,a);v&&c.appendChild(v)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.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 J0(i,e){return t=>new K0(t,i,e)}function U0(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/s:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function Ql(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function Y0(i,e){let t=[],n=null,s=a=>{t.push(a);let{section:f}=a.completion;if(f){n||(n=[]);let c=typeof f=="string"?f:f.name;n.some(p=>p.name==c)||n.push(typeof f=="string"?{name:c}:f)}};for(let a of i)if(a.hasResult()){let f=a.result.getMatch;if(a.result.filter===!1)for(let c of a.result.options)s(new Yl(c,a.source,f?f(c):[],1e9-t.length));else{let c=new q0(e.sliceDoc(a.from,a.to));for(let p of a.result.options)if(c.match(p.label)){let g=p.displayLabel?f?f(p,c.matched):[]:c.matched;s(new Yl(p,a.source,g,c.score+(p.boost||0)))}}}if(n){let a=Object.create(null),f=0,c=(p,g)=>{var v,k;return((v=p.rank)!==null&&v!==void 0?v:1e9)-((k=g.rank)!==null&&k!==void 0?k:1e9)||(p.name<g.name?-1:1)};for(let p of n.sort(c))f-=1e5,a[p.name]=f;for(let p of t){let{section:g}=p.completion;g&&(p.score+=a[typeof g=="string"?g:g.name])}}let r=[],o=null,l=e.facet(pe).compareCompletions;for(let a of t.sort((f,c)=>c.score-f.score||l(f.completion,c.completion))){let f=a.completion;!o||o.label!=f.label||o.detail!=f.detail||o.type!=null&&f.type!=null&&o.type!=f.type||o.apply!=f.apply||o.boost!=f.boost?r.push(a):Ql(a.completion)>Ql(o)&&(r[r.length-1]=a),o=a.completion}return r}class Vt{constructor(e,t,n,s,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Vt(this.options,Zl(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r){let o=Y0(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Vt(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(pe).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let f=0;f<o.length;f++)if(o[f].completion==a){l=f;break}}return new Vt(o,Zl(n,l),{pos:e.reduce((a,f)=>f.hasResult()?Math.min(a,f.from):a,1e8),create:ey,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Vt(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Jn{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Jn(Q0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(pe),r=(n.override||t.languageDataAt("autocomplete",mt(t)).map(z0)).map(l=>(this.active.find(f=>f.source==l)||new Pe(l,this.active.some(f=>f.state!=0)?1:0)).update(e,n));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))||!G0(r,this.active)?o=Vt.build(r,t,this.id,o,n):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(sf)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Jn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:X0}}function G0(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult;)t++;for(;n<e.length&&!e[n].hasResult;)n++;let s=t==i.length,r=n==e.length;if(s||r)return s==r;if(i[t++].result!=e[n++].result)return!1}}const X0={"aria-autocomplete":"list"};function Zl(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const Q0=[];function Dr(i){return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}class Pe{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Dr(e),s=this;n?s=s.handleUserEvent(e,n,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(Kn))s=new Pe(s.source,1,r.value?mt(e.state):-1);else if(r.is(Li))s=new Pe(s.source,0);else if(r.is(nf))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new Pe(this.source,1)}handleChange(e){return e.changes.touchesRange(mt(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 zt extends Pe{constructor(e,t,n,s,r){super(e,2,t),this.result=n,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=mt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&mt(e.startState)==this.from)return new Pe(this.source,t=="input"&&n.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),f;return Z0(this.result.validFor,e.state,r,o)?new zt(this.source,a,this.result,r,o):this.result.update&&(f=this.result.update(this.result,r,o,new Qc(e.state,l,a>=0)))?new zt(this.source,a,f,f.from,(s=f.to)!==null&&s!==void 0?s:mt(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 zt(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function Z0(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):ef(i,!0).test(s)}const nf=y.StateEffect.define({map(i,e){return i.map(t=>t.map(e))}}),sf=y.StateEffect.define(),Ie=y.StateField.define({create(){return Jn.start()},update(i,e){return i.update(e)},provide:i=>[Kr.from(i,e=>e.tooltip),L.contentAttributes.from(i,e=>e.attrs)]});function rf(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ie).active.find(s=>s.source==e.source);return n instanceof zt?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},W0(i.state,t,n.from,n.to)),{annotations:tf.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const ey=J0(Ie,rf);function gn(i,e="option"){return t=>{let n=t.state.field(Ie,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(pe).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Vh(t,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+s*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:sf.of(l)}),!0}}const ty=i=>{let e=i.state.field(Ie,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(pe).interactionDelay?!1:rf(i,e.open.options[e.open.selected])},iy=i=>i.state.field(Ie,!1)?(i.dispatch({effects:Kn.of(!0)}),!0):!1,ny=i=>{let e=i.state.field(Ie,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Li.of(null)}),!0)};class sy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const ry=50,oy=1e3,ly=te.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Ie).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(Ie);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ie)==e)return;let t=i.transactions.some(s=>(s.selection||s.docChanged)&&!Dr(s));for(let s=0;s<this.running.length;s++){let r=this.running[s];if(t||r.updates.length+i.transactions.length>ry&&Date.now()-r.time>oy){for(let o of r.context.abortListeners)try{o()}catch(l){ke(this.view.state,l)}r.context.abortListeners=null,this.running.splice(s--,1)}else r.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(r=>r.is(Kn)))&&(this.pendingStart=!0);let n=this.pendingStart?50:i.state.facet(pe).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(r=>r.active.source==s.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let s of i.transactions)Dr(s)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Ie);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=mt(e),n=new Qc(e,t,i.explicitPos==t),s=new sy(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Li.of(null)}),ke(this.view.state,r)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(pe);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(s.done===void 0)continue;if(this.running.splice(n--,1),s.done){let o=new zt(s.active.source,s.active.explicitPos,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:mt(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(Ie).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:nf.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ie,!1);if(e&&e.tooltip&&this.view.state.facet(pe).closeOnBlur){let t=e.open&&Vh(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Li.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Kn.of(!1)}),20),this.composing=0}}}),of=L.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 ay=class{constructor(e,t,n,s){this.field=e,this.line=t,this.from=n,this.to=s}},hy=class lf{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,y.MapMode.TrackDel),n=e.mapPos(this.to,1,y.MapMode.TrackDel);return t==null||n==null?null:new lf(this.field,t,n)}},cy=class af{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(n.length){let f=o,c=/^\t*/.exec(a)[0].length;for(let p=0;p<c;p++)f+=e.facet(ti);s.push(t+f.length-c),a=f+a.slice(c)}n.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new hy(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:n,ranges:l}}static parse(e){let t=[],n=[],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]||"",f=-1;for(let c=0;c<t.length;c++)(l!=null?t[c].seq==l:a&&t[c].name==a)&&(f=c);if(f<0){let c=0;for(;c<t.length&&(l==null||t[c].seq!=null&&t[c].seq<l);)c++;t.splice(c,0,{seq:l,name:a}),f=c;for(let p of s)p.field>=f&&p.field++}s.push(new ay(f,n.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==n.length&&a.from>l.index&&(a.from--,a.to--)}n.push(o)}return new af(n,s)}},fy=H.widget({widget:new class extends _e{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),uy=H.mark({class:"cm-snippetField"}),as=class hf{constructor(e,t){this.ranges=e,this.active=t,this.deco=H.set(e.map(n=>(n.from==n.to?fy:uy).range(n.from,n.to)))}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new hf(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}};const Ji=y.StateEffect.define({map(i,e){return i&&i.map(e)}}),dy=y.StateEffect.define(),Ii=y.StateField.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(Ji))return t.value;if(t.is(dy)&&i)return new as(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>L.decorations.from(i,e=>e?e.deco:H.none)});function ho(i,e){return y.EditorSelection.create(i.filter(t=>t.field==e).map(t=>y.EditorSelection.range(t.from,t.to)))}function py(i){let e=cy.parse(i);return(t,n,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:y.Text.of(o)},scrollIntoView:!0,annotations:n?[tf.of(n),y.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=ho(l,0)),l.some(f=>f.field>0)){let f=new as(l,0),c=a.effects=[Ji.of(f)];t.state.field(Ii,!1)===void 0&&c.push(y.StateEffect.appendConfig.of([Ii,Sy,vy,of]))}t.dispatch(t.state.update(a))}}function cf(i){return({state:e,dispatch:t})=>{let n=e.field(Ii,!1);if(!n||i<0&&n.active==0)return!1;let s=n.active+i,r=i>0&&!n.ranges.some(o=>o.field==s+i);return t(e.update({selection:ho(n.ranges,s),effects:Ji.of(r?null:new as(n.ranges,s)),scrollIntoView:!0})),!0}}const my=({state:i,dispatch:e})=>i.field(Ii,!1)?(e(i.update({effects:Ji.of(null)})),!0):!1,gy=cf(1),yy=cf(-1),by=[{key:"Tab",run:gy,shift:yy},{key:"Escape",run:my}],ea=y.Facet.define({combine(i){return i.length?i[0]:by}}),Sy=y.Prec.highest(ei.compute([ea],i=>i.facet(ea)));function se(i,e){return Object.assign(Object.assign({},e),{apply:py(i)})}const vy=L.domEventHandlers({mousedown(i,e){let t=e.state.field(Ii,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=n&&r.to>=n);return!s||s.field==t.active?!1:(e.dispatch({selection:ho(t.ranges,s.field),effects:Ji.of(t.ranges.some(r=>r.field>s.field)?new as(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Ni={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},wt=y.StateEffect.define({map(i,e){let t=e.mapPos(i,-1,y.MapMode.TrackAfter);return t??void 0}}),co=new class extends y.RangeValue{};co.startSide=1;co.endSide=-1;const ff=y.StateField.define({create(){return y.RangeSet.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(wt)&&(i=i.update({add:[co.range(t.value,t.value+1)]}));return i}});function xy(){return[ky,ff]}const Ws="()[]{}<>";function uf(i){for(let e=0;e<Ws.length;e+=2)if(Ws.charCodeAt(e)==i)return Ws.charAt(e+1);return y.fromCodePoint(i<128?i:i+1)}function df(i,e){return i.languageDataAt("closeBrackets",e)[0]||Ni}const wy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ky=L.inputHandler.of((i,e,t,n)=>{if((wy?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&y.codePointSize(y.codePointAt(n,0))==1||e!=s.from||t!=s.to)return!1;let r=My(i.state,n);return r?(i.dispatch(r),!0):!1}),Cy=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=df(i,i.selection.main.head).brackets||Ni.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Ey(i.doc,o.head);for(let a of n)if(a==l&&hs(i.doc,o.head)==uf(y.codePointAt(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:y.EditorSelection.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Ay=[{key:"Backspace",run:Cy}];function My(i,e){let t=df(i,i.selection.main.head),n=t.brackets||Ni.brackets;for(let s of n){let r=uf(y.codePointAt(s,0));if(e==s)return r==s?Dy(i,s,n.indexOf(s+s+s)>-1,t):Ty(i,s,r,t.before||Ni.before);if(e==r&&pf(i,i.selection.main.from))return Oy(i,s,r)}return null}function pf(i,e){let t=!1;return i.field(ff).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function hs(i,e){let t=i.sliceString(e,e+2);return t.slice(0,y.codePointSize(y.codePointAt(t,0)))}function Ey(i,e){let t=i.sliceString(e-2,e);return y.codePointSize(y.codePointAt(t,0))==t.length?t:t.slice(1)}function Ty(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:wt.of(o.to+e.length),range:y.EditorSelection.range(o.anchor+e.length,o.head+e.length)};let l=hs(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:wt.of(o.head+e.length),range:y.EditorSelection.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Oy(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&hs(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:y.EditorSelection.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Dy(i,e,t,n){let s=n.stringPrefixes||Ni.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:wt.of(l.to+e.length),range:y.EditorSelection.range(l.anchor+e.length,l.head+e.length)};let a=l.head,f=hs(i.doc,a),c;if(f==e){if(ta(i,a))return{changes:{insert:e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)};if(pf(i,a)){let g=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+g.length,insert:g},range:y.EditorSelection.cursor(a+g.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=ia(i,a-2*e.length,s))>-1&&ta(i,c))return{changes:{insert:e+e+e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)};if(i.charCategorizer(a)(f)!=y.CharCategory.Word&&ia(i,a,s)>-1&&!Py(i,a,e,s))return{changes:{insert:e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ta(i,e){let t=ie(i).resolveInner(e+1);return t.parent&&t.from==e}function Py(i,e,t,n){let s=ie(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let f=s.to==e&&s.parent;if(!f)break;s=f}return!1}function ia(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=y.CharCategory.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=y.CharCategory.Word)return r}return-1}function Ry(i={}){return[Ie,pe.of(i),ly,By,of]}const mf=[{key:"Ctrl-Space",run:iy},{key:"Escape",run:ny},{key:"ArrowDown",run:gn(!0)},{key:"ArrowUp",run:gn(!1)},{key:"PageDown",run:gn(!0,"page")},{key:"PageUp",run:gn(!1,"page")},{key:"Enter",run:ty}],By=y.Prec.highest(ei.computeN([pe],i=>i.facet(pe).defaultKeymap?[mf]:[]));var na=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Ay)),e.defaultKeymap!==!1&&(n=n.concat(Wg)),e.searchKeymap!==!1&&(n=n.concat(N0)),e.historyKeymap!==!1&&(n=n.concat(Gm)),e.foldKeymap!==!1&&(n=n.concat(cm)),e.completionKeymap!==!1&&(n=n.concat(mf)),e.lintKeymap!==!1&&(n=n.concat(Qg));var s=[];return e.lineNumbers!==!1&&s.push(Hp()),e.highlightActiveLineGutter!==!1&&s.push(zp()),e.highlightSpecialChars!==!1&&s.push(np()),e.history!==!1&&s.push(Wm()),e.foldGutter!==!1&&s.push(pm()),e.drawSelection!==!1&&s.push(Kd()),e.dropCursor!==!1&&s.push(Xd()),e.allowMultipleSelections!==!1&&s.push(y.EditorState.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(tm()),e.syntaxHighlighting!==!1&&s.push(tc(bm,{fallback:!0})),e.bracketMatching!==!1&&s.push(Am()),e.closeBrackets!==!1&&s.push(xy()),e.autocompletion!==!1&&s.push(Ry()),e.rectangularSelection!==!1&&s.push(yp()),t!==!1&&s.push(vp()),e.highlightActiveLine!==!1&&s.push(hp()),e.highlightSelectionMatches!==!1&&s.push(y0()),e.tabSize&&typeof e.tabSize=="number"&&s.push(ti.of(" ".repeat(e.tabSize))),s.concat([ei.of(n.flat())]).filter(Boolean)},zs;const xi=new Oe,Ly=new Oe;class et{constructor(e,t,n=[],s=""){this.data=e,this.name=s,y.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(y.EditorState.prototype,"tree",{get(){return Fi(this)}}),this.parser=t,this.extension=[Qt.of(this),y.EditorState.languageData.of((r,o,l)=>{let a=sa(r,o,l),f=a.type.prop(xi);if(!f)return[];let c=r.facet(f),p=a.type.prop(Ly);if(p){let g=a.resolve(o-a.from,l);for(let v of p)if(v.test(g,r)){let k=r.facet(v.facet);return v.type=="replace"?k:k.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return sa(e,t,n).type.prop(xi)==this.data}findRegions(e){let t=e.facet(Qt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(xi)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(Oe.mounted);if(l){if(l.tree.prop(xi)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let f=r.children[a];f instanceof Fe&&s(f,r.positions[a]+o)}};return s(Fi(e),0),n}get allowsNesting(){return!0}}et.setState=y.StateEffect.define();function sa(i,e,t){let n=i.facet(Qt),s=Fi(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Gn.ExcludeBuffers))r.type.isTop&&(s=r);return s}function Fi(i){let e=i.field(et.state,!1);return e?e.tree:Fe.empty}class Iy{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 n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let mi=null;class Un{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Un(e,t,[],Fe.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Iy(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Fe.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;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(dt.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n: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(dt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=mi;mi=this;try{return e()}finally{mi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ra(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((f,c,p,g)=>a.push({fromA:f,toA:c,fromB:p,toB:g})),n=dt.applyChanges(n,a),s=Fe.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let c=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);c<p&&l.push({from:c,to:p})}}}return new Un(this.parser,t,n,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 n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=ra(this.fragments,s,r),this.skipped.splice(n--,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 Ma{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=mi;if(a){for(let f of s)a.tempSkipped.push(f);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Fe(Zt.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 mi}}function ra(i,e,t){return dt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Xt{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),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Xt(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Un.create(e.facet(Qt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Xt(n)}}et.state=y.StateField.define({create:Xt.init,update(i,e){for(let t of e.effects)if(t.is(et.setState))return t.value;return e.startState.facet(Qt)!=e.state.facet(Qt)?Xt.init(e.state):i.apply(e)}});let gf=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(gf=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const qs=typeof navigator<"u"&&(!((zs=navigator.scheduling)===null||zs===void 0)&&zs.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ny=te.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(et.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(et.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=gf(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:n,viewport:{to:s}}=this.view,r=n.field(et.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!qs?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>qs&&qs()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:et.setState.of(new Xt(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=>ke(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()}}}),Qt=y.Facet.define({combine(i){return i.length?i[0]:null},enables:i=>[et.state,Ny,L.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class cs{constructor(e,t){this.specs=e;let n;function s(l){let a=tt.newName();return(n||(n=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 et?l=>l.prop(xi)==o.data:o?l=>l==o:void 0,this.style=Ea(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new tt(n):null,this.themeType=t.themeType}static define(e,t){return new cs(e,t||{})}}const Pr=y.Facet.define(),Fy=y.Facet.define({combine(i){return i.length?[i[0]]:null}});function js(i){let e=i.facet(Pr);return e.length?e:i.facet(Fy)}function Vy(i,e){let t=[$y],n;return i instanceof cs&&(i.module&&t.push(L.styleModule.of(i.module)),n=i.themeType),n?t.push(Pr.computeN([L.darkTheme],s=>s.facet(L.darkTheme)==(n=="dark")?[i]:[])):t.push(Pr.of(i)),t}class Hy{constructor(e){this.markCache=Object.create(null),this.tree=Fi(e.state),this.decorations=this.buildDeco(e,js(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Fi(e.state),n=js(e.state),s=n!=js(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,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return H.none;let n=new y.RangeSetBuilder;for(let{from:s,to:r}of e.visibleRanges)Ta(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=H.mark({class:a})))},s,r);return n.finish()}}const $y=y.Prec.high(te.fromClass(Hy,{decorations:i=>i.decorations})),Wy=Object.create(null),oa=[Zt.none],la=[],aa=Object.create(null),zy=Object.create(null);for(let[i,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"]])zy[i]=qy(Wy,e);function _s(i,e){la.indexOf(i)>-1||(la.push(i),console.warn(e))}function qy(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let f of l.split(".")){let c=i[f]||E[f];c?typeof c=="function"?a.length?a=a.map(c):_s(f,`Modifier ${f} used at start of tag`):a.length?_s(f,`Tag ${f} used as modifier`):a=Array.isArray(c)?c:[c]:_s(f,`Unknown highlighting tag ${f}`)}for(let f of a)t.push(f)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=aa[s];if(r)return r.id;let o=aa[s]=Zt.define({id:oa.length,name:n,props:[Oa({[n]:t})]});return oa.push(o),o.id}U.RTL,U.LTR;const jy="#e5c07b",ha="#e06c75",_y="#56b6c2",Ky="#ffffff",En="#abb2bf",Rr="#7d8799",Jy="#61afef",Uy="#98c379",ca="#d19a66",Yy="#c678dd",Gy="#21252b",fa="#2c313a",ua="#282c34",Ks="#353a42",Xy="#3E4451",da="#528bff",Qy=L.theme({"&":{color:En,backgroundColor:ua},".cm-content":{caretColor:da},".cm-cursor, .cm-dropCursor":{borderLeftColor:da},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Xy},".cm-panels":{backgroundColor:Gy,color:En},".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:ua,color:Rr,border:"none"},".cm-activeLineGutter":{backgroundColor:fa},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ks},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ks,borderBottomColor:Ks},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fa,color:En}}},{dark:!0}),Zy=cs.define([{tag:E.keyword,color:Yy},{tag:[E.name,E.deleted,E.character,E.propertyName,E.macroName],color:ha},{tag:[E.function(E.variableName),E.labelName],color:Jy},{tag:[E.color,E.constant(E.name),E.standard(E.name)],color:ca},{tag:[E.definition(E.name),E.separator],color:En},{tag:[E.typeName,E.className,E.number,E.changed,E.annotation,E.modifier,E.self,E.namespace],color:jy},{tag:[E.operator,E.operatorKeyword,E.url,E.escape,E.regexp,E.link,E.special(E.string)],color:_y},{tag:[E.meta,E.comment],color:Rr},{tag:E.strong,fontWeight:"bold"},{tag:E.emphasis,fontStyle:"italic"},{tag:E.strikethrough,textDecoration:"line-through"},{tag:E.link,color:Rr,textDecoration:"underline"},{tag:E.heading,fontWeight:"bold",color:ha},{tag:[E.atom,E.bool,E.special(E.variableName)],color:ca},{tag:[E.processingInstruction,E.string,E.inserted],color:Uy},{tag:E.invalid,color:Ky}]),eb=[Qy,Vy(Zy)];var tb=L.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ib=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(ei.of([zg])),l&&(typeof l=="boolean"?a.unshift(na()):a.unshift(na(l))),o&&a.unshift(dp(o)),r){case"light":a.push(tb);break;case"dark":a.push(eb);break;case"none":break;default:a.push(r);break}return n===!1&&a.push(L.editable.of(!1)),s&&a.push(y.EditorState.readOnly.of(!0)),[...a]},nb=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class sb{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class pa{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Js=null,rb=()=>typeof window>"u"?new pa:(Js||(Js=new pa),Js),ma=y.Annotation.define(),ob=200,lb=[];function ab(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=lb,autoFocus:a,theme:f="light",height:c=null,minHeight:p=null,maxHeight:g=null,width:v=null,minWidth:k=null,maxWidth:C=null,placeholder:M="",editable:T=!0,readOnly:P=!1,indentWithTab:F=!0,basicSetup:I=!0,root:R,initialState:N}=i,[z,Y]=Me.useState(),[_,me]=Me.useState(),[Ae,he]=Me.useState(),q=Me.useState(()=>({current:null}))[0],ue=Me.useState(()=>({current:null}))[0],ge=L.theme({"&":{height:c,minHeight:p,maxHeight:g,width:v,minWidth:k,maxWidth:C},"& .cm-scroller":{height:"100% !important"}}),X=L.updateListener.of(ne=>{if(ne.docChanged&&typeof n=="function"&&!ne.transactions.some(ht=>ht.annotation(ma))){q.current?q.current.reset():(q.current=new sb(()=>{if(ue.current){var ht=ue.current;ue.current=null,ht()}q.current=null},ob),rb().add(q.current));var re=ne.state.doc,st=re.toString();n(st,ne)}s&&s(nb(ne))}),ye=ib({theme:f,editable:T,readOnly:P,placeholder:M,indentWithTab:F,basicSetup:I}),be=[X,ge,...ye];return o&&typeof o=="function"&&be.push(L.updateListener.of(o)),be=be.concat(l),Me.useLayoutEffect(()=>{if(z&&!Ae){var ne={doc:e,selection:t,extensions:be},re=N?y.EditorState.fromJSON(N.json,ne,N.fields):y.EditorState.create(ne);if(he(re),!_){var st=new L({state:re,parent:z,root:R});me(st),r&&r(st,re)}}return()=>{_&&(he(void 0),me(void 0))}},[z,Ae]),Me.useEffect(()=>{i.container&&Y(i.container)},[i.container]),Me.useEffect(()=>()=>{_&&(_.destroy(),me(void 0)),q.current&&(q.current.cancel(),q.current=null)},[_]),Me.useEffect(()=>{a&&_&&_.focus()},[a,_]),Me.useEffect(()=>{_&&_.dispatch({effects:y.StateEffect.reconfigure.of(be)})},[f,l,c,p,g,v,k,C,M,T,P,F,I,n,o]),Me.useEffect(()=>{if(e!==void 0){var ne=_?_.state.doc.toString():"";if(_&&e!==ne){var re=q.current&&!q.current.isDone,st=()=>{_&&e!==_.state.doc.toString()&&_.dispatch({changes:{from:0,to:_.state.doc.toString().length,insert:e||""},annotations:[ma.of(!0)]})};re?ue.current=st:st()}}},[e,_]),{state:Ae,setState:he,view:_,setView:me,container:z,setContainer:Y}}var hb=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],cb=Me.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:f,autoFocus:c,theme:p="light",height:g,minHeight:v,maxHeight:k,width:C,minWidth:M,maxWidth:T,basicSetup:P,placeholder:F,indentWithTab:I,editable:R,readOnly:N,root:z,initialState:Y}=i,_=Zf(i,hb),me=Me.useRef(null),{state:Ae,view:he,container:q,setContainer:ue}=ab({root:z,value:n,autoFocus:c,theme:p,height:g,minHeight:v,maxHeight:k,width:C,minWidth:M,maxWidth:T,basicSetup:P,placeholder:F,indentWithTab:I,editable:R,readOnly:N,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:f,extensions:r,initialState:Y});Me.useImperativeHandle(e,()=>({editor:me.current,state:Ae,view:he}),[me,q,Ae,he]);var ge=Me.useCallback(ye=>{me.current=ye,ue(ye)},[ue]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var X=typeof p=="string"?"cm-theme-"+p:"cm-theme";return eu.jsx("div",tu({ref:ge,className:""+X+(t?" "+t:"")},_))});cb.displayName="CodeMirror";const fb=y.Annotation.define(),ub=L.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 db{constructor(e,t,n,s){this.field=e,this.line=t,this.from=n,this.to=s}}class fo{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,y.MapMode.TrackDel),n=e.mapPos(this.to,1,y.MapMode.TrackDel);return t==null||n==null?null:new fo(this.field,t,n)}}class uo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(n.length){let f=o,c=/^\t*/.exec(a)[0].length;for(let p=0;p<c;p++)f+=e.facet(ti);s.push(t+f.length-c),a=f+a.slice(c)}n.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new fo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:n,ranges:l}}static parse(e){let t=[],n=[],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]||"",f=-1,c=a.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p<t.length;p++)(l!=null?t[p].seq==l:c&&t[p].name==c)&&(f=p);if(f<0){let p=0;for(;p<t.length&&(l==null||t[p].seq!=null&&t[p].seq<l);)p++;t.splice(p,0,{seq:l,name:c}),f=p;for(let g of s)g.field>=f&&g.field++}s.push(new db(f,n.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,f)=>{for(let c of s)c.line==n.length&&c.from>f&&(c.from--,c.to--);return a}),n.push(o)}return new uo(n,s)}}let pb=H.widget({widget:new class extends _e{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),mb=H.mark({class:"cm-snippetField"});class si{constructor(e,t){this.ranges=e,this.active=t,this.deco=H.set(e.map(n=>(n.from==n.to?pb:mb).range(n.from,n.to)))}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new si(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}}const Ui=y.StateEffect.define({map(i,e){return i&&i.map(e)}}),gb=y.StateEffect.define(),Vi=y.StateField.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(Ui))return t.value;if(t.is(gb)&&i)return new si(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>L.decorations.from(i,e=>e?e.deco:H.none)});function po(i,e){return y.EditorSelection.create(i.filter(t=>t.field==e).map(t=>y.EditorSelection.range(t.from,t.to)))}function yb(i){let e=uo.parse(i);return(t,n,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,f={changes:{from:s,to:r==a.from?a.to:r,insert:y.Text.of(o)},scrollIntoView:!0,annotations:n?[fb.of(n),y.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(f.selection=po(l,0)),l.some(c=>c.field>0)){let c=new si(l,0),p=f.effects=[Ui.of(c)];t.state.field(Vi,!1)===void 0&&p.push(y.StateEffect.appendConfig.of([Vi,wb,Cb,ub]))}t.dispatch(t.state.update(f))}}function yf(i){return({state:e,dispatch:t})=>{let n=e.field(Vi,!1);if(!n||i<0&&n.active==0)return!1;let s=n.active+i,r=i>0&&!n.ranges.some(o=>o.field==s+i);return t(e.update({selection:po(n.ranges,s),effects:Ui.of(r?null:new si(n.ranges,s)),scrollIntoView:!0})),!0}}const bb=({state:i,dispatch:e})=>i.field(Vi,!1)?(e(i.update({effects:Ui.of(null)})),!0):!1,Sb=yf(1),vb=yf(-1),xb=[{key:"Tab",run:Sb,shift:vb},{key:"Escape",run:bb}],ga=y.Facet.define({combine(i){return i.length?i[0]:xb}}),wb=y.Prec.highest(ei.compute([ga],i=>i.facet(ga)));function kb(i,e){return Object.assign(Object.assign({},e),{apply:yb(i)})}const Cb=L.domEventHandlers({mousedown(i,e){let t=e.state.field(Vi,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=n&&r.to>=n);return!s||s.field==t.active?!1:(e.dispatch({selection:po(t.ranges,s.field),effects:Ui.of(t.ranges.some(r=>r.field>s.field)?new si(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),bf=new class extends y.RangeValue{};bf.startSide=1;bf.endSide=-1;Pa.setLevel("silent");const le=Pa,j={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:"⚠"},Ab={Pair:j.PROPERTY,Key:j.PROPERTY_NAME,BlockSequence:j.ARRAY,BlockMapping:j.OBJECT,FlowSequence:j.ARRAY,FlowMapping:j.OBJECT,QuotedLiteral:j.STRING,Literal:j.STRING,Stream:j.JSON_TEXT,Document:j.OBJECT},Mb={File:j.JSON_TEXT},mo=[j.STRING,j.NUMBER,j.TRUE,j.FALSE,j.NULL],Sf=[j.OBJECT,j.ARRAY,j.ITEM],ee={JSON5:"json5",JSON:"json4",YAML:"yaml"},ae=(i,e)=>{var t,n;switch(e){case ee.YAML:return(t=Ab[i])!==null&&t!==void 0?t:i;case ee.JSON5:return(n=Mb[i])!==null&&n!==void 0?n:i;default:return i}};function vf(i,e,t){const n=[];for(let s=e;s!=null&&s.parent;s=s.parent)switch(ae(s.parent.name,t)){case j.PROPERTY:{const r=Br(s.parent,j.PROPERTY_NAME,t);r&&n.unshift(Lt(i,r).replace(/[/~]/g,o=>o==="~"?"~0":"~1"));break}case j.ARRAY:{if(Tb(s,t)){const r=kf(s.parent,s,t);n.unshift(`${r}`)}break}}return n.unshift(""),n.join("/")}const xf=(i,e,t=-1,n)=>vf(i.doc,ie(i).resolve(e,t),n),go=(i,e)=>{const t=ie(i),n=new Map;return t.iterate({enter:s=>{var r,o,l,a,f,c,p,g;if([j.PROPERTY_NAME,j.OBJECT].includes(ae(s.name,e))){const v=vf(i.doc,s.node,e),{from:k,to:C}=s.node;if(!(!((o=(r=s.node)===null||r===void 0?void 0:r.nextSibling)===null||o===void 0)&&o.node))return n.set(v,{keyFrom:k,keyTo:C}),!0;const M=e===ee.JSON?(a=(l=s.node)===null||l===void 0?void 0:l.nextSibling)===null||a===void 0?void 0:a.node:(g=(p=(c=(f=s.node)===null||f===void 0?void 0:f.nextSibling)===null||c===void 0?void 0:c.node)===null||p===void 0?void 0:p.nextSibling)===null||g===void 0?void 0:g.node;if(!M)return n.set(v,{keyFrom:k,keyTo:C}),!0;const{from:T,to:P}=M;return n.set(v,{keyFrom:k,keyTo:C,valueFrom:T,valueTo:P}),!0}}}),n},Us=(i,e,t=-1)=>ie(i).resolveInner(e,t),Tn=i=>i.replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1"),Eb=i=>i.replace(/^"(.*)"$/,"'$1'"),Lt=(i,e,t=!0,n=!0)=>{const s=e?i.sliceString(e.from,e.to):"";return t?n?Tn(s):s.replace(/(^["'])|(["']$)/g,""):s},wf=(i,e)=>{var t,n,s,r;return ae(i.name,e)===j.INVALID&&(ae((n=(t=i.prevSibling)===null||t===void 0?void 0:t.name)!==null&&n!==void 0?n:"",e)===j.PROPERTY_NAME||ae((r=(s=i.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)===j.PROPERTY_COLON)},On=(i,e)=>mo.includes(ae(i.name,e))||wf(i,e),Tb=(i,e)=>[...mo,...Sf].includes(ae(i.name,e))||wf(i,e),yn=(i,e)=>{var t,n,s,r,o,l;return ae(i.name,e)===j.PROPERTY_NAME||ae(i.name,e)===j.INVALID&&(ae((n=(t=i.prevSibling)===null||t===void 0?void 0:t.name)!==null&&n!==void 0?n:"",e)===j.PROPERTY||ae((r=(s=i.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)==="{")||e===ee.YAML&&ae((l=(o=i.parent)===null||o===void 0?void 0:o.name)!==null&&l!==void 0?l:"",e)===j.OBJECT},Yi=i=>{const e=[];let t=i.firstChild;for(;t;)t&&e.push(t),t=t==null?void 0:t.nextSibling;return e},Ob=(i,e,t)=>Yi(i).filter(n=>ae(n.name,t)===e),Br=(i,e,t)=>{var n;return(n=Yi(i).find(s=>ae(s.name,t)===e))!==null&&n!==void 0?n:null},ya=(i,e)=>Yi(i).find(t=>On(t,e)),Db=(i,e)=>Yi(i).filter(t=>mo.includes(ae(t.name,e))||Sf.includes(ae(t.name,e))),kf=(i,e,t)=>Db(i,t).findIndex(n=>n.from===e.from&&n.to===e.to),ba=(i,e,t,n=1/0)=>{let s=i;for(;s&&n>0;){if(ae(s.name,t)===e)return s;s=s.parent,n--}return null},Pb=y.StateEffect.define(),Yn=y.StateField.define({create(){},update(i,e){for(const t of e.effects)if(t.is(Pb))return t.value;return i}}),yo=i=>i.field(Yn),yS=i=>[Yn.init(()=>i)];function Ye(i,e,t=[]){const n=document.createElement(i);return Object.entries(e).forEach(([s,r])=>{if(s==="text"){n.innerText=r;return}if(s==="inner"){n.innerHTML=r;return}n.setAttribute(s,r)}),t.forEach(s=>n.appendChild(s)),n}const Lr=iu({linkify:!0,typographer:!0});(async()=>{const i=await au({themes:[vs(()=>import("./vendor-shiki-MNnmOotP.js").then(e=>e.v),__vite__mapDeps([0,1,2,3])),vs(()=>import("./vendor-shiki-MNnmOotP.js").then(e=>e.a),__vite__mapDeps([0,1,2,3]))],langs:[vs(()=>import("./vendor-shiki-MNnmOotP.js").then(e=>e.j),__vite__mapDeps([0,1,2,3]))]});Lr.use(hu(i,{themes:{light:"vitesse-light",dark:"vitesse-dark"}}))})();function qt(i,e=!0){return e?Lr.renderInline(i):Lr.render(i)}function Rb(i){let e=null;try{e=JSON.parse(i.doc.toString())}catch{try{e=Ra.parse(i.doc.toString())}catch{}}const t=go(i,ee.JSON);return{data:e,pointers:t}}function Bb(i){let e=null;try{e=nu.parse(i.doc.toString())}catch{try{e=Ra.parse(i.doc.toString())}catch{}}const t=go(i,ee.JSON5);return{data:e,pointers:t}}function Lb(i){let e=null;try{e=su.parse(i.doc.toString())}catch{}const t=go(i,ee.YAML);return{data:e,pointers:t}}const Cf=i=>{switch(i){case ee.JSON:return Rb;case ee.JSON5:return Bb;case ee.YAML:return Lb}};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,n,s;this.opts=e,this.schema=null,this.mode=ee.JSON,this.mode=(t=e.mode)!==null&&t!==void 0?t:ee.JSON,this.parser=(s=(n=this.opts)===null||n===void 0?void 0:n.jsonParser)!==null&&s!==void 0?s:Cf(this.mode)}doComplete(e){var t,n,s;const r=yo(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=Us(e.state,e.pos),f=e.state.sliceDoc(a.from,e.pos).replace(/^(["'])/,"");if(le.log("xxx","node",a,"prefix",f,"ctx",e),!(On(a,this.mode)||yn(a,this.mode))&&!e.explicit)return le.log("xxx","no completions for non-word/primitive",a),o;const c=Lt(e.state.doc,a),p=Lt(e.state.doc,a,!1);if(a&&(On(a,this.mode)||yn(a,this.mode)))o.from=a.from,o.to=a.to;else{const C=e.matchBefore(/[A-Za-z0-9._]*/),M=e.pos-c.length;le.log("xxx","overwriteStart after",M,"ctx.pos",e.pos,"word",C,"currentWord",c,"=>",l[M-1],"..",l[M],"..",l),o.from=a.name===j.INVALID?(n=C==null?void 0:C.from)!==null&&n!==void 0?n:e.pos:M,o.to=e.pos}const g=new Ib;let v=!0;const k=ba(a,j.PROPERTY_NAME,this.mode);if(k&&(le.log("xxx","closestPropertyNameNode",k,"node",a),a=k),yn(a,this.mode)){le.log("xxx","isPropertyNameNode",a);const C=a.parent;if(C){const M=ya(C,this.mode);v=!M||M.name===j.INVALID&&M.from-M.to===0||(M.parent?Yi(M.parent).length<=1:!1),le.log("xxx","addValue",v,ya(C,this.mode),a),a=(s=ba(C,j.OBJECT,this.mode))!==null&&s!==void 0?s:null}}if(le.log("xxx",a,c,e,"node at pos",Us(e.state,e.pos)),a&&[j.OBJECT,j.JSON_TEXT].includes(ae(a.name,this.mode))&&(yn(Us(e.state,e.pos),this.mode)||k)){if(a.from===e.pos)return le.log("xxx","no completions for just before opening brace"),o;this.getPropertyCompletions(this.schema,e,a,g,v,p)}else{const C={},M=this.getValueCompletions(this.schema,e,C,g);le.log("xxx","getValueCompletions res",M)}return o.options=Array.from(g.completions.values()).filter(C=>Tn(C.label).startsWith(f)),le.log("xxx","result",o,"prefix",f,"collector.completions",g.completions,"reservedKeys",g.reservedKeys),o}applySnippetCompletion(e){return kb(typeof e.apply!="string"?e.label:e.apply,e)}getPropertyCompletions(e,t,n,s,r,o){const l=Ob(n,j.PROPERTY,this.mode);le.log("xxx","getPropertyCompletions",n,t,l),l.forEach(f=>{const c=Lt(t.state.doc,Br(f,j.PROPERTY_NAME,this.mode));s.reserve(Tn(c))});const a=this.getSchemas(e,t);le.log("xxx","propertyCompletion schemas",a),a.forEach(f=>{if(typeof f!="object")return;const c=f.properties;c&&Object.entries(c).forEach(([g,v])=>{var k,C;if(typeof v=="object"){const M=(k=v.description)!==null&&k!==void 0?k:"",T=(C=v.type)!==null&&C!==void 0?C:"",P=Array.isArray(T)?T.toString():T,F={label:g,apply:this.getInsertTextForProperty(g,r,o,v),type:"property",detail:P,info:()=>Ye("div",{inner:qt(M)})};s.add(this.applySnippetCompletion(F))}});const p=f.propertyNames;if(typeof p=="object"&&(p.enum&&p.enum.forEach(g=>{const v=g==null?void 0:g.toString();if(v){const k={label:v,apply:this.getInsertTextForProperty(v,r,o),type:"property"};s.add(this.applySnippetCompletion(k))}}),p.const)){const g=p.const.toString(),v={label:g,apply:this.getInsertTextForProperty(g,r,o),type:"property"};s.add(this.applySnippetCompletion(v))}})}getInsertTextForProperty(e,t,n,s){s=s&&this.expandSchemaProperty(s,this.schema);let r=this.getInsertTextForPropertyName(e,n);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 ee.JSON5:o="{#{}}";break;case ee.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)&&(le.log("xxx","value",o,"nValueProposals",l,s),o="#{}"),r+o}getInsertTextForPropertyName(e,t){switch(this.mode){case ee.JSON5:case ee.YAML:return t.startsWith('"')?`"${e}"`:t.startsWith("'")?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t="#"){switch(this.mode){case ee.JSON5:return`'${t}{${e}}'`;case ee.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 n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),this.getInsertTextForString(n,"$")+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 n=JSON.stringify(e,null," ");return n==="{}"?"{#{}}"+t:n==="[]"?"[#{}]"+t:this.getInsertTextForPlainText(n+t)}getValueCompletions(e,t,n,s){let r=ie(t.state).resolveInner(t.pos,-1),o=null,l;if(le.log("xxx","getValueCompletions",r,t),r&&On(r,this.mode)&&(o=r,r=r.parent),!r){this.addSchemaValueCompletions(e,n,s);return}if(ae(r.name,this.mode)===j.PROPERTY){const f=Br(r,j.PROPERTY_NAME,this.mode);f&&(l=Lt(t.state.doc,f),r=r.parent)}if(le.log("xxx","node",r,"parentKey",l),r&&(l!==void 0||ae(r.name,this.mode)===j.ARRAY)){const f=this.getSchemas(e,t);for(const c of f){if(typeof c!="object")return;if(ae(r.name,this.mode)===j.ARRAY&&c.items){let p=s;if(c.uniqueItems&&(p=Object.assign(Object.assign({},p),{add(g){p.completions.has(g.label)||s.add(g)},reserve(g){s.reserve(g)}})),Array.isArray(c.items)){let g=0;if(o){const k=kf(r,o,this.mode);k>=0&&(g=k)}const v=c.items[g];v&&this.addSchemaValueCompletions(v,n,p)}else this.addSchemaValueCompletions(c.items,n,p)}if(l!==void 0){let p=!1;if(c.properties){const g=c.properties[l];g&&(p=!0,this.addSchemaValueCompletions(g,n,s))}if(c.patternProperties&&!p)for(const g of Object.keys(c.patternProperties)){const v=this.extendedRegExp(g);if(v!=null&&v.test(l)){p=!0;const k=c.patternProperties[g];k&&this.addSchemaValueCompletions(k,n,s)}}if(c.additionalProperties&&!p){const g=c.additionalProperties;this.addSchemaValueCompletions(g,n,s)}}n.boolean&&(this.addBooleanValueCompletion(!0,s),this.addBooleanValueCompletion(!1,s)),n.null&&this.addNullValueCompletion(s)}}return{valuePrefix:o?Lt(t.state.doc,o,!0,!1):""}}addSchemaValueCompletions(e,t,n){typeof e=="object"&&(this.addEnumValueCompletions(e,n),this.addDefaultValueCompletions(e,n),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)),Array.isArray(e.anyOf)&&e.anyOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)),Array.isArray(e.oneOf)&&e.oneOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)))}addDefaultValueCompletions(e,t,n=0){let s=!1;if(typeof e.default<"u"){let r=e.type,o=e.default;for(let a=n;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=n;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)&&n<5&&this.addDefaultValueCompletions(e.items,t,n+1)}addEnumValueCompletions(e,t){var n,s;if(typeof e.const<"u"&&t.add(Object.assign(Object.assign({type:(n=e.type)===null||n===void 0?void 0:n.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 n=e.type;Array.isArray(n)?n.forEach(s=>t[s]=!0):n&&(t[n]=!0)}getSchemas(e,t){var n,s;const r=new ru(this.schema);let o=xf(t.state,t.pos,-1,this.mode);const{data:l}=this.parser(t.state);let a=r.getSchema({pointer:o,data:l??void 0});return le.log("xxxx","draft.getSchema",a,"data",l,"pointer",o),Ba(a)&&(a=(n=a.data)===null||n===void 0?void 0:n.schema),(!a||a.name==="UnknownPropertyError"||a.enum||a.type==="undefined"||a.type==="null")&&(o=o.replace(/\/[^/]*$/,"/"),a=r.getSchema({pointer:o})),le.log("xxx","pointer..",JSON.stringify(o)),(!o||o==="/")&&(a=(s=this.expandSchemaProperty(e,e))!==null&&s!==void 0?s:e),le.log("xxx","subSchema..",a),a?Array.isArray(a.allOf)?[a,...a.allOf.map(f=>this.expandSchemaProperty(f,e))]:Array.isArray(a.oneOf)?[a,...a.oneOf.map(f=>this.expandSchemaProperty(f,e))]:Array.isArray(a.anyOf)?[a,...a.anyOf.map(f=>this.expandSchemaProperty(f,e))]:[a]:[]}expandSchemaProperty(e,t){if(typeof e=="object"&&e.$ref){const n=this.getReferenceSchema(t,e.$ref);if(typeof n=="object"){const s=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(s,"$ref"),s}}return e}getReferenceSchema(e,t){const n=t.split("/");let s=e;return n.forEach(r=>{if(r){if(r==="#"){s=e;return}typeof s=="object"&&(s=s[r])}}),s}getAppliedValue(e){const t=Tn(JSON.stringify(e));switch(this.mode){case ee.JSON5:return{label:t,apply:Eb(JSON.stringify(e))};case ee.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 bS(i={}){const e=new Nb(i);return function(n){return e.doComplete(n)}}const Hi=(i,e)=>{const t=i.length>2;let n=i.map((s,r)=>{const o="`"+(e?e(s):s)+"`";return r===i.length-1?"or "+o:o});return t?n.join(", "):n.join(" ")},Fb=i=>{var e,t,n;return!((e=i==null?void 0:i.data)===null||e===void 0)&&e.pointer&&((t=i==null?void 0:i.data)===null||t===void 0?void 0:t.pointer)!=="#"?i.data.pointer.slice(1):!((n=i==null?void 0:i.data)===null||n===void 0)&&n.property?`/${i.data.property}`:""},SS=i=>i.startState.field(Yn)!==i.state.field(Yn);function vS(i){const e=new Hb(i);return t=>e.doValidation(t)}const Vb=["NoAdditionalPropertiesError","RequiredPropertyError","InvalidPropertyNameError","ForbiddenPropertyError","UndefinedValueError"];class Hb{constructor(e){var t,n,s,r;this.options=e,this.schema=null,this.mode=ee.JSON,this.rewriteError=o=>{var l,a,f,c,p;const g=o==null?void 0:o.data,v=g==null?void 0:g.errors;return o.code==="one-of-error"&&(v!=null&&v.length)?`Expected one of ${Hi(v,C=>C.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)?Hi((f=o==null?void 0:o.data)===null||f===void 0?void 0:f.expected):(c=o==null?void 0:o.data)===null||c===void 0?void 0:c.expected}\` but received \`${(p=o==null?void 0:o.data)===null||p===void 0?void 0:p.received}\``:o.message.replaceAll("in `#` ","").replaceAll("at `#`","").replaceAll("/",".").replaceAll("#.","")},this.mode=(n=(t=this.options)===null||t===void 0?void 0:t.mode)!==null&&n!==void 0?n:ee.JSON,this.parser=(r=(s=this.options)===null||s===void 0?void 0:s.jsonParser)!==null&&r!==void 0?r:Cf(this.mode)}get schemaTitle(){var e,t,n;return(n=(t=(e=this.schema)===null||e===void 0?void 0:e.getSchema())===null||t===void 0?void 0:t.title)!==null&&n!==void 0?n:"json-schema"}doValidation(e){const t=yo(e.state);if(!t)return[];if(this.schema=new La(t),!this.schema)return[];const n=e.state.doc.toString();if(!(n!=null&&n.length))return[];const s=this.parser(e.state);let r=[];try{r=this.schema.validate(s.data)}catch{}return le.log("xxx","validation errors",r,s.data),r.length?r.reduce((o,l)=>{const a=()=>{const p=this.rewriteError(l);o.push({from:0,to:0,message:p,severity:"error",source:this.schemaTitle,renderMessage:()=>{const g=Ye("div",{});return g.innerHTML=qt(p),g}})},f=Fb(l),c=s.pointers.get(f);if(l.name==="MaxPropertiesError"||l.name==="MinPropertiesError")a();else if(c){const p=Vb.includes(l.name),g=this.rewriteError(l),v=p?c.keyFrom:c.valueFrom,k=p?c.keyTo:c.valueTo;k!==void 0&&v!==void 0&&o.push({from:v,to:k,message:g,renderMessage:()=>{const C=Ye("div",{});return C.innerHTML=qt(g),C},severity:"error",source:this.schemaTitle})}else a();return o},[]):[]}}function xS(i){const e=new $b(i);return async function(n,s,r){return e.doHover(n,s,r)}}function Sa(i){if(i.type)return i.$ref?`${i.$ref} (${i.type})`:i.type;if(i.$ref)return`${i.$ref}`}function Ys(i,e,t){return`${e}: ${Hi(i[e].map(n=>{try{const{data:s}=t.resolveRef({data:n,pointer:n.$ref});return Sa(s||n)}catch{return n.type}}))}`}class $b{constructor(e){var t,n;this.opts=e,this.schema=null,this.mode=ee.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=(n=(t=this.opts)===null||t===void 0?void 0:t.mode)!==null&&n!==void 0?n:ee.JSON}getDataForCursor(e,t,n){const s=yo(e.state);if(!s)return null;this.schema=new La(s);const r=xf(e.state,t,n,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 Ba(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:n}=e;return t?Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--description",inner:qt(t,!1)}),Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("div",{class:"cm6-json-schema-hover--code",inner:qt(n,!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:qt(n,!1)})])])}getHoverTexts(e,t){let n="",s=null;const{schema:r}=e;return r.oneOf&&(n=Ys(r,"oneOf",t)),r.anyOf&&(n=Ys(r,"anyOf",t)),r.allOf&&(n=Ys(r,"allOf",t)),r.type&&(n=Array.isArray(r.type)?Hi(r.type):r.type),r.$ref&&(n=` Reference: ${r.$ref}`),r.enum&&(n=`\`enum\`: ${Hi(r.enum)}`),r.format&&(n+=`\`format\`: ${r.format}`),r.pattern&&(n+=`\`pattern\`: ${r.pattern}`),r.description&&(s=r.description),{message:s,typeInfo:n}}async doHover(e,t,n){var s,r,o,l;const a=t,f=t;try{const c=this.getDataForCursor(e,t,n);if(le.log("cursorData",c),!(c!=null&&c.schema))return null;const g=((r=(s=this.opts)===null||s===void 0?void 0:s.getHoverTexts)!==null&&r!==void 0?r:this.getHoverTexts)(c,this.schema),k=((l=(o=this.opts)===null||o===void 0?void 0:o.formatHover)!==null&&l!==void 0?l:this.formatMessage)(g);return{pos:a,end:f,arrow:!0,above:!0,create:C=>({dom:k})}}catch(c){return le.log(c),null}}}const va=new Ia,Af=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function bn(i){return(e,t,n)=>{if(n)return!1;let s=e.node.getChild("VariableName");return s&&t(s,i),!0}}const Wb={FunctionDefinition:bn("function"),ClassDefinition:bn("class"),ForStatement(i,e,t){if(t){for(let n=i.node.firstChild;n;n=n.nextSibling)if(n.name=="VariableName")e(n,"variable");else if(n.name=="in")break}},ImportStatement(i,e){var t,n;let{node:s}=i,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"&&((n=o.nextSibling)===null||n===void 0?void 0:n.name)!="as"&&e(o,r?"variable":"namespace")},AssignStatement(i,e){for(let t=i.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(i,e){for(let t=null,n=i.node.firstChild;n;n=n.nextSibling)n.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(n,"variable"),t=n},CapturePattern:bn("variable"),AsPattern:bn("variable"),__proto__:null};function Mf(i,e){let t=va.get(e);if(t)return t;let n=[],s=!0;function r(o,l){let a=i.sliceString(o.from,o.to);n.push({label:a,type:l})}return e.cursor(Gn.IncludeAnonymous).iterate(o=>{if(o.name){let l=Wb[o.name];if(l&&l(o,r,s)||!s&&Af.has(o.name))return!1;s=!1}else if(o.to-o.from>8192){for(let l of Mf(i,o.node))n.push(l);return!1}}),va.set(e,n),n}const xa=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Ef=["String","FormatString","Comment","PropertyName"];function zb(i){let e=ie(i.state).resolveInner(i.pos,-1);if(Ef.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&xa.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let s=e;s;s=s.parent)Af.has(s.name)&&(n=n.concat(Mf(i.state.doc,s)));return{options:n,from:t?e.from:i.pos,validFor:xa}}const qb=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(i=>({label:i,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(i=>({label:i,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(i=>({label:i,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(i=>({label:i,type:"function"}))),jb=[se("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),se("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),se("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),se("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),se(`if \${}:
11
+ `:n=="r"?"\r":n=="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 O0(this):new E0(this)}getCursor(e,t=0,n){let s=e.doc?e:y.EditorState.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Bt(this,s,t,n):Rt(this,s,t,n)}}class Jc{constructor(e){this.spec=e}}function Rt(i,e,t,n){return new Gt(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?M0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function M0(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(zn(s,t-r))!=y.CharCategory.Word||e(qn(s,t-r))!=y.CharCategory.Word)&&(e(qn(s,n-r))!=y.CharCategory.Word||e(zn(s,n-r))!=y.CharCategory.Word))}class E0 extends Jc{constructor(e){super(e)}nextMatch(e,t,n){let s=Rt(this.spec,e,n,e.doc.length).nextOverlapping();return s.done&&(s=Rt(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Rt(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,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Rt(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Rt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Bt(i,e,t,n){return new jc(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?T0(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function zn(i,e){return i.slice(y.findClusterBreak(i,e,!1),e)}function qn(i,e){return i.slice(e,y.findClusterBreak(i,e))}function T0(i){return(e,t,n)=>!n[0].length||(i(zn(n.input,n.index))!=y.CharCategory.Word||i(qn(n.input,n.index))!=y.CharCategory.Word)&&(i(qn(n.input,n.index+n[0].length))!=y.CharCategory.Word||i(zn(n.input,n.index+n[0].length))!=y.CharCategory.Word)}class O0 extends Jc{nextMatch(e,t,n){let s=Bt(this.spec,e,n,e.doc.length).next();return s.done&&(s=Bt(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Bt(this.spec,e,r,n),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,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n<e.match.length?e.match[n]:t)}matchAll(e,t){let n=Bt(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Bt(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Bi=y.StateEffect.define(),ro=y.StateEffect.define(),pt=y.StateField.define({create(i){return new Hs(Or(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Bi)?i=new Hs(t.value.create(),i.panel):t.is(ro)&&(i=new Hs(i.query,t.value?oo:null));return i},provide:i=>Di.from(i,e=>e.panel)});class Hs{constructor(e,t){this.query=e,this.panel=t}}const D0=H.mark({class:"cm-searchMatch"}),P0=H.mark({class:"cm-searchMatch cm-searchMatch-selected"}),R0=te.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(pt))}update(i){let e=i.state.field(pt);(e!=i.startState.field(pt)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return H.none;let{view:t}=this,n=new y.RangeSetBuilder;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-500;)a=r[++s].to;i.highlight(t.state,l,a,(f,c)=>{let p=t.state.selection.ranges.some(g=>g.from==f&&g.to==c);n.add(f,c,p?P0:D0)})}return n.finish()}},{decorations:i=>i.decorations});function Ki(i){return e=>{let t=e.state.field(pt,!1);return t&&t.query.spec.valid?i(e,t):Gc(e)}}const jn=Ki((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=y.EditorSelection.single(n.from,n.to),r=i.state.facet(ni);return i.dispatch({selection:s,effects:[lo(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),Yc(i),!0}),_n=Ki((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=y.EditorSelection.single(s.from,s.to),o=i.state.facet(ni);return i.dispatch({selection:r,effects:[lo(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),Yc(i),!0}),B0=Ki((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:y.EditorSelection.create(t.map(n=>y.EditorSelection.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),L0=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new Gt(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(y.EditorSelection.range(l.value.from,l.value.to))}return e(i.update({selection:y.EditorSelection.create(r,o),userEvent:"select.search.matches"})),!0},Jl=Ki((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=[],l,a,f=[];if(r.from==n&&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),f.push(L.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=y.EditorSelection.single(r.from-c,r.to-c),f.push(lo(i,r)),f.push(t.facet(ni).scrollToMatch(l.main,i))}return i.dispatch({changes:o,selection:l,effects:f,userEvent:"input.replace"}),!0}),I0=Ki((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.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 n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:L.announce.of(n),userEvent:"input.replace.all"}),!0});function oo(i){return i.state.facet(ni).createPanel(i)}function Or(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let f=i.facet(ni);return new Kc({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:f.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:f.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:f.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:f.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:f.wholeWord})}function Uc(i){let e=Oi(i,oo);return e&&e.dom.querySelector("[main-field]")}function Yc(i){let e=Uc(i);e&&e==i.root.activeElement&&e.select()}const Gc=i=>{let e=i.state.field(pt,!1);if(e&&e.panel){let t=Uc(i);if(t&&t!=i.root.activeElement){let n=Or(i.state,e.query.spec);n.valid&&i.dispatch({effects:Bi.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[ro.of(!0),e?Bi.of(Or(i.state,e.query.spec)):y.StateEffect.appendConfig.of(H0)]});return!0},Xc=i=>{let e=i.state.field(pt,!1);if(!e||!e.panel)return!1;let t=Oi(i,oo);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:ro.of(!1)}),!0},N0=[{key:"Mod-f",run:Gc,scope:"editor search-panel"},{key:"F3",run:jn,shift:_n,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jn,shift:_n,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:L0},{key:"Mod-Alt-g",run:d0},{key:"Mod-d",run:A0,preventDefault:!0}];class F0{constructor(e){this.view=e;let t=this.query=e.state.field(pt).query.spec;this.commit=this.commit.bind(this),this.searchField=G("input",{value:t.search,placeholder:Be(e,"Find"),"aria-label":Be(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=G("input",{value:t.replace,placeholder:Be(e,"Replace"),"aria-label":Be(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=G("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=G("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=G("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return G("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=G("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>jn(e),[Be(e,"next")]),n("prev",()=>_n(e),[Be(e,"previous")]),n("select",()=>B0(e),[Be(e,"all")]),G("label",null,[this.caseField,Be(e,"match case")]),G("label",null,[this.reField,Be(e,"regexp")]),G("label",null,[this.wordField,Be(e,"by word")]),...e.state.readOnly?[]:[G("br"),this.replaceField,n("replace",()=>Jl(e),[Be(e,"replace")]),n("replaceAll",()=>I0(e),[Be(e,"replace all")])],G("button",{name:"close",onclick:()=>Xc(e),"aria-label":Be(e,"close"),type:"button"},["×"])])}commit(){let e=new Kc({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:Bi.of(e)}))}keydown(e){$d(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?_n:jn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Jl(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Bi)&&!n.value.eq(this.query)&&this.setQuery(n.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(ni).top}}function Be(i,e){return i.state.phrase(e)}const pn=30,mn=/[\s\.,:;?!]/;function lo(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-pn),o=Math.min(s,t+pn),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<pn;a++)if(!mn.test(l[a+1])&&mn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-pn;a--)if(!mn.test(l[a-1])&&mn.test(l[a])){l=l.slice(0,a);break}}return L.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const V0=L.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"}}),H0=[pt,y.Prec.low(R0),V0];class Qc{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=ie(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),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),r=s.search(ef(e,!1));return r<0?null:{from:n+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 Ul(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function $0(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let n=Ul(e)+Ul(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ao(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:$0(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Zc(i,e){return t=>{for(let n=ie(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class Yl{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function mt(i){return i.selection.main.from}function ef(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",r=n[n.length-1]!="$";return!s&&!r?i:new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const tf=y.Annotation.define();function W0(i,e,t,n){let{main:s}=i.selection,r=t-s.from,o=n-s.from;return Object.assign(Object.assign({},i.changeByRange(l=>l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n)?{range:l}:{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:e},range:y.EditorSelection.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Gl=new WeakMap;function z0(i){if(!Array.isArray(i))return i;let e=Gl.get(i);return e||Gl.set(i,e=ao(i)),e}const Kn=y.StateEffect.define(),Li=y.StateEffect.define();class q0{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 n=y.codePointAt(e,t),s=y.codePointSize(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(y.codePointAt(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:n,any:s,precise:r,byWord:o}=this;if(t.length==1){let P=y.codePointAt(e,0),F=y.codePointSize(P),I=F==e.length?0:-100;if(P!=t[0])if(P==n[0])I+=-200;else return!1;return this.ret(I,[0,F])}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,f=0;if(l<0){for(let P=0,F=Math.min(e.length,200);P<F&&f<a;){let I=y.codePointAt(e,P);(I==t[f]||I==n[f])&&(s[f++]=P),P+=y.codePointSize(I)}if(f<a)return!1}let c=0,p=0,g=!1,v=0,k=-1,C=-1,M=/[a-z]/.test(e),T=!0;for(let P=0,F=Math.min(e.length,200),I=0;P<F&&p<a;){let R=y.codePointAt(e,P);l<0&&(c<a&&R==t[c]&&(r[c++]=P),v<a&&(R==t[v]||R==n[v]?(v==0&&(k=P),C=P+1,v++):v=0));let N,z=R<255?R>=48&&R<=57||R>=97&&R<=122?2:R>=65&&R<=90?1:0:(N=y.fromCodePoint(R))!=N.toLowerCase()?1:N!=N.toUpperCase()?2:0;(!P||z==1&&M||I==0&&z!=0)&&(t[p]==R||n[p]==R&&(g=!0)?o[p++]=P:o.length&&(T=!1)),I=z,P+=y.codePointSize(R)}return p==a&&o[0]==0&&T?this.result(-100+(g?-200:0),o,e):v==a&&k==0?this.ret(-200-e.length+(C==e.length?0:-100),[0,C]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):v==a?this.ret(-900-e.length,[k,C]):p==a?this.result(-100+(g?-200:0)+-700+(T?0:-1100),o,e):t.length==2?!1:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],r=0;for(let o of t){let l=o+(this.astral?y.codePointSize(y.codePointAt(n,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-n.length,s)}}const pe=y.Facet.define({combine(i){return y.combineConfig(i,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:j0,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)=>n=>Xl(e(n),t(n)),optionClass:(e,t)=>n=>Xl(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})}});function Xl(i,e){return i?e?i+" "+e:i:e}function j0(i,e,t,n,s,r){let o=i.textDirection==U.RTL,l=o,a=!1,f="top",c,p,g=e.left-s.left,v=s.right-e.right,k=n.right-n.left,C=n.bottom-n.top;if(l&&g<Math.min(k,v)?l=!1:!l&&v<Math.min(k,g)&&(l=!0),k<=(l?g:v))c=Math.max(s.top,Math.min(t.top,s.bottom-C))-e.top,p=Math.min(400,l?g:v);else{a=!0,p=Math.min(400,(o?e.right:s.right-e.left)-30);let P=s.bottom-e.bottom;P>=C||P>e.top?c=t.bottom-e.top:(f="bottom",c=e.bottom-t.top)}let M=(e.bottom-e.top)/r.offsetHeight,T=(e.right-e.left)/r.offsetWidth;return{style:`${f}: ${c/M}px; max-width: ${p/T}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function _0(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let f=0;f<r.length;){let c=r[f++],p=r[f++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(l.slice(c,p))),g.className="cm-completionMatchedText",a=p}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function $s(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class K0{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,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(pe);this.optionContent=_0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=$s(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:f}=e.state.field(t).open;for(let c=a.target,p;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(p=/-(\d+)$/.exec(c.id))&&+p[1]<f.length){this.applyCompletion(e,f[+p[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let f=e.state.field(this.stateField,!1);f&&f.tooltip&&e.state.facet(pe).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Li.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 n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:r,selected:o,disabled:l}=n.open;(!s.open||s.open.options!=r)&&(this.range=$s(r.length,o,e.state.facet(pe).maxRenderedOptions),this.showOptions(r,n.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 n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);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=$s(t.options.length,t.selected,this.view.state.facet(pe).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:s}=n;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(n);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>ke(this.view.state,o,"completion info")):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;n.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&U0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=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(pe).positionInfo(this.view,t,s,n,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,n){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=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:f}=l;if(f){let g=typeof f=="string"?f:f.name;if(g!=r&&(o>n.from||n.from==0))if(r=g,typeof f!="string"&&f.header)s.appendChild(f.header(f));else{let v=s.appendChild(document.createElement("completion-section"));v.textContent=g}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let p=this.optionClass(l);p&&(c.className=p);for(let g of this.optionContent){let v=g(l,this.view.state,this.view,a);v&&c.appendChild(v)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.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 J0(i,e){return t=>new K0(t,i,e)}function U0(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/s:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function Ql(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function Y0(i,e){let t=[],n=null,s=a=>{t.push(a);let{section:f}=a.completion;if(f){n||(n=[]);let c=typeof f=="string"?f:f.name;n.some(p=>p.name==c)||n.push(typeof f=="string"?{name:c}:f)}};for(let a of i)if(a.hasResult()){let f=a.result.getMatch;if(a.result.filter===!1)for(let c of a.result.options)s(new Yl(c,a.source,f?f(c):[],1e9-t.length));else{let c=new q0(e.sliceDoc(a.from,a.to));for(let p of a.result.options)if(c.match(p.label)){let g=p.displayLabel?f?f(p,c.matched):[]:c.matched;s(new Yl(p,a.source,g,c.score+(p.boost||0)))}}}if(n){let a=Object.create(null),f=0,c=(p,g)=>{var v,k;return((v=p.rank)!==null&&v!==void 0?v:1e9)-((k=g.rank)!==null&&k!==void 0?k:1e9)||(p.name<g.name?-1:1)};for(let p of n.sort(c))f-=1e5,a[p.name]=f;for(let p of t){let{section:g}=p.completion;g&&(p.score+=a[typeof g=="string"?g:g.name])}}let r=[],o=null,l=e.facet(pe).compareCompletions;for(let a of t.sort((f,c)=>c.score-f.score||l(f.completion,c.completion))){let f=a.completion;!o||o.label!=f.label||o.detail!=f.detail||o.type!=null&&f.type!=null&&o.type!=f.type||o.apply!=f.apply||o.boost!=f.boost?r.push(a):Ql(a.completion)>Ql(o)&&(r[r.length-1]=a),o=a.completion}return r}class Vt{constructor(e,t,n,s,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Vt(this.options,Zl(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r){let o=Y0(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Vt(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(pe).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let f=0;f<o.length;f++)if(o[f].completion==a){l=f;break}}return new Vt(o,Zl(n,l),{pos:e.reduce((a,f)=>f.hasResult()?Math.min(a,f.from):a,1e8),create:ey,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Vt(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Jn{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Jn(Q0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(pe),r=(n.override||t.languageDataAt("autocomplete",mt(t)).map(z0)).map(l=>(this.active.find(f=>f.source==l)||new Pe(l,this.active.some(f=>f.state!=0)?1:0)).update(e,n));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))||!G0(r,this.active)?o=Vt.build(r,t,this.id,o,n):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(sf)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Jn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:X0}}function G0(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult;)t++;for(;n<e.length&&!e[n].hasResult;)n++;let s=t==i.length,r=n==e.length;if(s||r)return s==r;if(i[t++].result!=e[n++].result)return!1}}const X0={"aria-autocomplete":"list"};function Zl(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const Q0=[];function Dr(i){return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}class Pe{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Dr(e),s=this;n?s=s.handleUserEvent(e,n,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(Kn))s=new Pe(s.source,1,r.value?mt(e.state):-1);else if(r.is(Li))s=new Pe(s.source,0);else if(r.is(nf))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new Pe(this.source,1)}handleChange(e){return e.changes.touchesRange(mt(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 zt extends Pe{constructor(e,t,n,s,r){super(e,2,t),this.result=n,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=mt(e.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||t=="delete"&&mt(e.startState)==this.from)return new Pe(this.source,t=="input"&&n.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),f;return Z0(this.result.validFor,e.state,r,o)?new zt(this.source,a,this.result,r,o):this.result.update&&(f=this.result.update(this.result,r,o,new Qc(e.state,l,a>=0)))?new zt(this.source,a,f,f.from,(s=f.to)!==null&&s!==void 0?s:mt(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 zt(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function Z0(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):ef(i,!0).test(s)}const nf=y.StateEffect.define({map(i,e){return i.map(t=>t.map(e))}}),sf=y.StateEffect.define(),Ie=y.StateField.define({create(){return Jn.start()},update(i,e){return i.update(e)},provide:i=>[Kr.from(i,e=>e.tooltip),L.contentAttributes.from(i,e=>e.attrs)]});function rf(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ie).active.find(s=>s.source==e.source);return n instanceof zt?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},W0(i.state,t,n.from,n.to)),{annotations:tf.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const ey=J0(Ie,rf);function gn(i,e="option"){return t=>{let n=t.state.field(Ie,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(pe).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Vh(t,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+s*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:sf.of(l)}),!0}}const ty=i=>{let e=i.state.field(Ie,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(pe).interactionDelay?!1:rf(i,e.open.options[e.open.selected])},iy=i=>i.state.field(Ie,!1)?(i.dispatch({effects:Kn.of(!0)}),!0):!1,ny=i=>{let e=i.state.field(Ie,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Li.of(null)}),!0)};class sy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const ry=50,oy=1e3,ly=te.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Ie).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(Ie);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ie)==e)return;let t=i.transactions.some(s=>(s.selection||s.docChanged)&&!Dr(s));for(let s=0;s<this.running.length;s++){let r=this.running[s];if(t||r.updates.length+i.transactions.length>ry&&Date.now()-r.time>oy){for(let o of r.context.abortListeners)try{o()}catch(l){ke(this.view.state,l)}r.context.abortListeners=null,this.running.splice(s--,1)}else r.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(r=>r.is(Kn)))&&(this.pendingStart=!0);let n=this.pendingStart?50:i.state.facet(pe).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(r=>r.active.source==s.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let s of i.transactions)Dr(s)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Ie);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=mt(e),n=new Qc(e,t,i.explicitPos==t),s=new sy(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Li.of(null)}),ke(this.view.state,r)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(pe);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(s.done===void 0)continue;if(this.running.splice(n--,1),s.done){let o=new zt(s.active.source,s.active.explicitPos,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:mt(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(Ie).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:nf.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ie,!1);if(e&&e.tooltip&&this.view.state.facet(pe).closeOnBlur){let t=e.open&&Vh(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Li.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Kn.of(!1)}),20),this.composing=0}}}),of=L.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 ay=class{constructor(e,t,n,s){this.field=e,this.line=t,this.from=n,this.to=s}},hy=class lf{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,y.MapMode.TrackDel),n=e.mapPos(this.to,1,y.MapMode.TrackDel);return t==null||n==null?null:new lf(this.field,t,n)}},cy=class af{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(n.length){let f=o,c=/^\t*/.exec(a)[0].length;for(let p=0;p<c;p++)f+=e.facet(ti);s.push(t+f.length-c),a=f+a.slice(c)}n.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new hy(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:n,ranges:l}}static parse(e){let t=[],n=[],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]||"",f=-1;for(let c=0;c<t.length;c++)(l!=null?t[c].seq==l:a&&t[c].name==a)&&(f=c);if(f<0){let c=0;for(;c<t.length&&(l==null||t[c].seq!=null&&t[c].seq<l);)c++;t.splice(c,0,{seq:l,name:a}),f=c;for(let p of s)p.field>=f&&p.field++}s.push(new ay(f,n.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==n.length&&a.from>l.index&&(a.from--,a.to--)}n.push(o)}return new af(n,s)}},fy=H.widget({widget:new class extends _e{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),uy=H.mark({class:"cm-snippetField"}),as=class hf{constructor(e,t){this.ranges=e,this.active=t,this.deco=H.set(e.map(n=>(n.from==n.to?fy:uy).range(n.from,n.to)))}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new hf(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}};const Ji=y.StateEffect.define({map(i,e){return i&&i.map(e)}}),dy=y.StateEffect.define(),Ii=y.StateField.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(Ji))return t.value;if(t.is(dy)&&i)return new as(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>L.decorations.from(i,e=>e?e.deco:H.none)});function ho(i,e){return y.EditorSelection.create(i.filter(t=>t.field==e).map(t=>y.EditorSelection.range(t.from,t.to)))}function py(i){let e=cy.parse(i);return(t,n,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:y.Text.of(o)},scrollIntoView:!0,annotations:n?[tf.of(n),y.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=ho(l,0)),l.some(f=>f.field>0)){let f=new as(l,0),c=a.effects=[Ji.of(f)];t.state.field(Ii,!1)===void 0&&c.push(y.StateEffect.appendConfig.of([Ii,Sy,vy,of]))}t.dispatch(t.state.update(a))}}function cf(i){return({state:e,dispatch:t})=>{let n=e.field(Ii,!1);if(!n||i<0&&n.active==0)return!1;let s=n.active+i,r=i>0&&!n.ranges.some(o=>o.field==s+i);return t(e.update({selection:ho(n.ranges,s),effects:Ji.of(r?null:new as(n.ranges,s)),scrollIntoView:!0})),!0}}const my=({state:i,dispatch:e})=>i.field(Ii,!1)?(e(i.update({effects:Ji.of(null)})),!0):!1,gy=cf(1),yy=cf(-1),by=[{key:"Tab",run:gy,shift:yy},{key:"Escape",run:my}],ea=y.Facet.define({combine(i){return i.length?i[0]:by}}),Sy=y.Prec.highest(ei.compute([ea],i=>i.facet(ea)));function se(i,e){return Object.assign(Object.assign({},e),{apply:py(i)})}const vy=L.domEventHandlers({mousedown(i,e){let t=e.state.field(Ii,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=n&&r.to>=n);return!s||s.field==t.active?!1:(e.dispatch({selection:ho(t.ranges,s.field),effects:Ji.of(t.ranges.some(r=>r.field>s.field)?new as(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Ni={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},wt=y.StateEffect.define({map(i,e){let t=e.mapPos(i,-1,y.MapMode.TrackAfter);return t??void 0}}),co=new class extends y.RangeValue{};co.startSide=1;co.endSide=-1;const ff=y.StateField.define({create(){return y.RangeSet.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(wt)&&(i=i.update({add:[co.range(t.value,t.value+1)]}));return i}});function xy(){return[ky,ff]}const Ws="()[]{}<>";function uf(i){for(let e=0;e<Ws.length;e+=2)if(Ws.charCodeAt(e)==i)return Ws.charAt(e+1);return y.fromCodePoint(i<128?i:i+1)}function df(i,e){return i.languageDataAt("closeBrackets",e)[0]||Ni}const wy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ky=L.inputHandler.of((i,e,t,n)=>{if((wy?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&y.codePointSize(y.codePointAt(n,0))==1||e!=s.from||t!=s.to)return!1;let r=My(i.state,n);return r?(i.dispatch(r),!0):!1}),Cy=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=df(i,i.selection.main.head).brackets||Ni.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Ey(i.doc,o.head);for(let a of n)if(a==l&&hs(i.doc,o.head)==uf(y.codePointAt(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:y.EditorSelection.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Ay=[{key:"Backspace",run:Cy}];function My(i,e){let t=df(i,i.selection.main.head),n=t.brackets||Ni.brackets;for(let s of n){let r=uf(y.codePointAt(s,0));if(e==s)return r==s?Dy(i,s,n.indexOf(s+s+s)>-1,t):Ty(i,s,r,t.before||Ni.before);if(e==r&&pf(i,i.selection.main.from))return Oy(i,s,r)}return null}function pf(i,e){let t=!1;return i.field(ff).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function hs(i,e){let t=i.sliceString(e,e+2);return t.slice(0,y.codePointSize(y.codePointAt(t,0)))}function Ey(i,e){let t=i.sliceString(e-2,e);return y.codePointSize(y.codePointAt(t,0))==t.length?t:t.slice(1)}function Ty(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:wt.of(o.to+e.length),range:y.EditorSelection.range(o.anchor+e.length,o.head+e.length)};let l=hs(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:wt.of(o.head+e.length),range:y.EditorSelection.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Oy(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&hs(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:y.EditorSelection.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Dy(i,e,t,n){let s=n.stringPrefixes||Ni.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:wt.of(l.to+e.length),range:y.EditorSelection.range(l.anchor+e.length,l.head+e.length)};let a=l.head,f=hs(i.doc,a),c;if(f==e){if(ta(i,a))return{changes:{insert:e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)};if(pf(i,a)){let g=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+g.length,insert:g},range:y.EditorSelection.cursor(a+g.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=ia(i,a-2*e.length,s))>-1&&ta(i,c))return{changes:{insert:e+e+e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)};if(i.charCategorizer(a)(f)!=y.CharCategory.Word&&ia(i,a,s)>-1&&!Py(i,a,e,s))return{changes:{insert:e+e,from:a},effects:wt.of(a+e.length),range:y.EditorSelection.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ta(i,e){let t=ie(i).resolveInner(e+1);return t.parent&&t.from==e}function Py(i,e,t,n){let s=ie(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let f=s.to==e&&s.parent;if(!f)break;s=f}return!1}function ia(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=y.CharCategory.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=y.CharCategory.Word)return r}return-1}function Ry(i={}){return[Ie,pe.of(i),ly,By,of]}const mf=[{key:"Ctrl-Space",run:iy},{key:"Escape",run:ny},{key:"ArrowDown",run:gn(!0)},{key:"ArrowUp",run:gn(!1)},{key:"PageDown",run:gn(!0,"page")},{key:"PageUp",run:gn(!1,"page")},{key:"Enter",run:ty}],By=y.Prec.highest(ei.computeN([pe],i=>i.facet(pe).defaultKeymap?[mf]:[]));var na=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Ay)),e.defaultKeymap!==!1&&(n=n.concat(Wg)),e.searchKeymap!==!1&&(n=n.concat(N0)),e.historyKeymap!==!1&&(n=n.concat(Gm)),e.foldKeymap!==!1&&(n=n.concat(cm)),e.completionKeymap!==!1&&(n=n.concat(mf)),e.lintKeymap!==!1&&(n=n.concat(Qg));var s=[];return e.lineNumbers!==!1&&s.push(Hp()),e.highlightActiveLineGutter!==!1&&s.push(zp()),e.highlightSpecialChars!==!1&&s.push(np()),e.history!==!1&&s.push(Wm()),e.foldGutter!==!1&&s.push(pm()),e.drawSelection!==!1&&s.push(Kd()),e.dropCursor!==!1&&s.push(Xd()),e.allowMultipleSelections!==!1&&s.push(y.EditorState.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(tm()),e.syntaxHighlighting!==!1&&s.push(tc(bm,{fallback:!0})),e.bracketMatching!==!1&&s.push(Am()),e.closeBrackets!==!1&&s.push(xy()),e.autocompletion!==!1&&s.push(Ry()),e.rectangularSelection!==!1&&s.push(yp()),t!==!1&&s.push(vp()),e.highlightActiveLine!==!1&&s.push(hp()),e.highlightSelectionMatches!==!1&&s.push(y0()),e.tabSize&&typeof e.tabSize=="number"&&s.push(ti.of(" ".repeat(e.tabSize))),s.concat([ei.of(n.flat())]).filter(Boolean)},zs;const xi=new Oe,Ly=new Oe;class et{constructor(e,t,n=[],s=""){this.data=e,this.name=s,y.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(y.EditorState.prototype,"tree",{get(){return Fi(this)}}),this.parser=t,this.extension=[Qt.of(this),y.EditorState.languageData.of((r,o,l)=>{let a=sa(r,o,l),f=a.type.prop(xi);if(!f)return[];let c=r.facet(f),p=a.type.prop(Ly);if(p){let g=a.resolve(o-a.from,l);for(let v of p)if(v.test(g,r)){let k=r.facet(v.facet);return v.type=="replace"?k:k.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return sa(e,t,n).type.prop(xi)==this.data}findRegions(e){let t=e.facet(Qt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(xi)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(Oe.mounted);if(l){if(l.tree.prop(xi)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let f=r.children[a];f instanceof Fe&&s(f,r.positions[a]+o)}};return s(Fi(e),0),n}get allowsNesting(){return!0}}et.setState=y.StateEffect.define();function sa(i,e,t){let n=i.facet(Qt),s=Fi(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Gn.ExcludeBuffers))r.type.isTop&&(s=r);return s}function Fi(i){let e=i.field(et.state,!1);return e?e.tree:Fe.empty}class Iy{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 n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let mi=null;class Un{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Un(e,t,[],Fe.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Iy(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Fe.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;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(dt.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n: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(dt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=mi;mi=this;try{return e()}finally{mi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ra(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((f,c,p,g)=>a.push({fromA:f,toA:c,fromB:p,toB:g})),n=dt.applyChanges(n,a),s=Fe.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let c=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);c<p&&l.push({from:c,to:p})}}}return new Un(this.parser,t,n,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 n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=ra(this.fragments,s,r),this.skipped.splice(n--,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 Ma{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=mi;if(a){for(let f of s)a.tempSkipped.push(f);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Fe(Zt.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 mi}}function ra(i,e,t){return dt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Xt{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),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Xt(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Un.create(e.facet(Qt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Xt(n)}}et.state=y.StateField.define({create:Xt.init,update(i,e){for(let t of e.effects)if(t.is(et.setState))return t.value;return e.startState.facet(Qt)!=e.state.facet(Qt)?Xt.init(e.state):i.apply(e)}});let gf=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(gf=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const qs=typeof navigator<"u"&&(!((zs=navigator.scheduling)===null||zs===void 0)&&zs.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ny=te.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(et.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(et.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=gf(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:n,viewport:{to:s}}=this.view,r=n.field(et.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!qs?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>qs&&qs()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:et.setState.of(new Xt(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=>ke(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()}}}),Qt=y.Facet.define({combine(i){return i.length?i[0]:null},enables:i=>[et.state,Ny,L.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class cs{constructor(e,t){this.specs=e;let n;function s(l){let a=tt.newName();return(n||(n=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 et?l=>l.prop(xi)==o.data:o?l=>l==o:void 0,this.style=Ea(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new tt(n):null,this.themeType=t.themeType}static define(e,t){return new cs(e,t||{})}}const Pr=y.Facet.define(),Fy=y.Facet.define({combine(i){return i.length?[i[0]]:null}});function js(i){let e=i.facet(Pr);return e.length?e:i.facet(Fy)}function Vy(i,e){let t=[$y],n;return i instanceof cs&&(i.module&&t.push(L.styleModule.of(i.module)),n=i.themeType),n?t.push(Pr.computeN([L.darkTheme],s=>s.facet(L.darkTheme)==(n=="dark")?[i]:[])):t.push(Pr.of(i)),t}class Hy{constructor(e){this.markCache=Object.create(null),this.tree=Fi(e.state),this.decorations=this.buildDeco(e,js(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Fi(e.state),n=js(e.state),s=n!=js(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,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return H.none;let n=new y.RangeSetBuilder;for(let{from:s,to:r}of e.visibleRanges)Ta(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=H.mark({class:a})))},s,r);return n.finish()}}const $y=y.Prec.high(te.fromClass(Hy,{decorations:i=>i.decorations})),Wy=Object.create(null),oa=[Zt.none],la=[],aa=Object.create(null),zy=Object.create(null);for(let[i,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"]])zy[i]=qy(Wy,e);function _s(i,e){la.indexOf(i)>-1||(la.push(i),console.warn(e))}function qy(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let f of l.split(".")){let c=i[f]||E[f];c?typeof c=="function"?a.length?a=a.map(c):_s(f,`Modifier ${f} used at start of tag`):a.length?_s(f,`Tag ${f} used as modifier`):a=Array.isArray(c)?c:[c]:_s(f,`Unknown highlighting tag ${f}`)}for(let f of a)t.push(f)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=aa[s];if(r)return r.id;let o=aa[s]=Zt.define({id:oa.length,name:n,props:[Oa({[n]:t})]});return oa.push(o),o.id}U.RTL,U.LTR;const jy="#e5c07b",ha="#e06c75",_y="#56b6c2",Ky="#ffffff",En="#abb2bf",Rr="#7d8799",Jy="#61afef",Uy="#98c379",ca="#d19a66",Yy="#c678dd",Gy="#21252b",fa="#2c313a",ua="#282c34",Ks="#353a42",Xy="#3E4451",da="#528bff",Qy=L.theme({"&":{color:En,backgroundColor:ua},".cm-content":{caretColor:da},".cm-cursor, .cm-dropCursor":{borderLeftColor:da},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Xy},".cm-panels":{backgroundColor:Gy,color:En},".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:ua,color:Rr,border:"none"},".cm-activeLineGutter":{backgroundColor:fa},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ks},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ks,borderBottomColor:Ks},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fa,color:En}}},{dark:!0}),Zy=cs.define([{tag:E.keyword,color:Yy},{tag:[E.name,E.deleted,E.character,E.propertyName,E.macroName],color:ha},{tag:[E.function(E.variableName),E.labelName],color:Jy},{tag:[E.color,E.constant(E.name),E.standard(E.name)],color:ca},{tag:[E.definition(E.name),E.separator],color:En},{tag:[E.typeName,E.className,E.number,E.changed,E.annotation,E.modifier,E.self,E.namespace],color:jy},{tag:[E.operator,E.operatorKeyword,E.url,E.escape,E.regexp,E.link,E.special(E.string)],color:_y},{tag:[E.meta,E.comment],color:Rr},{tag:E.strong,fontWeight:"bold"},{tag:E.emphasis,fontStyle:"italic"},{tag:E.strikethrough,textDecoration:"line-through"},{tag:E.link,color:Rr,textDecoration:"underline"},{tag:E.heading,fontWeight:"bold",color:ha},{tag:[E.atom,E.bool,E.special(E.variableName)],color:ca},{tag:[E.processingInstruction,E.string,E.inserted],color:Uy},{tag:E.invalid,color:Ky}]),eb=[Qy,Vy(Zy)];var tb=L.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ib=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(ei.of([zg])),l&&(typeof l=="boolean"?a.unshift(na()):a.unshift(na(l))),o&&a.unshift(dp(o)),r){case"light":a.push(tb);break;case"dark":a.push(eb);break;case"none":break;default:a.push(r);break}return n===!1&&a.push(L.editable.of(!1)),s&&a.push(y.EditorState.readOnly.of(!0)),[...a]},nb=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class sb{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class pa{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Js=null,rb=()=>typeof window>"u"?new pa:(Js||(Js=new pa),Js),ma=y.Annotation.define(),ob=200,lb=[];function ab(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=lb,autoFocus:a,theme:f="light",height:c=null,minHeight:p=null,maxHeight:g=null,width:v=null,minWidth:k=null,maxWidth:C=null,placeholder:M="",editable:T=!0,readOnly:P=!1,indentWithTab:F=!0,basicSetup:I=!0,root:R,initialState:N}=i,[z,Y]=Me.useState(),[_,me]=Me.useState(),[Ae,he]=Me.useState(),q=Me.useState(()=>({current:null}))[0],ue=Me.useState(()=>({current:null}))[0],ge=L.theme({"&":{height:c,minHeight:p,maxHeight:g,width:v,minWidth:k,maxWidth:C},"& .cm-scroller":{height:"100% !important"}}),X=L.updateListener.of(ne=>{if(ne.docChanged&&typeof n=="function"&&!ne.transactions.some(ht=>ht.annotation(ma))){q.current?q.current.reset():(q.current=new sb(()=>{if(ue.current){var ht=ue.current;ue.current=null,ht()}q.current=null},ob),rb().add(q.current));var re=ne.state.doc,st=re.toString();n(st,ne)}s&&s(nb(ne))}),ye=ib({theme:f,editable:T,readOnly:P,placeholder:M,indentWithTab:F,basicSetup:I}),be=[X,ge,...ye];return o&&typeof o=="function"&&be.push(L.updateListener.of(o)),be=be.concat(l),Me.useLayoutEffect(()=>{if(z&&!Ae){var ne={doc:e,selection:t,extensions:be},re=N?y.EditorState.fromJSON(N.json,ne,N.fields):y.EditorState.create(ne);if(he(re),!_){var st=new L({state:re,parent:z,root:R});me(st),r&&r(st,re)}}return()=>{_&&(he(void 0),me(void 0))}},[z,Ae]),Me.useEffect(()=>{i.container&&Y(i.container)},[i.container]),Me.useEffect(()=>()=>{_&&(_.destroy(),me(void 0)),q.current&&(q.current.cancel(),q.current=null)},[_]),Me.useEffect(()=>{a&&_&&_.focus()},[a,_]),Me.useEffect(()=>{_&&_.dispatch({effects:y.StateEffect.reconfigure.of(be)})},[f,l,c,p,g,v,k,C,M,T,P,F,I,n,o]),Me.useEffect(()=>{if(e!==void 0){var ne=_?_.state.doc.toString():"";if(_&&e!==ne){var re=q.current&&!q.current.isDone,st=()=>{_&&e!==_.state.doc.toString()&&_.dispatch({changes:{from:0,to:_.state.doc.toString().length,insert:e||""},annotations:[ma.of(!0)]})};re?ue.current=st:st()}}},[e,_]),{state:Ae,setState:he,view:_,setView:me,container:z,setContainer:Y}}var hb=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],cb=Me.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:f,autoFocus:c,theme:p="light",height:g,minHeight:v,maxHeight:k,width:C,minWidth:M,maxWidth:T,basicSetup:P,placeholder:F,indentWithTab:I,editable:R,readOnly:N,root:z,initialState:Y}=i,_=Zf(i,hb),me=Me.useRef(null),{state:Ae,view:he,container:q,setContainer:ue}=ab({root:z,value:n,autoFocus:c,theme:p,height:g,minHeight:v,maxHeight:k,width:C,minWidth:M,maxWidth:T,basicSetup:P,placeholder:F,indentWithTab:I,editable:R,readOnly:N,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:f,extensions:r,initialState:Y});Me.useImperativeHandle(e,()=>({editor:me.current,state:Ae,view:he}),[me,q,Ae,he]);var ge=Me.useCallback(ye=>{me.current=ye,ue(ye)},[ue]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var X=typeof p=="string"?"cm-theme-"+p:"cm-theme";return eu.jsx("div",tu({ref:ge,className:""+X+(t?" "+t:"")},_))});cb.displayName="CodeMirror";const fb=y.Annotation.define(),ub=L.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 db{constructor(e,t,n,s){this.field=e,this.line=t,this.from=n,this.to=s}}class fo{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,y.MapMode.TrackDel),n=e.mapPos(this.to,1,y.MapMode.TrackDel);return t==null||n==null?null:new fo(this.field,t,n)}}class uo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(n.length){let f=o,c=/^\t*/.exec(a)[0].length;for(let p=0;p<c;p++)f+=e.facet(ti);s.push(t+f.length-c),a=f+a.slice(c)}n.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new fo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:n,ranges:l}}static parse(e){let t=[],n=[],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]||"",f=-1,c=a.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p<t.length;p++)(l!=null?t[p].seq==l:c&&t[p].name==c)&&(f=p);if(f<0){let p=0;for(;p<t.length&&(l==null||t[p].seq!=null&&t[p].seq<l);)p++;t.splice(p,0,{seq:l,name:c}),f=p;for(let g of s)g.field>=f&&g.field++}s.push(new db(f,n.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,f)=>{for(let c of s)c.line==n.length&&c.from>f&&(c.from--,c.to--);return a}),n.push(o)}return new uo(n,s)}}let pb=H.widget({widget:new class extends _e{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),mb=H.mark({class:"cm-snippetField"});class si{constructor(e,t){this.ranges=e,this.active=t,this.deco=H.set(e.map(n=>(n.from==n.to?pb:mb).range(n.from,n.to)))}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new si(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}}const Ui=y.StateEffect.define({map(i,e){return i&&i.map(e)}}),gb=y.StateEffect.define(),Vi=y.StateField.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(Ui))return t.value;if(t.is(gb)&&i)return new si(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>L.decorations.from(i,e=>e?e.deco:H.none)});function po(i,e){return y.EditorSelection.create(i.filter(t=>t.field==e).map(t=>y.EditorSelection.range(t.from,t.to)))}function yb(i){let e=uo.parse(i);return(t,n,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,f={changes:{from:s,to:r==a.from?a.to:r,insert:y.Text.of(o)},scrollIntoView:!0,annotations:n?[fb.of(n),y.Transaction.userEvent.of("input.complete")]:void 0};if(l.length&&(f.selection=po(l,0)),l.some(c=>c.field>0)){let c=new si(l,0),p=f.effects=[Ui.of(c)];t.state.field(Vi,!1)===void 0&&p.push(y.StateEffect.appendConfig.of([Vi,wb,Cb,ub]))}t.dispatch(t.state.update(f))}}function yf(i){return({state:e,dispatch:t})=>{let n=e.field(Vi,!1);if(!n||i<0&&n.active==0)return!1;let s=n.active+i,r=i>0&&!n.ranges.some(o=>o.field==s+i);return t(e.update({selection:po(n.ranges,s),effects:Ui.of(r?null:new si(n.ranges,s)),scrollIntoView:!0})),!0}}const bb=({state:i,dispatch:e})=>i.field(Vi,!1)?(e(i.update({effects:Ui.of(null)})),!0):!1,Sb=yf(1),vb=yf(-1),xb=[{key:"Tab",run:Sb,shift:vb},{key:"Escape",run:bb}],ga=y.Facet.define({combine(i){return i.length?i[0]:xb}}),wb=y.Prec.highest(ei.compute([ga],i=>i.facet(ga)));function kb(i,e){return Object.assign(Object.assign({},e),{apply:yb(i)})}const Cb=L.domEventHandlers({mousedown(i,e){let t=e.state.field(Vi,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=n&&r.to>=n);return!s||s.field==t.active?!1:(e.dispatch({selection:po(t.ranges,s.field),effects:Ui.of(t.ranges.some(r=>r.field>s.field)?new si(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),bf=new class extends y.RangeValue{};bf.startSide=1;bf.endSide=-1;Pa.setLevel("silent");const le=Pa,j={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:"⚠"},Ab={Pair:j.PROPERTY,Key:j.PROPERTY_NAME,BlockSequence:j.ARRAY,BlockMapping:j.OBJECT,FlowSequence:j.ARRAY,FlowMapping:j.OBJECT,QuotedLiteral:j.STRING,Literal:j.STRING,Stream:j.JSON_TEXT,Document:j.OBJECT},Mb={File:j.JSON_TEXT},mo=[j.STRING,j.NUMBER,j.TRUE,j.FALSE,j.NULL],Sf=[j.OBJECT,j.ARRAY,j.ITEM],ee={JSON5:"json5",JSON:"json4",YAML:"yaml"},ae=(i,e)=>{var t,n;switch(e){case ee.YAML:return(t=Ab[i])!==null&&t!==void 0?t:i;case ee.JSON5:return(n=Mb[i])!==null&&n!==void 0?n:i;default:return i}};function vf(i,e,t){const n=[];for(let s=e;s!=null&&s.parent;s=s.parent)switch(ae(s.parent.name,t)){case j.PROPERTY:{const r=Br(s.parent,j.PROPERTY_NAME,t);r&&n.unshift(Lt(i,r).replace(/[/~]/g,o=>o==="~"?"~0":"~1"));break}case j.ARRAY:{if(Tb(s,t)){const r=kf(s.parent,s,t);n.unshift(`${r}`)}break}}return n.unshift(""),n.join("/")}const xf=(i,e,t=-1,n)=>vf(i.doc,ie(i).resolve(e,t),n),go=(i,e)=>{const t=ie(i),n=new Map;return t.iterate({enter:s=>{var r,o,l,a,f,c,p,g;if([j.PROPERTY_NAME,j.OBJECT].includes(ae(s.name,e))){const v=vf(i.doc,s.node,e),{from:k,to:C}=s.node;if(!(!((o=(r=s.node)===null||r===void 0?void 0:r.nextSibling)===null||o===void 0)&&o.node))return n.set(v,{keyFrom:k,keyTo:C}),!0;const M=e===ee.JSON?(a=(l=s.node)===null||l===void 0?void 0:l.nextSibling)===null||a===void 0?void 0:a.node:(g=(p=(c=(f=s.node)===null||f===void 0?void 0:f.nextSibling)===null||c===void 0?void 0:c.node)===null||p===void 0?void 0:p.nextSibling)===null||g===void 0?void 0:g.node;if(!M)return n.set(v,{keyFrom:k,keyTo:C}),!0;const{from:T,to:P}=M;return n.set(v,{keyFrom:k,keyTo:C,valueFrom:T,valueTo:P}),!0}}}),n},Us=(i,e,t=-1)=>ie(i).resolveInner(e,t),Tn=i=>i.replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1"),Eb=i=>i.replace(/^"(.*)"$/,"'$1'"),Lt=(i,e,t=!0,n=!0)=>{const s=e?i.sliceString(e.from,e.to):"";return t?n?Tn(s):s.replace(/(^["'])|(["']$)/g,""):s},wf=(i,e)=>{var t,n,s,r;return ae(i.name,e)===j.INVALID&&(ae((n=(t=i.prevSibling)===null||t===void 0?void 0:t.name)!==null&&n!==void 0?n:"",e)===j.PROPERTY_NAME||ae((r=(s=i.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)===j.PROPERTY_COLON)},On=(i,e)=>mo.includes(ae(i.name,e))||wf(i,e),Tb=(i,e)=>[...mo,...Sf].includes(ae(i.name,e))||wf(i,e),yn=(i,e)=>{var t,n,s,r,o,l;return ae(i.name,e)===j.PROPERTY_NAME||ae(i.name,e)===j.INVALID&&(ae((n=(t=i.prevSibling)===null||t===void 0?void 0:t.name)!==null&&n!==void 0?n:"",e)===j.PROPERTY||ae((r=(s=i.prevSibling)===null||s===void 0?void 0:s.name)!==null&&r!==void 0?r:"",e)==="{")||e===ee.YAML&&ae((l=(o=i.parent)===null||o===void 0?void 0:o.name)!==null&&l!==void 0?l:"",e)===j.OBJECT},Yi=i=>{const e=[];let t=i.firstChild;for(;t;)t&&e.push(t),t=t==null?void 0:t.nextSibling;return e},Ob=(i,e,t)=>Yi(i).filter(n=>ae(n.name,t)===e),Br=(i,e,t)=>{var n;return(n=Yi(i).find(s=>ae(s.name,t)===e))!==null&&n!==void 0?n:null},ya=(i,e)=>Yi(i).find(t=>On(t,e)),Db=(i,e)=>Yi(i).filter(t=>mo.includes(ae(t.name,e))||Sf.includes(ae(t.name,e))),kf=(i,e,t)=>Db(i,t).findIndex(n=>n.from===e.from&&n.to===e.to),ba=(i,e,t,n=1/0)=>{let s=i;for(;s&&n>0;){if(ae(s.name,t)===e)return s;s=s.parent,n--}return null},Pb=y.StateEffect.define(),Yn=y.StateField.define({create(){},update(i,e){for(const t of e.effects)if(t.is(Pb))return t.value;return i}}),yo=i=>i.field(Yn),yS=i=>[Yn.init(()=>i)];function Ye(i,e,t=[]){const n=document.createElement(i);return Object.entries(e).forEach(([s,r])=>{if(s==="text"){n.innerText=r;return}if(s==="inner"){n.innerHTML=r;return}n.setAttribute(s,r)}),t.forEach(s=>n.appendChild(s)),n}const Lr=iu({linkify:!0,typographer:!0});(async()=>{const i=await au({themes:[vs(()=>import("./vendor-shiki-DN26BkKE.js").then(e=>e.v),__vite__mapDeps([0,1,2,3])),vs(()=>import("./vendor-shiki-DN26BkKE.js").then(e=>e.a),__vite__mapDeps([0,1,2,3]))],langs:[vs(()=>import("./vendor-shiki-DN26BkKE.js").then(e=>e.j),__vite__mapDeps([0,1,2,3]))]});Lr.use(hu(i,{themes:{light:"vitesse-light",dark:"vitesse-dark"}}))})();function qt(i,e=!0){return e?Lr.renderInline(i):Lr.render(i)}function Rb(i){let e=null;try{e=JSON.parse(i.doc.toString())}catch{try{e=Ra.parse(i.doc.toString())}catch{}}const t=go(i,ee.JSON);return{data:e,pointers:t}}function Bb(i){let e=null;try{e=nu.parse(i.doc.toString())}catch{try{e=Ra.parse(i.doc.toString())}catch{}}const t=go(i,ee.JSON5);return{data:e,pointers:t}}function Lb(i){let e=null;try{e=su.parse(i.doc.toString())}catch{}const t=go(i,ee.YAML);return{data:e,pointers:t}}const Cf=i=>{switch(i){case ee.JSON:return Rb;case ee.JSON5:return Bb;case ee.YAML:return Lb}};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,n,s;this.opts=e,this.schema=null,this.mode=ee.JSON,this.mode=(t=e.mode)!==null&&t!==void 0?t:ee.JSON,this.parser=(s=(n=this.opts)===null||n===void 0?void 0:n.jsonParser)!==null&&s!==void 0?s:Cf(this.mode)}doComplete(e){var t,n,s;const r=yo(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=Us(e.state,e.pos),f=e.state.sliceDoc(a.from,e.pos).replace(/^(["'])/,"");if(le.log("xxx","node",a,"prefix",f,"ctx",e),!(On(a,this.mode)||yn(a,this.mode))&&!e.explicit)return le.log("xxx","no completions for non-word/primitive",a),o;const c=Lt(e.state.doc,a),p=Lt(e.state.doc,a,!1);if(a&&(On(a,this.mode)||yn(a,this.mode)))o.from=a.from,o.to=a.to;else{const C=e.matchBefore(/[A-Za-z0-9._]*/),M=e.pos-c.length;le.log("xxx","overwriteStart after",M,"ctx.pos",e.pos,"word",C,"currentWord",c,"=>",l[M-1],"..",l[M],"..",l),o.from=a.name===j.INVALID?(n=C==null?void 0:C.from)!==null&&n!==void 0?n:e.pos:M,o.to=e.pos}const g=new Ib;let v=!0;const k=ba(a,j.PROPERTY_NAME,this.mode);if(k&&(le.log("xxx","closestPropertyNameNode",k,"node",a),a=k),yn(a,this.mode)){le.log("xxx","isPropertyNameNode",a);const C=a.parent;if(C){const M=ya(C,this.mode);v=!M||M.name===j.INVALID&&M.from-M.to===0||(M.parent?Yi(M.parent).length<=1:!1),le.log("xxx","addValue",v,ya(C,this.mode),a),a=(s=ba(C,j.OBJECT,this.mode))!==null&&s!==void 0?s:null}}if(le.log("xxx",a,c,e,"node at pos",Us(e.state,e.pos)),a&&[j.OBJECT,j.JSON_TEXT].includes(ae(a.name,this.mode))&&(yn(Us(e.state,e.pos),this.mode)||k)){if(a.from===e.pos)return le.log("xxx","no completions for just before opening brace"),o;this.getPropertyCompletions(this.schema,e,a,g,v,p)}else{const C={},M=this.getValueCompletions(this.schema,e,C,g);le.log("xxx","getValueCompletions res",M)}return o.options=Array.from(g.completions.values()).filter(C=>Tn(C.label).startsWith(f)),le.log("xxx","result",o,"prefix",f,"collector.completions",g.completions,"reservedKeys",g.reservedKeys),o}applySnippetCompletion(e){return kb(typeof e.apply!="string"?e.label:e.apply,e)}getPropertyCompletions(e,t,n,s,r,o){const l=Ob(n,j.PROPERTY,this.mode);le.log("xxx","getPropertyCompletions",n,t,l),l.forEach(f=>{const c=Lt(t.state.doc,Br(f,j.PROPERTY_NAME,this.mode));s.reserve(Tn(c))});const a=this.getSchemas(e,t);le.log("xxx","propertyCompletion schemas",a),a.forEach(f=>{if(typeof f!="object")return;const c=f.properties;c&&Object.entries(c).forEach(([g,v])=>{var k,C;if(typeof v=="object"){const M=(k=v.description)!==null&&k!==void 0?k:"",T=(C=v.type)!==null&&C!==void 0?C:"",P=Array.isArray(T)?T.toString():T,F={label:g,apply:this.getInsertTextForProperty(g,r,o,v),type:"property",detail:P,info:()=>Ye("div",{inner:qt(M)})};s.add(this.applySnippetCompletion(F))}});const p=f.propertyNames;if(typeof p=="object"&&(p.enum&&p.enum.forEach(g=>{const v=g==null?void 0:g.toString();if(v){const k={label:v,apply:this.getInsertTextForProperty(v,r,o),type:"property"};s.add(this.applySnippetCompletion(k))}}),p.const)){const g=p.const.toString(),v={label:g,apply:this.getInsertTextForProperty(g,r,o),type:"property"};s.add(this.applySnippetCompletion(v))}})}getInsertTextForProperty(e,t,n,s){s=s&&this.expandSchemaProperty(s,this.schema);let r=this.getInsertTextForPropertyName(e,n);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 ee.JSON5:o="{#{}}";break;case ee.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)&&(le.log("xxx","value",o,"nValueProposals",l,s),o="#{}"),r+o}getInsertTextForPropertyName(e,t){switch(this.mode){case ee.JSON5:case ee.YAML:return t.startsWith('"')?`"${e}"`:t.startsWith("'")?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t="#"){switch(this.mode){case ee.JSON5:return`'${t}{${e}}'`;case ee.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 n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),this.getInsertTextForString(n,"$")+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 n=JSON.stringify(e,null," ");return n==="{}"?"{#{}}"+t:n==="[]"?"[#{}]"+t:this.getInsertTextForPlainText(n+t)}getValueCompletions(e,t,n,s){let r=ie(t.state).resolveInner(t.pos,-1),o=null,l;if(le.log("xxx","getValueCompletions",r,t),r&&On(r,this.mode)&&(o=r,r=r.parent),!r){this.addSchemaValueCompletions(e,n,s);return}if(ae(r.name,this.mode)===j.PROPERTY){const f=Br(r,j.PROPERTY_NAME,this.mode);f&&(l=Lt(t.state.doc,f),r=r.parent)}if(le.log("xxx","node",r,"parentKey",l),r&&(l!==void 0||ae(r.name,this.mode)===j.ARRAY)){const f=this.getSchemas(e,t);for(const c of f){if(typeof c!="object")return;if(ae(r.name,this.mode)===j.ARRAY&&c.items){let p=s;if(c.uniqueItems&&(p=Object.assign(Object.assign({},p),{add(g){p.completions.has(g.label)||s.add(g)},reserve(g){s.reserve(g)}})),Array.isArray(c.items)){let g=0;if(o){const k=kf(r,o,this.mode);k>=0&&(g=k)}const v=c.items[g];v&&this.addSchemaValueCompletions(v,n,p)}else this.addSchemaValueCompletions(c.items,n,p)}if(l!==void 0){let p=!1;if(c.properties){const g=c.properties[l];g&&(p=!0,this.addSchemaValueCompletions(g,n,s))}if(c.patternProperties&&!p)for(const g of Object.keys(c.patternProperties)){const v=this.extendedRegExp(g);if(v!=null&&v.test(l)){p=!0;const k=c.patternProperties[g];k&&this.addSchemaValueCompletions(k,n,s)}}if(c.additionalProperties&&!p){const g=c.additionalProperties;this.addSchemaValueCompletions(g,n,s)}}n.boolean&&(this.addBooleanValueCompletion(!0,s),this.addBooleanValueCompletion(!1,s)),n.null&&this.addNullValueCompletion(s)}}return{valuePrefix:o?Lt(t.state.doc,o,!0,!1):""}}addSchemaValueCompletions(e,t,n){typeof e=="object"&&(this.addEnumValueCompletions(e,n),this.addDefaultValueCompletions(e,n),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)),Array.isArray(e.anyOf)&&e.anyOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)),Array.isArray(e.oneOf)&&e.oneOf.forEach(s=>this.addSchemaValueCompletions(s,t,n)))}addDefaultValueCompletions(e,t,n=0){let s=!1;if(typeof e.default<"u"){let r=e.type,o=e.default;for(let a=n;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=n;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)&&n<5&&this.addDefaultValueCompletions(e.items,t,n+1)}addEnumValueCompletions(e,t){var n,s;if(typeof e.const<"u"&&t.add(Object.assign(Object.assign({type:(n=e.type)===null||n===void 0?void 0:n.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 n=e.type;Array.isArray(n)?n.forEach(s=>t[s]=!0):n&&(t[n]=!0)}getSchemas(e,t){var n,s;const r=new ru(this.schema);let o=xf(t.state,t.pos,-1,this.mode);const{data:l}=this.parser(t.state);let a=r.getSchema({pointer:o,data:l??void 0});return le.log("xxxx","draft.getSchema",a,"data",l,"pointer",o),Ba(a)&&(a=(n=a.data)===null||n===void 0?void 0:n.schema),(!a||a.name==="UnknownPropertyError"||a.enum||a.type==="undefined"||a.type==="null")&&(o=o.replace(/\/[^/]*$/,"/"),a=r.getSchema({pointer:o})),le.log("xxx","pointer..",JSON.stringify(o)),(!o||o==="/")&&(a=(s=this.expandSchemaProperty(e,e))!==null&&s!==void 0?s:e),le.log("xxx","subSchema..",a),a?Array.isArray(a.allOf)?[a,...a.allOf.map(f=>this.expandSchemaProperty(f,e))]:Array.isArray(a.oneOf)?[a,...a.oneOf.map(f=>this.expandSchemaProperty(f,e))]:Array.isArray(a.anyOf)?[a,...a.anyOf.map(f=>this.expandSchemaProperty(f,e))]:[a]:[]}expandSchemaProperty(e,t){if(typeof e=="object"&&e.$ref){const n=this.getReferenceSchema(t,e.$ref);if(typeof n=="object"){const s=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(s,"$ref"),s}}return e}getReferenceSchema(e,t){const n=t.split("/");let s=e;return n.forEach(r=>{if(r){if(r==="#"){s=e;return}typeof s=="object"&&(s=s[r])}}),s}getAppliedValue(e){const t=Tn(JSON.stringify(e));switch(this.mode){case ee.JSON5:return{label:t,apply:Eb(JSON.stringify(e))};case ee.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 bS(i={}){const e=new Nb(i);return function(n){return e.doComplete(n)}}const Hi=(i,e)=>{const t=i.length>2;let n=i.map((s,r)=>{const o="`"+(e?e(s):s)+"`";return r===i.length-1?"or "+o:o});return t?n.join(", "):n.join(" ")},Fb=i=>{var e,t,n;return!((e=i==null?void 0:i.data)===null||e===void 0)&&e.pointer&&((t=i==null?void 0:i.data)===null||t===void 0?void 0:t.pointer)!=="#"?i.data.pointer.slice(1):!((n=i==null?void 0:i.data)===null||n===void 0)&&n.property?`/${i.data.property}`:""},SS=i=>i.startState.field(Yn)!==i.state.field(Yn);function vS(i){const e=new Hb(i);return t=>e.doValidation(t)}const Vb=["NoAdditionalPropertiesError","RequiredPropertyError","InvalidPropertyNameError","ForbiddenPropertyError","UndefinedValueError"];class Hb{constructor(e){var t,n,s,r;this.options=e,this.schema=null,this.mode=ee.JSON,this.rewriteError=o=>{var l,a,f,c,p;const g=o==null?void 0:o.data,v=g==null?void 0:g.errors;return o.code==="one-of-error"&&(v!=null&&v.length)?`Expected one of ${Hi(v,C=>C.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)?Hi((f=o==null?void 0:o.data)===null||f===void 0?void 0:f.expected):(c=o==null?void 0:o.data)===null||c===void 0?void 0:c.expected}\` but received \`${(p=o==null?void 0:o.data)===null||p===void 0?void 0:p.received}\``:o.message.replaceAll("in `#` ","").replaceAll("at `#`","").replaceAll("/",".").replaceAll("#.","")},this.mode=(n=(t=this.options)===null||t===void 0?void 0:t.mode)!==null&&n!==void 0?n:ee.JSON,this.parser=(r=(s=this.options)===null||s===void 0?void 0:s.jsonParser)!==null&&r!==void 0?r:Cf(this.mode)}get schemaTitle(){var e,t,n;return(n=(t=(e=this.schema)===null||e===void 0?void 0:e.getSchema())===null||t===void 0?void 0:t.title)!==null&&n!==void 0?n:"json-schema"}doValidation(e){const t=yo(e.state);if(!t)return[];if(this.schema=new La(t),!this.schema)return[];const n=e.state.doc.toString();if(!(n!=null&&n.length))return[];const s=this.parser(e.state);let r=[];try{r=this.schema.validate(s.data)}catch{}return le.log("xxx","validation errors",r,s.data),r.length?r.reduce((o,l)=>{const a=()=>{const p=this.rewriteError(l);o.push({from:0,to:0,message:p,severity:"error",source:this.schemaTitle,renderMessage:()=>{const g=Ye("div",{});return g.innerHTML=qt(p),g}})},f=Fb(l),c=s.pointers.get(f);if(l.name==="MaxPropertiesError"||l.name==="MinPropertiesError")a();else if(c){const p=Vb.includes(l.name),g=this.rewriteError(l),v=p?c.keyFrom:c.valueFrom,k=p?c.keyTo:c.valueTo;k!==void 0&&v!==void 0&&o.push({from:v,to:k,message:g,renderMessage:()=>{const C=Ye("div",{});return C.innerHTML=qt(g),C},severity:"error",source:this.schemaTitle})}else a();return o},[]):[]}}function xS(i){const e=new $b(i);return async function(n,s,r){return e.doHover(n,s,r)}}function Sa(i){if(i.type)return i.$ref?`${i.$ref} (${i.type})`:i.type;if(i.$ref)return`${i.$ref}`}function Ys(i,e,t){return`${e}: ${Hi(i[e].map(n=>{try{const{data:s}=t.resolveRef({data:n,pointer:n.$ref});return Sa(s||n)}catch{return n.type}}))}`}class $b{constructor(e){var t,n;this.opts=e,this.schema=null,this.mode=ee.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=(n=(t=this.opts)===null||t===void 0?void 0:t.mode)!==null&&n!==void 0?n:ee.JSON}getDataForCursor(e,t,n){const s=yo(e.state);if(!s)return null;this.schema=new La(s);const r=xf(e.state,t,n,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 Ba(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:n}=e;return t?Ye("div",{class:"cm6-json-schema-hover"},[Ye("div",{class:"cm6-json-schema-hover--description",inner:qt(t,!1)}),Ye("div",{class:"cm6-json-schema-hover--code-wrapper"},[Ye("div",{class:"cm6-json-schema-hover--code",inner:qt(n,!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:qt(n,!1)})])])}getHoverTexts(e,t){let n="",s=null;const{schema:r}=e;return r.oneOf&&(n=Ys(r,"oneOf",t)),r.anyOf&&(n=Ys(r,"anyOf",t)),r.allOf&&(n=Ys(r,"allOf",t)),r.type&&(n=Array.isArray(r.type)?Hi(r.type):r.type),r.$ref&&(n=` Reference: ${r.$ref}`),r.enum&&(n=`\`enum\`: ${Hi(r.enum)}`),r.format&&(n+=`\`format\`: ${r.format}`),r.pattern&&(n+=`\`pattern\`: ${r.pattern}`),r.description&&(s=r.description),{message:s,typeInfo:n}}async doHover(e,t,n){var s,r,o,l;const a=t,f=t;try{const c=this.getDataForCursor(e,t,n);if(le.log("cursorData",c),!(c!=null&&c.schema))return null;const g=((r=(s=this.opts)===null||s===void 0?void 0:s.getHoverTexts)!==null&&r!==void 0?r:this.getHoverTexts)(c,this.schema),k=((l=(o=this.opts)===null||o===void 0?void 0:o.formatHover)!==null&&l!==void 0?l:this.formatMessage)(g);return{pos:a,end:f,arrow:!0,above:!0,create:C=>({dom:k})}}catch(c){return le.log(c),null}}}const va=new Ia,Af=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function bn(i){return(e,t,n)=>{if(n)return!1;let s=e.node.getChild("VariableName");return s&&t(s,i),!0}}const Wb={FunctionDefinition:bn("function"),ClassDefinition:bn("class"),ForStatement(i,e,t){if(t){for(let n=i.node.firstChild;n;n=n.nextSibling)if(n.name=="VariableName")e(n,"variable");else if(n.name=="in")break}},ImportStatement(i,e){var t,n;let{node:s}=i,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"&&((n=o.nextSibling)===null||n===void 0?void 0:n.name)!="as"&&e(o,r?"variable":"namespace")},AssignStatement(i,e){for(let t=i.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(i,e){for(let t=null,n=i.node.firstChild;n;n=n.nextSibling)n.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(n,"variable"),t=n},CapturePattern:bn("variable"),AsPattern:bn("variable"),__proto__:null};function Mf(i,e){let t=va.get(e);if(t)return t;let n=[],s=!0;function r(o,l){let a=i.sliceString(o.from,o.to);n.push({label:a,type:l})}return e.cursor(Gn.IncludeAnonymous).iterate(o=>{if(o.name){let l=Wb[o.name];if(l&&l(o,r,s)||!s&&Af.has(o.name))return!1;s=!1}else if(o.to-o.from>8192){for(let l of Mf(i,o.node))n.push(l);return!1}}),va.set(e,n),n}const xa=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Ef=["String","FormatString","Comment","PropertyName"];function zb(i){let e=ie(i.state).resolveInner(i.pos,-1);if(Ef.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&xa.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let s=e;s;s=s.parent)Af.has(s.name)&&(n=n.concat(Mf(i.state.doc,s)));return{options:n,from:t?e.from:i.pos,validFor:xa}}const qb=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(i=>({label:i,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(i=>({label:i,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(i=>({label:i,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(i=>({label:i,type:"function"}))),jb=[se("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),se("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),se("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),se("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),se(`if \${}:
12
12
 
13
13
  `,{label:"if",detail:"block",type:"keyword"}),se("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),se("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),se("import ${module}",{label:"import",detail:"statement",type:"keyword"}),se("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],_b=Zc(Ef,ao(qb.concat(jb)));function wa(i,e){let t=i.baseIndentFor(e),n=i.lineAt(i.pos,-1),s=n.from+n.text.length;return/^\s*($|#)/.test(n.text)&&i.node.to<s+100&&!/\S/.test(i.state.sliceDoc(s,i.node.to))&&i.lineIndent(i.pos,-1)<=t||/^\s*(else:|elif |except |finally:)/.test(i.textAfter)&&i.lineIndent(i.pos,-1)>t?null:t+i.unit}const Gs=Ut.define({name:"python",parser:ou.configure({props:[ts.add({Body:i=>{var e;return(e=wa(i,i.node))!==null&&e!==void 0?e:i.continue()},IfStatement:i=>/^\s*(else:|elif )/.test(i.textAfter)?i.baseIndent:i.continue(),TryStatement:i=>/^\s*(except |finally:|else:)/.test(i.textAfter)?i.baseIndent:i.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Mn({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Mn({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Mn({closing:"]"}),"String FormatString":()=>null,Script:i=>{if(i.pos+/\s*/.exec(i.textAfter)[0].length>=i.node.to){let e=null;for(let t=i.node,n=t.to;t=t.lastChild,!(!t||t.to!=n);)t.type.name=="Body"&&(e=t);if(e){let t=wa(i,e);if(t!=null)return t}}return i.continue()}}),is.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":Xr,Body:(i,e)=>({from:i.from+1,to:i.to-(i.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 wS(){return new Ur(Gs,[Gs.data.of({autocomplete:zb}),Gs.data.of({autocomplete:_b})])}const Tf=[se("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),se("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),se("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),se("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),se("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),se(`try {
14
14
  \${}