@paperkite/plugin-runtime-console 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/package.json +2 -2
  2. package/public/_app/immutable/assets/0.8e19Eas9.css +1 -0
  3. package/public/_app/immutable/chunks/0P6E5PgQ.js +1 -0
  4. package/public/_app/immutable/chunks/473aTmYL.js +1 -0
  5. package/public/_app/immutable/chunks/{DVEB1r5D.js → 8TLgZ-vL.js} +1 -1
  6. package/public/_app/immutable/chunks/AUu53b1K.js +2 -0
  7. package/public/_app/immutable/chunks/BKJ0Y2X2.js +1 -0
  8. package/public/_app/immutable/chunks/Bkcwen-N.js +1 -0
  9. package/public/_app/immutable/chunks/BwDU-fss.js +1 -0
  10. package/public/_app/immutable/chunks/{BpJGvxOD.js → C7x1AckM.js} +1 -1
  11. package/public/_app/immutable/chunks/{C1_V7OdN.js → CES7FAnl.js} +1 -1
  12. package/public/_app/immutable/chunks/CK68nzZP.js +1 -0
  13. package/public/_app/immutable/chunks/CTs8zH2A.js +1 -0
  14. package/public/_app/immutable/chunks/CVQRPBHI.js +1 -0
  15. package/public/_app/immutable/chunks/{-MWhb9c-.js → CYrhPW18.js} +1 -1
  16. package/public/_app/immutable/chunks/{B1VSXVja.js → CjpBsztx.js} +1 -1
  17. package/public/_app/immutable/chunks/CpCbeTkV.js +2 -0
  18. package/public/_app/immutable/chunks/D1JMNvQG.js +1 -0
  19. package/public/_app/immutable/chunks/{Dk_FALGi.js → D5ygbMy_.js} +1 -1
  20. package/public/_app/immutable/chunks/{JYomMW8A.js → DHgbx_fZ.js} +1 -1
  21. package/public/_app/immutable/chunks/{BM-d1iyU.js → DYakwjaq.js} +1 -1
  22. package/public/_app/immutable/chunks/{CBkgBsl2.js → Dk8UGBZ2.js} +1 -1
  23. package/public/_app/immutable/chunks/{u9x_yOz5.js → Dnszd-a_.js} +2 -2
  24. package/public/_app/immutable/chunks/KZaYLgoS.js +1 -0
  25. package/public/_app/immutable/chunks/NLo5Zh3E.js +1 -0
  26. package/public/_app/immutable/chunks/{D4TYZfw1.js → XK2XwNCE.js} +2 -2
  27. package/public/_app/immutable/chunks/{DwNr-XJb.js → Xaflb_xi.js} +1 -1
  28. package/public/_app/immutable/chunks/{BHsjJ8bF.js → bzYZcIpo.js} +1 -1
  29. package/public/_app/immutable/chunks/{DLXc3MsS.js → rz89OrhQ.js} +1 -1
  30. package/public/_app/immutable/chunks/{BKgPCz3n.js → vGOpwVvV.js} +1 -1
  31. package/public/_app/immutable/entry/{app.xGcxUCtq.js → app.BRhmEJql.js} +2 -2
  32. package/public/_app/immutable/entry/{start.BfgCqfOg.js → start.BkvLfThy.js} +1 -1
  33. package/public/_app/immutable/nodes/0.0pNZvtKd.js +1 -0
  34. package/public/_app/immutable/nodes/1.B81L6iLG.js +1 -0
  35. package/public/_app/immutable/nodes/2.osjLQP-7.js +1 -0
  36. package/public/_app/immutable/nodes/{3.Bkc35OBN.js → 3.5Qv8DQzq.js} +2 -2
  37. package/public/_app/immutable/nodes/4.C6R1dt1K.js +1 -0
  38. package/public/_app/immutable/nodes/5.DZHiidRm.js +2 -0
  39. package/public/_app/immutable/nodes/6.Dpfuh3uG.js +2 -0
  40. package/public/_app/immutable/nodes/7.DKyaWWa3.js +1 -0
  41. package/public/_app/immutable/nodes/8.De3ko3u7.js +1 -0
  42. package/public/_app/version.json +1 -1
  43. package/public/index.html +26 -25
  44. package/public/_app/immutable/assets/0.DtIwIIdd.css +0 -1
  45. package/public/_app/immutable/chunks/1mqgODEB.js +0 -1
  46. package/public/_app/immutable/chunks/4FxxAFXN.js +0 -1
  47. package/public/_app/immutable/chunks/B36KvkWl.js +0 -1
  48. package/public/_app/immutable/chunks/B8_hs9R4.js +0 -1
  49. package/public/_app/immutable/chunks/BkeJCmZR.js +0 -1
  50. package/public/_app/immutable/chunks/C1dm7snI.js +0 -2
  51. package/public/_app/immutable/chunks/C3IMQzMn.js +0 -1
  52. package/public/_app/immutable/chunks/C59Htmoo.js +0 -1
  53. package/public/_app/immutable/chunks/CXE75xOj.js +0 -1
  54. package/public/_app/immutable/chunks/Cl3lhUWL.js +0 -1
  55. package/public/_app/immutable/chunks/D3H57P1T.js +0 -1
  56. package/public/_app/immutable/chunks/DpIbH5kQ.js +0 -1
  57. package/public/_app/immutable/chunks/ywqHnl7S.js +0 -2
  58. package/public/_app/immutable/nodes/0.6NyaEHme.js +0 -1
  59. package/public/_app/immutable/nodes/1.BuZaC350.js +0 -1
  60. package/public/_app/immutable/nodes/2.B86h23eK.js +0 -1
  61. package/public/_app/immutable/nodes/4.DTipQFjn.js +0 -1
  62. package/public/_app/immutable/nodes/5.CcLKuLYX.js +0 -1
  63. package/public/_app/immutable/nodes/6.DPrxF31w.js +0 -2
  64. package/public/_app/immutable/nodes/7.HhYOLA1h.js +0 -1
  65. package/public/_app/immutable/nodes/8.b5y1XVkv.js +0 -1
@@ -1,4 +1,4 @@
1
- import{c as gn,a as te,d as ql,s as Vn,b as Fn,f as Zi}from"./ywqHnl7S.js";import{a as jl}from"./D3H57P1T.js";import{c as We,p as _l,b as Gl,g as q,a as ce,h as Ql,i as oi,k as zn,j as li,e as hi,D as Ul,r as ai,l as $n,B as Kn}from"./DLXc3MsS.js";import{l as oo,s as lo,p as Yl,i as hs}from"./B36KvkWl.js";import{I as ho,s as ao,b as qn,c as Xl}from"./C1dm7snI.js";import{b as Jl}from"./DwNr-XJb.js";import{c as Zl}from"./C3IMQzMn.js";import{C as th}from"./CBkgBsl2.js";function eh(r,t){const e=oo(t,["children","$$slots","$$events","$$legacy"]);const i=[["path",{d:"m9 18 6-6-6-6"}]];ho(r,lo({name:"chevron-right"},()=>e,{get iconNode(){return i},children:(s,n)=>{var o=gn(),l=We(o);ao(l,t,"default",{}),te(s,o)},$$slots:{default:!0}}))}function ih(r,t){const e=oo(t,["children","$$slots","$$events","$$legacy"]);const i=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];ho(r,lo({name:"copy"},()=>e,{get iconNode(){return i},children:(s,n)=>{var o=gn(),l=We(o);ao(l,t,"default",{}),te(s,o)},$$slots:{default:!0}}))}let Bs=[],fo=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<r.length;t++)(t%2?fo:Bs).push(e=e+r[t])})();function sh(r){if(r<768)return!1;for(let t=0,e=Bs.length;;){let i=t+e>>1;if(r<Bs[i])e=i;else if(r>=fo[i])t=i+1;else return!0;if(t==e)return!1}}function jn(r){return r>=127462&&r<=127487}const _n=8205;function nh(r,t,e=!0,i=!0){return(e?co:rh)(r,t,i)}function co(r,t,e){if(t==r.length)return t;t&&uo(r.charCodeAt(t))&&po(r.charCodeAt(t-1))&&t--;let i=as(r,t);for(t+=Gn(i);t<r.length;){let s=as(r,t);if(i==_n||s==_n||e&&sh(s))t+=Gn(s),i=s;else if(jn(s)){let n=0,o=t-2;for(;o>=0&&jn(as(r,o));)n++,o-=2;if(n%2==0)break;t+=2}else break}return t}function rh(r,t,e){for(;t>1;){let i=co(r,t-2,e);if(i<t)return i;t--}return 0}function as(r,t){let e=r.charCodeAt(t);if(!po(e)||t+1==r.length)return e;let i=r.charCodeAt(t+1);return uo(i)?(e-55296<<10)+(i-56320)+65536:e}function uo(r){return r>=56320&&r<57344}function po(r){return r>=55296&&r<56320}function Gn(r){return r<65536?1:2}class W{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Se(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(e,this.length,s,1),Mt.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Se(this,t,e);let i=[];return this.decompose(t,e,i,0),Mt.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),s=new He(this),n=new He(t);for(let o=e,l=e;;){if(s.next(o),n.next(o),o=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(t=1){return new He(this,t)}iterRange(t,e=this.length){return new go(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let s=this.line(t).from;i=this.iterRange(s,Math.max(s,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new mo(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?W.empty:t.length<=32?new Q(t):Mt.from(Q.split(t,[]))}}class Q extends W{constructor(t,e=oh(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,s){for(let n=0;;n++){let o=this.text[n],l=s+o.length;if((e?i:l)>=t)return new lh(s,l,i,o);s=l+1,i++}}decompose(t,e,i,s){let n=t<=0&&e>=this.length?this:new Q(Qn(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(s&1){let o=i.pop(),l=Di(n.text,o.text.slice(),0,n.length);if(l.length<=32)i.push(new Q(l,o.length+n.length));else{let h=l.length>>1;i.push(new Q(l.slice(0,h)),new Q(l.slice(h)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof Q))return super.replace(t,e,i);[t,e]=Se(this,t,e);let s=Di(this.text,Di(i.text,Qn(this.text,0,t)),e),n=this.length+i.length-(e-t);return s.length<=32?new Q(s,n):Mt.from(Q.split(s,[]),n)}sliceString(t,e=this.length,i=`
1
+ import{c as gn,a as te,d as ql,s as Vn,b as Fn,f as Zi}from"./CpCbeTkV.js";import{a as jl}from"./BKJ0Y2X2.js";import{c as We,p as _l,b as Gl,g as q,a as ce,h as Ql,i as oi,k as zn,j as li,e as hi,D as Ul,r as ai,l as $n,B as Kn}from"./rz89OrhQ.js";import{l as oo,s as lo,p as Yl,i as hs}from"./BwDU-fss.js";import{I as ho,s as ao,o as Xl,b as qn,c as Jl}from"./AUu53b1K.js";import{b as Zl}from"./Xaflb_xi.js";import{C as th}from"./Dk8UGBZ2.js";function eh(r,t){const e=oo(t,["children","$$slots","$$events","$$legacy"]);const i=[["path",{d:"m9 18 6-6-6-6"}]];ho(r,lo({name:"chevron-right"},()=>e,{get iconNode(){return i},children:(s,n)=>{var o=gn(),l=We(o);ao(l,t,"default",{}),te(s,o)},$$slots:{default:!0}}))}function ih(r,t){const e=oo(t,["children","$$slots","$$events","$$legacy"]);const i=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];ho(r,lo({name:"copy"},()=>e,{get iconNode(){return i},children:(s,n)=>{var o=gn(),l=We(o);ao(l,t,"default",{}),te(s,o)},$$slots:{default:!0}}))}let Bs=[],fo=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<r.length;t++)(t%2?fo:Bs).push(e=e+r[t])})();function sh(r){if(r<768)return!1;for(let t=0,e=Bs.length;;){let i=t+e>>1;if(r<Bs[i])e=i;else if(r>=fo[i])t=i+1;else return!0;if(t==e)return!1}}function jn(r){return r>=127462&&r<=127487}const _n=8205;function nh(r,t,e=!0,i=!0){return(e?co:rh)(r,t,i)}function co(r,t,e){if(t==r.length)return t;t&&uo(r.charCodeAt(t))&&po(r.charCodeAt(t-1))&&t--;let i=as(r,t);for(t+=Gn(i);t<r.length;){let s=as(r,t);if(i==_n||s==_n||e&&sh(s))t+=Gn(s),i=s;else if(jn(s)){let n=0,o=t-2;for(;o>=0&&jn(as(r,o));)n++,o-=2;if(n%2==0)break;t+=2}else break}return t}function rh(r,t,e){for(;t>1;){let i=co(r,t-2,e);if(i<t)return i;t--}return 0}function as(r,t){let e=r.charCodeAt(t);if(!po(e)||t+1==r.length)return e;let i=r.charCodeAt(t+1);return uo(i)?(e-55296<<10)+(i-56320)+65536:e}function uo(r){return r>=56320&&r<57344}function po(r){return r>=55296&&r<56320}function Gn(r){return r<65536?1:2}class W{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Se(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(e,this.length,s,1),Mt.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Se(this,t,e);let i=[];return this.decompose(t,e,i,0),Mt.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),s=new He(this),n=new He(t);for(let o=e,l=e;;){if(s.next(o),n.next(o),o=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(t=1){return new He(this,t)}iterRange(t,e=this.length){return new go(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let s=this.line(t).from;i=this.iterRange(s,Math.max(s,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new mo(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?W.empty:t.length<=32?new Q(t):Mt.from(Q.split(t,[]))}}class Q extends W{constructor(t,e=oh(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,s){for(let n=0;;n++){let o=this.text[n],l=s+o.length;if((e?i:l)>=t)return new lh(s,l,i,o);s=l+1,i++}}decompose(t,e,i,s){let n=t<=0&&e>=this.length?this:new Q(Qn(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(s&1){let o=i.pop(),l=Di(n.text,o.text.slice(),0,n.length);if(l.length<=32)i.push(new Q(l,o.length+n.length));else{let h=l.length>>1;i.push(new Q(l.slice(0,h)),new Q(l.slice(h)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof Q))return super.replace(t,e,i);[t,e]=Se(this,t,e);let s=Di(this.text,Di(i.text,Qn(this.text,0,t)),e),n=this.length+i.length-(e-t);return s.length<=32?new Q(s,n):Mt.from(Q.split(s,[]),n)}sliceString(t,e=this.length,i=`
2
2
  `){[t,e]=Se(this,t,e);let s="";for(let n=0,o=0;n<=e&&o<this.text.length;o++){let l=this.text[o],h=n+l.length;n>t&&o&&(s+=i),t<h&&e>n&&(s+=l.slice(Math.max(0,t-n),e-n)),n=h+1}return s}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],s=-1;for(let n of t)i.push(n),s+=n.length+1,i.length==32&&(e.push(new Q(i,s)),i=[],s=-1);return s>-1&&e.push(new Q(i,s)),e}}class Mt extends W{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,s){for(let n=0;;n++){let o=this.children[n],l=s+o.length,h=i+o.lines-1;if((e?h:l)>=t)return o.lineInner(t,e,i,s);s=l+1,i=h+1}}decompose(t,e,i,s){for(let n=0,o=0;o<=e&&n<this.children.length;n++){let l=this.children[n],h=o+l.length;if(t<=h&&e>=o){let a=s&((o<=t?1:0)|(h>=e?2:0));o>=t&&h<=e&&!a?i.push(l):l.decompose(t-o,e-o,i,a)}o=h+1}}replace(t,e,i){if([t,e]=Se(this,t,e),i.lines<this.lines)for(let s=0,n=0;s<this.children.length;s++){let o=this.children[s],l=n+o.length;if(t>=n&&e<=l){let h=o.replace(t-n,e-n,i),a=this.lines-o.lines+h.lines;if(h.lines<a>>4&&h.lines>a>>6){let f=this.children.slice();return f[s]=h,new Mt(f,this.length-(e-t)+i.length)}return super.replace(n,l,h)}n=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
3
3
  `){[t,e]=Se(this,t,e);let s="";for(let n=0,o=0;n<this.children.length&&o<=e;n++){let l=this.children[n],h=o+l.length;o>t&&n&&(s+=i),t<h&&e>o&&(s+=l.sliceString(t-o,e-o,i)),o=h+1}return s}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Mt))return 0;let i=0,[s,n,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,n+=e){if(s==o||n==l)return i;let h=this.children[s],a=t.children[n];if(h!=a)return i+h.scanIdentical(a,e);i+=h.length+1}}static from(t,e=t.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let d=[];for(let p of t)p.flatten(d);return new Q(d,e)}let s=Math.max(32,i>>5),n=s<<1,o=s>>1,l=[],h=0,a=-1,f=[];function c(d){let p;if(d.lines>n&&d instanceof Mt)for(let g of d.children)c(g);else d.lines>o&&(h>o||!h)?(u(),l.push(d)):d instanceof Q&&h&&(p=f[f.length-1])instanceof Q&&d.lines+p.lines<=32?(h+=d.lines,a+=d.length+1,f[f.length-1]=new Q(p.text.concat(d.text),p.length+1+d.length)):(h+d.lines>s&&u(),h+=d.lines,a+=d.length+1,f.push(d))}function u(){h!=0&&(l.push(f.length==1?f[0]:Mt.from(f,a)),a=-1,h=f.length=0)}for(let d of t)c(d);return u(),l.length==1?l[0]:new Mt(l,e)}}W.empty=new Q([""],0);function oh(r){let t=-1;for(let e of r)t+=e.length+1;return t}function Di(r,t,e=0,i=1e9){for(let s=0,n=0,o=!0;n<r.length&&s<=i;n++){let l=r[n],h=s+l.length;h>=e&&(h>i&&(l=l.slice(0,i-s)),s<e&&(l=l.slice(e-s)),o?(t[t.length-1]+=l,o=!1):t.push(l)),s=h+1}return t}function Qn(r,t,e){return Di(r,[""],t,e)}class He{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof Q?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],n=this.offsets[i],o=n>>1,l=s instanceof Q?s.text.length:s.children.length;if(o==(e>0?l:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;t--}else if(s instanceof Q){let h=s.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,h.length>Math.max(0,t))return this.value=t==0?h:e>0?h.slice(t):h.slice(0,h.length-t),this;t-=h.length}else{let h=s.children[o+(e<0?-1:0)];t>h.length?(t-=h.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(h),this.offsets.push(e>0?1:(h instanceof Q?h.text.length:h.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class go{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new He(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:s}=this.cursor.next(t);return this.pos+=(s.length+t)*e,this.value=s.length<=i?s:e<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class mo{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:s}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(W.prototype[Symbol.iterator]=function(){return this.iter()},He.prototype[Symbol.iterator]=go.prototype[Symbol.iterator]=mo.prototype[Symbol.iterator]=function(){return this});class lh{constructor(t,e,i,s){this.from=t,this.to=e,this.number=i,this.text=s}get length(){return this.to-this.from}}function Se(r,t,e){return t=Math.max(0,Math.min(r.length,t)),[t,Math.max(t,Math.min(r.length,e))]}function wt(r,t,e=!0,i=!0){return nh(r,t,e,i)}function hh(r){return r>=56320&&r<57344}function ah(r){return r>=55296&&r<56320}function fh(r,t){let e=r.charCodeAt(t);if(!ah(e)||t+1==r.length)return e;let i=r.charCodeAt(t+1);return hh(i)?(e-55296<<10)+(i-56320)+65536:e}function ch(r){return r<65536?1:2}const Rs=/\r\n?|\n/;var ot=(function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r})(ot||(ot={}));class It{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,s=0;e<this.sections.length;){let n=this.sections[e++],o=this.sections[e++];o<0?(t(i,s,n),s+=n):s+=o,i+=n}}iterChangedRanges(t,e=!1){Es(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];s<0?t.push(i,s):t.push(s,i)}return new It(t)}composeDesc(t){return this.empty?t:t.empty?this:bo(this,t)}mapDesc(t,e=!1){return t.empty?this:Ns(this,t,e)}mapPos(t,e=-1,i=ot.Simple){let s=0,n=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],h=this.sections[o++],a=s+l;if(h<0){if(a>t)return n+(t-s);n+=l}else{if(i!=ot.Simple&&a>=t&&(i==ot.TrackDel&&s<t&&a>t||i==ot.TrackBefore&&s<t||i==ot.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!l)return t==s||e<0?n:n+h;n+=h}s=a}if(t>s)throw new RangeError(`Position ${t} is out of range for changeset of length ${s}`);return n}touchesRange(t,e=t){for(let i=0,s=0;i<this.sections.length&&s<=e;){let n=this.sections[i++],o=this.sections[i++],l=s+n;if(o>=0&&s<=e&&l>=t)return s<t&&l>e?"cover":!0;s=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];t+=(t?" ":"")+i+(s>=0?":"+s:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new It(t)}static create(t){return new It(t)}}class X extends It{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Es(this,(e,i,s,n,o)=>t=t.replace(s,s+(i-e),o),!1),t}mapDesc(t,e=!1){return Ns(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,n=0;s<e.length;s+=2){let o=e[s],l=e[s+1];if(l>=0){e[s]=l,e[s+1]=o;let h=s>>1;for(;i.length<h;)i.push(W.empty);i.push(o?t.slice(n,n+o):W.empty)}n+=o}return new X(e,i)}compose(t){return this.empty?t:t.empty?this:bo(this,t,!0)}map(t,e=!1){return t.empty?this:Ns(this,t,e,!0)}iterChanges(t,e=!1){Es(this,t,e)}get desc(){return It.create(this.sections)}filter(t){let e=[],i=[],s=[],n=new je(this);t:for(let o=0,l=0;;){let h=o==t.length?1e9:t[o++];for(;l<h||l==h&&n.len==0;){if(n.done)break t;let f=Math.min(n.len,h-l);et(s,f,-1);let c=n.ins==-1?-1:n.off==0?n.ins:0;et(e,f,c),c>0&&Kt(i,e,n.text),n.forward(f),l+=f}let a=t[o++];for(;l<a;){if(n.done)break t;let f=Math.min(n.len,a-l);et(e,f,-1),et(s,f,n.ins==-1?-1:n.off==0?n.ins:0),n.forward(f),l+=f}}return{changes:new X(e,i),filtered:It.create(s)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],s=this.sections[e+1];s<0?t.push(i):s==0?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],n=[],o=0,l=null;function h(f=!1){if(!f&&!s.length)return;o<e&&et(s,e-o,-1);let c=new X(s,n);l=l?l.compose(c.map(l)):c,s=[],n=[],o=0}function a(f){if(Array.isArray(f))for(let c of f)a(c);else if(f instanceof X){if(f.length!=e)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${e})`);h(),l=l?l.compose(f.map(l)):f}else{let{from:c,to:u=c,insert:d}=f;if(c>u||c<0||u>e)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${e})`);let p=d?typeof d=="string"?W.of(d.split(i||Rs)):d:W.empty,g=p.length;if(c==u&&g==0)return;c<o&&h(),c>o&&et(s,c-o,-1),et(s,u-c,g),Kt(n,s,p),o=u}}return a(t),h(!l),l}static empty(t){return new X(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let n=t[s];if(typeof n=="number")e.push(n,-1);else{if(!Array.isArray(n)||typeof n[0]!="number"||n.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(n.length==1)e.push(n[0],0);else{for(;i.length<s;)i.push(W.empty);i[s]=W.of(n.slice(1)),e.push(n[0],i[s].length)}}}return new X(e,i)}static createSet(t,e){return new X(t,e)}}function et(r,t,e,i=!1){if(t==0&&e<=0)return;let s=r.length-2;s>=0&&e<=0&&e==r[s+1]?r[s]+=t:s>=0&&t==0&&r[s]==0?r[s+1]+=e:i?(r[s]+=t,r[s+1]+=e):r.push(t,e)}function Kt(r,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(e);else{for(;r.length<i;)r.push(W.empty);r.push(e)}}function Es(r,t,e){let i=r.inserted;for(let s=0,n=0,o=0;o<r.sections.length;){let l=r.sections[o++],h=r.sections[o++];if(h<0)s+=l,n+=l;else{let a=s,f=n,c=W.empty;for(;a+=l,f+=h,h&&i&&(c=c.append(i[o-2>>1])),!(e||o==r.sections.length||r.sections[o+1]<0);)l=r.sections[o++],h=r.sections[o++];t(s,a,n,f,c),s=a,n=f}}}function Ns(r,t,e,i=!1){let s=[],n=i?[]:null,o=new je(r),l=new je(t);for(let h=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let a=Math.min(o.len,l.len);et(s,a,-1),o.forward(a),l.forward(a)}else if(l.ins>=0&&(o.ins<0||h==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!e))){let a=l.len;for(et(s,l.ins,-1);a;){let f=Math.min(o.len,a);o.ins>=0&&h<o.i&&o.len<=f&&(et(s,0,o.ins),n&&Kt(n,s,o.text),h=o.i),o.forward(f),a-=f}l.next()}else if(o.ins>=0){let a=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);a+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;et(s,a,h<o.i?o.ins:0),n&&h<o.i&&Kt(n,s,o.text),h=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return n?X.createSet(s,n):It.create(s);throw new Error("Mismatched change set lengths")}}}function bo(r,t,e=!1){let i=[],s=e?[]:null,n=new je(r),o=new je(t);for(let l=!1;;){if(n.done&&o.done)return s?X.createSet(i,s):It.create(i);if(n.ins==0)et(i,n.len,0,l),n.next();else if(o.len==0&&!o.done)et(i,0,o.ins,l),s&&Kt(s,i,o.text),o.next();else{if(n.done||o.done)throw new Error("Mismatched change set lengths");{let h=Math.min(n.len2,o.len),a=i.length;if(n.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;et(i,h,f,l),s&&f&&Kt(s,i,o.text)}else o.ins==-1?(et(i,n.off?0:n.len,h,l),s&&Kt(s,i,n.textBit(h))):(et(i,n.off?0:n.len,o.off?0:o.ins,l),s&&!o.off&&Kt(s,i,o.text));l=(n.ins>h||o.ins>=0&&o.len>h)&&(l||i.length>a),n.forward2(h),o.forward(h)}}}}class je{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?W.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?W.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class zt{constructor(t,e,i,s){this.from=t,this.to=e,this.flags=i,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}map(t,e=-1){let i,s;return this.empty?i=s=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),s=t.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new zt(i,s,this.flags,this.goalColumn)}extend(t,e=t,i=0){if(t<=this.anchor&&e>=this.anchor)return S.range(t,e,void 0,void 0,i);let s=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return S.range(this.anchor,s,void 0,void 0,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return S.range(t.anchor,t.head)}static create(t,e,i,s){return new zt(t,e,i,s)}}class S{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:S.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new S([this.main],0)}addRange(t,e=!0){return S.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,S.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new S(t.ranges.map(e=>zt.fromJSON(e)),t.main)}static single(t,e=t){return new S([S.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<t.length;s++){let n=t[s];if(n.empty?n.from<=i:n.from<i)return S.normalized(t.slice(),e);i=n.to}return new S(t,e)}static cursor(t,e=0,i,s){return zt.create(t,t,(e==0?0:e<0?8:16)|(i==null?7:Math.min(6,i)),s)}static range(t,e,i,s,n){let o=s==null?7:Math.min(6,s);return!n&&t!=e&&(n=e<t?1:-1),n&&(o|=n<0?8:16),e<t?zt.create(e,t,o|32,i):zt.create(t,e,o,i)}static undirectionalRange(t,e){return zt.create(t,e,64,void 0)}static normalized(t,e=0){let i=t[e];t.sort((s,n)=>s.from-n.from),e=t.indexOf(i);for(let s=1;s<t.length;s++){let n=t[s],o=t[s-1];if(n.empty?n.from<=o.to:n.from<o.to){let l=o.from,h=Math.max(n.to,o.to);s<=e&&e--,t.splice(--s,2,n.anchor>n.head?S.range(h,l):S.range(l,h))}}return new S(t,e)}}function wo(r,t){for(let e of r.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let mn=0;class A{constructor(t,e,i,s,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=s,this.id=mn++,this.default=t([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(t={}){return new A(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:bn),!!t.static,t.enables)}of(t){return new Bi([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}}function bn(r,t){return r==t||r.length==t.length&&r.every((e,i)=>e===t[i])}class Bi{constructor(t,e,i,s){this.dependencies=t,this.facet=e,this.type=i,this.value=s,this.id=mn++}dynamicSlot(t){var e;let i=this.value,s=this.facet.compareInput,n=this.id,o=t[n]>>1,l=this.type==2,h=!1,a=!1,f=[];for(let c of this.dependencies)c=="doc"?h=!0:c=="selection"?a=!0:(((e=t[c.id])!==null&&e!==void 0?e:1)&1)==0&&f.push(t[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(h&&u.docChanged||a&&(u.docChanged||u.selection)||Is(c,f)){let d=i(c);if(l?!Un(d,c.values[o],s):!s(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[n];if(p!=null){let g=Wi(u,p);if(this.dependencies.every(m=>m instanceof A?u.facet(m)===c.facet(m):m instanceof Ut?u.field(m,!1)==c.field(m,!1):!0)||(l?Un(d=i(c),g,s):s(d=i(c),g)))return c.values[o]=g,0}else d=i(c);return c.values[o]=d,1}}}get extension(){return this}}function Un(r,t,e){if(r.length!=t.length)return!1;for(let i=0;i<r.length;i++)if(!e(r[i],t[i]))return!1;return!0}function Is(r,t){let e=!1;for(let i of t)Ve(r,i)&1&&(e=!0);return e}function uh(r,t,e){let i=e.map(h=>r[h.id]),s=e.map(h=>h.type),n=i.filter(h=>!(h&1)),o=r[t.id]>>1;function l(h){let a=[];for(let f=0;f<i.length;f++){let c=Wi(h,i[f]);if(s[f]==2)for(let u of c)a.push(u);else a.push(c)}return t.combine(a)}return{create(h){for(let a of i)Ve(h,a);return h.values[o]=l(h),1},update(h,a){if(!Is(h,n))return 0;let f=l(h);return t.compare(f,h.values[o])?0:(h.values[o]=f,1)},reconfigure(h,a){let f=Is(h,i),c=a.config.facets[t.id],u=a.facet(t);if(c&&!f&&bn(e,c))return h.values[o]=u,0;let d=l(h);return t.compare(d,u)?(h.values[o]=u,0):(h.values[o]=d,1)}}}const fi=A.define({static:!0});class Ut{constructor(t,e,i,s,n){this.id=t,this.createF=e,this.updateF=i,this.compareF=s,this.spec=n,this.provides=void 0}static define(t){let e=new Ut(mn++,t.create,t.update,t.compare||((i,s)=>i===s),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(fi).find(i=>i.field==this);return(e?.create||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,s)=>{let n=i.values[e],o=this.updateF(n,s);return this.compareF(n,o)?0:(i.values[e]=o,1)},reconfigure:(i,s)=>{let n=i.facet(fi),o=s.facet(fi),l;return(l=n.find(h=>h.field==this))&&l!=o.find(h=>h.field==this)?(i.values[e]=l.create(i),1):s.config.address[this.id]!=null?(i.values[e]=s.field(this),0):(i.values[e]=this.create(i),1)}}}init(t){return[this,fi.of({field:this,create:t})]}get extension(){return this}}const ee={lowest:4,low:3,default:2,high:1,highest:0};function Be(r){return t=>new yo(t,r)}const wn={highest:Be(ee.highest),high:Be(ee.high),default:Be(ee.default),low:Be(ee.low),lowest:Be(ee.lowest)};class yo{constructor(t,e){this.inner=t,this.prec=e}get extension(){return this}}class ts{of(t){return new Ls(this,t)}reconfigure(t){return ts.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Ls{constructor(t,e){this.compartment=t,this.inner=e}get extension(){return this}}class Li{constructor(t,e,i,s,n,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=s,this.staticValues=n,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let s=[],n=Object.create(null),o=new Map;for(let u of dh(t,e,o))u instanceof Ut?s.push(u):(n[u.facet.id]||(n[u.facet.id]=[])).push(u);let l=Object.create(null),h=[],a=[];for(let u of s)l[u.id]=a.length<<1,a.push(d=>u.slot(d));let f=i?.config.facets;for(let u in n){let d=n[u],p=d[0].facet,g=f&&f[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=h.length<<1|1,bn(g,d))h.push(i.facet(p));else{let m=p.combine(d.map(b=>b.value));h.push(i&&p.compare(m,i.facet(p))?i.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=h.length<<1|1,h.push(m.value)):(l[m.id]=a.length<<1,a.push(b=>m.dynamicSlot(b)));l[p.id]=a.length<<1,a.push(m=>uh(m,p,d))}}let c=a.map(u=>u(l));return new Li(t,o,c,l,h,n)}}function dh(r,t,e){let i=[[],[],[],[],[]],s=new Map;function n(o,l){let h=s.get(o);if(h!=null){if(h<=l)return;let a=i[h].indexOf(o);a>-1&&i[h].splice(a,1),o instanceof Ls&&e.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let a of o)n(a,l);else if(o instanceof Ls){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let a=t.get(o.compartment)||o.inner;e.set(o.compartment,a),n(a,l)}else if(o instanceof yo)n(o.inner,o.prec);else if(o instanceof Ut)i[l].push(o),o.provides&&n(o.provides,l);else if(o instanceof Bi)i[l].push(o),o.facet.extensions&&n(o.facet.extensions,ee.default);else{let a=o.extension;if(!a)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(a==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(a,l)}}return n(r,ee.default),i.reduce((o,l)=>o.concat(l))}function Ve(r,t){if(t&1)return 2;let e=t>>1,i=r.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[e]=4;let s=r.computeSlot(r,r.config.dynamicSlots[e]);return r.status[e]=2|s}function Wi(r,t){return t&1?r.config.staticValues[t>>1]:r.values[t>>1]}const xo=A.define(),Ws=A.define({combine:r=>r.some(t=>t),static:!0}),vo=A.define({combine:r=>r.length?r[0]:void 0,static:!0}),ko=A.define(),So=A.define(),Co=A.define(),Ao=A.define({combine:r=>r.length?r[0]:!1});class Pe{constructor(t,e){this.type=t,this.value=e}static define(){return new ph}}class ph{of(t){return new Pe(this,t)}}class gh{constructor(t){this.map=t}of(t){return new U(this,t)}}class U{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new U(this.type,e)}is(t){return this.type==t}static define(t={}){return new gh(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let s of t){let n=s.map(e);n&&i.push(n)}return i}}U.reconfigure=U.define();U.appendConfig=U.define();class it{constructor(t,e,i,s,n,o){this.startState=t,this.changes=e,this.selection=i,this.effects=s,this.annotations=n,this.scrollIntoView=o,this._doc=null,this._state=null,i&&wo(i,e.newLength),n.some(l=>l.type==it.time)||(this.annotations=n.concat(it.time.of(Date.now())))}static create(t,e,i,s,n,o){return new it(t,e,i,s,n,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(it.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}it.time=Pe.define();it.userEvent=Pe.define();it.addToHistory=Pe.define();it.remote=Pe.define();function mh(r,t){let e=[];for(let i=0,s=0;;){let n,o;if(i<r.length&&(s==t.length||t[s]>=r[i]))n=r[i++],o=r[i++];else if(s<t.length)n=t[s++],o=t[s++];else return e;!e.length||e[e.length-1]<n?e.push(n,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function Oo(r,t,e){var i;let s,n,o;return e?(s=t.changes,n=X.empty(t.changes.length),o=r.changes.compose(t.changes)):(s=t.changes.map(r.changes),n=r.changes.mapDesc(t.changes,!0),o=r.changes.compose(s)),{changes:o,selection:t.selection?t.selection.map(n):(i=r.selection)===null||i===void 0?void 0:i.map(s),effects:U.mapEffects(r.effects,s).concat(U.mapEffects(t.effects,n)),annotations:r.annotations.length?r.annotations.concat(t.annotations):t.annotations,scrollIntoView:r.scrollIntoView||t.scrollIntoView}}function Hs(r,t,e){let i=t.selection,s=be(t.annotations);return t.userEvent&&(s=s.concat(it.userEvent.of(t.userEvent))),{changes:t.changes instanceof X?t.changes:X.of(t.changes||[],e,r.facet(vo)),selection:i&&(i instanceof S?i:S.single(i.anchor,i.head)),effects:be(t.effects),annotations:s,scrollIntoView:!!t.scrollIntoView}}function To(r,t,e){let i=Hs(r,t.length?t[0]:{},r.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let n=1;n<t.length;n++){t[n].filter===!1&&(e=!1);let o=!!t[n].sequential;i=Oo(i,Hs(r,t[n],o?i.changes.newLength:r.doc.length),o)}let s=it.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return wh(e?bh(s):s)}function bh(r){let t=r.startState,e=!0;for(let s of t.facet(ko)){let n=s(r);if(n===!1){e=!1;break}Array.isArray(n)&&(e=e===!0?n:mh(e,n))}if(e!==!0){let s,n;if(e===!1)n=r.changes.invertedDesc,s=X.empty(t.doc.length);else{let o=r.changes.filter(e);s=o.changes,n=o.filtered.mapDesc(o.changes).invertedDesc}r=it.create(t,s,r.selection&&r.selection.map(n),U.mapEffects(r.effects,n),r.annotations,r.scrollIntoView)}let i=t.facet(So);for(let s=i.length-1;s>=0;s--){let n=i[s](r);n instanceof it?r=n:Array.isArray(n)&&n.length==1&&n[0]instanceof it?r=n[0]:r=To(t,be(n),!1)}return r}function wh(r){let t=r.startState,e=t.facet(Co),i=r;for(let s=e.length-1;s>=0;s--){let n=e[s](r);n&&Object.keys(n).length&&(i=Oo(i,Hs(t,n,r.changes.newLength),!0))}return i==r?r:it.create(t,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const yh=[];function be(r){return r==null?yh:Array.isArray(r)?r:[r]}var Nt=(function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r})(Nt||(Nt={}));const xh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Vs;try{Vs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function vh(r){if(Vs)return Vs.test(r);for(let t=0;t<r.length;t++){let e=r[t];if(/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||xh.test(e)))return!0}return!1}function kh(r){return t=>{if(!/\S/.test(t))return Nt.Space;if(vh(t))return Nt.Word;for(let e=0;e<r.length;e++)if(t.indexOf(r[e])>-1)return Nt.Word;return Nt.Other}}class L{constructor(t,e,i,s,n,o){this.config=t,this.doc=e,this.selection=i,this.values=s,this.status=t.statusTemplate.slice(),this.computeSlot=n,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ve(this,l<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(i==null){if(e)throw new RangeError("Field is not present in this state");return}return Ve(this,i),Wi(this,i)}update(...t){return To(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:s}=e;for(let l of t.effects)l.is(ts.reconfigure)?(e&&(s=new Map,e.compartments.forEach((h,a)=>s.set(a,h)),e=null),s.set(l.value.compartment,l.value.extension)):l.is(U.reconfigure)?(e=null,i=l.value):l.is(U.appendConfig)&&(e=null,i=be(i).concat(l.value));let n;e?n=t.startState.values.slice():(e=Li.resolve(i,s,this),n=new L(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(h,a)=>a.reconfigure(h,this),null).values);let o=t.startState.facet(Ws)?t.newSelection:t.newSelection.asSingle();new L(e,t.newDoc,o,n,(l,h)=>h.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:S.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),s=this.changes(i.changes),n=[i.range],o=be(i.effects);for(let l=1;l<e.ranges.length;l++){let h=t(e.ranges[l]),a=this.changes(h.changes),f=a.map(s);for(let u=0;u<l;u++)n[u]=n[u].map(f);let c=s.mapDesc(a,!0);n.push(h.range.map(c)),s=s.compose(f),o=U.mapEffects(o,f).concat(U.mapEffects(be(h.effects),c))}return{changes:s,selection:S.create(n,e.mainIndex),effects:o}}changes(t=[]){return t instanceof X?t:X.of(t,this.doc.length,this.facet(L.lineSeparator))}toText(t){return W.of(t.split(this.facet(L.lineSeparator)||Rs))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(Ve(this,e),Wi(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let s=t[i];s instanceof Ut&&this.config.address[s.id]!=null&&(e[i]=s.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let n in i)if(Object.prototype.hasOwnProperty.call(t,n)){let o=i[n],l=t[n];s.push(o.init(h=>o.spec.fromJSON(l,h)))}}return L.create({doc:t.doc,selection:S.fromJSON(t.selection),extensions:e.extensions?s.concat([e.extensions]):s})}static create(t={}){let e=Li.resolve(t.extensions||[],new Map),i=t.doc instanceof W?t.doc:W.of((t.doc||"").split(e.staticFacet(L.lineSeparator)||Rs)),s=t.selection?t.selection instanceof S?t.selection:S.single(t.selection.anchor,t.selection.head):S.single(0);return wo(s,i.length),e.staticFacet(Ws)||(s=s.asSingle()),new L(e,i,s,e.dynamicSlots.map(()=>null),(n,o)=>o.create(n),null)}get tabSize(){return this.facet(L.tabSize)}get lineBreak(){return this.facet(L.lineSeparator)||`
@@ -7,4 +7,4 @@ import{c as gn,a as te,d as ql,s as Vn,b as Fn,f as Zi}from"./ywqHnl7S.js";impor
7
7
  `;this.styleTag.textContent=o;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var _t={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ge={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Th=typeof navigator<"u"&&/Mac/.test(navigator.platform),Mh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var tt=0;tt<10;tt++)_t[48+tt]=_t[96+tt]=String(tt);for(var tt=1;tt<=24;tt++)_t[tt+111]="F"+tt;for(var tt=65;tt<=90;tt++)_t[tt]=String.fromCharCode(tt+32),Ge[tt]=String.fromCharCode(tt);for(var cs in _t)Ge.hasOwnProperty(cs)||(Ge[cs]=_t[cs]);function Ph(r){var t=Th&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Mh&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",e=!t&&r.key||(r.shiftKey?Ge:_t)[r.keyCode]||r.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}let st=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},js=typeof document<"u"?document:{documentElement:{style:{}}};const _s=/Edge\/(\d+)/.exec(st.userAgent),Bo=/MSIE \d/.test(st.userAgent),Gs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(st.userAgent),es=!!(Bo||Gs||_s),ir=!es&&/gecko\/(\d+)/i.test(st.userAgent),us=!es&&/Chrome\/(\d+)/.exec(st.userAgent),sr="webkitFontSmoothing"in js.documentElement.style,Qs=!es&&/Apple Computer/.test(st.vendor),nr=Qs&&(/Mobile\/\w+/.test(st.userAgent)||st.maxTouchPoints>2);var k={mac:nr||/Mac/.test(st.platform),windows:/Win/.test(st.platform),linux:/Linux|X11/.test(st.platform),ie:es,ie_version:Bo?js.documentMode||6:Gs?+Gs[1]:_s?+_s[1]:0,gecko:ir,gecko_version:ir?+(/Firefox\/(\d+)/.exec(st.userAgent)||[0,0])[1]:0,chrome:!!us,chrome_version:us?+us[1]:0,ios:nr,android:/Android\b/.test(st.userAgent),webkit:sr,webkit_version:sr?+(/\bAppleWebKit\/(\d+)/.exec(st.userAgent)||[0,0])[1]:0,safari:Qs,safari_version:Qs?+(/\bVersion\/(\d+(\.\d+)?)/.exec(st.userAgent)||[0,0])[1]:0,tabSize:js.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function vn(r,t){for(let e in r)e=="class"&&t.class?t.class+=" "+r.class:e=="style"&&t.style?t.style+=";"+r.style:t[e]=r[e];return t}const Hi=Object.create(null);function kn(r,t,e){if(r==t)return!0;r||(r=Hi),t||(t=Hi);let i=Object.keys(r),s=Object.keys(t);if(i.length-0!=s.length-0)return!1;for(let n of i)if(n!=e&&(s.indexOf(n)==-1||r[n]!==t[n]))return!1;return!0}function Dh(r,t){for(let e=r.attributes.length-1;e>=0;e--){let i=r.attributes[e].name;t[i]==null&&r.removeAttribute(i)}for(let e in t){let i=t[e];e=="style"?r.style.cssText=i:r.getAttribute(e)!=i&&r.setAttribute(e,i)}}function rr(r,t,e){let i=!1;if(t)for(let s in t)e&&s in e||(i=!0,s=="style"?r.style.cssText="":r.removeAttribute(s));if(e)for(let s in e)t&&t[s]==e[s]||(i=!0,s=="style"?r.style.cssText=e[s]:r.setAttribute(s,e[s]));return i}function Bh(r){let t=Object.create(null);for(let e=0;e<r.attributes.length;e++){let i=r.attributes[e];t[i.name]=i.value}return t}class ti{eq(t){return!1}updateDOM(t,e,i){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var ht=(function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r})(ht||(ht={}));class F extends ne{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new ei(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new re(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:n,end:o}=Ro(t,e);i=(n?e?-3e8:-1:5e8)-1,s=(o?e?2e8:1:-6e8)+1}return new re(t,i,s,e,t.widget||null,!0)}static line(t){return new ii(t)}static set(t,e=!1){return I.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}F.none=I.empty;class ei extends F{constructor(t){let{start:e,end:i}=Ro(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?vn(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Hi}eq(t){return this==t||t instanceof ei&&this.tagName==t.tagName&&kn(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}ei.prototype.point=!1;class ii extends F{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ii&&this.spec.class==t.spec.class&&kn(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}ii.prototype.mapMode=ot.TrackBefore;ii.prototype.point=!0;class re extends F{constructor(t,e,i,s,n,o){super(e,i,n,t),this.block=s,this.isReplace=o,this.mapMode=s?e<=0?ot.TrackBefore:ot.TrackAfter:ot.TrackDel}get type(){return this.startSide!=this.endSide?ht.WidgetRange:this.startSide<=0?ht.WidgetBefore:ht.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof re&&Rh(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}re.prototype.point=!0;function Ro(r,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=r;return e==null&&(e=r.inclusive),i==null&&(i=r.inclusive),{start:e??t,end:i??t}}function Rh(r,t){return r==t||!!(r&&t&&r.compare(t))}function ye(r,t,e,i=0){let s=e.length-1;s>=0&&e[s]+i>=r?e[s]=Math.max(e[s],t):e.push(r,t)}class Qe extends ne{constructor(t,e,i){super(),this.tagName=t,this.attributes=e,this.rank=i}eq(t){return t==this||t instanceof Qe&&this.tagName==t.tagName&&kn(this.attributes,t.attributes)}static create(t){return new Qe(t.tagName,t.attributes||Hi,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,e=!1){return I.of(t,e)}}Qe.prototype.startSide=Qe.prototype.endSide=-1;function Ue(r){let t;return r.nodeType==11?t=r.getSelection?r:r.ownerDocument:t=r,t.getSelection()}function Us(r,t){return t?r==t||r.contains(t.nodeType!=1?t.parentNode:t):!1}function Fe(r,t){if(!t.anchorNode)return!1;try{return Us(r,t.anchorNode)}catch{return!1}}function ze(r){return r.nodeType==3?Xe(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function $e(r,t,e,i){return e?or(r,t,e,i,-1)||or(r,t,e,i,1):!1}function Gt(r){for(var t=0;;t++)if(r=r.previousSibling,!r)return t}function Vi(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function or(r,t,e,i,s){for(;;){if(r==e&&t==i)return!0;if(t==(s<0?0:Wt(r))){if(r.nodeName=="DIV")return!1;let n=r.parentNode;if(!n||n.nodeType!=1)return!1;t=Gt(r)+(s<0?0:1),r=n}else if(r.nodeType==1){if(r=r.childNodes[t+(s<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;t=s<0?Wt(r):0}else return!1}}function Wt(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Ye(r,t){let{left:e,right:i}=r;if(e==i)return r;let s=t?e:i;return{left:s,right:s,top:r.top,bottom:r.bottom}}function Eh(r){let t=r.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function Eo(r,t){let e=t.width/r.offsetWidth,i=t.height/r.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-r.offsetWidth)<1)&&(e=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-r.offsetHeight)<1)&&(i=1),{scaleX:e,scaleY:i}}function Nh(r,t,e,i,s,n,o,l){let h=r.ownerDocument,a=h.defaultView||window;for(let f=r,c=!1;f&&!c;)if(f.nodeType==1){let u,d=f==h.body,p=1,g=1;if(d)u=Eh(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let v=f.getBoundingClientRect();({scaleX:p,scaleY:g}=Eo(f,v)),u={left:v.left,right:v.left+f.clientWidth*p,top:v.top,bottom:v.top+f.clientHeight*g}}let m=0,b=0;if(s=="nearest")t.top<u.top+o?(b=t.top-(u.top+o),e>0&&t.bottom>u.bottom+b&&(b=t.bottom-u.bottom+o)):t.bottom>u.bottom-o&&(b=t.bottom-u.bottom+o,e<0&&t.top-b<u.top&&(b=t.top-(u.top+o)));else{let v=t.bottom-t.top,y=u.bottom-u.top;b=(s=="center"&&v<=y?t.top+v/2-y/2:s=="start"||s=="center"&&e<0?t.top-o:t.bottom-y+o)-u.top}if(i=="nearest"?t.left<u.left+n?(m=t.left-(u.left+n),e>0&&t.right>u.right+m&&(m=t.right-u.right+n)):t.right>u.right-n&&(m=t.right-u.right+n,e<0&&t.left<u.left+m&&(m=t.left-(u.left+n))):m=(i=="center"?t.left+(t.right-t.left)/2-(u.right-u.left)/2:i=="start"==l?t.left-n:t.right-(u.right-u.left)+n)-u.left,m||b)if(d)a.scrollBy(m,b);else{let v=0,y=0;if(b){let P=f.scrollTop;f.scrollTop+=b/g,y=(f.scrollTop-P)*g}if(m){let P=f.scrollLeft;f.scrollLeft+=m/p,v=(f.scrollLeft-P)*p}t={left:t.left-v,top:t.top-y,right:t.right-v,bottom:t.bottom-y},v&&Math.abs(v-m)<1&&(i="nearest"),y&&Math.abs(y-b)<1&&(s="nearest")}if(d)break;(t.top<u.top||t.bottom>u.bottom||t.left<u.left||t.right>u.right)&&(t={left:Math.max(t.left,u.left),right:Math.min(t.right,u.right),top:Math.max(t.top,u.top),bottom:Math.min(t.bottom,u.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function No(r,t=!0){let e=r.ownerDocument,i=null,s=null;for(let n=r.parentNode;n&&!(n==e.body||(!t||i)&&s);)if(n.nodeType==1)!s&&n.scrollHeight>n.clientHeight&&(s=n),t&&!i&&n.scrollWidth>n.clientWidth&&(i=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:i,y:s}}class Ih{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Wt(e):0),i,Math.min(t.focusOffset,i?Wt(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}function Io(r){let t=[];for(let e=r;e;e=e.nodeType==11?e.host:e.parentNode)e.nodeType==1&&t.push({node:e,left:e.scrollLeft,top:e.scrollTop});return t}function Lo(r,t=!0){for(let{node:e,left:i,top:s}of r)t&&e.scrollTop!=s&&(e.scrollTop=s),e.scrollLeft!=i&&(e.scrollLeft=i)}let Zt=null;k.safari&&k.safari_version>=26&&(Zt=!1);function Wo(r){if(r.setActive)return r.setActive();if(Zt)return r.focus(Zt);let t=Io(r);r.focus(Zt==null?{get preventScroll(){return Zt={preventScroll:!0},!0}}:void 0),Zt||(Zt=!1,Lo(t))}let lr;function Xe(r,t,e=t){let i=lr||(lr=document.createRange());return i.setEnd(r,e),i.setStart(r,t),i}function xe(r,t,e,i){let s={key:t,code:t,keyCode:e,which:e,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let n=new KeyboardEvent("keydown",s);n.synthetic=!0,r.dispatchEvent(n);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,r.dispatchEvent(o),n.defaultPrevented||o.defaultPrevented}function Lh(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Wh(r,t){let e=t.focusNode,i=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=i)return!1;for(i=Math.min(i,Wt(e));;)if(i){if(e.nodeType!=1)return!1;let s=e.childNodes[i-1];s.contentEditable=="false"?i--:(e=s,i=Wt(e))}else{if(e==r)return!0;i=Gt(e),e=e.parentNode}}function Ho(r){return r instanceof Window?r.pageYOffset>Math.max(0,r.document.documentElement.scrollHeight-r.innerHeight-4):r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}function Vo(r,t){for(let e=r,i=t;;){if(e.nodeType==3&&i>0)return{node:e,offset:i};if(e.nodeType==1&&i>0){if(e.contentEditable=="false")return null;e=e.childNodes[i-1],i=Wt(e)}else if(e.parentNode&&!Vi(e))i=Gt(e),e=e.parentNode;else return null}}function Fo(r,t){for(let e=r,i=t;;){if(e.nodeType==3&&i<e.nodeValue.length)return{node:e,offset:i};if(e.nodeType==1&&i<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[i],i=0}else if(e.parentNode&&!Vi(e))i=Gt(e)+1,e=e.parentNode;else return null}}class yt{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new yt(t.parentNode,Gt(t),e)}static after(t,e){return new yt(t.parentNode,Gt(t)+1,e)}}var _=(function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r})(_||(_={}));const oe=_.LTR,Sn=_.RTL;function zo(r){let t=[];for(let e=0;e<r.length;e++)t.push(1<<+r[e]);return t}const Hh=zo("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Vh=zo("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ys=Object.create(null),Ct=[];for(let r of["()","[]","{}"]){let t=r.charCodeAt(0),e=r.charCodeAt(1);Ys[t]=e,Ys[e]=-t}function $o(r){return r<=247?Hh[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Vh[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8204?256:64336<=r&&r<=65023?4:1}const Fh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Dt{get dir(){return this.level%2?Sn:oe}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let n=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==i)return o;(n<0||(s!=0?s<0?l.from<e:l.to>e:t[n].level>l.level))&&(n=o)}}if(n<0)throw new RangeError("Index out of range");return n}}function Ko(r,t){if(r.length!=t.length)return!1;for(let e=0;e<r.length;e++){let i=r[e],s=t[e];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!Ko(i.inner,s.inner))return!1}return!0}const V=[];function zh(r,t,e,i,s){for(let n=0;n<=i.length;n++){let o=n?i[n-1].to:t,l=n<i.length?i[n].from:e,h=n?256:s;for(let a=o,f=h,c=h;a<l;a++){let u=$o(r.charCodeAt(a));u==512?u=f:u==8&&c==4&&(u=16),V[a]=u==4?2:u,u&7&&(c=u),f=u}for(let a=o,f=h,c=h;a<l;a++){let u=V[a];if(u==128)a<l-1&&f==V[a+1]&&f&24?u=V[a]=f:V[a]=256;else if(u==64){let d=a+1;for(;d<l&&V[d]==64;)d++;let p=a&&f==8||d<e&&V[d]==8?c==1?1:8:256;for(let g=a;g<d;g++)V[g]=p;a=d-1}else u==8&&c==1&&(V[a]=1);f=u,u&7&&(c=u)}}}function $h(r,t,e,i,s){let n=s==1?2:1;for(let o=0,l=0,h=0;o<=i.length;o++){let a=o?i[o-1].to:t,f=o<i.length?i[o].from:e;for(let c=a,u,d,p;c<f;c++)if(d=Ys[u=r.charCodeAt(c)])if(d<0){for(let g=l-3;g>=0;g-=3)if(Ct[g+1]==-d){let m=Ct[g+2],b=m&2?s:m&4?m&1?n:s:0;b&&(V[c]=V[Ct[g]]=b),l=g;break}}else{if(Ct.length==189)break;Ct[l++]=c,Ct[l++]=u,Ct[l++]=h}else if((p=V[c])==2||p==1){let g=p==s;h=g?0:1;for(let m=l-3;m>=0;m-=3){let b=Ct[m+2];if(b&2)break;if(g)Ct[m+2]|=2;else{if(b&4)break;Ct[m+2]|=4}}}}}function Kh(r,t,e,i){for(let s=0,n=i;s<=e.length;s++){let o=s?e[s-1].to:r,l=s<e.length?e[s].from:t;for(let h=o;h<l;){let a=V[h];if(a==256){let f=h+1;for(;;)if(f==l){if(s==e.length)break;f=e[s++].to,l=s<e.length?e[s].from:t}else if(V[f]==256)f++;else break;let c=n==1,u=(f<t?V[f]:i)==1,d=c==u?c?1:2:i;for(let p=f,g=s,m=g?e[g-1].to:r;p>h;)p==m&&(p=e[--g].from,m=g?e[g-1].to:r),V[--p]=d;h=f}else n=a,h++}}}function Xs(r,t,e,i,s,n,o){let l=i%2?2:1;if(i%2==s%2)for(let h=t,a=0;h<e;){let f=!0,c=!1;if(a==n.length||h<n[a].from){let g=V[h];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=h;t:for(;;)if(a<n.length&&p==n[a].from){if(c)break t;let g=n[a];if(!f)for(let m=g.to,b=a+1;;){if(m==e)break t;if(b<n.length&&n[b].from==m)m=n[b++].to;else{if(V[m]==l)break t;break}}if(a++,u)u.push(g);else{g.from>h&&o.push(new Dt(h,g.from,d));let m=g.direction==oe!=!(d%2);Js(r,m?i+1:i,s,g.inner,g.from,g.to,o),h=g.to}p=g.to}else{if(p==e||(f?V[p]!=l:V[p]==l))break;p++}u?Xs(r,h,p,i+1,s,u,o):h<p&&o.push(new Dt(h,p,d)),h=p}else for(let h=e,a=n.length;h>t;){let f=!0,c=!1;if(!a||h>n[a-1].to){let g=V[h-1];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=h;t:for(;;)if(a&&p==n[a-1].to){if(c)break t;let g=n[--a];if(!f)for(let m=g.from,b=a;;){if(m==t)break t;if(b&&n[b-1].to==m)m=n[--b].from;else{if(V[m-1]==l)break t;break}}if(u)u.push(g);else{g.to<h&&o.push(new Dt(g.to,h,d));let m=g.direction==oe!=!(d%2);Js(r,m?i+1:i,s,g.inner,g.from,g.to,o),h=g.from}p=g.from}else{if(p==t||(f?V[p-1]!=l:V[p-1]==l))break;p--}u?Xs(r,p,h,i+1,s,u,o):p<h&&o.push(new Dt(p,h,d)),h=p}}function Js(r,t,e,i,s,n,o){let l=t%2?2:1;zh(r,s,n,i,l),$h(r,s,n,i,l),Kh(s,n,i,l),Xs(r,s,n,t,e,i,o)}function qh(r,t,e){if(!r)return[new Dt(0,0,t==Sn?1:0)];if(t==oe&&!e.length&&!Fh.test(r))return qo(r.length);if(e.length)for(;r.length>V.length;)V[V.length]=256;let i=[],s=t==oe?0:1;return Js(r,s,s,e,0,r.length,i),i}function qo(r){return[new Dt(0,r,0)]}let jo="";function jh(r,t,e,i,s){var n;let o=i.head-r.from,l=Dt.find(t,o,(n=i.bidiLevel)!==null&&n!==void 0?n:-1,i.assoc),h=t[l],a=h.side(s,e);if(o==a){let u=l+=s?1:-1;if(u<0||u>=t.length)return null;h=t[l=u],o=h.side(!s,e),a=h.side(s,e)}let f=wt(r.text,o,h.forward(s,e));(f<h.from||f>h.to)&&(f=a),jo=r.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(s?t.length-1:0)?null:t[l+(s?1:-1)];return c&&f==a&&c.level+(s?0:1)<h.level?S.cursor(c.side(!s,e)+r.from,c.forward(s,e)?1:-1,c.level):S.cursor(f+r.from,h.forward(s,e)?-1:1,h.level)}function _h(r,t,e){for(let i=t;i<e;i++){let s=$o(r.charCodeAt(i));if(s==1)return oe;if(s==2||s==4)return Sn}return oe}const _o=A.define(),Go=A.define(),Qo=A.define(),Uo=A.define(),Zs=A.define(),Yo=A.define(),Xo=A.define(),Cn=A.define(),An=A.define(),Jo=A.define({combine:r=>r.some(t=>t)}),Gh=A.define({combine:r=>r.some(t=>t)}),Zo=A.define();class ve{constructor(t,e,i,s,n,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=n,this.isSnapshot=o}map(t){return t.empty?this:new ve(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new ve(S.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const di=U.define({map:(r,t)=>r.map(t)}),tl=U.define();function xt(r,t,e){let i=r.facet(Uo);i.length?i[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const Et=A.define({combine:r=>r.length?r[0]:!0});let Qh=0;const pe=A.define({combine(r){return r.filter((t,e)=>{for(let i=0;i<e;i++)if(r[i].plugin==t.plugin)return!1;return!0})}});class at{constructor(t,e,i,s,n){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(pe.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(pe.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:s,provide:n,decorations:o}=e||{};return new at(Qh++,t,i,s,l=>{let h=[];return o&&h.push(is.of(a=>{let f=a.plugin(l);return f?o(f):F.none})),n&&h.push(n(l)),h})}static fromClass(t,e){return at.define((i,s)=>new t(i,s),e)}}class ds{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(xt(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){xt(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){xt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const el=A.define(),On=A.define(),is=A.define(),il=A.define(),Tn=A.define(),si=A.define(),sl=A.define();function hr(r,t){let e=r.state.facet(sl);if(!e.length)return e;let i=e.map(n=>n instanceof Function?n(r):n),s=[];return I.spans(i,t.from,t.to,{point(){},span(n,o,l,h){let a=n-t.from,f=o-t.from,c=s;for(let u=l.length-1;u>=0;u--,h--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=_h(t.text,a,f)),h>0&&c.length&&(p=c[c.length-1]).to==a&&p.direction==d)p.to=f,c=p.inner;else{let g={from:a,to:f,direction:d,inner:[]};c.push(g),c=g.inner}}}}),s}const nl=A.define();function Mn(r){let t=0,e=0,i=0,s=0;for(let n of r.state.facet(nl)){let o=n(r);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:t,right:e,top:i,bottom:s}}const Ie=A.define();class gt{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new gt(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(e.length==0)return t;let i=[];for(let s=0,n=0,o=0;;){let l=s<t.length?t[s].fromB:1e9,h=n<e.length?e[n]:1e9,a=Math.min(l,h);if(a==1e9)break;let f=a+o,c=a,u=f;for(;;)if(n<e.length&&e[n]<=c){let d=e[n+1];n+=2,c=Math.max(c,d);for(let p=s;p<t.length&&t[p].fromB<=c;p++)o=t[p].toA-t[p].toB;u=Math.max(u,d+o)}else if(s<t.length&&t[s].fromB<=c){let d=t[s++];c=Math.max(c,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new gt(f,u,a,c))}return i}}class Fi{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=X.empty(this.startState.doc.length);for(let n of i)this.changes=this.changes.compose(n.changes);let s=[];this.changes.iterChangedRanges((n,o,l,h)=>s.push(new gt(n,o,l,h))),this.changedRanges=s}static create(t,e,i){return new Fi(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Uh=[];class G{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Uh}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Dh(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let s of this.children){if(s==t)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e,i){return null}domPosFor(t,e){let i=Gt(this.dom),s=this.length?t>0:e>0;return new yt(this.parent.dom,i+(s?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof ns)return t;return null}static get(t){return t.cmTile}}class ss extends G{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,i=null,s,n=t?.node==e?t:null,o=0;for(let l of this.children){if(l.sync(t),o+=l.length+l.breakAfter,s=i?i.nextSibling:e.firstChild,n&&s!=l.dom&&(n.written=!0),l.dom.parentNode==e)for(;s&&s!=l.dom;)s=ar(s);else e.insertBefore(l.dom,s);i=l.dom}for(s=i?i.nextSibling:e.firstChild,n&&s&&(n.written=!0);s;)s=ar(s);this.length=o}}function ar(r){let t=r.nextSibling;return r.parentNode.removeChild(r),t}class ns extends ss{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=G.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,s=0,n=0;;)if(s==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&n++,s=e.pop()}else{let o=i.children[s++];if(o instanceof Lt)e.push(s),i=o,s=0;else{let l=n+o.length,h=t(o,n);if(h!==void 0)return h;n=l+o.breakAfter}}}resolveBlock(t,e){let i,s=-1,n,o=-1;if(this.blockTiles((l,h)=>{let a=h+l.length;if(t>=h&&t<=a){if(l.isWidget()&&e>=-1&&e<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(h<t||t==a&&(e<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,s=t-h),(a>t||t==h&&(e>1?l.length:l.covers(-1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,o=t-h)}}),!i&&!n)throw new Error("No tile at position "+t);return i&&e<0||!n?{tile:i,offset:s}:{tile:n,offset:o}}}class Lt extends ss{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new Lt(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Ce extends ss{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let s=new Ce(e||document.createElement("div"),t);return(!e||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(t,e,i){let s=null,n=-1,o=null,l=-1;function h(f,c){for(let u=0,d=0;u<f.children.length&&d<=c;u++){let p=f.children[u],g=d+p.length;g>=c&&(p.isComposite()?h(p,c-d):(!o||o.isHidden&&(e>0&&!(o.flags&32)||i&&Xh(o,p)))&&(g>c||p.flags&32&&e<=1)?(o=p,l=c-d):(d<c||p.flags&16&&!p.isHidden&&e>=-1)&&(s=p,n=c-d)),d=g}}h(this,t);let a=(e<0?s:o)||s||o;return a?{tile:a,offset:a==s?n:l}:null}coordsIn(t,e,i){let s=this.resolveInline(t,e,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),e,i):Yh(this)}domIn(t,e){let i=this.resolveInline(t,e);if(i){let{tile:s,offset:n}=i;if(this.dom.contains(s.dom))return s.isText()?new yt(s.dom,Math.min(s.dom.nodeValue.length,n)):s.domPosFor(n,s.flags&16?1:s.flags&32?-1:e);let o=i.tile.parent,l=!1;for(let h of o.children){if(l)return new yt(h.dom,0);h==i.tile&&(l=!0)}}return new yt(this.dom,0)}}function Yh(r){let t=r.dom.lastChild;if(!t)return r.dom.getBoundingClientRect();let e=ze(t);return e[e.length-1]||null}function Xh(r,t){let e=r.coordsIn(0,1),i=t.coordsIn(0,1);return e&&i&&i.top<e.bottom}class lt extends ss{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let i=new lt(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class ie extends G{constructor(t,e){super(t,e.length),this.text=e}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e,i){let s=this.dom.nodeValue.length;t>s&&(t=s);let n=t,o=t,l=0;t==0&&e<0||t==s&&e>=0?k.chrome||k.gecko||(t?(n--,l=1):o<s&&(o++,l=-1)):e<0?n--:o<s&&o++;let h=Xe(this.dom,n,o).getClientRects();if(!h.length)return null;let a=h[(l?l<0:e>=0)?0:h.length-1];return k.safari&&!l&&a.width==0&&(a=Array.prototype.find.call(h,f=>f.width)||a),i==null?a:Ye(a,(l?l>0:e<0)==i)}static of(t,e){let i=new ie(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class le extends G{constructor(t,e,i,s){super(t,e,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let s=this.widget.coordsAt(this.dom,t,e);if(s)return s;if(i)return Ye(this.dom.getBoundingClientRect(),this.length?t==0:e<=0);{let n=this.dom.getClientRects(),o=null;if(!n.length)return null;let l=this.flags&16?!0:this.flags&32?!1:t>0;for(let h=l?n.length-1:0;o=n[h],!(t>0?h==0:h==n.length-1||o.top<o.bottom);h+=l?-1:1);return Ye(o,!l)}}get overrideDOMText(){if(!this.length)return W.empty;let{root:t}=this;if(!t)return W.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,i,s,n){return n||(n=t.toDOM(e),t.editable||(n.contentEditable="false")),new le(n,i,t,s)}}class zi extends G{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return W.empty}coordsIn(t,e,i){let s=this.dom.getBoundingClientRect();return i==null?s:Ye(s,e>0==i)}}class Jh{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:s,index:n,beforeBreak:o,parents:l}=this;for(;t||e>0;)if(s.isComposite())if(o){if(!t)break;i&&i.break(),t--,o=!1}else if(n==s.children.length){if(!t&&!l.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:n}=l.pop(),n++}else{let h=s.children[n],a=h.breakAfter;(e>0?h.length<=t:h.length<t)&&(!i||i.skip(h,0,h.length)!==!1||!h.isComposite)?(o=!!a,n++,t-=h.length):(l.push({tile:s,index:n}),s=h,n=0,i&&h.isComposite()&&i.enter(h))}else{let h=s.length;if(n<h&&t){let a=Math.min(t,h-n);i&&i.skip(s,n,n+a),t-=a,n+=a}if(n==h)o=!!s.breakAfter,{tile:s,index:n}=l.pop(),n++;else if(!t)break}return this.tile=s,this.index=n,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Zh{constructor(t,e,i,s){this.from=t,this.to=e,this.wrapper=i,this.rank=s}}class ta{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,s){var n;this.flushBuffer();let o=this.ensureMarks(e,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+t.length<512){this.cache.reused.set(l,2);let h=o.children[o.children.length-1]=new ie(l.dom,l.text+t);h.parent=o}else o.append(s||ie.of(t,(n=this.cache.find(ie))===null||n===void 0?void 0:n.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?ps(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let s=i;for(let l=e.marks.length-1;l>=0;l--){let h=e.marks[l],a=s.lastChild;if(a instanceof lt&&a.mark.eq(h.mark))a.dom!=h.dom&&a.setDOM(ps(h.dom)),s=a;else{if(this.cache.reused.get(h)){let c=G.get(h.dom);c&&c.setDOM(ps(h.dom))}let f=lt.of(h.mark,h.dom);s.append(f),s=f}this.cache.reused.set(h,2)}let n=G.get(t.text);n&&this.cache.reused.set(n,2);let o=new ie(t.text,t.text.nodeValue);o.flags|=8,this.pos=t.range.toB,s.append(o)}addInlineWidget(t,e,i){let s=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);s||this.flushBuffer();let n=this.ensureMarks(e,i);!s&&!(t.flags&16)&&n.append(this.getBuffer(1)),n.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=rl);let s=Ce.start(t,e||((i=this.cache.find(Ce))===null||i===void 0?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let s=this.curLine;for(let n=t.length-1;n>=0;n--){let o=t[n],l;if(e>0&&(l=s.lastChild)&&l instanceof lt&&l.mark.eq(o))s=l,e--;else{let h=lt.of(o,(i=this.cache.find(lt,a=>a.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(h),s=h,e=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!fr(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(k.ios&&fr(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(gs,0,32)||new le(gs.toDOM(),0,gs,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=t.rank*102+t.value.rank,i=new Zh(t.from,t.to,t.value,e),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-i.rank||this.wrappers[s-1].to-i.to)<0;)s--;this.wrappers.splice(s,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let s=e.lastChild;if(i.from<this.pos&&s instanceof Lt&&s.wrapper.eq(i.wrapper))e=s;else{let n=Lt.of(i.wrapper,(t=this.cache.find(Lt,o=>o.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);e.append(n),e=n}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(zi,void 0,1);return i&&(i.flags=e),i||new zi(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class ea{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:s,lineBreak:n,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(t,s.length);return n?null:s.slice(0,l)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const $i=[le,Ce,ie,lt,zi,Lt,ns];for(let r=0;r<$i.length;r++)$i[r].bucket=r;class ia{constructor(t){this.view=t,this.buckets=$i.map(()=>[]),this.index=$i.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let s=t.bucket,n=this.buckets[s],o=this.index[s];for(let l=0;l<n.length;l++){let h=(l+o)%n.length,a=n[h];if((!e||e(a))&&!this.reused.has(a))return n.splice(h,1),h<o&&this.index[s]--,this.reused.set(a,i),a}return null}findWidget(t,e,i){let s=this.buckets[0];if(s.length)for(let n=0,o=0;;n++){if(n==s.length){if(o)return null;o=1,n=0}let l=s[n];if(!this.reused.has(l)&&(o==0?l.widget.compare(t):l.widget.constructor==t.constructor&&t.updateDOM(l.dom,this.view,l.widget)))return s.splice(n,1),n<this.index[0]&&this.index[0]--,l.widget==t&&l.length==e&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new le(l.dom,e,t,l.flags&-498|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class sa{constructor(t,e,i,s,n){this.view=t,this.decorations=s,this.disallowBlockEffectsFor=n,this.openWidget=!1,this.openMarks=0,this.cache=new ia(t),this.text=new ea(t.state.doc),this.builder=new ta(this.cache,new ns(t,t.contentDOM),I.iter(i)),this.cache.reused.set(e,2),this.old=new Jh(e),this.reuseWalker={skip:(o,l,h)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let s=0,n=0,o=0;;){let l=o<t.length?t[o++]:null,h=l?l.fromA:this.old.root.length;if(h>s){let a=h-s;this.preserve(a,!o,!l),s=h,n+=a}if(!l)break;e&&l.fromA<=e.range.fromA&&l.toA>=e.range.toA?(this.forward(l.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(n,e.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,l.toA),this.emit(e.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(n,l.toB)),n=l.toB,s=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let s=oa(this.old),n=this.openMarks;this.old.advance(t,i?1:-1,{skip:(o,l,h)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(h-l);else{let a=h>0||l<o.length?le.of(o.widget,this.view,h-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,s,n),n=s.length)}else if(o.isText())this.builder.ensureLine(null),!l&&h==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,n,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,h),s,n)),n=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof zi)this.cache.add(o);else if(o instanceof lt)this.builder.ensureLine(null),this.builder.addMark(o,s,n),this.cache.reused.set(o,1),n=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof lt&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=n=0):o instanceof lt&&(s.shift(),n=Math.min(n,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,s=this.builder,n=-1,o=I.spans(this.decorations,t,e,{point:(l,h,a,f,c,u)=>{if(a instanceof re){if(this.disallowBlockEffectsFor[u]){if(a.block)throw new RangeError("Block decorations may not be specified via plugins");if(h>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=f.length,c>f.length)s.continueWidget(h-l);else{let d=a.widget||(a.block?Ae.block:Ae.inline),p=na(a),g=this.cache.findWidget(d,h-l,p)||le.of(d,this.view,h-l,p);a.block?(a.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(g)):(s.ensureLine(i),s.addInlineWidget(g,f,c))}i=null}else i=ra(i,a);h>l&&this.text.skip(h-l)},span:(l,h,a,f)=>{for(let c=l;c<h;){let u=this.text.next(Math.min(512,h-c));u==null?(s.addLineStartIfNotCovered(i),s.addBreak(),c++):(s.ensureLine(i),s.addText(u,a,c==l?f:a.length),c+=u.length),i=null}n=a.length}});n>-1&&(this.openWidget=o>n),this.openWidget||s.addLineStartIfNotCovered(i),this.openMarks=o}forward(t,e,i=1){e-t<=10?this.old.advance(e-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let s=t.parentNode;;s=s.parentNode){let n=G.get(s);if(s==this.view.contentDOM)break;n instanceof lt?e.push(n):n?.isLine()?i=n:n instanceof Lt||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new Ce(s,rl):i||e.push(lt.of(new ei({tagName:s.nodeName.toLowerCase(),attributes:Bh(s)}),s)))}return{line:i,marks:e}}}function fr(r,t){let e=i=>{for(let s of i.children)if((t?s.isText():s.length)||e(s))return!0;return!1};return e(r)}function na(r){let t=r.isReplace?(r.startSide<0?64:0)|(r.endSide>0?128:0):r.startSide>0?32:16;return r.block&&(t|=256),t}const rl={class:"cm-line"};function ra(r,t){let e=t.spec.attributes,i=t.spec.class;return!e&&!i||(r||(r={class:"cm-line"}),e&&vn(e,r),i&&(r.class+=" "+i)),r}function oa(r){let t=[];for(let e=r.parents.length;e>1;e--){let i=e==r.parents.length?r.tile:r.parents[e].tile;i instanceof lt&&t.push(i.mark)}return t}function ps(r){let t=G.get(r);return t&&t.setDOM(r.cloneNode()),r}class Ae extends ti{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ae.inline=new Ae("span");Ae.block=new Ae("div");const gs=new class extends ti{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class cr{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=F.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ns(t,t.contentDOM),this.updateInner([new gt(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:c})=>c<this.minWidthFrom||f>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?s=this.domChanged.newSel.head:!ga(t.changes,this.hasComposition)&&!t.selectionSet&&(s=t.state.selection.main.head));let n=s>-1?ha(this.view,t.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:f,to:c}=this.hasComposition;i=new gt(f,c,t.changes.mapPos(f,-1),t.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(k.ie||k.chrome)&&!n&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let h=ca(o,this.decorations,t.changes);h.length&&(i=gt.extendWithRanges(i,h));let a=da(l,this.blockWrappers,t.changes);return a.length&&(i=gt.extendWithRanges(i,a)),n&&!i.some(f=>f.fromA<=n.range.fromA&&f.toA>=n.range.toA)&&(i=n.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,n),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let o=this.tile,l=new sa(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&G.get(e.text)&&l.cache.reused.set(G.get(e.text),2),this.tile=l.run(t,e),tn(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=k.chrome||k.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||i.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let n of this.tile.children)n.isWidget()&&n.widget instanceof ms&&s.push(n.dom);i.updateGaps(s)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(tl)&&(this.editContextFormatting=i.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,s=this.view.root.activeElement,n=s==i,o=!n&&!(this.view.state.facet(Et)||i.tabIndex>-1)&&Fe(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(n||e||o))return;let l=this.forceSelection;this.forceSelection=!1;let h=this.view.state.selection.main,a,f;if(h.empty?f=a=this.inlineDOMNearPos(h.anchor,h.assoc||1):(f=this.inlineDOMNearPos(h.head,h.head==h.from?1:-1),a=this.inlineDOMNearPos(h.anchor,h.anchor==h.from?1:-1)),k.gecko&&h.empty&&!this.hasComposition&&la(a)){let u=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(u,a.node.childNodes[a.offset]||null)),a=f=new yt(u,0),l=!0}let c=this.view.observer.selectionRange;(l||!c.focusNode||(!$e(a.node,a.offset,c.anchorNode,c.anchorOffset)||!$e(f.node,f.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,h))&&(this.view.observer.ignore(()=>{k.android&&k.chrome&&i.contains(c.focusNode)&&pa(c.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Ue(this.view.root);if(u)if(h.empty){if(k.gecko){let d=aa(a.node,a.offset);if(d&&d!=3){let p=(d==1?Vo:Fo)(a.node,a.offset);p&&(a=new yt(p.node,p.offset))}}u.collapse(a.node,a.offset),h.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=h.bidiLevel)}else if(u.extend){u.collapse(a.node,a.offset);try{u.extend(f.node,f.offset)}catch{}}else{let d=document.createRange();h.anchor>h.head&&([a,f]=[f,a]),d.setEnd(f.node,f.offset),d.setStart(a.node,a.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(a,f)),this.impreciseAnchor=a.precise?null:new yt(c.anchorNode,c.anchorOffset),this.impreciseHead=f.precise?null:new yt(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&$e(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Ue(t.root),{anchorNode:s,anchorOffset:n}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let o=this.lineAt(e.head,e.assoc);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let h=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!h||!a||h.bottom>a.top)return;let f=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(f.node,f.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,n)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let n;if(t==i.dom)n=i.dom.childNodes[e];else{let o=Wt(t)==0?0:e==0?-1:1;for(;;){let l=t.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(t==l.firstChild?o=-1:o=1),t=l}o<0?n=t:n=t.nextSibling}if(n==i.dom.firstChild)return s;for(;n&&!G.get(n);)n=n.nextSibling;if(!n)return s+i.length;for(let o=0,l=s;;o++){let h=i.children[o];if(h.dom==n)return l;l+=h.length+h.breakAfter}}else return i.isText()?t==i.dom?s+e:s+(e?i.length:0):s}domAtPos(t,e){let{tile:i,offset:s}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(s,e):i.domIn(s,e)}inlineDOMNearPos(t,e){let i,s=-1,n=!1,o,l=-1,h=!1;return this.tile.blockTiles((a,f)=>{if(a.isWidget()){if(a.flags&32&&f>=t)return!0;a.flags&16&&(n=!0)}else{let c=f+a.length;if(f<=t&&(i=a,s=t-f,n=c<t),c>=t&&!o&&(o=a,l=t-f,h=f>t),f>t&&o)return!0}}),!i&&!o?this.domAtPos(t,e):(n&&o?i=null:h&&i&&(o=null),i&&e<0||!o?i.domIn(s,e):o.domIn(l,e))}coordsAt(t,e,i){let{tile:s,offset:n}=this.tile.resolveBlock(t,e);return s.isWidget()?s.widget instanceof ms?null:s.coordsInWidget(n,e,!0):s.coordsIn(n,e,i)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function s(n,o){if(n.isComposite())for(let l of n.children){if(l.length>=o){let h=s(l,o);if(h)return h}if(o-=l.length,o<0)break}else if(n.isText()&&o<n.length){let l=wt(n.text,o);if(l==o)return null;let h=Xe(n.dom,o,l).getClientRects();for(let a=0;a<h.length;a++){let f=h[a];if(a==h.length-1||f.top<f.bottom&&f.left<f.right)return f}}return null}return s(e,i)}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t,n=this.view.contentDOM.clientWidth,o=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,h=this.view.textDirection==_.LTR,a=0,f=(c,u,d)=>{for(let p=0;p<c.children.length&&!(u>s);p++){let g=c.children[p],m=u+g.length,b=g.dom.getBoundingClientRect(),{height:v}=b;if(d&&!p&&(a+=b.top-d.top),g instanceof Lt)m>i&&f(g,u,b);else if(u>=i&&(a>0&&e.push(-a),e.push(v+a),a=0,o)){let y=g.dom.lastChild,P=y?ze(y):[];if(P.length){let T=P[P.length-1],O=h?T.right-b.left:b.right-T.left;O>l&&(l=O,this.minWidth=n,this.minWidthFrom=u,this.minWidthTo=m)}}d&&p==c.children.length-1&&(a+=d.bottom-b.bottom),u=m+g.breakAfter}};return f(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?_.RTL:_.LTR}measureTextSize(){let t=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,h;for(let a of o.children){if(!a.isText()||/[^ -~]/.test(a.text))return;let f=ze(a.dom);if(f.length!=1)return;l+=f[0].width,h=f[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:h}}});if(t)return t;let e=document.createElement("div"),i,s,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(e);let o=ze(e.firstChild)[0];i=e.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,n=o&&o.height?o.height:i,e.remove()}),{lineHeight:i,charWidth:s,textHeight:n}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let n=s==e.viewports.length?null:e.viewports[s],o=n?n.from-1:this.view.state.doc.length;if(o>i){let l=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(F.replace({widget:new ms(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!n)break;i=n.to+1}return F.set(t)}updateDeco(){let t=1,e=this.view.state.facet(is).map(n=>(this.dynamicDecorationMap[t++]=typeof n=="function")?n(this.view):n),i=!1,s=this.view.state.facet(Tn).map((n,o)=>{let l=typeof n=="function";return l&&(i=!0),l?n(this.view):n});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(I.join(s))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(il).map(n=>typeof n=="function"?n(this.view):n)}scrollIntoView(t){if(t.isSnapshot){let a=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=a.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let a of this.view.state.facet(Zo))try{if(a(this.view,t.range,t))return!0}catch(f){xt(this.view.state,f,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.assoc||(e.head>e.anchor?-1:1)),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let n=Mn(this.view),o={left:i.left-n.left,top:i.top-n.top,right:i.right+n.right,bottom:i.bottom+n.bottom},{offsetWidth:l,offsetHeight:h}=this.view.scrollDOM;if(Nh(this.view.scrollDOM,o,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,l),-l),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==_.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let a=this.view.docView.lineAt(e.head,1);if(a){let f=Io(a.dom);a.dom.scrollIntoView({block:"nearest"}),Lo(f,!1)}}}lineHasWidget(t){let e=i=>i.isWidget()||i.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){tn(this.tile)}}function tn(r,t){let e=t?.get(r);if(e!=1){e==null&&r.destroy();for(let i of r.children)tn(i,t)}}function la(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}function ol(r,t){let e=r.observer.selectionRange;if(!e.focusNode)return null;let i=Vo(e.focusNode,e.focusOffset),s=Fo(e.focusNode,e.focusOffset),n=i||s;if(s&&i&&s.node!=i.node){let l=G.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)n=s;else if(r.docView.lastCompositionAfterCursor){let h=G.get(i.node);!h||h.isText()&&h.text!=i.node.nodeValue||(n=s)}}if(r.docView.lastCompositionAfterCursor=n!=i,!n)return null;let o=t-n.offset;return{from:o,to:o+n.node.nodeValue.length,node:n.node}}function ha(r,t,e){let i=ol(r,e);if(!i)return null;let{node:s,from:n,to:o}=i,l=s.nodeValue;if(/[\n\r]/.test(l)||r.state.doc.sliceString(i.from,i.to)!=l)return null;let h=t.invertedDesc;return{range:new gt(h.mapPos(n),h.mapPos(o),n,o),text:s}}function aa(r,t){return r.nodeType!=1?0:(t&&r.childNodes[t-1].contentEditable=="false"?1:0)|(t<r.childNodes.length&&r.childNodes[t].contentEditable=="false"?2:0)}let fa=class{constructor(){this.changes=[]}compareRange(t,e){ye(t,e,this.changes)}comparePoint(t,e){ye(t,e,this.changes)}boundChange(t){ye(t,t,this.changes)}};function ca(r,t,e){let i=new fa;return I.compare(r,t,e,i),i.changes}class ua{constructor(){this.changes=[]}compareRange(t,e){ye(t,e,this.changes)}comparePoint(){}boundChange(t){ye(t,t,this.changes)}}function da(r,t,e){let i=new ua;return I.compare(r,t,e,i),i.changes}function pa(r,t){for(let e=r;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function ga(r,t){let e=!1;return t&&r.iterChangedRanges((i,s)=>{i<t.to&&s>t.from&&(e=!0)}),e}class ms extends ti{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ma(r,t,e=1){let i=r.charCategorizer(t),s=r.doc.lineAt(t),n=t-s.from;if(s.length==0)return S.cursor(t);n==0?e=1:n==s.length&&(e=-1);let o=n,l=n;e<0?o=wt(s.text,n,!1):l=wt(s.text,n);let h=i(s.text.slice(o,l));for(;o>0;){let a=wt(s.text,o,!1);if(i(s.text.slice(a,o))!=h)break;o=a}for(;l<s.length;){let a=wt(s.text,l);if(i(s.text.slice(l,a))!=h)break;l=a}return S.undirectionalRange(o+s.from,l+s.from)}function ba(r,t,e,i,s){let n=Math.round((i-t.left)*r.defaultCharacterWidth);if(r.lineWrapping&&e.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,h=Math.floor((s-e.top-(r.defaultLineHeight-l)*.5)/l);n+=h*r.viewState.heightOracle.lineLength}let o=r.state.sliceDoc(e.from,e.to);return e.from+Ah(o,n,r.state.tabSize)}function wa(r,t,e){let i=r.lineBlockAt(t);if(Array.isArray(i.type)){let s;for(let n of i.type){if(n.from>t)break;if(!(n.to<t)){if(n.from<t&&n.to>t)return n;(!s||n.type==ht.Text&&(s.type!=n.type||(e<0?n.from<t:n.to>t)))&&(s=n)}}return s||i}return i}function ya(r,t,e,i){let s=wa(r,t.head,t.assoc||-1),n=!i||s.type!=ht.Text||!(r.lineWrapping||s.widgetLineBreaks)?null:r.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head);if(n){let o=r.dom.getBoundingClientRect(),l=r.textDirectionAt(s.from),h=r.posAtCoords({x:e==(l==_.LTR)?o.right-1:o.left+1,y:(n.top+n.bottom)/2});if(h!=null)return S.cursor(h,e?-1:1)}return S.cursor(e?s.to:s.from,e?-1:1)}function ur(r,t,e,i){let s=r.state.doc.lineAt(t.head),n=r.bidiSpans(s),o=r.textDirectionAt(s.from);for(let l=t,h=null;;){let a=jh(s,n,o,l,e),f=jo;if(!a){if(s.number==(e?r.state.doc.lines:1))return l;f=`
8
8
  `,s=r.state.doc.line(s.number+(e?1:-1)),n=r.bidiSpans(s),a=r.visualLineSide(s,!e)}if(h){if(!h(f))return l}else{if(!i)return a;h=i(f)}l=a}}function xa(r,t,e){let i=r.state.charCategorizer(t),s=i(e);return n=>{let o=i(n);return s==Nt.Space&&(s=o),s==o}}function va(r,t,e,i){let s=t.head,n=e?1:-1;if(s==(e?r.state.doc.length:0))return S.cursor(s,t.assoc);let o=t.goalColumn,l,h=r.contentDOM.getBoundingClientRect(),a=r.coordsAtPos(s,t.assoc||((t.empty?e:t.head==t.from)?1:-1)),f=r.documentTop;if(a)o==null&&(o=a.left-h.left),l=n<0?a.top:a.bottom;else{let p=r.viewState.lineBlockAt(s);o==null&&(o=Math.min(h.right-h.left,r.defaultCharacterWidth*(s-p.from))),l=(n<0?p.top:p.bottom)+f}let c=h.left+o,u=r.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let g=l+(d+p)*n,m=en(r,{x:c,y:g},!1,n);if(e?g>h.bottom:g<h.top)return S.cursor(m.pos,m.assoc);let b=r.coordsAtPos(m.pos,m.assoc),v=b?(b.top+b.bottom)/2:0;if(!b||(e?v>l:v<l))return S.cursor(m.pos,m.assoc,void 0,o)}}function Ke(r,t,e){for(;;){let i=0;for(let s of r)s.between(t-1,t+1,(n,o,l)=>{if(t>n&&t<o){let h=i||e||(t-n<o-t?-1:1);t=h<0?n:o,i=h}});if(!i)return t}}function ll(r,t){let e=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],n=null;if(s.empty){let o=Ke(r,s.from,0);o!=s.from&&(n=S.cursor(o,-1))}else{let o=Ke(r,s.from,-1),l=Ke(r,s.to,1);(o!=s.from||l!=s.to)&&(s.undirectional?n=S.undirectionalRange(s.from,s.to):n=S.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}n&&(e||(e=t.ranges.slice()),e[i]=n)}return e?S.create(e,t.mainIndex):t}function bs(r,t,e){let i=Ke(r.state.facet(si).map(s=>s(r)),e.from,t.head>e.from?-1:1);return i==e.from?e:S.cursor(i,i<e.from?1:-1)}class Pt{constructor(t,e){this.pos=t,this.assoc=e}}function en(r,t,e,i){let s=r.contentDOM.getBoundingClientRect(),n=s.top+r.viewState.paddingTop,{x:o,y:l}=t,h=l-n,a;for(;;){if(h<0)return new Pt(0,1);if(h>r.viewState.docHeight)return new Pt(r.state.doc.length,-1);if(a=r.elementAtHeight(h),i==null)break;if(a.type==ht.Text){if(i<0?a.to<r.viewport.from:a.from>r.viewport.to)break;let u=r.docView.coordsAt(i<0?a.from:a.to,i>0?-1:1);if(u&&(i<0?u.top<=h+n:u.bottom>=h+n))break}let c=r.viewState.heightOracle.textHeight/2;h=i>0?a.bottom+c:a.top-c}if(r.viewport.from>=a.to||r.viewport.to<=a.from){if(e)return null;if(a.type==ht.Text){let c=ba(r,s,a,o,l);return new Pt(c,c==a.from?1:-1)}}if(a.type!=ht.Text)return h<(a.top+a.bottom)/2?new Pt(a.from,1):new Pt(a.to,-1);let f=r.docView.lineAt(a.from,2);return(!f||f.length!=a.length)&&(f=r.docView.lineAt(a.from,-2)),new ka(r,o,l,r.textDirectionAt(a.from)).scanTile(f,a.from)}class ka{constructor(t,e,i,s){this.view=t,this.x=e,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[Dt.find(s,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[Dt.find(s,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:s}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from<e)}scan(t,e,i=!1){let s=0,n=t.length-1,o=new Set,l=this.bidiIn(t[0],t[n]),h,a,f=-1,c=1e9,u;t:for(;s<n;){let p=n-s,g=s+n>>1;e:if(o.has(g)){for(let v=1;v<p;v++){let y=g+v;if(y>=n&&(y-=p),!o.has(y)){g=y;break e}}break t}o.add(g);let m=e(g),b=0;if(m)for(let v=0;v<m.length;v++){let y=m[v];if(!(y.width==0&&m.length>1))if(y.bottom<this.y)(!h||h.bottom<y.bottom)&&(h=y),b=1;else if(y.top>this.y)(!a||a.top>y.top)&&(a=y),b=-1;else{let P=y.left>this.x?this.x-y.left:y.right<this.x?this.x-y.right:0,T=Math.abs(P);T<c&&(f=g,c=T,u=y),P&&(b=P<0==(this.baseDir==_.LTR)?-1:1)}}b==-1&&(!l||this.baseDirAt(t[g],1))?n=g:b==1&&(!l||this.baseDirAt(t[g+1],-1))&&(s=g+1)}if(!u){if(!a&&!h)return{i:0,after:!1};let p=h&&(!a||this.y-h.bottom<a.top-this.y)?h:a;return this.y=(p.top+p.bottom)/2,this.scan(t,e,!0)}if(c&&!i){let{top:p,bottom:g}=u;if(h&&h.bottom>(p+p+g)/3)return this.y=h.bottom-1,this.scan(t,e,!0);if(a&&a.top<(p+g+g)/3)return this.y=a.top+1,this.scan(t,e,!0)}let d=(l?this.dirAt(t[f],1):this.baseDir)==_.LTR;return{i:f,after:this.x>(u.left+u.right)/2==d}}scanText(t,e){let i=[];for(let n=0;n<t.length;n=wt(t.text,n))i.push(e+n);i.push(e+t.length);let s=this.scan(i,n=>{let o=i[n]-e,l=i[n+1]-e;return Xe(t.dom,o,l).getClientRects()});return s.after?new Pt(i[s.i+1],-1):new Pt(i[s.i],1)}scanTile(t,e){if(!t.length)return new Pt(e,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,e);if(l.isComposite())return this.scanTile(l,e)}let i=[e];for(let l=0,h=e;l<t.children.length;l++)i.push(h+=t.children[l].length);let s=this.scan(i,l=>{let h=t.children[l];return h.flags&48?null:(h.dom.nodeType==1?h.dom:Xe(h.dom,0,h.length)).getClientRects()}),n=t.children[s.i],o=i[s.i];return n.isText()?this.scanText(n,o):n.isComposite()?this.scanTile(n,o):s.after?new Pt(i[s.i+1],-1):new Pt(o,1)}}const de="￿";class Sa{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(L.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=de}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let n=this.text.length;this.readNode(s);let o=G.get(s),l=s.nextSibling;if(l==e){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let h=G.get(l);(o&&h?o.breakAfter:(o?o.breakAfter:Vi(s))||Vi(l)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>n)&&!Aa(l,e)&&this.lineBreak(),s=l}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,o=1,l;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(e))&&(n=l.index,o=l[0].length),this.append(e.slice(i,n<0?e.length:n)),n<0)break;if(this.lineBreak(),o>1)for(let h of this.points)h.node==t&&h.pos>this.text.length&&(h.pos-=o-1);i=n+o}}readNode(t){let e=G.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Ca(t,i.node,i.offset)?e:0))}}function Ca(r,t,e){for(;;){if(!t||e<Wt(t))return!1;if(t==r)return!0;e=Gt(t)+1,t=t.parentNode}}function Aa(r,t){let e;for(;!(r==t||!r);r=r.nextSibling){let i=G.get(r);if(!i?.isWidget())return!1;i&&(e||(e=[])).push(i)}if(e)for(let i of e){let s=i.overrideDOMText;if(s?.length)return!1}return!0}class dr{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Oa{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:n,impreciseAnchor:o}=t.docView,l=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=hl(t.docView.tile,e,i,0))){let h=n||o?[]:Ma(t),a=new Sa(h,t);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Pa(h,this.bounds.from)}else{let h=t.observer.selectionRange,a=n&&n.node==h.focusNode&&n.offset==h.focusOffset||!Us(t.contentDOM,h.focusNode)?l.main.head:t.docView.posFromDOM(h.focusNode,h.focusOffset),f=o&&o.node==h.anchorNode&&o.offset==h.anchorOffset||!Us(t.contentDOM,h.anchorNode)?l.main.anchor:t.docView.posFromDOM(h.anchorNode,h.anchorOffset),c=t.viewport;if((k.ios||k.chrome)&&a!=f&&Math.min(a,f)<=l.main.from&&Math.max(a,f)>=l.main.to&&(c.from>0||c.to<t.state.doc.length)){let u=Math.min(a,f),d=Math.max(a,f),p=c.from-u,g=c.to-d;(p==0||p==1||u==0)&&(g==0||g==-1||d==t.state.doc.length)&&(a=0,f=t.state.doc.length)}if(t.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(S.range(f,a));else if(t.lineWrapping&&f==a&&!(l.main.empty&&l.main.head==a)&&t.inputState.lastTouchTime>Date.now()-100){let u=t.coordsAtPos(a,-1),d=0;u&&(d=t.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=S.create([S.cursor(a,d)])}else this.newSel=S.single(f,a)}}}function hl(r,t,e,i){if(r.isComposite()){let s=-1,n=-1,o=-1,l=-1;for(let h=0,a=i,f=i;h<r.children.length;h++){let c=r.children[h],u=a+c.length;if(a<t&&u>e)return hl(c,t,e,a);if(u>=t&&s==-1&&(s=h,n=a),a>e&&c.dom.parentNode==r.dom){o=h,l=f;break}f=u,a=u+c.breakAfter}return{from:n,to:l<0?i+r.length:l,startDOM:(s?r.children[s-1].dom.nextSibling:null)||r.dom.firstChild,endDOM:o<r.children.length&&o>=0?r.children[o].dom:null}}else return r.isText()?{from:i,to:i+r.length,startDOM:r.dom,endDOM:r.dom.nextSibling}:null}function al(r,t){let e,{newSel:i}=t,{state:s}=r,n=s.selection.main,o=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:h}=t.bounds,a=n.from,f=null;(o===8||k.android&&t.text.length<h-l)&&(a=n.to,f="end");let c=s.doc.sliceString(l,h,de),u,d;!n.empty&&n.from>=l&&n.to<=h&&(t.typeOver||c!=t.text)&&c.slice(0,n.from-l)==t.text.slice(0,n.from-l)&&c.slice(n.to-l)==t.text.slice(u=t.text.length-(c.length-(n.to-l)))?e={from:n.from,to:n.to,insert:W.of(t.text.slice(n.from-l,u).split(de))}:(d=fl(c,t.text,a-l,f))&&(k.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==de+de&&d.toB--,e={from:l+d.from,to:l+d.toA,insert:W.of(t.text.slice(d.from,d.toB).split(de))})}else i&&(!r.hasFocus&&s.facet(Et)||Ki(i,n))&&(i=null);if(!e&&!i)return!1;if((k.mac||k.android)&&e&&e.from==e.to&&e.from==n.head-1&&/^\. ?$/.test(e.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=S.single(i.main.anchor-1,i.main.head-1)),e={from:e.from,to:e.to,insert:W.of([e.insert.toString().replace("."," ")])}):s.doc.lineAt(n.from).to<n.to&&r.docView.lineHasWidget(n.to)&&r.inputState.insertingTextAt>Date.now()-50?e={from:n.from,to:n.to,insert:s.toText(r.inputState.insertingText)}:k.chrome&&e&&e.from==e.to&&e.from==n.head&&e.insert.toString()==`
9
9
  `&&r.lineWrapping&&(i&&(i=S.single(i.main.anchor-1,i.main.head-1)),e={from:n.from,to:n.to,insert:W.of([" "])}),e)return Pn(r,e,i,o);if(i&&!Ki(i,n)){let l=!1,h="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(l=!0),h=r.inputState.lastSelectionOrigin,h=="select.pointer"&&(i=ll(s.facet(si).map(a=>a(r)),i))),r.dispatch({selection:i,scrollIntoView:l,userEvent:h}),!0}else return!1}function Pn(r,t,e,i=-1){if(k.ios&&r.inputState.flushIOSKey(t))return!0;let s=r.state.selection.main;if(k.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&r.state.sliceDoc(t.from,s.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&xe(r.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>s.head)&&xe(r.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&xe(r.contentDOM,"Delete",46)))return!0;let n=t.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let o,l=()=>o||(o=Ta(r,t,e));return r.state.facet(Yo).some(h=>h(r,t.from,t.to,n,l))||r.dispatch(l()),!0}function Ta(r,t,e){let i,s=r.state,n=s.selection.main,o=-1;if(t.from==t.to&&t.from<n.from||t.from>n.to){let h=t.from<n.from?-1:1,a=h<0?n.from:n.to,f=Ke(s.facet(si).map(c=>c(r)),a,h);t.from==f&&(o=f)}if(o>-1)i={changes:t,selection:S.cursor(t.from+t.insert.length,-1)};else if(t.from>=n.from&&t.to<=n.to&&t.to-t.from>=(n.to-n.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&r.inputState.composing<0){let h=n.from<t.from?s.sliceDoc(n.from,t.from):"",a=n.to>t.to?s.sliceDoc(t.to,n.to):"";i=s.replaceSelection(r.state.toText(h+t.insert.sliceString(0,void 0,r.state.lineBreak)+a))}else{let h=s.changes(t),a=e&&e.main.to<=h.newLength?e.main:void 0;if(s.selection.ranges.length>1&&(r.inputState.composing>=0||r.inputState.compositionPendingChange)&&t.to<=n.to+10&&t.to>=n.to-10){let f=r.state.sliceDoc(t.from,t.to),c,u=e&&ol(r,e.main.head);if(u){let p=t.insert.length-(t.to-t.from);c={from:u.from,to:u.to-p}}else c=r.state.doc.lineAt(n.head);let d=n.to-t.to;i=s.changeByRange(p=>{if(p.from==n.from&&p.to==n.to)return{changes:h,range:a||p.map(h)};let g=p.to-d,m=g-f.length;if(r.state.sliceDoc(m,g)!=f||g>=c.from&&m<=c.to)return{range:p};let b=s.changes({from:m,to:g,insert:t.insert}),v=p.to-n.to;return{changes:b,range:a?S.range(Math.max(0,a.anchor+v),Math.max(0,a.head+v)):p.map(b)}})}else i={changes:h,selection:a&&s.selection.replaceRange(a)}}let l="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,l+=".compose",r.inputState.compositionFirstChange&&(l+=".start",r.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:l,scrollIntoView:!0})}function fl(r,t,e,i){let s=Math.min(r.length,t.length),n=0;for(;n<s&&r.charCodeAt(n)==t.charCodeAt(n);)n++;if(n==s&&r.length==t.length)return null;let o=r.length,l=t.length;for(;o>0&&l>0&&r.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let h=Math.max(0,n-Math.min(o,l));e-=o+h-n}if(o<n&&r.length<t.length){let h=e<=n&&e>=o?n-e:0;n-=h,l=n+(l-o),o=n}else if(l<n){let h=e<=n&&e>=l?n-e:0;n-=h,o=n+(o-l),l=n}return{from:n,toA:o,toB:l}}function Ma(r){let t=[];if(r.root.activeElement!=r.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:n}=r.observer.selectionRange;return e&&(t.push(new dr(e,i)),(s!=e||n!=i)&&t.push(new dr(s,n))),t}function Pa(r,t){if(r.length==0)return null;let e=r[0].pos,i=r.length==2?r[1].pos:e;return e>-1&&i>-1?S.single(e+t,i+t):null}function Ki(r,t){return t.head==r.main.head&&t.anchor==r.main.anchor}class Da{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,k.safari&&t.contentDOM.addEventListener("input",()=>null),k.gecko&&_a(t.contentDOM.ownerDocument)}handleEvent(t){!Va(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let s of i.observers)s(this.view,e);for(let s of i.handlers){if(e.defaultPrevented)break;if(s(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Ra(t),i=this.handlers,s=this.view.contentDOM;for(let n in e)if(n!="scroll"){let o=!e[n].handlers.length,l=i[n];l&&o!=!l.handlers.length&&(s.removeEventListener(n,this.handleEvent),l=null),l||s.addEventListener(n,this.handleEvent,{passive:o})}for(let n in i)n!="scroll"&&!e[n]&&s.removeEventListener(n,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&ul.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),k.android&&k.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(k.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(cl.some(e=>e.keyCode==t.keyCode)&&!t.ctrlKey||Ea.indexOf(t.key)>-1&&t.ctrlKey)){let e={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};return e.shiftKey&&k.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Ba(this.view.win)&&(e.shiftKey=!1),this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:e},setTimeout(()=>this.flushIOSKey(),50),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let e=this.pendingIOSKey;return!e||this.view.observer.pendingRecords().length||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,xe(this.view.contentDOM,e.key,e.keyCode,e.mods))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:k.safari&&!k.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Ba(r){return r.visualViewport?r.visualViewport.height*r.visualViewport.scale/r.document.documentElement.clientHeight<.85:!1}function pr(r,t){return(e,i)=>{try{return t.call(r,i,e)}catch(s){xt(e.state,s)}}}function Ra(r){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of r){let s=i.spec,n=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(n)for(let l in n){let h=n[l];h&&e(l).handlers.push(pr(i.value,h))}if(o)for(let l in o){let h=o[l];h&&e(l).observers.push(pr(i.value,h))}}for(let i in kt)e(i).handlers.push(kt[i]);for(let i in rt)e(i).observers.push(rt[i]);return t}const cl=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ea="dthko",ul=[16,17,18,20,91,92,224,225],pi=6;function gi(r){return Math.max(0,r)*.7+8}function Na(r,t){return Math.max(Math.abs(r.clientX-t.clientX),Math.abs(r.clientY-t.clientY))}class Ia{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=No(t.contentDOM),this.atoms=t.state.facet(si).map(o=>o(t));let n=t.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(L.allowMultipleSelections)&&La(t,e),this.dragging=Ha(t,e)&&gl(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Na(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,s=0,n=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:n,bottom:l}=this.scrollParents.y.getBoundingClientRect());let h=Mn(this.view);t.clientX-h.left<=s+pi?e=-gi(s-t.clientX):t.clientX+h.right>=o-pi&&(e=gi(t.clientX-o)),t.clientY-h.top<=n+pi?i=-gi(n-t.clientY):t.clientY+h.bottom>=l-pi&&(i=gi(t.clientY-l)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=ll(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function La(r,t){let e=r.state.facet(_o);return e.length?e[0](t):k.mac?t.metaKey:t.ctrlKey}function Wa(r,t){let e=r.state.facet(Go);return e.length?e[0](t):k.mac?!t.altKey:!t.ctrlKey}function Ha(r,t){let{main:e}=r.state.selection;if(e.empty)return!1;let i=Ue(r.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let n=0;n<s.length;n++){let o=s[n];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Va(r,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=r.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=G.get(e))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const kt=Object.create(null),rt=Object.create(null),dl=k.ie&&k.ie_version<15||k.ios&&k.webkit_version<604;function Fa(r){let t=r.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{r.focus(),e.remove(),pl(r,e.value)},50)}function rs(r,t,e){for(let i of r.facet(t))e=i(e,r);return e}function pl(r,t){t=rs(r.state,Cn,t);let{state:e}=r,i,s=1,n=e.toText(t),o=n.lines==e.selection.ranges.length;if(sn!=null&&e.selection.ranges.every(h=>h.empty)&&sn==n.toString()){let h=-1;i=e.changeByRange(a=>{let f=e.doc.lineAt(a.from);if(f.from==h)return{range:a};h=f.from;let c=e.toText((o?n.line(s++).text:t)+e.lineBreak);return{changes:{from:f.from,insert:c},range:S.cursor(a.from+c.length)}})}else o?i=e.changeByRange(h=>{let a=n.line(s++);return{changes:{from:h.from,to:h.to,insert:a.text},range:S.cursor(h.from+a.length)}}):i=e.replaceSelection(n);r.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}rt.scroll=r=>{let t=r.inputState;t.lastScrollTop=r.scrollDOM.scrollTop,t.lastScrollLeft=r.scrollDOM.scrollLeft,k.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};rt.wheel=rt.mousewheel=r=>{r.inputState.lastWheelEvent=Date.now()};kt.keydown=(r,t)=>(r.inputState.setSelectionOrigin("select"),t.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);rt.touchstart=(r,t)=>{let e=r.inputState,i=t.targetTouches[0];e.touchActive=!0,e.lastTouchTime=Date.now(),i&&(e.lastTouchX=i.clientX,e.lastTouchY=i.clientY),e.setSelectionOrigin("select.pointer")};rt.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};rt.touchend=(r,t)=>{r.inputState.touchActive=!1};kt.mousedown=(r,t)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of r.state.facet(Qo))if(e=i(r,t),e)break;if(!e&&t.button==0&&(e=$a(r,t)),e){let i=!r.hasFocus;r.inputState.startMouseSelection(new Ia(r,t,e,i)),i&&r.observer.ignore(()=>{Wo(r.contentDOM);let n=r.root.activeElement;n&&!n.contains(r.contentDOM)&&n.blur()});let s=r.inputState.mouseSelection;if(s)return s.start(t),s.dragging===!1}else r.inputState.setSelectionOrigin("select.pointer");return!1};function gr(r,t,e,i){if(i==1)return S.cursor(t,e);if(i==2)return ma(r.state,t,e);{let s=r.docView.lineAt(t,e),n=r.state.doc.lineAt(s?s.posAtEnd:t),o=s?s.posAtStart:n.from,l=s?s.posAtEnd:n.to;return l<r.state.doc.length&&l==n.to&&l++,S.undirectionalRange(o,l)}}const za=k.ie&&k.ie_version<=11;let mr=null,br=0,wr=0;function gl(r){if(!za)return r.detail;let t=mr,e=wr;return mr=r,wr=Date.now(),br=!t||e>Date.now()-400&&Math.abs(t.clientX-r.clientX)<2&&Math.abs(t.clientY-r.clientY)<2?(br+1)%3:1}function $a(r,t){let e=r.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=gl(t),s=r.state.selection;return{update(n){n.docChanged&&(e.pos=n.changes.mapPos(e.pos),s=s.map(n.changes))},get(n,o,l){let h=r.posAndSideAtCoords({x:n.clientX,y:n.clientY},!1),a,f=gr(r,h.pos,h.assoc,i);if(e.pos!=h.pos&&!o){let c=gr(r,e.pos,e.assoc,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u<f.from?S.range(u,d,f.assoc):S.range(d,u,f.assoc)}return o?s.replaceRange(s.main.extend(f.from,f.to,f.assoc)):l&&i==1&&s.ranges.length>1&&(a=Ka(s,h.pos))?a:l?s.addRange(f):S.create([f])}}}function Ka(r,t){for(let e=0;e<r.ranges.length;e++){let{from:i,to:s}=r.ranges[e];if(i<=t&&s>=t)return S.create(r.ranges.slice(0,e).concat(r.ranges.slice(e+1)),r.mainIndex==e?0:r.mainIndex-(r.mainIndex>e?1:0))}return null}kt.dragstart=(r,t)=>{let{selection:{main:e}}=r.state;if(t.target.draggable){let s=r.docView.tile.nearest(t.target);if(s&&s.isWidget()){let n=s.posAtStart,o=n+s.length;(n>=e.to||o<=e.from)&&(e=S.undirectionalRange(n,o))}}let{inputState:i}=r;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",rs(r.state,An,r.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};kt.dragend=r=>(r.inputState.draggedContent=null,!1);function yr(r,t,e,i){if(e=rs(r.state,Cn,e),!e)return;let s=r.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:n}=r.inputState,o=i&&n&&Wa(r,t)?{from:n.from,to:n.to}:null,l={from:s,insert:e},h=r.state.changes(o?[o,l]:l);r.focus(),r.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),r.inputState.draggedContent=null}kt.drop=(r,t)=>{if(!t.dataTransfer)return!1;if(r.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),s=0,n=()=>{++s==e.length&&yr(r,t,i.filter(o=>o!=null).join(r.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=n,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),n()},l.readAsText(e[o])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return yr(r,t,i,!0),!0}return!1};kt.paste=(r,t)=>{if(r.state.readOnly)return!0;r.observer.flush();let e=dl?null:t.clipboardData;return e?(pl(r,e.getData("text/plain")||e.getData("text/uri-list")),!0):(Fa(r),!1)};function qa(r,t){let e=r.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),r.focus()},50)}function ja(r){let t=[],e=[],i=!1;for(let s of r.selection.ranges)s.empty||(t.push(r.sliceDoc(s.from,s.to)),e.push(s));if(!t.length){let s=-1;for(let{from:n}of r.selection.ranges){let o=r.doc.lineAt(n);o.number>s&&(t.push(o.text),e.push({from:o.from,to:Math.min(r.doc.length,o.to+1)})),s=o.number}i=!0}return{text:rs(r,An,t.join(r.lineBreak)),ranges:e,linewise:i}}let sn=null;kt.copy=kt.cut=(r,t)=>{if(!Fe(r.contentDOM,r.observer.selectionRange))return!1;let{text:e,ranges:i,linewise:s}=ja(r.state);if(!e&&!s)return!1;sn=s?e:null,t.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let n=dl?null:t.clipboardData;return n?(n.clearData(),n.setData("text/plain",e),!0):(qa(r,e),!1)};const ml=Pe.define();function bl(r,t){let e=[];for(let i of r.facet(Xo)){let s=i(r,t);s&&e.push(s)}return e.length?r.update({effects:e,annotations:ml.of(!0)}):null}function wl(r){setTimeout(()=>{let t=r.hasFocus;if(t!=r.inputState.notifiedFocused){let e=bl(r.state,t);e?r.dispatch(e):r.update([])}},10)}rt.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),wl(r)};rt.blur=r=>{r.observer.clearSelectionRange(),wl(r)};rt.compositionstart=rt.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};rt.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,k.chrome&&k.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};rt.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};kt.beforeinput=(r,t)=>{var e,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(r.inputState.insertingText=t.data,r.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&r.observer.editContext){let n=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(n&&o.length){let l=o[0],h=r.posAtDOM(l.startContainer,l.startOffset),a=r.posAtDOM(l.endContainer,l.endOffset);return Pn(r,{from:h,to:a,insert:r.state.toText(n)},null),!0}}let s;if(k.chrome&&k.android&&(s=cl.find(n=>n.inputType==t.inputType))&&(r.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let n=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>n+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return k.ios&&t.inputType=="deleteContentForward"&&r.observer.flushSoon(),k.safari&&t.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>rt.compositionend(r,t),20),!1};const xr=new Set;function _a(r){xr.has(r)||(xr.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const vr=["pre-wrap","normal","pre-line","break-spaces"];let Oe=!1;function kr(){Oe=!1}class Ga{constructor(t){this.lineWrapping=t,this.doc=W.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return vr.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let s=t[i];s<0?i++:this.heightSamples[Math.floor(s*10)]||(e=!0,this.heightSamples[Math.floor(s*10)]=!0)}return e}refresh(t,e,i,s,n,o){let l=vr.indexOf(t)>-1,h=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=n,h){this.heightSamples={};for(let a=0;a<o.length;a++){let f=o[a];f<0?a++:this.heightSamples[Math.floor(f*10)]=!0}}return h}}class Qa{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class bt{constructor(t,e,i,s,n){this.from=t,this.length=e,this.top=i,this.height=s,this._content=n}get type(){return typeof this._content=="number"?ht.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 re?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new bt(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var z=(function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r})(z||(z={}));const Ri=.001;class nt{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Ri&&(Oe=!0),this.height=t)}replace(t,e,i){return nt.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let n=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:h,toA:a,fromB:f,toB:c}=s[l],u=n.lineAt(h,z.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=a?u:n.lineAt(a,z.ByPosNoHeight,i,0,0);for(c+=d.to-a,a=d.to;l>0&&u.from<=s[l-1].toA;)h=s[l-1].fromA,f=s[l-1].fromB,l--,h<u.from&&(u=n.lineAt(h,z.ByPosNoHeight,i,0,0));f+=u.from-h,h=u.from;let p=Dn.build(i.setDoc(o),t,f,c);n=qi(n,n.replace(h,a,p))}return n.updateHeight(i,0)}static empty(){return new ut(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,s=0,n=0;for(;;)if(e==i)if(s>n*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(n>s*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,n-=l.size}else break;else if(s<n){let l=t[e++];l&&(s+=l.size)}else{let l=t[--i];l&&(n+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,i++),new Ya(nt.of(t.slice(0,e)),o,nt.of(t.slice(i)))}}function qi(r,t){return r==t?r:(r.constructor!=t.constructor&&(Oe=!0),t)}nt.prototype.size=1;const Ua=F.replace({});class yl extends nt{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new bt(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,s){return this.spaceAbove&&t<i+this.spaceAbove?new bt(s,0,i,this.spaceAbove,Ua):this.mainBlock(i,s)}lineAt(t,e,i,s,n){let o=this.mainBlock(s,n);return this.spaceAbove?this.blockAt(0,i,s,n).join(o):o}forEachLine(t,e,i,s,n,o){t<=n+this.length&&e>=n&&o(this.lineAt(0,z.ByPos,i,s,n))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ut extends yl{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new bt(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let s=i[0];return i.length==1&&(s instanceof ut||s instanceof Z&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Z?s=new ut(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):nt.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Z extends nt{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,n=s-i+1,o,l=0;if(t.lineWrapping){let h=Math.min(this.height,t.lineHeight*n);o=h/n,this.length>n+1&&(l=(this.height-h)/(this.length-n-1))}else o=this.height/n;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(t,e,i,s){let{firstLine:n,lastLine:o,perLine:l,perChar:h}=this.heightMetrics(e,s);if(e.lineWrapping){let a=s+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),f=e.doc.lineAt(a),c=l+f.length*h,u=Math.max(i,t-c/2);return new bt(f.from,f.length,u,c,0)}else{let a=Math.max(0,Math.min(o-n,Math.floor((t-i)/l))),{from:f,length:c}=e.doc.line(n+a);return new bt(f,c,i+l*a,l,0)}}lineAt(t,e,i,s,n){if(e==z.ByHeight)return this.blockAt(t,i,s,n);if(e==z.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(t);return new bt(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,n),a=i.doc.lineAt(t),f=l+a.length*h,c=a.number-o,u=s+l*c+h*(a.from-n-c);return new bt(a.from,a.length,Math.max(s,Math.min(u,s+this.height-f)),f,0)}forEachLine(t,e,i,s,n,o){t=Math.max(t,n),e=Math.min(e,n+this.length);let{firstLine:l,perLine:h,perChar:a}=this.heightMetrics(i,n);for(let f=t,c=s;f<=e;){let u=i.doc.lineAt(f);if(f==t){let p=u.number-l;c+=h*p+a*(t-n-p)}let d=h+a*u.length;o(new bt(u.from,u.length,c,d,0)),c+=d,f=u.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let n=i[i.length-1];n instanceof Z?i[i.length-1]=new Z(n.length+s):i.push(null,new Z(s-1))}if(t>0){let n=i[0];n instanceof Z?i[0]=new Z(t+n.length):i.unshift(new Z(t-1),null)}return nt.of(i)}decomposeLeft(t,e){e.push(new Z(t-1),null)}decomposeRight(t,e){e.push(null,new Z(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let n=e+this.length;if(s&&s.from<=e+this.length&&s.more){let o=[],l=Math.max(e,s.from),h=-1;for(s.from>e&&o.push(new Z(s.from-e-1).updateHeight(t,e));l<=n&&s.more;){let f=t.doc.lineAt(l).length;o.length&&o.push(null);let c=s.heights[s.index++],u=0;c<0&&(u=-c,c=s.heights[s.index++]),h==-1?h=c:Math.abs(c-h)>=Ri&&(h=-2);let d=new ut(f,c,u);d.outdated=!1,o.push(d),l+=f+1}l<=n&&o.push(null,new Z(n-l).updateHeight(t,l));let a=nt.of(o);return(h<0||Math.abs(a.height-this.height)>=Ri||Math.abs(h-this.heightMetrics(t,e).perLine)>=Ri)&&(Oe=!0),qi(this,a)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Ya extends nt{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,s){let n=i+this.left.height;return t<n?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,n,s+this.left.length+this.break)}lineAt(t,e,i,s,n){let o=s+this.left.height,l=n+this.left.length+this.break,h=e==z.ByHeight?t<o:t<l,a=h?this.left.lineAt(t,e,i,s,n):this.right.lineAt(t,e,i,o,l);if(this.break||(h?a.to<l:a.from>l))return a;let f=e==z.ByPosNoHeight?z.ByPosNoHeight:z.ByPos;return h?a.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,s,n).join(a)}forEachLine(t,e,i,s,n,o){let l=s+this.left.height,h=n+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,s,n,o),e>=h&&this.right.forEachLine(t,e,i,l,h,o);else{let a=this.lineAt(h,z.ByPos,i,s,n);t<a.from&&this.left.forEachLine(t,a.from-1,i,s,n,o),a.to>=t&&a.from<=e&&o(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,l,h,o)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let n=[];t>0&&this.decomposeLeft(t,n);let o=n.length;for(let l of i)n.push(l);if(t>0&&Sr(n,o-1),e<this.length){let l=n.length;this.decomposeRight(e,n),Sr(n,l)}return nt.of(n)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<s&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?nt.of(this.break?[t,null,e]:[t,e]):(this.left=qi(this.left,t),this.right=qi(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,s){let{left:n,right:o}=this,l=e+n.length+this.break,h=null;return s&&s.from<=e+n.length&&s.more?h=n=n.updateHeight(t,e,i,s):n.updateHeight(t,e,i),s&&s.from<=l+o.length&&s.more?h=o=o.updateHeight(t,l,i,s):o.updateHeight(t,l,i),h?this.balanced(n,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Sr(r,t){let e,i;r[t]==null&&(e=r[t-1])instanceof Z&&(i=r[t+1])instanceof Z&&r.splice(t-1,3,new Z(e.length+1+i.length))}const Xa=5;class Dn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let i=Math.min(e,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof ut?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ut(i-this.pos,-1,0)),this.writtenTo=i,e>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new yl(o,s,i)):(o||n||s>=Xa)&&this.addLineDeco(s,n,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new ut(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new Z(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof ut)return t;let e=new ut(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof ut)&&!this.isCovered?this.nodes.push(new ut(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let s of this.nodes)s instanceof ut&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(t,e,i,s){let n=new Dn(i,t);return I.spans(e,i,s,n,0),n.finish(i)}}function Ja(r,t,e){let i=new Za;return I.compare(r,t,e,i,0),i.changes}class Za{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&ye(t,e,this.changes,5)}}function tf(r,t){let e=r.getBoundingClientRect(),i=r.ownerDocument,s=i.defaultView||window,n=Math.max(0,e.left),o=Math.min(s.innerWidth,e.right),l=Math.max(0,e.top),h=Math.min(s.innerHeight,e.bottom);for(let a=r.parentNode;a&&a!=i.body;)if(a.nodeType==1){let f=a,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();n=Math.max(n,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),h=Math.min(a==r.parentNode?s.innerHeight:h,u.bottom)}a=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(a.nodeType==11)a=a.host;else break;return{left:n-e.left,right:Math.max(n,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,h)-(e.top+t)}}function ef(r){let t=r.getBoundingClientRect(),e=r.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function sf(r,t){let e=r.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class ws{constructor(t,e,i,s){this.from=t,this.to=e,this.size=i,this.displaySize=s}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],n=e[i];if(s.from!=n.from||s.to!=n.to||s.size!=n.size)return!1}return!0}draw(t,e){return F.replace({widget:new nf(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class nf extends ti{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class Cr{constructor(t,e){this.view=t,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.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ar,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=_.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(On).some(s=>typeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new Ga(i),this.stateDeco=Or(e),this.heightMap=nt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle.setDoc(e.doc),[new gt(0,0,0,e.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=F.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:n,to:o})=>s>=n&&s<=o)){let{from:n,to:o}=this.lineBlockAt(s);t.push(new mi(n,o))}}return this.viewports=t.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ar:new Bn(this.heightOracle,this.heightMap,this.viewports),t.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,t=>{this.viewportLines.push(Le(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=Or(this.state);let s=t.changedRanges,n=gt.extendWithRanges(s,Ja(i,this.stateDeco,t?t.changes:X.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);kr(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=o||Oe)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let h=n.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let a=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,t.flags|=this.updateForViewport(),(a||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Gh)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?_.RTL:_.LTR;let o=this.heightOracle.mustRefreshForWrapping(n)||this.mustMeasureContent==="refresh",l=e.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let a=0,f=0;if(l.width&&l.height){let{scaleX:T,scaleY:O}=Eo(e,l);(T>.005&&Math.abs(this.scaleX-T)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=T,this.scaleY=O,a|=16,o=h=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let d=No(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Ho(this.scrollParent||t.win);let g=(this.printing?sf:tf)(e,this.paddingTop),m=g.top-this.pixelViewport.top,b=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(h=!0)),!this.inView&&!this.scrollTarget&&!ef(t.dom))return 0;let y=l.width;if((this.contentDOMWidth!=y||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),h){let T=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(T)&&(o=!0),o||s.lineWrapping&&Math.abs(y-this.contentDOMWidth)>s.charWidth){let{lineHeight:O,charWidth:C,textHeight:R}=t.docView.measureTextSize();o=O>0&&s.refresh(n,O,C,R,Math.max(5,y/C),T),o&&(t.docView.minWidth=0,a|=16)}m>0&&b>0?f=Math.max(m,b):m<0&&b<0&&(f=Math.min(m,b)),kr();for(let O of this.viewports){let C=O.from==this.viewport.from?T:t.docView.measureVisibleLineHeights(O);this.heightMap=(o?nt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle,[new gt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Qa(O.from,C))}Oe&&(a|=2)}let P=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return P&&(a&2&&(a|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),a|=this.updateForViewport()),(a&2||P)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),s=this.heightMap,n=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,h=new mi(s.lineAt(o-i*1e3,z.ByHeight,n,0,0).from,s.lineAt(l+(1-i)*1e3,z.ByHeight,n,0,0).to);if(e){let{head:a}=e.range;if(a<h.from||a>h.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=s.lineAt(a,z.ByPos,n,0,0),u;e.y=="center"?u=(c.top+c.bottom)/2-f/2:e.y=="start"||e.y=="nearest"&&a<h.from?u=c.top:u=c.bottom-f,h=new mi(s.lineAt(u-1e3/2,z.ByHeight,n,0,0).from,s.lineAt(u+f+1e3/2,z.ByHeight,n,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new mi(this.heightMap.lineAt(i,z.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,z.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(t,z.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(e,z.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||s<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||n>=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&n<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new ws(e.mapPos(s.from),e.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,n=s>>1,o=s<<1;if(this.defaultTextDirection!=_.LTR&&!i)return[];let l=[],h=(f,c,u,d)=>{if(c-f<n)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let b of g)if(b>f&&b<c){h(f,b-10,u,d),h(b+10,c,u,d);return}let m=of(t,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-f)<n&&Math.abs(b.to-c)<n&&!g.some(v=>b.from<v&&b.to>v));if(!m){if(c<u.to&&e&&i&&e.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=e.moveToLineBoundary(S.cursor(c),!1,!0).head;y>f&&(c=y)}let b=this.gapSize(u,f,c,d),v=i||b<2e6?b:2e6;m=new ws(f,c,b,v)}l.push(m)},a=f=>{if(f.length<o||f.type!=ht.Text)return;let c=rf(f.from,f.to,this.stateDeco);if(c.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,b;if(u!=null){let v=wi(c,u),y=((this.visibleBottom-this.visibleTop)/2+g)/f.height;m=v-y,b=v+y}else m=(this.visibleTop-f.top-g)/f.height,b=(this.visibleBottom-f.top+g)/f.height;d=bi(c,m),p=bi(c,b)}else{let g=c.total*this.heightOracle.charWidth,m=s*this.heightOracle.charWidth,b=0;if(g>2e6)for(let O of t)O.from>=f.from&&O.from<f.to&&O.size!=O.displaySize&&O.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=O.size-O.displaySize);let v=this.pixelViewport.left+b,y=this.pixelViewport.right+b,P,T;if(u!=null){let O=wi(c,u),C=((y-v)/2+m)/g;P=O-C,T=O+C}else P=(v-m)/g,T=(y+m)/g;d=bi(c,P),p=bi(c,T)}d>f.from&&h(f.from,d,f,c),p<f.to&&h(p,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(a):a(f);return l}gapSize(t,e,i,s){let n=wi(s,i)-wi(s,e);return this.heightOracle.lineWrapping?t.height*n:s.total*this.heightOracle.charWidth*n}updateLineGaps(t){ws.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=F.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];I.spans(e,this.viewport.from,this.viewport.to,{span(n,o){i.push({from:n,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let n=0;n<i.length&&!(s&8);n++){let o=this.visibleRanges[n],l=i[n];(o.from!=l.from||o.to!=l.to)&&(s|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Le(this.heightMap.lineAt(t,z.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Le(this.heightMap.lineAt(this.scaler.fromDOM(t),z.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Le(this.heightMap.blockAt(this.scaler.fromDOM(t),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 mi{constructor(t,e){this.from=t,this.to=e}}function rf(r,t,e){let i=[],s=r,n=0;return I.spans(e,r,t,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),n+=o-s),s=l}},20),s<t&&(i.push({from:s,to:t}),n+=t-s),{total:n,ranges:i}}function bi({total:r,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(r*e);for(let s=0;;s++){let{from:n,to:o}=t[s],l=o-n;if(i<=l)return n+i;i-=l}}function wi(r,t){let e=0;for(let{from:i,to:s}of r.ranges){if(t<=s){e+=t-i;break}e+=s-i}return e/r.total}function of(r,t){for(let e of r)if(t(e))return e}const Ar={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};function Or(r){let t=r.facet(is).filter(i=>typeof i!="function"),e=r.facet(Tn).filter(i=>typeof i!="function");return e.length&&t.push(I.join(e)),t}class Bn{constructor(t,e,i){let s=0,n=0,o=0;this.viewports=i.map(({from:l,to:h})=>{let a=e.lineAt(l,z.ByPos,t,0,0).top,f=e.lineAt(h,z.ByPos,t,0,0).bottom;return s+=f-a,{from:l,to:h,top:a,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s);for(let l of this.viewports)l.domTop=o+(l.top-n)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),n=l.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.top)return s+(t-i)*this.scale;if(t<=n.bottom)return n.domTop+(t-n.top);i=n.bottom,s=n.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.domTop)return i+(t-s)/this.scale;if(t<=n.domBottom)return n.top+(t-n.domTop);i=n.bottom,s=n.domBottom}}eq(t){return t instanceof Bn?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to):!1}}function Le(r,t){if(t.scale==1)return r;let e=t.toDOM(r.top),i=t.toDOM(r.bottom);return new bt(r.from,r.length,e,i-e,Array.isArray(r._content)?r._content.map(s=>Le(s,t)):r._content)}const yi=A.define({combine:r=>r.join(" ")}),nn=A.define({combine:r=>r.indexOf(!0)>-1}),rn=jt.newName(),xl=jt.newName(),vl=jt.newName(),kl={"&light":"."+xl,"&dark":"."+vl};function on(r,t,e){return new jt(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return r;if(!e||!e[s])throw new RangeError(`Unsupported selector: ${s}`);return e[s]}):r+" "+i}})}const lf=on("."+rn,{"&":{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":{userSelect:"none",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-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".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"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&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":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) 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"}},kl),hf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ys=k.ie&&k.ie_version<=11;class af{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Ih,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=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(k.ie&&k.ie_version<=11||k.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&k.android&&t.constructor.EDIT_CONTEXT!==!1&&!(k.chrome&&k.chrome_version<126)&&(this.editContext=new cf(t),t.state.facet(Et)&&(t.contentDOM.editContext=this.editContext.editContext)),ys&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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 e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Et)?i.root.activeElement!=this.dom:!Fe(this.dom,s))return;let n=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(n&&n.isWidget()&&n.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(k.ie&&k.ie_version<=11||k.android&&k.chrome)&&!i.state.selection.main.empty&&s.focusNode&&$e(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ue(t.root);if(!e)return!1;let i=k.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&ff(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=Fe(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&Wh(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,hf),ys&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ys&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let s=()=>{let n=this.delayedAndroidKey;n&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=n.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&n.force&&xe(this.dom,n.key,n.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let n of t){let o=this.readMutation(n);o&&(o.typeOver&&(s=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&Fe(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new Oa(this.view,t,e,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=al(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!Ki(this.view.state.selection,e.newSel.main))&&this.view.update([]),s}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let i=Tr(e,t.previousSibling||t.target.previousSibling,-1),s=Tr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Et)!=t.state.facet(Et)&&(t.view.contentDOM.editContext=t.state.facet(Et)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Tr(r,t,e){for(;t;){let i=G.get(t);if(i&&i.parent==r)return i;let s=t.parentNode;t=s!=r.dom?s:e>0?t.nextSibling:t.previousSibling}return null}function Mr(r,t){let e=t.startContainer,i=t.startOffset,s=t.endContainer,n=t.endOffset,o=r.docView.domAtPos(r.state.selection.main.anchor,1);return $e(o.node,o.offset,s,n)&&([e,i,s,n]=[s,n,e,i]),{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:n}}function ff(r,t){if(t.getComposedRanges){let s=t.getComposedRanges(r.root)[0];if(s)return Mr(r,s)}let e=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),e=s.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",i,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",i,!0),e?Mr(r,e):null}class cf{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let s=t.state.selection.main,{anchor:n,head:o}=s,l=this.toEditorPos(i.updateRangeStart),h=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let a=h-l>i.text.length;l==this.from&&n<this.from?l=n:h==this.to&&n>this.to&&(h=n);let f=fl(t.state.sliceDoc(l,h),i.text,(a?s.from:s.to)-l,a?"end":null);if(!f){let u=S.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ki(u,s)||t.dispatch({selection:u,userEvent:"select"});return}let c={from:f.from+l,to:f.toA+l,insert:W.of(i.text.slice(f.from,f.toB).split(`
10
- `))};if((k.mac||k.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:h,insert:W.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Pn(t,c,S.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],n=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let h=t.coordsForChar(o);n=h&&new DOMRect(h.left,h.top,h.right-h.left,h.bottom-h.top)||n||new DOMRect,s.push(n)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let n of i.getTextFormats()){let o=n.underlineStyle,l=n.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let h=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);if(h<a){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(F.mark({attributes:{style:f}}).range(h,a))}}}t.dispatch({effects:tl.of(F.set(s))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let s=Ue(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((n,o,l,h,a)=>{if(i)return;let f=a.length-(o-n);if(s&&o>=s.to)if(s.from==n&&s.to==o&&s.insert.eq(a)){s=this.pendingContextChange=null,e+=f,this.to+=f;return}else s=null,this.revertPending(t.state);if(n+=e,o+=e,o<=this.from)this.from+=f,this.to+=f;else if(n<this.to){if(n<this.from||o>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(o),a.toString()),this.to+=f}e+=f}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class B{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(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(s=>s.forEach(n=>i(n,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Lh(t.parent)||document,this.viewState=new Cr(this,t.state||L.create(t)),t.scrollTo&&t.scrollTo.is(di)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(pe).map(s=>new ds(s));for(let s of this.plugins)s.update(this);this.observer=new af(this),this.inputState=new Da(this),this.inputState.ensureHandlers(this.plugins),this.docView=new cr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof it?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,n=this.state;for(let u of t){if(u.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=u.state}if(this.destroyed){this.viewState.state=n;return}let o=this.hasFocus,l=0,h=null;t.some(u=>u.annotation(ml))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=bl(n,o),h||(l=1));let a=this.observer.delayedAndroidKey,f=null;if(a?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(f=null)):this.observer.clear(),n.facet(L.phrases)!=this.state.facet(L.phrases))return this.setState(n);s=Fi.create(this,n,t),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:g}=this.state.facet(B.cursorScrollMargin);c=new ve(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of u.effects)d.is(di)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=ji.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(Ie)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(yi)!=s.state.facet(yi)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Zs))try{u(s)}catch(d){xt(this.state,d,"update listener")}(h||f)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),f&&!al(this,f)&&a.force&&xe(this.contentDOM,a.key,a.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Cr(this,t),this.plugins=t.facet(pe).map(i=>new ds(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new cr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(pe),i=t.state.facet(pe);if(e!=i){let s=[];for(let n of i){let o=e.indexOf(n);if(o<0)s.push(new ds(n));else{let l=this.plugins[o];l.mustUpdate=t,s.push(l)}}for(let n of this.plugins)n.mustUpdate!=t&&n.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){xt(this.state,i,"doc view update listener")}}}measure(t=!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,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let h=0;;h++){if(o<0){if(Ho(i||this.win))n=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(s);n=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(h>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(p=>{try{return p.read(this)}catch(g){return xt(this.state,g),Pr}}),u=Fi.create(this,this.state,[]),d=!1;u.flags|=a,e?e.flags|=a:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<f.length;p++)if(c[p]!=Pr)try{let g=f[p];g.write&&g.write(c[p],this)}catch(g){xt(this.state,g)}if(d&&this.docView.updateSelection(!0),!u.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 g=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)/this.viewState.scaleY-o/l;if((g>1||g<-1)&&!(k.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+g,i?n<0?i.scrollTop=i.scrollHeight:i.scrollTop+=g:this.win.scrollBy(0,g),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(Zs))h(e)}get themeClasses(){return rn+" "+(this.state.facet(nn)?vl:xl)+" "+this.state.facet(yi)}updateAttrs(){let t=Dr(this,el,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Et)?"true":"false",class:"cm-content",style:`${k.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Dr(this,On,e);let i=this.observer.ignore(()=>{let s=rr(this.contentDOM,this.contentAttrs,e),n=rr(this.dom,this.editorAttrs,t);return s||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let s of i.effects)if(s.is(B.announce)){e&&(this.announceDOM.textContent=""),e=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ie);let t=this.state.facet(B.cspNonce);jt.mount(this.root,this.styleModules.concat(lf).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return bs(this,t,ur(this,t,e,i))}moveByGroup(t,e){return bs(this,t,ur(this,t,e,i=>xa(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return S.cursor(n.side(e,s)+t.from,n.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return ya(this,t,e,i)}moveVertically(t,e,i){return bs(this,t,va(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=en(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),en(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.state.doc.lineAt(t),s=this.bidiSpans(i),n=s[Dt.find(s,t-i.from,-1,e)];return this.docView.coordsAt(t,e,n.dir==_.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Jo)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>uf)return qo(t.length);let e=this.textDirectionAt(t.from),i;for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e&&(n.fresh||Ko(n.isolates,i=hr(this,t))))return n.order;i||(i=hr(this,t));let s=qh(t.text,e,i);return this.bidiCache.push(new ji(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||k.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Wo(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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(t,e={}){var i,s,n,o;return di.of(new ve(typeof t=="number"?S.cursor(t):t,(i=e.y)!==null&&i!==void 0?i:"nearest",(s=e.x)!==null&&s!==void 0?s:"nearest",(n=e.yMargin)!==null&&n!==void 0?n:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return di.of(new ve(S.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return at.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return at.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=jt.newName(),s=[yi.of(i),Ie.of(on(`.${i}`,t))];return e&&e.dark&&s.push(nn.of(!0)),s}static baseTheme(t){return wn.lowest(Ie.of(on("."+rn,t,kl)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&G.get(i)||G.get(t);return((e=s?.root)===null||e===void 0?void 0:e.view)||null}}B.styleModule=Ie;B.inputHandler=Yo;B.clipboardInputFilter=Cn;B.clipboardOutputFilter=An;B.scrollHandler=Zo;B.focusChangeEffect=Xo;B.perLineTextDirection=Jo;B.exceptionSink=Uo;B.updateListener=Zs;B.editable=Et;B.mouseSelectionStyle=Qo;B.dragMovesSelection=Go;B.clickAddsSelectionRange=_o;B.decorations=is;B.blockWrappers=il;B.outerDecorations=Tn;B.atomicRanges=si;B.bidiIsolatedRanges=sl;B.cursorScrollMargin=A.define({combine:r=>{let t=5,e=5;for(let i of r)typeof i=="number"?t=e=i:{x:t,y:e}=i;return{x:t,y:e}}});B.scrollMargins=nl;B.darkTheme=nn;B.cspNonce=A.define({combine:r=>r.length?r[0]:""});B.contentAttributes=On;B.editorAttributes=el;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=U.define();const uf=4096,Pr={};class ji{constructor(t,e,i,s,n,o){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=n,this.order=o}static update(t,e){if(e.empty&&!t.some(n=>n.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:_.LTR;for(let n=Math.max(0,t.length-10);n<t.length;n++){let o=t[n];o.dir==s&&!e.touchesRange(o.from,o.to)&&i.push(new ji(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Dr(r,t,e){for(let i=r.state.facet(t),s=i.length-1;s>=0;s--){let n=i[s],o=typeof n=="function"?n(r):n;o&&vn(o,e)}return e}const df=k.mac?"mac":k.windows?"win":k.linux?"linux":"key";function pf(r,t){const e=r.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let s,n,o,l;for(let h=0;h<e.length-1;++h){const a=e[h];if(/^(cmd|meta|m)$/i.test(a))l=!0;else if(/^a(lt)?$/i.test(a))s=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))t=="mac"?l=!0:n=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(i="Alt-"+i),n&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function xi(r,t,e){return t.altKey&&(r="Alt-"+r),t.ctrlKey&&(r="Ctrl-"+r),t.metaKey&&(r="Meta-"+r),e!==!1&&t.shiftKey&&(r="Shift-"+r),r}const gf=wn.default(B.domEventHandlers({keydown(r,t){return xf(bf(t.state),r,t,"editor")}})),mf=A.define({enables:gf}),Br=new WeakMap;function bf(r){let t=r.facet(mf),e=Br.get(t);return e||Br.set(t,e=yf(t.reduce((i,s)=>i.concat(s),[]))),e}let $t=null;const wf=4e3;function yf(r,t=df){let e=Object.create(null),i=Object.create(null),s=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},n=(o,l,h,a,f)=>{var c,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>pf(b,t));for(let b=1;b<p.length;b++){let v=p.slice(0,b).join(" ");s(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[y=>{let P=$t={view:y,prefix:v,scope:o};return setTimeout(()=>{$t==P&&($t=null)},wf),!0}]})}let g=p.join(" ");s(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});h&&m.run.push(h),a&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of r){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let a of l){let f=e[a]||(e[a]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,ln))}let h=o[t]||o.key;if(h)for(let a of l)n(a,h,o.run,o.preventDefault,o.stopPropagation),o.shift&&n(a,"Shift-"+h,o.shift,o.preventDefault,o.stopPropagation)}return e}let ln=null;function xf(r,t,e,i){ln=t;let s=Ph(t),n=fh(s,0),o=ch(n)==s.length&&s!=" ",l="",h=!1,a=!1,f=!1;$t&&$t.view==e&&$t.scope==i&&(l=$t.prefix+" ",ul.indexOf(t.keyCode)<0&&(a=!0,$t=null));let c=new Set,u=m=>{if(m){for(let b of m.run)if(!c.has(b)&&(c.add(b),b(e)))return m.stopPropagation&&(f=!0),!0;m.preventDefault&&(m.stopPropagation&&(f=!0),a=!0)}return!1},d=r[i],p,g;return d&&(u(d[l+xi(s,t,!o)])?h=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(k.windows&&t.ctrlKey&&t.altKey)&&!(k.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=_t[t.keyCode])&&p!=s?(u(d[l+xi(p,t,!0)])||t.shiftKey&&(g=Ge[t.keyCode])!=s&&g!=p&&u(d[l+xi(g,t,!1)]))&&(h=!0):o&&t.shiftKey&&u(d[l+xi(s,t,!0)])&&(h=!0),!h&&u(d._any)&&(h=!0)),a&&(h=!0),h&&f&&t.stopPropagation(),ln=null,h}function fu(){return kf}const vf=F.line({class:"cm-activeLine"}),kf=at.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let t=-1,e=[];for(let i of r.state.selection.ranges){let s=r.lineBlockAt(i.head);s.from>t&&(e.push(vf.range(s.from)),t=s.from)}return F.set(e)}},{decorations:r=>r.decorations});class Sf extends ti{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?ze(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),s=Ye(e[0],i.direction!="rtl"),n=parseInt(i.lineHeight);return s.bottom-s.top>n*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+n}:s}ignoreEvent(){return!1}}function cu(r){let t=at.fromClass(class{constructor(e){this.view=e,this.placeholder=r?F.set([F.widget({widget:new Sf(r),side:1}).range(0)]):F.none}get decorations(){return this.view.state.doc.length?F.none:this.placeholder}},{decorations:e=>e.decorations});return typeof r=="string"?[t,B.contentAttributes.of({"aria-placeholder":r})]:t}const vi="-10000px";class Sl{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let n=null;this.tooltipViews=this.tooltips.map(o=>n=i(o,n))}update(t,e){var i;let s=t.state.facet(this.facet),n=s.filter(h=>h);if(s===this.input){for(let h of this.tooltipViews)h.update&&h.update(t);return!1}let o=[],l=e?[]:null;for(let h=0;h<n.length;h++){let a=n[h],f=-1;if(a){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==a.create&&(f=c)}if(f<0)o[h]=this.createTooltipView(a,h?o[h-1]:null),l&&(l[h]=!!a.above);else{let c=o[h]=this.tooltipViews[f];l&&(l[h]=e[f]),c.update&&c.update(t)}}}for(let h of this.tooltipViews)o.indexOf(h)<0&&(this.removeTooltipView(h),(i=h.destroy)===null||i===void 0||i.call(h));return e&&(l.forEach((h,a)=>e[a]=h),e.length=l.length),this.input=s,this.tooltips=n,this.tooltipViews=o,!0}}function Cf(r){let t=r.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const xs=A.define({combine:r=>{var t,e,i;return{position:k.ios?"absolute":((t=r.find(s=>s.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=r.find(s=>s.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=r.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Cf}}}),Rr=new WeakMap,Cl=at.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=r.state.facet(xs);this.position=t.position,this.parent=t.parent,this.classes=r.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 Sl(r,Al,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.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 r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(r,this.above);t&&this.observeIntersection();let e=t||r.geometryChanged,i=r.state.facet(xs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(r,t){let e=r.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),r.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",e.dom.appendChild(s)}return e.dom.style.position=this.position,e.dom.style.top=vi,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var r,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(r=i.destroy)===null||r===void 0||r.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(k.safari){let o=n.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!n.offsetParent&&n.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(r=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:r,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Mn(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((n,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(xs).tooltipSpace(this.view),scaleX:r,scaleY:t,makeAbsolute:e}}writeMeasure(r){var t;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:s,scaleY:n}=r,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let h=this.manager.tooltips[l],a=this.manager.tooltipViews[l],{dom:f}=a,c=r.pos[l],u=r.size[l];if(!c||h.clip!==!1&&(c.bottom<=Math.max(e.top,i.top)||c.top>=Math.min(e.bottom,i.bottom)||c.right<Math.max(e.left,i.left)-.1||c.left>Math.min(e.right,i.right)+.1)){f.style.top=vi;continue}let d=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(t=Rr.get(a))!==null&&t!==void 0?t:u.bottom-u.top,b=a.offset||Of,v=this.view.textDirection==_.LTR,y=u.width>i.right-i.left?v?i.left:i.right-u.width:v?Math.max(i.left,Math.min(c.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,c.left-g+(d?14:0)-b.x),i.right-g),P=this.above[l];!h.strictSide&&(P?c.top-m-p-b.y<i.top:c.bottom+m+p+b.y>i.bottom)&&P==i.bottom-c.bottom>c.top-i.top&&(P=this.above[l]=!P);let T=(P?c.top-i.top:i.bottom-c.bottom)-p;if(T<m&&a.resize!==!1){if(T<this.view.defaultLineHeight){f.style.top=vi;continue}Rr.set(a,m),f.style.height=(m=T)/n+"px"}else f.style.height&&(f.style.height="");let O=P?c.top-m-p-b.y:c.bottom+p+b.y,C=y+g;if(a.overlap!==!0)for(let R of o)R.left<C&&R.right>y&&R.top<O+m&&R.bottom>O&&(O=P?R.top-m-2-p:R.bottom+p+2);if(this.position=="absolute"?(f.style.top=(O-r.parent.top)/n+"px",Er(f,(y-r.parent.left)/s)):(f.style.top=O/n+"px",Er(f,y/s)),d){let R=c.left+(v?b.x:-b.x)-(y+14-7);d.style.left=R/s+"px"}a.overlap!==!0&&o.push({left:y,top:O,right:C,bottom:O+m}),f.classList.toggle("cm-tooltip-above",P),f.classList.toggle("cm-tooltip-below",!P),a.positioned&&a.positioned(r.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 r of this.manager.tooltipViews)r.dom.style.top=vi}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Er(r,t){let e=parseInt(r.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(r.style.left=t+"px")}const Af=B.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"}}}),Of={x:0,y:0},Al=A.define({enables:[Cl,Af]}),_i=A.define({combine:r=>r.reduce((t,e)=>t.concat(e),[])});class os{static create(t){return new os(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Sl(t,_i,(e,i)=>this.createHostedView(e,i),e=>e.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(s!==void 0){if(e===void 0)e=s;else if(e!==s)return}}return e}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 Tf=Al.compute([_i],r=>{let t=r.facet(_i);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var i;return(i=e.end)!==null&&i!==void 0?i:e.pos})),create:os.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Mf=A.define();class Pf{constructor(t,e,i,s,n,o){this.view=t,this.source=e,this.field=i,this.locked=s,this.setHover=n,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){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 t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.tile.nearest(e.target);if(!i)return;let s,n=1;if(i.isWidget())s=i.posAtStart;else{if(s=t.posAtCoords(e),s==null)return;let o=t.coordsAtPos(s);if(!o||e.y<o.top||e.y>o.bottom||e.x<o.left-t.defaultCharacterWidth||e.x>o.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(s)).find(a=>a.from<=s&&a.to>=s),h=l&&l.dir==_.RTL?-1:1;n=e.x<o.left?-h:h}this.activateHover(t,s,n)}activateHover(t,e,i,s){let n=this.source(t,e,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let h=Array.isArray(l)?l:[l];s&&this.locked.set(h,s),t.dispatch({effects:this.setHover.of(h)})}};if(n&&"then"in n){let l=this.pending={pos:e};n.then(h=>{this.pending==l&&(this.pending=null,o(h))},h=>xt(t.state,h,"hover tooltip"))}else o(n)}get tooltip(){let t=this.view.plugin(Cl),e=t?t.manager.tooltips.findIndex(i=>i.create==os.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:n}=this;if(s.length&&!this.locked.has(s)&&n&&!Df(n.dom,t)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(e=s[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Bf(this.view,o,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length&&!this.locked.has(e)){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ki=4;function Df(r,t){let{left:e,right:i,top:s,bottom:n}=r.getBoundingClientRect(),o;if(o=r.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),n=Math.max(l.bottom,n)}return t.clientX>=e-ki&&t.clientX<=i+ki&&t.clientY>=s-ki&&t.clientY<=n+ki}function Bf(r,t,e,i,s,n){let o=r.scrollDOM.getBoundingClientRect(),l=r.documentTop+r.documentPadding.top+r.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let h=r.posAtCoords({x:i,y:s},!1);return h>=t&&h<=e}function uu(r,t={}){let e=U.define(),i=new WeakMap,s=Ut.define({create(){return[]},update(o,l){let h=i.get(o);if(o.length&&(t.hideOnChange&&(l.docChanged||l.selection)?o=[]:h&&h(l)?o=[]:t.hideOn&&(o=o.filter(a=>!t.hideOn(l,a)))),l.docChanged&&o.length){let a=[];for(let f of o){let c=l.changes.mapPos(f.pos,-1,ot.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),f);u.pos=c,u.end!=null&&(u.end=l.changes.mapPos(u.end)),a.push(u)}}o=a}for(let a of l.effects)a.is(e)&&(o=a.value,h=void 0),(a.is(Rf)&&!a.value||a.value==s)&&(o=[]);return o.length&&h&&i.set(o,h),o},provide:o=>_i.from(o)});const n=at.define(o=>new Pf(o,r,s,i,e,t.hoverTime||300));return{active:s,extension:[s,n,Mf.of(n),Tf]}}const Rf=U.define(),Nr=A.define({combine(r){let t,e;for(let i of r)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}}),Ef=at.fromClass(class{constructor(r){this.input=r.state.facet(Lr),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(r));let t=r.state.facet(Nr);this.top=new Si(r,!0,t.topContainer),this.bottom=new Si(r,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(r){let t=r.state.facet(Nr);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Si(r.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Si(r.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=r.state.facet(Lr);if(e!=this.input){let i=e.filter(h=>h),s=[],n=[],o=[],l=[];for(let h of i){let a=this.specs.indexOf(h),f;a<0?(f=h(r.view),l.push(f)):(f=this.panels[a],f.update&&f.update(r)),s.push(f),(f.top?n:o).push(f)}this.specs=i,this.panels=s,this.top.sync(n),this.bottom.sync(o);for(let h of l)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let i of this.panels)i.update&&i.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>B.scrollMargins.of(t=>{let e=t.plugin(r);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Si{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,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";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Ir(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Ir(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Ir(r){let t=r.nextSibling;return r.remove(),t}const Lr=A.define({enables:Ef});class he extends ne{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}he.prototype.elementClass="";he.prototype.toDOM=void 0;he.prototype.mapMode=ot.TrackBefore;he.prototype.startSide=he.prototype.endSide=-1;he.prototype.point=!0;const vs=A.define(),Nf=A.define(),Ei=A.define(),Wr=A.define({combine:r=>r.some(t=>t)});function If(r){return[Lf]}const Lf=at.fromClass(class{constructor(r){this.view=r,this.domAfter=null,this.prevViewport=r.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=r.state.facet(Ei).map(t=>new Vr(r,t)),this.fixed=!r.state.facet(Wr);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.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(r){if(this.updateGutters(r)){let t=this.prevViewport,e=r.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}if(r.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(Wr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=r.view.viewport}syncGutters(r){let t=this.dom.nextSibling;r&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let e=I.iter(this.view.state.facet(vs),this.view.viewport.from),i=[],s=this.gutters.map(n=>new Wf(n,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(n.type)){let o=!0;for(let l of n.type)if(l.type==ht.Text&&o){hn(e,i,l.from);for(let h of s)h.line(this.view,l,i);o=!1}else if(l.widget)for(let h of s)h.widget(this.view,l)}else if(n.type==ht.Text){hn(e,i,n.from);for(let o of s)o.line(this.view,n,i)}else if(n.widget)for(let o of s)o.widget(this.view,n);for(let n of s)n.finish();r&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(r){let t=r.startState.facet(Ei),e=r.state.facet(Ei),i=r.docChanged||r.heightChanged||r.viewportChanged||!I.eq(r.startState.facet(vs),r.state.facet(vs),r.view.viewport.from,r.view.viewport.to);if(t==e)for(let s of this.gutters)s.update(r)&&(i=!0);else{i=!0;let s=[];for(let n of e){let o=t.indexOf(n);o<0?s.push(new Vr(this.view,n)):(this.gutters[o].update(r),s.push(this.gutters[o]))}for(let n of this.gutters)n.dom.remove(),s.indexOf(n)<0&&n.destroy();for(let n of s)n.config.side=="after"?this.getDOMAfter().appendChild(n.dom):this.dom.appendChild(n.dom);this.gutters=s}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:r=>B.scrollMargins.of(t=>{let e=t.plugin(r);if(!e||e.gutters.length==0||!e.fixed)return null;let i=e.dom.offsetWidth*t.scaleX,s=e.domAfter?e.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==_.LTR?{left:i,right:s}:{right:i,left:s}})});function Hr(r){return Array.isArray(r)?r:[r]}function hn(r,t,e){for(;r.value&&r.from<=e;)r.from==e&&t.push(r.value),r.next()}class Wf{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=I.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,n=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==s.elements.length){let l=new Ol(t,o,n,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(t,o,n,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];hn(this.cursor,s,e.from),i.length&&(s=s.concat(i));let n=this.gutter.config.lineMarker(t,e,s);n&&s.unshift(n);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let n of t.state.facet(Nf)){let o=n(t,e.widget,e);o&&(s||(s=[])).push(o)}s&&this.addElement(t,e,s)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Vr{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,s=>{let n=s.target,o;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let h=n.getBoundingClientRect();o=(h.top+h.bottom)/2}else o=s.clientY;let l=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,l,s)&&s.preventDefault()});this.markers=Hr(e.markers(t)),e.initialSpacer&&(this.spacer=new Ol(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Hr(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],t);s!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[s])}let i=t.view.viewport;return!I.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Ol{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Hf(this.markers,s)||this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let n=0,o=0;;){let l=o,h=n<e.length?e[n++]:null,a=!1;if(h){let f=h.elementClass;f&&(i+=" "+f);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(h)){l=c,a=!0;break}}else l=this.markers.length;for(;o<l;){let f=this.markers[o++];if(f.toDOM){f.destroy(s);let c=s.nextSibling;s.remove(),s=c}}if(!h)break;h.toDOM&&(a?s=s.nextSibling:this.dom.insertBefore(h.toDOM(t),s)),a&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function Hf(r,t){if(r.length!=t.length)return!1;for(let e=0;e<r.length;e++)if(!r[e].compare(t[e]))return!1;return!0}const Vf=A.define(),Ff=A.define(),ge=A.define({combine(r){return Mo(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let s in e){let n=i[s],o=e[s];i[s]=n?(l,h,a)=>n(l,h,a)||o(l,h,a):o}return i}})}});class ks extends he{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Ss(r,t){return r.state.facet(ge).formatNumber(t,r.state)}const zf=Ei.compute([ge],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Vf)},lineMarker(t,e,i){return i.some(s=>s.toDOM)?null:new ks(Ss(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let s of t.state.facet(Ff)){let n=s(t,e,i);if(n)return n}return null},lineMarkerChange:t=>t.startState.facet(ge)!=t.state.facet(ge),initialSpacer(t){return new ks(Ss(t,Fr(t.state.doc.lines)))},updateSpacer(t,e){let i=Ss(e.view,Fr(e.view.state.doc.lines));return i==t.number?t:new ks(i)},domEventHandlers:r.facet(ge).domEventHandlers,side:"before"}));function du(r={}){return[ge.of(r),If(),zf]}function Fr(r){let t=9;for(;t<r;)t=t*10+9;return t}const Tl=1024;let $f=0;class Cs{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=$f++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ft.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}N.closedBy=new N({deserialize:r=>r.split(" ")});N.openedBy=new N({deserialize:r=>r.split(" ")});N.group=new N({deserialize:r=>r.split(" ")});N.isolate=new N({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});N.contextHash=new N({perNode:!0});N.lookAhead=new N({perNode:!0});N.mounted=new N({perNode:!0});class qe{constructor(t,e,i,s=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=s}static get(t){return t&&t.props&&t.props[N.mounted.id]}}const Kf=Object.create(null);class ft{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):Kf,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new ft(t.name||"",e,t.id,i);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(s)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(N.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return i=>{for(let s=i.prop(N.group),n=-1;n<(s?s.length:0);n++){let o=e[n<0?i.name:s[n]];if(o)return o}}}}ft.none=new ft("",Object.create(null),0,8);class Rn{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let n of t){let o=n(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],h=o[0];h.combine&&h.id in s&&(l=h.combine(s[h.id],l)),s[h.id]=l}}e.push(s?new ft(i.name,s,i.id,i.flags):i)}return new Rn(e)}}const Ci=new WeakMap,zr=new WeakMap;var j;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(j||(j={}));class Y{constructor(t,e,i,s,n){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,n&&n.length){this.props=Object.create(null);for(let[o,l]of n)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=qe.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let s=i.toString();s&&(e&&(e+=","),e+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new fn(this.topNode,t)}cursorAt(t,e=0,i=0){let s=Ci.get(this)||this.topNode,n=new fn(s);return n.moveTo(t,e),Ci.set(this,n._tree),n}get topNode(){return new mt(this,0,0,null)}resolve(t,e=0){let i=Je(Ci.get(this)||this.topNode,t,e,!1);return Ci.set(this,i),i}resolveInner(t,e=0){let i=Je(zr.get(this)||this.topNode,t,e,!0);return zr.set(this,i),i}resolveStack(t,e=0){return _f(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:n=this.length}=t,o=t.mode||0,l=(o&j.IncludeAnonymous)>0;for(let h=this.cursor(o|j.IncludeAnonymous);;){let a=!1;if(h.from<=n&&h.to>=s&&(!l&&h.type.isAnonymous||e(h)!==!1)){if(h.firstChild())continue;a=!0}for(;a&&i&&(l||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.parent())return;a=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:In(ft.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,s)=>new Y(this.type,e,i,s,this.propValues),t.makeTree||((e,i,s)=>new Y(ft.none,e,i,s)))}static build(t){return Gf(t)}}Y.empty=new Y(ft.none,[],[],0);class En{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new En(this.buffer,this.index)}}class Qt{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ft.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],n=s.name;if(/\W/.test(n)&&!s.isError&&(n=JSON.stringify(n)),t+=4,i==t)return n;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return n+"("+o.join(",")+")"}findChild(t,e,i,s,n){let{buffer:o}=this,l=-1;for(let h=t;h!=e&&!(Ml(n,s,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(t,e,i){let s=this.buffer,n=new Uint16Array(e-t),o=0;for(let l=t,h=0;l<e;){n[h++]=s[l++],n[h++]=s[l++]-i;let a=n[h++]=s[l++]-i;n[h++]=s[l++]-t,o=Math.max(o,a)}return new Qt(n,o,this.set)}}function Ml(r,t,e,i){switch(r){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function Je(r,t,e,i){for(var s;r.from==r.to||(e<1?r.from>=t:r.from>t)||(e>-1?r.to<=t:r.to<t);){let o=!i&&r instanceof mt&&r.index<0?null:r.parent;if(!o)return r;r=o}let n=i?0:j.IgnoreOverlays;if(i)for(let o=r,l=o.parent;l;o=l,l=o.parent)o instanceof mt&&o.index<0&&((s=l.enter(t,e,n))===null||s===void 0?void 0:s.from)!=o.from&&(r=l);for(;;){let o=r.enter(t,e,n);if(!o)return r;r=o}}class Pl{cursor(t=0){return new fn(this,t)}getChild(t,e=null,i=null){let s=$r(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return $r(this,t,e,i)}resolve(t,e=0){return Je(this,t,e,!1)}resolveInner(t,e=0){return Je(this,t,e,!0)}matchContext(t){return an(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let s=e.lastChild;if(!s||s.to!=e.to)break;s.type.isError&&s.from==s.to?(i=e,e=s.prevSibling):e=s}return i}get node(){return this}get next(){return this.parent}}class mt extends Pl{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,n=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,a=e>0?l.length:-1;t!=a;t+=e){let f=l[t],c=h[t]+o.from,u;if(!(!(n&j.EnterBracketed&&f instanceof Y&&(u=qe.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!Ml(s,i,c,c+f.length))){if(f instanceof Qt){if(n&j.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,e,i-c,s);if(d>-1)return new qt(new qf(o,f,t,c),null,d)}else if(n&j.IncludeAnonymous||!f.type.isAnonymous||Nn(f)){let d;if(!(n&j.IgnoreMounts)&&(d=qe.get(f))&&!d.overlay)return new mt(d.tree,c,t,o);let p=new mt(f,c,t,o);return n&j.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?f.children.length-1:0,e,i,s,n)}}}if(n&j.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let s;if(!(i&j.IgnoreOverlays)&&(s=qe.get(this._tree))&&s.overlay){let n=t-this.from,o=i&j.EnterBracketed&&s.bracketed;for(let{from:l,to:h}of s.overlay)if((e>0||o?l<=n:l<n)&&(e<0||o?h>=n:h>n))return new mt(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $r(r,t,e,i){let s=r.cursor(),n=[];if(!s.firstChild())return n;if(e!=null){for(let o=!1;!o;)if(o=s.type.is(e),!s.nextSibling())return n}for(;;){if(i!=null&&s.type.is(i))return n;if(s.type.is(t)&&n.push(s.node),!s.nextSibling())return i==null?n:[]}}function an(r,t,e=t.length-1){for(let i=r;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class qf{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class qt extends Pl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new qt(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&j.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new qt(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new qt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new qt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,n=i.buffer[this.index+3];if(n>s){let o=i.buffer[this.index+1];t.push(i.slice(s,n,o)),e.push(0)}return new Y(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Dl(r){if(!r.length)return null;let t=0,e=r[0];for(let n=1;n<r.length;n++){let o=r[n];(o.from>e.from||o.to<e.to)&&(e=o,t=n)}let i=e instanceof mt&&e.index<0?null:e.parent,s=r.slice();return i?s[t]=i:s.splice(t,1),new jf(s,e)}class jf{constructor(t,e){this.heads=t,this.node=e}get next(){return Dl(this.heads)}}function _f(r,t,e){let i=r.resolveInner(t,e),s=null;for(let n=i instanceof mt?i:i.context.parent;n;n=n.parent)if(n.index<0){let o=n.parent;(s||(s=[i])).push(o.resolve(t,e)),n=o}else{let o=qe.get(n.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new mt(o.tree,o.overlay[0].from+n.from,-1,n);(s||(s=[i])).push(Je(l,t,e,!1))}}return s?Dl(s):i}class fn{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~j.EnterBracketed,t instanceof mt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return t?t instanceof mt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&j.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&j.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&j.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(e.findChild(s,this.index,-1,0,4))}else{let s=e.buffer[this.index+3];if(s<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(s.buffer.buffer[n+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let n=e+t,o=t<0?-1:i._tree.children.length;n!=o;n+=t){let l=i._tree.children[n];if(this.mode&j.IncludeAnonymous||l instanceof Qt||!l.type.isAnonymous||Nn(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let s=this.index,n=this.stack.length;n>=0;){for(let o=t;o;o=o._parent)if(o.index==s){if(s==this.index)return o;e=o,i=n+1;break t}s=this.stack[--n]}for(let s=i;s<this.stack.length;s++)e=new qt(this.buffer,e,this.stack[s]);return this.bufferNode=new qt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return an(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,n=this.stack.length-1;s>=0;n--){if(n<0)return an(this._tree,t,s);let o=i[e.buffer[this.stack[n]]];if(!o.isAnonymous){if(t[s]&&t[s]!=o.name)return!1;s--}}return!0}}function Nn(r){return r.children.some(t=>t instanceof Qt||!t.type.isAnonymous||Nn(t))}function Gf(r){var t;let{buffer:e,nodeSet:i,maxBufferLength:s=Tl,reused:n=[],minRepeatType:o=i.types.length}=r,l=Array.isArray(e)?new En(e,e.length):e,h=i.types,a=0,f=0;function c(T,O,C,R,H,E){let{id:D,start:M,end:$,size:K}=l,J=f,Ht=a;if(K<0)if(l.next(),K==-1){let Bt=n[D];C.push(Bt),R.push(M-T);return}else if(K==-3){a=D;return}else if(K==-4){f=D;return}else throw new RangeError(`Unrecognized record size: ${K}`);let De=h[D],ni,Yt,Wn=M-T;if($-M<=s&&(Yt=m(l.pos-O,H))){let Bt=new Uint16Array(Yt.size-Yt.skip),dt=l.pos-Yt.size,St=Bt.length;for(;l.pos>dt;)St=b(Yt.start,Bt,St);ni=new Qt(Bt,$-Yt.start,i),Wn=Yt.start-T}else{let Bt=l.pos-K;l.next();let dt=[],St=[],Xt=D>=o?D:-1,fe=0,ri=$;for(;l.pos>Bt;)Xt>=0&&l.id==Xt&&l.size>=0?(l.end<=ri-s&&(p(dt,St,M,fe,l.end,ri,Xt,J,Ht),fe=dt.length,ri=l.end),l.next()):E>2500?u(M,Bt,dt,St):c(M,Bt,dt,St,Xt,E+1);if(Xt>=0&&fe>0&&fe<dt.length&&p(dt,St,M,fe,M,ri,Xt,J,Ht),dt.reverse(),St.reverse(),Xt>-1&&fe>0){let Hn=d(De,Ht);ni=In(De,dt,St,0,dt.length,0,$-M,Hn,Hn)}else ni=g(De,dt,St,$-M,J-$,Ht)}C.push(ni),R.push(Wn)}function u(T,O,C,R){let H=[],E=0,D=-1;for(;l.pos>O;){let{id:M,start:$,end:K,size:J}=l;if(J>4)l.next();else{if(D>-1&&$<D)break;D<0&&(D=K-s),H.push(M,$,K),E++,l.next()}}if(E){let M=new Uint16Array(E*4),$=H[H.length-2];for(let K=H.length-3,J=0;K>=0;K-=3)M[J++]=H[K],M[J++]=H[K+1]-$,M[J++]=H[K+2]-$,M[J++]=J;C.push(new Qt(M,H[2]-$,i)),R.push($-T)}}function d(T,O){return(C,R,H)=>{let E=0,D=C.length-1,M,$;if(D>=0&&(M=C[D])instanceof Y){if(!D&&M.type==T&&M.length==H)return M;($=M.prop(N.lookAhead))&&(E=R[D]+M.length+$)}return g(T,C,R,H,E,O)}}function p(T,O,C,R,H,E,D,M,$){let K=[],J=[];for(;T.length>R;)K.push(T.pop()),J.push(O.pop()+C-H);T.push(g(i.types[D],K,J,E-H,M-E,$)),O.push(H-C)}function g(T,O,C,R,H,E,D){if(E){let M=[N.contextHash,E];D=D?[M].concat(D):[M]}if(H>25){let M=[N.lookAhead,H];D=D?[M].concat(D):[M]}return new Y(T,O,C,R,D)}function m(T,O){let C=l.fork(),R=0,H=0,E=0,D=C.end-s,M={size:0,start:0,skip:0};t:for(let $=C.pos-T;C.pos>$;){let K=C.size;if(C.id==O&&K>=0){M.size=R,M.start=H,M.skip=E,E+=4,R+=4,C.next();continue}let J=C.pos-K;if(K<0||J<$||C.start<D)break;let Ht=C.id>=o?4:0,De=C.start;for(C.next();C.pos>J;){if(C.size<0)if(C.size==-3||C.size==-4)Ht+=4;else break t;else C.id>=o&&(Ht+=4);C.next()}H=De,R+=K,E+=Ht}return(O<0||R==T)&&(M.size=R,M.start=H,M.skip=E),M.size>4?M:void 0}function b(T,O,C){let{id:R,start:H,end:E,size:D}=l;if(l.next(),D>=0&&R<o){let M=C;if(D>4){let $=l.pos-(D-4);for(;l.pos>$;)C=b(T,O,C)}O[--C]=M,O[--C]=E-T,O[--C]=H-T,O[--C]=R}else D==-3?a=R:D==-4&&(f=R);return C}let v=[],y=[];for(;l.pos>0;)c(r.start||0,r.bufferStart||0,v,y,-1,0);let P=(t=r.length)!==null&&t!==void 0?t:v.length?y[0]+v[0].length:0;return new Y(h[r.topID],v.reverse(),y.reverse(),P)}const Kr=new WeakMap;function Ni(r,t){if(!r.isAnonymous||t instanceof Qt||t.type!=r)return 1;let e=Kr.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=r||!(i instanceof Y)){e=1;break}e+=Ni(r,i)}Kr.set(t,e)}return e}function In(r,t,e,i,s,n,o,l,h){let a=0;for(let p=i;p<s;p++)a+=Ni(r,t[p]);let f=Math.ceil(a*1.5/8),c=[],u=[];function d(p,g,m,b,v){for(let y=m;y<b;){let P=y,T=g[y],O=Ni(r,p[y]);for(y++;y<b;y++){let C=Ni(r,p[y]);if(O+C>=f)break;O+=C}if(y==P+1){if(O>f){let C=p[P];d(C.children,C.positions,0,C.children.length,g[P]+v);continue}c.push(p[P])}else{let C=g[y-1]+p[y-1].length-T;c.push(In(r,p,g,P,y,T,C,null,h))}u.push(T+v-n)}}return d(t,e,i,s,0),(l||h)(c,u,o)}class se{constructor(t,e,i,s,n=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(n?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let s=[new se(0,t.length,t,0,!1,i)];for(let n of e)n.to>t.length&&s.push(n);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],n=1,o=t.length?t[0]:null;for(let l=0,h=0,a=0;;l++){let f=l<e.length?e[l]:null,c=f?f.fromA:1e9;if(c-h>=i)for(;o&&o.from<c;){let u=o;if(h>=u.from||c<=u.to||a){let d=Math.max(u.from,h)-a,p=Math.min(u.to,c)-a;u=d>=p?null:new se(d,p,u.tree,u.offset+a,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=n<t.length?t[n++]:null}if(!f)break;h=f.toA,a=f.toA-f.toB}return s}}class Bl{startParse(t,e,i){return typeof t=="string"&&(t=new Qf(t)),i=i?i.length?i.map(s=>new Cs(s.from,s.to)):[new Cs(0,0)]:[new Cs(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let n=s.advance();if(n)return n}}}class Qf{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new N({perNode:!0});var qr={};class Gi{constructor(t,e,i,s,n,o,l,h,a,f=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=n,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=a,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new Gi(t,[],e,i,i,0,[],0,s?new jr(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=t&65535,{parser:n}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=n.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){s<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,s,!0),this.reducePos),s<n.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let h=this.stack.length-(i-1)*3-(t&262144?6:0),a=h?this.stack[h-2]:this.p.ranges[0].from;s<n.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let f=this.reducePos-a;f>=2e3&&!(!((e=this.p.parser.nodeSet.types[s])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=f));let c=h?this.stack[h-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<n.minRepeatTerm||t&131072){let d=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,a,d,u+4,!0)}if(t&262144)this.state=this.stack[h];else{let d=this.stack[h-3];this.state=n.getGoto(d,s,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(s,a)}storeNode(t,e,i,s=4,n=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(e==i)return;if(this.buffer[o-2]>=e){this.buffer[o-2]=i;return}}}if(!n||this.pos==i)this.buffer.push(t,e,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let h=o;h>0&&this.buffer[h-2]>i;h-=4)if(this.buffer[h-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(t,e,i,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let n=t,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(n,1);!l&&(s>i||e<=o.maxNode)&&(this.reducePos=s),this.pushState(n,l?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){t&65536?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new Gi(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Uf(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let n=0,o;n<e.length;n+=2)(o=e[n+1])!=this.state&&this.p.parser.hasAction(o,t)&&s.push(e[n],o);if(this.stack.length<120)for(let n=0;s.length<8&&n<e.length;n+=2){let o=e[n+1];s.some((l,h)=>h&1&&l==o)||s.push(e[n],o)}e=s}let i=[];for(let s=0;s<e.length&&i.length<4;s+=2){let n=e[s+1];if(n==this.state)continue;let o=this.split();o.pushState(n,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[s],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,n=this.stack.length-i*3;if(n<0||t.getGoto(this.stack[n],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,n)=>{if(!e.includes(s))return e.push(s),t.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-n;if(l>1){let h=o&65535,a=this.stack.length-l*3;if(a>=0&&t.getGoto(this.stack[a],h,!1)>=0)return l<<19|65536|h}}else{let l=i(o,n+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new jr(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class jr{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Uf{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}}class Qi{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Qi(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Qi(this.stack,this.pos,this.index)}}function Ai(r,t=Uint16Array){if(typeof r!="string")return r;let e=null;for(let i=0,s=0;i<r.length;){let n=0;for(;;){let o=r.charCodeAt(i++),l=!1;if(o==126){n=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),n+=h,l)break;n*=46}e?e[s++]=n:e=new t(n)}return e}class Ii{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const _r=new Ii;class Yf{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_r,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,n=this.pos+t;for(;n<i.from;){if(!s)return null;let o=this.ranges[--s];n-=i.from-o.to,i=o}for(;e<0?n>i.to:n>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];n+=o.from-i.to,i=o}return n}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e<this.chunk.length)i=this.pos+t,s=this.chunk.charCodeAt(e);else{let n=this.resolveOffset(t,1);if(n==null)return-1;if(i=n,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=_r,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class ke{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Xf(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}ke.prototype.contextual=ke.prototype.fallback=ke.prototype.extend=!1;ke.prototype.fallback=ke.prototype.extend=!1;function Xf(r,t,e,i,s,n){let o=0,l=1<<i,{dialect:h}=e.p.parser;t:for(;(l&r[o])!=0;){let a=r[o+1];for(let d=o+3;d<a;d+=2)if((r[d+1]&l)>0){let p=r[d];if(h.allows(p)&&(t.token.value==-1||t.token.value==p||Jf(p,t.token.value,s,n))){t.acceptToken(p);break}}let f=t.next,c=0,u=r[o+2];if(t.next<0&&u>c&&r[a+u*3-3]==65535){o=r[a+u*3-1];continue t}for(;c<u;){let d=c+u>>1,p=a+d+(d<<1),g=r[p],m=r[p+1]||65536;if(f<g)u=d;else if(f>=m)c=d+1;else{o=r[p+2],t.advance();continue t}}break}}function Gr(r,t,e){for(let i=t,s;(s=r[i])!=65535;i++)if(s==e)return i-t;return-1}function Jf(r,t,e,i){let s=Gr(e,i,t);return s<0||Gr(e,i,r)<s}const ct=typeof process<"u"&&qr&&/\bparse\b/.test(qr.LOG);let As=null;function Qr(r,t,e){let i=r.cursor(j.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(r.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:r.length}}class Zf{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Qr(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Qr(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],s=this.index[e];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[s],o=this.start[e]+i.positions[s];if(o>t)return this.nextStart=o,null;if(n instanceof Y){if(o==t){if(o<this.safeFrom)return null;let l=o+n.length;if(l<=this.safeTo){let h=n.prop(N.lookAhead);if(!h||l+h<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}}class tc{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new Ii)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:n}=s,o=s.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,h=0;for(let a=0;a<n.length;a++){if((1<<a&o)==0)continue;let f=n[a],c=this.tokens[a];if(!(i&&!f.fallback)&&((f.contextual||c.start!=t.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,t),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(h=Math.max(c.lookAhead,h)),c.value!=0)){let u=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!f.extend&&(i=c,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return h&&t.setLookAhead(h),!i&&t.pos==this.stream.end&&(i=new Ii,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new Ii,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:n}=i.p;for(let o=0;o<n.specialized.length;o++)if(n.specialized[o]==t.value){let l=n.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?t.value=l>>1:t.extended=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let n=0;n<s;n+=3)if(this.actions[n]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:n}=t,{parser:o}=t.p,{data:l}=o;for(let h=0;h<2;h++)for(let a=o.stateSlot(n,h?2:1);;a+=3){if(l[a]==65535)if(l[a+1]==1)a=Rt(l,a+2);else{s==0&&l[a+1]==2&&(s=this.putAction(Rt(l,a+2),e,i,s));break}l[a]==e&&(s=this.putAction(Rt(l,a+1),e,i,s))}return s}}class ec{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Yf(e,s),this.tokens=new tc(t,this.stream),this.topTerm=t.top[1];let{from:n}=s[0];this.stacks=[Gi.start(this,t.top[0],n)],this.fragments=i.length&&this.stream.end-n>t.bufferLength*4?new Zf(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],s,n;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{s||(s=[],n=[]),s.push(l);let h=this.tokens.getMainToken(l);n.push(h.value,h.end)}}break}}if(!i.length){let o=s&&sc(s);if(o)return ct&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ct&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,n,i);if(o)return ct&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let a=i[h];if(l.sameState(a)||l.buffer.length>500&&a.buffer.length>500)if((l.score-a.score||l.buffer.length-a.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let s=t.pos,{parser:n}=this,o=ct?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,f=a?t.curContext.hash:0;for(let c=this.fragments.nodeAt(s);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?n.getGoto(t.state,c.type.id):-1;if(u>-1&&c.length&&(!a||(c.prop(N.contextHash)||0)==f))return t.useNode(c,u),ct&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(c.type.id)})`),!0;if(!(c instanceof Y)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof Y&&c.positions[0]==0)c=d;else break}}let l=n.stateSlot(t.state,4);if(l>0)return t.reduce(l),ct&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let h=this.tokens.getActions(t);for(let a=0;a<h.length;){let f=h[a++],c=h[a++],u=h[a++],d=a==h.length||!i,p=d?t:t.split(),g=this.tokens.mainToken;if(p.apply(f,c,g?g.start:p.pos,u),ct&&console.log(o+this.stackID(p)+` (via ${(f&65536)==0?"shift":`reduce of ${n.getName(f&65535)}`} for ${n.getName(c)} @ ${s}${p==t?"":", split"})`),d)return!0;p.pos>s?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Ur(t,e),!0}}runRecovery(t,e,i){let s=null,n=!1;for(let o=0;o<t.length;o++){let l=t[o],h=e[o<<1],a=e[(o<<1)+1],f=ct?this.stackID(l)+" -> ":"";if(l.deadEnd&&(n||(n=!0,l.restart(),ct&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;d<10&&c.forceReduce()&&(ct&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)ct&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(h))ct&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(a==l.pos&&(a++,h=0),l.recoverByDelete(h,a),ct&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),Ur(l,i)):(!s||s.score<c.score)&&(s=c)}return s}stackToTree(t){return t.close(),Y.build({buffer:Qi.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(As||(As=new WeakMap)).get(t);return e||As.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function Ur(r,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==r.pos&&i.sameState(r)){t[e].score<r.score&&(t[e]=r);return}}t.push(r)}class ic{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}}class Ui extends Bl{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),s=[];for(let l=0;l<e.length;l++)s.push([]);function n(l,h,a){s[l].push([h,h.deserialize(String(a))])}if(t.nodeProps)for(let l of t.nodeProps){let h=l[0];typeof h=="string"&&(h=N[h]);for(let a=1;a<l.length;){let f=l[a++];if(f>=0)n(f,h,l[a++]);else{let c=l[a+-f];for(let u=-f;u>0;u--)n(l[a++],h,c);a++}}}this.nodeSet=new Rn(e.map((l,h)=>ft.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:s[h],top:i.indexOf(h)>-1,error:h==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(h)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=Tl;let o=Ai(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Yr),this.states=Ai(t.states,Uint32Array),this.data=Ai(t.stateData),this.goto=Ai(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new ke(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new ec(this,t,e,i);for(let n of this.wrappers)s=n(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return-1;for(let n=s[e+1];;){let o=s[n++],l=o&1,h=s[n++];if(l&&i)return h;for(let a=n+(o>>1);n<a;n++)if(s[n]==t)return h;if(l)return-1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let n=this.stateSlot(t,s?2:1),o;;n+=3){if((o=i[n])==65535)if(i[n+1]==1)o=i[n=Rt(i,n+2)];else{if(i[n+1]==2)return Rt(i,n+2);break}if(o==e||o==0)return Rt(i,n+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let n=this.stateSlot(t,1);s==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Rt(this.data,n+2);else break;s=e(Rt(this.data,n+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Rt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];e.some((n,o)=>o&1&&n==s)||e.push(this.data[i],s)}}return e}configure(t){let e=Object.assign(Object.create(Ui.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let s=t.tokenizers.find(n=>n.from==i);return s?s.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let n=t.specializers.find(l=>l.from==i.external);if(!n)return i;let o=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[s]=Yr(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let o=e.indexOf(n);o>=0&&(i[o]=!0)}let s=null;for(let n=0;n<e.length;n++)if(!i[n])for(let o=this.dialects[e[n]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new ic(t,i,s)}static deserialize(t){return new Ui(t)}}function Rt(r,t){return r[t]|r[t+1]<<16}function sc(r){let t=null;for(let e of r){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function Yr(r){if(r.external){let t=r.extend?1:0;return(e,i)=>r.external(e,i)<<1|t}return r.get}let nc=0;class pt{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=nc++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof pt&&(e=t),e?.base)throw new Error("Can not derive from a modified tag");let s=new pt(i,[],null,[]);if(s.set.push(s),e)for(let n of e.set)s.set.push(n);return s}static defineModifier(t){let e=new Yi(t);return i=>i.modified.indexOf(e)>-1?i:Yi.get(i.base||i,i.modified.concat(e).sort((s,n)=>s.id-n.id))}}let rc=0;class Yi{constructor(t){this.name=t,this.instances=[],this.id=rc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&oc(e,l.modified));if(i)return i;let s=[],n=new pt(t.name,s,t,e);for(let l of e)l.instances.push(n);let o=lc(e);for(let l of t.set)if(!l.modified.length)for(let h of o)s.push(Yi.get(l,h));return n}}function oc(r,t){return r.length==t.length&&r.every((e,i)=>e==t[i])}function lc(r){let t=[[]];for(let e=0;e<r.length;e++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(r[e]));return t.sort((e,i)=>i.length-e.length)}function Rl(r){let t=Object.create(null);for(let e in r){let i=r[e];Array.isArray(i)||(i=[i]);for(let s of e.split(" "))if(s){let n=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(n.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let h=n.length-1,a=n[h];if(!a)throw new RangeError("Invalid path: "+s);let f=new Ze(i,o,h>0?n.slice(0,h):null);t[a]=f.sort(t[a])}}return El.add(t)}const El=new N({combine(r,t){let e,i,s;for(;r||t;){if(!r||t&&r.depth>=t.depth?(s=t,t=t.next):(s=r,r=r.next),e&&e.mode==s.mode&&!s.context&&!e.context)continue;let n=new Ze(s.tags,s.mode,s.context);e?e.next=n:i=n,e=n}return i}});class Ze{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}Ze.empty=new Ze([],2,null);function Nl(r,t){let e=Object.create(null);for(let n of r)if(!Array.isArray(n.tag))e[n.tag.id]=n.class;else for(let o of n.tag)e[o.id]=n.class;let{scope:i,all:s=null}=t||{};return{style:n=>{let o=s;for(let l of n)for(let h of l.set){let a=e[h.id];if(a){o=o?o+" "+a:a;break}}return o},scope:i}}function hc(r,t){let e=null;for(let i of r){let s=i.style(t);s&&(e=e?e+" "+s:s)}return e}function ac(r,t,e,i=0,s=r.length){let n=new fc(i,Array.isArray(t)?t:[t],e);n.highlightRange(r.cursor(),i,s,"",n.highlighters),n.flush(s)}class fc{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,n){let{type:o,from:l,to:h}=t;if(l>=i||h<=e)return;o.isTop&&(n=this.highlighters.filter(d=>!d.scope||d.scope(o)));let a=s,f=cc(t)||Ze.empty,c=hc(n,f.tags);if(c&&(a&&(a+=" "),a+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,l),a),f.opaque)return;let u=t.tree&&t.tree.prop(N.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=t.firstChild();for(let m=0,b=l;;m++){let v=m<u.overlay.length?u.overlay[m]:null,y=v?v.from+l:h,P=Math.max(e,b),T=Math.min(i,y);if(P<T&&g)for(;t.from<T&&(this.highlightRange(t,P,T,s,n),this.startSpan(Math.min(T,t.to),a),!(t.to>=y||!t.nextSibling())););if(!v||y>i)break;b=v.to+l,b>e&&(this.highlightRange(d.cursor(),Math.max(e,v.from+l),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),a))}g&&t.parent()}else if(t.firstChild()){u&&(s="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,n),this.startSpan(Math.min(i,t.to),a)}while(t.nextSibling());t.parent()}}}function cc(r){let t=r.type.prop(El);for(;t&&t.context&&!r.matchContext(t.context);)t=t.next;return t||null}const x=pt.define,Oi=x(),Vt=x(),Xr=x(Vt),Jr=x(Vt),Ft=x(),Ti=x(Ft),Os=x(Ft),Tt=x(),Jt=x(Tt),At=x(),Ot=x(),cn=x(),Ee=x(cn),Mi=x(),w={comment:Oi,lineComment:x(Oi),blockComment:x(Oi),docComment:x(Oi),name:Vt,variableName:x(Vt),typeName:Xr,tagName:x(Xr),propertyName:Jr,attributeName:x(Jr),className:x(Vt),labelName:x(Vt),namespace:x(Vt),macroName:x(Vt),literal:Ft,string:Ti,docString:x(Ti),character:x(Ti),attributeValue:x(Ti),number:Os,integer:x(Os),float:x(Os),bool:x(Ft),regexp:x(Ft),escape:x(Ft),color:x(Ft),url:x(Ft),keyword:At,self:x(At),null:x(At),atom:x(At),unit:x(At),modifier:x(At),operatorKeyword:x(At),controlKeyword:x(At),definitionKeyword:x(At),moduleKeyword:x(At),operator:Ot,derefOperator:x(Ot),arithmeticOperator:x(Ot),logicOperator:x(Ot),bitwiseOperator:x(Ot),compareOperator:x(Ot),updateOperator:x(Ot),definitionOperator:x(Ot),typeOperator:x(Ot),controlOperator:x(Ot),punctuation:cn,separator:x(cn),bracket:Ee,angleBracket:x(Ee),squareBracket:x(Ee),paren:x(Ee),brace:x(Ee),content:Tt,heading:Jt,heading1:x(Jt),heading2:x(Jt),heading3:x(Jt),heading4:x(Jt),heading5:x(Jt),heading6:x(Jt),contentSeparator:x(Tt),list:x(Tt),quote:x(Tt),emphasis:x(Tt),strong:x(Tt),link:x(Tt),monospace:x(Tt),strikethrough:x(Tt),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Mi,documentMeta:x(Mi),annotation:x(Mi),processingInstruction:x(Mi),definition:pt.defineModifier("definition"),constant:pt.defineModifier("constant"),function:pt.defineModifier("function"),standard:pt.defineModifier("standard"),local:pt.defineModifier("local"),special:pt.defineModifier("special")};for(let r in w){let t=w[r];t instanceof pt&&(t.name=r)}Nl([{tag:w.link,class:"tok-link"},{tag:w.heading,class:"tok-heading"},{tag:w.emphasis,class:"tok-emphasis"},{tag:w.strong,class:"tok-strong"},{tag:w.keyword,class:"tok-keyword"},{tag:w.atom,class:"tok-atom"},{tag:w.bool,class:"tok-bool"},{tag:w.url,class:"tok-url"},{tag:w.labelName,class:"tok-labelName"},{tag:w.inserted,class:"tok-inserted"},{tag:w.deleted,class:"tok-deleted"},{tag:w.literal,class:"tok-literal"},{tag:w.string,class:"tok-string"},{tag:w.number,class:"tok-number"},{tag:[w.regexp,w.escape,w.special(w.string)],class:"tok-string2"},{tag:w.variableName,class:"tok-variableName"},{tag:w.local(w.variableName),class:"tok-variableName tok-local"},{tag:w.definition(w.variableName),class:"tok-variableName tok-definition"},{tag:w.special(w.variableName),class:"tok-variableName2"},{tag:w.definition(w.propertyName),class:"tok-propertyName tok-definition"},{tag:w.typeName,class:"tok-typeName"},{tag:w.namespace,class:"tok-namespace"},{tag:w.className,class:"tok-className"},{tag:w.macroName,class:"tok-macroName"},{tag:w.propertyName,class:"tok-propertyName"},{tag:w.operator,class:"tok-operator"},{tag:w.comment,class:"tok-comment"},{tag:w.meta,class:"tok-meta"},{tag:w.invalid,class:"tok-invalid"},{tag:w.punctuation,class:"tok-punctuation"}]);const uc=Rl({String:w.string,Number:w.number,"True False":w.bool,PropertyName:w.propertyName,Null:w.null,", :":w.separator,"[ ]":w.squareBracket,"{ }":w.brace}),dc=Ui.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[uc],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});var Ts;const me=new N;function pc(r){return A.define({combine:r?t=>t.concat(r):void 0})}const gc=new N;class vt{constructor(t,e,i=[],s=""){this.data=t,this.name=s,L.prototype.hasOwnProperty("tree")||Object.defineProperty(L.prototype,"tree",{get(){return ae(this)}}),this.parser=e,this.extension=[Me.of(this),L.languageData.of((n,o,l)=>{let h=Zr(n,o,l),a=h.type.prop(me);if(!a)return[];let f=n.facet(a),c=h.type.prop(gc);if(c){let u=h.resolve(o-h.from,l);for(let d of c)if(d.test(u,n)){let p=n.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(t,e,i=-1){return Zr(t,e,i).type.prop(me)==this.data}findRegions(t){let e=t.facet(Me);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(n,o)=>{if(n.prop(me)==this.data){i.push({from:o,to:o+n.length});return}let l=n.prop(N.mounted);if(l){if(l.tree.prop(me)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+n.length});return}else if(l.overlay){let h=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<n.children.length;h++){let a=n.children[h];a instanceof Y&&s(a,n.positions[h]+o)}};return s(ae(t),0),i}get allowsNesting(){return!0}}vt.setState=U.define();function Zr(r,t,e){let i=r.facet(Me),s=ae(r).topNode;if(!i||i.allowsNesting)for(let n=s;n;n=n.enter(t,e,j.ExcludeBuffers|j.EnterBracketed))n.type.isTop&&(s=n);return s}class Xi extends vt{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=pc(t.languageData);return new Xi(e,t.parser.configure({props:[me.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new Xi(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ae(r){let t=r.field(vt.state,!1);return t?t.tree:Y.empty}class mc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Ne=null;class Ji{constructor(t,e,i=[],s,n,o,l,h){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Ji(t,e,[],Y.empty,0,i,[],null)}startParse(){return this.parser.startParse(new mc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=Y.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(se.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(se.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Ne;Ne=this;try{return t()}finally{Ne=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=to(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:n,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let h=[];if(t.iterChangedRanges((a,f,c,u)=>h.push({fromA:a,toA:f,fromB:c,toB:u})),i=se.applyChanges(i,h),s=Y.empty,n=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let a of this.skipped){let f=t.mapPos(a.from,1),c=t.mapPos(a.to,-1);f<c&&l.push({from:f,to:c})}}}return new Ji(this.parser,e,i,s,n,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:n}=this.skipped[i];s<t.to&&n>t.from&&(this.fragments=to(this.fragments,s,n),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Bl{createParse(e,i,s){let n=s[0].from,o=s[s.length-1].to;return{parsedPos:n,advance(){let h=Ne;if(h){for(let a of s)h.tempSkipped.push(a);t&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,t]):t)}return this.parsedPos=o,new Y(ft.none,[],[],o-n)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return Ne}}function to(r,t,e){return se.applyChanges(r,[{fromA:t,toA:e,fromB:t,toB:e}])}class Te{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Te(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Ji.create(t.facet(Me).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Te(i)}}vt.state=Ut.define({create:Te.init,update(r,t){for(let e of t.effects)if(e.is(vt.setState))return e.value;return t.startState.facet(Me)!=t.state.facet(Me)?Te.init(t.state):r.apply(t)}});let Il=r=>{let t=setTimeout(()=>r(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Il=r=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(r,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Ms=typeof navigator<"u"&&(!((Ts=navigator.scheduling)===null||Ts===void 0)&&Ts.isInputPending)?()=>navigator.scheduling.isInputPending():null,bc=at.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(vt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(vt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Il(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,n=i.field(vt.state);if(n.tree==n.context.tree&&n.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Ms?Math.max(25,t.timeRemaining()-5):1e9),l=n.context.treeLen<s&&i.doc.length>s+1e3,h=n.context.work(()=>Ms&&Ms()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:vt.setState.of(new Te(n.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>xt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Me=A.define({combine(r){return r.length?r[0]:null},enables:r=>[vt.state,bc,B.contentAttributes.compute([r],t=>{let e=t.facet(r);return e&&e.name?{"data-language":e.name}:{}})]});class wc{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const yc=A.define(),Ll=A.define({combine:r=>{if(!r.length)return" ";let t=r[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return t}});function xc(r){let t=r.facet(Ll);return t.charCodeAt(0)==9?r.tabSize*t.length:t.length}function vc(r,t){let e="",i=r.tabSize,s=r.facet(Ll)[0];if(s==" "){for(;t>=i;)e+=" ",t-=i;s=" "}for(let n=0;n<t;n++)e+=s;return e}function kc(r,t){r instanceof L&&(r=new Wl(r));for(let i of r.state.facet(yc)){let s=i(r,t);if(s!==void 0)return s}let e=ae(r.state);return e.length>=t?Sc(r,e,t):null}class Wl{constructor(t,e={}){this.state=t,this.options=e,this.unit=xc(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:n}=this.options;return s!=null&&s>=i.from&&s<=i.to?n&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.countColumn(i,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(n+=o-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return Ch(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let o=n(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Hl=new N;function Sc(r,t,e){let i=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=i.node){let n=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)n.push(o);for(let o=n.length-1;o>=0;o--)i={node:n[o],next:i}}return Vl(i,r,e)}function Vl(r,t,e){for(let i=r;i;i=i.next){let s=Ac(i.node);if(s)return s(Ln.create(t,e,i))}return 0}function Cc(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function Ac(r){let t=r.type.prop(Hl);if(t)return t;let e=r.firstChild,i;if(e&&(i=e.type.prop(N.closedBy))){let s=r.lastChild,n=s&&i.indexOf(s.name)>-1;return o=>Pc(o,!0,1,void 0,n&&!Cc(o)?s.from:void 0)}return r.parent==null?Oc:null}function Oc(){return 0}class Ln extends Wl{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Ln(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Tc(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Vl(this.context.next,this.base,this.pos)}}function Tc(r,t){for(let e=t;e;e=e.parent)if(r==e)return!0;return!1}function Mc(r){let t=r.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let s=r.options.simulateBreak,n=r.state.doc.lineAt(e.from),o=s==null||s<=n.from?n.to:Math.min(n.to,s);for(let l=e.to;;){let h=t.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped){if(h.from>=o)return null;let a=/^ */.exec(n.text.slice(e.to-n.from))[0].length;return{from:e.from,to:e.to+a}}l=h.to}}function Pc(r,t,e,i,s){let n=r.textAfter,o=n.match(/^\s*/)[0].length,l=i&&n.slice(o,o+i.length)==i||s==r.pos+o,h=Mc(r);return h?l?r.column(h.from):r.column(h.to):r.baseIndent+(l?0:r.unit*e)}function eo({except:r,units:t=1}={}){return e=>{let i=r&&r.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const Dc=200;function gu(){return L.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let t=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!t.length)return r;let e=r.newDoc,{head:i}=r.newSelection.main,s=e.lineAt(i);if(i>s.from+Dc)return r;let n=e.sliceString(s.from,i);if(!t.some(a=>a.test(n)))return r;let{state:o}=r,l=-1,h=[];for(let{head:a}of o.selection.ranges){let f=o.doc.lineAt(a);if(f.from==l)continue;l=f.from;let c=kc(o,f.from);if(c==null)continue;let u=/^\s*/.exec(f.text)[0],d=vc(o,c);u!=d&&h.push({from:f.from,to:f.from+u.length,insert:d})}return h.length?[r,{changes:h,sequential:!0}]:r})}const Bc=new N;function Rc(r){let t=r.firstChild,e=r.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?r.to:e.from}:null}class ls{constructor(t,e){this.specs=t;let i;function s(l){let h=jt.newName();return(i||(i=Object.create(null)))["."+h]=l,h}const n=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof vt?l=>l.prop(me)==o.data:o?l=>l==o:void 0,this.style=Nl(t.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:n}).style,this.module=i?new jt(i):null,this.themeType=e.themeType}static define(t,e){return new ls(t,e||{})}}const un=A.define(),Fl=A.define({combine(r){return r.length?[r[0]]:null}});function Ps(r){let t=r.facet(un);return t.length?t:r.facet(Fl)}function Ec(r,t){let e=[Ic],i;return r instanceof ls&&(r.module&&e.push(B.styleModule.of(r.module)),i=r.themeType),t?.fallback?e.push(Fl.of(r)):i?e.push(un.computeN([B.darkTheme],s=>s.facet(B.darkTheme)==(i=="dark")?[r]:[])):e.push(un.of(r)),e}class Nc{constructor(t){this.markCache=Object.create(null),this.tree=ae(t.state),this.decorations=this.buildDeco(t,Ps(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=ae(t.state),i=Ps(t.state),s=i!=Ps(t.startState),{viewport:n}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!s&&e.type==this.tree.type&&o>=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return F.none;let i=new we;for(let{from:s,to:n}of t.visibleRanges)ac(this.tree,e,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=F.mark({class:h})))},s,n);return i.finish()}}const Ic=wn.high(at.fromClass(Nc,{decorations:r=>r.decorations})),Lc=ls.define([{tag:w.meta,color:"#404740"},{tag:w.link,textDecoration:"underline"},{tag:w.heading,textDecoration:"underline",fontWeight:"bold"},{tag:w.emphasis,fontStyle:"italic"},{tag:w.strong,fontWeight:"bold"},{tag:w.strikethrough,textDecoration:"line-through"},{tag:w.keyword,color:"#708"},{tag:[w.atom,w.bool,w.url,w.contentSeparator,w.labelName],color:"#219"},{tag:[w.literal,w.inserted],color:"#164"},{tag:[w.string,w.deleted],color:"#a11"},{tag:[w.regexp,w.escape,w.special(w.string)],color:"#e40"},{tag:w.definition(w.variableName),color:"#00f"},{tag:w.local(w.variableName),color:"#30a"},{tag:[w.typeName,w.namespace],color:"#085"},{tag:w.className,color:"#167"},{tag:[w.special(w.variableName),w.macroName],color:"#256"},{tag:w.definition(w.propertyName),color:"#00c"},{tag:w.comment,color:"#940"},{tag:w.invalid,color:"#f00"}]),Wc=B.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),zl=1e4,$l="()[]{}",Kl=A.define({combine(r){return Mo(r,{afterCursor:!0,brackets:$l,maxScanDistance:zl,renderMatch:Fc})}}),Hc=F.mark({class:"cm-matchingBracket"}),Vc=F.mark({class:"cm-nonmatchingBracket"});function Fc(r){let t=[],e=r.matched?Hc:Vc;return t.push(e.range(r.start.from,r.start.to)),r.end&&t.push(e.range(r.end.from,r.end.to)),t}function io(r){let t=[],e=r.facet(Kl);for(let i of r.selection.ranges){if(!i.empty)continue;let s=Pi(r,i.head,-1,e)||i.head>0&&Pi(r,i.head-1,1,e)||e.afterCursor&&(Pi(r,i.head,1,e)||i.head<r.doc.length&&Pi(r,i.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,r)))}return F.set(t,!0)}const zc=at.fromClass(class{constructor(r){this.paused=!1,this.decorations=io(r.state)}update(r){(r.docChanged||r.selectionSet||this.paused)&&(r.view.composing?(this.decorations=this.decorations.map(r.changes),this.paused=!0):(this.decorations=io(r.state),this.paused=!1))}},{decorations:r=>r.decorations}),$c=[zc,Wc];function mu(r={}){return[Kl.of(r),$c]}const Kc=new N;function dn(r,t,e){let i=r.prop(t<0?N.openedBy:N.closedBy);if(i)return i;if(r.name.length==1){let s=e.indexOf(r.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function pn(r){let t=r.type.prop(Kc);return t?t(r.node):r}function Pi(r,t,e,i={}){let s=i.maxScanDistance||zl,n=i.brackets||$l,o=ae(r),l=o.resolveInner(t,e);for(let h=l;h;h=h.parent){let a=dn(h.type,e,n);if(a&&h.from<h.to){let f=pn(h);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return qc(r,t,e,h,f,a,n)}}return jc(r,t,e,o,l.type,s,n)}function qc(r,t,e,i,s,n,o){let l=i.parent,h={from:s.from,to:s.to},a=0,f=l?.cursor();if(f&&(e<0?f.childBefore(i.from):f.childAfter(i.to)))do if(e<0?f.to<=i.from:f.from>=i.to){if(a==0&&n.indexOf(f.type.name)>-1&&f.from<f.to){let c=pn(f);return{start:h,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(dn(f.type,e,o))a++;else if(dn(f.type,-e,o)){if(a==0){let c=pn(f);return{start:h,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}a--}}while(e<0?f.prevSibling():f.nextSibling());return{start:h,matched:!1}}function jc(r,t,e,i,s,n,o){if(e<0?!t:t==r.doc.length)return null;let l=e<0?r.sliceDoc(t-1,t):r.sliceDoc(t,t+1),h=o.indexOf(l);if(h<0||h%2==0!=e>0)return null;let a={from:e<0?t-1:t,to:e>0?t+1:t},f=r.doc.iterRange(t,e>0?r.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=n;){let d=f.value;e<0&&(u+=d.length);let p=t+u*e;for(let g=e>0?0:d.length-1,m=e>0?d.length:-1;g!=m;g+=e){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==e>0)c++;else{if(c==1)return{start:a,end:{from:p+g,to:p+g+1},matched:b>>1==h>>1};c--}}e>0&&(u+=d.length)}return f.done?{start:a,matched:!1}:null}const _c=Object.create(null),so=[ft.none],no=[],ro=Object.create(null),Gc=Object.create(null);for(let[r,t]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"]])Gc[r]=Qc(_c,t);function Ds(r,t){no.indexOf(r)>-1||(no.push(r),console.warn(t))}function Qc(r,t){let e=[];for(let l of t.split(" ")){let h=[];for(let a of l.split(".")){let f=r[a]||w[a];f?typeof f=="function"?h.length?h=h.map(f):Ds(a,`Modifier ${a} used at start of tag`):h.length?Ds(a,`Tag ${a} used as modifier`):h=Array.isArray(f)?f:[f]:Ds(a,`Unknown highlighting tag ${a}`)}for(let a of h)e.push(a)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+e.map(l=>l.id),n=ro[s];if(n)return n.id;let o=ro[s]=ft.define({id:so.length,name:i,props:[Rl({[i]:e})]});return so.push(o),o.id}_.RTL,_.LTR;const Uc=Xi.define({name:"json",parser:dc.configure({props:[Hl.add({Object:eo({except:/^\s*\}/}),Array:eo({except:/^\s*\]/})}),Bc.add({"Object Array":Rc})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Yc(){return new wc(Uc)}var Xc=Zi("<!> 已复制",1),Jc=Zi("<!> 复制",1),Zc=Zi('<div class="border-t bg-background/60 svelte-e020de" style="--cm-bg: transparent;" role="img"></div>'),tu=Zi('<div class="overflow-hidden rounded-lg border bg-muted/40 svelte-e020de"><div class="flex items-center gap-1 svelte-e020de"><button type="button" class="flex min-w-0 flex-1 items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><!> <span class="ml-auto font-mono text-[10px] text-muted-foreground/70"> </span></button> <button type="button" class="flex shrink-0 items-center gap-1 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" title="复制全部内容"><!></button></div> <!></div>');function bu(r,t){_l(t,!0);let e=Yl(t,"label",3,"载荷"),i=oi(!1),s=oi(!1),n=oi(void 0),o=oi(void 0);const l=zn(()=>Zl(t.value));async function h(){try{await navigator.clipboard.writeText(q(l)),ce(s,!0),setTimeout(()=>ce(s,!1),1500)}catch{}}Gl(()=>{if(!q(o)&&q(i)&&q(n)){const u=L.create({doc:q(l),extensions:[L.readOnly.of(!0),B.editable.of(!1),Ec(Lc,{fallback:!0}),Yc(),B.lineWrapping]});ce(o,new B({state:u,parent:q(n)}),!0)}else q(o)&&q(l)!==q(o).state.doc.toString()&&q(o).dispatch({changes:{from:0,to:q(o).state.doc.length,insert:q(l)}})}),jl(()=>{q(o)?.destroy(),ce(o,void 0)});var a=gn(),f=We(a);{var c=u=>{var d=tu(),p=li(d),g=li(p),m=li(g);{let E=zn(()=>Xl("size-3.5 shrink-0 transition-transform",q(i)&&"rotate-90"));eh(m,{get class(){return q(E)},"aria-hidden":"true"})}var b=hi(m),v=hi(b),y=Ul(v);ai(g);var P=hi(g,2),T=li(P);{var O=E=>{var D=Xc(),M=We(D);th(M,{class:"size-3.5 text-emerald-600","aria-hidden":"true"}),Kn(),te(E,D)},C=E=>{var D=Jc(),M=We(D);ih(M,{class:"size-3.5","aria-hidden":"true"}),Kn(),te(E,D)};hs(T,E=>{q(s)?E(O):E(C,-1)})}ai(P),ai(p);var R=hi(p,2);{var H=E=>{var D=Zc();Jl(D,M=>ce(n,M),()=>q(n)),$n(()=>qn(D,"aria-label",`${e()} 内容`)),te(E,D)};hs(R,E=>{q(i)&&E(H)})}ai(d),$n(()=>{qn(g,"aria-expanded",q(i)),Vn(b,` ${e()??""} `),Vn(y,`${q(l).length??""} 字符`)}),Fn("click",g,()=>ce(i,!q(i))),Fn("click",P,()=>{h()}),te(u,d)};hs(f,u=>{q(l)&&u(c)})}te(r,a),Ql()}ql(["click"]);export{Pe as A,cu as B,bu as C,_ as D,B as E,A as F,Yc as G,eh as H,Wl as I,N,we as R,Ut as S,it as T,at as V,ti as W,S as a,U as b,Mo as c,X as d,It as e,Ch as f,kc as g,W as h,vc as i,wt as j,xc as k,Ll as l,Pi as m,F as n,Lr as o,uu as p,xt as q,L as r,ae as s,du as t,fu as u,mf as v,mu as w,gu as x,Ec as y,Lc as z};
10
+ `))};if((k.mac||k.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:h,insert:W.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Pn(t,c,S.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],n=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let h=t.coordsForChar(o);n=h&&new DOMRect(h.left,h.top,h.right-h.left,h.bottom-h.top)||n||new DOMRect,s.push(n)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let n of i.getTextFormats()){let o=n.underlineStyle,l=n.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let h=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);if(h<a){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(F.mark({attributes:{style:f}}).range(h,a))}}}t.dispatch({effects:tl.of(F.set(s))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let s=Ue(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((n,o,l,h,a)=>{if(i)return;let f=a.length-(o-n);if(s&&o>=s.to)if(s.from==n&&s.to==o&&s.insert.eq(a)){s=this.pendingContextChange=null,e+=f,this.to+=f;return}else s=null,this.revertPending(t.state);if(n+=e,o+=e,o<=this.from)this.from+=f,this.to+=f;else if(n<this.to){if(n<this.from||o>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(o),a.toString()),this.to+=f}e+=f}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class B{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(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(s=>s.forEach(n=>i(n,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Lh(t.parent)||document,this.viewState=new Cr(this,t.state||L.create(t)),t.scrollTo&&t.scrollTo.is(di)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(pe).map(s=>new ds(s));for(let s of this.plugins)s.update(this);this.observer=new af(this),this.inputState=new Da(this),this.inputState.ensureHandlers(this.plugins),this.docView=new cr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof it?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,n=this.state;for(let u of t){if(u.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=u.state}if(this.destroyed){this.viewState.state=n;return}let o=this.hasFocus,l=0,h=null;t.some(u=>u.annotation(ml))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=bl(n,o),h||(l=1));let a=this.observer.delayedAndroidKey,f=null;if(a?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(f=null)):this.observer.clear(),n.facet(L.phrases)!=this.state.facet(L.phrases))return this.setState(n);s=Fi.create(this,n,t),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:g}=this.state.facet(B.cursorScrollMargin);c=new ve(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of u.effects)d.is(di)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=ji.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(Ie)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(yi)!=s.state.facet(yi)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Zs))try{u(s)}catch(d){xt(this.state,d,"update listener")}(h||f)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),f&&!al(this,f)&&a.force&&xe(this.contentDOM,a.key,a.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Cr(this,t),this.plugins=t.facet(pe).map(i=>new ds(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new cr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(pe),i=t.state.facet(pe);if(e!=i){let s=[];for(let n of i){let o=e.indexOf(n);if(o<0)s.push(new ds(n));else{let l=this.plugins[o];l.mustUpdate=t,s.push(l)}}for(let n of this.plugins)n.mustUpdate!=t&&n.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){xt(this.state,i,"doc view update listener")}}}measure(t=!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,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let h=0;;h++){if(o<0){if(Ho(i||this.win))n=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(s);n=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(h>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(p=>{try{return p.read(this)}catch(g){return xt(this.state,g),Pr}}),u=Fi.create(this,this.state,[]),d=!1;u.flags|=a,e?e.flags|=a:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<f.length;p++)if(c[p]!=Pr)try{let g=f[p];g.write&&g.write(c[p],this)}catch(g){xt(this.state,g)}if(d&&this.docView.updateSelection(!0),!u.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 g=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)/this.viewState.scaleY-o/l;if((g>1||g<-1)&&!(k.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+g,i?n<0?i.scrollTop=i.scrollHeight:i.scrollTop+=g:this.win.scrollBy(0,g),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(Zs))h(e)}get themeClasses(){return rn+" "+(this.state.facet(nn)?vl:xl)+" "+this.state.facet(yi)}updateAttrs(){let t=Dr(this,el,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Et)?"true":"false",class:"cm-content",style:`${k.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Dr(this,On,e);let i=this.observer.ignore(()=>{let s=rr(this.contentDOM,this.contentAttrs,e),n=rr(this.dom,this.editorAttrs,t);return s||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let s of i.effects)if(s.is(B.announce)){e&&(this.announceDOM.textContent=""),e=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ie);let t=this.state.facet(B.cspNonce);jt.mount(this.root,this.styleModules.concat(lf).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return bs(this,t,ur(this,t,e,i))}moveByGroup(t,e){return bs(this,t,ur(this,t,e,i=>xa(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return S.cursor(n.side(e,s)+t.from,n.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return ya(this,t,e,i)}moveVertically(t,e,i){return bs(this,t,va(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=en(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),en(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.state.doc.lineAt(t),s=this.bidiSpans(i),n=s[Dt.find(s,t-i.from,-1,e)];return this.docView.coordsAt(t,e,n.dir==_.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Jo)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>uf)return qo(t.length);let e=this.textDirectionAt(t.from),i;for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e&&(n.fresh||Ko(n.isolates,i=hr(this,t))))return n.order;i||(i=hr(this,t));let s=qh(t.text,e,i);return this.bidiCache.push(new ji(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||k.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Wo(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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(t,e={}){var i,s,n,o;return di.of(new ve(typeof t=="number"?S.cursor(t):t,(i=e.y)!==null&&i!==void 0?i:"nearest",(s=e.x)!==null&&s!==void 0?s:"nearest",(n=e.yMargin)!==null&&n!==void 0?n:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return di.of(new ve(S.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return at.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return at.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=jt.newName(),s=[yi.of(i),Ie.of(on(`.${i}`,t))];return e&&e.dark&&s.push(nn.of(!0)),s}static baseTheme(t){return wn.lowest(Ie.of(on("."+rn,t,kl)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&G.get(i)||G.get(t);return((e=s?.root)===null||e===void 0?void 0:e.view)||null}}B.styleModule=Ie;B.inputHandler=Yo;B.clipboardInputFilter=Cn;B.clipboardOutputFilter=An;B.scrollHandler=Zo;B.focusChangeEffect=Xo;B.perLineTextDirection=Jo;B.exceptionSink=Uo;B.updateListener=Zs;B.editable=Et;B.mouseSelectionStyle=Qo;B.dragMovesSelection=Go;B.clickAddsSelectionRange=_o;B.decorations=is;B.blockWrappers=il;B.outerDecorations=Tn;B.atomicRanges=si;B.bidiIsolatedRanges=sl;B.cursorScrollMargin=A.define({combine:r=>{let t=5,e=5;for(let i of r)typeof i=="number"?t=e=i:{x:t,y:e}=i;return{x:t,y:e}}});B.scrollMargins=nl;B.darkTheme=nn;B.cspNonce=A.define({combine:r=>r.length?r[0]:""});B.contentAttributes=On;B.editorAttributes=el;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=U.define();const uf=4096,Pr={};class ji{constructor(t,e,i,s,n,o){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=n,this.order=o}static update(t,e){if(e.empty&&!t.some(n=>n.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:_.LTR;for(let n=Math.max(0,t.length-10);n<t.length;n++){let o=t[n];o.dir==s&&!e.touchesRange(o.from,o.to)&&i.push(new ji(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Dr(r,t,e){for(let i=r.state.facet(t),s=i.length-1;s>=0;s--){let n=i[s],o=typeof n=="function"?n(r):n;o&&vn(o,e)}return e}const df=k.mac?"mac":k.windows?"win":k.linux?"linux":"key";function pf(r,t){const e=r.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let s,n,o,l;for(let h=0;h<e.length-1;++h){const a=e[h];if(/^(cmd|meta|m)$/i.test(a))l=!0;else if(/^a(lt)?$/i.test(a))s=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))t=="mac"?l=!0:n=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(i="Alt-"+i),n&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function xi(r,t,e){return t.altKey&&(r="Alt-"+r),t.ctrlKey&&(r="Ctrl-"+r),t.metaKey&&(r="Meta-"+r),e!==!1&&t.shiftKey&&(r="Shift-"+r),r}const gf=wn.default(B.domEventHandlers({keydown(r,t){return xf(bf(t.state),r,t,"editor")}})),mf=A.define({enables:gf}),Br=new WeakMap;function bf(r){let t=r.facet(mf),e=Br.get(t);return e||Br.set(t,e=yf(t.reduce((i,s)=>i.concat(s),[]))),e}let $t=null;const wf=4e3;function yf(r,t=df){let e=Object.create(null),i=Object.create(null),s=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},n=(o,l,h,a,f)=>{var c,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>pf(b,t));for(let b=1;b<p.length;b++){let v=p.slice(0,b).join(" ");s(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[y=>{let P=$t={view:y,prefix:v,scope:o};return setTimeout(()=>{$t==P&&($t=null)},wf),!0}]})}let g=p.join(" ");s(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});h&&m.run.push(h),a&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of r){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let a of l){let f=e[a]||(e[a]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,ln))}let h=o[t]||o.key;if(h)for(let a of l)n(a,h,o.run,o.preventDefault,o.stopPropagation),o.shift&&n(a,"Shift-"+h,o.shift,o.preventDefault,o.stopPropagation)}return e}let ln=null;function xf(r,t,e,i){ln=t;let s=Ph(t),n=fh(s,0),o=ch(n)==s.length&&s!=" ",l="",h=!1,a=!1,f=!1;$t&&$t.view==e&&$t.scope==i&&(l=$t.prefix+" ",ul.indexOf(t.keyCode)<0&&(a=!0,$t=null));let c=new Set,u=m=>{if(m){for(let b of m.run)if(!c.has(b)&&(c.add(b),b(e)))return m.stopPropagation&&(f=!0),!0;m.preventDefault&&(m.stopPropagation&&(f=!0),a=!0)}return!1},d=r[i],p,g;return d&&(u(d[l+xi(s,t,!o)])?h=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(k.windows&&t.ctrlKey&&t.altKey)&&!(k.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=_t[t.keyCode])&&p!=s?(u(d[l+xi(p,t,!0)])||t.shiftKey&&(g=Ge[t.keyCode])!=s&&g!=p&&u(d[l+xi(g,t,!1)]))&&(h=!0):o&&t.shiftKey&&u(d[l+xi(s,t,!0)])&&(h=!0),!h&&u(d._any)&&(h=!0)),a&&(h=!0),h&&f&&t.stopPropagation(),ln=null,h}function au(){return kf}const vf=F.line({class:"cm-activeLine"}),kf=at.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let t=-1,e=[];for(let i of r.state.selection.ranges){let s=r.lineBlockAt(i.head);s.from>t&&(e.push(vf.range(s.from)),t=s.from)}return F.set(e)}},{decorations:r=>r.decorations});class Sf extends ti{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?ze(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),s=Ye(e[0],i.direction!="rtl"),n=parseInt(i.lineHeight);return s.bottom-s.top>n*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+n}:s}ignoreEvent(){return!1}}function fu(r){let t=at.fromClass(class{constructor(e){this.view=e,this.placeholder=r?F.set([F.widget({widget:new Sf(r),side:1}).range(0)]):F.none}get decorations(){return this.view.state.doc.length?F.none:this.placeholder}},{decorations:e=>e.decorations});return typeof r=="string"?[t,B.contentAttributes.of({"aria-placeholder":r})]:t}const vi="-10000px";class Sl{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let n=null;this.tooltipViews=this.tooltips.map(o=>n=i(o,n))}update(t,e){var i;let s=t.state.facet(this.facet),n=s.filter(h=>h);if(s===this.input){for(let h of this.tooltipViews)h.update&&h.update(t);return!1}let o=[],l=e?[]:null;for(let h=0;h<n.length;h++){let a=n[h],f=-1;if(a){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==a.create&&(f=c)}if(f<0)o[h]=this.createTooltipView(a,h?o[h-1]:null),l&&(l[h]=!!a.above);else{let c=o[h]=this.tooltipViews[f];l&&(l[h]=e[f]),c.update&&c.update(t)}}}for(let h of this.tooltipViews)o.indexOf(h)<0&&(this.removeTooltipView(h),(i=h.destroy)===null||i===void 0||i.call(h));return e&&(l.forEach((h,a)=>e[a]=h),e.length=l.length),this.input=s,this.tooltips=n,this.tooltipViews=o,!0}}function Cf(r){let t=r.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const xs=A.define({combine:r=>{var t,e,i;return{position:k.ios?"absolute":((t=r.find(s=>s.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=r.find(s=>s.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=r.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Cf}}}),Rr=new WeakMap,Cl=at.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=r.state.facet(xs);this.position=t.position,this.parent=t.parent,this.classes=r.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 Sl(r,Al,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.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 r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(r,this.above);t&&this.observeIntersection();let e=t||r.geometryChanged,i=r.state.facet(xs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(r,t){let e=r.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),r.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",e.dom.appendChild(s)}return e.dom.style.position=this.position,e.dom.style.top=vi,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var r,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(r=i.destroy)===null||r===void 0||r.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(k.safari){let o=n.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!n.offsetParent&&n.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(r=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:r,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Mn(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((n,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(xs).tooltipSpace(this.view),scaleX:r,scaleY:t,makeAbsolute:e}}writeMeasure(r){var t;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:s,scaleY:n}=r,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let h=this.manager.tooltips[l],a=this.manager.tooltipViews[l],{dom:f}=a,c=r.pos[l],u=r.size[l];if(!c||h.clip!==!1&&(c.bottom<=Math.max(e.top,i.top)||c.top>=Math.min(e.bottom,i.bottom)||c.right<Math.max(e.left,i.left)-.1||c.left>Math.min(e.right,i.right)+.1)){f.style.top=vi;continue}let d=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(t=Rr.get(a))!==null&&t!==void 0?t:u.bottom-u.top,b=a.offset||Of,v=this.view.textDirection==_.LTR,y=u.width>i.right-i.left?v?i.left:i.right-u.width:v?Math.max(i.left,Math.min(c.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,c.left-g+(d?14:0)-b.x),i.right-g),P=this.above[l];!h.strictSide&&(P?c.top-m-p-b.y<i.top:c.bottom+m+p+b.y>i.bottom)&&P==i.bottom-c.bottom>c.top-i.top&&(P=this.above[l]=!P);let T=(P?c.top-i.top:i.bottom-c.bottom)-p;if(T<m&&a.resize!==!1){if(T<this.view.defaultLineHeight){f.style.top=vi;continue}Rr.set(a,m),f.style.height=(m=T)/n+"px"}else f.style.height&&(f.style.height="");let O=P?c.top-m-p-b.y:c.bottom+p+b.y,C=y+g;if(a.overlap!==!0)for(let R of o)R.left<C&&R.right>y&&R.top<O+m&&R.bottom>O&&(O=P?R.top-m-2-p:R.bottom+p+2);if(this.position=="absolute"?(f.style.top=(O-r.parent.top)/n+"px",Er(f,(y-r.parent.left)/s)):(f.style.top=O/n+"px",Er(f,y/s)),d){let R=c.left+(v?b.x:-b.x)-(y+14-7);d.style.left=R/s+"px"}a.overlap!==!0&&o.push({left:y,top:O,right:C,bottom:O+m}),f.classList.toggle("cm-tooltip-above",P),f.classList.toggle("cm-tooltip-below",!P),a.positioned&&a.positioned(r.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 r of this.manager.tooltipViews)r.dom.style.top=vi}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Er(r,t){let e=parseInt(r.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(r.style.left=t+"px")}const Af=B.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"}}}),Of={x:0,y:0},Al=A.define({enables:[Cl,Af]}),_i=A.define({combine:r=>r.reduce((t,e)=>t.concat(e),[])});class os{static create(t){return new os(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Sl(t,_i,(e,i)=>this.createHostedView(e,i),e=>e.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(s!==void 0){if(e===void 0)e=s;else if(e!==s)return}}return e}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 Tf=Al.compute([_i],r=>{let t=r.facet(_i);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var i;return(i=e.end)!==null&&i!==void 0?i:e.pos})),create:os.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Mf=A.define();class Pf{constructor(t,e,i,s,n,o){this.view=t,this.source=e,this.field=i,this.locked=s,this.setHover=n,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){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 t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.tile.nearest(e.target);if(!i)return;let s,n=1;if(i.isWidget())s=i.posAtStart;else{if(s=t.posAtCoords(e),s==null)return;let o=t.coordsAtPos(s);if(!o||e.y<o.top||e.y>o.bottom||e.x<o.left-t.defaultCharacterWidth||e.x>o.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(s)).find(a=>a.from<=s&&a.to>=s),h=l&&l.dir==_.RTL?-1:1;n=e.x<o.left?-h:h}this.activateHover(t,s,n)}activateHover(t,e,i,s){let n=this.source(t,e,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let h=Array.isArray(l)?l:[l];s&&this.locked.set(h,s),t.dispatch({effects:this.setHover.of(h)})}};if(n&&"then"in n){let l=this.pending={pos:e};n.then(h=>{this.pending==l&&(this.pending=null,o(h))},h=>xt(t.state,h,"hover tooltip"))}else o(n)}get tooltip(){let t=this.view.plugin(Cl),e=t?t.manager.tooltips.findIndex(i=>i.create==os.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:n}=this;if(s.length&&!this.locked.has(s)&&n&&!Df(n.dom,t)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(e=s[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Bf(this.view,o,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length&&!this.locked.has(e)){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ki=4;function Df(r,t){let{left:e,right:i,top:s,bottom:n}=r.getBoundingClientRect(),o;if(o=r.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),n=Math.max(l.bottom,n)}return t.clientX>=e-ki&&t.clientX<=i+ki&&t.clientY>=s-ki&&t.clientY<=n+ki}function Bf(r,t,e,i,s,n){let o=r.scrollDOM.getBoundingClientRect(),l=r.documentTop+r.documentPadding.top+r.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let h=r.posAtCoords({x:i,y:s},!1);return h>=t&&h<=e}function cu(r,t={}){let e=U.define(),i=new WeakMap,s=Ut.define({create(){return[]},update(o,l){let h=i.get(o);if(o.length&&(t.hideOnChange&&(l.docChanged||l.selection)?o=[]:h&&h(l)?o=[]:t.hideOn&&(o=o.filter(a=>!t.hideOn(l,a)))),l.docChanged&&o.length){let a=[];for(let f of o){let c=l.changes.mapPos(f.pos,-1,ot.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),f);u.pos=c,u.end!=null&&(u.end=l.changes.mapPos(u.end)),a.push(u)}}o=a}for(let a of l.effects)a.is(e)&&(o=a.value,h=void 0),(a.is(Rf)&&!a.value||a.value==s)&&(o=[]);return o.length&&h&&i.set(o,h),o},provide:o=>_i.from(o)});const n=at.define(o=>new Pf(o,r,s,i,e,t.hoverTime||300));return{active:s,extension:[s,n,Mf.of(n),Tf]}}const Rf=U.define(),Nr=A.define({combine(r){let t,e;for(let i of r)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}}),Ef=at.fromClass(class{constructor(r){this.input=r.state.facet(Lr),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(r));let t=r.state.facet(Nr);this.top=new Si(r,!0,t.topContainer),this.bottom=new Si(r,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(r){let t=r.state.facet(Nr);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Si(r.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Si(r.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=r.state.facet(Lr);if(e!=this.input){let i=e.filter(h=>h),s=[],n=[],o=[],l=[];for(let h of i){let a=this.specs.indexOf(h),f;a<0?(f=h(r.view),l.push(f)):(f=this.panels[a],f.update&&f.update(r)),s.push(f),(f.top?n:o).push(f)}this.specs=i,this.panels=s,this.top.sync(n),this.bottom.sync(o);for(let h of l)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let i of this.panels)i.update&&i.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>B.scrollMargins.of(t=>{let e=t.plugin(r);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Si{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,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";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Ir(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Ir(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Ir(r){let t=r.nextSibling;return r.remove(),t}const Lr=A.define({enables:Ef});class he extends ne{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}he.prototype.elementClass="";he.prototype.toDOM=void 0;he.prototype.mapMode=ot.TrackBefore;he.prototype.startSide=he.prototype.endSide=-1;he.prototype.point=!0;const vs=A.define(),Nf=A.define(),Ei=A.define(),Wr=A.define({combine:r=>r.some(t=>t)});function If(r){return[Lf]}const Lf=at.fromClass(class{constructor(r){this.view=r,this.domAfter=null,this.prevViewport=r.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=r.state.facet(Ei).map(t=>new Vr(r,t)),this.fixed=!r.state.facet(Wr);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.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(r){if(this.updateGutters(r)){let t=this.prevViewport,e=r.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}if(r.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(Wr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=r.view.viewport}syncGutters(r){let t=this.dom.nextSibling;r&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let e=I.iter(this.view.state.facet(vs),this.view.viewport.from),i=[],s=this.gutters.map(n=>new Wf(n,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(n.type)){let o=!0;for(let l of n.type)if(l.type==ht.Text&&o){hn(e,i,l.from);for(let h of s)h.line(this.view,l,i);o=!1}else if(l.widget)for(let h of s)h.widget(this.view,l)}else if(n.type==ht.Text){hn(e,i,n.from);for(let o of s)o.line(this.view,n,i)}else if(n.widget)for(let o of s)o.widget(this.view,n);for(let n of s)n.finish();r&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(r){let t=r.startState.facet(Ei),e=r.state.facet(Ei),i=r.docChanged||r.heightChanged||r.viewportChanged||!I.eq(r.startState.facet(vs),r.state.facet(vs),r.view.viewport.from,r.view.viewport.to);if(t==e)for(let s of this.gutters)s.update(r)&&(i=!0);else{i=!0;let s=[];for(let n of e){let o=t.indexOf(n);o<0?s.push(new Vr(this.view,n)):(this.gutters[o].update(r),s.push(this.gutters[o]))}for(let n of this.gutters)n.dom.remove(),s.indexOf(n)<0&&n.destroy();for(let n of s)n.config.side=="after"?this.getDOMAfter().appendChild(n.dom):this.dom.appendChild(n.dom);this.gutters=s}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:r=>B.scrollMargins.of(t=>{let e=t.plugin(r);if(!e||e.gutters.length==0||!e.fixed)return null;let i=e.dom.offsetWidth*t.scaleX,s=e.domAfter?e.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==_.LTR?{left:i,right:s}:{right:i,left:s}})});function Hr(r){return Array.isArray(r)?r:[r]}function hn(r,t,e){for(;r.value&&r.from<=e;)r.from==e&&t.push(r.value),r.next()}class Wf{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=I.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,n=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==s.elements.length){let l=new Ol(t,o,n,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(t,o,n,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];hn(this.cursor,s,e.from),i.length&&(s=s.concat(i));let n=this.gutter.config.lineMarker(t,e,s);n&&s.unshift(n);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let n of t.state.facet(Nf)){let o=n(t,e.widget,e);o&&(s||(s=[])).push(o)}s&&this.addElement(t,e,s)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Vr{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,s=>{let n=s.target,o;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let h=n.getBoundingClientRect();o=(h.top+h.bottom)/2}else o=s.clientY;let l=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,l,s)&&s.preventDefault()});this.markers=Hr(e.markers(t)),e.initialSpacer&&(this.spacer=new Ol(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Hr(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],t);s!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[s])}let i=t.view.viewport;return!I.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Ol{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Hf(this.markers,s)||this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let n=0,o=0;;){let l=o,h=n<e.length?e[n++]:null,a=!1;if(h){let f=h.elementClass;f&&(i+=" "+f);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(h)){l=c,a=!0;break}}else l=this.markers.length;for(;o<l;){let f=this.markers[o++];if(f.toDOM){f.destroy(s);let c=s.nextSibling;s.remove(),s=c}}if(!h)break;h.toDOM&&(a?s=s.nextSibling:this.dom.insertBefore(h.toDOM(t),s)),a&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function Hf(r,t){if(r.length!=t.length)return!1;for(let e=0;e<r.length;e++)if(!r[e].compare(t[e]))return!1;return!0}const Vf=A.define(),Ff=A.define(),ge=A.define({combine(r){return Mo(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let s in e){let n=i[s],o=e[s];i[s]=n?(l,h,a)=>n(l,h,a)||o(l,h,a):o}return i}})}});class ks extends he{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Ss(r,t){return r.state.facet(ge).formatNumber(t,r.state)}const zf=Ei.compute([ge],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Vf)},lineMarker(t,e,i){return i.some(s=>s.toDOM)?null:new ks(Ss(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let s of t.state.facet(Ff)){let n=s(t,e,i);if(n)return n}return null},lineMarkerChange:t=>t.startState.facet(ge)!=t.state.facet(ge),initialSpacer(t){return new ks(Ss(t,Fr(t.state.doc.lines)))},updateSpacer(t,e){let i=Ss(e.view,Fr(e.view.state.doc.lines));return i==t.number?t:new ks(i)},domEventHandlers:r.facet(ge).domEventHandlers,side:"before"}));function uu(r={}){return[ge.of(r),If(),zf]}function Fr(r){let t=9;for(;t<r;)t=t*10+9;return t}const Tl=1024;let $f=0;class Cs{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=$f++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ft.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}N.closedBy=new N({deserialize:r=>r.split(" ")});N.openedBy=new N({deserialize:r=>r.split(" ")});N.group=new N({deserialize:r=>r.split(" ")});N.isolate=new N({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});N.contextHash=new N({perNode:!0});N.lookAhead=new N({perNode:!0});N.mounted=new N({perNode:!0});class qe{constructor(t,e,i,s=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=s}static get(t){return t&&t.props&&t.props[N.mounted.id]}}const Kf=Object.create(null);class ft{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):Kf,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new ft(t.name||"",e,t.id,i);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(s)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(N.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return i=>{for(let s=i.prop(N.group),n=-1;n<(s?s.length:0);n++){let o=e[n<0?i.name:s[n]];if(o)return o}}}}ft.none=new ft("",Object.create(null),0,8);class Rn{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let n of t){let o=n(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],h=o[0];h.combine&&h.id in s&&(l=h.combine(s[h.id],l)),s[h.id]=l}}e.push(s?new ft(i.name,s,i.id,i.flags):i)}return new Rn(e)}}const Ci=new WeakMap,zr=new WeakMap;var j;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(j||(j={}));class Y{constructor(t,e,i,s,n){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,n&&n.length){this.props=Object.create(null);for(let[o,l]of n)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=qe.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let s=i.toString();s&&(e&&(e+=","),e+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new fn(this.topNode,t)}cursorAt(t,e=0,i=0){let s=Ci.get(this)||this.topNode,n=new fn(s);return n.moveTo(t,e),Ci.set(this,n._tree),n}get topNode(){return new mt(this,0,0,null)}resolve(t,e=0){let i=Je(Ci.get(this)||this.topNode,t,e,!1);return Ci.set(this,i),i}resolveInner(t,e=0){let i=Je(zr.get(this)||this.topNode,t,e,!0);return zr.set(this,i),i}resolveStack(t,e=0){return _f(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:n=this.length}=t,o=t.mode||0,l=(o&j.IncludeAnonymous)>0;for(let h=this.cursor(o|j.IncludeAnonymous);;){let a=!1;if(h.from<=n&&h.to>=s&&(!l&&h.type.isAnonymous||e(h)!==!1)){if(h.firstChild())continue;a=!0}for(;a&&i&&(l||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.parent())return;a=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:In(ft.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,s)=>new Y(this.type,e,i,s,this.propValues),t.makeTree||((e,i,s)=>new Y(ft.none,e,i,s)))}static build(t){return Gf(t)}}Y.empty=new Y(ft.none,[],[],0);class En{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new En(this.buffer,this.index)}}class Qt{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ft.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],n=s.name;if(/\W/.test(n)&&!s.isError&&(n=JSON.stringify(n)),t+=4,i==t)return n;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return n+"("+o.join(",")+")"}findChild(t,e,i,s,n){let{buffer:o}=this,l=-1;for(let h=t;h!=e&&!(Ml(n,s,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(t,e,i){let s=this.buffer,n=new Uint16Array(e-t),o=0;for(let l=t,h=0;l<e;){n[h++]=s[l++],n[h++]=s[l++]-i;let a=n[h++]=s[l++]-i;n[h++]=s[l++]-t,o=Math.max(o,a)}return new Qt(n,o,this.set)}}function Ml(r,t,e,i){switch(r){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function Je(r,t,e,i){for(var s;r.from==r.to||(e<1?r.from>=t:r.from>t)||(e>-1?r.to<=t:r.to<t);){let o=!i&&r instanceof mt&&r.index<0?null:r.parent;if(!o)return r;r=o}let n=i?0:j.IgnoreOverlays;if(i)for(let o=r,l=o.parent;l;o=l,l=o.parent)o instanceof mt&&o.index<0&&((s=l.enter(t,e,n))===null||s===void 0?void 0:s.from)!=o.from&&(r=l);for(;;){let o=r.enter(t,e,n);if(!o)return r;r=o}}class Pl{cursor(t=0){return new fn(this,t)}getChild(t,e=null,i=null){let s=$r(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return $r(this,t,e,i)}resolve(t,e=0){return Je(this,t,e,!1)}resolveInner(t,e=0){return Je(this,t,e,!0)}matchContext(t){return an(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let s=e.lastChild;if(!s||s.to!=e.to)break;s.type.isError&&s.from==s.to?(i=e,e=s.prevSibling):e=s}return i}get node(){return this}get next(){return this.parent}}class mt extends Pl{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,n=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,a=e>0?l.length:-1;t!=a;t+=e){let f=l[t],c=h[t]+o.from,u;if(!(!(n&j.EnterBracketed&&f instanceof Y&&(u=qe.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!Ml(s,i,c,c+f.length))){if(f instanceof Qt){if(n&j.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,e,i-c,s);if(d>-1)return new qt(new qf(o,f,t,c),null,d)}else if(n&j.IncludeAnonymous||!f.type.isAnonymous||Nn(f)){let d;if(!(n&j.IgnoreMounts)&&(d=qe.get(f))&&!d.overlay)return new mt(d.tree,c,t,o);let p=new mt(f,c,t,o);return n&j.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?f.children.length-1:0,e,i,s,n)}}}if(n&j.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let s;if(!(i&j.IgnoreOverlays)&&(s=qe.get(this._tree))&&s.overlay){let n=t-this.from,o=i&j.EnterBracketed&&s.bracketed;for(let{from:l,to:h}of s.overlay)if((e>0||o?l<=n:l<n)&&(e<0||o?h>=n:h>n))return new mt(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $r(r,t,e,i){let s=r.cursor(),n=[];if(!s.firstChild())return n;if(e!=null){for(let o=!1;!o;)if(o=s.type.is(e),!s.nextSibling())return n}for(;;){if(i!=null&&s.type.is(i))return n;if(s.type.is(t)&&n.push(s.node),!s.nextSibling())return i==null?n:[]}}function an(r,t,e=t.length-1){for(let i=r;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class qf{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class qt extends Pl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new qt(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&j.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new qt(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new qt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new qt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,n=i.buffer[this.index+3];if(n>s){let o=i.buffer[this.index+1];t.push(i.slice(s,n,o)),e.push(0)}return new Y(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Dl(r){if(!r.length)return null;let t=0,e=r[0];for(let n=1;n<r.length;n++){let o=r[n];(o.from>e.from||o.to<e.to)&&(e=o,t=n)}let i=e instanceof mt&&e.index<0?null:e.parent,s=r.slice();return i?s[t]=i:s.splice(t,1),new jf(s,e)}class jf{constructor(t,e){this.heads=t,this.node=e}get next(){return Dl(this.heads)}}function _f(r,t,e){let i=r.resolveInner(t,e),s=null;for(let n=i instanceof mt?i:i.context.parent;n;n=n.parent)if(n.index<0){let o=n.parent;(s||(s=[i])).push(o.resolve(t,e)),n=o}else{let o=qe.get(n.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new mt(o.tree,o.overlay[0].from+n.from,-1,n);(s||(s=[i])).push(Je(l,t,e,!1))}}return s?Dl(s):i}class fn{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~j.EnterBracketed,t instanceof mt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return t?t instanceof mt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&j.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&j.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&j.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(e.findChild(s,this.index,-1,0,4))}else{let s=e.buffer[this.index+3];if(s<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(s.buffer.buffer[n+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let n=e+t,o=t<0?-1:i._tree.children.length;n!=o;n+=t){let l=i._tree.children[n];if(this.mode&j.IncludeAnonymous||l instanceof Qt||!l.type.isAnonymous||Nn(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let s=this.index,n=this.stack.length;n>=0;){for(let o=t;o;o=o._parent)if(o.index==s){if(s==this.index)return o;e=o,i=n+1;break t}s=this.stack[--n]}for(let s=i;s<this.stack.length;s++)e=new qt(this.buffer,e,this.stack[s]);return this.bufferNode=new qt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return an(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,n=this.stack.length-1;s>=0;n--){if(n<0)return an(this._tree,t,s);let o=i[e.buffer[this.stack[n]]];if(!o.isAnonymous){if(t[s]&&t[s]!=o.name)return!1;s--}}return!0}}function Nn(r){return r.children.some(t=>t instanceof Qt||!t.type.isAnonymous||Nn(t))}function Gf(r){var t;let{buffer:e,nodeSet:i,maxBufferLength:s=Tl,reused:n=[],minRepeatType:o=i.types.length}=r,l=Array.isArray(e)?new En(e,e.length):e,h=i.types,a=0,f=0;function c(T,O,C,R,H,E){let{id:D,start:M,end:$,size:K}=l,J=f,Ht=a;if(K<0)if(l.next(),K==-1){let Bt=n[D];C.push(Bt),R.push(M-T);return}else if(K==-3){a=D;return}else if(K==-4){f=D;return}else throw new RangeError(`Unrecognized record size: ${K}`);let De=h[D],ni,Yt,Wn=M-T;if($-M<=s&&(Yt=m(l.pos-O,H))){let Bt=new Uint16Array(Yt.size-Yt.skip),dt=l.pos-Yt.size,St=Bt.length;for(;l.pos>dt;)St=b(Yt.start,Bt,St);ni=new Qt(Bt,$-Yt.start,i),Wn=Yt.start-T}else{let Bt=l.pos-K;l.next();let dt=[],St=[],Xt=D>=o?D:-1,fe=0,ri=$;for(;l.pos>Bt;)Xt>=0&&l.id==Xt&&l.size>=0?(l.end<=ri-s&&(p(dt,St,M,fe,l.end,ri,Xt,J,Ht),fe=dt.length,ri=l.end),l.next()):E>2500?u(M,Bt,dt,St):c(M,Bt,dt,St,Xt,E+1);if(Xt>=0&&fe>0&&fe<dt.length&&p(dt,St,M,fe,M,ri,Xt,J,Ht),dt.reverse(),St.reverse(),Xt>-1&&fe>0){let Hn=d(De,Ht);ni=In(De,dt,St,0,dt.length,0,$-M,Hn,Hn)}else ni=g(De,dt,St,$-M,J-$,Ht)}C.push(ni),R.push(Wn)}function u(T,O,C,R){let H=[],E=0,D=-1;for(;l.pos>O;){let{id:M,start:$,end:K,size:J}=l;if(J>4)l.next();else{if(D>-1&&$<D)break;D<0&&(D=K-s),H.push(M,$,K),E++,l.next()}}if(E){let M=new Uint16Array(E*4),$=H[H.length-2];for(let K=H.length-3,J=0;K>=0;K-=3)M[J++]=H[K],M[J++]=H[K+1]-$,M[J++]=H[K+2]-$,M[J++]=J;C.push(new Qt(M,H[2]-$,i)),R.push($-T)}}function d(T,O){return(C,R,H)=>{let E=0,D=C.length-1,M,$;if(D>=0&&(M=C[D])instanceof Y){if(!D&&M.type==T&&M.length==H)return M;($=M.prop(N.lookAhead))&&(E=R[D]+M.length+$)}return g(T,C,R,H,E,O)}}function p(T,O,C,R,H,E,D,M,$){let K=[],J=[];for(;T.length>R;)K.push(T.pop()),J.push(O.pop()+C-H);T.push(g(i.types[D],K,J,E-H,M-E,$)),O.push(H-C)}function g(T,O,C,R,H,E,D){if(E){let M=[N.contextHash,E];D=D?[M].concat(D):[M]}if(H>25){let M=[N.lookAhead,H];D=D?[M].concat(D):[M]}return new Y(T,O,C,R,D)}function m(T,O){let C=l.fork(),R=0,H=0,E=0,D=C.end-s,M={size:0,start:0,skip:0};t:for(let $=C.pos-T;C.pos>$;){let K=C.size;if(C.id==O&&K>=0){M.size=R,M.start=H,M.skip=E,E+=4,R+=4,C.next();continue}let J=C.pos-K;if(K<0||J<$||C.start<D)break;let Ht=C.id>=o?4:0,De=C.start;for(C.next();C.pos>J;){if(C.size<0)if(C.size==-3||C.size==-4)Ht+=4;else break t;else C.id>=o&&(Ht+=4);C.next()}H=De,R+=K,E+=Ht}return(O<0||R==T)&&(M.size=R,M.start=H,M.skip=E),M.size>4?M:void 0}function b(T,O,C){let{id:R,start:H,end:E,size:D}=l;if(l.next(),D>=0&&R<o){let M=C;if(D>4){let $=l.pos-(D-4);for(;l.pos>$;)C=b(T,O,C)}O[--C]=M,O[--C]=E-T,O[--C]=H-T,O[--C]=R}else D==-3?a=R:D==-4&&(f=R);return C}let v=[],y=[];for(;l.pos>0;)c(r.start||0,r.bufferStart||0,v,y,-1,0);let P=(t=r.length)!==null&&t!==void 0?t:v.length?y[0]+v[0].length:0;return new Y(h[r.topID],v.reverse(),y.reverse(),P)}const Kr=new WeakMap;function Ni(r,t){if(!r.isAnonymous||t instanceof Qt||t.type!=r)return 1;let e=Kr.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=r||!(i instanceof Y)){e=1;break}e+=Ni(r,i)}Kr.set(t,e)}return e}function In(r,t,e,i,s,n,o,l,h){let a=0;for(let p=i;p<s;p++)a+=Ni(r,t[p]);let f=Math.ceil(a*1.5/8),c=[],u=[];function d(p,g,m,b,v){for(let y=m;y<b;){let P=y,T=g[y],O=Ni(r,p[y]);for(y++;y<b;y++){let C=Ni(r,p[y]);if(O+C>=f)break;O+=C}if(y==P+1){if(O>f){let C=p[P];d(C.children,C.positions,0,C.children.length,g[P]+v);continue}c.push(p[P])}else{let C=g[y-1]+p[y-1].length-T;c.push(In(r,p,g,P,y,T,C,null,h))}u.push(T+v-n)}}return d(t,e,i,s,0),(l||h)(c,u,o)}class se{constructor(t,e,i,s,n=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(n?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let s=[new se(0,t.length,t,0,!1,i)];for(let n of e)n.to>t.length&&s.push(n);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],n=1,o=t.length?t[0]:null;for(let l=0,h=0,a=0;;l++){let f=l<e.length?e[l]:null,c=f?f.fromA:1e9;if(c-h>=i)for(;o&&o.from<c;){let u=o;if(h>=u.from||c<=u.to||a){let d=Math.max(u.from,h)-a,p=Math.min(u.to,c)-a;u=d>=p?null:new se(d,p,u.tree,u.offset+a,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=n<t.length?t[n++]:null}if(!f)break;h=f.toA,a=f.toA-f.toB}return s}}class Bl{startParse(t,e,i){return typeof t=="string"&&(t=new Qf(t)),i=i?i.length?i.map(s=>new Cs(s.from,s.to)):[new Cs(0,0)]:[new Cs(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let n=s.advance();if(n)return n}}}class Qf{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new N({perNode:!0});var qr={};class Gi{constructor(t,e,i,s,n,o,l,h,a,f=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=n,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=a,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new Gi(t,[],e,i,i,0,[],0,s?new jr(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=t&65535,{parser:n}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=n.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){s<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,s,!0),this.reducePos),s<n.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let h=this.stack.length-(i-1)*3-(t&262144?6:0),a=h?this.stack[h-2]:this.p.ranges[0].from;s<n.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let f=this.reducePos-a;f>=2e3&&!(!((e=this.p.parser.nodeSet.types[s])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=f));let c=h?this.stack[h-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<n.minRepeatTerm||t&131072){let d=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,a,d,u+4,!0)}if(t&262144)this.state=this.stack[h];else{let d=this.stack[h-3];this.state=n.getGoto(d,s,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(s,a)}storeNode(t,e,i,s=4,n=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(e==i)return;if(this.buffer[o-2]>=e){this.buffer[o-2]=i;return}}}if(!n||this.pos==i)this.buffer.push(t,e,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let h=o;h>0&&this.buffer[h-2]>i;h-=4)if(this.buffer[h-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(t,e,i,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let n=t,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(n,1);!l&&(s>i||e<=o.maxNode)&&(this.reducePos=s),this.pushState(n,l?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){t&65536?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new Gi(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Uf(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let n=0,o;n<e.length;n+=2)(o=e[n+1])!=this.state&&this.p.parser.hasAction(o,t)&&s.push(e[n],o);if(this.stack.length<120)for(let n=0;s.length<8&&n<e.length;n+=2){let o=e[n+1];s.some((l,h)=>h&1&&l==o)||s.push(e[n],o)}e=s}let i=[];for(let s=0;s<e.length&&i.length<4;s+=2){let n=e[s+1];if(n==this.state)continue;let o=this.split();o.pushState(n,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[s],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,n=this.stack.length-i*3;if(n<0||t.getGoto(this.stack[n],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,n)=>{if(!e.includes(s))return e.push(s),t.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-n;if(l>1){let h=o&65535,a=this.stack.length-l*3;if(a>=0&&t.getGoto(this.stack[a],h,!1)>=0)return l<<19|65536|h}}else{let l=i(o,n+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new jr(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class jr{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Uf{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}}class Qi{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Qi(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Qi(this.stack,this.pos,this.index)}}function Ai(r,t=Uint16Array){if(typeof r!="string")return r;let e=null;for(let i=0,s=0;i<r.length;){let n=0;for(;;){let o=r.charCodeAt(i++),l=!1;if(o==126){n=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),n+=h,l)break;n*=46}e?e[s++]=n:e=new t(n)}return e}class Ii{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const _r=new Ii;class Yf{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_r,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,n=this.pos+t;for(;n<i.from;){if(!s)return null;let o=this.ranges[--s];n-=i.from-o.to,i=o}for(;e<0?n>i.to:n>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];n+=o.from-i.to,i=o}return n}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e<this.chunk.length)i=this.pos+t,s=this.chunk.charCodeAt(e);else{let n=this.resolveOffset(t,1);if(n==null)return-1;if(i=n,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=_r,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class ke{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Xf(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}ke.prototype.contextual=ke.prototype.fallback=ke.prototype.extend=!1;ke.prototype.fallback=ke.prototype.extend=!1;function Xf(r,t,e,i,s,n){let o=0,l=1<<i,{dialect:h}=e.p.parser;t:for(;(l&r[o])!=0;){let a=r[o+1];for(let d=o+3;d<a;d+=2)if((r[d+1]&l)>0){let p=r[d];if(h.allows(p)&&(t.token.value==-1||t.token.value==p||Jf(p,t.token.value,s,n))){t.acceptToken(p);break}}let f=t.next,c=0,u=r[o+2];if(t.next<0&&u>c&&r[a+u*3-3]==65535){o=r[a+u*3-1];continue t}for(;c<u;){let d=c+u>>1,p=a+d+(d<<1),g=r[p],m=r[p+1]||65536;if(f<g)u=d;else if(f>=m)c=d+1;else{o=r[p+2],t.advance();continue t}}break}}function Gr(r,t,e){for(let i=t,s;(s=r[i])!=65535;i++)if(s==e)return i-t;return-1}function Jf(r,t,e,i){let s=Gr(e,i,t);return s<0||Gr(e,i,r)<s}const ct=typeof process<"u"&&qr&&/\bparse\b/.test(qr.LOG);let As=null;function Qr(r,t,e){let i=r.cursor(j.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(r.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:r.length}}class Zf{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Qr(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Qr(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],s=this.index[e];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[s],o=this.start[e]+i.positions[s];if(o>t)return this.nextStart=o,null;if(n instanceof Y){if(o==t){if(o<this.safeFrom)return null;let l=o+n.length;if(l<=this.safeTo){let h=n.prop(N.lookAhead);if(!h||l+h<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}}class tc{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new Ii)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:n}=s,o=s.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,h=0;for(let a=0;a<n.length;a++){if((1<<a&o)==0)continue;let f=n[a],c=this.tokens[a];if(!(i&&!f.fallback)&&((f.contextual||c.start!=t.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,t),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(h=Math.max(c.lookAhead,h)),c.value!=0)){let u=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!f.extend&&(i=c,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return h&&t.setLookAhead(h),!i&&t.pos==this.stream.end&&(i=new Ii,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new Ii,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:n}=i.p;for(let o=0;o<n.specialized.length;o++)if(n.specialized[o]==t.value){let l=n.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?t.value=l>>1:t.extended=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let n=0;n<s;n+=3)if(this.actions[n]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:n}=t,{parser:o}=t.p,{data:l}=o;for(let h=0;h<2;h++)for(let a=o.stateSlot(n,h?2:1);;a+=3){if(l[a]==65535)if(l[a+1]==1)a=Rt(l,a+2);else{s==0&&l[a+1]==2&&(s=this.putAction(Rt(l,a+2),e,i,s));break}l[a]==e&&(s=this.putAction(Rt(l,a+1),e,i,s))}return s}}class ec{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Yf(e,s),this.tokens=new tc(t,this.stream),this.topTerm=t.top[1];let{from:n}=s[0];this.stacks=[Gi.start(this,t.top[0],n)],this.fragments=i.length&&this.stream.end-n>t.bufferLength*4?new Zf(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],s,n;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{s||(s=[],n=[]),s.push(l);let h=this.tokens.getMainToken(l);n.push(h.value,h.end)}}break}}if(!i.length){let o=s&&sc(s);if(o)return ct&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ct&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,n,i);if(o)return ct&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let a=i[h];if(l.sameState(a)||l.buffer.length>500&&a.buffer.length>500)if((l.score-a.score||l.buffer.length-a.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let s=t.pos,{parser:n}=this,o=ct?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,f=a?t.curContext.hash:0;for(let c=this.fragments.nodeAt(s);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?n.getGoto(t.state,c.type.id):-1;if(u>-1&&c.length&&(!a||(c.prop(N.contextHash)||0)==f))return t.useNode(c,u),ct&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(c.type.id)})`),!0;if(!(c instanceof Y)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof Y&&c.positions[0]==0)c=d;else break}}let l=n.stateSlot(t.state,4);if(l>0)return t.reduce(l),ct&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let h=this.tokens.getActions(t);for(let a=0;a<h.length;){let f=h[a++],c=h[a++],u=h[a++],d=a==h.length||!i,p=d?t:t.split(),g=this.tokens.mainToken;if(p.apply(f,c,g?g.start:p.pos,u),ct&&console.log(o+this.stackID(p)+` (via ${(f&65536)==0?"shift":`reduce of ${n.getName(f&65535)}`} for ${n.getName(c)} @ ${s}${p==t?"":", split"})`),d)return!0;p.pos>s?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Ur(t,e),!0}}runRecovery(t,e,i){let s=null,n=!1;for(let o=0;o<t.length;o++){let l=t[o],h=e[o<<1],a=e[(o<<1)+1],f=ct?this.stackID(l)+" -> ":"";if(l.deadEnd&&(n||(n=!0,l.restart(),ct&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;d<10&&c.forceReduce()&&(ct&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)ct&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(h))ct&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(a==l.pos&&(a++,h=0),l.recoverByDelete(h,a),ct&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),Ur(l,i)):(!s||s.score<c.score)&&(s=c)}return s}stackToTree(t){return t.close(),Y.build({buffer:Qi.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(As||(As=new WeakMap)).get(t);return e||As.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function Ur(r,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==r.pos&&i.sameState(r)){t[e].score<r.score&&(t[e]=r);return}}t.push(r)}class ic{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}}class Ui extends Bl{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),s=[];for(let l=0;l<e.length;l++)s.push([]);function n(l,h,a){s[l].push([h,h.deserialize(String(a))])}if(t.nodeProps)for(let l of t.nodeProps){let h=l[0];typeof h=="string"&&(h=N[h]);for(let a=1;a<l.length;){let f=l[a++];if(f>=0)n(f,h,l[a++]);else{let c=l[a+-f];for(let u=-f;u>0;u--)n(l[a++],h,c);a++}}}this.nodeSet=new Rn(e.map((l,h)=>ft.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:s[h],top:i.indexOf(h)>-1,error:h==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(h)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=Tl;let o=Ai(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Yr),this.states=Ai(t.states,Uint32Array),this.data=Ai(t.stateData),this.goto=Ai(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new ke(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new ec(this,t,e,i);for(let n of this.wrappers)s=n(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return-1;for(let n=s[e+1];;){let o=s[n++],l=o&1,h=s[n++];if(l&&i)return h;for(let a=n+(o>>1);n<a;n++)if(s[n]==t)return h;if(l)return-1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let n=this.stateSlot(t,s?2:1),o;;n+=3){if((o=i[n])==65535)if(i[n+1]==1)o=i[n=Rt(i,n+2)];else{if(i[n+1]==2)return Rt(i,n+2);break}if(o==e||o==0)return Rt(i,n+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let n=this.stateSlot(t,1);s==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Rt(this.data,n+2);else break;s=e(Rt(this.data,n+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Rt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];e.some((n,o)=>o&1&&n==s)||e.push(this.data[i],s)}}return e}configure(t){let e=Object.assign(Object.create(Ui.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let s=t.tokenizers.find(n=>n.from==i);return s?s.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let n=t.specializers.find(l=>l.from==i.external);if(!n)return i;let o=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[s]=Yr(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let o=e.indexOf(n);o>=0&&(i[o]=!0)}let s=null;for(let n=0;n<e.length;n++)if(!i[n])for(let o=this.dialects[e[n]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new ic(t,i,s)}static deserialize(t){return new Ui(t)}}function Rt(r,t){return r[t]|r[t+1]<<16}function sc(r){let t=null;for(let e of r){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function Yr(r){if(r.external){let t=r.extend?1:0;return(e,i)=>r.external(e,i)<<1|t}return r.get}let nc=0;class pt{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=nc++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof pt&&(e=t),e?.base)throw new Error("Can not derive from a modified tag");let s=new pt(i,[],null,[]);if(s.set.push(s),e)for(let n of e.set)s.set.push(n);return s}static defineModifier(t){let e=new Yi(t);return i=>i.modified.indexOf(e)>-1?i:Yi.get(i.base||i,i.modified.concat(e).sort((s,n)=>s.id-n.id))}}let rc=0;class Yi{constructor(t){this.name=t,this.instances=[],this.id=rc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&oc(e,l.modified));if(i)return i;let s=[],n=new pt(t.name,s,t,e);for(let l of e)l.instances.push(n);let o=lc(e);for(let l of t.set)if(!l.modified.length)for(let h of o)s.push(Yi.get(l,h));return n}}function oc(r,t){return r.length==t.length&&r.every((e,i)=>e==t[i])}function lc(r){let t=[[]];for(let e=0;e<r.length;e++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(r[e]));return t.sort((e,i)=>i.length-e.length)}function Rl(r){let t=Object.create(null);for(let e in r){let i=r[e];Array.isArray(i)||(i=[i]);for(let s of e.split(" "))if(s){let n=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(n.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let h=n.length-1,a=n[h];if(!a)throw new RangeError("Invalid path: "+s);let f=new Ze(i,o,h>0?n.slice(0,h):null);t[a]=f.sort(t[a])}}return El.add(t)}const El=new N({combine(r,t){let e,i,s;for(;r||t;){if(!r||t&&r.depth>=t.depth?(s=t,t=t.next):(s=r,r=r.next),e&&e.mode==s.mode&&!s.context&&!e.context)continue;let n=new Ze(s.tags,s.mode,s.context);e?e.next=n:i=n,e=n}return i}});class Ze{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}Ze.empty=new Ze([],2,null);function Nl(r,t){let e=Object.create(null);for(let n of r)if(!Array.isArray(n.tag))e[n.tag.id]=n.class;else for(let o of n.tag)e[o.id]=n.class;let{scope:i,all:s=null}=t||{};return{style:n=>{let o=s;for(let l of n)for(let h of l.set){let a=e[h.id];if(a){o=o?o+" "+a:a;break}}return o},scope:i}}function hc(r,t){let e=null;for(let i of r){let s=i.style(t);s&&(e=e?e+" "+s:s)}return e}function ac(r,t,e,i=0,s=r.length){let n=new fc(i,Array.isArray(t)?t:[t],e);n.highlightRange(r.cursor(),i,s,"",n.highlighters),n.flush(s)}class fc{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,n){let{type:o,from:l,to:h}=t;if(l>=i||h<=e)return;o.isTop&&(n=this.highlighters.filter(d=>!d.scope||d.scope(o)));let a=s,f=cc(t)||Ze.empty,c=hc(n,f.tags);if(c&&(a&&(a+=" "),a+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,l),a),f.opaque)return;let u=t.tree&&t.tree.prop(N.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=t.firstChild();for(let m=0,b=l;;m++){let v=m<u.overlay.length?u.overlay[m]:null,y=v?v.from+l:h,P=Math.max(e,b),T=Math.min(i,y);if(P<T&&g)for(;t.from<T&&(this.highlightRange(t,P,T,s,n),this.startSpan(Math.min(T,t.to),a),!(t.to>=y||!t.nextSibling())););if(!v||y>i)break;b=v.to+l,b>e&&(this.highlightRange(d.cursor(),Math.max(e,v.from+l),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),a))}g&&t.parent()}else if(t.firstChild()){u&&(s="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,n),this.startSpan(Math.min(i,t.to),a)}while(t.nextSibling());t.parent()}}}function cc(r){let t=r.type.prop(El);for(;t&&t.context&&!r.matchContext(t.context);)t=t.next;return t||null}const x=pt.define,Oi=x(),Vt=x(),Xr=x(Vt),Jr=x(Vt),Ft=x(),Ti=x(Ft),Os=x(Ft),Tt=x(),Jt=x(Tt),At=x(),Ot=x(),cn=x(),Ee=x(cn),Mi=x(),w={comment:Oi,lineComment:x(Oi),blockComment:x(Oi),docComment:x(Oi),name:Vt,variableName:x(Vt),typeName:Xr,tagName:x(Xr),propertyName:Jr,attributeName:x(Jr),className:x(Vt),labelName:x(Vt),namespace:x(Vt),macroName:x(Vt),literal:Ft,string:Ti,docString:x(Ti),character:x(Ti),attributeValue:x(Ti),number:Os,integer:x(Os),float:x(Os),bool:x(Ft),regexp:x(Ft),escape:x(Ft),color:x(Ft),url:x(Ft),keyword:At,self:x(At),null:x(At),atom:x(At),unit:x(At),modifier:x(At),operatorKeyword:x(At),controlKeyword:x(At),definitionKeyword:x(At),moduleKeyword:x(At),operator:Ot,derefOperator:x(Ot),arithmeticOperator:x(Ot),logicOperator:x(Ot),bitwiseOperator:x(Ot),compareOperator:x(Ot),updateOperator:x(Ot),definitionOperator:x(Ot),typeOperator:x(Ot),controlOperator:x(Ot),punctuation:cn,separator:x(cn),bracket:Ee,angleBracket:x(Ee),squareBracket:x(Ee),paren:x(Ee),brace:x(Ee),content:Tt,heading:Jt,heading1:x(Jt),heading2:x(Jt),heading3:x(Jt),heading4:x(Jt),heading5:x(Jt),heading6:x(Jt),contentSeparator:x(Tt),list:x(Tt),quote:x(Tt),emphasis:x(Tt),strong:x(Tt),link:x(Tt),monospace:x(Tt),strikethrough:x(Tt),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Mi,documentMeta:x(Mi),annotation:x(Mi),processingInstruction:x(Mi),definition:pt.defineModifier("definition"),constant:pt.defineModifier("constant"),function:pt.defineModifier("function"),standard:pt.defineModifier("standard"),local:pt.defineModifier("local"),special:pt.defineModifier("special")};for(let r in w){let t=w[r];t instanceof pt&&(t.name=r)}Nl([{tag:w.link,class:"tok-link"},{tag:w.heading,class:"tok-heading"},{tag:w.emphasis,class:"tok-emphasis"},{tag:w.strong,class:"tok-strong"},{tag:w.keyword,class:"tok-keyword"},{tag:w.atom,class:"tok-atom"},{tag:w.bool,class:"tok-bool"},{tag:w.url,class:"tok-url"},{tag:w.labelName,class:"tok-labelName"},{tag:w.inserted,class:"tok-inserted"},{tag:w.deleted,class:"tok-deleted"},{tag:w.literal,class:"tok-literal"},{tag:w.string,class:"tok-string"},{tag:w.number,class:"tok-number"},{tag:[w.regexp,w.escape,w.special(w.string)],class:"tok-string2"},{tag:w.variableName,class:"tok-variableName"},{tag:w.local(w.variableName),class:"tok-variableName tok-local"},{tag:w.definition(w.variableName),class:"tok-variableName tok-definition"},{tag:w.special(w.variableName),class:"tok-variableName2"},{tag:w.definition(w.propertyName),class:"tok-propertyName tok-definition"},{tag:w.typeName,class:"tok-typeName"},{tag:w.namespace,class:"tok-namespace"},{tag:w.className,class:"tok-className"},{tag:w.macroName,class:"tok-macroName"},{tag:w.propertyName,class:"tok-propertyName"},{tag:w.operator,class:"tok-operator"},{tag:w.comment,class:"tok-comment"},{tag:w.meta,class:"tok-meta"},{tag:w.invalid,class:"tok-invalid"},{tag:w.punctuation,class:"tok-punctuation"}]);const uc=Rl({String:w.string,Number:w.number,"True False":w.bool,PropertyName:w.propertyName,Null:w.null,", :":w.separator,"[ ]":w.squareBracket,"{ }":w.brace}),dc=Ui.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[uc],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});var Ts;const me=new N;function pc(r){return A.define({combine:r?t=>t.concat(r):void 0})}const gc=new N;class vt{constructor(t,e,i=[],s=""){this.data=t,this.name=s,L.prototype.hasOwnProperty("tree")||Object.defineProperty(L.prototype,"tree",{get(){return ae(this)}}),this.parser=e,this.extension=[Me.of(this),L.languageData.of((n,o,l)=>{let h=Zr(n,o,l),a=h.type.prop(me);if(!a)return[];let f=n.facet(a),c=h.type.prop(gc);if(c){let u=h.resolve(o-h.from,l);for(let d of c)if(d.test(u,n)){let p=n.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(t,e,i=-1){return Zr(t,e,i).type.prop(me)==this.data}findRegions(t){let e=t.facet(Me);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(n,o)=>{if(n.prop(me)==this.data){i.push({from:o,to:o+n.length});return}let l=n.prop(N.mounted);if(l){if(l.tree.prop(me)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+n.length});return}else if(l.overlay){let h=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<n.children.length;h++){let a=n.children[h];a instanceof Y&&s(a,n.positions[h]+o)}};return s(ae(t),0),i}get allowsNesting(){return!0}}vt.setState=U.define();function Zr(r,t,e){let i=r.facet(Me),s=ae(r).topNode;if(!i||i.allowsNesting)for(let n=s;n;n=n.enter(t,e,j.ExcludeBuffers|j.EnterBracketed))n.type.isTop&&(s=n);return s}class Xi extends vt{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=pc(t.languageData);return new Xi(e,t.parser.configure({props:[me.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new Xi(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ae(r){let t=r.field(vt.state,!1);return t?t.tree:Y.empty}class mc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Ne=null;class Ji{constructor(t,e,i=[],s,n,o,l,h){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Ji(t,e,[],Y.empty,0,i,[],null)}startParse(){return this.parser.startParse(new mc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=Y.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(se.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(se.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Ne;Ne=this;try{return t()}finally{Ne=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=to(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:n,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let h=[];if(t.iterChangedRanges((a,f,c,u)=>h.push({fromA:a,toA:f,fromB:c,toB:u})),i=se.applyChanges(i,h),s=Y.empty,n=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let a of this.skipped){let f=t.mapPos(a.from,1),c=t.mapPos(a.to,-1);f<c&&l.push({from:f,to:c})}}}return new Ji(this.parser,e,i,s,n,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:n}=this.skipped[i];s<t.to&&n>t.from&&(this.fragments=to(this.fragments,s,n),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Bl{createParse(e,i,s){let n=s[0].from,o=s[s.length-1].to;return{parsedPos:n,advance(){let h=Ne;if(h){for(let a of s)h.tempSkipped.push(a);t&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,t]):t)}return this.parsedPos=o,new Y(ft.none,[],[],o-n)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return Ne}}function to(r,t,e){return se.applyChanges(r,[{fromA:t,toA:e,fromB:t,toB:e}])}class Te{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Te(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Ji.create(t.facet(Me).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Te(i)}}vt.state=Ut.define({create:Te.init,update(r,t){for(let e of t.effects)if(e.is(vt.setState))return e.value;return t.startState.facet(Me)!=t.state.facet(Me)?Te.init(t.state):r.apply(t)}});let Il=r=>{let t=setTimeout(()=>r(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Il=r=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(r,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Ms=typeof navigator<"u"&&(!((Ts=navigator.scheduling)===null||Ts===void 0)&&Ts.isInputPending)?()=>navigator.scheduling.isInputPending():null,bc=at.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(vt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(vt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Il(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,n=i.field(vt.state);if(n.tree==n.context.tree&&n.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Ms?Math.max(25,t.timeRemaining()-5):1e9),l=n.context.treeLen<s&&i.doc.length>s+1e3,h=n.context.work(()=>Ms&&Ms()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:vt.setState.of(new Te(n.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>xt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Me=A.define({combine(r){return r.length?r[0]:null},enables:r=>[vt.state,bc,B.contentAttributes.compute([r],t=>{let e=t.facet(r);return e&&e.name?{"data-language":e.name}:{}})]});class wc{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const yc=A.define(),Ll=A.define({combine:r=>{if(!r.length)return" ";let t=r[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return t}});function xc(r){let t=r.facet(Ll);return t.charCodeAt(0)==9?r.tabSize*t.length:t.length}function vc(r,t){let e="",i=r.tabSize,s=r.facet(Ll)[0];if(s==" "){for(;t>=i;)e+=" ",t-=i;s=" "}for(let n=0;n<t;n++)e+=s;return e}function kc(r,t){r instanceof L&&(r=new Wl(r));for(let i of r.state.facet(yc)){let s=i(r,t);if(s!==void 0)return s}let e=ae(r.state);return e.length>=t?Sc(r,e,t):null}class Wl{constructor(t,e={}){this.state=t,this.options=e,this.unit=xc(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:n}=this.options;return s!=null&&s>=i.from&&s<=i.to?n&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.countColumn(i,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(n+=o-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return Ch(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let o=n(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Hl=new N;function Sc(r,t,e){let i=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=i.node){let n=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)n.push(o);for(let o=n.length-1;o>=0;o--)i={node:n[o],next:i}}return Vl(i,r,e)}function Vl(r,t,e){for(let i=r;i;i=i.next){let s=Ac(i.node);if(s)return s(Ln.create(t,e,i))}return 0}function Cc(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function Ac(r){let t=r.type.prop(Hl);if(t)return t;let e=r.firstChild,i;if(e&&(i=e.type.prop(N.closedBy))){let s=r.lastChild,n=s&&i.indexOf(s.name)>-1;return o=>Pc(o,!0,1,void 0,n&&!Cc(o)?s.from:void 0)}return r.parent==null?Oc:null}function Oc(){return 0}class Ln extends Wl{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Ln(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Tc(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Vl(this.context.next,this.base,this.pos)}}function Tc(r,t){for(let e=t;e;e=e.parent)if(r==e)return!0;return!1}function Mc(r){let t=r.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let s=r.options.simulateBreak,n=r.state.doc.lineAt(e.from),o=s==null||s<=n.from?n.to:Math.min(n.to,s);for(let l=e.to;;){let h=t.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped){if(h.from>=o)return null;let a=/^ */.exec(n.text.slice(e.to-n.from))[0].length;return{from:e.from,to:e.to+a}}l=h.to}}function Pc(r,t,e,i,s){let n=r.textAfter,o=n.match(/^\s*/)[0].length,l=i&&n.slice(o,o+i.length)==i||s==r.pos+o,h=Mc(r);return h?l?r.column(h.from):r.column(h.to):r.baseIndent+(l?0:r.unit*e)}function eo({except:r,units:t=1}={}){return e=>{let i=r&&r.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const Dc=200;function pu(){return L.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let t=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!t.length)return r;let e=r.newDoc,{head:i}=r.newSelection.main,s=e.lineAt(i);if(i>s.from+Dc)return r;let n=e.sliceString(s.from,i);if(!t.some(a=>a.test(n)))return r;let{state:o}=r,l=-1,h=[];for(let{head:a}of o.selection.ranges){let f=o.doc.lineAt(a);if(f.from==l)continue;l=f.from;let c=kc(o,f.from);if(c==null)continue;let u=/^\s*/.exec(f.text)[0],d=vc(o,c);u!=d&&h.push({from:f.from,to:f.from+u.length,insert:d})}return h.length?[r,{changes:h,sequential:!0}]:r})}const Bc=new N;function Rc(r){let t=r.firstChild,e=r.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?r.to:e.from}:null}class ls{constructor(t,e){this.specs=t;let i;function s(l){let h=jt.newName();return(i||(i=Object.create(null)))["."+h]=l,h}const n=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof vt?l=>l.prop(me)==o.data:o?l=>l==o:void 0,this.style=Nl(t.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:n}).style,this.module=i?new jt(i):null,this.themeType=e.themeType}static define(t,e){return new ls(t,e||{})}}const un=A.define(),Fl=A.define({combine(r){return r.length?[r[0]]:null}});function Ps(r){let t=r.facet(un);return t.length?t:r.facet(Fl)}function Ec(r,t){let e=[Ic],i;return r instanceof ls&&(r.module&&e.push(B.styleModule.of(r.module)),i=r.themeType),t?.fallback?e.push(Fl.of(r)):i?e.push(un.computeN([B.darkTheme],s=>s.facet(B.darkTheme)==(i=="dark")?[r]:[])):e.push(un.of(r)),e}class Nc{constructor(t){this.markCache=Object.create(null),this.tree=ae(t.state),this.decorations=this.buildDeco(t,Ps(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=ae(t.state),i=Ps(t.state),s=i!=Ps(t.startState),{viewport:n}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!s&&e.type==this.tree.type&&o>=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return F.none;let i=new we;for(let{from:s,to:n}of t.visibleRanges)ac(this.tree,e,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=F.mark({class:h})))},s,n);return i.finish()}}const Ic=wn.high(at.fromClass(Nc,{decorations:r=>r.decorations})),Lc=ls.define([{tag:w.meta,color:"#404740"},{tag:w.link,textDecoration:"underline"},{tag:w.heading,textDecoration:"underline",fontWeight:"bold"},{tag:w.emphasis,fontStyle:"italic"},{tag:w.strong,fontWeight:"bold"},{tag:w.strikethrough,textDecoration:"line-through"},{tag:w.keyword,color:"#708"},{tag:[w.atom,w.bool,w.url,w.contentSeparator,w.labelName],color:"#219"},{tag:[w.literal,w.inserted],color:"#164"},{tag:[w.string,w.deleted],color:"#a11"},{tag:[w.regexp,w.escape,w.special(w.string)],color:"#e40"},{tag:w.definition(w.variableName),color:"#00f"},{tag:w.local(w.variableName),color:"#30a"},{tag:[w.typeName,w.namespace],color:"#085"},{tag:w.className,color:"#167"},{tag:[w.special(w.variableName),w.macroName],color:"#256"},{tag:w.definition(w.propertyName),color:"#00c"},{tag:w.comment,color:"#940"},{tag:w.invalid,color:"#f00"}]),Wc=B.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),zl=1e4,$l="()[]{}",Kl=A.define({combine(r){return Mo(r,{afterCursor:!0,brackets:$l,maxScanDistance:zl,renderMatch:Fc})}}),Hc=F.mark({class:"cm-matchingBracket"}),Vc=F.mark({class:"cm-nonmatchingBracket"});function Fc(r){let t=[],e=r.matched?Hc:Vc;return t.push(e.range(r.start.from,r.start.to)),r.end&&t.push(e.range(r.end.from,r.end.to)),t}function io(r){let t=[],e=r.facet(Kl);for(let i of r.selection.ranges){if(!i.empty)continue;let s=Pi(r,i.head,-1,e)||i.head>0&&Pi(r,i.head-1,1,e)||e.afterCursor&&(Pi(r,i.head,1,e)||i.head<r.doc.length&&Pi(r,i.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,r)))}return F.set(t,!0)}const zc=at.fromClass(class{constructor(r){this.paused=!1,this.decorations=io(r.state)}update(r){(r.docChanged||r.selectionSet||this.paused)&&(r.view.composing?(this.decorations=this.decorations.map(r.changes),this.paused=!0):(this.decorations=io(r.state),this.paused=!1))}},{decorations:r=>r.decorations}),$c=[zc,Wc];function gu(r={}){return[Kl.of(r),$c]}const Kc=new N;function dn(r,t,e){let i=r.prop(t<0?N.openedBy:N.closedBy);if(i)return i;if(r.name.length==1){let s=e.indexOf(r.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function pn(r){let t=r.type.prop(Kc);return t?t(r.node):r}function Pi(r,t,e,i={}){let s=i.maxScanDistance||zl,n=i.brackets||$l,o=ae(r),l=o.resolveInner(t,e);for(let h=l;h;h=h.parent){let a=dn(h.type,e,n);if(a&&h.from<h.to){let f=pn(h);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return qc(r,t,e,h,f,a,n)}}return jc(r,t,e,o,l.type,s,n)}function qc(r,t,e,i,s,n,o){let l=i.parent,h={from:s.from,to:s.to},a=0,f=l?.cursor();if(f&&(e<0?f.childBefore(i.from):f.childAfter(i.to)))do if(e<0?f.to<=i.from:f.from>=i.to){if(a==0&&n.indexOf(f.type.name)>-1&&f.from<f.to){let c=pn(f);return{start:h,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(dn(f.type,e,o))a++;else if(dn(f.type,-e,o)){if(a==0){let c=pn(f);return{start:h,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}a--}}while(e<0?f.prevSibling():f.nextSibling());return{start:h,matched:!1}}function jc(r,t,e,i,s,n,o){if(e<0?!t:t==r.doc.length)return null;let l=e<0?r.sliceDoc(t-1,t):r.sliceDoc(t,t+1),h=o.indexOf(l);if(h<0||h%2==0!=e>0)return null;let a={from:e<0?t-1:t,to:e>0?t+1:t},f=r.doc.iterRange(t,e>0?r.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=n;){let d=f.value;e<0&&(u+=d.length);let p=t+u*e;for(let g=e>0?0:d.length-1,m=e>0?d.length:-1;g!=m;g+=e){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==e>0)c++;else{if(c==1)return{start:a,end:{from:p+g,to:p+g+1},matched:b>>1==h>>1};c--}}e>0&&(u+=d.length)}return f.done?{start:a,matched:!1}:null}const _c=Object.create(null),so=[ft.none],no=[],ro=Object.create(null),Gc=Object.create(null);for(let[r,t]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"]])Gc[r]=Qc(_c,t);function Ds(r,t){no.indexOf(r)>-1||(no.push(r),console.warn(t))}function Qc(r,t){let e=[];for(let l of t.split(" ")){let h=[];for(let a of l.split(".")){let f=r[a]||w[a];f?typeof f=="function"?h.length?h=h.map(f):Ds(a,`Modifier ${a} used at start of tag`):h.length?Ds(a,`Tag ${a} used as modifier`):h=Array.isArray(f)?f:[f]:Ds(a,`Unknown highlighting tag ${a}`)}for(let a of h)e.push(a)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+e.map(l=>l.id),n=ro[s];if(n)return n.id;let o=ro[s]=ft.define({id:so.length,name:i,props:[Rl({[i]:e})]});return so.push(o),o.id}_.RTL,_.LTR;const Uc=Xi.define({name:"json",parser:dc.configure({props:[Hl.add({Object:eo({except:/^\s*\}/}),Array:eo({except:/^\s*\]/})}),Bc.add({"Object Array":Rc})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Yc(){return new wc(Uc)}var Xc=Zi("<!> 已复制",1),Jc=Zi("<!> 复制",1),Zc=Zi('<div class="border-t bg-background/60 svelte-e020de" style="--cm-bg: transparent;" role="img"></div>'),tu=Zi('<div class="overflow-hidden rounded-lg border bg-muted/40 svelte-e020de"><div class="flex items-center gap-1 svelte-e020de"><button type="button" class="flex min-w-0 flex-1 items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><!> <span class="ml-auto font-mono text-[10px] text-muted-foreground/70"> </span></button> <button type="button" class="flex shrink-0 items-center gap-1 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" title="复制全部内容"><!></button></div> <!></div>');function mu(r,t){_l(t,!0);let e=Yl(t,"label",3,"载荷"),i=oi(!1),s=oi(!1),n=oi(void 0),o=oi(void 0);const l=zn(()=>Xl(t.value));async function h(){try{await navigator.clipboard.writeText(q(l)),ce(s,!0),setTimeout(()=>ce(s,!1),1500)}catch{}}Gl(()=>{if(!q(o)&&q(i)&&q(n)){const u=L.create({doc:q(l),extensions:[L.readOnly.of(!0),B.editable.of(!1),Ec(Lc,{fallback:!0}),Yc(),B.lineWrapping]});ce(o,new B({state:u,parent:q(n)}),!0)}else q(o)&&q(l)!==q(o).state.doc.toString()&&q(o).dispatch({changes:{from:0,to:q(o).state.doc.length,insert:q(l)}})}),jl(()=>{q(o)?.destroy(),ce(o,void 0)});var a=gn(),f=We(a);{var c=u=>{var d=tu(),p=li(d),g=li(p),m=li(g);{let E=zn(()=>Jl("size-3.5 shrink-0 transition-transform",q(i)&&"rotate-90"));eh(m,{get class(){return q(E)},"aria-hidden":"true"})}var b=hi(m),v=hi(b),y=Ul(v);ai(g);var P=hi(g,2),T=li(P);{var O=E=>{var D=Xc(),M=We(D);th(M,{class:"size-3.5 text-emerald-600","aria-hidden":"true"}),Kn(),te(E,D)},C=E=>{var D=Jc(),M=We(D);ih(M,{class:"size-3.5","aria-hidden":"true"}),Kn(),te(E,D)};hs(T,E=>{q(s)?E(O):E(C,-1)})}ai(P),ai(p);var R=hi(p,2);{var H=E=>{var D=Zc();Zl(D,M=>ce(n,M),()=>q(n)),$n(()=>qn(D,"aria-label",`${e()} 内容`)),te(E,D)};hs(R,E=>{q(i)&&E(H)})}ai(d),$n(()=>{qn(g,"aria-expanded",q(i)),Vn(b,` ${e()??""} `),Vn(y,`${q(l).length??""} 字符`)}),Fn("click",g,()=>ce(i,!q(i))),Fn("click",P,()=>{h()}),te(u,d)};hs(f,u=>{q(l)&&u(c)})}te(r,a),Ql()}ql(["click"]);export{Pe as A,fu as B,mu as C,_ as D,B as E,A as F,Yc as G,eh as H,Wl as I,N,we as R,Ut as S,it as T,at as V,ti as W,S as a,U as b,Mo as c,X as d,It as e,Ch as f,kc as g,W as h,vc as i,wt as j,xc as k,Ll as l,Pi as m,F as n,Lr as o,cu as p,xt as q,L as r,ae as s,uu as t,au as u,mf as v,gu as w,pu as x,Ec as y,Lc as z};