@bhsd/codemirror-mediawiki 2.1.1 → 2.1.2
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.
- package/dist/codemirror.d.ts +1 -1
- package/dist/main.min.js +10 -10
- package/dist/plugins.d.ts +1 -1
- package/mw/dist/base.js +9 -4
- package/package.json +1 -1
package/dist/main.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ld=Object.defineProperty;var ad=(n,e)=>{for(var t in e)ld(n,t,{get:e[t],enumerable:!0})};var ua=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var ee=(n,e,t)=>(ua(n,e,"read from private field"),t?t.call(n):e.get(n)),Gt=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Ut=(n,e,t,i)=>(ua(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var Z=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=wi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),gi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=wi(this,e,t);let i=[];return this.decompose(e,t,i,0),gi.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Xt(this),s=new Xt(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Xt(this,e)}iterRange(e,t=this.length){return new Un(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Yn(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new Ie(e):gi.from(Ie.split(e,[]))}},Ie=class n extends Z{constructor(e,t=hd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new Fs(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(da(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Gn(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=wi(this,e,t);let r=Gn(this.text,Gn(i.text,da(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):gi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=wi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},gi=class n extends Z{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=wi(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
|
-
`){[e,t]=wi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new Ie(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(p){let g;if(p.lines>s&&p instanceof n)for(let x of p.children)f(x);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ie&&a&&(g=c[c.length-1])instanceof Ie&&p.lines+g.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ie(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>r&&u(),a+=p.lines,h+=p.length+1,c.push(p))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let p of e)f(p);return u(),l.length==1?l[0]:new n(l,t)}};Z.empty=new Ie([""],0);function
|
|
4
|
-
`,this;e--}else if(r instanceof Ie){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Ie?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Un=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Xt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Yn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Z.prototype[Symbol.iterator]=function(){return this.iter()},Xt.prototype[Symbol.iterator]=Un.prototype[Symbol.iterator]=Yn.prototype[Symbol.iterator]=function(){return this});var Fs=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function wi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var bi="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;n<bi.length;n++)bi[n]+=bi[n-1];function hd(n){for(let e=1;e<bi.length;e+=2)if(bi[e]>n)return bi[e-1]<=n;return!1}function pa(n){return n>=127462&&n<=127487}var ma=8205;function be(n,e,t=!0,i=!0){return(t?xa:cd)(n,e,i)}function xa(n,e,t){if(e==n.length)return e;e&&va(n.charCodeAt(e))&&Sa(n.charCodeAt(e-1))&&e--;let i=$e(n,e);for(e+=wt(i);e<n.length;){let r=$e(n,e);if(i==ma||r==ma||t&&hd(r))e+=wt(r),i=r;else if(pa(r)){let s=0,o=e-2;for(;o>=0&&pa($e(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function cd(n,e,t){for(;e>0;){let i=xa(n,e-2,t);if(i<e)return i;e--}return 0}function va(n){return n>=56320&&n<57344}function Sa(n){return n>=55296&&n<56320}function $e(n,e){let t=n.charCodeAt(e);if(!Sa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return va(i)?(t-55296<<10)+(i-56320)+65536:t}function er(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function wt(n){return n<65536?1:2}var Hs=/\r\n?|\n/,Ce=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Ce||(Ce={})),yt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Vs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:Ca(this,e)}mapDesc(e,t=!1){return e.empty?this:Ws(this,e,t)}mapPos(e,t=-1,i=Ce.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ce.Simple&&h>=e&&(i==Ce.TrackDel&&r<e&&h>e||i==Ce.TrackBefore&&r<e||i==Ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},De=class n extends yt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Vs(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Ws(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(Z.empty);i.push(o?e.slice(s,s+o):Z.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Ca(this,e,!0)}map(e,t=!1){return e.empty?this:Ws(this,e,t,!0)}iterChanges(e,t=!1){Vs(this,e,t)}get desc(){return yt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Zt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Me(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Me(t,c,f),f>0&&Mt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Me(t,c,-1),Me(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:yt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Me(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:p}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=p?typeof p=="string"?Z.of(p.split(i||Hs)):p:Z.empty,x=g.length;if(f==u&&x==0)return;f<o&&a(),f>o&&Me(r,f-o,-1),Me(r,u-f,x),Mt(s,r,g),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Z.empty);i[r]=Z.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Me(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Z.empty);n.push(t)}}function Vs(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=Z.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Ws(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Zt(n),l=new Zt(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Me(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Me(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Me(r,0,o.ins),s&&Mt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Me(r,h,a<o.i?o.ins:0),s&&a<o.i&&Mt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?De.createSet(r,s):yt.create(r);throw new Error("Mismatched change set lengths")}}function Ca(n,e,t=!1){let i=[],r=t?[]:null,s=new Zt(n),o=new Zt(e);for(let l=!1;;){if(s.done&&o.done)return r?De.createSet(i,r):yt.create(i);if(s.ins==0)Me(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Me(i,0,o.ins,l),r&&Mt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Me(i,a,c,l),r&&c&&Mt(r,i,o.text)}else o.ins==-1?(Me(i,s.off?0:s.len,a,l),r&&Mt(r,i,s.textBit(a))):(Me(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Mt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Zt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Z.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Z.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},mi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>mi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return mi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?mi.create(t,e,48|s):mi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Aa(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Xs=0,I=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Xs++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Zs),!!e.static,e.enables)}of(e){return new ki([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Zs(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var ki=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Xs++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||js(f,c)){let p=i(f);if(l?!ga(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,g=u.config.address[s];if(g!=null){let x=Zn(u,g);if(this.dependencies.every(y=>y instanceof I?u.facet(y)===f.facet(y):y instanceof pe?u.field(y,!1)==f.field(y,!1):!0)||(l?ga(p=i(f),x,r):r(p=i(f),x)))return f.values[o]=x,0}else p=i(f);return f.values[o]=p,1}}}};function ga(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function js(n,e){let t=!1;for(let i of e)Ui(n,i)&1&&(t=!0);return t}function fd(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Zn(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Ui(a,h);return a.values[o]=l(a),1},update(a,h){if(!js(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=js(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Zs(t,f))return a.values[o]=u,0;let p=l(a);return e.compare(p,u)?(a.values[o]=u,0):(a.values[o]=p,1)}}}var ba=I.define({static:!0}),pe=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Xs++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ba).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,ba.of({field:this,create:e})]}get extension(){return this}},Yt={lowest:4,low:3,default:2,high:1,highest:0};function Gi(n){return e=>new Jn(e,n)}var Lt={highest:Gi(Yt.highest),high:Gi(Yt.high),default:Gi(Yt.default),low:Gi(Yt.low),lowest:Gi(Yt.lowest)},Jn=class{constructor(e,t){this.inner=e,this.prec=t}},xt=class n{of(e){return new Yi(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Yi=class{constructor(e,t){this.compartment=e,this.inner=t}},Xn=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of ud(e,t,o))u instanceof pe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(p=>u.slot(p));let c=i==null?void 0:i.config.facets;for(let u in s){let p=s[u],g=p[0].facet,x=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[g.id]=a.length<<1|1,Zs(x,p))a.push(i.facet(g));else{let y=g.combine(p.map(v=>v.value));a.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(v=>y.dynamicSlot(v)));l[g.id]=h.length<<1,h.push(y=>fd(y,g,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function ud(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Yi&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Yi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Jn)s(o.inner,o.prec);else if(o instanceof pe)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ki)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Yt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,Yt.default),i.reduce((o,l)=>o.concat(l))}function Ui(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Zn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ta=I.define(),qs=I.define({combine:n=>n.some(e=>e),static:!0}),Ma=I.define({combine:n=>n.length?n[0]:void 0,static:!0}),La=I.define(),Da=I.define(),Oa=I.define(),Ea=I.define({combine:n=>n.length?n[0]:!1}),Ne=class{constructor(e,t){this.type=e,this.value=t}static define(){return new $s}},$s=class{of(e){return new Ne(this,e)}},Ks=class{constructor(e){this.map=e}of(e){return new J(this,e)}},J=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ks(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};J.reconfigure=J.define();J.appendConfig=J.define();var xe=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Aa(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};xe.time=Ne.define();xe.userEvent=Ne.define();xe.addToHistory=Ne.define();xe.remote=Ne.define();function dd(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ba(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=De.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:J.mapEffects(n.effects,r).concat(J.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function _s(n,e,t){let i=e.selection,r=yi(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,n.facet(Ma)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:yi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Pa(n,e,t){let i=_s(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Ba(i,_s(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=xe.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return md(t?pd(r):r)}function pd(n){let e=n.startState,t=!0;for(let r of e.facet(La)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:dd(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=De.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=xe.create(e,r,n.selection&&n.selection.map(s),J.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Da);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof xe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?n=s[0]:n=Pa(e,yi(s),!1)}return n}function md(n){let e=n.startState,t=e.facet(Oa),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Ba(i,_s(e,s,n.changes.newLength),!0))}return i==n?n:xe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var gd=[];function yi(n){return n==null?gd:Array.isArray(n)?n:[n]}var fe=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(fe||(fe={})),bd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Gs;try{Gs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function kd(n){if(Gs)return Gs.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||bd.test(t)))return!0}return!1}function yd(n){return e=>{if(!/\S/.test(e))return fe.Space;if(kd(e))return fe.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return fe.Word;return fe.Other}}var he=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ui(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Ui(this,i),Zn(this,i)}update(...e){return Pa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(xt.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,i=l.value):l.is(J.appendConfig)&&(t=null,i=yi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Xn.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(qs)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=yi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(yi(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Z.of(e.split(this.facet(n.lineSeparator)||Hs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ui(this,t),Zn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof pe&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Xn.resolve(e.extensions||[],new Map),i=e.doc instanceof Z?e.doc:Z.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Hs)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Aa(r,i.length),t.staticFacet(qs)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
|
|
5
|
-
`}get readOnly(){return this.facet(Ea)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ta))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return yd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=be(t,o,!1);if(s(t.slice(a,o))!=fe.Word)break;o=a}for(;l<r;){let a=be(t,l);if(s(t.slice(l,a))!=fe.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};he.allowMultipleSelections=qs;he.tabSize=I.define({combine:n=>n.length?n[0]:4});he.lineSeparator=Ma;he.readOnly=Ea;he.phrases=I.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});he.languageData=Ta;he.changeFilter=La;he.transactionFilter=Da;he.transactionExtender=Oa;xt.reconfigure=J.define();function ze(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ze=class{eq(e){return this==e}range(e,t=e){return Ji.create(e,t,this)}};Ze.prototype.startSide=Ze.prototype.endSide=0;Ze.prototype.point=!1;Ze.prototype.mapMode=Ce.TrackDel;var Ji=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Us(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Ys=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,p;if(c==f){let g=t.mapPos(c,h.startSide,h.mapMode);if(g==null||(u=p=g,h.startSide!=h.endSide&&(p=t.mapPos(c,h.endSide),p<u)))continue}else if(u=t.mapPos(c,h.startSide),p=t.mapPos(f,h.endSide),u>p||u==p&&h.startSide>0&&h.endSide<=0)continue;(p-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,p-u)),i.push(h),r.push(u-o),s.push(p-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},ie=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Us)),this.isEmpty)return t.length?n.of(t):this;let l=new Qn(this,null,-1).goto(0),a=0,h=[],c=new ot;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(Ji.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Xi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Xi.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ka(o,l,i),h=new Jt(o,a,s),c=new Jt(l,a,s);i.iterGaps((f,u,p)=>ya(h,f,c,u,p,r)),i.empty&&i.length==0&&ya(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ka(s,o),a=new Jt(s,l,0).goto(i),h=new Jt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Js(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Jt(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new ot;for(let r of e instanceof Ji?[e]:t?wd(e):e)i.add(r.from,r.to,r.value);return i.finish()}};ie.empty=new ie([],[],null,-1);function wd(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Us(e,i)>0)return n.slice().sort(Us);e=i}return n}ie.empty.nextLayer=ie.empty;var ot=class n{finishChunk(e){this.chunks.push(new Ys(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ka(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var Qn=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Xi=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new Qn(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),zs(this.heap,0)}}};function zs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Jt=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Xi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Kn(this.active,e),Kn(this.activeTo,e),Kn(this.activeRank,e),this.minActive=wa(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;_n(this.active,t,i),_n(this.activeTo,t,r),_n(this.activeRank,t,s),e&&_n(e,t,this.cursor.from),this.minActive=wa(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Kn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function ya(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e;for(;;){let h=n.to+a-t.to||n.endSide-t.endSide,c=h<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&Js(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!Js(n.active,t.active)&&s.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function Js(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function Kn(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function _n(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function wa(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Dt(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=be(n,r));return i}function Ra(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=be(n,r)}return i===!0?-1:n.length}var Qs="\u037C",Ia=typeof Symbol=="undefined"?"__"+Qs:Symbol.for(Qs),eo=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Na=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ke=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let p in l){let g=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(y=>x.replace(/&/,y))).reduce((x,y)=>x.concat(y)),g,a);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,u)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+g+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
3
|
+
`){[e,t]=wi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new Ie(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(p){let g;if(p.lines>s&&p instanceof n)for(let x of p.children)f(x);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ie&&a&&(g=c[c.length-1])instanceof Ie&&p.lines+g.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ie(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>r&&u(),a+=p.lines,h+=p.length+1,c.push(p))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let p of e)f(p);return u(),l.length==1?l[0]:new n(l,t)}};Z.empty=new Ie([""],0);function hd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Gn(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function da(n,e,t){return Gn(n,[""],e,t)}var Xt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Ie?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Ie?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;e--}else if(r instanceof Ie){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Ie?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Un=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Xt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Yn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Z.prototype[Symbol.iterator]=function(){return this.iter()},Xt.prototype[Symbol.iterator]=Un.prototype[Symbol.iterator]=Yn.prototype[Symbol.iterator]=function(){return this});var Fs=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function wi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var bi="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;n<bi.length;n++)bi[n]+=bi[n-1];function cd(n){for(let e=1;e<bi.length;e+=2)if(bi[e]>n)return bi[e-1]<=n;return!1}function pa(n){return n>=127462&&n<=127487}var ma=8205;function be(n,e,t=!0,i=!0){return(t?xa:fd)(n,e,i)}function xa(n,e,t){if(e==n.length)return e;e&&va(n.charCodeAt(e))&&Sa(n.charCodeAt(e-1))&&e--;let i=$e(n,e);for(e+=wt(i);e<n.length;){let r=$e(n,e);if(i==ma||r==ma||t&&cd(r))e+=wt(r),i=r;else if(pa(r)){let s=0,o=e-2;for(;o>=0&&pa($e(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function fd(n,e,t){for(;e>0;){let i=xa(n,e-2,t);if(i<e)return i;e--}return 0}function va(n){return n>=56320&&n<57344}function Sa(n){return n>=55296&&n<56320}function $e(n,e){let t=n.charCodeAt(e);if(!Sa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return va(i)?(t-55296<<10)+(i-56320)+65536:t}function er(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function wt(n){return n<65536?1:2}var Hs=/\r\n?|\n/,Ce=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Ce||(Ce={})),yt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Vs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:Ca(this,e)}mapDesc(e,t=!1){return e.empty?this:Ws(this,e,t)}mapPos(e,t=-1,i=Ce.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ce.Simple&&h>=e&&(i==Ce.TrackDel&&r<e&&h>e||i==Ce.TrackBefore&&r<e||i==Ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},De=class n extends yt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Vs(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Ws(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(Z.empty);i.push(o?e.slice(s,s+o):Z.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Ca(this,e,!0)}map(e,t=!1){return e.empty?this:Ws(this,e,t,!0)}iterChanges(e,t=!1){Vs(this,e,t)}get desc(){return yt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Zt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Me(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Me(t,c,f),f>0&&Mt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Me(t,c,-1),Me(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:yt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Me(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:p}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=p?typeof p=="string"?Z.of(p.split(i||Hs)):p:Z.empty,x=g.length;if(f==u&&x==0)return;f<o&&a(),f>o&&Me(r,f-o,-1),Me(r,u-f,x),Mt(s,r,g),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Z.empty);i[r]=Z.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Me(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Z.empty);n.push(t)}}function Vs(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=Z.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Ws(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Zt(n),l=new Zt(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Me(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Me(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Me(r,0,o.ins),s&&Mt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Me(r,h,a<o.i?o.ins:0),s&&a<o.i&&Mt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?De.createSet(r,s):yt.create(r);throw new Error("Mismatched change set lengths")}}function Ca(n,e,t=!1){let i=[],r=t?[]:null,s=new Zt(n),o=new Zt(e);for(let l=!1;;){if(s.done&&o.done)return r?De.createSet(i,r):yt.create(i);if(s.ins==0)Me(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Me(i,0,o.ins,l),r&&Mt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Me(i,a,c,l),r&&c&&Mt(r,i,o.text)}else o.ins==-1?(Me(i,s.off?0:s.len,a,l),r&&Mt(r,i,s.textBit(a))):(Me(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Mt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Zt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Z.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Z.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},mi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>mi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return mi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?mi.create(t,e,48|s):mi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Aa(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Xs=0,I=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Xs++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Zs),!!e.static,e.enables)}of(e){return new ki([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Zs(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var ki=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Xs++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||js(f,c)){let p=i(f);if(l?!ga(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,g=u.config.address[s];if(g!=null){let x=Zn(u,g);if(this.dependencies.every(y=>y instanceof I?u.facet(y)===f.facet(y):y instanceof pe?u.field(y,!1)==f.field(y,!1):!0)||(l?ga(p=i(f),x,r):r(p=i(f),x)))return f.values[o]=x,0}else p=i(f);return f.values[o]=p,1}}}};function ga(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function js(n,e){let t=!1;for(let i of e)Ui(n,i)&1&&(t=!0);return t}function ud(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Zn(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Ui(a,h);return a.values[o]=l(a),1},update(a,h){if(!js(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=js(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Zs(t,f))return a.values[o]=u,0;let p=l(a);return e.compare(p,u)?(a.values[o]=u,0):(a.values[o]=p,1)}}}var ba=I.define({static:!0}),pe=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Xs++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ba).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,ba.of({field:this,create:e})]}get extension(){return this}},Yt={lowest:4,low:3,default:2,high:1,highest:0};function Gi(n){return e=>new Jn(e,n)}var Lt={highest:Gi(Yt.highest),high:Gi(Yt.high),default:Gi(Yt.default),low:Gi(Yt.low),lowest:Gi(Yt.lowest)},Jn=class{constructor(e,t){this.inner=e,this.prec=t}},xt=class n{of(e){return new Yi(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Yi=class{constructor(e,t){this.compartment=e,this.inner=t}},Xn=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of dd(e,t,o))u instanceof pe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(p=>u.slot(p));let c=i==null?void 0:i.config.facets;for(let u in s){let p=s[u],g=p[0].facet,x=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[g.id]=a.length<<1|1,Zs(x,p))a.push(i.facet(g));else{let y=g.combine(p.map(v=>v.value));a.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(v=>y.dynamicSlot(v)));l[g.id]=h.length<<1,h.push(y=>ud(y,g,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function dd(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Yi&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Yi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Jn)s(o.inner,o.prec);else if(o instanceof pe)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ki)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Yt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,Yt.default),i.reduce((o,l)=>o.concat(l))}function Ui(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Zn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ta=I.define(),qs=I.define({combine:n=>n.some(e=>e),static:!0}),Ma=I.define({combine:n=>n.length?n[0]:void 0,static:!0}),La=I.define(),Da=I.define(),Oa=I.define(),Ea=I.define({combine:n=>n.length?n[0]:!1}),Ne=class{constructor(e,t){this.type=e,this.value=t}static define(){return new $s}},$s=class{of(e){return new Ne(this,e)}},Ks=class{constructor(e){this.map=e}of(e){return new J(this,e)}},J=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ks(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};J.reconfigure=J.define();J.appendConfig=J.define();var xe=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Aa(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};xe.time=Ne.define();xe.userEvent=Ne.define();xe.addToHistory=Ne.define();xe.remote=Ne.define();function pd(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ba(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=De.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:J.mapEffects(n.effects,r).concat(J.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function _s(n,e,t){let i=e.selection,r=yi(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,n.facet(Ma)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:yi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Pa(n,e,t){let i=_s(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Ba(i,_s(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=xe.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return gd(t?md(r):r)}function md(n){let e=n.startState,t=!0;for(let r of e.facet(La)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:pd(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=De.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=xe.create(e,r,n.selection&&n.selection.map(s),J.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Da);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof xe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?n=s[0]:n=Pa(e,yi(s),!1)}return n}function gd(n){let e=n.startState,t=e.facet(Oa),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Ba(i,_s(e,s,n.changes.newLength),!0))}return i==n?n:xe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var bd=[];function yi(n){return n==null?bd:Array.isArray(n)?n:[n]}var fe=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(fe||(fe={})),kd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Gs;try{Gs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function yd(n){if(Gs)return Gs.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||kd.test(t)))return!0}return!1}function wd(n){return e=>{if(!/\S/.test(e))return fe.Space;if(yd(e))return fe.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return fe.Word;return fe.Other}}var oe=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ui(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Ui(this,i),Zn(this,i)}update(...e){return Pa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(xt.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,i=l.value):l.is(J.appendConfig)&&(t=null,i=yi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Xn.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(qs)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=yi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(yi(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Z.of(e.split(this.facet(n.lineSeparator)||Hs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ui(this,t),Zn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof pe&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Xn.resolve(e.extensions||[],new Map),i=e.doc instanceof Z?e.doc:Z.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Hs)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Aa(r,i.length),t.staticFacet(qs)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(Ea)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ta))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return wd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=be(t,o,!1);if(s(t.slice(a,o))!=fe.Word)break;o=a}for(;l<r;){let a=be(t,l);if(s(t.slice(l,a))!=fe.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};oe.allowMultipleSelections=qs;oe.tabSize=I.define({combine:n=>n.length?n[0]:4});oe.lineSeparator=Ma;oe.readOnly=Ea;oe.phrases=I.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});oe.languageData=Ta;oe.changeFilter=La;oe.transactionFilter=Da;oe.transactionExtender=Oa;xt.reconfigure=J.define();function ze(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ze=class{eq(e){return this==e}range(e,t=e){return Ji.create(e,t,this)}};Ze.prototype.startSide=Ze.prototype.endSide=0;Ze.prototype.point=!1;Ze.prototype.mapMode=Ce.TrackDel;var Ji=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Us(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Ys=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,p;if(c==f){let g=t.mapPos(c,h.startSide,h.mapMode);if(g==null||(u=p=g,h.startSide!=h.endSide&&(p=t.mapPos(c,h.endSide),p<u)))continue}else if(u=t.mapPos(c,h.startSide),p=t.mapPos(f,h.endSide),u>p||u==p&&h.startSide>0&&h.endSide<=0)continue;(p-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,p-u)),i.push(h),r.push(u-o),s.push(p-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},ie=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Us)),this.isEmpty)return t.length?n.of(t):this;let l=new Qn(this,null,-1).goto(0),a=0,h=[],c=new ot;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(Ji.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Xi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Xi.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ka(o,l,i),h=new Jt(o,a,s),c=new Jt(l,a,s);i.iterGaps((f,u,p)=>ya(h,f,c,u,p,r)),i.empty&&i.length==0&&ya(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ka(s,o),a=new Jt(s,l,0).goto(i),h=new Jt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Js(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Jt(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new ot;for(let r of e instanceof Ji?[e]:t?xd(e):e)i.add(r.from,r.to,r.value);return i.finish()}};ie.empty=new ie([],[],null,-1);function xd(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Us(e,i)>0)return n.slice().sort(Us);e=i}return n}ie.empty.nextLayer=ie.empty;var ot=class n{finishChunk(e){this.chunks.push(new Ys(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ka(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var Qn=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Xi=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new Qn(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),zs(this.heap,0)}}};function zs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Jt=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Xi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Kn(this.active,e),Kn(this.activeTo,e),Kn(this.activeRank,e),this.minActive=wa(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;_n(this.active,t,i),_n(this.activeTo,t,r),_n(this.activeRank,t,s),e&&_n(e,t,this.cursor.from),this.minActive=wa(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Kn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function ya(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e;for(;;){let h=n.to+a-t.to||n.endSide-t.endSide,c=h<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&Js(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!Js(n.active,t.active)&&s.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function Js(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function Kn(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function _n(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function wa(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Dt(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=be(n,r));return i}function Ra(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=be(n,r)}return i===!0?-1:n.length}var Qs="\u037C",Ia=typeof Symbol=="undefined"?"__"+Qs:Symbol.for(Qs),eo=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Na=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ke=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let p in l){let g=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(y=>x.replace(/&/,y))).reduce((x,y)=>x.concat(y)),g,a);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,u)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+g+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
6
|
`)}static newName(){let e=Na[Ia]||1;return Na[Ia]=e+1,Qs+e.toString(36)}static mount(e,t,i){let r=e[eo],s=i&&i.nonce;r?s&&r.setNonce(s):r=new to(e,s),r.mount(Array.isArray(t)?t:[t])}},za=new Map,to=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=za.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[eo]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],za.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[eo]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),t)for(let a=0;a<o.rules.length;a++)t.insertRule(o.rules[a],i++)}else{for(;r<l;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
|
|
7
|
-
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var vt={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:"'"},xi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xd=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),vd=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ke=0;ke<10;ke++)vt[48+ke]=vt[96+ke]=String(ke);var ke;for(ke=1;ke<=24;ke++)vt[ke+111]="F"+ke;var ke;for(ke=65;ke<=90;ke++)vt[ke]=String.fromCharCode(ke+32),xi[ke]=String.fromCharCode(ke);var ke;for(tr in vt)xi.hasOwnProperty(tr)||(xi[tr]=vt[tr]);var tr;function Fa(n){var e=xd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||vd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?xi:vt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function mr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function co(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Sd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fr(n,e){if(!e.anchorNode)return!1;try{return co(n,e.anchorNode)}catch(t){return!1}}function cn(n){return n.nodeType==3?Qt(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gr(n,e,t,i){return t?Ha(n,e,t,i,-1)||Ha(n,e,t,i,1):!1}function fn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ha(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:St(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=fn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?St(n):0}else return!1}}function St(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Go(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Cd(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ch(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Ad(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,p=c==a.body,g=1,x=1;if(p)u=Cd(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let M=c.getBoundingClientRect();({scaleX:g,scaleY:x}=Ch(c,M)),u={left:M.left,right:M.left+c.clientWidth*g,top:M.top,bottom:M.top+c.clientHeight*x}}let y=0,v=0;if(r=="nearest")e.top<u.top?(v=-(u.top-e.top+o),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+o)));else{let M=e.bottom-e.top,O=u.bottom-u.top;v=(r=="center"&&M<=O?e.top+M/2-O/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-O+o)-u.top}if(i=="nearest"?e.left<u.left?(y=-(u.left-e.left+s),t>0&&e.right>u.right+y&&(y=e.right-u.right+y+s)):e.right>u.right&&(y=e.right-u.right+s,t<0&&e.left<u.left+y&&(y=-(u.left+y-e.left+s))):y=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,y||v)if(p)h.scrollBy(y,v);else{let M=0,O=0;if(v){let R=c.scrollTop;c.scrollTop+=v/x,O=(c.scrollTop-R)*x}if(y){let R=c.scrollLeft;c.scrollLeft+=y/g,M=(c.scrollLeft-R)*g}e={left:e.left-M,top:e.top-O,right:e.right-M,bottom:e.bottom-O},M&&Math.abs(M-y)<1&&(i="nearest"),O&&Math.abs(O-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Td(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var fo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?St(t):0),i,Math.min(e.focusOffset,i?St(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},vi=null;function Ah(n){if(n.setActive)return n.setActive();if(vi)return n.focus(vi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(vi==null?{get preventScroll(){return vi={preventScroll:!0},!0}}:void 0),!vi){vi=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var Va;function Qt(n,e,t=e){let i=Va||(Va=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ti(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Md(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Th(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Ld(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,St(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=St(t))}else{if(t==n)return!0;i=fn(t),t=t.parentNode}}function Mh(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var Oe=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,fn(e),t)}static after(e,t){return new n(e.parentNode,fn(e)+1,t)}},Uo=[],ue=class n{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=n.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=Wa(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=Wa(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=St(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!n.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Uo){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new br(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};ue.prototype.breakAfter=0;function Wa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var br=class{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function Lh(n,e,t,i,r,s,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&s.length<2&&c.merge(t,r,s.length?f:null,t==0,l,a))){if(i<h.length){let p=h[i];p&&(r<p.length||p.breakAfter&&(f!=null&&f.breakAfter))?(e==i&&(p=p.split(r),r=0),!u&&f&&p.merge(0,r,f,!0,0,a)?s[s.length-1]=p:((r||p.children.length&&!p.children[0].length)&&p.merge(0,r,null,!1,0,a),s.push(p))):p!=null&&p.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function Dh(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,Lh(n,h,c,l,a,i,0,r,s)}var Fe=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},uo=typeof document!="undefined"?document:{documentElement:{style:{}}},po=/Edge\/(\d+)/.exec(Fe.userAgent),Oh=/MSIE \d/.test(Fe.userAgent),mo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe.userAgent),Er=!!(Oh||mo||po),ja=!Er&&/gecko\/(\d+)/i.test(Fe.userAgent),io=!Er&&/Chrome\/(\d+)/.exec(Fe.userAgent),qa="webkitFontSmoothing"in uo.documentElement.style,Eh=!Er&&/Apple Computer/.test(Fe.vendor),$a=Eh&&(/Mobile\/\w+/.test(Fe.userAgent)||Fe.maxTouchPoints>2),H={mac:$a||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:Er,ie_version:Oh?uo.documentMode||6:mo?+mo[1]:po?+po[1]:0,gecko:ja,gecko_version:ja?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!io,chrome_version:io?+io[1]:0,ios:$a,android:/Android\b/.test(Fe.userAgent),webkit:qa,safari:Eh,webkit_version:qa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:uo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Dd=256,Bt=class n extends ue{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof n)||this.length-(t-e)+i.length>Dd||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new n(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Oe(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Od(this.dom,e,t)}},Pt=class n extends ue{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Th(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,r,s,o){return i&&(!(i instanceof n&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(Dh(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new n(this.mark,t,o)}domAtPos(e){return Bh(this,e)}coordsAt(e,t){return Rh(this,e,t)}};function Od(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?H.chrome||H.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Qt(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Go(a,o<0):a||null}var un=class n extends ue{static create(e,t,i){return new n(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=n.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof n&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Z.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Z.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return Go(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},dn=class n extends ue{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof n&&e.side==this.side}split(){return new n(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Oe.before(this.dom):Oe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Z.empty}get isHidden(){return!0}};Bt.prototype.children=un.prototype.children=dn.prototype.children=Uo;function Bh(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Oe(t,0)}function Ph(n,e,t){let i,{children:r}=n;t>0&&e instanceof Pt&&r.length&&(i=r[r.length-1])instanceof Pt&&i.mark.eq(e.mark)?Ph(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function Rh(n,e,t){let i=null,r=-1,s=null,o=-1;function l(h,c){for(let f=0,u=0;f<h.children.length&&u<=c;f++){let p=h.children[f],g=u+p.length;g>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(g>c||u==g&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==g&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=g}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Ed(n)}function Ed(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=cn(e);return t[t.length-1]||null}function go(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Ka=Object.create(null);function Yo(n,e,t){if(n==e)return!0;n||(n=Ka),e||(e=Ka);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function bo(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Bd(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ae=class n extends ue{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),Dh(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new n;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Yo(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ph(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=go(t,this.attrs||{})),i&&(this.attrs=go({class:i},this.attrs||{}))}domAtPos(e){return Bh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Th(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(bo(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&ue.get(r)instanceof Pt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=ue.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!H.ios||!this.children.some(s=>s instanceof Bt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Bt)||/[^ -~]/.test(i.text))return null;let r=cn(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Rh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof n)return s;if(o>t)break}r=o+s.breakAfter}return null}},Mi=class n extends ue{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new n(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Uo}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Z.empty}domBoundsAround(){return null}become(e){return e instanceof n&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}},et=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}destroy(e){}},Qe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Qe||(Qe={})),Y=class extends Ze{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new pn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Rt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Ih(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Rt(e,i,r,t,e.widget||null,!0)}static line(e){return new mn(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Y.none=ie.empty;var pn=class n extends Y{constructor(e){let{start:t,end:i}=Ih(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof n&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&Yo(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};pn.prototype.point=!1;var mn=class n extends Y{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Yo(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};mn.prototype.mapMode=Ce.TrackBefore;mn.prototype.point=!0;var Rt=class n extends Y{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ce.TrackBefore:Ce.TrackAfter:Ce.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Pd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Rt.prototype.point=!0;function Ih(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function Pd(n,e){return n==e||!!(n&&e&&n.compare(e))}function ko(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var rn=class n{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Mi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ir(new dn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Mi)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ir(new Bt(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Rt){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Rt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Mi(i.widget||new kr("div"),l,i));else{let a=un.create(i.widget||new kr("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||s>r.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(f.append(ir(new dn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(ir(a,r),s),this.atCursorPos=c,this.pendingBuffer=c?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,i,r,s){let o=new n(e,t,i,s);return o.openEnd=ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function ir(n,e){for(let t of e)n=new Pt(t,[n],n.length);return n}var kr=class extends et{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},Nh=I.define(),zh=I.define(),Fh=I.define(),Hh=I.define(),yo=I.define(),Vh=I.define(),Wh=I.define(),jh=I.define({combine:n=>n.some(e=>e)}),Rd=I.define({combine:n=>n.some(e=>e)}),sn=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},nr=J.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Hh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Br=I.define({combine:n=>n.length?n[0]:!0}),Id=0,Qi=I.define(),ye=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(Id++,e,i,r,l=>{let a=[Qi.of(l)];return o&&a.push(gn.of(h=>{let c=h.plugin(l);return c?o(c):Y.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},on=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(He(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){He(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},qh=I.define(),Jo=I.define(),gn=I.define(),Xo=I.define(),$h=I.define();function _a(n,e,t){let i=n.state.facet($h);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return ie.spans(r,e,t,{point(){},span(o,l,a,h){let c=s;for(let f=a.length-1;f>=0;f--,h--){let u=a[f].spec.bidiIsolate,p;if(u!=null)if(h>0&&c.length&&(p=c[c.length-1]).to==o&&p.direction==u)p.to=l,c=p.inner;else{let g={from:o,to:l,direction:u,inner:[]};c.push(g),c=g.inner}}}}),s}var Kh=I.define();function _h(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Kh)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var en=I.define(),ct=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],h=o-l,c=a?a.fromB:1e9;for(;s<t.length&&t[s]<c;){let f=t[s],u=t[s+1],p=Math.max(l,f),g=Math.min(c,u);if(p<=g&&new n(p+h,g+h,p,g).addToSet(i),u>c)break;s+=2}if(!a)return i;new n(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},yr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ct(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ge=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ge||(ge={})),bn=ge.LTR,Gh=ge.RTL;function Uh(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Nd=Uh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),zd=Uh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),wo=Object.create(null),lt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);wo[e]=t,wo[t]=-e}function Fd(n){return n<=247?Nd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?zd[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Hd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ht=class{get dir(){return this.level%2?Gh:bn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Yh(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Yh(i.inner,r.inner))return!1}return!0}var oe=[];function Vd(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=Fd(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),oe[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=oe[h];if(u==128)h<l-1&&c==oe[h+1]&&c&24?u=oe[h]=c:oe[h]=256;else if(u==64){let p=h+1;for(;p<l&&oe[p]==64;)p++;let g=h&&c==8||p<t&&oe[p]==8?f==1?1:8:256;for(let x=h;x<p;x++)oe[x]=g;h=p-1}else u==8&&f==1&&(oe[h]=1);c=u,u&7&&(f=u)}}}function Wd(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,p,g;f<c;f++)if(p=wo[u=n.charCodeAt(f)])if(p<0){for(let x=l-3;x>=0;x-=3)if(lt[x+1]==-p){let y=lt[x+2],v=y&2?r:y&4?y&1?s:r:0;v&&(oe[f]=oe[lt[x]]=v),l=x;break}}else{if(lt.length==189)break;lt[l++]=f,lt[l++]=u,lt[l++]=a}else if((g=oe[f])==2||g==1){let x=g==r;a=x?0:1;for(let y=l-3;y>=0;y-=3){let v=lt[y+2];if(v&2)break;if(x)lt[y+2]|=2;else{if(v&4)break;lt[y+2]|=4}}}}}function jd(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=oe[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(oe[c]==256)c++;else break;let f=s==1,u=(c<e?oe[c]:i)==1,p=f==u?f?1:2:i;for(let g=c,x=r,y=x?t[x-1].to:n;g>a;)g==y&&(g=t[--x].from,y=x?t[x-1].to:n),oe[--g]=p;a=c}else s=h,a++}}}function xo(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let x=oe[a];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h<s.length&&g==s[h].from){if(f)break e;let x=s[h];if(!c)for(let y=x.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(oe[y]==l)break e;break}}if(h++,u)u.push(x);else{x.from>a&&o.push(new ht(a,x.from,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.to}g=x.to}else{if(g==t||(c?oe[g]!=l:oe[g]==l))break;g++}u?xo(n,a,g,i+1,r,u,o):a<g&&o.push(new ht(a,g,p)),a=g}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let x=oe[a-1];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h&&g==s[h-1].to){if(f)break e;let x=s[--h];if(!c)for(let y=x.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(oe[y-1]==l)break e;break}}if(u)u.push(x);else{x.to<a&&o.push(new ht(x.to,a,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.from}g=x.from}else{if(g==e||(c?oe[g-1]!=l:oe[g-1]==l))break;g--}u?xo(n,g,a,i+1,r,u,o):g<a&&o.push(new ht(g,a,p)),a=g}}function vo(n,e,t,i,r,s,o){let l=e%2?2:1;Vd(n,r,s,i,l),Wd(n,r,s,i,l),jd(r,s,i,l),xo(n,r,s,e,t,i,o)}function qd(n,e,t){if(!n)return[new ht(0,0,e==Gh?1:0)];if(e==bn&&!t.length&&!Hd.test(n))return Jh(n.length);if(t.length)for(;n.length>oe.length;)oe[oe.length]=256;let i=[],r=e==bn?0:1;return vo(n,r,r,t,0,n.length,i),i}function Jh(n){return[new ht(0,n,0)]}var Xh="";function $d(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=ht.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let a=e[l];o==a.side(r,t)&&(a=e[l+=r?1:-1],o=a.side(!r,t));let h=r==(a.dir==t),c=be(n.text,o,h);if(Xh=n.text.slice(Math.min(o,c),Math.max(o,c)),c>a.from&&c<a.to)return L.cursor(c+n.from,h?-1:1,a.level);let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!f&&a.level!=t?L.cursor(r?n.to:n.from,r?-1:1,t):f&&f.level<a.level?L.cursor(f.side(!r,t)+n.from,r?1:-1,f.level):L.cursor(c+n.from,r?-1:1,a.level)}var wr=class extends ue{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ct(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>c<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Xd(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?_d(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new ct(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(H.ie||H.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Yd(o,l,e.changes);return i=ct.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=H.chrome||H.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Mi&&o.widget instanceof xr&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,p,g,x;if(i&&i.range.fromB<f&&i.range.toB>c){let R=rn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),F=rn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=R.breakAtStart,g=R.openStart,x=F.openEnd;let q=this.compositionView(i);F.breakAtStart?q.breakAfter=1:F.content.length&&q.merge(q.length,q.length,F.content[0],!1,F.openStart,0)&&(q.breakAfter=F.content[0].breakAfter,F.content.shift()),R.content.length&&q.merge(0,0,R.content[R.content.length-1],!0,0,R.openEnd)&&R.content.pop(),u=R.content.concat(q).concat(F.content)}else({content:u,breakAtStart:p,openStart:g,openEnd:x}=rn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:M,off:O}=s.findPos(a,-1);Lh(this,M,O,y,v,u,p,g,x)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Bt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Pt(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=ue.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&fr(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(H.gecko&&l.empty&&!this.hasComposition&&Kd(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Oe(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!gr(a.node,a.offset,c.anchorNode,c.anchorOffset)||!gr(h.node,h.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(c.focusNode)&&Jd(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=mr(this.view.root);if(f)if(l.empty){if(H.gecko){let u=Gd(a.node,a.offset);if(u&&u!=3){let p=Qh(a.node,a.offset,u==1?1:-1);p&&(a=new Oe(p.node,p.offset))}}f.collapse(a.node,a.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(a.node,a.offset);try{f.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(u)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Oe(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Oe(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=mr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new Oe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ue.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=s-l.breakAfter,h=a-l.length;if(a<e)break;h<=e&&(h<e||l.covers(-1))&&(a>e||l.covers(1))&&(!i||l instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=l,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=a}if(!(r instanceof Bt))return null;let s=be(r.text,i);if(s==i)return null;let o=Qt(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ge.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>r)break;if(h>=i){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let g=f.dom.lastChild,x=g?cn(g):[];if(x.length){let y=x[x.length-1],v=a?y.right-p.left:p.right-y.left;v>l&&(l=v,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ge.RTL:ge.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;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.dom.appendChild(e);let s=cn(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new br(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Y.replace({widget:new xr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Y.set(e)}updateDeco(){let e=this.view.state.facet(gn).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=_h(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Ad(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ge.LTR)}};function Kd(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}var xr=class extends et{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function Zh(n,e){let t=n.observer.selectionRange,i=t.focusNode&&Qh(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function _d(n,e,t){let i=Zh(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new ct(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=ue.get(f);if(u instanceof Pt)c.push({node:f,deco:u.mark});else{if(u instanceof Ae||f.nodeName=="DIV"&&f.parentNode==n.contentDOM)return{range:h,text:r,marks:c,line:f};if(f!=n.contentDOM)c.push({node:f,deco:new pn({inclusive:!0,attributes:Bd(f),tagName:f.tagName.toLowerCase()})});else return null}}}function Qh(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=St(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function Gd(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Ud=class{constructor(){this.changes=[]}compareRange(e,t){ko(e,t,this.changes)}comparePoint(e,t){ko(e,t,this.changes)}};function Yd(n,e,t){let i=new Ud;return ie.compare(n,e,t,i),i.changes}function Jd(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Xd(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function Zd(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=be(r.text,s,!1):l=be(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=be(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=be(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function Qd(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function ep(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function no(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function Ga(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function Ua(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function So(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let g=n.firstChild;g;g=g.nextSibling){let x=cn(g);for(let y=0;y<x.length;y++){let v=x[y];r&&no(r,v)&&(v=Ga(Ua(v,r.bottom),r.top));let M=Qd(e,v),O=ep(t,v);if(M==0&&O==0)return g.nodeType==3?Ya(g,e,t):So(g,e,t);if(!i||o>O||o==O&&s>M){i=g,r=v,s=M,o=O;let R=O?t<v.top?-1:1:M?e<v.left?-1:1:0;l=!R||(R>0?y<x.length-1:y>0)}M==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=g,c=v):t<v.top&&(!f||f.top>v.top)&&(h=g,f=v):c&&no(c,v)?c=Ua(c,v.bottom):f&&no(f,v)&&(f=Ga(f,v.top))}}if(c&&c.bottom>=t?(i=a,r=c):f&&f.top<=t&&(i=h,r=f),!i)return{node:n,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return Ya(i,u,t);if(l&&i.contentEditable!="false")return So(i,u,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function Ya(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=Qt(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<s){let u=e>=(c.left+c.right)/2,p=u;if((H.chrome||H.gecko)&&Qt(n,l).getBoundingClientRect().left==c.right&&(p=!u),f<=0)return{node:n,offset:l+(p?1:0)};r=l+(p?1:0),s=f}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function ec(n,e,t,i=-1){var r,s;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,{x:c,y:f}=e,u=f-l;if(u<0)return 0;if(u>h)return n.state.doc.length;for(let R=n.viewState.heightOracle.textHeight/2,F=!1;a=n.elementAtHeight(u),a.type!=Qe.Text;)for(;u=i>0?a.bottom+R:a.top-R,!(u>=0&&u<=h);){if(F)return t?null:0;F=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:Ja(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:Ja(n,o,a,c,f);let g=n.dom.ownerDocument,x=n.root.elementFromPoint?n.root:g,y=x.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=x.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,M=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let R=g.caretPositionFromPoint(c,f);R&&({offsetNode:v,offset:M}=R)}else if(g.caretRangeFromPoint){let R=g.caretRangeFromPoint(c,f);R&&({startContainer:v,startOffset:M}=R,(!n.contentDOM.contains(v)||H.safari&&tp(v,M,c)||H.chrome&&ip(v,M,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let R=Ae.find(n.docView,p);if(!R)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:M}=So(R.dom,c,f))}let O=n.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let R=O.dom.getBoundingClientRect();return e.y<R.top||e.y<=R.bottom&&e.x<=(R.left+R.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,M)+O.posAtStart}function Ja(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Ra(o,s,n.state.tabSize)}function tp(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Qt(n,i-1,i).getBoundingClientRect().left>t}function ip(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():Qt(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function np(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Qe.Text))return i}return t}function rp(n,e,t,i){let r=np(n,e.head),s=!i||r.type!=Qe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ge.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return L.cursor(a,t?-1:1)}return L.cursor(t?r.to:r.from,t?-1:1)}function Xa(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=$d(r,s,o,l,t),c=Xh;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
|
|
8
|
-
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=L.cursor(t?r.from:r.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function sp(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==fe.Space&&(r=o),r==o}}function op(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(u+p)*s,x=ec(n,{x:f,y:g},!1,s);if(g<a.top||g>a.bottom||(s<0?x<r:x>r)){let y=n.docView.coordsForChar(x),v=!y||g<y.top?-1:1;return L.cursor(x,v,void 0,o)}}}function ur(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function ro(n,e,t){let i=ur(n.state.facet(Xo).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var Co=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&xp(e.contentDOM.ownerDocument)}handleEvent(e){!dp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=lp(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&ic.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=tc.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||ap.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Ti(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Za(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){He(t.state,r)}}}function lp(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(Za(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(Za(i.value,o))}}for(let i in tt)t(i).handlers.push(tt[i]);for(let i in it)t(i).observers.push(it[i]);return e}var tc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ap="dthko",ic=[16,17,18,20,91,92,224,225],rr=6;function sr(n){return Math.max(0,n)*.7+8}function hp(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var Ao=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Td(e.contentDOM),this.atoms=e.state.facet(Xo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(he.allowMultipleSelections)&&cp(e,t),this.dragging=up(e,t)&&oc(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&hp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=_h(this.view);e.clientX-o.left<=s.left+rr?i=-sr(s.left-e.clientX):e.clientX+o.right>=s.right-rr&&(i=sr(e.clientX-s.right)),e.clientY-o.top<=s.top+rr?r=-sr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-rr&&(r=sr(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=ur(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=ur(this.atoms,r.from,-1),l=ur(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function cp(n,e){let t=n.state.facet(Nh);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function fp(n,e){let t=n.state.facet(zh);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function up(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=mr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function dp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=ue.get(t))&&i.ignoreEvent(e))return!1;return!0}var tt=Object.create(null),it=Object.create(null),nc=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function pp(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),rc(n,t.value)},50)}function rc(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(To!=null&&t.selection.ranges.every(a=>a.empty)&&To==s.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:L.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:L.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}it.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};tt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);it.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};it.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};tt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Fh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=bp(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Ao(n,e,t,i)),i&&n.observer.ignore(()=>Ah(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function Qa(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return Zd(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.range(o,l)}}var sc=(n,e)=>n>=e.top&&n<=e.bottom,eh=(n,e,t)=>sc(e,t)&&n>=t.left&&n<=t.right;function mp(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&eh(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&eh(t,i,l)?1:o&&sc(i,o)?-1:1}function th(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:mp(n,t,e.clientX,e.clientY)}}var gp=H.ie&&H.ie_version<=11,ih=null,nh=0,rh=0;function oc(n){if(!gp)return n.detail;let e=ih,t=rh;return ih=n,rh=Date.now(),nh=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(nh+1)%3:1}function bp(n,e){let t=th(n,e),i=oc(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=th(n,s),h,c=Qa(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=Qa(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?L.range(u,p):L.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=kp(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function kp(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}tt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};tt.dragend=n=>(n.inputState.draggedContent=null,!1);function sh(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&fp(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}tt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&sh(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return sh(n,e,i,!0),!0}return!1};tt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=nc?null:e.clipboardData;return t?(rc(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(pp(n),!1)};function yp(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function wp(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}var To=null;tt.copy=tt.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=wp(n.state);if(!t&&!r)return!1;To=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=nc?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(yp(n,t),!1)};var lc=Ne.define();function ac(n,e){let t=[];for(let i of n.facet(Wh)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:lc.of(!0)}):null}function hc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=ac(n.state,e);t?n.dispatch(t):n.update([])}},10)}it.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),hc(n)};it.blur=n=>{n.observer.clearSelectionRange(),hc(n)};it.compositionstart=it.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};it.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,H.chrome&&H.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};it.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};tt.beforeinput=(n,e)=>{var t;let i;if(H.chrome&&H.android&&(i=tc.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};var oh=new Set;function xp(n){oh.has(n)||(oh.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var lh=["pre-wrap","normal","pre-line","break-spaces"],Mo=class{constructor(e){this.lineWrapping=e,this.doc=Z.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=lh.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},Lo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},at=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.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 Rt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(ce||(ce={})),dr=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>dr&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ce.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,ce.ByPosNoHeight,i,0,0);for(f+=p.to-h,h=p.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ce.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let g=Oo.build(i.setDoc(o),e,c,f);s=s.replace(a,h,g)}return s.updateHeight(i,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Do(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ve.prototype.size=1;var vr=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},_e=class n extends vr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Et&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Et?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Et=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new at(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new at(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new at(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new at(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let g=u.number-l;f+=a*g+h*(e-s-g)}let p=a+h*u.length;o(new at(u.from,u.length,f,p,0)),f+=p,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=dr&&(a=-2);let u=new _e(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=dr||Math.abs(a-this.heightMetrics(e,t).perLine)>=dr)&&(e.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Do=class extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ce.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ce.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&ah(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),ah(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function ah(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Et&&(i=n[e+1])instanceof Et&&n.splice(e-1,3,new Et(t.length+1+i.length))}var vp=5,Oo=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof _e?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _e(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new vr(o,r,i)):(o||s||r>=vp)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Et(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _e)return e;let t=new _e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _e&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return ie.spans(t,i,r,s,0),s.finish(i)}};function Sp(n,e,t){let i=new Eo;return ie.compare(n,e,t,i,0),i.changes}var Eo=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&ko(e,t,this.changes,5)}};function Cp(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=h==n.parentNode?u.bottom:Math.min(a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Ap(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ln=class{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return Y.replace({widget:new Bo(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Bo=class extends et{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Sr=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=hh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ge.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Jo).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Mo(t),this.stateDeco=e.facet(gn).filter(i=>typeof i!="function"),this.heightMap=Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle.setDoc(e.doc),[new ct(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Si(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?hh:new Po(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:tn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(gn).filter(c=>typeof c!="function");let r=e.changedRanges,s=ct.extendWithRanges(r,Sp(i,this.stateDeco,e?e.changes:De.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Rd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ge.RTL:ge.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:R,scaleY:F}=Ch(t,l);(this.scaleX!=R||this.scaleY!=F)&&(this.scaleX=R,this.scaleY=F,h|=8,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Mh(e.scrollDOM);let g=(this.printing?Ap:Cp)(t,this.paddingTop),x=g.top-this.pixelViewport.top,y=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&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let M=l.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let R=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(R)&&(o=!0),o||r.lineWrapping&&Math.abs(M-this.contentDOMWidth)>r.charWidth){let{lineHeight:F,charWidth:q,textHeight:w}=e.docView.measureTextSize();o=F>0&&r.refresh(s,F,q,w,M/q,R),o&&(e.docView.minWidth=0,h|=8)}x>0&&y>0?c=Math.max(x,y):x<0&&y<0&&(c=Math.min(x,y)),r.heightChanged=!1;for(let F of this.viewports){let q=F.from==this.viewport.from?R:e.docView.measureVisibleLineHeights(F);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Lo(F.from,q))}r.heightChanged&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Si(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ce.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Si(r.lineAt(u-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ce.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Si(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new ln(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ge.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let x=Mp(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!g.some(v=>y.from<v&&y.to>v));if(!x){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(L.cursor(c),!1,!0).head;y>h&&(c=y)}x=new ln(h,c,this.gapSize(f,h,c,u))}l.push(x)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Tp(h.from,h.to,this.stateDeco);if(c.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let v=lr(c,f),M=((this.visibleBottom-this.visibleTop)/2+g)/h.height;x=v-M,y=v+M}else x=(this.visibleTop-h.top-g)/h.height,y=(this.visibleBottom-h.top+g)/h.height;u=or(c,x),p=or(c,y)}else{let g=c.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,y,v;if(f!=null){let M=lr(c,f),O=((this.pixelViewport.right-this.pixelViewport.left)/2+x)/g;y=M-O,v=M+O}else y=(this.pixelViewport.left-x)/g,v=(this.pixelViewport.right+x)/g;u=or(c,y),p=or(c,v)}u>h.from&&a(h.from,u,h,c),p<h.to&&a(p,h.to,h,c)}return l}gapSize(e,t,i,r){let s=lr(r,i)-lr(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){ln.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||tn(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return tn(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return tn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Si=class{constructor(e,t){this.from=e,this.to=t}};function Tp(n,e,t){let i=[],r=n,s=0;return ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function or({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function lr(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Mp(n,e){for(let t of n)if(e(t))return t}var hh={toDOM(n){return n},fromDOM(n){return n},scale:1},Po=class{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ce.ByPos,e,0,0).top,c=t.lineAt(a,ce.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}};function tn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new at(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>tn(r,e)):n._content)}var ar=I.define({combine:n=>n.join(" ")}),Ro=I.define({combine:n=>n.indexOf(!0)>-1}),Io=Ke.newName(),cc=Ke.newName(),fc=Ke.newName(),uc={"&light":"."+cc,"&dark":"."+fc};function No(n,e,t){return new Ke(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var Lp=No("."+Io,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},uc),nn="\uFFFF",zo=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(he.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=nn}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=ue.get(r),a=ue.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:ch(r))||ch(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=ue.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Dp(e,i.node,i.offset)?t:0))}};function Dp(n,e,t){for(;;){if(!e||t<St(e))return!1;if(e==n)return!0;t=fn(e)+1,e=e.parentNode}}function ch(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Cr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Fo=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:Bp(e),a=new zo(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Pp(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!co(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!co(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=L.single(h,a)}}};function dc(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||H.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Ep(n.state.doc.sliceString(o,l,nn),e.text,a-o,h);c&&(H.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==nn+nn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Z.of(e.text.slice(c.from,c.toB).split(nn))})}else i&&(!n.hasFocus&&n.state.facet(Br)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
-
`&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}),t){if(H.ios&&n.inputState.flushIOSKey()||H.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Ti(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ti(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ti(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Op(n,t,i));return n.state.facet(Vh).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Op(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=r.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&Zh(n,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-g}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:l,range:a||g.map(l)};let x=g.to-u,y=x-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,x)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let v=r.changes({from:y,to:x,insert:e.insert}),M=g.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+M),Math.max(0,a.head+M)):g.map(v)}})}else i={changes:l,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function Ep(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Bp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Cr(t,i)),(r!=t||s!=i)&&e.push(new Cr(r,s))),e}function Pp(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?L.single(t+e,i+e):null}var Rp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},so=H.ie&&H.ie_version<=11,Ho=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new fo,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.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),so&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Br)?i.root.activeElement!=this.dom:!fr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!i.state.selection.main.empty&&r.focusNode&&gr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&Sd(this.dom.ownerDocument)==this.dom&&Ip(this.view)||mr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=fr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Ld(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Rp),so&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),so&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ti(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&fr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Fo(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=dc(this.view,t);return this.view.state==i&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=fh(t,e.previousSibling||e.target.previousSibling,-1),r=fh(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function fh(n,e,t){for(;e;){let i=ue.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ip(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return gr(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var z=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Md(e.parent)||document,this.viewState=new Sr(e.state||he.create(e)),e.scrollTo&&e.scrollTo.is(nr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qi).map(i=>new on(i));for(let i of this.plugins)i.update(this);this.observer=new Ho(this),this.inputState=new Co(this),this.inputState.ensureHandlers(this.plugins),this.docView=new wr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(lc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=ac(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(he.phrases)!=this.state.facet(he.phrases))return this.setState(s);r=yr.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:p}=u.state.selection;f=new sn(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(nr)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ar.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(en)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(ar)!=r.state.facet(ar)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(yo))try{u(r)}catch(p){He(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!dc(this,c)&&h.force&&Ti(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Sr(e),this.plugins=e.facet(Qi).map(i=>new on(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new wr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Qi),i=e.state.facet(Qi);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new on(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Mh(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(p=>{try{return p.read(this)}catch(g){return He(this.state,g),uh}}),f=yr.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f));for(let p=0;p<h.length;p++)if(c[p]!=uh)try{let g=h[p];g.write&&g.write(c[p],this)}catch(g){He(this.state,g)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(g>1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(yo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(Ro)?fc:cc)+" "+this.state.facet(ar)}updateAttrs(){let e=dh(this,qh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Br)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),dh(this,Jo,t);let i=this.observer.ignore(()=>{let r=bo(this.contentDOM,this.contentAttrs,t),s=bo(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(en);let e=this.state.facet(n.cspNonce);Ke.mount(this.root,this.styleModules.concat(Lp).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ro(this,e,Xa(this,e,t,i))}moveByGroup(e,t){return ro(this,e,Xa(this,e,t,i=>sp(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return rp(this,e,t,i)}moveVertically(e,t,i){return ro(this,e,op(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),ec(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ht.find(s,e-r.from,-1,t)];return Go(i,o.dir==ge.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(jh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Np)return Jh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Yh(s.isolates,i=_a(this,e.from,e.to))))return s.order;i||(i=_a(this,e.from,e.to));let r=qd(e.text,t,i);return this.bidiCache.push(new Ar(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ah(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return nr.of(new sn(typeof e=="number"?L.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return nr.of(new sn(L.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ye.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ye.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ke.newName(),r=[ar.of(i),en.of(No(`.${i}`,e))];return t&&t.dark&&r.push(Ro.of(!0)),r}static baseTheme(e){return Lt.lowest(en.of(No("."+Io,e,uc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&ue.get(i)||ue.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};z.styleModule=en;z.inputHandler=Vh;z.focusChangeEffect=Wh;z.perLineTextDirection=jh;z.exceptionSink=Hh;z.updateListener=yo;z.editable=Br;z.mouseSelectionStyle=Fh;z.dragMovesSelection=zh;z.clickAddsSelectionRange=Nh;z.decorations=gn;z.atomicRanges=Xo;z.bidiIsolatedRanges=$h;z.scrollMargins=Kh;z.darkTheme=Ro;z.cspNonce=I.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Jo;z.editorAttributes=qh;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=J.define();var Np=4096,uh={},Ar=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ge.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function dh(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&go(o,t)}return t}var zp=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Fp(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function hr(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var Hp=Lt.default(z.domEventHandlers({keydown(n,e){return gc(pc(e.state),n,e,"editor")}})),Pr=I.define({enables:Hp}),ph=new WeakMap;function pc(n){let e=n.facet(Pr),t=ph.get(e);return t||ph.set(e,t=Wp(e.reduce((i,r)=>i.concat(r),[]))),t}function mc(n,e,t){return gc(pc(n.state),e,n,t)}var Ot=null,Vp=4e3;function Wp(n,e=zp){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(v=>Fp(v,e));for(let v=1;v<g.length;v++){let M=g.slice(0,v).join(" ");r(M,!0),p[M]||(p[M]={preventDefault:!0,stopPropagation:!1,run:[O=>{let R=Ot={view:O,prefix:M,scope:o};return setTimeout(()=>{Ot==R&&(Ot=null)},Vp),!0}]})}let x=g.join(" ");r(x,!1);let y=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((u=(f=p._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),h&&(y.preventDefault=!0),c&&(y.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function gc(n,e,t,i){let r=Fa(e),s=$e(r,0),o=wt(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Ot&&Ot.view==t&&Ot.scope==i&&(l=Ot.prefix+" ",ic.indexOf(e.keyCode)<0&&(h=!0,Ot=null));let f=new Set,u=y=>{if(y){for(let v of y.run)if(!f.has(v)&&(f.add(v),v(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,x;return p&&(u(p[l+hr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(g=vt[e.keyCode])&&g!=r?(u(p[l+hr(g,e,!0)])||e.shiftKey&&(x=xi[e.keyCode])!=r&&x!=g&&u(p[l+hr(x,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+hr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var jp=!H.ios;var mh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};jp&&(mh[".cm-line"].caretColor="transparent !important",mh[".cm-content"]={caretColor:"transparent !important"});function gh(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function qp(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}var kn=class{constructor(e){let{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,h,c)=>r(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new ot,i=t.add.bind(t);for(let{from:r,to:s}of qp(e,this.maxLength))gh(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],p,g=(x,y,v)=>u.push(v.range(x,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<f-a.from;)this.addMatch(p,e,p.index+a.from,g);else gh(e.state.doc,this.regexp,c,f,(x,y)=>this.addMatch(y,e,x,g));t=t.update({filterFrom:c,filterTo:f,filter:(x,y)=>x<c||y>f,add:u})}}return t}},Vo=/x/.unicode!=null?"gu":"g",$p=new RegExp(`[\0-\b
|
|
10
|
-
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Vo),Kp={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},oo=null;function _p(){var n;if(oo==null&&typeof document!="undefined"&&document.body){let e=document.body.style;oo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return oo||!1}var pr=I.define({combine(n){let e=ze(n,{render:null,specialChars:$p,addSpecialChars:null});return(e.replaceTabs=!_p())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Vo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Vo)),e}});function bc(n={}){return[pr.of(n),Gp()]}var bh=null;function Gp(){return bh||(bh=ye.fromClass(class{constructor(n){this.view=n,this.decorations=Y.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(pr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new kn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=$e(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Dt(o.text,l,i-o.from);return Y.replace({widget:new jo((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Y.replace({widget:new Wo(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(pr);n.startState.facet(pr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}var Up="\u2022";function Yp(n){return n>=32?Up:n==10?"\u2424":String.fromCharCode(9216+n)}var Wo=class extends et{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Yp(this.code),i=e.state.phrase("Control character")+" "+(Kp[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}},jo=class extends et{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function kc(){return Xp}var Jp=Y.line({class:"cm-activeLine"}),Xp=ye.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(Jp.range(r.from)),e=r.from)}return Y.set(t)}},{decorations:n=>n.decorations});var Zi="-10000px",Tr=class{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(a.dom.remove(),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function Zp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var lo=I.define({combine:n=>{var e,t,i;return{position:H.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Zp}}}),kh=new WeakMap,yc=ye.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(lo);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Tr(n,yn,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(lo);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Zi,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(H.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(this.view.scaleX!=1||this.view.scaleY!=1)i=!0;else if(r.style.top==Zi&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(lo).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){c.style.top=Zi;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,x=u.right-u.left,y=(e=kh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||em,M=this.view.textDirection==ge.LTR,O=u.width>i.right-i.left?M?i.left:i.right-u.width:M?Math.min(f.left-(p?14:0)+v.x,i.right-x):Math.max(i.left,f.left-x+(p?14:0)-v.x),R=this.above[l];!a.strictSide&&(R?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&R==i.bottom-f.bottom>f.top-i.top&&(R=this.above[l]=!R);let F=(R?f.top-i.top:i.bottom-f.bottom)-g;if(F<y&&h.resize!==!1){if(F<this.view.defaultLineHeight){c.style.top=Zi;continue}kh.set(h,y),c.style.height=(y=F)/s+"px"}else c.style.height&&(c.style.height="");let q=R?f.top-y-g-v.y:f.bottom+g+v.y,w=O+x;if(h.overlap!==!0)for(let D of o)D.left<w&&D.right>O&&D.top<q+y&&D.bottom>q&&(q=R?D.top-y-2-g:D.bottom+g+2);if(this.position=="absolute"?(c.style.top=(q-n.parent.top)/s+"px",c.style.left=(O-n.parent.left)/r+"px"):(c.style.top=q/s+"px",c.style.left=O/r+"px"),p){let D=f.left+(M?v.x:-v.x)-(O+14-7);p.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:O,top:q,right:w,bottom:q+y}),c.classList.toggle("cm-tooltip-above",R),c.classList.toggle("cm-tooltip-below",!R),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Zi}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Qp=z.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),em={x:0,y:0},yn=I.define({enables:[yc,Qp]}),Mr=I.define(),Lr=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tr(e,Mr,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},tm=yn.compute([Mr],n=>{let e=n.facet(Mr).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Lr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),qo=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof un)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=a&&a.dir==ge.RTL?-1:1;s=t.x<l.left?-h:h}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(a=>{this.pending==l&&(this.pending=null,a&&e.dispatch({effects:this.setHover.of(a)}))},a=>He(e.state,a,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(yc),t=e?e.manager.tooltips.findIndex(i=>i.create==Lr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i&&r&&!im(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!nm(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},cr=4;function im(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-cr&&e.clientX<=t.right+cr&&e.clientY>=t.top-cr&&e.clientY<=t.bottom+cr}function nm(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=n.posAtCoords({x:i,y:r},!1);return a>=e&&a<=t}function wc(n,e={}){let t=J.define(),i=pe.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Ce.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(rm)&&(r=null);return r},provide:r=>Mr.from(r)});return[i,ye.define(r=>new qo(r,n,i,t,e.hoverTime||300)),tm]}var rm=J.define();var yh=I.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ti(n,e){let t=n.plugin(xc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var xc=ye.fromClass(class{constructor(n){this.input=n.state.facet(ei),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(yh);this.top=new Ci(n,!0,e.topContainer),this.bottom=new Ci(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(yh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ci(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ci(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ei);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Ci=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=wh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=wh(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function wh(n){let e=n.nextSibling;return n.remove(),e}var ei=I.define({enables:xc}),Ge=class extends Ze{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ge.prototype.elementClass="";Ge.prototype.toDOM=void 0;Ge.prototype.mapMode=Ce.TrackBefore;Ge.prototype.startSide=Ge.prototype.endSide=-1;Ge.prototype.point=!0;var ao=I.define(),sm={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},an=I.define();function Zo(n){return[vc(),an.of(Object.assign(Object.assign({},sm),n))]}var $o=I.define({combine:n=>n.some(e=>e)});function vc(n){let e=[om];return n&&n.fixed===!1&&e.push($o.of(!0)),e}var om=ye.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(an).map(e=>new Dr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet($o),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet($o)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=ie.iter(this.view.state.facet(ao),this.view.viewport.from),i=[],r=this.gutters.map(s=>new _o(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Qe.Text&&o){Ko(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Qe.Text){Ko(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(an),t=n.state.facet(an),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(ao),n.state.facet(ao),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Dr(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ge.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function xh(n){return Array.isArray(n)?n:[n]}function Ko(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var _o=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Or(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Ko(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Dr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=xh(t.markers(e)),t.initialSpacer&&(this.spacer=new Or(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=xh(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ie.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Or=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),lm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function lm(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var am=I.define(),Ai=I.define({combine(n){return ze(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),hn=class extends Ge{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function ho(n,e){return n.state.facet(Ai).formatNumber(e,n.state)}var hm=an.compute([Ai],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(am)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new hn(ho(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Ai)!=e.state.facet(Ai),initialSpacer(e){return new hn(ho(e,vh(e.state.doc.lines)))},updateSpacer(e,t){let i=ho(t.view,vh(t.view.state.doc.lines));return i==e.number?e:new hn(i)},domEventHandlers:n.facet(Ai).domEventHandlers}));function Sc(n={}){return[Ai.of(n),vc(),hm]}function vh(n){let e=9;for(;e<n;)e=e*10+9;return e}var Sh=new Map;function cm(n){let e=Sh.get(n);return e||Sh.set(n,e=Y.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function Cc(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var fm=Cc(new kn({regexp:/\t| +/g,decoration:n=>cm(n[0]),boundary:/\S/}));function Ac(){return fm}var um=Cc(new kn({regexp:/\s+$/g,decoration:Y.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Tc(){return um}var dm=0,wn=class{constructor(e,t){this.from=e,this.to=t}},X=class{constructor(e={}){this.id=dm++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ee.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};X.closedBy=new X({deserialize:n=>n.split(" ")});X.openedBy=new X({deserialize:n=>n.split(" ")});X.group=new X({deserialize:n=>n.split(" ")});X.contextHash=new X({perNode:!0});X.lookAhead=new X({perNode:!0});X.mounted=new X({perNode:!0});var Li=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[X.mounted.id]}},pm=Object.create(null),Ee=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):pm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.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(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(X.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(X.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Nr=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new Ee(i.name,r,i.id,i.flags):i)}return new n(t)}},Rr=new WeakMap,Mc=new WeakMap,ve;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ve||(ve={}));var de=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Li.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Rr.get(this)||this.topNode,s=new Sn(r);return s.moveTo(e,t),Rr.set(this,s._tree),s}get topNode(){return new ft(this,0,0,null)}resolve(e,t=0){let i=xn(Rr.get(this)||this.topNode,e,t,!1);return Rr.set(this,i),i}resolveInner(e,t=0){let i=xn(Mc.get(this)||this.topNode,e,t,!0);return Mc.set(this,i),i}resolveStack(e,t=0){return mm(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ve.IncludeAnonymous)>0;for(let a=this.cursor(o|ve.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:sl(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Ee.none,t,i,r)))}static build(e){return gm(e)}};de.empty=new de(Ee.none,[],[],0);var Qo=class n{constructor(e,t){this.buffer=e,this.index=t}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 n(this.buffer,this.index)}},It=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ee.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Oc(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function Oc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function xn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof ft&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ve.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof ft&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var zr=class{cursor(e=0){return new Sn(this,e)}getChild(e,t=null,i=null){let r=Lc(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Lc(this,e,t,i)}resolve(e,t=0){return xn(this,e,t,!1)}resolveInner(e,t=0){return xn(this,e,t,!0)}matchContext(e){return el(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},ft=class n extends zr{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Oc(r,i,f,f+c.length)){if(c instanceof It){if(s&ve.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new vn(new tl(o,c,e,f),null,u)}else if(s&ve.IncludeAnonymous||!c.type.isAnonymous||rl(c)){let u;if(!(s&ve.IgnoreMounts)&&(u=Li.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&ve.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ve.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let r;if(!(i&ve.IgnoreOverlays)&&(r=Li.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}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 Lc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function el(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var tl=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},vn=class n extends zr{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(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ve.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new de(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ec(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof ft&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new il(r,t)}var il=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ec(this.heads)}};function mm(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof ft?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Li.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ft(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(xn(l,e,t,!1))}}return r?Ec(r):i}var Sn=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ft)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof ft?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ve.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ve.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ve.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ve.IncludeAnonymous||l instanceof It||!l.type.isAnonymous||rl(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new vn(this.buffer,t,this.stack[r]);return this.bufferNode=new vn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return el(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return el(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function rl(n){return n.children.some(e=>e instanceof It||!e.type.isAnonymous||rl(e))}function gm(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Qo(t,t.length):t,a=i.types,h=0,c=0;function f(F,q,w,D,b,U){let{id:$,start:G,end:K,size:k}=l,T=c;for(;k<0;)if(l.next(),k==-1){let j=s[$];w.push(j),D.push(G-F);return}else if(k==-3){h=$;return}else if(k==-4){c=$;return}else throw new RangeError(`Unrecognized record size: ${k}`);let A=a[$],V,le,we=G-F;if(K-G<=r&&(le=y(l.pos-q,b))){let j=new Uint16Array(le.size-le.skip),W=l.pos-le.size,_=j.length;for(;l.pos>W;)_=v(le.start,j,_);V=new It(j,K-le.start,i),we=le.start-F}else{let j=l.pos-k;l.next();let W=[],_=[],ae=$>=o?$:-1,Ct=0,te=K;for(;l.pos>j;)ae>=0&&l.id==ae&&l.size>=0?(l.end<=te-r&&(g(W,_,G,Ct,l.end,te,ae,T),Ct=W.length,te=l.end),l.next()):U>2500?u(G,j,W,_):f(G,j,W,_,ae,U+1);if(ae>=0&&Ct>0&&Ct<W.length&&g(W,_,G,Ct,G,te,ae,T),W.reverse(),_.reverse(),ae>-1&&Ct>0){let Te=p(A);V=sl(A,W,_,0,W.length,0,K-G,Te,Te)}else V=x(A,W,_,K-G,T-K)}w.push(V),D.push(we)}function u(F,q,w,D){let b=[],U=0,$=-1;for(;l.pos>q;){let{id:G,start:K,end:k,size:T}=l;if(T>4)l.next();else{if($>-1&&K<$)break;$<0&&($=k-r),b.push(G,K,k),U++,l.next()}}if(U){let G=new Uint16Array(U*4),K=b[b.length-2];for(let k=b.length-3,T=0;k>=0;k-=3)G[T++]=b[k],G[T++]=b[k+1]-K,G[T++]=b[k+2]-K,G[T++]=T;w.push(new It(G,b[2]-K,i)),D.push(K-F)}}function p(F){return(q,w,D)=>{let b=0,U=q.length-1,$,G;if(U>=0&&($=q[U])instanceof de){if(!U&&$.type==F&&$.length==D)return $;(G=$.prop(X.lookAhead))&&(b=w[U]+$.length+G)}return x(F,q,w,D,b)}}function g(F,q,w,D,b,U,$,G){let K=[],k=[];for(;F.length>D;)K.push(F.pop()),k.push(q.pop()+w-b);F.push(x(i.types[$],K,k,U-b,G-U)),q.push(b-w)}function x(F,q,w,D,b=0,U){if(h){let $=[X.contextHash,h];U=U?[$].concat(U):[$]}if(b>25){let $=[X.lookAhead,b];U=U?[$].concat(U):[$]}return new de(F,q,w,D,U)}function y(F,q){let w=l.fork(),D=0,b=0,U=0,$=w.end-r,G={size:0,start:0,skip:0};e:for(let K=w.pos-F;w.pos>K;){let k=w.size;if(w.id==q&&k>=0){G.size=D,G.start=b,G.skip=U,U+=4,D+=4,w.next();continue}let T=w.pos-k;if(k<0||T<K||w.start<$)break;let A=w.id>=o?4:0,V=w.start;for(w.next();w.pos>T;){if(w.size<0)if(w.size==-3)A+=4;else break e;else w.id>=o&&(A+=4);w.next()}b=V,D+=k,U+=A}return(q<0||D==F)&&(G.size=D,G.start=b,G.skip=U),G.size>4?G:void 0}function v(F,q,w){let{id:D,start:b,end:U,size:$}=l;if(l.next(),$>=0&&D<o){let G=w;if($>4){let K=l.pos-($-4);for(;l.pos>K;)w=v(F,q,w)}q[--w]=G,q[--w]=U-F,q[--w]=b-F,q[--w]=D}else $==-3?h=D:$==-4&&(c=D);return w}let M=[],O=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,M,O,-1,0);let R=(e=n.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new de(a[n.topID],M.reverse(),O.reverse(),R)}var Dc=new WeakMap;function Ir(n,e){if(!n.isAnonymous||e instanceof It||e.type!=n)return 1;let t=Dc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof de)){t=1;break}t+=Ir(n,i)}Dc.set(e,t)}return t}function sl(n,e,t,i,r,s,o,l,a){let h=0;for(let g=i;g<r;g++)h+=Ir(n,e[g]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(g,x,y,v,M){for(let O=y;O<v;){let R=O,F=x[O],q=Ir(n,g[O]);for(O++;O<v;O++){let w=Ir(n,g[O]);if(q+w>=c)break;q+=w}if(O==R+1){if(q>c){let w=g[R];p(w.children,w.positions,0,w.children.length,x[R]+M);continue}f.push(g[R])}else{let w=x[O-1]+g[O-1].length-F;f.push(sl(n,g,x,R,O,F,w,null,a))}u.push(F+M-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var ii=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let p=Math.max(u.from,a)-h,g=Math.min(u.to,f)-h;u=p>=g?null:new n(p,g,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},Cn=class{startParse(e,t,i){return typeof e=="string"&&(e=new nl(e)),i=i?i.length?i.map(r=>new wn(r.from,r.to)):[new wn(0,0)]:[new wn(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},nl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var pb=new X({perNode:!0});var bm=0,Pe=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=bm++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new n([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Wr;return t=>t.modified.indexOf(e)>-1?t:Wr.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},km=0,Wr=class n{constructor(){this.instances=[],this.id=km++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&ym(t,l.modified));if(i)return i;let r=[],s=new Pe(r,e,t);for(let l of t)l.instances.push(s);let o=wm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function ym(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function wm(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Rc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Di(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Ic.add(e)}var Ic=new X,Di=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Di.empty=new Di([],2,null);function hl(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function xm(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Nc(n,e,t,i=0,r=n.length){let s=new ll(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var ll=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=vm(e)||Di.empty,f=xm(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(X.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),x=e.firstChild();for(let y=0,v=l;;y++){let M=y<u.overlay.length?u.overlay[y]:null,O=M?M.from+l:a,R=Math.max(t,v),F=Math.min(i,O);if(R<F&&x)for(;e.from<F&&(this.highlightRange(e,R,F,r,s),this.startSpan(Math.min(F,e.to),h),!(e.to>=O||!e.nextSibling())););if(!M||O>i)break;v=M.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,M.from+l),Math.min(i,v),"",g),this.startSpan(Math.min(i,v),h))}x&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function vm(n){let e=n.type.prop(Ic);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var E=Pe.define,Fr=E(),Nt=E(),Bc=E(Nt),Pc=E(Nt),zt=E(),Hr=E(zt),ol=E(zt),pt=E(),ni=E(pt),ut=E(),dt=E(),al=E(),An=E(al),Vr=E(),P={comment:Fr,lineComment:E(Fr),blockComment:E(Fr),docComment:E(Fr),name:Nt,variableName:E(Nt),typeName:Bc,tagName:E(Bc),propertyName:Pc,attributeName:E(Pc),className:E(Nt),labelName:E(Nt),namespace:E(Nt),macroName:E(Nt),literal:zt,string:Hr,docString:E(Hr),character:E(Hr),attributeValue:E(Hr),number:ol,integer:E(ol),float:E(ol),bool:E(zt),regexp:E(zt),escape:E(zt),color:E(zt),url:E(zt),keyword:ut,self:E(ut),null:E(ut),atom:E(ut),unit:E(ut),modifier:E(ut),operatorKeyword:E(ut),controlKeyword:E(ut),definitionKeyword:E(ut),moduleKeyword:E(ut),operator:dt,derefOperator:E(dt),arithmeticOperator:E(dt),logicOperator:E(dt),bitwiseOperator:E(dt),compareOperator:E(dt),updateOperator:E(dt),definitionOperator:E(dt),typeOperator:E(dt),controlOperator:E(dt),punctuation:al,separator:E(al),bracket:An,angleBracket:E(An),squareBracket:E(An),paren:E(An),brace:E(An),content:pt,heading:ni,heading1:E(ni),heading2:E(ni),heading3:E(ni),heading4:E(ni),heading5:E(ni),heading6:E(ni),contentSeparator:E(pt),list:E(pt),quote:E(pt),emphasis:E(pt),strong:E(pt),link:E(pt),monospace:E(pt),strikethrough:E(pt),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:Vr,documentMeta:E(Vr),annotation:E(Vr),processingInstruction:E(Vr),definition:Pe.defineModifier(),constant:Pe.defineModifier(),function:Pe.defineModifier(),standard:Pe.defineModifier(),local:Pe.defineModifier(),special:Pe.defineModifier()},bb=hl([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var cl,Oi=new X;function Sm(n){return I.define({combine:n?e=>e.concat(n):void 0})}var Cm=new X,We=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,he.prototype.hasOwnProperty("tree")||Object.defineProperty(he.prototype,"tree",{get(){return Be(this)}}),this.parser=t,this.extension=[Ei.of(this),he.languageData.of((s,o,l)=>{let a=zc(s,o,l),h=a.type.prop(Oi);if(!h)return[];let c=s.facet(h),f=a.type.prop(Cm);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return zc(e,t,i).type.prop(Oi)==this.data}findRegions(e){let t=e.facet(Ei);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Oi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(X.mounted);if(l){if(l.tree.prop(Oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof de&&r(h,s.positions[a]+o)}};return r(Be(e),0),i}get allowsNesting(){return!0}};We.setState=J.define();function zc(n,e,t){let i=n.facet(Ei),r=Be(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ve.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Be(n){let e=n.field(We.state,!1);return e?e.tree:de.empty}var pl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Tn=null,Mn=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],de.empty,0,i,[],null)}startParse(){return this.parser.startParse(new pl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=de.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ii.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ii.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Tn;Tn=this;try{return e()}finally{Tn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=ii.applyChanges(i,a),r=de.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Fc(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Cn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Tn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new de(Ee.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Tn}};function Fc(n,e,t){return ii.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Ln=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Mn.create(e.facet(Ei).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};We.state=pe.define({create:Ln.init,update(n,e){for(let t of e.effects)if(t.is(We.setState))return t.value;return e.startState.facet(Ei)!=e.state.facet(Ei)?Ln.init(e.state):n.apply(e)}});var qc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(qc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var fl=typeof navigator!="undefined"&&(!((cl=navigator.scheduling)===null||cl===void 0)&&cl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Am=ye.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(We.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(We.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(We.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!fl?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>fl&&fl()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:We.setState.of(new Ln(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>He(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ei=I.define({combine(n){return n.length?n[0]:null},enables:n=>[We.state,Am,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Bi=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var $c=I.define(),Ht=I.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ft(n){let e=n.facet(Ht);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ii(n,e){let t="",i=n.tabSize,r=n.facet(Ht)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function $r(n,e){n instanceof he&&(n=new ri(n));for(let i of n.state.facet($c)){let r=i(n,e);if(r!==void 0)return r}let t=Be(n.state);return t.length>=e?Mm(n,t,e):null}var ri=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ft(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Dt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Tm=new X;function Mm(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Kc(i,n,t)}function Kc(n,e,t){for(let i=n;i;i=i.next){let r=Dm(i.node);if(r)return r(ml.create(e,t,i))}return 0}function Lm(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Dm(n){let e=n.type.prop(Tm);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(X.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Pm(o,!0,1,void 0,s&&!Lm(o)?r.from:void 0)}return n.parent==null?Om:null}function Om(){return 0}var ml=class n extends ri{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Em(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Kc(this.context.next,this.base,this.pos)}};function Em(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Bm(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function Pm(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Bm(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var Rm=200;function _c(){return he.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+Rm)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=$r(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Ii(o,f);u!=p&&a.push({from:c.from,to:c.from+u.length,insert:p})}return a.length?[n,{changes:a,sequential:!0}]:n})}var Pi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ke.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof We?l=>l.prop(Oi)==o.data:o?l=>l==o:void 0,this.style=hl(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},gl=I.define(),Gc=I.define({combine(n){return n.length?[n[0]]:null}});function ul(n){let e=n.facet(gl);return e.length?e:n.facet(Gc)}function Kr(n,e){let t=[Im],i;return n instanceof Pi&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Gc.of(n)):i?t.push(gl.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(gl.of(n)),t}var bl=class{constructor(e){this.markCache=Object.create(null),this.tree=Be(e.state),this.decorations=this.buildDeco(e,ul(e.state))}update(e){let t=Be(e.state),i=ul(e.state),r=i!=ul(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let i=new ot;for(let{from:r,to:s}of e.visibleRanges)Nc(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Y.mark({class:a})))},r,s);return i.finish()}},Im=Lt.high(ye.fromClass(bl,{decorations:n=>n.decorations})),Uc=Pi.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Nm=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Yc=1e4,Jc="()[]{}",Xc=I.define({combine(n){return ze(n,{afterCursor:!0,brackets:Jc,maxScanDistance:Yc,renderMatch:Hm})}}),zm=Y.mark({class:"cm-matchingBracket"}),Fm=Y.mark({class:"cm-nonmatchingBracket"});function Hm(n){let e=[],t=n.matched?zm:Fm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}var Vm=pe.define({create(){return Y.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Xc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=nt(e.state,r.head,-1,i)||r.head>0&&nt(e.state,r.head-1,1,i)||i.afterCursor&&(nt(e.state,r.head,1,i)||r.head<e.state.doc.length&&nt(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return Y.set(t,!0)},provide:n=>z.decorations.from(n)}),Wm=[Vm,Nm];function Zc(n={}){return[Xc.of(n),Wm]}var jm=new X;function kl(n,e,t){let i=n.prop(e<0?X.openedBy:X.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function yl(n){let e=n.type.prop(jm);return e?e(n.node):n}function nt(n,e,t,i={}){let r=i.maxScanDistance||Yc,s=i.brackets||Jc,o=Be(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=kl(a.type,t,s);if(h&&a.from<a.to){let c=yl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return qm(n,e,t,a,c,h,s)}}return $m(n,e,t,o,l.type,r,s)}function qm(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=yl(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(kl(c.type,t,o))h++;else if(kl(c.type,-t,o)){if(h==0){let f=yl(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function $m(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let p=c.value;t<0&&(u+=p.length);let g=e+u*t;for(let x=t>0?0:p.length-1,y=t>0?p.length:-1;x!=y;x+=t){let v=o.indexOf(p[x]);if(!(v<0||i.resolveInner(g+x,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:g+x,to:g+x+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function Hc(n,e,t,i=0,r=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let s=r;for(let o=i;o<e;o++)n.charCodeAt(o)==9?s+=t-s%t:s++;return s}var jr=class{constructor(e,t,i,r){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Hc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Hc(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let r=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function Km(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||_m,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||vl}}function _m(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var Vc=new WeakMap,Ri=class n extends We{constructor(e){let t=Sm(e.languageData),i=Km(e),r,s=new class extends Cn{createParse(o,l,a){return new wl(r,o,l,a)}};super(t,s,[$c.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=Jm(t),r=this,this.streamParser=i,this.stateAfter=new X({perNode:!0}),this.tokenTable=e.tokenTable?new qr(i.tokenTable):Ym}static define(e){return new n(e)}getIndent(e,t){let i=Be(e.state),r=i.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=Vc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=xl(this,i,0,r.from,s!=null?s:t),a,h;if(l?(h=l.state,a=l.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let f=e.state.doc.lineAt(a),u=Math.min(t,f.to);if(f.length){let p=o?o(f.from):-1,g=new jr(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;g.pos<u-f.from;)ef(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,e.unit);if(u==t)break;a=f.to+1}let c=e.lineAt(t);return o&&s==null&&Vc.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function xl(n,e,t,i,r){let s=t>=i&&t+e.length<=r&&e.prop(n.stateAfter);if(s)return{state:n.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof de&&a<r&&xl(n,l,a,i,r);if(h)return h}return null}function Qc(n,e,t,i,r){if(r&&t<=0&&i>=e.length)return e;!r&&e.type==n.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<i&&l instanceof de){if(!(a=Qc(n,l,t-o,i-o,r)))break;return r?new de(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Gm(n,e,t,i){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),l=s<=t&&o>t&&xl(n,r.tree,0-r.offset,t,o),a;if(l&&(a=Qc(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Ft(i):4),tree:de.empty}}var wl=class{constructor(e,t,i,r){this.lang=e,this.input=t,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=Mn.get(),o=r[0].from,{state:l,tree:a}=Gm(e,i,o,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Ft(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=Mn.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
7
|
+
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var vt={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:"'"},xi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},vd=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Sd=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ke=0;ke<10;ke++)vt[48+ke]=vt[96+ke]=String(ke);var ke;for(ke=1;ke<=24;ke++)vt[ke+111]="F"+ke;var ke;for(ke=65;ke<=90;ke++)vt[ke]=String.fromCharCode(ke+32),xi[ke]=String.fromCharCode(ke);var ke;for(tr in vt)xi.hasOwnProperty(tr)||(xi[tr]=vt[tr]);var tr;function Fa(n){var e=vd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Sd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?xi:vt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function mr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function co(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Cd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fr(n,e){if(!e.anchorNode)return!1;try{return co(n,e.anchorNode)}catch(t){return!1}}function cn(n){return n.nodeType==3?Qt(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gr(n,e,t,i){return t?Ha(n,e,t,i,-1)||Ha(n,e,t,i,1):!1}function fn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ha(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:St(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=fn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?St(n):0}else return!1}}function St(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Go(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Ad(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ch(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Td(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,p=c==a.body,g=1,x=1;if(p)u=Ad(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let M=c.getBoundingClientRect();({scaleX:g,scaleY:x}=Ch(c,M)),u={left:M.left,right:M.left+c.clientWidth*g,top:M.top,bottom:M.top+c.clientHeight*x}}let y=0,v=0;if(r=="nearest")e.top<u.top?(v=-(u.top-e.top+o),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+o)));else{let M=e.bottom-e.top,O=u.bottom-u.top;v=(r=="center"&&M<=O?e.top+M/2-O/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-O+o)-u.top}if(i=="nearest"?e.left<u.left?(y=-(u.left-e.left+s),t>0&&e.right>u.right+y&&(y=e.right-u.right+y+s)):e.right>u.right&&(y=e.right-u.right+s,t<0&&e.left<u.left+y&&(y=-(u.left+y-e.left+s))):y=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,y||v)if(p)h.scrollBy(y,v);else{let M=0,O=0;if(v){let R=c.scrollTop;c.scrollTop+=v/x,O=(c.scrollTop-R)*x}if(y){let R=c.scrollLeft;c.scrollLeft+=y/g,M=(c.scrollLeft-R)*g}e={left:e.left-M,top:e.top-O,right:e.right-M,bottom:e.bottom-O},M&&Math.abs(M-y)<1&&(i="nearest"),O&&Math.abs(O-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Md(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var fo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?St(t):0),i,Math.min(e.focusOffset,i?St(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},vi=null;function Ah(n){if(n.setActive)return n.setActive();if(vi)return n.focus(vi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(vi==null?{get preventScroll(){return vi={preventScroll:!0},!0}}:void 0),!vi){vi=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var Va;function Qt(n,e,t=e){let i=Va||(Va=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ti(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Ld(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Th(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Dd(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,St(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=St(t))}else{if(t==n)return!0;i=fn(t),t=t.parentNode}}function Mh(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var Oe=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,fn(e),t)}static after(e,t){return new n(e.parentNode,fn(e)+1,t)}},Uo=[],ue=class n{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=n.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=Wa(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=Wa(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=St(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!n.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Uo){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new br(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};ue.prototype.breakAfter=0;function Wa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var br=class{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function Lh(n,e,t,i,r,s,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&s.length<2&&c.merge(t,r,s.length?f:null,t==0,l,a))){if(i<h.length){let p=h[i];p&&(r<p.length||p.breakAfter&&(f!=null&&f.breakAfter))?(e==i&&(p=p.split(r),r=0),!u&&f&&p.merge(0,r,f,!0,0,a)?s[s.length-1]=p:((r||p.children.length&&!p.children[0].length)&&p.merge(0,r,null,!1,0,a),s.push(p))):p!=null&&p.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function Dh(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,Lh(n,h,c,l,a,i,0,r,s)}var Fe=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},uo=typeof document!="undefined"?document:{documentElement:{style:{}}},po=/Edge\/(\d+)/.exec(Fe.userAgent),Oh=/MSIE \d/.test(Fe.userAgent),mo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe.userAgent),Er=!!(Oh||mo||po),ja=!Er&&/gecko\/(\d+)/i.test(Fe.userAgent),io=!Er&&/Chrome\/(\d+)/.exec(Fe.userAgent),qa="webkitFontSmoothing"in uo.documentElement.style,Eh=!Er&&/Apple Computer/.test(Fe.vendor),$a=Eh&&(/Mobile\/\w+/.test(Fe.userAgent)||Fe.maxTouchPoints>2),H={mac:$a||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:Er,ie_version:Oh?uo.documentMode||6:mo?+mo[1]:po?+po[1]:0,gecko:ja,gecko_version:ja?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!io,chrome_version:io?+io[1]:0,ios:$a,android:/Android\b/.test(Fe.userAgent),webkit:qa,safari:Eh,webkit_version:qa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:uo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Od=256,Bt=class n extends ue{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof n)||this.length-(t-e)+i.length>Od||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new n(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Oe(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Ed(this.dom,e,t)}},Pt=class n extends ue{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Th(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,r,s,o){return i&&(!(i instanceof n&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(Dh(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new n(this.mark,t,o)}domAtPos(e){return Bh(this,e)}coordsAt(e,t){return Rh(this,e,t)}};function Ed(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?H.chrome||H.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Qt(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Go(a,o<0):a||null}var un=class n extends ue{static create(e,t,i){return new n(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=n.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof n&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Z.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Z.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return Go(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},dn=class n extends ue{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof n&&e.side==this.side}split(){return new n(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Oe.before(this.dom):Oe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Z.empty}get isHidden(){return!0}};Bt.prototype.children=un.prototype.children=dn.prototype.children=Uo;function Bh(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Oe(t,0)}function Ph(n,e,t){let i,{children:r}=n;t>0&&e instanceof Pt&&r.length&&(i=r[r.length-1])instanceof Pt&&i.mark.eq(e.mark)?Ph(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function Rh(n,e,t){let i=null,r=-1,s=null,o=-1;function l(h,c){for(let f=0,u=0;f<h.children.length&&u<=c;f++){let p=h.children[f],g=u+p.length;g>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(g>c||u==g&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==g&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=g}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Bd(n)}function Bd(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=cn(e);return t[t.length-1]||null}function go(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Ka=Object.create(null);function Yo(n,e,t){if(n==e)return!0;n||(n=Ka),e||(e=Ka);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function bo(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Pd(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ae=class n extends ue{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),Dh(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new n;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Yo(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ph(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=go(t,this.attrs||{})),i&&(this.attrs=go({class:i},this.attrs||{}))}domAtPos(e){return Bh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Th(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(bo(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&ue.get(r)instanceof Pt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=ue.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!H.ios||!this.children.some(s=>s instanceof Bt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Bt)||/[^ -~]/.test(i.text))return null;let r=cn(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Rh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof n)return s;if(o>t)break}r=o+s.breakAfter}return null}},Mi=class n extends ue{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new n(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Uo}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Z.empty}domBoundsAround(){return null}become(e){return e instanceof n&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}},et=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}destroy(e){}},Qe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Qe||(Qe={})),Y=class extends Ze{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new pn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Rt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Ih(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Rt(e,i,r,t,e.widget||null,!0)}static line(e){return new mn(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Y.none=ie.empty;var pn=class n extends Y{constructor(e){let{start:t,end:i}=Ih(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof n&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&Yo(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};pn.prototype.point=!1;var mn=class n extends Y{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Yo(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};mn.prototype.mapMode=Ce.TrackBefore;mn.prototype.point=!0;var Rt=class n extends Y{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ce.TrackBefore:Ce.TrackAfter:Ce.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Rd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Rt.prototype.point=!0;function Ih(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function Rd(n,e){return n==e||!!(n&&e&&n.compare(e))}function ko(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var rn=class n{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Mi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ir(new dn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Mi)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ir(new Bt(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Rt){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Rt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Mi(i.widget||new kr("div"),l,i));else{let a=un.create(i.widget||new kr("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||s>r.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(f.append(ir(new dn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(ir(a,r),s),this.atCursorPos=c,this.pendingBuffer=c?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,i,r,s){let o=new n(e,t,i,s);return o.openEnd=ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function ir(n,e){for(let t of e)n=new Pt(t,[n],n.length);return n}var kr=class extends et{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},Nh=I.define(),zh=I.define(),Fh=I.define(),Hh=I.define(),yo=I.define(),Vh=I.define(),Wh=I.define(),jh=I.define({combine:n=>n.some(e=>e)}),Id=I.define({combine:n=>n.some(e=>e)}),sn=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},nr=J.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Hh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Br=I.define({combine:n=>n.length?n[0]:!0}),Nd=0,Qi=I.define(),ye=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(Nd++,e,i,r,l=>{let a=[Qi.of(l)];return o&&a.push(gn.of(h=>{let c=h.plugin(l);return c?o(c):Y.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},on=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(He(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){He(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},qh=I.define(),Jo=I.define(),gn=I.define(),Xo=I.define(),$h=I.define();function _a(n,e,t){let i=n.state.facet($h);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return ie.spans(r,e,t,{point(){},span(o,l,a,h){let c=s;for(let f=a.length-1;f>=0;f--,h--){let u=a[f].spec.bidiIsolate,p;if(u!=null)if(h>0&&c.length&&(p=c[c.length-1]).to==o&&p.direction==u)p.to=l,c=p.inner;else{let g={from:o,to:l,direction:u,inner:[]};c.push(g),c=g.inner}}}}),s}var Kh=I.define();function _h(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Kh)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var en=I.define(),ct=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],h=o-l,c=a?a.fromB:1e9;for(;s<t.length&&t[s]<c;){let f=t[s],u=t[s+1],p=Math.max(l,f),g=Math.min(c,u);if(p<=g&&new n(p+h,g+h,p,g).addToSet(i),u>c)break;s+=2}if(!a)return i;new n(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},yr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ct(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ge=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ge||(ge={})),bn=ge.LTR,Gh=ge.RTL;function Uh(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var zd=Uh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Fd=Uh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),wo=Object.create(null),lt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);wo[e]=t,wo[t]=-e}function Hd(n){return n<=247?zd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Fd[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Vd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ht=class{get dir(){return this.level%2?Gh:bn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Yh(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Yh(i.inner,r.inner))return!1}return!0}var le=[];function Wd(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=Hd(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),le[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=le[h];if(u==128)h<l-1&&c==le[h+1]&&c&24?u=le[h]=c:le[h]=256;else if(u==64){let p=h+1;for(;p<l&&le[p]==64;)p++;let g=h&&c==8||p<t&&le[p]==8?f==1?1:8:256;for(let x=h;x<p;x++)le[x]=g;h=p-1}else u==8&&f==1&&(le[h]=1);c=u,u&7&&(f=u)}}}function jd(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,p,g;f<c;f++)if(p=wo[u=n.charCodeAt(f)])if(p<0){for(let x=l-3;x>=0;x-=3)if(lt[x+1]==-p){let y=lt[x+2],v=y&2?r:y&4?y&1?s:r:0;v&&(le[f]=le[lt[x]]=v),l=x;break}}else{if(lt.length==189)break;lt[l++]=f,lt[l++]=u,lt[l++]=a}else if((g=le[f])==2||g==1){let x=g==r;a=x?0:1;for(let y=l-3;y>=0;y-=3){let v=lt[y+2];if(v&2)break;if(x)lt[y+2]|=2;else{if(v&4)break;lt[y+2]|=4}}}}}function qd(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=le[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(le[c]==256)c++;else break;let f=s==1,u=(c<e?le[c]:i)==1,p=f==u?f?1:2:i;for(let g=c,x=r,y=x?t[x-1].to:n;g>a;)g==y&&(g=t[--x].from,y=x?t[x-1].to:n),le[--g]=p;a=c}else s=h,a++}}}function xo(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let x=le[a];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h<s.length&&g==s[h].from){if(f)break e;let x=s[h];if(!c)for(let y=x.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(le[y]==l)break e;break}}if(h++,u)u.push(x);else{x.from>a&&o.push(new ht(a,x.from,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.to}g=x.to}else{if(g==t||(c?le[g]!=l:le[g]==l))break;g++}u?xo(n,a,g,i+1,r,u,o):a<g&&o.push(new ht(a,g,p)),a=g}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let x=le[a-1];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h&&g==s[h-1].to){if(f)break e;let x=s[--h];if(!c)for(let y=x.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(le[y-1]==l)break e;break}}if(u)u.push(x);else{x.to<a&&o.push(new ht(x.to,a,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.from}g=x.from}else{if(g==e||(c?le[g-1]!=l:le[g-1]==l))break;g--}u?xo(n,g,a,i+1,r,u,o):g<a&&o.push(new ht(g,a,p)),a=g}}function vo(n,e,t,i,r,s,o){let l=e%2?2:1;Wd(n,r,s,i,l),jd(n,r,s,i,l),qd(r,s,i,l),xo(n,r,s,e,t,i,o)}function $d(n,e,t){if(!n)return[new ht(0,0,e==Gh?1:0)];if(e==bn&&!t.length&&!Vd.test(n))return Jh(n.length);if(t.length)for(;n.length>le.length;)le[le.length]=256;let i=[],r=e==bn?0:1;return vo(n,r,r,t,0,n.length,i),i}function Jh(n){return[new ht(0,n,0)]}var Xh="";function Kd(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=ht.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let a=e[l];o==a.side(r,t)&&(a=e[l+=r?1:-1],o=a.side(!r,t));let h=r==(a.dir==t),c=be(n.text,o,h);if(Xh=n.text.slice(Math.min(o,c),Math.max(o,c)),c>a.from&&c<a.to)return L.cursor(c+n.from,h?-1:1,a.level);let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!f&&a.level!=t?L.cursor(r?n.to:n.from,r?-1:1,t):f&&f.level<a.level?L.cursor(f.side(!r,t)+n.from,r?1:-1,f.level):L.cursor(c+n.from,r?-1:1,a.level)}var wr=class extends ue{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ct(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>c<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Zd(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Gd(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new ct(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(H.ie||H.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Jd(o,l,e.changes);return i=ct.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=H.chrome||H.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Mi&&o.widget instanceof xr&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,p,g,x;if(i&&i.range.fromB<f&&i.range.toB>c){let R=rn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),F=rn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=R.breakAtStart,g=R.openStart,x=F.openEnd;let q=this.compositionView(i);F.breakAtStart?q.breakAfter=1:F.content.length&&q.merge(q.length,q.length,F.content[0],!1,F.openStart,0)&&(q.breakAfter=F.content[0].breakAfter,F.content.shift()),R.content.length&&q.merge(0,0,R.content[R.content.length-1],!0,0,R.openEnd)&&R.content.pop(),u=R.content.concat(q).concat(F.content)}else({content:u,breakAtStart:p,openStart:g,openEnd:x}=rn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:M,off:O}=s.findPos(a,-1);Lh(this,M,O,y,v,u,p,g,x)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Bt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Pt(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=ue.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&fr(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(H.gecko&&l.empty&&!this.hasComposition&&_d(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Oe(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!gr(a.node,a.offset,c.anchorNode,c.anchorOffset)||!gr(h.node,h.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(c.focusNode)&&Xd(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=mr(this.view.root);if(f)if(l.empty){if(H.gecko){let u=Ud(a.node,a.offset);if(u&&u!=3){let p=Qh(a.node,a.offset,u==1?1:-1);p&&(a=new Oe(p.node,p.offset))}}f.collapse(a.node,a.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(a.node,a.offset);try{f.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(u)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Oe(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Oe(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=mr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new Oe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ue.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=s-l.breakAfter,h=a-l.length;if(a<e)break;h<=e&&(h<e||l.covers(-1))&&(a>e||l.covers(1))&&(!i||l instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=l,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=a}if(!(r instanceof Bt))return null;let s=be(r.text,i);if(s==i)return null;let o=Qt(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ge.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>r)break;if(h>=i){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let g=f.dom.lastChild,x=g?cn(g):[];if(x.length){let y=x[x.length-1],v=a?y.right-p.left:p.right-y.left;v>l&&(l=v,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ge.RTL:ge.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;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.dom.appendChild(e);let s=cn(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new br(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Y.replace({widget:new xr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Y.set(e)}updateDeco(){let e=this.view.state.facet(gn).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=_h(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Td(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ge.LTR)}};function _d(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}var xr=class extends et{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function Zh(n,e){let t=n.observer.selectionRange,i=t.focusNode&&Qh(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function Gd(n,e,t){let i=Zh(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new ct(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=ue.get(f);if(u instanceof Pt)c.push({node:f,deco:u.mark});else{if(u instanceof Ae||f.nodeName=="DIV"&&f.parentNode==n.contentDOM)return{range:h,text:r,marks:c,line:f};if(f!=n.contentDOM)c.push({node:f,deco:new pn({inclusive:!0,attributes:Pd(f),tagName:f.tagName.toLowerCase()})});else return null}}}function Qh(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=St(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function Ud(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Yd=class{constructor(){this.changes=[]}compareRange(e,t){ko(e,t,this.changes)}comparePoint(e,t){ko(e,t,this.changes)}};function Jd(n,e,t){let i=new Yd;return ie.compare(n,e,t,i),i.changes}function Xd(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Zd(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function Qd(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=be(r.text,s,!1):l=be(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=be(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=be(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function ep(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function tp(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function no(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function Ga(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function Ua(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function So(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let g=n.firstChild;g;g=g.nextSibling){let x=cn(g);for(let y=0;y<x.length;y++){let v=x[y];r&&no(r,v)&&(v=Ga(Ua(v,r.bottom),r.top));let M=ep(e,v),O=tp(t,v);if(M==0&&O==0)return g.nodeType==3?Ya(g,e,t):So(g,e,t);if(!i||o>O||o==O&&s>M){i=g,r=v,s=M,o=O;let R=O?t<v.top?-1:1:M?e<v.left?-1:1:0;l=!R||(R>0?y<x.length-1:y>0)}M==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=g,c=v):t<v.top&&(!f||f.top>v.top)&&(h=g,f=v):c&&no(c,v)?c=Ua(c,v.bottom):f&&no(f,v)&&(f=Ga(f,v.top))}}if(c&&c.bottom>=t?(i=a,r=c):f&&f.top<=t&&(i=h,r=f),!i)return{node:n,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return Ya(i,u,t);if(l&&i.contentEditable!="false")return So(i,u,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function Ya(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=Qt(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<s){let u=e>=(c.left+c.right)/2,p=u;if((H.chrome||H.gecko)&&Qt(n,l).getBoundingClientRect().left==c.right&&(p=!u),f<=0)return{node:n,offset:l+(p?1:0)};r=l+(p?1:0),s=f}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function ec(n,e,t,i=-1){var r,s;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,{x:c,y:f}=e,u=f-l;if(u<0)return 0;if(u>h)return n.state.doc.length;for(let R=n.viewState.heightOracle.textHeight/2,F=!1;a=n.elementAtHeight(u),a.type!=Qe.Text;)for(;u=i>0?a.bottom+R:a.top-R,!(u>=0&&u<=h);){if(F)return t?null:0;F=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:Ja(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:Ja(n,o,a,c,f);let g=n.dom.ownerDocument,x=n.root.elementFromPoint?n.root:g,y=x.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=x.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,M=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let R=g.caretPositionFromPoint(c,f);R&&({offsetNode:v,offset:M}=R)}else if(g.caretRangeFromPoint){let R=g.caretRangeFromPoint(c,f);R&&({startContainer:v,startOffset:M}=R,(!n.contentDOM.contains(v)||H.safari&&ip(v,M,c)||H.chrome&&np(v,M,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let R=Ae.find(n.docView,p);if(!R)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:M}=So(R.dom,c,f))}let O=n.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let R=O.dom.getBoundingClientRect();return e.y<R.top||e.y<=R.bottom&&e.x<=(R.left+R.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,M)+O.posAtStart}function Ja(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Ra(o,s,n.state.tabSize)}function ip(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Qt(n,i-1,i).getBoundingClientRect().left>t}function np(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():Qt(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function rp(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Qe.Text))return i}return t}function sp(n,e,t,i){let r=rp(n,e.head),s=!i||r.type!=Qe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ge.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return L.cursor(a,t?-1:1)}return L.cursor(t?r.to:r.from,t?-1:1)}function Xa(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=Kd(r,s,o,l,t),c=Xh;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
|
|
8
|
+
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=L.cursor(t?r.from:r.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function op(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==fe.Space&&(r=o),r==o}}function lp(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(u+p)*s,x=ec(n,{x:f,y:g},!1,s);if(g<a.top||g>a.bottom||(s<0?x<r:x>r)){let y=n.docView.coordsForChar(x),v=!y||g<y.top?-1:1;return L.cursor(x,v,void 0,o)}}}function ur(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function ro(n,e,t){let i=ur(n.state.facet(Xo).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var Co=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&vp(e.contentDOM.ownerDocument)}handleEvent(e){!pp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=ap(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&ic.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=tc.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||hp.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Ti(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Za(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){He(t.state,r)}}}function ap(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(Za(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(Za(i.value,o))}}for(let i in tt)t(i).handlers.push(tt[i]);for(let i in it)t(i).observers.push(it[i]);return e}var tc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],hp="dthko",ic=[16,17,18,20,91,92,224,225],rr=6;function sr(n){return Math.max(0,n)*.7+8}function cp(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var Ao=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Md(e.contentDOM),this.atoms=e.state.facet(Xo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(oe.allowMultipleSelections)&&fp(e,t),this.dragging=dp(e,t)&&oc(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&cp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=_h(this.view);e.clientX-o.left<=s.left+rr?i=-sr(s.left-e.clientX):e.clientX+o.right>=s.right-rr&&(i=sr(e.clientX-s.right)),e.clientY-o.top<=s.top+rr?r=-sr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-rr&&(r=sr(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=ur(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=ur(this.atoms,r.from,-1),l=ur(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function fp(n,e){let t=n.state.facet(Nh);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function up(n,e){let t=n.state.facet(zh);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function dp(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=mr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function pp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=ue.get(t))&&i.ignoreEvent(e))return!1;return!0}var tt=Object.create(null),it=Object.create(null),nc=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function mp(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),rc(n,t.value)},50)}function rc(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(To!=null&&t.selection.ranges.every(a=>a.empty)&&To==s.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:L.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:L.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}it.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};tt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);it.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};it.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};tt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Fh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=kp(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Ao(n,e,t,i)),i&&n.observer.ignore(()=>Ah(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function Qa(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return Qd(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.range(o,l)}}var sc=(n,e)=>n>=e.top&&n<=e.bottom,eh=(n,e,t)=>sc(e,t)&&n>=t.left&&n<=t.right;function gp(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&eh(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&eh(t,i,l)?1:o&&sc(i,o)?-1:1}function th(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:gp(n,t,e.clientX,e.clientY)}}var bp=H.ie&&H.ie_version<=11,ih=null,nh=0,rh=0;function oc(n){if(!bp)return n.detail;let e=ih,t=rh;return ih=n,rh=Date.now(),nh=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(nh+1)%3:1}function kp(n,e){let t=th(n,e),i=oc(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=th(n,s),h,c=Qa(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=Qa(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?L.range(u,p):L.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=yp(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function yp(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}tt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};tt.dragend=n=>(n.inputState.draggedContent=null,!1);function sh(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&up(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}tt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&sh(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return sh(n,e,i,!0),!0}return!1};tt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=nc?null:e.clipboardData;return t?(rc(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(mp(n),!1)};function wp(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function xp(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}var To=null;tt.copy=tt.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=xp(n.state);if(!t&&!r)return!1;To=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=nc?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(wp(n,t),!1)};var lc=Ne.define();function ac(n,e){let t=[];for(let i of n.facet(Wh)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:lc.of(!0)}):null}function hc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=ac(n.state,e);t?n.dispatch(t):n.update([])}},10)}it.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),hc(n)};it.blur=n=>{n.observer.clearSelectionRange(),hc(n)};it.compositionstart=it.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};it.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,H.chrome&&H.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};it.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};tt.beforeinput=(n,e)=>{var t;let i;if(H.chrome&&H.android&&(i=tc.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};var oh=new Set;function vp(n){oh.has(n)||(oh.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var lh=["pre-wrap","normal","pre-line","break-spaces"],Mo=class{constructor(e){this.lineWrapping=e,this.doc=Z.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=lh.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},Lo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},at=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.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 Rt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(ce||(ce={})),dr=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>dr&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ce.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,ce.ByPosNoHeight,i,0,0);for(f+=p.to-h,h=p.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ce.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let g=Oo.build(i.setDoc(o),e,c,f);s=s.replace(a,h,g)}return s.updateHeight(i,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Do(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ve.prototype.size=1;var vr=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},_e=class n extends vr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Et&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Et?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Et=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new at(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new at(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new at(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new at(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let g=u.number-l;f+=a*g+h*(e-s-g)}let p=a+h*u.length;o(new at(u.from,u.length,f,p,0)),f+=p,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=dr&&(a=-2);let u=new _e(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=dr||Math.abs(a-this.heightMetrics(e,t).perLine)>=dr)&&(e.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Do=class extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ce.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ce.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&ah(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),ah(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function ah(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Et&&(i=n[e+1])instanceof Et&&n.splice(e-1,3,new Et(t.length+1+i.length))}var Sp=5,Oo=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof _e?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _e(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new vr(o,r,i)):(o||s||r>=Sp)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Et(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _e)return e;let t=new _e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _e&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return ie.spans(t,i,r,s,0),s.finish(i)}};function Cp(n,e,t){let i=new Eo;return ie.compare(n,e,t,i,0),i.changes}var Eo=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&ko(e,t,this.changes,5)}};function Ap(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=h==n.parentNode?u.bottom:Math.min(a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Tp(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ln=class{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return Y.replace({widget:new Bo(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Bo=class extends et{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Sr=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=hh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ge.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Jo).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Mo(t),this.stateDeco=e.facet(gn).filter(i=>typeof i!="function"),this.heightMap=Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle.setDoc(e.doc),[new ct(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Si(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?hh:new Po(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:tn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(gn).filter(c=>typeof c!="function");let r=e.changedRanges,s=ct.extendWithRanges(r,Cp(i,this.stateDeco,e?e.changes:De.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Id)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ge.RTL:ge.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:R,scaleY:F}=Ch(t,l);(this.scaleX!=R||this.scaleY!=F)&&(this.scaleX=R,this.scaleY=F,h|=8,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Mh(e.scrollDOM);let g=(this.printing?Tp:Ap)(t,this.paddingTop),x=g.top-this.pixelViewport.top,y=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&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let M=l.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let R=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(R)&&(o=!0),o||r.lineWrapping&&Math.abs(M-this.contentDOMWidth)>r.charWidth){let{lineHeight:F,charWidth:q,textHeight:w}=e.docView.measureTextSize();o=F>0&&r.refresh(s,F,q,w,M/q,R),o&&(e.docView.minWidth=0,h|=8)}x>0&&y>0?c=Math.max(x,y):x<0&&y<0&&(c=Math.min(x,y)),r.heightChanged=!1;for(let F of this.viewports){let q=F.from==this.viewport.from?R:e.docView.measureVisibleLineHeights(F);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Lo(F.from,q))}r.heightChanged&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Si(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ce.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Si(r.lineAt(u-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ce.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Si(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new ln(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ge.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let x=Lp(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!g.some(v=>y.from<v&&y.to>v));if(!x){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(L.cursor(c),!1,!0).head;y>h&&(c=y)}x=new ln(h,c,this.gapSize(f,h,c,u))}l.push(x)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Mp(h.from,h.to,this.stateDeco);if(c.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let v=lr(c,f),M=((this.visibleBottom-this.visibleTop)/2+g)/h.height;x=v-M,y=v+M}else x=(this.visibleTop-h.top-g)/h.height,y=(this.visibleBottom-h.top+g)/h.height;u=or(c,x),p=or(c,y)}else{let g=c.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,y,v;if(f!=null){let M=lr(c,f),O=((this.pixelViewport.right-this.pixelViewport.left)/2+x)/g;y=M-O,v=M+O}else y=(this.pixelViewport.left-x)/g,v=(this.pixelViewport.right+x)/g;u=or(c,y),p=or(c,v)}u>h.from&&a(h.from,u,h,c),p<h.to&&a(p,h.to,h,c)}return l}gapSize(e,t,i,r){let s=lr(r,i)-lr(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){ln.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||tn(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return tn(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return tn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Si=class{constructor(e,t){this.from=e,this.to=t}};function Mp(n,e,t){let i=[],r=n,s=0;return ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function or({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function lr(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Lp(n,e){for(let t of n)if(e(t))return t}var hh={toDOM(n){return n},fromDOM(n){return n},scale:1},Po=class{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ce.ByPos,e,0,0).top,c=t.lineAt(a,ce.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}};function tn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new at(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>tn(r,e)):n._content)}var ar=I.define({combine:n=>n.join(" ")}),Ro=I.define({combine:n=>n.indexOf(!0)>-1}),Io=Ke.newName(),cc=Ke.newName(),fc=Ke.newName(),uc={"&light":"."+cc,"&dark":"."+fc};function No(n,e,t){return new Ke(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var Dp=No("."+Io,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},uc),nn="\uFFFF",zo=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(oe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=nn}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=ue.get(r),a=ue.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:ch(r))||ch(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=ue.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Op(e,i.node,i.offset)?t:0))}};function Op(n,e,t){for(;;){if(!e||t<St(e))return!1;if(e==n)return!0;t=fn(e)+1,e=e.parentNode}}function ch(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Cr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Fo=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:Pp(e),a=new zo(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Rp(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!co(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!co(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=L.single(h,a)}}};function dc(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||H.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Bp(n.state.doc.sliceString(o,l,nn),e.text,a-o,h);c&&(H.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==nn+nn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Z.of(e.text.slice(c.from,c.toB).split(nn))})}else i&&(!n.hasFocus&&n.state.facet(Br)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
+
`&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}),t){if(H.ios&&n.inputState.flushIOSKey()||H.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Ti(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ti(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ti(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Ep(n,t,i));return n.state.facet(Vh).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Ep(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=r.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&Zh(n,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-g}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:l,range:a||g.map(l)};let x=g.to-u,y=x-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,x)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let v=r.changes({from:y,to:x,insert:e.insert}),M=g.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+M),Math.max(0,a.head+M)):g.map(v)}})}else i={changes:l,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function Bp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Pp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Cr(t,i)),(r!=t||s!=i)&&e.push(new Cr(r,s))),e}function Rp(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?L.single(t+e,i+e):null}var Ip={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},so=H.ie&&H.ie_version<=11,Ho=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new fo,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.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),so&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Br)?i.root.activeElement!=this.dom:!fr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!i.state.selection.main.empty&&r.focusNode&&gr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&Cd(this.dom.ownerDocument)==this.dom&&Np(this.view)||mr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=fr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Dd(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ip),so&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),so&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ti(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&fr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Fo(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=dc(this.view,t);return this.view.state==i&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=fh(t,e.previousSibling||e.target.previousSibling,-1),r=fh(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function fh(n,e,t){for(;e;){let i=ue.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Np(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return gr(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var z=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Ld(e.parent)||document,this.viewState=new Sr(e.state||oe.create(e)),e.scrollTo&&e.scrollTo.is(nr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qi).map(i=>new on(i));for(let i of this.plugins)i.update(this);this.observer=new Ho(this),this.inputState=new Co(this),this.inputState.ensureHandlers(this.plugins),this.docView=new wr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(lc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=ac(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(s);r=yr.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:p}=u.state.selection;f=new sn(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(nr)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ar.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(en)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(ar)!=r.state.facet(ar)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(yo))try{u(r)}catch(p){He(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!dc(this,c)&&h.force&&Ti(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Sr(e),this.plugins=e.facet(Qi).map(i=>new on(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new wr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Qi),i=e.state.facet(Qi);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new on(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Mh(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(p=>{try{return p.read(this)}catch(g){return He(this.state,g),uh}}),f=yr.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f));for(let p=0;p<h.length;p++)if(c[p]!=uh)try{let g=h[p];g.write&&g.write(c[p],this)}catch(g){He(this.state,g)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(g>1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(yo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(Ro)?fc:cc)+" "+this.state.facet(ar)}updateAttrs(){let e=dh(this,qh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Br)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),dh(this,Jo,t);let i=this.observer.ignore(()=>{let r=bo(this.contentDOM,this.contentAttrs,t),s=bo(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(en);let e=this.state.facet(n.cspNonce);Ke.mount(this.root,this.styleModules.concat(Dp).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ro(this,e,Xa(this,e,t,i))}moveByGroup(e,t){return ro(this,e,Xa(this,e,t,i=>op(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return sp(this,e,t,i)}moveVertically(e,t,i){return ro(this,e,lp(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),ec(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ht.find(s,e-r.from,-1,t)];return Go(i,o.dir==ge.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(jh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zp)return Jh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Yh(s.isolates,i=_a(this,e.from,e.to))))return s.order;i||(i=_a(this,e.from,e.to));let r=$d(e.text,t,i);return this.bidiCache.push(new Ar(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ah(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return nr.of(new sn(typeof e=="number"?L.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return nr.of(new sn(L.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ye.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ye.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ke.newName(),r=[ar.of(i),en.of(No(`.${i}`,e))];return t&&t.dark&&r.push(Ro.of(!0)),r}static baseTheme(e){return Lt.lowest(en.of(No("."+Io,e,uc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&ue.get(i)||ue.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};z.styleModule=en;z.inputHandler=Vh;z.focusChangeEffect=Wh;z.perLineTextDirection=jh;z.exceptionSink=Hh;z.updateListener=yo;z.editable=Br;z.mouseSelectionStyle=Fh;z.dragMovesSelection=zh;z.clickAddsSelectionRange=Nh;z.decorations=gn;z.atomicRanges=Xo;z.bidiIsolatedRanges=$h;z.scrollMargins=Kh;z.darkTheme=Ro;z.cspNonce=I.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Jo;z.editorAttributes=qh;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=J.define();var zp=4096,uh={},Ar=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ge.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function dh(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&go(o,t)}return t}var Fp=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Hp(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function hr(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var Vp=Lt.default(z.domEventHandlers({keydown(n,e){return gc(pc(e.state),n,e,"editor")}})),Pr=I.define({enables:Vp}),ph=new WeakMap;function pc(n){let e=n.facet(Pr),t=ph.get(e);return t||ph.set(e,t=jp(e.reduce((i,r)=>i.concat(r),[]))),t}function mc(n,e,t){return gc(pc(n.state),e,n,t)}var Ot=null,Wp=4e3;function jp(n,e=Fp){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(v=>Hp(v,e));for(let v=1;v<g.length;v++){let M=g.slice(0,v).join(" ");r(M,!0),p[M]||(p[M]={preventDefault:!0,stopPropagation:!1,run:[O=>{let R=Ot={view:O,prefix:M,scope:o};return setTimeout(()=>{Ot==R&&(Ot=null)},Wp),!0}]})}let x=g.join(" ");r(x,!1);let y=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((u=(f=p._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),h&&(y.preventDefault=!0),c&&(y.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function gc(n,e,t,i){let r=Fa(e),s=$e(r,0),o=wt(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Ot&&Ot.view==t&&Ot.scope==i&&(l=Ot.prefix+" ",ic.indexOf(e.keyCode)<0&&(h=!0,Ot=null));let f=new Set,u=y=>{if(y){for(let v of y.run)if(!f.has(v)&&(f.add(v),v(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,x;return p&&(u(p[l+hr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(g=vt[e.keyCode])&&g!=r?(u(p[l+hr(g,e,!0)])||e.shiftKey&&(x=xi[e.keyCode])!=r&&x!=g&&u(p[l+hr(x,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+hr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var qp=!H.ios;var mh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};qp&&(mh[".cm-line"].caretColor="transparent !important",mh[".cm-content"]={caretColor:"transparent !important"});function gh(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function $p(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}var kn=class{constructor(e){let{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,h,c)=>r(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new ot,i=t.add.bind(t);for(let{from:r,to:s}of $p(e,this.maxLength))gh(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],p,g=(x,y,v)=>u.push(v.range(x,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<f-a.from;)this.addMatch(p,e,p.index+a.from,g);else gh(e.state.doc,this.regexp,c,f,(x,y)=>this.addMatch(y,e,x,g));t=t.update({filterFrom:c,filterTo:f,filter:(x,y)=>x<c||y>f,add:u})}}return t}},Vo=/x/.unicode!=null?"gu":"g",Kp=new RegExp(`[\0-\b
|
|
10
|
+
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Vo),_p={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},oo=null;function Gp(){var n;if(oo==null&&typeof document!="undefined"&&document.body){let e=document.body.style;oo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return oo||!1}var pr=I.define({combine(n){let e=ze(n,{render:null,specialChars:Kp,addSpecialChars:null});return(e.replaceTabs=!Gp())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Vo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Vo)),e}});function bc(n={}){return[pr.of(n),Up()]}var bh=null;function Up(){return bh||(bh=ye.fromClass(class{constructor(n){this.view=n,this.decorations=Y.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(pr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new kn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=$e(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Dt(o.text,l,i-o.from);return Y.replace({widget:new jo((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Y.replace({widget:new Wo(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(pr);n.startState.facet(pr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}var Yp="\u2022";function Jp(n){return n>=32?Yp:n==10?"\u2424":String.fromCharCode(9216+n)}var Wo=class extends et{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Jp(this.code),i=e.state.phrase("Control character")+" "+(_p[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}},jo=class extends et{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function kc(){return Zp}var Xp=Y.line({class:"cm-activeLine"}),Zp=ye.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(Xp.range(r.from)),e=r.from)}return Y.set(t)}},{decorations:n=>n.decorations});var Zi="-10000px",Tr=class{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(a.dom.remove(),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function Qp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var lo=I.define({combine:n=>{var e,t,i;return{position:H.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Qp}}}),kh=new WeakMap,yc=ye.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(lo);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Tr(n,yn,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(lo);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Zi,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(H.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(this.view.scaleX!=1||this.view.scaleY!=1)i=!0;else if(r.style.top==Zi&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(lo).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){c.style.top=Zi;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,x=u.right-u.left,y=(e=kh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||tm,M=this.view.textDirection==ge.LTR,O=u.width>i.right-i.left?M?i.left:i.right-u.width:M?Math.min(f.left-(p?14:0)+v.x,i.right-x):Math.max(i.left,f.left-x+(p?14:0)-v.x),R=this.above[l];!a.strictSide&&(R?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&R==i.bottom-f.bottom>f.top-i.top&&(R=this.above[l]=!R);let F=(R?f.top-i.top:i.bottom-f.bottom)-g;if(F<y&&h.resize!==!1){if(F<this.view.defaultLineHeight){c.style.top=Zi;continue}kh.set(h,y),c.style.height=(y=F)/s+"px"}else c.style.height&&(c.style.height="");let q=R?f.top-y-g-v.y:f.bottom+g+v.y,w=O+x;if(h.overlap!==!0)for(let D of o)D.left<w&&D.right>O&&D.top<q+y&&D.bottom>q&&(q=R?D.top-y-2-g:D.bottom+g+2);if(this.position=="absolute"?(c.style.top=(q-n.parent.top)/s+"px",c.style.left=(O-n.parent.left)/r+"px"):(c.style.top=q/s+"px",c.style.left=O/r+"px"),p){let D=f.left+(M?v.x:-v.x)-(O+14-7);p.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:O,top:q,right:w,bottom:q+y}),c.classList.toggle("cm-tooltip-above",R),c.classList.toggle("cm-tooltip-below",!R),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Zi}},{eventObservers:{scroll(){this.maybeMeasure()}}}),em=z.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),tm={x:0,y:0},yn=I.define({enables:[yc,em]}),Mr=I.define(),Lr=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tr(e,Mr,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},im=yn.compute([Mr],n=>{let e=n.facet(Mr).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Lr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),qo=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof un)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=a&&a.dir==ge.RTL?-1:1;s=t.x<l.left?-h:h}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(a=>{this.pending==l&&(this.pending=null,a&&e.dispatch({effects:this.setHover.of(a)}))},a=>He(e.state,a,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(yc),t=e?e.manager.tooltips.findIndex(i=>i.create==Lr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i&&r&&!nm(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!rm(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},cr=4;function nm(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-cr&&e.clientX<=t.right+cr&&e.clientY>=t.top-cr&&e.clientY<=t.bottom+cr}function rm(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=n.posAtCoords({x:i,y:r},!1);return a>=e&&a<=t}function wc(n,e={}){let t=J.define(),i=pe.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Ce.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(sm)&&(r=null);return r},provide:r=>Mr.from(r)});return[i,ye.define(r=>new qo(r,n,i,t,e.hoverTime||300)),im]}var sm=J.define();var yh=I.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ti(n,e){let t=n.plugin(xc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var xc=ye.fromClass(class{constructor(n){this.input=n.state.facet(ei),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(yh);this.top=new Ci(n,!0,e.topContainer),this.bottom=new Ci(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(yh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ci(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ci(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ei);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Ci=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=wh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=wh(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function wh(n){let e=n.nextSibling;return n.remove(),e}var ei=I.define({enables:xc}),Ge=class extends Ze{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ge.prototype.elementClass="";Ge.prototype.toDOM=void 0;Ge.prototype.mapMode=Ce.TrackBefore;Ge.prototype.startSide=Ge.prototype.endSide=-1;Ge.prototype.point=!0;var ao=I.define(),om={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},an=I.define();function Zo(n){return[vc(),an.of(Object.assign(Object.assign({},om),n))]}var $o=I.define({combine:n=>n.some(e=>e)});function vc(n){let e=[lm];return n&&n.fixed===!1&&e.push($o.of(!0)),e}var lm=ye.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(an).map(e=>new Dr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet($o),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet($o)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=ie.iter(this.view.state.facet(ao),this.view.viewport.from),i=[],r=this.gutters.map(s=>new _o(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Qe.Text&&o){Ko(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Qe.Text){Ko(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(an),t=n.state.facet(an),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(ao),n.state.facet(ao),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Dr(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ge.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function xh(n){return Array.isArray(n)?n:[n]}function Ko(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var _o=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Or(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Ko(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Dr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=xh(t.markers(e)),t.initialSpacer&&(this.spacer=new Or(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=xh(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ie.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Or=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),am(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function am(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var hm=I.define(),Ai=I.define({combine(n){return ze(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),hn=class extends Ge{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function ho(n,e){return n.state.facet(Ai).formatNumber(e,n.state)}var cm=an.compute([Ai],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(hm)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new hn(ho(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Ai)!=e.state.facet(Ai),initialSpacer(e){return new hn(ho(e,vh(e.state.doc.lines)))},updateSpacer(e,t){let i=ho(t.view,vh(t.view.state.doc.lines));return i==e.number?e:new hn(i)},domEventHandlers:n.facet(Ai).domEventHandlers}));function Sc(n={}){return[Ai.of(n),vc(),cm]}function vh(n){let e=9;for(;e<n;)e=e*10+9;return e}var Sh=new Map;function fm(n){let e=Sh.get(n);return e||Sh.set(n,e=Y.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function Cc(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var um=Cc(new kn({regexp:/\t| +/g,decoration:n=>fm(n[0]),boundary:/\S/}));function Ac(){return um}var dm=Cc(new kn({regexp:/\s+$/g,decoration:Y.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Tc(){return dm}var pm=0,wn=class{constructor(e,t){this.from=e,this.to=t}},X=class{constructor(e={}){this.id=pm++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ee.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};X.closedBy=new X({deserialize:n=>n.split(" ")});X.openedBy=new X({deserialize:n=>n.split(" ")});X.group=new X({deserialize:n=>n.split(" ")});X.contextHash=new X({perNode:!0});X.lookAhead=new X({perNode:!0});X.mounted=new X({perNode:!0});var Li=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[X.mounted.id]}},mm=Object.create(null),Ee=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):mm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.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(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(X.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(X.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Nr=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new Ee(i.name,r,i.id,i.flags):i)}return new n(t)}},Rr=new WeakMap,Mc=new WeakMap,ve;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ve||(ve={}));var de=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Li.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Rr.get(this)||this.topNode,s=new Sn(r);return s.moveTo(e,t),Rr.set(this,s._tree),s}get topNode(){return new ft(this,0,0,null)}resolve(e,t=0){let i=xn(Rr.get(this)||this.topNode,e,t,!1);return Rr.set(this,i),i}resolveInner(e,t=0){let i=xn(Mc.get(this)||this.topNode,e,t,!0);return Mc.set(this,i),i}resolveStack(e,t=0){return gm(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ve.IncludeAnonymous)>0;for(let a=this.cursor(o|ve.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:sl(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Ee.none,t,i,r)))}static build(e){return bm(e)}};de.empty=new de(Ee.none,[],[],0);var Qo=class n{constructor(e,t){this.buffer=e,this.index=t}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 n(this.buffer,this.index)}},It=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ee.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Oc(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function Oc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function xn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof ft&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ve.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof ft&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var zr=class{cursor(e=0){return new Sn(this,e)}getChild(e,t=null,i=null){let r=Lc(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Lc(this,e,t,i)}resolve(e,t=0){return xn(this,e,t,!1)}resolveInner(e,t=0){return xn(this,e,t,!0)}matchContext(e){return el(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},ft=class n extends zr{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Oc(r,i,f,f+c.length)){if(c instanceof It){if(s&ve.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new vn(new tl(o,c,e,f),null,u)}else if(s&ve.IncludeAnonymous||!c.type.isAnonymous||rl(c)){let u;if(!(s&ve.IgnoreMounts)&&(u=Li.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&ve.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ve.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let r;if(!(i&ve.IgnoreOverlays)&&(r=Li.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}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 Lc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function el(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var tl=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},vn=class n extends zr{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(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ve.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new de(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ec(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof ft&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new il(r,t)}var il=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ec(this.heads)}};function gm(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof ft?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Li.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ft(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(xn(l,e,t,!1))}}return r?Ec(r):i}var Sn=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ft)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof ft?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ve.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ve.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ve.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ve.IncludeAnonymous||l instanceof It||!l.type.isAnonymous||rl(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new vn(this.buffer,t,this.stack[r]);return this.bufferNode=new vn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return el(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return el(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function rl(n){return n.children.some(e=>e instanceof It||!e.type.isAnonymous||rl(e))}function bm(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Qo(t,t.length):t,a=i.types,h=0,c=0;function f(F,q,w,D,b,U){let{id:$,start:G,end:K,size:k}=l,T=c;for(;k<0;)if(l.next(),k==-1){let j=s[$];w.push(j),D.push(G-F);return}else if(k==-3){h=$;return}else if(k==-4){c=$;return}else throw new RangeError(`Unrecognized record size: ${k}`);let A=a[$],V,ae,we=G-F;if(K-G<=r&&(ae=y(l.pos-q,b))){let j=new Uint16Array(ae.size-ae.skip),W=l.pos-ae.size,_=j.length;for(;l.pos>W;)_=v(ae.start,j,_);V=new It(j,K-ae.start,i),we=ae.start-F}else{let j=l.pos-k;l.next();let W=[],_=[],he=$>=o?$:-1,Ct=0,te=K;for(;l.pos>j;)he>=0&&l.id==he&&l.size>=0?(l.end<=te-r&&(g(W,_,G,Ct,l.end,te,he,T),Ct=W.length,te=l.end),l.next()):U>2500?u(G,j,W,_):f(G,j,W,_,he,U+1);if(he>=0&&Ct>0&&Ct<W.length&&g(W,_,G,Ct,G,te,he,T),W.reverse(),_.reverse(),he>-1&&Ct>0){let Te=p(A);V=sl(A,W,_,0,W.length,0,K-G,Te,Te)}else V=x(A,W,_,K-G,T-K)}w.push(V),D.push(we)}function u(F,q,w,D){let b=[],U=0,$=-1;for(;l.pos>q;){let{id:G,start:K,end:k,size:T}=l;if(T>4)l.next();else{if($>-1&&K<$)break;$<0&&($=k-r),b.push(G,K,k),U++,l.next()}}if(U){let G=new Uint16Array(U*4),K=b[b.length-2];for(let k=b.length-3,T=0;k>=0;k-=3)G[T++]=b[k],G[T++]=b[k+1]-K,G[T++]=b[k+2]-K,G[T++]=T;w.push(new It(G,b[2]-K,i)),D.push(K-F)}}function p(F){return(q,w,D)=>{let b=0,U=q.length-1,$,G;if(U>=0&&($=q[U])instanceof de){if(!U&&$.type==F&&$.length==D)return $;(G=$.prop(X.lookAhead))&&(b=w[U]+$.length+G)}return x(F,q,w,D,b)}}function g(F,q,w,D,b,U,$,G){let K=[],k=[];for(;F.length>D;)K.push(F.pop()),k.push(q.pop()+w-b);F.push(x(i.types[$],K,k,U-b,G-U)),q.push(b-w)}function x(F,q,w,D,b=0,U){if(h){let $=[X.contextHash,h];U=U?[$].concat(U):[$]}if(b>25){let $=[X.lookAhead,b];U=U?[$].concat(U):[$]}return new de(F,q,w,D,U)}function y(F,q){let w=l.fork(),D=0,b=0,U=0,$=w.end-r,G={size:0,start:0,skip:0};e:for(let K=w.pos-F;w.pos>K;){let k=w.size;if(w.id==q&&k>=0){G.size=D,G.start=b,G.skip=U,U+=4,D+=4,w.next();continue}let T=w.pos-k;if(k<0||T<K||w.start<$)break;let A=w.id>=o?4:0,V=w.start;for(w.next();w.pos>T;){if(w.size<0)if(w.size==-3)A+=4;else break e;else w.id>=o&&(A+=4);w.next()}b=V,D+=k,U+=A}return(q<0||D==F)&&(G.size=D,G.start=b,G.skip=U),G.size>4?G:void 0}function v(F,q,w){let{id:D,start:b,end:U,size:$}=l;if(l.next(),$>=0&&D<o){let G=w;if($>4){let K=l.pos-($-4);for(;l.pos>K;)w=v(F,q,w)}q[--w]=G,q[--w]=U-F,q[--w]=b-F,q[--w]=D}else $==-3?h=D:$==-4&&(c=D);return w}let M=[],O=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,M,O,-1,0);let R=(e=n.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new de(a[n.topID],M.reverse(),O.reverse(),R)}var Dc=new WeakMap;function Ir(n,e){if(!n.isAnonymous||e instanceof It||e.type!=n)return 1;let t=Dc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof de)){t=1;break}t+=Ir(n,i)}Dc.set(e,t)}return t}function sl(n,e,t,i,r,s,o,l,a){let h=0;for(let g=i;g<r;g++)h+=Ir(n,e[g]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(g,x,y,v,M){for(let O=y;O<v;){let R=O,F=x[O],q=Ir(n,g[O]);for(O++;O<v;O++){let w=Ir(n,g[O]);if(q+w>=c)break;q+=w}if(O==R+1){if(q>c){let w=g[R];p(w.children,w.positions,0,w.children.length,x[R]+M);continue}f.push(g[R])}else{let w=x[O-1]+g[O-1].length-F;f.push(sl(n,g,x,R,O,F,w,null,a))}u.push(F+M-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var ii=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let p=Math.max(u.from,a)-h,g=Math.min(u.to,f)-h;u=p>=g?null:new n(p,g,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},Cn=class{startParse(e,t,i){return typeof e=="string"&&(e=new nl(e)),i=i?i.length?i.map(r=>new wn(r.from,r.to)):[new wn(0,0)]:[new wn(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},nl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var mb=new X({perNode:!0});var km=0,Pe=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=km++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new n([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Wr;return t=>t.modified.indexOf(e)>-1?t:Wr.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},ym=0,Wr=class n{constructor(){this.instances=[],this.id=ym++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&wm(t,l.modified));if(i)return i;let r=[],s=new Pe(r,e,t);for(let l of t)l.instances.push(s);let o=xm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function wm(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function xm(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Rc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Di(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Ic.add(e)}var Ic=new X,Di=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Di.empty=new Di([],2,null);function hl(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function vm(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Nc(n,e,t,i=0,r=n.length){let s=new ll(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var ll=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=Sm(e)||Di.empty,f=vm(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(X.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),x=e.firstChild();for(let y=0,v=l;;y++){let M=y<u.overlay.length?u.overlay[y]:null,O=M?M.from+l:a,R=Math.max(t,v),F=Math.min(i,O);if(R<F&&x)for(;e.from<F&&(this.highlightRange(e,R,F,r,s),this.startSpan(Math.min(F,e.to),h),!(e.to>=O||!e.nextSibling())););if(!M||O>i)break;v=M.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,M.from+l),Math.min(i,v),"",g),this.startSpan(Math.min(i,v),h))}x&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function Sm(n){let e=n.type.prop(Ic);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var E=Pe.define,Fr=E(),Nt=E(),Bc=E(Nt),Pc=E(Nt),zt=E(),Hr=E(zt),ol=E(zt),pt=E(),ni=E(pt),ut=E(),dt=E(),al=E(),An=E(al),Vr=E(),P={comment:Fr,lineComment:E(Fr),blockComment:E(Fr),docComment:E(Fr),name:Nt,variableName:E(Nt),typeName:Bc,tagName:E(Bc),propertyName:Pc,attributeName:E(Pc),className:E(Nt),labelName:E(Nt),namespace:E(Nt),macroName:E(Nt),literal:zt,string:Hr,docString:E(Hr),character:E(Hr),attributeValue:E(Hr),number:ol,integer:E(ol),float:E(ol),bool:E(zt),regexp:E(zt),escape:E(zt),color:E(zt),url:E(zt),keyword:ut,self:E(ut),null:E(ut),atom:E(ut),unit:E(ut),modifier:E(ut),operatorKeyword:E(ut),controlKeyword:E(ut),definitionKeyword:E(ut),moduleKeyword:E(ut),operator:dt,derefOperator:E(dt),arithmeticOperator:E(dt),logicOperator:E(dt),bitwiseOperator:E(dt),compareOperator:E(dt),updateOperator:E(dt),definitionOperator:E(dt),typeOperator:E(dt),controlOperator:E(dt),punctuation:al,separator:E(al),bracket:An,angleBracket:E(An),squareBracket:E(An),paren:E(An),brace:E(An),content:pt,heading:ni,heading1:E(ni),heading2:E(ni),heading3:E(ni),heading4:E(ni),heading5:E(ni),heading6:E(ni),contentSeparator:E(pt),list:E(pt),quote:E(pt),emphasis:E(pt),strong:E(pt),link:E(pt),monospace:E(pt),strikethrough:E(pt),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:Vr,documentMeta:E(Vr),annotation:E(Vr),processingInstruction:E(Vr),definition:Pe.defineModifier(),constant:Pe.defineModifier(),function:Pe.defineModifier(),standard:Pe.defineModifier(),local:Pe.defineModifier(),special:Pe.defineModifier()},kb=hl([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var cl,Oi=new X;function Cm(n){return I.define({combine:n?e=>e.concat(n):void 0})}var Am=new X,We=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return Be(this)}}),this.parser=t,this.extension=[Ei.of(this),oe.languageData.of((s,o,l)=>{let a=zc(s,o,l),h=a.type.prop(Oi);if(!h)return[];let c=s.facet(h),f=a.type.prop(Am);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return zc(e,t,i).type.prop(Oi)==this.data}findRegions(e){let t=e.facet(Ei);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Oi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(X.mounted);if(l){if(l.tree.prop(Oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof de&&r(h,s.positions[a]+o)}};return r(Be(e),0),i}get allowsNesting(){return!0}};We.setState=J.define();function zc(n,e,t){let i=n.facet(Ei),r=Be(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ve.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Be(n){let e=n.field(We.state,!1);return e?e.tree:de.empty}var pl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Tn=null,Mn=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],de.empty,0,i,[],null)}startParse(){return this.parser.startParse(new pl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=de.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ii.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ii.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Tn;Tn=this;try{return e()}finally{Tn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=ii.applyChanges(i,a),r=de.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Fc(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Cn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Tn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new de(Ee.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Tn}};function Fc(n,e,t){return ii.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Ln=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Mn.create(e.facet(Ei).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};We.state=pe.define({create:Ln.init,update(n,e){for(let t of e.effects)if(t.is(We.setState))return t.value;return e.startState.facet(Ei)!=e.state.facet(Ei)?Ln.init(e.state):n.apply(e)}});var qc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(qc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var fl=typeof navigator!="undefined"&&(!((cl=navigator.scheduling)===null||cl===void 0)&&cl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Tm=ye.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(We.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(We.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(We.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!fl?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>fl&&fl()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:We.setState.of(new Ln(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>He(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ei=I.define({combine(n){return n.length?n[0]:null},enables:n=>[We.state,Tm,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Bi=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var $c=I.define(),Ht=I.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ft(n){let e=n.facet(Ht);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ii(n,e){let t="",i=n.tabSize,r=n.facet(Ht)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function $r(n,e){n instanceof oe&&(n=new ri(n));for(let i of n.state.facet($c)){let r=i(n,e);if(r!==void 0)return r}let t=Be(n.state);return t.length>=e?Lm(n,t,e):null}var ri=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ft(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Dt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Mm=new X;function Lm(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Kc(i,n,t)}function Kc(n,e,t){for(let i=n;i;i=i.next){let r=Om(i.node);if(r)return r(ml.create(e,t,i))}return 0}function Dm(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Om(n){let e=n.type.prop(Mm);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(X.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Rm(o,!0,1,void 0,s&&!Dm(o)?r.from:void 0)}return n.parent==null?Em:null}function Em(){return 0}var ml=class n extends ri{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Bm(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Kc(this.context.next,this.base,this.pos)}};function Bm(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Pm(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function Rm(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Pm(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var Im=200;function _c(){return oe.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+Im)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=$r(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Ii(o,f);u!=p&&a.push({from:c.from,to:c.from+u.length,insert:p})}return a.length?[n,{changes:a,sequential:!0}]:n})}var Pi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ke.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof We?l=>l.prop(Oi)==o.data:o?l=>l==o:void 0,this.style=hl(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},gl=I.define(),Gc=I.define({combine(n){return n.length?[n[0]]:null}});function ul(n){let e=n.facet(gl);return e.length?e:n.facet(Gc)}function Kr(n,e){let t=[Nm],i;return n instanceof Pi&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Gc.of(n)):i?t.push(gl.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(gl.of(n)),t}var bl=class{constructor(e){this.markCache=Object.create(null),this.tree=Be(e.state),this.decorations=this.buildDeco(e,ul(e.state))}update(e){let t=Be(e.state),i=ul(e.state),r=i!=ul(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let i=new ot;for(let{from:r,to:s}of e.visibleRanges)Nc(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Y.mark({class:a})))},r,s);return i.finish()}},Nm=Lt.high(ye.fromClass(bl,{decorations:n=>n.decorations})),Uc=Pi.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),zm=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Yc=1e4,Jc="()[]{}",Xc=I.define({combine(n){return ze(n,{afterCursor:!0,brackets:Jc,maxScanDistance:Yc,renderMatch:Vm})}}),Fm=Y.mark({class:"cm-matchingBracket"}),Hm=Y.mark({class:"cm-nonmatchingBracket"});function Vm(n){let e=[],t=n.matched?Fm:Hm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}var Wm=pe.define({create(){return Y.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Xc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=nt(e.state,r.head,-1,i)||r.head>0&&nt(e.state,r.head-1,1,i)||i.afterCursor&&(nt(e.state,r.head,1,i)||r.head<e.state.doc.length&&nt(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return Y.set(t,!0)},provide:n=>z.decorations.from(n)}),jm=[Wm,zm];function Zc(n={}){return[Xc.of(n),jm]}var qm=new X;function kl(n,e,t){let i=n.prop(e<0?X.openedBy:X.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function yl(n){let e=n.type.prop(qm);return e?e(n.node):n}function nt(n,e,t,i={}){let r=i.maxScanDistance||Yc,s=i.brackets||Jc,o=Be(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=kl(a.type,t,s);if(h&&a.from<a.to){let c=yl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return $m(n,e,t,a,c,h,s)}}return Km(n,e,t,o,l.type,r,s)}function $m(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=yl(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(kl(c.type,t,o))h++;else if(kl(c.type,-t,o)){if(h==0){let f=yl(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Km(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let p=c.value;t<0&&(u+=p.length);let g=e+u*t;for(let x=t>0?0:p.length-1,y=t>0?p.length:-1;x!=y;x+=t){let v=o.indexOf(p[x]);if(!(v<0||i.resolveInner(g+x,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:g+x,to:g+x+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function Hc(n,e,t,i=0,r=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let s=r;for(let o=i;o<e;o++)n.charCodeAt(o)==9?s+=t-s%t:s++;return s}var jr=class{constructor(e,t,i,r){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Hc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Hc(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let r=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function _m(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||Gm,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||vl}}function Gm(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var Vc=new WeakMap,Ri=class n extends We{constructor(e){let t=Cm(e.languageData),i=_m(e),r,s=new class extends Cn{createParse(o,l,a){return new wl(r,o,l,a)}};super(t,s,[$c.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=Xm(t),r=this,this.streamParser=i,this.stateAfter=new X({perNode:!0}),this.tokenTable=e.tokenTable?new qr(i.tokenTable):Jm}static define(e){return new n(e)}getIndent(e,t){let i=Be(e.state),r=i.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=Vc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=xl(this,i,0,r.from,s!=null?s:t),a,h;if(l?(h=l.state,a=l.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let f=e.state.doc.lineAt(a),u=Math.min(t,f.to);if(f.length){let p=o?o(f.from):-1,g=new jr(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;g.pos<u-f.from;)ef(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,e.unit);if(u==t)break;a=f.to+1}let c=e.lineAt(t);return o&&s==null&&Vc.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function xl(n,e,t,i,r){let s=t>=i&&t+e.length<=r&&e.prop(n.stateAfter);if(s)return{state:n.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof de&&a<r&&xl(n,l,a,i,r);if(h)return h}return null}function Qc(n,e,t,i,r){if(r&&t<=0&&i>=e.length)return e;!r&&e.type==n.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<i&&l instanceof de){if(!(a=Qc(n,l,t-o,i-o,r)))break;return r?new de(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Um(n,e,t,i){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),l=s<=t&&o>t&&xl(n,r.tree,0-r.offset,t,o),a;if(l&&(a=Qc(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Ft(i):4),tree:de.empty}}var wl=class{constructor(e,t,i,r){this.lang=e,this.input=t,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=Mn.get(),o=r[0].from,{state:l,tree:a}=Um(e,i,o,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Ft(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=Mn.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
11
11
|
`&&(t="");else{let i=t.indexOf(`
|
|
12
|
-
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new jr(t,e?e.state.tabSize:4,e?Ft(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=ef(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=de.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Um,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new de(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new de(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function ef(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var vl=Object.create(null),Dn=[Ee.none],Um=new Nr(Dn),Wc=[],jc=Object.create(null),tf=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tf[n]=nf(vl,e);var qr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),tf)}resolve(e){return e?this.table[e]||(this.table[e]=nf(this.extra,e)):0}},Ym=new qr(vl);function dl(n,e){Wc.indexOf(n)>-1||(Wc.push(n),console.warn(e))}function nf(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||P[h];c?typeof c=="function"?a.length?a=a.map(c):dl(h,`Modifier ${h} used at start of tag`):a.length?dl(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:dl(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=jc[r];if(s)return s.id;let o=jc[r]=Ee.define({id:Dn.length,name:i,props:[Rc({[i]:t})]});return Dn.push(o),o.id}function Jm(n){let e=Ee.define({id:Dn.length,name:"Document",props:[Oi.add(()=>n)],top:!0});return Dn.push(e),e}var Xm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Dl(n.state,t.from);return i.line?Zm(n):i.block?eg(n):!1};function Ll(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var Zm=Ll(ng,0);var Qm=Ll(ff,0);var eg=Ll((n,e)=>ff(n,e,ig(e)),0);function Dl(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var On=50;function tg(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-On,i),o=n.sliceDoc(r,r+On),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*On?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+On),f=n.sliceDoc(r-On,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(g,g+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function ig(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function ff(n,e,t=e.selection.ranges){let i=t.map(s=>Dl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>tg(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function ng(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,a=1e9,h=Dl(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,p=u==f.length,g=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:g,token:h,indent:u,empty:p,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var Cl=Ne.define(),rg=Ne.define(),sg=I.define(),uf=I.define({combine(n){return ze(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),df=pe.define({create(){return si.empty},update(n,e){let t=e.state.facet(uf),i=e.annotation(Cl);if(i){let a=rt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Gr(c,c.length,t.minDepth,a):c=bf(c,e.startState.selection),new si(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(rg);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=rt.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new si(n.done.map(rt.fromJSON),n.undone.map(rt.fromJSON))}});function pf(n={}){return[df,uf.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?mf:e.inputType=="historyRedo"?Al:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ur(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(df,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var mf=Ur(0,!1),Al=Ur(1,!1),og=Ur(0,!0),lg=Ur(1,!0);var rt=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&De.fromJSON(e.changes),[],e.mapped&&yt.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Ue;for(let r of e.startState.facet(sg)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ue)}static selection(e){return new n(void 0,Ue,void 0,void 0,e)}};function Gr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function ag(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function hg(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function gf(n,e){return n.length?e.length?n.concat(e):n:e}var Ue=[],cg=200;function bf(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-cg));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Gr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[rt.selection([e])]}function fg(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Sl(n,e){if(!n.length)return n;let t=n.length,i=Ue;for(;t;){let r=ug(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[rt.selection(i)]:Ue}function ug(n,e,t){let i=gf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ue,t);if(!n.changes)return rt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new rt(r,J.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var dg=/^(input\.type|delete)($|\.)/,si=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||dg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,ag(l.changes,e.changes))||i=="input.type.compose")?o=Gr(o,o.length-1,r.minDepth,new rt(e.changes.compose(l.changes),gf(e.effects,l.effects),l.mapped,l.startSelection,Ue)):o=Gr(o,o.length,r.minDepth,e),new n(o,Ue,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ue;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&hg(s[s.length-1],e)?this:new n(bf(this.done,e),this.undone,t,i)}addMapping(e){return new n(Sl(this.done,e),Sl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Cl.of({side:e,rest:fg(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ue:r.slice(0,r.length-1);return s.mapped&&(l=Sl(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Cl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};si.empty=new si(Ue,Ue);var kf=[{key:"Mod-z",run:mf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Al,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Al,preventDefault:!0},{key:"Mod-u",run:og,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:lg,preventDefault:!0}];function Ni(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function mt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function st({state:n,dispatch:e},t){let i=Ni(n.selection,t);return i.eq(n.selection)?!1:(e(mt(n,i)),!0)}function Yr(n,e){return L.cursor(e?n.to:n.from)}function yf(n,e){return st(n,t=>t.empty?n.moveByChar(t,e):Yr(t,e))}function Le(n){return n.textDirectionAt(n.state.selection.main.head)==ge.LTR}var wf=n=>yf(n,!Le(n)),xf=n=>yf(n,Le(n));function vf(n,e){return st(n,t=>t.empty?n.moveByGroup(t,e):Yr(t,e))}var pg=n=>vf(n,!Le(n)),mg=n=>vf(n,Le(n));var Bb=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function gg(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jr(n,e,t){let i=Be(n).resolveInner(e.head),r=t?X.closedBy:X.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;gg(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?nt(n,i.from,1):nt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var bg=n=>st(n,e=>Jr(n.state,e,!Le(n))),kg=n=>st(n,e=>Jr(n.state,e,Le(n)));function Sf(n,e){return st(n,t=>{if(!t.empty)return Yr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Cf=n=>Sf(n,!1),Af=n=>Sf(n,!0);function Tf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Mf(n,e){let t=Tf(n),{state:i}=n,r=Ni(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Yr(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(mt(i,r),{effects:s}),!0}var rf=n=>Mf(n,!1),Tl=n=>Mf(n,!0);function Vt(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var yg=n=>st(n,e=>Vt(n,e,!0)),wg=n=>st(n,e=>Vt(n,e,!1)),xg=n=>st(n,e=>Vt(n,e,!Le(n))),vg=n=>st(n,e=>Vt(n,e,Le(n))),Sg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Cg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function Ag(n,e,t){let i=!1,r=Ni(n.selection,s=>{let o=nt(n,s.head,-1)||nt(n,s.head,1)||s.head>0&&nt(n,s.head-1,1)||s.head<n.doc.length&&nt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(mt(n,r)),!0):!1}var Tg=({state:n,dispatch:e})=>Ag(n,e,!1);function Ye(n,e){let t=Ni(n.state.selection,i=>{let r=e(i);return L.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(mt(n.state,t)),!0)}function Lf(n,e){return Ye(n,t=>n.moveByChar(t,e))}var Df=n=>Lf(n,!Le(n)),Of=n=>Lf(n,Le(n));function Ef(n,e){return Ye(n,t=>n.moveByGroup(t,e))}var Mg=n=>Ef(n,!Le(n)),Lg=n=>Ef(n,Le(n));var Dg=n=>Ye(n,e=>Jr(n.state,e,!Le(n))),Og=n=>Ye(n,e=>Jr(n.state,e,Le(n)));function Bf(n,e){return Ye(n,t=>n.moveVertically(t,e))}var Pf=n=>Bf(n,!1),Rf=n=>Bf(n,!0);function If(n,e){return Ye(n,t=>n.moveVertically(t,e,Tf(n).height))}var sf=n=>If(n,!1),of=n=>If(n,!0),Eg=n=>Ye(n,e=>Vt(n,e,!0)),Bg=n=>Ye(n,e=>Vt(n,e,!1)),Pg=n=>Ye(n,e=>Vt(n,e,!Le(n))),Rg=n=>Ye(n,e=>Vt(n,e,Le(n))),Ig=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).from)),Ng=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).to)),lf=({state:n,dispatch:e})=>(e(mt(n,{anchor:0})),!0),af=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.doc.length})),!0),hf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:0})),!0),cf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),zg=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Fg=({state:n,dispatch:e})=>{let t=Xr(n).map(({from:i,to:r})=>L.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},Hg=({state:n,dispatch:e})=>{let t=Ni(n.selection,i=>{var r;let s=Be(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return L.range(l.to,l.from)}return i});return e(mt(n,t)),!0},Vg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(mt(n,i)),!0):!1};function En(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=_r(n,a,!1)):a>o&&(t="delete.forward",a=_r(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=_r(n,o,!1),l=_r(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function _r(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Nf=(n,e)=>En(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]==" ")return i-1;let a=Dt(o,r.tabSize),h=a%Ft(r)||Ft(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=be(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=be(s.text,l-s.from,!1,!1)+s.from);return l}),Ml=n=>Nf(n,!1),zf=n=>Nf(n,!0),Ff=(n,e)=>En(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=be(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Hf=n=>Ff(n,!1),Wg=n=>Ff(n,!0),jg=n=>En(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var qg=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),$g=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Kg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Z.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},_g=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:be(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:be(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xr(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Vf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Xr(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Gg=({state:n,dispatch:e})=>Vf(n,e,!1),Ug=({state:n,dispatch:e})=>Vf(n,e,!0);function Wf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Xr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Yg=({state:n,dispatch:e})=>Wf(n,e,!1),Jg=({state:n,dispatch:e})=>Wf(n,e,!0),Xg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Xr(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Ni(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Be(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(X.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var Qg=jf(!1),e0=jf(!0);function jf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&Zg(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ri(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=$r(h,s);for(c==null&&(c=Dt(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Ii(e,c)];return a&&f.push(Ii(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Z.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ol(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var t0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new ri(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Ol(n,(s,o,l)=>{let a=$r(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Ii(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},i0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Ht)})}),{userEvent:"input.indent"})),!0),n0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Dt(r,n.tabSize),o=0,l=Ii(n,Math.max(0,s-Ft(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var r0=[{key:"Ctrl-b",run:wf,shift:Df,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:Of},{key:"Ctrl-p",run:Cf,shift:Pf},{key:"Ctrl-n",run:Af,shift:Rf},{key:"Ctrl-a",run:Sg,shift:Ig},{key:"Ctrl-e",run:Cg,shift:Ng},{key:"Ctrl-d",run:zf},{key:"Ctrl-h",run:Ml},{key:"Ctrl-k",run:jg},{key:"Ctrl-Alt-h",run:Hf},{key:"Ctrl-o",run:Kg},{key:"Ctrl-t",run:_g},{key:"Ctrl-v",run:Tl}],s0=[{key:"ArrowLeft",run:wf,shift:Df,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:pg,shift:Mg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:xg,shift:Pg,preventDefault:!0},{key:"ArrowRight",run:xf,shift:Of,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:mg,shift:Lg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:vg,shift:Rg,preventDefault:!0},{key:"ArrowUp",run:Cf,shift:Pf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lf,shift:hf},{mac:"Ctrl-ArrowUp",run:rf,shift:sf},{key:"ArrowDown",run:Af,shift:Rf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:af,shift:cf},{mac:"Ctrl-ArrowDown",run:Tl,shift:of},{key:"PageUp",run:rf,shift:sf},{key:"PageDown",run:Tl,shift:of},{key:"Home",run:wg,shift:Bg,preventDefault:!0},{key:"Mod-Home",run:lf,shift:hf},{key:"End",run:yg,shift:Eg,preventDefault:!0},{key:"Mod-End",run:af,shift:cf},{key:"Enter",run:Qg},{key:"Mod-a",run:zg},{key:"Backspace",run:Ml,shift:Ml},{key:"Delete",run:zf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Hf},{key:"Mod-Delete",mac:"Alt-Delete",run:Wg},{mac:"Mod-Backspace",run:qg},{mac:"Mod-Delete",run:$g}].concat(r0.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),qf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:bg,shift:Dg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:kg,shift:Og},{key:"Alt-ArrowUp",run:Gg},{key:"Shift-Alt-ArrowUp",run:Yg},{key:"Alt-ArrowDown",run:Ug},{key:"Shift-Alt-ArrowDown",run:Jg},{key:"Escape",run:Vg},{key:"Mod-Enter",run:e0},{key:"Alt-l",mac:"Ctrl-l",run:Fg},{key:"Mod-i",run:Hg,preventDefault:!0},{key:"Mod-[",run:n0},{key:"Mod-]",run:i0},{key:"Mod-Alt-\\",run:t0},{key:"Shift-Mod-k",run:Xg},{key:"Shift-Mod-\\",run:Tg},{key:"Mod-/",run:Xm},{key:"Alt-A",run:Qm}].concat(s0);function ne(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)$f(n,arguments[e]);return n}function $f(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)$f(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var Kf=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,oi=class{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(Kf(l)):Kf,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $e(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=er(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=wt(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o);if(s==r.length-1){if(a)return this.value=a,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}};typeof Symbol!="undefined"&&(oi.prototype[Symbol.iterator]=function(){return this});var Uf={from:-1,to:-1,match:/.*/.exec("")},zl="gm"+(/x/.unicode==null?"":"u"),es=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Uf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new is(e,t,i,r,s);this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=ns(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=ns(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},El=new WeakMap,ts=class n{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=El.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return El.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),El.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},is=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=Uf,this.matchPos=ns(e,r),this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=ts.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=ns(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ts.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(es.prototype[Symbol.iterator]=is.prototype[Symbol.iterator]=function(){return this});function o0(n){try{return new RegExp(n,zl),!0}catch(e){return!1}}function ns(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Bl(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=ne("input",{class:"cm-textfield",name:"line",value:e}),i=ne("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:rs.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},ne("label",n.state.phrase("Go to line"),": ",t)," ",ne("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=s,u=c?+c.slice(1):0,p=h?+h:l.number;if(h&&f){let y=p/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*y)}else h&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=L.cursor(g.from+Math.max(0,Math.min(u,g.length)));n.dispatch({effects:[rs.of(!1),z.scrollIntoView(x.from,{y:"center"})],selection:x}),n.focus()}return{dom:i}}var rs=J.define(),_f=pe.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(rs)&&(n=t.value);return n},provide:n=>ei.from(n,e=>e?Bl:null)}),l0=n=>{let e=ti(n,Bl);if(!e){let t=[rs.of(!0)];n.state.field(_f,!1)==null&&t.push(J.appendConfig.of([_f,a0])),n.dispatch({effects:t}),e=ti(n,Bl)}return e&&e.dom.querySelector("input").select(),!0},a0=z.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var h0=({state:n,dispatch:e})=>{let{selection:t}=n,i=L.create(t.ranges.map(r=>n.wordAt(r.head)||L.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function c0(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new oi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new oi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var f0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return h0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=c0(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:z.scrollIntoView(r.to)})),!0):!1},Hi=I.define({combine(n){return ze(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Nl(e),scrollToMatch:e=>z.scrollIntoView(e)})}});var ss=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||o0(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
13
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Rl(this):new Pl(this)}getCursor(e,t=0,i){let r=e.doc?e:he.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Fi(this,r,t,i):zi(this,r,t,i)}},os=class{constructor(e){this.spec=e}};function zi(n,e,t,i){return new oi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?u0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function u0(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(ls(r,t-s))!=fe.Word||e(as(r,t-s))!=fe.Word)&&(e(as(r,i-s))!=fe.Word||e(ls(r,i-s))!=fe.Word))}var Pl=class extends os{constructor(e){super(e)}nextMatch(e,t,i){let r=zi(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=zi(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=zi(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=zi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=zi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function Fi(n,e,t,i){return new es(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?d0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ls(n,e){return n.slice(be(n,e,!1),e)}function as(n,e){return n.slice(e,be(n,e))}function d0(n){return(e,t,i)=>!i[0].length||(n(ls(i.input,i.index))!=fe.Word||n(as(i.input,i.index))!=fe.Word)&&(n(as(i.input,i.index+i[0].length))!=fe.Word||n(ls(i.input,i.index+i[0].length))!=fe.Word)}var Rl=class extends os{nextMatch(e,t,i){let r=Fi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Fi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Fi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t))}matchAll(e,t){let i=Fi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Fi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Pn=J.define(),Fl=J.define(),Wt=pe.define({create(n){return new Bn(Il(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Pn)?n=new Bn(t.value.create(),n.panel):t.is(Fl)&&(n=new Bn(n.query,t.value?Hl:null));return n},provide:n=>ei.from(n,e=>e.panel)});var Bn=class{constructor(e,t){this.query=e,this.panel=t}},p0=Y.mark({class:"cm-searchMatch"}),m0=Y.mark({class:"cm-searchMatch cm-searchMatch-selected"}),g0=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Wt))}update(n){let e=n.state.field(Wt);(e!=n.startState.field(Wt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Y.none;let{view:t}=this,i=new ot;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?m0:p0)})}return i.finish()}},{decorations:n=>n.decorations});function Rn(n){return e=>{let t=e.state.field(Wt,!1);return t&&t.query.spec.valid?n(e,t):Xf(e)}}var hs=Rn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=L.single(i.from,i.to),s=n.state.facet(Hi);return n.dispatch({selection:r,effects:[Vl(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Jf(n),!0}),cs=Rn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=L.single(r.from,r.to),o=n.state.facet(Hi);return n.dispatch({selection:s,effects:[Vl(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Jf(n),!0}),b0=Rn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:L.create(t.map(i=>L.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),k0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new oi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(L.range(l.value.from,l.value.to))}return e(n.update({selection:L.create(s,o),userEvent:"select.search.matches"})),!0},Gf=Rn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,a,h=[];if(s.from==i&&s.to==r&&(a=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(t,s.from,s.to),h.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-a.length;l=L.single(s.from-c,s.to-c),h.push(Vl(n,s)),h.push(t.facet(Hi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),y0=Rn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:z.announce.of(i),userEvent:"input.replace.all"}),!0});function Hl(n){return n.state.facet(Hi).createPanel(n)}function Il(n,e){var t,i,r,s,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Hi);return new ss({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Yf(n){let e=ti(n,Hl);return e&&e.dom.querySelector("[main-field]")}function Jf(n){let e=Yf(n);e&&e==n.root.activeElement&&e.select()}var Xf=n=>{let e=n.state.field(Wt,!1);if(e&&e.panel){let t=Yf(n);if(t&&t!=n.root.activeElement){let i=Il(n.state,e.query.spec);i.valid&&n.dispatch({effects:Pn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Fl.of(!0),e?Pn.of(Il(n.state,e.query.spec)):J.appendConfig.of(x0)]});return!0},Zf=n=>{let e=n.state.field(Wt,!1);if(!e||!e.panel)return!1;let t=ti(n,Hl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Fl.of(!1)}),!0},Qf=[{key:"Mod-f",run:Xf,scope:"editor search-panel"},{key:"F3",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Zf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:k0},{key:"Alt-g",run:l0},{key:"Mod-d",run:f0,preventDefault:!0}],Nl=class{constructor(e){this.view=e;let t=this.query=e.state.field(Wt).query.spec;this.commit=this.commit.bind(this),this.searchField=ne("input",{value:t.search,placeholder:je(e,"Find"),"aria-label":je(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ne("input",{value:t.replace,placeholder:je(e,"Replace"),"aria-label":je(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ne("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ne("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ne("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ne("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ne("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>hs(e),[je(e,"next")]),i("prev",()=>cs(e),[je(e,"previous")]),i("select",()=>b0(e),[je(e,"all")]),ne("label",null,[this.caseField,je(e,"match case")]),ne("label",null,[this.reField,je(e,"regexp")]),ne("label",null,[this.wordField,je(e,"by word")]),...e.state.readOnly?[]:[ne("br"),this.replaceField,i("replace",()=>Gf(e),[je(e,"replace")]),i("replaceAll",()=>y0(e),[je(e,"replace all")])],ne("button",{name:"close",onclick:()=>Zf(e),"aria-label":je(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new ss({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Pn.of(e)}))}keydown(e){mc(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?cs:hs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Gf(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Pn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Hi).top}};function je(n,e){return n.state.phrase(e)}var Zr=30,Qr=/[\s\.,:;?!]/;function Vl(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-Zr),o=Math.min(r,t+Zr),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<Zr;a++)if(!Qr.test(l[a+1])&&Qr.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-Zr;a--)if(!Qr.test(l[a-1])&&Qr.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var w0=z.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),x0=[Wt,Lt.low(g0),w0];var Wl=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},li=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(ai).markerFilter;s&&(r=s(r));let o=Y.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?Y.widget({widget:new jl(l),diagnostic:l}).range(l.from):Y.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new n(o,t,Vi(o))}};function Vi(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new Wl(r,s,o.diagnostic),!1}),i}function tu(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(ms))||n.changes.touchesRange(t.from,t.to))}function iu(n,e){return n.field(Je,!1)?e:e.concat(J.appendConfig.of(cu))}function v0(n,e){return{effects:iu(n,[ms.of(e)])}}var ms=J.define(),$l=J.define(),nu=J.define(),Je=pe.define({create(){return new li(Y.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vi(t,n.selected.diagnostic,r)||Vi(t,null,r)}n=new li(t,n.panel,i)}for(let t of e.effects)t.is(ms)?n=li.init(t.value,n.panel,e.state):t.is($l)?n=new li(n.diagnostics,t.value?ps.open:null,n.selected):t.is(nu)&&(n=new li(n.diagnostics,n.panel,t.value));return n},provide:n=>[ei.from(n,e=>e.panel),z.decorations.from(n,e=>e.diagnostics)]});var S0=Y.mark({class:"cm-lintRange cm-lintRange-active"});function C0(n,e,t){let{diagnostics:i}=n.state.field(Je),r=[],s=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(r.push(c.diagnostic),s=Math.min(a,s),o=Math.max(h,o))});let l=n.state.facet(ai).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:ru(n,r)}}}:null}function ru(n,e){return ne("ul",{class:"cm-tooltip-lint"},e.map(t=>lu(n,t,!1)))}var Kl=n=>{let e=n.state.field(Je,!1);(!e||!e.panel)&&n.dispatch({effects:iu(n.state,[$l.of(!0)])});let t=ti(n,ps.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},In=n=>{let e=n.state.field(Je,!1);return!e||!e.panel?!1:(n.dispatch({effects:$l.of(!1)}),!0)};var A0=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(ai);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(ai);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(v0(this.view.state,r))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(ai);(n.docChanged||e!=n.startState.facet(ai)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),ai=I.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ze(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function su(n,e={}){return[ai.of({source:n,config:e}),A0,cu]}function ou(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function lu(n,e,t){var i;let r=t?ou(e.actions):[];return ne("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ne("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let p=Vi(n.state.field(Je).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),ne("u",h.slice(c,c+1)),h.slice(c+1)];return ne("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&ne("div",{class:"cm-diagnosticSource"},e.source))}var jl=class extends et{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ne("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},ds=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lu(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ps=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)In(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=ou(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=Vi(this.view.state.field(Je).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=ne("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=ne("div",{class:"cm-panel-lint"},this.list,ne("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>In(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ds(this.view,a.diagnostic),this.items.splice(i,0,c),r=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ds(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Je),i=Vi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:nu.of(i)})}static open(e){return new n(e)}};function us(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function fs(n){return us(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var T0=z.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fs("#d11")},".cm-lintRange-warning":{backgroundImage:fs("orange")},".cm-lintRange-info":{backgroundImage:fs("#999")},".cm-lintRange-hint":{backgroundImage:fs("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function eu(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var ql=class extends Ge{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>eu(t)<eu(i.severity)?i.severity:t,"hint")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(gs).tooltipFilter;return r&&(i=r(i)),i.length&&(t.onmouseover=()=>L0(e,t,i)),t}};function M0(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(hu)&&n.dispatch({effects:_l.of(null)})}};window.addEventListener("mousemove",t)}function L0(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:_l.of({pos:o.from,above:!1,create(){return{dom:ru(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,M0(n,e)}let{hoverTime:r}=n.state.facet(gs),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function D0(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new ql(t[r]).range(+r));return ie.of(i,!0)}var O0=Zo({class:"cm-gutter-lint",markers:n=>n.state.field(au)}),au=pe.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(gs).markerFilter;for(let i of e.effects)if(i.is(ms)){let r=i.value;t&&(r=t(r||[])),n=D0(e.state.doc,r.slice(0))}return n}}),_l=J.define(),hu=pe.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=tu(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(_l)?i.value:t,n)},provide:n=>yn.from(n)}),E0=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:us('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:us('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:us('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),cu=[Je,z.decorations.compute([Je],n=>{let{selected:e,panel:t}=n.field(Je);return!e||!t||e.from==e.to?Y.none:Y.set([S0.range(e.from,e.to)])}),wc(C0,{hideOn:tu}),T0],gs=I.define({combine(n){return ze(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fu(n={}){return[gs.of(n),au,O0,E0,hu]}var bs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},hi=J.define({map(n,e){let t=e.mapPos(n,-1,Ce.TrackAfter);return t==null?void 0:t}}),Ul=new class extends Ze{};Ul.startSide=1;Ul.endSide=-1;var pu=pe.define({create(){return ie.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(hi)&&(n=n.update({add:[Ul.range(t.value,t.value+1)]}));return n}});function mu(){return[I0,pu]}var Gl="()[]{}<>";function B0(n){for(let e=0;e<Gl.length;e+=2)if(Gl.charCodeAt(e)==n)return Gl.charAt(e+1);return er(n<128?n:n+1)}function P0(n,e){return n.languageDataAt("closeBrackets",e)[0]||bs}var R0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),I0=z.inputHandler.of((n,e,t,i)=>{if((R0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&wt($e(i,0))==1||e!=r.from||t!=r.to)return!1;let s=N0(n.state,i);return s?(n.dispatch(s),!0):!1});function N0(n,e){let t=P0(n,n.selection.main.head),i=t.brackets||bs.brackets;for(let r of i){let s=B0($e(r,0));if(e==r)return s==r?H0(n,r,i.indexOf(r+r+r)>-1,t):z0(n,r,s,t.before||bs.before);if(e==s&&gu(n,n.selection.main.from))return F0(n,r,s)}return null}function gu(n,e){let t=!1;return n.field(pu).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Yl(n,e){let t=n.sliceString(e,e+2);return t.slice(0,wt($e(t,0)))}function z0(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:hi.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=Yl(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:hi.of(o.head+e.length),range:L.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function F0(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Yl(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:L.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function H0(n,e,t,i){let r=i.stringPrefixes||bs.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:hi.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Yl(n.doc,a),c;if(h==e){if(uu(n,a))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(gu(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:L.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=du(n,a-2*e.length,r))>-1&&uu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=fe.Word&&du(n,a,r)>-1&&!V0(n,a,e,r))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function uu(n,e){let t=Be(n).resolveInner(e+1);return t.parent&&t.from==e}function V0(n,e,t,i){let r=Be(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function du(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=fe.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=fe.Word)return s}return-1}var S={permittedHtmlTags:new Set(["b","bdi","bdo","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","q","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","br","wbr","hr","li","dt","dd","td","th","tr","noinclude","includeonly","onlyinclude","img"]),implicitlyClosedHtmlTags:new Set(["br","hr","wbr","img"]),tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",extGround:"mw-ext-ground",ext2Ground:"mw-ext2-ground",ext2LinkGround:"mw-ext2-link-ground",ext3Ground:"mw-ext3-ground",ext3LinkGround:"mw-ext3-link-ground",extLinkGround:"mw-ext-link-ground",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateExtGround:"mw-template-ext-ground",templateExt2Ground:"mw-template-ext2-ground",templateExt2LinkGround:"mw-template-ext2-link-ground",templateExt3Ground:"mw-template-ext3-ground",templateExt3LinkGround:"mw-template-ext3-link-ground",templateExtLinkGround:"mw-template-ext-link-ground",templateGround:"mw-template-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ext2Ground:"mw-template2-ext2-ground",template2Ext3Ground:"mw-template2-ext3-ground",templatet2Ext2LinkGround:"mw-template2-ext2-link-ground",template2Ext3LinkGround:"mw-template2-ext3-link-ground",template2ExtLinkGround:"mw-template2-ext-link-ground",template2Ground:"mw-template2-ground",template2LinkGround:"mw-template2-link-ground",template3ExtGround:"mw-template3-ext-ground",template3Ext2Ground:"mw-template3-ext2-ground",template3Ext3Ground:"mw-template3-ext3-ground",template3ExtLinkGround:"mw-template3-ext-link-ground",template3Ext2LinkGround:"mw-template3-ext2-link-ground",template3Ext3LinkGround:"mw-template3-ext3-link-ground",template3Ground:"mw-template3-ground",template3LinkGround:"mw-template3-link-ground"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=Pe.define();return n}};var Nn={};ld(Nn,{css:()=>Mu,javascript:()=>Lu,lua:()=>Eu});function ks(n){n={...$0,...n};var e=n.inline,t=n.tokenHooks,i=n.documentTypes||{},r=n.mediaTypes||{},s=n.mediaFeatures||{},o=n.mediaValueKeywords||{},l=n.propertyKeywords||{},a=n.nonStandardPropertyKeywords||{},h=n.fontProperties||{},c=n.counterDescriptors||{},f=n.colorKeywords||{},u=n.valueKeywords||{},p=n.allowNested,g=n.lineComment,x=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,M;function O(k,T){return v=T,k}function R(k,T){var A=k.next();if(t[A]){var V=t[A](k,T);if(V!==!1)return V}if(A=="@")return k.eatWhile(/[\w\\\-]/),O("def",k.current());if(A=="="||(A=="~"||A=="|")&&k.eat("="))return O(null,"compare");if(A=='"'||A=="'")return T.tokenize=F(A),T.tokenize(k,T);if(A=="#")return k.eatWhile(/[\w\\\-]/),O("atom","hash");if(A=="!")return k.match(/^\s*\w*/),O("keyword","important");if(/\d/.test(A)||A=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),O("number","unit");if(A==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),O("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?O("def","variable-definition"):O("variableName","variable");if(k.match(/^\w+-/))return O("meta","meta")}else return/[,+>*\/]/.test(A)?O(null,"select-op"):A=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?O("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(A)?O(null,A):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(T.tokenize=q),O("variableName.function","variable")):/[\w\\\-]/.test(A)?(k.eatWhile(/[\w\\\-]/),O("property","word")):O(null,null)}function F(k){return function(T,A){for(var V=!1,le;(le=T.next())!=null;){if(le==k&&!V){k==")"&&T.backUp(1);break}V=!V&&le=="\\"}return(le==k||!V&&k!=")")&&(A.tokenize=null),O("string","string")}}function q(k,T){return k.next(),k.match(/^\s*[\"\')]/,!1)?T.tokenize=null:T.tokenize=F(")"),O(null,"(")}function w(k,T,A){this.type=k,this.indent=T,this.prev=A}function D(k,T,A,V){return k.context=new w(A,T.indentation()+(V===!1?0:T.indentUnit),k.context),A}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function U(k,T,A){return K[A.context.type](k,T,A)}function $(k,T,A,V){for(var le=V||1;le>0;le--)A.context=A.context.prev;return U(k,T,A)}function G(k){var T=k.current().toLowerCase();u.hasOwnProperty(T)?M="atom":f.hasOwnProperty(T)?M="keyword":M="variable"}var K={};return K.top=function(k,T,A){if(k=="{")return D(A,T,"block");if(k=="}"&&A.context.prev)return b(A);if(x&&/@component/i.test(k))return D(A,T,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return D(A,T,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return D(A,T,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return A.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return D(A,T,"at");if(k=="hash")M="builtin";else if(k=="word")M="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return D(A,T,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return D(A,T,"parens")}return A.context.type},K.block=function(k,T,A){if(k=="word"){var V=T.current().toLowerCase();return l.hasOwnProperty(V)?(M="property","maybeprop"):a.hasOwnProperty(V)?(M=y?"string.special":"property","maybeprop"):p?(M=T.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(M="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(M="error","block"):K.top(k,T,A)},K.maybeprop=function(k,T,A){return k==":"?D(A,T,"prop"):U(k,T,A)},K.prop=function(k,T,A){if(k==";")return b(A);if(k=="{"&&p)return D(A,T,"propBlock");if(k=="}"||k=="{")return $(k,T,A);if(k=="(")return D(A,T,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(T.current()))M="error";else if(k=="word")G(T);else if(k=="interpolation")return D(A,T,"interpolation");return"prop"},K.propBlock=function(k,T,A){return k=="}"?b(A):k=="word"?(M="property","maybeprop"):A.context.type},K.parens=function(k,T,A){return k=="{"||k=="}"?$(k,T,A):k==")"?b(A):k=="("?D(A,T,"parens"):k=="interpolation"?D(A,T,"interpolation"):(k=="word"&&G(T),"parens")},K.pseudo=function(k,T,A){return k=="meta"?"pseudo":k=="word"?(M="variableName.constant",A.context.type):U(k,T,A)},K.documentTypes=function(k,T,A){return k=="word"&&i.hasOwnProperty(T.current())?(M="tag",A.context.type):K.atBlock(k,T,A)},K.atBlock=function(k,T,A){if(k=="(")return D(A,T,"atBlock_parens");if(k=="}"||k==";")return $(k,T,A);if(k=="{")return b(A)&&D(A,T,p?"block":"top");if(k=="interpolation")return D(A,T,"interpolation");if(k=="word"){var V=T.current().toLowerCase();V=="only"||V=="not"||V=="and"||V=="or"?M="keyword":r.hasOwnProperty(V)?M="attribute":s.hasOwnProperty(V)?M="property":o.hasOwnProperty(V)?M="keyword":l.hasOwnProperty(V)?M="property":a.hasOwnProperty(V)?M=y?"string.special":"property":u.hasOwnProperty(V)?M="atom":f.hasOwnProperty(V)?M="keyword":M="error"}return A.context.type},K.atComponentBlock=function(k,T,A){return k=="}"?$(k,T,A):k=="{"?b(A)&&D(A,T,p?"block":"top",!1):(k=="word"&&(M="error"),A.context.type)},K.atBlock_parens=function(k,T,A){return k==")"?b(A):k=="{"||k=="}"?$(k,T,A,2):K.atBlock(k,T,A)},K.restricted_atBlock_before=function(k,T,A){return k=="{"?D(A,T,"restricted_atBlock"):k=="word"&&A.stateArg=="@counter-style"?(M="variable","restricted_atBlock_before"):U(k,T,A)},K.restricted_atBlock=function(k,T,A){return k=="}"?(A.stateArg=null,b(A)):k=="word"?(A.stateArg=="@font-face"&&!h.hasOwnProperty(T.current().toLowerCase())||A.stateArg=="@counter-style"&&!c.hasOwnProperty(T.current().toLowerCase())?M="error":M="property","maybeprop"):"restricted_atBlock"},K.keyframes=function(k,T,A){return k=="word"?(M="variable","keyframes"):k=="{"?D(A,T,"top"):U(k,T,A)},K.at=function(k,T,A){return k==";"?b(A):k=="{"||k=="}"?$(k,T,A):(k=="word"?M="tag":k=="hash"&&(M="builtin"),"at")},K.interpolation=function(k,T,A){return k=="}"?b(A):k=="{"||k==";"?$(k,T,A):(k=="word"?M="variable":k!="variable"&&k!="("&&k!=")"&&(M="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new w(e?"block":"top",0,null)}},token:function(k,T){if(!T.tokenize&&k.eatSpace())return null;var A=(T.tokenize||R)(k,T);return A&&typeof A=="object"&&(v=A[1],A=A[0]),M=A,v!="comment"&&(T.state=K[T.state](v,k,T)),M},indent:function(k,T,A){var V=k.context,le=T&&T.charAt(0),we=V.indent;return V.type=="prop"&&(le=="}"||le==")")&&(V=V.prev),V.prev&&(le=="}"&&(V.type=="block"||V.type=="top"||V.type=="interpolation"||V.type=="restricted_atBlock")?(V=V.prev,we=V.indent):(le==")"&&(V.type=="parens"||V.type=="atBlock_parens")||le=="{"&&(V.type=="at"||V.type=="atBlock"))&&(we=Math.max(0,V.indent-A.unit))),we},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:q0}}}function gt(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var bu=["domain","regexp","url","url-prefix"],ku=gt(bu),yu=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],ys=gt(yu),wu=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],ws=gt(wu),xu=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Jl=gt(xu),vu=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],xs=gt(vu),Su=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],vs=gt(Su),W0=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],Ss=gt(W0),j0=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],Cu=gt(j0),Au=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Cs=gt(Au),Tu=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],As=gt(Tu),q0=bu.concat(yu).concat(wu).concat(xu).concat(vu).concat(Su).concat(Au).concat(Tu);var $0={documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}},Mu=ks({name:"css"});function jt(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var Qb=ks({name:"scss",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},":":function(n){return n.match(/^\s*\{/,!1)?[null,null]:!1},$:function(n){return n.match(/^[\w-]+/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}}}),ek=ks({name:"less",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},"@":function(n){return n.eat("{")?[null,"interpolation"]:n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),tk=ks({name:"gss",documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}});function Ts(n){var e=n.statementIndent,t=n.jsonld,i=n.json||t,r=n.typescript,s=n.wordCharacters||/[\w$\xa1-\uffff]/,o=function(){function d(Re){return{type:Re,style:"keyword"}}var m=d("keyword a"),C=d("keyword b"),B=d("keyword c"),N=d("keyword d"),Q=d("operator"),se={type:"atom",style:"atom"};return{if:d("if"),while:m,with:m,else:C,do:C,try:C,finally:C,return:N,break:N,continue:N,new:d("new"),delete:B,void:B,throw:B,debugger:d("debugger"),var:d("var"),const:d("var"),let:d("var"),function:d("function"),catch:d("catch"),for:d("for"),switch:d("switch"),case:d("case"),default:d("default"),in:Q,typeof:Q,instanceof:Q,true:se,false:se,null:se,undefined:se,NaN:se,Infinity:se,this:d("this"),class:d("class"),super:d("atom"),yield:B,export:d("export"),import:d("import"),extends:B,await:B}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var m=!1,C,B=!1;(C=d.next())!=null;){if(!m){if(C=="/"&&!B)return;C=="["?B=!0:B&&C=="]"&&(B=!1)}m=!m&&C=="\\"}}var c,f;function u(d,m,C){return c=d,f=C,m}function p(d,m){var C=d.next();if(C=='"'||C=="'")return m.tokenize=g(C),m.tokenize(d,m);if(C=="."&&d.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if(C=="."&&d.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(C))return u(C);if(C=="="&&d.eat(">"))return u("=>","operator");if(C=="0"&&d.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(C))return d.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if(C=="/")return d.eat("*")?(m.tokenize=x,x(d,m)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):sd(d,m,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return m.tokenize=y,y(d,m);if(C=="#"&&d.peek()=="!")return d.skipToEnd(),u("meta","meta");if(C=="#"&&d.eatWhile(s))return u("variable","property");if(C=="<"&&d.match("!--")||C=="-"&&d.match("->")&&!/\S/.test(d.string.slice(0,d.start)))return d.skipToEnd(),u("comment","comment");if(l.test(C))return(C!=">"||!m.lexical||m.lexical.type!=">")&&(d.eat("=")?(C=="!"||C=="=")&&d.eat("="):/[<>*+\-|&?]/.test(C)&&(d.eat(C),C==">"&&d.eat(C))),C=="?"&&d.eat(".")?u("."):u("operator","operator",d.current());if(s.test(C)){d.eatWhile(s);var B=d.current();if(m.lastType!="."){if(o.propertyIsEnumerable(B)){var N=o[B];return u(N.type,N.style,B)}if(B=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",B)}return u("variable","variable",B)}}function g(d){return function(m,C){var B=!1,N;if(t&&m.peek()=="@"&&m.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(N=m.next())!=null&&!(N==d&&!B);)B=!B&&N=="\\";return B||(C.tokenize=p),u("string","string")}}function x(d,m){for(var C=!1,B;B=d.next();){if(B=="/"&&C){m.tokenize=p;break}C=B=="*"}return u("comment","comment")}function y(d,m){for(var C=!1,B;(B=d.next())!=null;){if(!C&&(B=="`"||B=="$"&&d.eat("{"))){m.tokenize=p;break}C=!C&&B=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function M(d,m){m.fatArrowAt&&(m.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var B=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));B&&(C=B.index)}for(var N=0,Q=!1,se=C-1;se>=0;--se){var Re=d.string.charAt(se),qe=v.indexOf(Re);if(qe>=0&&qe<3){if(!N){++se;break}if(--N==0){Re=="("&&(Q=!0);break}}else if(qe>=3&&qe<6)++N;else if(s.test(Re))Q=!0;else if(/["'\/`]/.test(Re))for(;;--se){if(se==0)return;var _i=d.string.charAt(se-1);if(_i==Re&&d.string.charAt(se-2)!="\\"){se--;break}}else if(Q&&!N){++se;break}}Q&&!N&&(m.fatArrowAt=se)}}var O={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function R(d,m,C,B,N,Q){this.indented=d,this.column=m,this.type=C,this.prev=N,this.info=Q,B!=null&&(this.align=B)}function F(d,m){for(var C=d.localVars;C;C=C.next)if(C.name==m)return!0;for(var B=d.context;B;B=B.prev)for(var C=B.vars;C;C=C.next)if(C.name==m)return!0}function q(d,m,C,B,N){var Q=d.cc;for(w.state=d,w.stream=N,w.marked=null,w.cc=Q,w.style=m,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var se=Q.length?Q.pop():i?te:ae;if(se(C,B)){for(;Q.length&&Q[Q.length-1].lex;)Q.pop()();return w.marked?w.marked:C=="variable"&&F(d,B)?"variableName.local":m}}}var w={state:null,column:null,marked:null,cc:null};function D(){for(var d=arguments.length-1;d>=0;d--)w.cc.push(arguments[d])}function b(){return D.apply(null,arguments),!0}function U(d,m){for(var C=m;C;C=C.next)if(C.name==d)return!0;return!1}function $(d){var m=w.state;if(w.marked="def",m.context){if(m.lexical.info=="var"&&m.context&&m.context.block){var C=G(d,m.context);if(C!=null){m.context=C;return}}else if(!U(d,m.localVars)){m.localVars=new T(d,m.localVars);return}}n.globalVars&&!U(d,m.globalVars)&&(m.globalVars=new T(d,m.globalVars))}function G(d,m){if(m)if(m.block){var C=G(d,m.prev);return C?C==m.prev?m:new k(C,m.vars,!0):null}else return U(d,m.vars)?m:new k(m.prev,new T(d,m.vars),!1);else return null}function K(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,m,C){this.prev=d,this.vars=m,this.block=C}function T(d,m){this.name=d,this.next=m}var A=new T("this",new T("arguments",null));function V(){w.state.context=new k(w.state.context,w.state.localVars,!1),w.state.localVars=A}function le(){w.state.context=new k(w.state.context,w.state.localVars,!0),w.state.localVars=null}V.lex=le.lex=!0;function we(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}we.lex=!0;function j(d,m){var C=function(){var B=w.state,N=B.indented;if(B.lexical.type=="stat")N=B.lexical.indented;else for(var Q=B.lexical;Q&&Q.type==")"&&Q.align;Q=Q.prev)N=Q.indented;B.lexical=new R(N,w.stream.column(),d,null,B.lexical,m)};return C.lex=!0,C}function W(){var d=w.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}W.lex=!0;function _(d){function m(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?D():b(m)}return m}function ae(d,m){return d=="var"?b(j("vardef",m),Is,_(";"),W):d=="keyword a"?b(j("form"),Es,ae,W):d=="keyword b"?b(j("form"),ae,W):d=="keyword d"?w.stream.match(/^\s*$/,!1)?b():b(j("stat"),ci,_(";"),W):d=="debugger"?b(_(";")):d=="{"?b(j("}"),le,Vn,W,we):d==";"?b():d=="if"?(w.state.lexical.info=="else"&&w.state.cc[w.state.cc.length-1]==W&&w.state.cc.pop()(),b(j("form"),Es,ae,W,sa)):d=="function"?b(Tt):d=="for"?b(j("form"),le,oa,ae,we,W):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form",d=="class"?d:m),aa,W)):d=="variable"?r&&m=="declare"?(w.marked="keyword",b(ae)):r&&(m=="module"||m=="enum"||m=="type")&&w.stream.match(/^\s*\w/,!1)?(w.marked="keyword",m=="enum"?b(fa):m=="type"?b(la,_("operator"),re,_(";")):b(j("form"),Xe,_("{"),j("}"),Vn,W,W)):r&&m=="namespace"?(w.marked="keyword",b(j("form"),te,ae,W)):r&&m=="abstract"?(w.marked="keyword",b(ae)):b(j("stat"),Vu):d=="switch"?b(j("form"),Es,_("{"),j("}","switch"),le,Vn,W,W,we):d=="case"?b(te,_(":")):d=="default"?b(_(":")):d=="catch"?b(j("form"),V,Ct,ae,W,we):d=="export"?b(j("stat"),Qu,W):d=="import"?b(j("stat"),ed,W):d=="async"?b(ae):m=="@"?b(te,ae):D(j("stat"),te,_(";"),W)}function Ct(d){if(d=="(")return b(_t,_(")"))}function te(d,m){return ea(d,m,!1)}function Te(d,m){return ea(d,m,!0)}function Es(d){return d!="("?D():b(j(")"),ci,_(")"),W)}function ea(d,m,C){if(w.state.fatArrowAt==w.stream.start){var B=C?ia:ta;if(d=="(")return b(V,j(")"),Se(_t,")"),W,_("=>"),B,we);if(d=="variable")return D(V,Xe,_("=>"),B,we)}var N=C?fi:$t;return O.hasOwnProperty(d)?b(N):d=="function"?b(Tt,N):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form"),Zu,W)):d=="keyword c"||d=="async"?b(C?Te:te):d=="("?b(j(")"),ci,_(")"),W,N):d=="operator"||d=="spread"?b(C?Te:te):d=="["?b(j("]"),id,W,N):d=="{"?$i(Hn,"}",null,N):d=="quasi"?D(Fn,N):d=="new"?b(zu(C)):b()}function ci(d){return d.match(/[;\}\)\],]/)?D():D(te)}function $t(d,m){return d==","?b(ci):fi(d,m,!1)}function fi(d,m,C){var B=C==!1?$t:fi,N=C==!1?te:Te;if(d=="=>")return b(V,C?ia:ta,we);if(d=="operator")return/\+\+|--/.test(m)||r&&m=="!"?b(B):r&&m=="<"&&w.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Se(re,">"),W,B):m=="?"?b(te,_(":"),N):b(N);if(d=="quasi")return D(Fn,B);if(d!=";"){if(d=="(")return $i(Te,")","call",B);if(d==".")return b(Wu,B);if(d=="[")return b(j("]"),ci,_("]"),W,B);if(r&&m=="as")return w.marked="keyword",b(re,B);if(d=="regexp")return w.state.lastType=w.marked="operator",w.stream.backUp(w.stream.pos-w.stream.start-1),b(N)}}function Fn(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Fn):b(ci,Nu)}function Nu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Fn)}function ta(d){return M(w.stream,w.state),D(d=="{"?ae:te)}function ia(d){return M(w.stream,w.state),D(d=="{"?ae:Te)}function zu(d){return function(m){return m=="."?b(d?Hu:Fu):m=="variable"&&r?b(Gu,d?fi:$t):D(d?Te:te)}}function Fu(d,m){if(m=="target")return w.marked="keyword",b($t)}function Hu(d,m){if(m=="target")return w.marked="keyword",b(fi)}function Vu(d){return d==":"?b(W,ae):D($t,_(";"),W)}function Wu(d){if(d=="variable")return w.marked="property",b()}function Hn(d,m){if(d=="async")return w.marked="property",b(Hn);if(d=="variable"||w.style=="keyword"){if(w.marked="property",m=="get"||m=="set")return b(ju);var C;return r&&w.state.fatArrowAt==w.stream.start&&(C=w.stream.match(/^\s*:\s*/,!1))&&(w.state.fatArrowAt=w.stream.pos+C[0].length),b(Kt)}else{if(d=="number"||d=="string")return w.marked=t?"property":w.style+" property",b(Kt);if(d=="jsonld-keyword")return b(Kt);if(r&&K(m))return w.marked="keyword",b(Hn);if(d=="[")return b(te,ui,_("]"),Kt);if(d=="spread")return b(Te,Kt);if(m=="*")return w.marked="keyword",b(Hn);if(d==":")return D(Kt)}}function ju(d){return d!="variable"?D(Kt):(w.marked="property",b(Tt))}function Kt(d){if(d==":")return b(Te);if(d=="(")return D(Tt)}function Se(d,m,C){function B(N,Q){if(C?C.indexOf(N)>-1:N==","){var se=w.state.lexical;return se.info=="call"&&(se.pos=(se.pos||0)+1),b(function(Re,qe){return Re==m||qe==m?D():D(d)},B)}return N==m||Q==m?b():C&&C.indexOf(";")>-1?D(d):b(_(m))}return function(N,Q){return N==m||Q==m?b():D(d,B)}}function $i(d,m,C){for(var B=3;B<arguments.length;B++)w.cc.push(arguments[B]);return b(j(m,C),Se(d,m),W)}function Vn(d){return d=="}"?b():D(ae,Vn)}function ui(d,m){if(r){if(d==":")return b(re);if(m=="?")return b(ui)}}function qu(d,m){if(r&&(d==":"||m=="in"))return b(re)}function na(d){if(r&&d==":")return w.stream.match(/^\s*\w+\s+is\b/,!1)?b(te,$u,re):b(re)}function $u(d,m){if(m=="is")return w.marked="keyword",b()}function re(d,m){if(m=="keyof"||m=="typeof"||m=="infer"||m=="readonly")return w.marked="keyword",b(m=="typeof"?Te:re);if(d=="variable"||m=="void")return w.marked="type",b(bt);if(m=="|"||m=="&")return b(re);if(d=="string"||d=="number"||d=="atom")return b(bt);if(d=="[")return b(j("]"),Se(re,"]",","),W,bt);if(d=="{")return b(j("}"),Bs,W,bt);if(d=="(")return b(Se(Rs,")"),Ku,bt);if(d=="<")return b(Se(re,">"),re);if(d=="quasi")return D(Ps,bt)}function Ku(d){if(d=="=>")return b(re)}function Bs(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(Bs):D(Ki,Bs)}function Ki(d,m){if(d=="variable"||w.style=="keyword")return w.marked="property",b(Ki);if(m=="?"||d=="number"||d=="string")return b(Ki);if(d==":")return b(re);if(d=="[")return b(_("variable"),qu,_("]"),Ki);if(d=="(")return D(pi,Ki);if(!d.match(/[;\}\)\],]/))return b()}function Ps(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Ps):b(re,_u)}function _u(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Ps)}function Rs(d,m){return d=="variable"&&w.stream.match(/^\s*[?:]/,!1)||m=="?"?b(Rs):d==":"?b(re):d=="spread"?b(Rs):D(re)}function bt(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt);if(m=="|"||d=="."||m=="&")return b(re);if(d=="[")return b(re,_("]"),bt);if(m=="extends"||m=="implements")return w.marked="keyword",b(re);if(m=="?")return b(re,_(":"),re)}function Gu(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt)}function Wn(){return D(re,Uu)}function Uu(d,m){if(m=="=")return b(re)}function Is(d,m){return m=="enum"?(w.marked="keyword",b(fa)):D(Xe,ui,At,Ju)}function Xe(d,m){if(r&&K(m))return w.marked="keyword",b(Xe);if(d=="variable")return $(m),b();if(d=="spread")return b(Xe);if(d=="[")return $i(Yu,"]");if(d=="{")return $i(ra,"}")}function ra(d,m){return d=="variable"&&!w.stream.match(/^\s*:/,!1)?($(m),b(At)):(d=="variable"&&(w.marked="property"),d=="spread"?b(Xe):d=="}"?D():d=="["?b(te,_("]"),_(":"),ra):b(_(":"),Xe,At))}function Yu(){return D(Xe,At)}function At(d,m){if(m=="=")return b(Te)}function Ju(d){if(d==",")return b(Is)}function sa(d,m){if(d=="keyword b"&&m=="else")return b(j("form","else"),ae,W)}function oa(d,m){if(m=="await")return b(oa);if(d=="(")return b(j(")"),Xu,W)}function Xu(d){return d=="var"?b(Is,di):d=="variable"?b(di):D(di)}function di(d,m){return d==")"?b():d==";"?b(di):m=="in"||m=="of"?(w.marked="keyword",b(te,di)):D(te,di)}function Tt(d,m){if(m=="*")return w.marked="keyword",b(Tt);if(d=="variable")return $(m),b(Tt);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,ae,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,Tt)}function pi(d,m){if(m=="*")return w.marked="keyword",b(pi);if(d=="variable")return $(m),b(pi);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,pi)}function la(d,m){if(d=="keyword"||d=="variable")return w.marked="type",b(la);if(m=="<")return b(j(">"),Se(Wn,">"),W)}function _t(d,m){return m=="@"&&b(te,_t),d=="spread"?b(_t):r&&K(m)?(w.marked="keyword",b(_t)):r&&d=="this"?b(ui,At):D(Xe,ui,At)}function Zu(d,m){return d=="variable"?aa(d,m):jn(d,m)}function aa(d,m){if(d=="variable")return $(m),b(jn)}function jn(d,m){if(m=="<")return b(j(">"),Se(Wn,">"),W,jn);if(m=="extends"||m=="implements"||r&&d==",")return m=="implements"&&(w.marked="keyword"),b(r?re:te,jn);if(d=="{")return b(j("}"),kt,W)}function kt(d,m){if(d=="async"||d=="variable"&&(m=="static"||m=="get"||m=="set"||r&&K(m))&&w.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return w.marked="keyword",b(kt);if(d=="variable"||w.style=="keyword")return w.marked="property",b(qn,kt);if(d=="number"||d=="string")return b(qn,kt);if(d=="[")return b(te,ui,_("]"),qn,kt);if(m=="*")return w.marked="keyword",b(kt);if(r&&d=="(")return D(pi,kt);if(d==";"||d==",")return b(kt);if(d=="}")return b();if(m=="@")return b(te,kt)}function qn(d,m){if(m=="!"||m=="?")return b(qn);if(d==":")return b(re,At);if(m=="=")return b(Te);var C=w.state.lexical.prev,B=C&&C.info=="interface";return D(B?pi:Tt)}function Qu(d,m){return m=="*"?(w.marked="keyword",b(Ns,_(";"))):m=="default"?(w.marked="keyword",b(te,_(";"))):d=="{"?b(Se(ha,"}"),Ns,_(";")):D(ae)}function ha(d,m){if(m=="as")return w.marked="keyword",b(_("variable"));if(d=="variable")return D(Te,ha)}function ed(d){return d=="string"?b():d=="("?D(te):d=="."?D($t):D($n,ca,Ns)}function $n(d,m){return d=="{"?$i($n,"}"):(d=="variable"&&$(m),m=="*"&&(w.marked="keyword"),b(td))}function ca(d){if(d==",")return b($n,ca)}function td(d,m){if(m=="as")return w.marked="keyword",b($n)}function Ns(d,m){if(m=="from")return w.marked="keyword",b(te)}function id(d){return d=="]"?b():D(Se(Te,"]"))}function fa(){return D(j("form"),Xe,_("{"),j("}"),Se(nd,"}"),W,W)}function nd(){return D(Xe,At)}function rd(d,m){return d.lastType=="operator"||d.lastType==","||l.test(m.charAt(0))||/[,.]/.test(m.charAt(0))}function sd(d,m,C){return m.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(m.lastType)||m.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var m={tokenize:p,lastType:"sof",cc:[],lexical:new R(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(m.globalVars=n.globalVars),m},token:function(d,m){if(d.sol()&&(m.lexical.hasOwnProperty("align")||(m.lexical.align=!1),m.indented=d.indentation(),M(d,m)),m.tokenize!=x&&d.eatSpace())return null;var C=m.tokenize(d,m);return c=="comment"?C:(m.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,q(m,C,c,f,d))},indent:function(d,m,C){if(d.tokenize==x||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var B=m&&m.charAt(0),N=d.lexical,Q;if(!/^\s*else\b/.test(m))for(var se=d.cc.length-1;se>=0;--se){var Re=d.cc[se];if(Re==W)N=N.prev;else if(Re!=sa&&Re!=we)break}for(;(N.type=="stat"||N.type=="form")&&(B=="}"||(Q=d.cc[d.cc.length-1])&&(Q==$t||Q==fi)&&!/^[,\.=+\-*:?[\(]/.test(m));)N=N.prev;e&&N.type==")"&&N.prev.type=="stat"&&(N=N.prev);var qe=N.type,_i=B==qe;return qe=="vardef"?N.indented+(d.lastType=="operator"||d.lastType==","?N.info.length+1:0):qe=="form"&&B=="{"?N.indented:qe=="form"?N.indented+C.unit:qe=="stat"?N.indented+(rd(d,m)?e||C.unit:0):N.info=="switch"&&!_i&&n.doubleIndentSwitch!=!1?N.indented+(/^(?:case|default)\b/.test(m)?C.unit:2*C.unit):N.align?N.column+(_i?0:1):N.indented+(_i?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var Lu=Ts({name:"javascript"}),nk=Ts({name:"json",json:!0}),rk=Ts({name:"json",jsonld:!0}),sk=Ts({name:"typescript",typescript:!0});function K0(n){return new RegExp("^(?:"+n.join("|")+")","i")}function Ms(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var _0=Ms(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),G0=Ms(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),U0=Ms(["function","if","repeat","do","\\(","{"]),Y0=Ms(["end","until","\\)","}"]),J0=K0(["end","until","\\)","}","else","elseif"]);function Du(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function Xl(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=Ou(Du(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=X0(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=Ou(Du(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function Ou(n,e){return function(t,i){for(var r=null,s;(s=t.next())!=null;)if(r==null)s=="]"&&(r=0);else if(s=="=")++r;else if(s=="]"&&r==n){i.cur=Xl;break}else r=null;return e}}function X0(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=Xl),"string"}}var Eu={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:Xl}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(G0.test(i)?t="keyword":_0.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(U0.test(i)?++e.indentDepth:Y0.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=J0.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var Bu=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},Pu=document.createElement("span"),Z0=n=>(Pu.innerHTML=n,[...Pu.textContent].length===1),Ls=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[],this.tokenTable={...S.tokenTable};for(let t of Object.keys(e.tags))this.addTag(t)}get fileRegex(){let e=Object.entries(this.config.nsid).filter(([,t])=>t===6).map(([t])=>t).join("|");return new RegExp(`^\\s*(?:${e})\\s*:\\s*`,"iu")}addTag(e,t){var i,r;(i=this.tokenTable)[r=`mw-tag-${e}`]||(i[r]=Pe.define(t))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}${e==="templateName"?" cm-mw-pagename":""}`}))}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&Z0(`&${i[0]}`)?S.tags.htmlEntity:t}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold?S.tags.strong:""} ${this.isItalic?S.tags.em:""}`,t,i)}makeLocalStyle(e,t,i){let r="";switch(t.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(t.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}return t.nLink>0&&(r+="-link"),i&&t[i]--,(r&&`mw${r}-ground `)+e}inBlock(e,t,i=!0){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalStyle(e,s))}eatEnd(e){return(t,i)=>(t.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(e,i))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalStyle(S.tags.error,r))}inSectionHeader(e){return(t,i)=>t.match(/^[^&<[{~']+/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatEnd(S.tags.sectionHeader)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock(S.tags.sectionHeader,"<!--",!1)),this.makeLocalStyle(S.tags.section,i)):this.eatWikiText(S.tags.section)(t,i)}inVariable(e,t){return e.match(/^[^{}|]+/u)?this.makeLocalStyle(S.tags.templateVariableName,t):e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalStyle(S.tags.templateVariableDelimiter,t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,t)):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalStyle(S.tags.templateVariableBracket,t)):(e.next(),this.makeLocalStyle(S.tags.templateVariableName,t))}inVariableDefault(e){let t=S.tags[e?"templateVariable":"comment"];return(i,r)=>i.match(/^[^{}[<&~|]+/u)?this.makeStyle(t,r):i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,r)):i.eat("|")?(r.tokenize=this.inVariableDefault(!1),this.makeLocalStyle(S.tags.templateVariableDelimiter,r)):this.eatWikiText(t)(i,r)}inParserFunctionName(e,t){return e.match(/^[^:}{~|<>[\]]+/u)?this.makeLocalStyle(S.tags.parserFunctionName,t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(S.tags.parserFunctionDelimiter,t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.match(/^[^|}{[<&~]+/u)?this.makeLocalStyle(S.tags.parserFunction,t):e.eat("|")?this.makeLocalStyle(S.tags.parserFunctionDelimiter,t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.parserFunction)(e,t)}inTemplatePageName(e){return(t,i)=>t.match(/^\s*\|\s*/u)?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match(/^\s*\}\}/u)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):t.match(/^\s*<!--.*?-->/u)?this.makeLocalStyle(S.tags.comment,i):e&&t.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):t.match(/^\s*[^\s|&~{}<>[\]]+/u)?(i.tokenize=this.inTemplatePageName(!0),this.makeLocalStyle(S.tags.templateName,i)):t.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalStyle(S.tags.error,i):t.eatSpace()?this.makeLocalStyle(S.tags.templateName,i):this.eatWikiText(S.tags.templateName)(t,i)}inTemplateArgument(e){return(t,i)=>e&&t.eatWhile(/[^=|}{[<&~]/u)?t.eat("=")?(i.tokenize=this.inTemplateArgument(!1),this.makeLocalStyle(S.tags.templateArgumentName,i)):this.makeLocalStyle(S.tags.template,i):t.eatWhile(/[^|}{[<&~]/u)?this.makeLocalStyle(S.tags.template,i):t.eat("|")?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):this.eatWikiText(S.tags.template)(t,i)}eatExternalLinkProtocol(e){return(t,i)=>{for(let r=0;r<e;r++)t.next();return t.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(S.tags.extLinkProtocol,i)}}inExternalLink(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.match(/^\s*\]/u)?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.eatSpace()?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):e.match(/^[^\s\]{&~']+/u)?(e.peek()==="'"&&(e.match("''",!1)?t.tokenize=this.inExternalLinkText.bind(this):e.next()),this.makeLocalStyle(S.tags.extLink,t)):this.eatWikiText(S.tags.extLink)(e,t)}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.match(/^[^'\]{&~<]+/u)?this.makeStyle(S.tags.extLinkText,t):this.eatWikiText(S.tags.extLinkText)(e,t)}inLink(e){return(t,i)=>{if(t.sol())return i.nLink--,i.tokenize=i.stack.pop(),"";if(t.match(/^\s*#\s*/u))return i.tokenize=this.inLinkToSection(e),this.makeStyle(S.tags.link,i);if(t.match(/^\s*\|\s*/u))return i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i);if(t.match(/^\s*\]\]/u))return i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink");if(t.match(/^(?:[<>[\]}]|\{(?!\{))/u))return this.makeStyle(S.tags.error,i);let r=`${S.tags.linkPageName} ${S.tags.pageName}`;return t.match(/^[^#|[\]&~{}<>]+/u)?this.makeStyle(r,i):this.eatWikiText(r)(t,i)}}inLinkToSection(e){return(t,i)=>t.sol()?(i.nLink--,i.tokenize=i.stack.pop(),""):t.match(/^[^|\]&~{}]+/u)?this.makeStyle(S.tags.linkToSection,i):t.eat("|")?(i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i)):t.match("]]")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink")):this.eatWikiText(S.tags.linkToSection)(t,i)}inLinkText(e){let t,i;return(r,s)=>{let o=`${S.tags.linkText} ${t?S.tags.strong:""} ${i?S.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.tokenize=s.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,s,"nLink"));if(e&&r.eat("|"))return this.makeLocalStyle(S.tags.linkDelimiter,s);if(r.match("'''"))return t=!t,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);if(r.match("''"))return i=!i,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);let l=r.match(e?/^(?:[^'\]{&~<|[]|\[(?!\[))+/u:/^[^'\]{&~<]+/u);return l&&l[0].includes("[")&&(s.lbrack=!0),l?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}eatTagName(e,t,i){return(r,s)=>{let o="";for(let l=0;l<e;l++)o+=r.next();return r.eatSpace(),o=o.toLowerCase(),i?(s.tokenize=t?this.inChar(">",S.tags.htmlTagBracket):this.inHtmlTagAttribute(o),this.makeLocalStyle(S.tags.htmlTagName,s)):(s.tokenize=t?this.inChar(">",S.tags.extTagBracket):this.inExtTagAttribute(o),this.makeLocalStyle(S.tags.extTagName,s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^[^>/<{]+/u)?this.makeLocalStyle(S.tags.htmlTagAttribute,i):t.match(/^\/?>/u)?(S.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.push(e),i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.htmlTagBracket,i)):this.eatWikiText(S.tags.htmlTagAttribute)(t,i)}eatNowiki(){return e=>e.match(/^[^&]+/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^[^>/]+/u)?this.makeLocalStyle(S.tags.extTagAttribute,i):t.eat(">")?(i.extName=e,e==="nowiki"||e==="pre"?(i.extMode={startState:()=>({}),token:this.eatNowiki()},i.extState={}):e in this.config.tagModes&&(i.extMode=this[this.config.tagModes[e]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(e),this.makeLocalStyle(S.tags.extTagBracket,i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.extTagBracket,i)):this.eatWikiText(S.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu"),o=s.exec(r?t.string.slice(r):t.string),l=!1;if(o){if(o.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);let a=o.index+r;l=t.string,t.string=l.slice(0,a)}return i.stack.push(i.tokenize),i.tokenize=this.inExtTokens(l),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0,!1),this.makeLocalStyle(S.tags.extTagBracket,i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=S.tags.extTag,t.skipToEnd()):r=`mw-tag-${i.extName} ${i.extMode.token(t,i.extState)}`,t.eol()&&(e!==!1&&(t.string=e),i.tokenize=i.stack.pop()),r}}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):this.eatWikiText(S.tags.tableDefinition)(e,t)}inTableCaption(e,t){return e.sol()&&e.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1)?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):e.match(/^\s*(?:\||\{\{\s*!\s*\}\}){2}/u,!1)?(t.tokenize=this.inTableRow(!1,!1),""):this.eatWikiText(S.tags.tableCaption)(e,t)}inTable(e,t){if(e.sol()){if(e.eatSpace(),e.match(/^(?:\||\{\{\s*!\s*\}\})/u))return e.match(/^-+\s*/u)?(t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("+")?(e.eatSpace(),t.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.tableBracket,t)):(e.eatSpace(),t.tokenize=this.inTableRow(!0,!1),this.makeLocalStyle(S.tags.tableDelimiter,t));if(e.eat("!"))return e.eatSpace(),t.tokenize=this.inTableRow(!0,!0),this.makeLocalStyle(S.tags.tableDelimiter,t)}return this.eatWikiText("")(e,t)}inTableRow(e,t){return(i,r)=>{if(i.sol()){if(i.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return r.tokenize=this.inTable.bind(this),this.inTable(i,r)}else{if(i.match(/^[^'|{[<&~!]+/u))return this.makeStyle(t?S.tags.strong:"",r);if(i.match(/^(?:\||\{\{\s*!\s*\}\}){2}/u)||t&&i.match("!!")||e&&i.match(/^(?:\||\{\{\s*!\s*\}\})/u))return this.isBold=!1,this.isItalic=!1,e&&(r.tokenize=this.inTableRow(!1,t)),this.makeLocalStyle(S.tags.tableDelimiter,r)}return this.eatWikiText(t?S.tags.strong:"")(i,r)}}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,t)}inFreeExternalLink(e,t){if(!e.eol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u);if(t.lpar||(t.lpar=i[0].includes("(")),e.peek()==="~"){if(e.match(/^~{1,2}(?!~)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="{"){if(e.match(/^\{(?!\{)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="'"){if(e.match(/^'(?!')/u))return this.makeStyle(S.tags.freeExtLink,t)}else{if(t.lpar&&e.peek()===")")return e.next(),this.makeStyle(S.tags.freeExtLink,t);if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeStyle(S.tags.freeExtLink,t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeStyle(S.tags.freeExtLink,t)}eatWikiText(e){return(t,i)=>{let r;if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return i.stack.push(i.tokenize),i.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return S.tags.hr;break;case"=":{let o=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->.*\S).*)?)$/u);if(o)return t.backUp(o[2].length),i.stack.push(i.tokenize),i.tokenize=this.inSectionHeader(o[3].length),this.makeLocalStyle(`${S.tags.sectionHeader} ${S.tags[`sectionHeader${o[1].length+1}`]}`,i);break}case"*":case"#":case";":return t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case":":return t.match(/^:*(?:\{\||\{{3}\s*!\s*\}\})/u,!1)&&(i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this)),t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case" ":{let o=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(o){if(o[1])return i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this),this.makeLocalStyle(S.tags.list,i);t.eat("{")}else return S.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return i.stack.push(i.tokenize),i.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,i);break;default:}}else r=t.next();switch(r){case"&":return this.makeStyle(this.eatHtmlEntity(t,e),i);case"'":if(t.match(/^'*(?='{5})/u)||t.match(/^'''(?!')/u,!1))break;if(t.match("''"))return this.firstSingleLetterWord||t.match("''",!1)||this.prepareItalicForCorrection(t),this.isBold=!this.isBold,this.makeLocalStyle(S.tags.apostrophesBold,i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(S.tags.apostrophesItalic,i);break;case"[":if(t.eat("[")){if(t.eatSpace(),/[^\]|[]/u.test(t.peek()||""))return i.nLink++,i.stack.push(i.tokenize),i.lbrack=!1,i.tokenize=this.inLink(!!t.match(this.fileRegex,!1)),this.makeLocalStyle(S.tags.linkBracket,i)}else{let o=t.match(this.urlProtocols,!1);if(o)return i.nLink++,i.stack.push(i.tokenize),i.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(S.tags.extLinkBracket,i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/u))return t.eatSpace(),i.stack.push(i.tokenize),i.tokenize=this.inVariable.bind(this),this.makeLocalStyle(S.tags.templateVariableBracket,i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i);let o=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return o&&(o[2]===":"||o[4]===void 0||o[3]==="}}")&&(o[1].toLowerCase()in this.config.functionSynonyms[0]||o[1]in this.config.functionSynonyms[1])?(i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i)):(i.nTemplate++,i.stack.push(i.tokenize),i.tokenize=this.inTemplatePageName(!1),this.makeLocalStyle(S.tags.templateBracket,i))}break;case"<":{if(t.match("!--"))return i.stack.push(i.tokenize),i.tokenize=this.inBlock(S.tags.comment,"-->"),this.makeLocalStyle(S.tags.comment,i);let o=!!t.eat("/"),l=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/u);if(l){let a=l[0].toLowerCase();if(a in this.config.tags)return o?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!1),this.makeLocalStyle(S.tags.extTagBracket,i));if(S.permittedHtmlTags.has(a))return o&&a!==i.inHtmlTag.pop()?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):o&&S.implicitlyClosedHtmlTags.has(a)?this.makeLocalStyle(S.tags.error,i):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!0),this.makeLocalStyle(S.tags.htmlTagBracket,i));t.backUp(a.length)}break}case"~":if(t.match(/^~{2,4}/u))return S.tags.signature;break;case"_":{let o=1;for(;t.eat("_");)o++;if(o>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(o===2){let l=t.match(/^\w+?__/u);if(l)return`__${l[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${l[0]}`in this.config.doubleUnderscore[1]?S.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}default:if(/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//")))return i.stack.push(i.tokenize),i.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(e,i);break}return t.match(/^[^\s_>}[\]<{'|&:~=]+/u),this.makeStyle(e,i)}}prepareItalicForCorrection(e){let t=e.pos,i=e.string.slice(0,t-3),r=i.slice(-1),s=i.slice(-2,-1);if(r===" "){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=t}else if(s===" ")this.firstSingleLetterWord=t;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=t}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,lpar:!1,lbrack:!1}),copyState:e=>{let t=Bu(e);return e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i,r=null,s,o,l=[],a=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),e.pos=s.pos,s.style;e.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do if(i=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==r&&(r=o,l.length>0&&(a.push(...l),l=[])),l.push({pos:e.pos,style:i,state:(t.extMode&&t.extMode.copyState||Bu)(t)});else return this.oldStyle=i,i;while(!e.eol());if(this.isBold&&this.isItalic)if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,a.length>0)a[a.length-1].pos++,this.oldTokens=a;else return e.pos=l[0].pos-2,this.oldStyle||"";else this.oldTokens=[...a,...l];return s=this.oldTokens.shift(),e.pos=s.pos,s.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Nn))Object.defineProperty(Ls.prototype,n,{get(){return e}});var Zl=n=>{let e=new Ls(n),t=e.mediawiki,i=Ri.define(t),r=Kr(Pi.define(e.getTagStyles()));return new Bi(i,r)},Ru=n=>Zl({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"}});var Ql={plain:()=>[],mediawiki:Zl,html:Ru};for(let[n,e]of Object.entries(Nn))Ql[n]=()=>new Bi(Ri.define(e));var Ds={},Q0={highlightSpecialChars:[bc,{}],highlightActiveLine:[kc,{}],highlightWhitespace:[Ac,{}],highlightTrailingWhitespace:[Tc,{}],bracketMatching:[Zc,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[mu,{}]},Os=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`https://testingcf.jsdelivr.net/${n}`,i.onload=()=>{t()},document.head.append(i)}),zn,Wi,qt,ji,qi,me,Iu=class{constructor(e,t="plain",i){Gt(this,zn,void 0);Gt(this,Wi,void 0);Gt(this,qt,void 0);Gt(this,ji,void 0);Gt(this,qi,void 0);Gt(this,me,void 0);Ut(this,zn,e),this.lang=t,Ut(this,Wi,new xt),Ut(this,qt,new xt),Ut(this,ji,new xt),Ut(this,qi,new xt);let r,s=[ee(this,Wi).of(Ql[t](i)),ee(this,qt).of([]),ee(this,ji).of([]),ee(this,qi).of(Ht.of(" ")),Kr(Uc),z.contentAttributes.of({accesskey:e.accessKey,dir:e.dir,lang:e.lang}),Sc(),z.lineWrapping,pf(),_c(),Pr.of([...qf,...kf,...Qf]),z.updateListener.of(({state:{doc:p},docChanged:g})=>{g&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=p.toString()},400))})];Ut(this,me,new z({extensions:s,doc:e.value}));let{offsetHeight:o,selectionStart:l,selectionEnd:a,scrollTop:h}=e,{fontSize:c,lineHeight:f}=getComputedStyle(e),u=document.activeElement===e;e.parentNode.insertBefore(ee(this,me).dom,e),ee(this,me).dom.style.minHeight="2em",ee(this,me).dom.style.height=`${o}px`,ee(this,me).dom.style.fontSize=c,ee(this,me).scrollDOM.style.lineHeight=f,ee(this,me).requestMeasure(),ee(this,me).dispatch({selection:{anchor:l,head:a}}),e.style.display="none",u&&ee(this,me).focus(),window.requestAnimationFrame(()=>{ee(this,me).scrollDOM.scrollTop=h})}get textarea(){return ee(this,zn)}get view(){return ee(this,me)}setLanguage(e="plain",t){var i;ee(this,me).dispatch({effects:[ee(this,Wi).reconfigure(Ql[e](t)),ee(this,qt).reconfigure((i=Ds[e])!=null?i:[])]}),this.lang=e,(Ds[e]?Kl:In)(ee(this,me))}lint(e){let{lang:t}=this,i=e?[su(r=>e(r.state.doc)),fu()]:[];e?Ds[t]=i:delete Ds[t],ee(this,me).dispatch({effects:[ee(this,qt).reconfigure(i)]}),(e?Kl:In)(ee(this,me))}update(){let e=ee(this,qt).get(ee(this,me).state);if(e.length>0){let t=ee(this,me).plugin(e[0][1]);t.set=!0,t.force()}}prefer(e){let{lang:t}=this;ee(this,me).dispatch({effects:[ee(this,ji).reconfigure(e.map(i=>{let[r,s]=Q0[i];return r(s[t])}))]})}setIndent(e){ee(this,me).dispatch({effects:[ee(this,qi).reconfigure(Ht.of(e))]})}async getLinter(){switch(this.lang){case"html":case"mediawiki":{await Os("combine/npm/wikiparser-node@1.3.0-b/extensions/dist/base.min.js,npm/wikiparser-node@1.3.0-b/extensions/dist/lint.min.js","wikiparse");let t=new wikiparse.Linter;return i=>t.codemirror(i.toString())}case"javascript":{await Os("npm/eslint-linter-browserify","eslint");let e=new eslint.Linter,t={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{}};for(let[i,{meta:r}]of e.getRules())r!=null&&r.docs.recommended&&(t.rules[i]=2);return i=>e.verify(i.toString(),t).map(({message:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>{let c=i.line(o).from+l-1;return{message:r,severity:s===1?"warning":"error",from:c,to:a===void 0?c+1:i.line(a).from+h-1}})}case"css":{await Os("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let e={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0}};return async t=>{let{results:i}=await stylelint.lint({code:t.toString(),config:e});return i.flatMap(({warnings:r})=>r).map(({text:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>({message:r,severity:s,from:t.line(o).from+l-1,to:a===void 0?t.line(o).to:t.line(a).from+h-1}))}}case"lua":return await Os("npm/luaparse","luaparse"),e=>{try{luaparse.parse(e.toString())}catch(t){if(t instanceof luaparse.SyntaxError)return[{message:t.message,severity:"error",from:t.index,to:t.index}]}return[]};default:return()=>[]}}};zn=new WeakMap,Wi=new WeakMap,qt=new WeakMap,ji=new WeakMap,qi=new WeakMap,me=new WeakMap;export{Iu as CodeMirror6};
|
|
12
|
+
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new jr(t,e?e.state.tabSize:4,e?Ft(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=ef(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=de.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Ym,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new de(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new de(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function ef(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var vl=Object.create(null),Dn=[Ee.none],Ym=new Nr(Dn),Wc=[],jc=Object.create(null),tf=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tf[n]=nf(vl,e);var qr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),tf)}resolve(e){return e?this.table[e]||(this.table[e]=nf(this.extra,e)):0}},Jm=new qr(vl);function dl(n,e){Wc.indexOf(n)>-1||(Wc.push(n),console.warn(e))}function nf(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||P[h];c?typeof c=="function"?a.length?a=a.map(c):dl(h,`Modifier ${h} used at start of tag`):a.length?dl(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:dl(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=jc[r];if(s)return s.id;let o=jc[r]=Ee.define({id:Dn.length,name:i,props:[Rc({[i]:t})]});return Dn.push(o),o.id}function Xm(n){let e=Ee.define({id:Dn.length,name:"Document",props:[Oi.add(()=>n)],top:!0});return Dn.push(e),e}var Zm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Dl(n.state,t.from);return i.line?Qm(n):i.block?tg(n):!1};function Ll(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var Qm=Ll(rg,0);var eg=Ll(ff,0);var tg=Ll((n,e)=>ff(n,e,ng(e)),0);function Dl(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var On=50;function ig(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-On,i),o=n.sliceDoc(r,r+On),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*On?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+On),f=n.sliceDoc(r-On,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(g,g+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function ng(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function ff(n,e,t=e.selection.ranges){let i=t.map(s=>Dl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>ig(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function rg(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,a=1e9,h=Dl(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,p=u==f.length,g=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:g,token:h,indent:u,empty:p,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var Cl=Ne.define(),sg=Ne.define(),og=I.define(),uf=I.define({combine(n){return ze(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),df=pe.define({create(){return si.empty},update(n,e){let t=e.state.facet(uf),i=e.annotation(Cl);if(i){let a=rt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Gr(c,c.length,t.minDepth,a):c=bf(c,e.startState.selection),new si(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(sg);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=rt.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new si(n.done.map(rt.fromJSON),n.undone.map(rt.fromJSON))}});function pf(n={}){return[df,uf.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?mf:e.inputType=="historyRedo"?Al:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ur(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(df,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var mf=Ur(0,!1),Al=Ur(1,!1),lg=Ur(0,!0),ag=Ur(1,!0);var rt=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&De.fromJSON(e.changes),[],e.mapped&&yt.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Ue;for(let r of e.startState.facet(og)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ue)}static selection(e){return new n(void 0,Ue,void 0,void 0,e)}};function Gr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function hg(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function cg(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function gf(n,e){return n.length?e.length?n.concat(e):n:e}var Ue=[],fg=200;function bf(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-fg));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Gr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[rt.selection([e])]}function ug(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Sl(n,e){if(!n.length)return n;let t=n.length,i=Ue;for(;t;){let r=dg(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[rt.selection(i)]:Ue}function dg(n,e,t){let i=gf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ue,t);if(!n.changes)return rt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new rt(r,J.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var pg=/^(input\.type|delete)($|\.)/,si=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||pg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,hg(l.changes,e.changes))||i=="input.type.compose")?o=Gr(o,o.length-1,r.minDepth,new rt(e.changes.compose(l.changes),gf(e.effects,l.effects),l.mapped,l.startSelection,Ue)):o=Gr(o,o.length,r.minDepth,e),new n(o,Ue,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ue;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&cg(s[s.length-1],e)?this:new n(bf(this.done,e),this.undone,t,i)}addMapping(e){return new n(Sl(this.done,e),Sl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Cl.of({side:e,rest:ug(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ue:r.slice(0,r.length-1);return s.mapped&&(l=Sl(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Cl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};si.empty=new si(Ue,Ue);var kf=[{key:"Mod-z",run:mf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Al,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Al,preventDefault:!0},{key:"Mod-u",run:lg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ag,preventDefault:!0}];function Ni(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function mt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function st({state:n,dispatch:e},t){let i=Ni(n.selection,t);return i.eq(n.selection)?!1:(e(mt(n,i)),!0)}function Yr(n,e){return L.cursor(e?n.to:n.from)}function yf(n,e){return st(n,t=>t.empty?n.moveByChar(t,e):Yr(t,e))}function Le(n){return n.textDirectionAt(n.state.selection.main.head)==ge.LTR}var wf=n=>yf(n,!Le(n)),xf=n=>yf(n,Le(n));function vf(n,e){return st(n,t=>t.empty?n.moveByGroup(t,e):Yr(t,e))}var mg=n=>vf(n,!Le(n)),gg=n=>vf(n,Le(n));var Pb=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bg(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jr(n,e,t){let i=Be(n).resolveInner(e.head),r=t?X.closedBy:X.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;bg(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?nt(n,i.from,1):nt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var kg=n=>st(n,e=>Jr(n.state,e,!Le(n))),yg=n=>st(n,e=>Jr(n.state,e,Le(n)));function Sf(n,e){return st(n,t=>{if(!t.empty)return Yr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Cf=n=>Sf(n,!1),Af=n=>Sf(n,!0);function Tf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Mf(n,e){let t=Tf(n),{state:i}=n,r=Ni(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Yr(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(mt(i,r),{effects:s}),!0}var rf=n=>Mf(n,!1),Tl=n=>Mf(n,!0);function Vt(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var wg=n=>st(n,e=>Vt(n,e,!0)),xg=n=>st(n,e=>Vt(n,e,!1)),vg=n=>st(n,e=>Vt(n,e,!Le(n))),Sg=n=>st(n,e=>Vt(n,e,Le(n))),Cg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Ag=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function Tg(n,e,t){let i=!1,r=Ni(n.selection,s=>{let o=nt(n,s.head,-1)||nt(n,s.head,1)||s.head>0&&nt(n,s.head-1,1)||s.head<n.doc.length&&nt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(mt(n,r)),!0):!1}var Mg=({state:n,dispatch:e})=>Tg(n,e,!1);function Ye(n,e){let t=Ni(n.state.selection,i=>{let r=e(i);return L.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(mt(n.state,t)),!0)}function Lf(n,e){return Ye(n,t=>n.moveByChar(t,e))}var Df=n=>Lf(n,!Le(n)),Of=n=>Lf(n,Le(n));function Ef(n,e){return Ye(n,t=>n.moveByGroup(t,e))}var Lg=n=>Ef(n,!Le(n)),Dg=n=>Ef(n,Le(n));var Og=n=>Ye(n,e=>Jr(n.state,e,!Le(n))),Eg=n=>Ye(n,e=>Jr(n.state,e,Le(n)));function Bf(n,e){return Ye(n,t=>n.moveVertically(t,e))}var Pf=n=>Bf(n,!1),Rf=n=>Bf(n,!0);function If(n,e){return Ye(n,t=>n.moveVertically(t,e,Tf(n).height))}var sf=n=>If(n,!1),of=n=>If(n,!0),Bg=n=>Ye(n,e=>Vt(n,e,!0)),Pg=n=>Ye(n,e=>Vt(n,e,!1)),Rg=n=>Ye(n,e=>Vt(n,e,!Le(n))),Ig=n=>Ye(n,e=>Vt(n,e,Le(n))),Ng=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).from)),zg=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).to)),lf=({state:n,dispatch:e})=>(e(mt(n,{anchor:0})),!0),af=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.doc.length})),!0),hf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:0})),!0),cf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Fg=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Hg=({state:n,dispatch:e})=>{let t=Xr(n).map(({from:i,to:r})=>L.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},Vg=({state:n,dispatch:e})=>{let t=Ni(n.selection,i=>{var r;let s=Be(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return L.range(l.to,l.from)}return i});return e(mt(n,t)),!0},Wg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(mt(n,i)),!0):!1};function En(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=_r(n,a,!1)):a>o&&(t="delete.forward",a=_r(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=_r(n,o,!1),l=_r(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function _r(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Nf=(n,e)=>En(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]==" ")return i-1;let a=Dt(o,r.tabSize),h=a%Ft(r)||Ft(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=be(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=be(s.text,l-s.from,!1,!1)+s.from);return l}),Ml=n=>Nf(n,!1),zf=n=>Nf(n,!0),Ff=(n,e)=>En(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=be(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Hf=n=>Ff(n,!1),jg=n=>Ff(n,!0),qg=n=>En(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var $g=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Kg=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var _g=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Z.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Gg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:be(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:be(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xr(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Vf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Xr(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Ug=({state:n,dispatch:e})=>Vf(n,e,!1),Yg=({state:n,dispatch:e})=>Vf(n,e,!0);function Wf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Xr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Jg=({state:n,dispatch:e})=>Wf(n,e,!1),Xg=({state:n,dispatch:e})=>Wf(n,e,!0),Zg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Xr(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Ni(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Qg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Be(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(X.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var e0=jf(!1),t0=jf(!0);function jf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&Qg(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ri(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=$r(h,s);for(c==null&&(c=Dt(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Ii(e,c)];return a&&f.push(Ii(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Z.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ol(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var i0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new ri(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Ol(n,(s,o,l)=>{let a=$r(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Ii(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},n0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Ht)})}),{userEvent:"input.indent"})),!0),r0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Dt(r,n.tabSize),o=0,l=Ii(n,Math.max(0,s-Ft(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var s0=[{key:"Ctrl-b",run:wf,shift:Df,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:Of},{key:"Ctrl-p",run:Cf,shift:Pf},{key:"Ctrl-n",run:Af,shift:Rf},{key:"Ctrl-a",run:Cg,shift:Ng},{key:"Ctrl-e",run:Ag,shift:zg},{key:"Ctrl-d",run:zf},{key:"Ctrl-h",run:Ml},{key:"Ctrl-k",run:qg},{key:"Ctrl-Alt-h",run:Hf},{key:"Ctrl-o",run:_g},{key:"Ctrl-t",run:Gg},{key:"Ctrl-v",run:Tl}],o0=[{key:"ArrowLeft",run:wf,shift:Df,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:mg,shift:Lg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:vg,shift:Rg,preventDefault:!0},{key:"ArrowRight",run:xf,shift:Of,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:gg,shift:Dg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Sg,shift:Ig,preventDefault:!0},{key:"ArrowUp",run:Cf,shift:Pf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lf,shift:hf},{mac:"Ctrl-ArrowUp",run:rf,shift:sf},{key:"ArrowDown",run:Af,shift:Rf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:af,shift:cf},{mac:"Ctrl-ArrowDown",run:Tl,shift:of},{key:"PageUp",run:rf,shift:sf},{key:"PageDown",run:Tl,shift:of},{key:"Home",run:xg,shift:Pg,preventDefault:!0},{key:"Mod-Home",run:lf,shift:hf},{key:"End",run:wg,shift:Bg,preventDefault:!0},{key:"Mod-End",run:af,shift:cf},{key:"Enter",run:e0},{key:"Mod-a",run:Fg},{key:"Backspace",run:Ml,shift:Ml},{key:"Delete",run:zf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Hf},{key:"Mod-Delete",mac:"Alt-Delete",run:jg},{mac:"Mod-Backspace",run:$g},{mac:"Mod-Delete",run:Kg}].concat(s0.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),qf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:kg,shift:Og},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:yg,shift:Eg},{key:"Alt-ArrowUp",run:Ug},{key:"Shift-Alt-ArrowUp",run:Jg},{key:"Alt-ArrowDown",run:Yg},{key:"Shift-Alt-ArrowDown",run:Xg},{key:"Escape",run:Wg},{key:"Mod-Enter",run:t0},{key:"Alt-l",mac:"Ctrl-l",run:Hg},{key:"Mod-i",run:Vg,preventDefault:!0},{key:"Mod-[",run:r0},{key:"Mod-]",run:n0},{key:"Mod-Alt-\\",run:i0},{key:"Shift-Mod-k",run:Zg},{key:"Shift-Mod-\\",run:Mg},{key:"Mod-/",run:Zm},{key:"Alt-A",run:eg}].concat(o0);function ne(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)$f(n,arguments[e]);return n}function $f(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)$f(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var Kf=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,oi=class{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(Kf(l)):Kf,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $e(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=er(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=wt(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o);if(s==r.length-1){if(a)return this.value=a,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}};typeof Symbol!="undefined"&&(oi.prototype[Symbol.iterator]=function(){return this});var Uf={from:-1,to:-1,match:/.*/.exec("")},zl="gm"+(/x/.unicode==null?"":"u"),es=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Uf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new is(e,t,i,r,s);this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=ns(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=ns(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},El=new WeakMap,ts=class n{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=El.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return El.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),El.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},is=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=Uf,this.matchPos=ns(e,r),this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=ts.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=ns(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ts.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(es.prototype[Symbol.iterator]=is.prototype[Symbol.iterator]=function(){return this});function l0(n){try{return new RegExp(n,zl),!0}catch(e){return!1}}function ns(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Bl(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=ne("input",{class:"cm-textfield",name:"line",value:e}),i=ne("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:rs.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},ne("label",n.state.phrase("Go to line"),": ",t)," ",ne("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=s,u=c?+c.slice(1):0,p=h?+h:l.number;if(h&&f){let y=p/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*y)}else h&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=L.cursor(g.from+Math.max(0,Math.min(u,g.length)));n.dispatch({effects:[rs.of(!1),z.scrollIntoView(x.from,{y:"center"})],selection:x}),n.focus()}return{dom:i}}var rs=J.define(),_f=pe.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(rs)&&(n=t.value);return n},provide:n=>ei.from(n,e=>e?Bl:null)}),a0=n=>{let e=ti(n,Bl);if(!e){let t=[rs.of(!0)];n.state.field(_f,!1)==null&&t.push(J.appendConfig.of([_f,h0])),n.dispatch({effects:t}),e=ti(n,Bl)}return e&&e.dom.querySelector("input").select(),!0},h0=z.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var c0=({state:n,dispatch:e})=>{let{selection:t}=n,i=L.create(t.ranges.map(r=>n.wordAt(r.head)||L.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function f0(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new oi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new oi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var u0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return c0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=f0(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:z.scrollIntoView(r.to)})),!0):!1},Hi=I.define({combine(n){return ze(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Nl(e),scrollToMatch:e=>z.scrollIntoView(e)})}});var ss=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||l0(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
13
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Rl(this):new Pl(this)}getCursor(e,t=0,i){let r=e.doc?e:oe.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Fi(this,r,t,i):zi(this,r,t,i)}},os=class{constructor(e){this.spec=e}};function zi(n,e,t,i){return new oi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?d0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function d0(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(ls(r,t-s))!=fe.Word||e(as(r,t-s))!=fe.Word)&&(e(as(r,i-s))!=fe.Word||e(ls(r,i-s))!=fe.Word))}var Pl=class extends os{constructor(e){super(e)}nextMatch(e,t,i){let r=zi(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=zi(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=zi(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=zi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=zi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function Fi(n,e,t,i){return new es(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?p0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ls(n,e){return n.slice(be(n,e,!1),e)}function as(n,e){return n.slice(e,be(n,e))}function p0(n){return(e,t,i)=>!i[0].length||(n(ls(i.input,i.index))!=fe.Word||n(as(i.input,i.index))!=fe.Word)&&(n(as(i.input,i.index+i[0].length))!=fe.Word||n(ls(i.input,i.index+i[0].length))!=fe.Word)}var Rl=class extends os{nextMatch(e,t,i){let r=Fi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Fi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Fi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t))}matchAll(e,t){let i=Fi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Fi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Pn=J.define(),Fl=J.define(),Wt=pe.define({create(n){return new Bn(Il(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Pn)?n=new Bn(t.value.create(),n.panel):t.is(Fl)&&(n=new Bn(n.query,t.value?Hl:null));return n},provide:n=>ei.from(n,e=>e.panel)});var Bn=class{constructor(e,t){this.query=e,this.panel=t}},m0=Y.mark({class:"cm-searchMatch"}),g0=Y.mark({class:"cm-searchMatch cm-searchMatch-selected"}),b0=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Wt))}update(n){let e=n.state.field(Wt);(e!=n.startState.field(Wt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Y.none;let{view:t}=this,i=new ot;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?g0:m0)})}return i.finish()}},{decorations:n=>n.decorations});function Rn(n){return e=>{let t=e.state.field(Wt,!1);return t&&t.query.spec.valid?n(e,t):Xf(e)}}var hs=Rn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=L.single(i.from,i.to),s=n.state.facet(Hi);return n.dispatch({selection:r,effects:[Vl(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Jf(n),!0}),cs=Rn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=L.single(r.from,r.to),o=n.state.facet(Hi);return n.dispatch({selection:s,effects:[Vl(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Jf(n),!0}),k0=Rn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:L.create(t.map(i=>L.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),y0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new oi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(L.range(l.value.from,l.value.to))}return e(n.update({selection:L.create(s,o),userEvent:"select.search.matches"})),!0},Gf=Rn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,a,h=[];if(s.from==i&&s.to==r&&(a=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(t,s.from,s.to),h.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-a.length;l=L.single(s.from-c,s.to-c),h.push(Vl(n,s)),h.push(t.facet(Hi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),w0=Rn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:z.announce.of(i),userEvent:"input.replace.all"}),!0});function Hl(n){return n.state.facet(Hi).createPanel(n)}function Il(n,e){var t,i,r,s,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Hi);return new ss({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Yf(n){let e=ti(n,Hl);return e&&e.dom.querySelector("[main-field]")}function Jf(n){let e=Yf(n);e&&e==n.root.activeElement&&e.select()}var Xf=n=>{let e=n.state.field(Wt,!1);if(e&&e.panel){let t=Yf(n);if(t&&t!=n.root.activeElement){let i=Il(n.state,e.query.spec);i.valid&&n.dispatch({effects:Pn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Fl.of(!0),e?Pn.of(Il(n.state,e.query.spec)):J.appendConfig.of(v0)]});return!0},Zf=n=>{let e=n.state.field(Wt,!1);if(!e||!e.panel)return!1;let t=ti(n,Hl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Fl.of(!1)}),!0},Qf=[{key:"Mod-f",run:Xf,scope:"editor search-panel"},{key:"F3",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Zf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:y0},{key:"Alt-g",run:a0},{key:"Mod-d",run:u0,preventDefault:!0}],Nl=class{constructor(e){this.view=e;let t=this.query=e.state.field(Wt).query.spec;this.commit=this.commit.bind(this),this.searchField=ne("input",{value:t.search,placeholder:je(e,"Find"),"aria-label":je(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ne("input",{value:t.replace,placeholder:je(e,"Replace"),"aria-label":je(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ne("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ne("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ne("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ne("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ne("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>hs(e),[je(e,"next")]),i("prev",()=>cs(e),[je(e,"previous")]),i("select",()=>k0(e),[je(e,"all")]),ne("label",null,[this.caseField,je(e,"match case")]),ne("label",null,[this.reField,je(e,"regexp")]),ne("label",null,[this.wordField,je(e,"by word")]),...e.state.readOnly?[]:[ne("br"),this.replaceField,i("replace",()=>Gf(e),[je(e,"replace")]),i("replaceAll",()=>w0(e),[je(e,"replace all")])],ne("button",{name:"close",onclick:()=>Zf(e),"aria-label":je(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new ss({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Pn.of(e)}))}keydown(e){mc(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?cs:hs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Gf(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Pn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Hi).top}};function je(n,e){return n.state.phrase(e)}var Zr=30,Qr=/[\s\.,:;?!]/;function Vl(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-Zr),o=Math.min(r,t+Zr),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<Zr;a++)if(!Qr.test(l[a+1])&&Qr.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-Zr;a--)if(!Qr.test(l[a-1])&&Qr.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var x0=z.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),v0=[Wt,Lt.low(b0),x0];var Wl=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},li=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(ai).markerFilter;s&&(r=s(r));let o=Y.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?Y.widget({widget:new jl(l),diagnostic:l}).range(l.from):Y.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new n(o,t,Vi(o))}};function Vi(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new Wl(r,s,o.diagnostic),!1}),i}function tu(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(ms))||n.changes.touchesRange(t.from,t.to))}function iu(n,e){return n.field(Je,!1)?e:e.concat(J.appendConfig.of(cu))}function S0(n,e){return{effects:iu(n,[ms.of(e)])}}var ms=J.define(),$l=J.define(),nu=J.define(),Je=pe.define({create(){return new li(Y.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vi(t,n.selected.diagnostic,r)||Vi(t,null,r)}n=new li(t,n.panel,i)}for(let t of e.effects)t.is(ms)?n=li.init(t.value,n.panel,e.state):t.is($l)?n=new li(n.diagnostics,t.value?ps.open:null,n.selected):t.is(nu)&&(n=new li(n.diagnostics,n.panel,t.value));return n},provide:n=>[ei.from(n,e=>e.panel),z.decorations.from(n,e=>e.diagnostics)]});var C0=Y.mark({class:"cm-lintRange cm-lintRange-active"});function A0(n,e,t){let{diagnostics:i}=n.state.field(Je),r=[],s=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(r.push(c.diagnostic),s=Math.min(a,s),o=Math.max(h,o))});let l=n.state.facet(ai).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:ru(n,r)}}}:null}function ru(n,e){return ne("ul",{class:"cm-tooltip-lint"},e.map(t=>lu(n,t,!1)))}var Kl=n=>{let e=n.state.field(Je,!1);(!e||!e.panel)&&n.dispatch({effects:iu(n.state,[$l.of(!0)])});let t=ti(n,ps.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},In=n=>{let e=n.state.field(Je,!1);return!e||!e.panel?!1:(n.dispatch({effects:$l.of(!1)}),!0)};var T0=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(ai);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(ai);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(S0(this.view.state,r))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(ai);(n.docChanged||e!=n.startState.facet(ai)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),ai=I.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ze(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function su(n,e={}){return[ai.of({source:n,config:e}),T0,cu]}function ou(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function lu(n,e,t){var i;let r=t?ou(e.actions):[];return ne("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ne("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let p=Vi(n.state.field(Je).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),ne("u",h.slice(c,c+1)),h.slice(c+1)];return ne("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&ne("div",{class:"cm-diagnosticSource"},e.source))}var jl=class extends et{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ne("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},ds=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lu(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ps=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)In(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=ou(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=Vi(this.view.state.field(Je).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=ne("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=ne("div",{class:"cm-panel-lint"},this.list,ne("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>In(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ds(this.view,a.diagnostic),this.items.splice(i,0,c),r=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ds(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Je),i=Vi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:nu.of(i)})}static open(e){return new n(e)}};function us(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function fs(n){return us(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var M0=z.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fs("#d11")},".cm-lintRange-warning":{backgroundImage:fs("orange")},".cm-lintRange-info":{backgroundImage:fs("#999")},".cm-lintRange-hint":{backgroundImage:fs("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function eu(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var ql=class extends Ge{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>eu(t)<eu(i.severity)?i.severity:t,"hint")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(gs).tooltipFilter;return r&&(i=r(i)),i.length&&(t.onmouseover=()=>D0(e,t,i)),t}};function L0(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(hu)&&n.dispatch({effects:_l.of(null)})}};window.addEventListener("mousemove",t)}function D0(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:_l.of({pos:o.from,above:!1,create(){return{dom:ru(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,L0(n,e)}let{hoverTime:r}=n.state.facet(gs),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function O0(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new ql(t[r]).range(+r));return ie.of(i,!0)}var E0=Zo({class:"cm-gutter-lint",markers:n=>n.state.field(au)}),au=pe.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(gs).markerFilter;for(let i of e.effects)if(i.is(ms)){let r=i.value;t&&(r=t(r||[])),n=O0(e.state.doc,r.slice(0))}return n}}),_l=J.define(),hu=pe.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=tu(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(_l)?i.value:t,n)},provide:n=>yn.from(n)}),B0=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:us('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:us('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:us('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),cu=[Je,z.decorations.compute([Je],n=>{let{selected:e,panel:t}=n.field(Je);return!e||!t||e.from==e.to?Y.none:Y.set([C0.range(e.from,e.to)])}),wc(A0,{hideOn:tu}),M0],gs=I.define({combine(n){return ze(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fu(n={}){return[gs.of(n),au,E0,B0,hu]}var bs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},hi=J.define({map(n,e){let t=e.mapPos(n,-1,Ce.TrackAfter);return t==null?void 0:t}}),Ul=new class extends Ze{};Ul.startSide=1;Ul.endSide=-1;var pu=pe.define({create(){return ie.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(hi)&&(n=n.update({add:[Ul.range(t.value,t.value+1)]}));return n}});function mu(){return[N0,pu]}var Gl="()[]{}<>";function P0(n){for(let e=0;e<Gl.length;e+=2)if(Gl.charCodeAt(e)==n)return Gl.charAt(e+1);return er(n<128?n:n+1)}function R0(n,e){return n.languageDataAt("closeBrackets",e)[0]||bs}var I0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),N0=z.inputHandler.of((n,e,t,i)=>{if((I0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&wt($e(i,0))==1||e!=r.from||t!=r.to)return!1;let s=z0(n.state,i);return s?(n.dispatch(s),!0):!1});function z0(n,e){let t=R0(n,n.selection.main.head),i=t.brackets||bs.brackets;for(let r of i){let s=P0($e(r,0));if(e==r)return s==r?V0(n,r,i.indexOf(r+r+r)>-1,t):F0(n,r,s,t.before||bs.before);if(e==s&&gu(n,n.selection.main.from))return H0(n,r,s)}return null}function gu(n,e){let t=!1;return n.field(pu).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Yl(n,e){let t=n.sliceString(e,e+2);return t.slice(0,wt($e(t,0)))}function F0(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:hi.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=Yl(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:hi.of(o.head+e.length),range:L.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function H0(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Yl(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:L.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function V0(n,e,t,i){let r=i.stringPrefixes||bs.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:hi.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Yl(n.doc,a),c;if(h==e){if(uu(n,a))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(gu(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:L.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=du(n,a-2*e.length,r))>-1&&uu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=fe.Word&&du(n,a,r)>-1&&!W0(n,a,e,r))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function uu(n,e){let t=Be(n).resolveInner(e+1);return t.parent&&t.from==e}function W0(n,e,t,i){let r=Be(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function du(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=fe.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=fe.Word)return s}return-1}var S={permittedHtmlTags:new Set(["b","bdi","bdo","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","q","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","br","wbr","hr","li","dt","dd","td","th","tr","noinclude","includeonly","onlyinclude","img"]),implicitlyClosedHtmlTags:new Set(["br","hr","wbr","img"]),tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",extGround:"mw-ext-ground",ext2Ground:"mw-ext2-ground",ext2LinkGround:"mw-ext2-link-ground",ext3Ground:"mw-ext3-ground",ext3LinkGround:"mw-ext3-link-ground",extLinkGround:"mw-ext-link-ground",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateExtGround:"mw-template-ext-ground",templateExt2Ground:"mw-template-ext2-ground",templateExt2LinkGround:"mw-template-ext2-link-ground",templateExt3Ground:"mw-template-ext3-ground",templateExt3LinkGround:"mw-template-ext3-link-ground",templateExtLinkGround:"mw-template-ext-link-ground",templateGround:"mw-template-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ext2Ground:"mw-template2-ext2-ground",template2Ext3Ground:"mw-template2-ext3-ground",templatet2Ext2LinkGround:"mw-template2-ext2-link-ground",template2Ext3LinkGround:"mw-template2-ext3-link-ground",template2ExtLinkGround:"mw-template2-ext-link-ground",template2Ground:"mw-template2-ground",template2LinkGround:"mw-template2-link-ground",template3ExtGround:"mw-template3-ext-ground",template3Ext2Ground:"mw-template3-ext2-ground",template3Ext3Ground:"mw-template3-ext3-ground",template3ExtLinkGround:"mw-template3-ext-link-ground",template3Ext2LinkGround:"mw-template3-ext2-link-ground",template3Ext3LinkGround:"mw-template3-ext3-link-ground",template3Ground:"mw-template3-ground",template3LinkGround:"mw-template3-link-ground"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=Pe.define();return n}};var Nn={};ad(Nn,{css:()=>Mu,javascript:()=>Lu,json:()=>Du,lua:()=>Bu});function ks(n){n={...K0,...n};var e=n.inline,t=n.tokenHooks,i=n.documentTypes||{},r=n.mediaTypes||{},s=n.mediaFeatures||{},o=n.mediaValueKeywords||{},l=n.propertyKeywords||{},a=n.nonStandardPropertyKeywords||{},h=n.fontProperties||{},c=n.counterDescriptors||{},f=n.colorKeywords||{},u=n.valueKeywords||{},p=n.allowNested,g=n.lineComment,x=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,M;function O(k,T){return v=T,k}function R(k,T){var A=k.next();if(t[A]){var V=t[A](k,T);if(V!==!1)return V}if(A=="@")return k.eatWhile(/[\w\\\-]/),O("def",k.current());if(A=="="||(A=="~"||A=="|")&&k.eat("="))return O(null,"compare");if(A=='"'||A=="'")return T.tokenize=F(A),T.tokenize(k,T);if(A=="#")return k.eatWhile(/[\w\\\-]/),O("atom","hash");if(A=="!")return k.match(/^\s*\w*/),O("keyword","important");if(/\d/.test(A)||A=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),O("number","unit");if(A==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),O("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?O("def","variable-definition"):O("variableName","variable");if(k.match(/^\w+-/))return O("meta","meta")}else return/[,+>*\/]/.test(A)?O(null,"select-op"):A=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?O("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(A)?O(null,A):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(T.tokenize=q),O("variableName.function","variable")):/[\w\\\-]/.test(A)?(k.eatWhile(/[\w\\\-]/),O("property","word")):O(null,null)}function F(k){return function(T,A){for(var V=!1,ae;(ae=T.next())!=null;){if(ae==k&&!V){k==")"&&T.backUp(1);break}V=!V&&ae=="\\"}return(ae==k||!V&&k!=")")&&(A.tokenize=null),O("string","string")}}function q(k,T){return k.next(),k.match(/^\s*[\"\')]/,!1)?T.tokenize=null:T.tokenize=F(")"),O(null,"(")}function w(k,T,A){this.type=k,this.indent=T,this.prev=A}function D(k,T,A,V){return k.context=new w(A,T.indentation()+(V===!1?0:T.indentUnit),k.context),A}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function U(k,T,A){return K[A.context.type](k,T,A)}function $(k,T,A,V){for(var ae=V||1;ae>0;ae--)A.context=A.context.prev;return U(k,T,A)}function G(k){var T=k.current().toLowerCase();u.hasOwnProperty(T)?M="atom":f.hasOwnProperty(T)?M="keyword":M="variable"}var K={};return K.top=function(k,T,A){if(k=="{")return D(A,T,"block");if(k=="}"&&A.context.prev)return b(A);if(x&&/@component/i.test(k))return D(A,T,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return D(A,T,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return D(A,T,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return A.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return D(A,T,"at");if(k=="hash")M="builtin";else if(k=="word")M="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return D(A,T,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return D(A,T,"parens")}return A.context.type},K.block=function(k,T,A){if(k=="word"){var V=T.current().toLowerCase();return l.hasOwnProperty(V)?(M="property","maybeprop"):a.hasOwnProperty(V)?(M=y?"string.special":"property","maybeprop"):p?(M=T.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(M="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(M="error","block"):K.top(k,T,A)},K.maybeprop=function(k,T,A){return k==":"?D(A,T,"prop"):U(k,T,A)},K.prop=function(k,T,A){if(k==";")return b(A);if(k=="{"&&p)return D(A,T,"propBlock");if(k=="}"||k=="{")return $(k,T,A);if(k=="(")return D(A,T,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(T.current()))M="error";else if(k=="word")G(T);else if(k=="interpolation")return D(A,T,"interpolation");return"prop"},K.propBlock=function(k,T,A){return k=="}"?b(A):k=="word"?(M="property","maybeprop"):A.context.type},K.parens=function(k,T,A){return k=="{"||k=="}"?$(k,T,A):k==")"?b(A):k=="("?D(A,T,"parens"):k=="interpolation"?D(A,T,"interpolation"):(k=="word"&&G(T),"parens")},K.pseudo=function(k,T,A){return k=="meta"?"pseudo":k=="word"?(M="variableName.constant",A.context.type):U(k,T,A)},K.documentTypes=function(k,T,A){return k=="word"&&i.hasOwnProperty(T.current())?(M="tag",A.context.type):K.atBlock(k,T,A)},K.atBlock=function(k,T,A){if(k=="(")return D(A,T,"atBlock_parens");if(k=="}"||k==";")return $(k,T,A);if(k=="{")return b(A)&&D(A,T,p?"block":"top");if(k=="interpolation")return D(A,T,"interpolation");if(k=="word"){var V=T.current().toLowerCase();V=="only"||V=="not"||V=="and"||V=="or"?M="keyword":r.hasOwnProperty(V)?M="attribute":s.hasOwnProperty(V)?M="property":o.hasOwnProperty(V)?M="keyword":l.hasOwnProperty(V)?M="property":a.hasOwnProperty(V)?M=y?"string.special":"property":u.hasOwnProperty(V)?M="atom":f.hasOwnProperty(V)?M="keyword":M="error"}return A.context.type},K.atComponentBlock=function(k,T,A){return k=="}"?$(k,T,A):k=="{"?b(A)&&D(A,T,p?"block":"top",!1):(k=="word"&&(M="error"),A.context.type)},K.atBlock_parens=function(k,T,A){return k==")"?b(A):k=="{"||k=="}"?$(k,T,A,2):K.atBlock(k,T,A)},K.restricted_atBlock_before=function(k,T,A){return k=="{"?D(A,T,"restricted_atBlock"):k=="word"&&A.stateArg=="@counter-style"?(M="variable","restricted_atBlock_before"):U(k,T,A)},K.restricted_atBlock=function(k,T,A){return k=="}"?(A.stateArg=null,b(A)):k=="word"?(A.stateArg=="@font-face"&&!h.hasOwnProperty(T.current().toLowerCase())||A.stateArg=="@counter-style"&&!c.hasOwnProperty(T.current().toLowerCase())?M="error":M="property","maybeprop"):"restricted_atBlock"},K.keyframes=function(k,T,A){return k=="word"?(M="variable","keyframes"):k=="{"?D(A,T,"top"):U(k,T,A)},K.at=function(k,T,A){return k==";"?b(A):k=="{"||k=="}"?$(k,T,A):(k=="word"?M="tag":k=="hash"&&(M="builtin"),"at")},K.interpolation=function(k,T,A){return k=="}"?b(A):k=="{"||k==";"?$(k,T,A):(k=="word"?M="variable":k!="variable"&&k!="("&&k!=")"&&(M="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new w(e?"block":"top",0,null)}},token:function(k,T){if(!T.tokenize&&k.eatSpace())return null;var A=(T.tokenize||R)(k,T);return A&&typeof A=="object"&&(v=A[1],A=A[0]),M=A,v!="comment"&&(T.state=K[T.state](v,k,T)),M},indent:function(k,T,A){var V=k.context,ae=T&&T.charAt(0),we=V.indent;return V.type=="prop"&&(ae=="}"||ae==")")&&(V=V.prev),V.prev&&(ae=="}"&&(V.type=="block"||V.type=="top"||V.type=="interpolation"||V.type=="restricted_atBlock")?(V=V.prev,we=V.indent):(ae==")"&&(V.type=="parens"||V.type=="atBlock_parens")||ae=="{"&&(V.type=="at"||V.type=="atBlock"))&&(we=Math.max(0,V.indent-A.unit))),we},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:$0}}}function gt(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var bu=["domain","regexp","url","url-prefix"],ku=gt(bu),yu=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],ys=gt(yu),wu=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],ws=gt(wu),xu=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Jl=gt(xu),vu=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],xs=gt(vu),Su=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],vs=gt(Su),j0=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],Ss=gt(j0),q0=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],Cu=gt(q0),Au=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Cs=gt(Au),Tu=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],As=gt(Tu),$0=bu.concat(yu).concat(wu).concat(xu).concat(vu).concat(Su).concat(Au).concat(Tu);var K0={documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}},Mu=ks({name:"css"});function jt(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var ek=ks({name:"scss",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},":":function(n){return n.match(/^\s*\{/,!1)?[null,null]:!1},$:function(n){return n.match(/^[\w-]+/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}}}),tk=ks({name:"less",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},"@":function(n){return n.eat("{")?[null,"interpolation"]:n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),ik=ks({name:"gss",documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}});function Ts(n){var e=n.statementIndent,t=n.jsonld,i=n.json||t,r=n.typescript,s=n.wordCharacters||/[\w$\xa1-\uffff]/,o=function(){function d(Re){return{type:Re,style:"keyword"}}var m=d("keyword a"),C=d("keyword b"),B=d("keyword c"),N=d("keyword d"),Q=d("operator"),se={type:"atom",style:"atom"};return{if:d("if"),while:m,with:m,else:C,do:C,try:C,finally:C,return:N,break:N,continue:N,new:d("new"),delete:B,void:B,throw:B,debugger:d("debugger"),var:d("var"),const:d("var"),let:d("var"),function:d("function"),catch:d("catch"),for:d("for"),switch:d("switch"),case:d("case"),default:d("default"),in:Q,typeof:Q,instanceof:Q,true:se,false:se,null:se,undefined:se,NaN:se,Infinity:se,this:d("this"),class:d("class"),super:d("atom"),yield:B,export:d("export"),import:d("import"),extends:B,await:B}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var m=!1,C,B=!1;(C=d.next())!=null;){if(!m){if(C=="/"&&!B)return;C=="["?B=!0:B&&C=="]"&&(B=!1)}m=!m&&C=="\\"}}var c,f;function u(d,m,C){return c=d,f=C,m}function p(d,m){var C=d.next();if(C=='"'||C=="'")return m.tokenize=g(C),m.tokenize(d,m);if(C=="."&&d.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if(C=="."&&d.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(C))return u(C);if(C=="="&&d.eat(">"))return u("=>","operator");if(C=="0"&&d.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(C))return d.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if(C=="/")return d.eat("*")?(m.tokenize=x,x(d,m)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):od(d,m,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return m.tokenize=y,y(d,m);if(C=="#"&&d.peek()=="!")return d.skipToEnd(),u("meta","meta");if(C=="#"&&d.eatWhile(s))return u("variable","property");if(C=="<"&&d.match("!--")||C=="-"&&d.match("->")&&!/\S/.test(d.string.slice(0,d.start)))return d.skipToEnd(),u("comment","comment");if(l.test(C))return(C!=">"||!m.lexical||m.lexical.type!=">")&&(d.eat("=")?(C=="!"||C=="=")&&d.eat("="):/[<>*+\-|&?]/.test(C)&&(d.eat(C),C==">"&&d.eat(C))),C=="?"&&d.eat(".")?u("."):u("operator","operator",d.current());if(s.test(C)){d.eatWhile(s);var B=d.current();if(m.lastType!="."){if(o.propertyIsEnumerable(B)){var N=o[B];return u(N.type,N.style,B)}if(B=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",B)}return u("variable","variable",B)}}function g(d){return function(m,C){var B=!1,N;if(t&&m.peek()=="@"&&m.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(N=m.next())!=null&&!(N==d&&!B);)B=!B&&N=="\\";return B||(C.tokenize=p),u("string","string")}}function x(d,m){for(var C=!1,B;B=d.next();){if(B=="/"&&C){m.tokenize=p;break}C=B=="*"}return u("comment","comment")}function y(d,m){for(var C=!1,B;(B=d.next())!=null;){if(!C&&(B=="`"||B=="$"&&d.eat("{"))){m.tokenize=p;break}C=!C&&B=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function M(d,m){m.fatArrowAt&&(m.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var B=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));B&&(C=B.index)}for(var N=0,Q=!1,se=C-1;se>=0;--se){var Re=d.string.charAt(se),qe=v.indexOf(Re);if(qe>=0&&qe<3){if(!N){++se;break}if(--N==0){Re=="("&&(Q=!0);break}}else if(qe>=3&&qe<6)++N;else if(s.test(Re))Q=!0;else if(/["'\/`]/.test(Re))for(;;--se){if(se==0)return;var _i=d.string.charAt(se-1);if(_i==Re&&d.string.charAt(se-2)!="\\"){se--;break}}else if(Q&&!N){++se;break}}Q&&!N&&(m.fatArrowAt=se)}}var O={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function R(d,m,C,B,N,Q){this.indented=d,this.column=m,this.type=C,this.prev=N,this.info=Q,B!=null&&(this.align=B)}function F(d,m){for(var C=d.localVars;C;C=C.next)if(C.name==m)return!0;for(var B=d.context;B;B=B.prev)for(var C=B.vars;C;C=C.next)if(C.name==m)return!0}function q(d,m,C,B,N){var Q=d.cc;for(w.state=d,w.stream=N,w.marked=null,w.cc=Q,w.style=m,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var se=Q.length?Q.pop():i?te:he;if(se(C,B)){for(;Q.length&&Q[Q.length-1].lex;)Q.pop()();return w.marked?w.marked:C=="variable"&&F(d,B)?"variableName.local":m}}}var w={state:null,column:null,marked:null,cc:null};function D(){for(var d=arguments.length-1;d>=0;d--)w.cc.push(arguments[d])}function b(){return D.apply(null,arguments),!0}function U(d,m){for(var C=m;C;C=C.next)if(C.name==d)return!0;return!1}function $(d){var m=w.state;if(w.marked="def",m.context){if(m.lexical.info=="var"&&m.context&&m.context.block){var C=G(d,m.context);if(C!=null){m.context=C;return}}else if(!U(d,m.localVars)){m.localVars=new T(d,m.localVars);return}}n.globalVars&&!U(d,m.globalVars)&&(m.globalVars=new T(d,m.globalVars))}function G(d,m){if(m)if(m.block){var C=G(d,m.prev);return C?C==m.prev?m:new k(C,m.vars,!0):null}else return U(d,m.vars)?m:new k(m.prev,new T(d,m.vars),!1);else return null}function K(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,m,C){this.prev=d,this.vars=m,this.block=C}function T(d,m){this.name=d,this.next=m}var A=new T("this",new T("arguments",null));function V(){w.state.context=new k(w.state.context,w.state.localVars,!1),w.state.localVars=A}function ae(){w.state.context=new k(w.state.context,w.state.localVars,!0),w.state.localVars=null}V.lex=ae.lex=!0;function we(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}we.lex=!0;function j(d,m){var C=function(){var B=w.state,N=B.indented;if(B.lexical.type=="stat")N=B.lexical.indented;else for(var Q=B.lexical;Q&&Q.type==")"&&Q.align;Q=Q.prev)N=Q.indented;B.lexical=new R(N,w.stream.column(),d,null,B.lexical,m)};return C.lex=!0,C}function W(){var d=w.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}W.lex=!0;function _(d){function m(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?D():b(m)}return m}function he(d,m){return d=="var"?b(j("vardef",m),Is,_(";"),W):d=="keyword a"?b(j("form"),Es,he,W):d=="keyword b"?b(j("form"),he,W):d=="keyword d"?w.stream.match(/^\s*$/,!1)?b():b(j("stat"),ci,_(";"),W):d=="debugger"?b(_(";")):d=="{"?b(j("}"),ae,Vn,W,we):d==";"?b():d=="if"?(w.state.lexical.info=="else"&&w.state.cc[w.state.cc.length-1]==W&&w.state.cc.pop()(),b(j("form"),Es,he,W,sa)):d=="function"?b(Tt):d=="for"?b(j("form"),ae,oa,he,we,W):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form",d=="class"?d:m),aa,W)):d=="variable"?r&&m=="declare"?(w.marked="keyword",b(he)):r&&(m=="module"||m=="enum"||m=="type")&&w.stream.match(/^\s*\w/,!1)?(w.marked="keyword",m=="enum"?b(fa):m=="type"?b(la,_("operator"),re,_(";")):b(j("form"),Xe,_("{"),j("}"),Vn,W,W)):r&&m=="namespace"?(w.marked="keyword",b(j("form"),te,he,W)):r&&m=="abstract"?(w.marked="keyword",b(he)):b(j("stat"),Wu):d=="switch"?b(j("form"),Es,_("{"),j("}","switch"),ae,Vn,W,W,we):d=="case"?b(te,_(":")):d=="default"?b(_(":")):d=="catch"?b(j("form"),V,Ct,he,W,we):d=="export"?b(j("stat"),ed,W):d=="import"?b(j("stat"),td,W):d=="async"?b(he):m=="@"?b(te,he):D(j("stat"),te,_(";"),W)}function Ct(d){if(d=="(")return b(_t,_(")"))}function te(d,m){return ea(d,m,!1)}function Te(d,m){return ea(d,m,!0)}function Es(d){return d!="("?D():b(j(")"),ci,_(")"),W)}function ea(d,m,C){if(w.state.fatArrowAt==w.stream.start){var B=C?ia:ta;if(d=="(")return b(V,j(")"),Se(_t,")"),W,_("=>"),B,we);if(d=="variable")return D(V,Xe,_("=>"),B,we)}var N=C?fi:$t;return O.hasOwnProperty(d)?b(N):d=="function"?b(Tt,N):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form"),Qu,W)):d=="keyword c"||d=="async"?b(C?Te:te):d=="("?b(j(")"),ci,_(")"),W,N):d=="operator"||d=="spread"?b(C?Te:te):d=="["?b(j("]"),nd,W,N):d=="{"?$i(Hn,"}",null,N):d=="quasi"?D(Fn,N):d=="new"?b(Fu(C)):b()}function ci(d){return d.match(/[;\}\)\],]/)?D():D(te)}function $t(d,m){return d==","?b(ci):fi(d,m,!1)}function fi(d,m,C){var B=C==!1?$t:fi,N=C==!1?te:Te;if(d=="=>")return b(V,C?ia:ta,we);if(d=="operator")return/\+\+|--/.test(m)||r&&m=="!"?b(B):r&&m=="<"&&w.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Se(re,">"),W,B):m=="?"?b(te,_(":"),N):b(N);if(d=="quasi")return D(Fn,B);if(d!=";"){if(d=="(")return $i(Te,")","call",B);if(d==".")return b(ju,B);if(d=="[")return b(j("]"),ci,_("]"),W,B);if(r&&m=="as")return w.marked="keyword",b(re,B);if(d=="regexp")return w.state.lastType=w.marked="operator",w.stream.backUp(w.stream.pos-w.stream.start-1),b(N)}}function Fn(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Fn):b(ci,zu)}function zu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Fn)}function ta(d){return M(w.stream,w.state),D(d=="{"?he:te)}function ia(d){return M(w.stream,w.state),D(d=="{"?he:Te)}function Fu(d){return function(m){return m=="."?b(d?Vu:Hu):m=="variable"&&r?b(Uu,d?fi:$t):D(d?Te:te)}}function Hu(d,m){if(m=="target")return w.marked="keyword",b($t)}function Vu(d,m){if(m=="target")return w.marked="keyword",b(fi)}function Wu(d){return d==":"?b(W,he):D($t,_(";"),W)}function ju(d){if(d=="variable")return w.marked="property",b()}function Hn(d,m){if(d=="async")return w.marked="property",b(Hn);if(d=="variable"||w.style=="keyword"){if(w.marked="property",m=="get"||m=="set")return b(qu);var C;return r&&w.state.fatArrowAt==w.stream.start&&(C=w.stream.match(/^\s*:\s*/,!1))&&(w.state.fatArrowAt=w.stream.pos+C[0].length),b(Kt)}else{if(d=="number"||d=="string")return w.marked=t?"property":w.style+" property",b(Kt);if(d=="jsonld-keyword")return b(Kt);if(r&&K(m))return w.marked="keyword",b(Hn);if(d=="[")return b(te,ui,_("]"),Kt);if(d=="spread")return b(Te,Kt);if(m=="*")return w.marked="keyword",b(Hn);if(d==":")return D(Kt)}}function qu(d){return d!="variable"?D(Kt):(w.marked="property",b(Tt))}function Kt(d){if(d==":")return b(Te);if(d=="(")return D(Tt)}function Se(d,m,C){function B(N,Q){if(C?C.indexOf(N)>-1:N==","){var se=w.state.lexical;return se.info=="call"&&(se.pos=(se.pos||0)+1),b(function(Re,qe){return Re==m||qe==m?D():D(d)},B)}return N==m||Q==m?b():C&&C.indexOf(";")>-1?D(d):b(_(m))}return function(N,Q){return N==m||Q==m?b():D(d,B)}}function $i(d,m,C){for(var B=3;B<arguments.length;B++)w.cc.push(arguments[B]);return b(j(m,C),Se(d,m),W)}function Vn(d){return d=="}"?b():D(he,Vn)}function ui(d,m){if(r){if(d==":")return b(re);if(m=="?")return b(ui)}}function $u(d,m){if(r&&(d==":"||m=="in"))return b(re)}function na(d){if(r&&d==":")return w.stream.match(/^\s*\w+\s+is\b/,!1)?b(te,Ku,re):b(re)}function Ku(d,m){if(m=="is")return w.marked="keyword",b()}function re(d,m){if(m=="keyof"||m=="typeof"||m=="infer"||m=="readonly")return w.marked="keyword",b(m=="typeof"?Te:re);if(d=="variable"||m=="void")return w.marked="type",b(bt);if(m=="|"||m=="&")return b(re);if(d=="string"||d=="number"||d=="atom")return b(bt);if(d=="[")return b(j("]"),Se(re,"]",","),W,bt);if(d=="{")return b(j("}"),Bs,W,bt);if(d=="(")return b(Se(Rs,")"),_u,bt);if(d=="<")return b(Se(re,">"),re);if(d=="quasi")return D(Ps,bt)}function _u(d){if(d=="=>")return b(re)}function Bs(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(Bs):D(Ki,Bs)}function Ki(d,m){if(d=="variable"||w.style=="keyword")return w.marked="property",b(Ki);if(m=="?"||d=="number"||d=="string")return b(Ki);if(d==":")return b(re);if(d=="[")return b(_("variable"),$u,_("]"),Ki);if(d=="(")return D(pi,Ki);if(!d.match(/[;\}\)\],]/))return b()}function Ps(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Ps):b(re,Gu)}function Gu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Ps)}function Rs(d,m){return d=="variable"&&w.stream.match(/^\s*[?:]/,!1)||m=="?"?b(Rs):d==":"?b(re):d=="spread"?b(Rs):D(re)}function bt(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt);if(m=="|"||d=="."||m=="&")return b(re);if(d=="[")return b(re,_("]"),bt);if(m=="extends"||m=="implements")return w.marked="keyword",b(re);if(m=="?")return b(re,_(":"),re)}function Uu(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt)}function Wn(){return D(re,Yu)}function Yu(d,m){if(m=="=")return b(re)}function Is(d,m){return m=="enum"?(w.marked="keyword",b(fa)):D(Xe,ui,At,Xu)}function Xe(d,m){if(r&&K(m))return w.marked="keyword",b(Xe);if(d=="variable")return $(m),b();if(d=="spread")return b(Xe);if(d=="[")return $i(Ju,"]");if(d=="{")return $i(ra,"}")}function ra(d,m){return d=="variable"&&!w.stream.match(/^\s*:/,!1)?($(m),b(At)):(d=="variable"&&(w.marked="property"),d=="spread"?b(Xe):d=="}"?D():d=="["?b(te,_("]"),_(":"),ra):b(_(":"),Xe,At))}function Ju(){return D(Xe,At)}function At(d,m){if(m=="=")return b(Te)}function Xu(d){if(d==",")return b(Is)}function sa(d,m){if(d=="keyword b"&&m=="else")return b(j("form","else"),he,W)}function oa(d,m){if(m=="await")return b(oa);if(d=="(")return b(j(")"),Zu,W)}function Zu(d){return d=="var"?b(Is,di):d=="variable"?b(di):D(di)}function di(d,m){return d==")"?b():d==";"?b(di):m=="in"||m=="of"?(w.marked="keyword",b(te,di)):D(te,di)}function Tt(d,m){if(m=="*")return w.marked="keyword",b(Tt);if(d=="variable")return $(m),b(Tt);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,he,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,Tt)}function pi(d,m){if(m=="*")return w.marked="keyword",b(pi);if(d=="variable")return $(m),b(pi);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,pi)}function la(d,m){if(d=="keyword"||d=="variable")return w.marked="type",b(la);if(m=="<")return b(j(">"),Se(Wn,">"),W)}function _t(d,m){return m=="@"&&b(te,_t),d=="spread"?b(_t):r&&K(m)?(w.marked="keyword",b(_t)):r&&d=="this"?b(ui,At):D(Xe,ui,At)}function Qu(d,m){return d=="variable"?aa(d,m):jn(d,m)}function aa(d,m){if(d=="variable")return $(m),b(jn)}function jn(d,m){if(m=="<")return b(j(">"),Se(Wn,">"),W,jn);if(m=="extends"||m=="implements"||r&&d==",")return m=="implements"&&(w.marked="keyword"),b(r?re:te,jn);if(d=="{")return b(j("}"),kt,W)}function kt(d,m){if(d=="async"||d=="variable"&&(m=="static"||m=="get"||m=="set"||r&&K(m))&&w.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return w.marked="keyword",b(kt);if(d=="variable"||w.style=="keyword")return w.marked="property",b(qn,kt);if(d=="number"||d=="string")return b(qn,kt);if(d=="[")return b(te,ui,_("]"),qn,kt);if(m=="*")return w.marked="keyword",b(kt);if(r&&d=="(")return D(pi,kt);if(d==";"||d==",")return b(kt);if(d=="}")return b();if(m=="@")return b(te,kt)}function qn(d,m){if(m=="!"||m=="?")return b(qn);if(d==":")return b(re,At);if(m=="=")return b(Te);var C=w.state.lexical.prev,B=C&&C.info=="interface";return D(B?pi:Tt)}function ed(d,m){return m=="*"?(w.marked="keyword",b(Ns,_(";"))):m=="default"?(w.marked="keyword",b(te,_(";"))):d=="{"?b(Se(ha,"}"),Ns,_(";")):D(he)}function ha(d,m){if(m=="as")return w.marked="keyword",b(_("variable"));if(d=="variable")return D(Te,ha)}function td(d){return d=="string"?b():d=="("?D(te):d=="."?D($t):D($n,ca,Ns)}function $n(d,m){return d=="{"?$i($n,"}"):(d=="variable"&&$(m),m=="*"&&(w.marked="keyword"),b(id))}function ca(d){if(d==",")return b($n,ca)}function id(d,m){if(m=="as")return w.marked="keyword",b($n)}function Ns(d,m){if(m=="from")return w.marked="keyword",b(te)}function nd(d){return d=="]"?b():D(Se(Te,"]"))}function fa(){return D(j("form"),Xe,_("{"),j("}"),Se(rd,"}"),W,W)}function rd(){return D(Xe,At)}function sd(d,m){return d.lastType=="operator"||d.lastType==","||l.test(m.charAt(0))||/[,.]/.test(m.charAt(0))}function od(d,m,C){return m.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(m.lastType)||m.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var m={tokenize:p,lastType:"sof",cc:[],lexical:new R(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(m.globalVars=n.globalVars),m},token:function(d,m){if(d.sol()&&(m.lexical.hasOwnProperty("align")||(m.lexical.align=!1),m.indented=d.indentation(),M(d,m)),m.tokenize!=x&&d.eatSpace())return null;var C=m.tokenize(d,m);return c=="comment"?C:(m.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,q(m,C,c,f,d))},indent:function(d,m,C){if(d.tokenize==x||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var B=m&&m.charAt(0),N=d.lexical,Q;if(!/^\s*else\b/.test(m))for(var se=d.cc.length-1;se>=0;--se){var Re=d.cc[se];if(Re==W)N=N.prev;else if(Re!=sa&&Re!=we)break}for(;(N.type=="stat"||N.type=="form")&&(B=="}"||(Q=d.cc[d.cc.length-1])&&(Q==$t||Q==fi)&&!/^[,\.=+\-*:?[\(]/.test(m));)N=N.prev;e&&N.type==")"&&N.prev.type=="stat"&&(N=N.prev);var qe=N.type,_i=B==qe;return qe=="vardef"?N.indented+(d.lastType=="operator"||d.lastType==","?N.info.length+1:0):qe=="form"&&B=="{"?N.indented:qe=="form"?N.indented+C.unit:qe=="stat"?N.indented+(sd(d,m)?e||C.unit:0):N.info=="switch"&&!_i&&n.doubleIndentSwitch!=!1?N.indented+(/^(?:case|default)\b/.test(m)?C.unit:2*C.unit):N.align?N.column+(_i?0:1):N.indented+(_i?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var Lu=Ts({name:"javascript"}),Du=Ts({name:"json",json:!0}),rk=Ts({name:"json",jsonld:!0}),sk=Ts({name:"typescript",typescript:!0});function _0(n){return new RegExp("^(?:"+n.join("|")+")","i")}function Ms(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var G0=Ms(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),U0=Ms(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),Y0=Ms(["function","if","repeat","do","\\(","{"]),J0=Ms(["end","until","\\)","}"]),X0=_0(["end","until","\\)","}","else","elseif"]);function Ou(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function Xl(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=Eu(Ou(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=Z0(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=Eu(Ou(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function Eu(n,e){return function(t,i){for(var r=null,s;(s=t.next())!=null;)if(r==null)s=="]"&&(r=0);else if(s=="=")++r;else if(s=="]"&&r==n){i.cur=Xl;break}else r=null;return e}}function Z0(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=Xl),"string"}}var Bu={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:Xl}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(U0.test(i)?t="keyword":G0.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(Y0.test(i)?++e.indentDepth:J0.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=X0.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var Pu=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},Ru=document.createElement("span"),Q0=n=>(Ru.innerHTML=n,[...Ru.textContent].length===1),Ls=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[],this.tokenTable={...S.tokenTable};for(let t of Object.keys(e.tags))this.addTag(t)}get fileRegex(){let e=Object.entries(this.config.nsid).filter(([,t])=>t===6).map(([t])=>t).join("|");return new RegExp(`^\\s*(?:${e})\\s*:\\s*`,"iu")}addTag(e,t){var i,r;(i=this.tokenTable)[r=`mw-tag-${e}`]||(i[r]=Pe.define(t))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}${e==="templateName"?" cm-mw-pagename":""}`}))}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&Q0(`&${i[0]}`)?S.tags.htmlEntity:t}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold?S.tags.strong:""} ${this.isItalic?S.tags.em:""}`,t,i)}makeLocalStyle(e,t,i){let r="";switch(t.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(t.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}return t.nLink>0&&(r+="-link"),i&&t[i]--,(r&&`mw${r}-ground `)+e}inBlock(e,t,i=!0){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalStyle(e,s))}eatEnd(e){return(t,i)=>(t.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(e,i))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalStyle(S.tags.error,r))}inSectionHeader(e){return(t,i)=>t.match(/^[^&<[{~']+/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatEnd(S.tags.sectionHeader)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock(S.tags.sectionHeader,"<!--",!1)),this.makeLocalStyle(S.tags.section,i)):this.eatWikiText(S.tags.section)(t,i)}inVariable(e,t){return e.match(/^[^{}|]+/u)?this.makeLocalStyle(S.tags.templateVariableName,t):e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalStyle(S.tags.templateVariableDelimiter,t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,t)):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalStyle(S.tags.templateVariableBracket,t)):(e.next(),this.makeLocalStyle(S.tags.templateVariableName,t))}inVariableDefault(e){let t=S.tags[e?"templateVariable":"comment"];return(i,r)=>i.match(/^[^{}[<&~|]+/u)?this.makeStyle(t,r):i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,r)):i.eat("|")?(r.tokenize=this.inVariableDefault(!1),this.makeLocalStyle(S.tags.templateVariableDelimiter,r)):this.eatWikiText(t)(i,r)}inParserFunctionName(e,t){return e.match(/^[^:}{~|<>[\]]+/u)?this.makeLocalStyle(S.tags.parserFunctionName,t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(S.tags.parserFunctionDelimiter,t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.match(/^[^|}{[<&~]+/u)?this.makeLocalStyle(S.tags.parserFunction,t):e.eat("|")?this.makeLocalStyle(S.tags.parserFunctionDelimiter,t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.parserFunction)(e,t)}inTemplatePageName(e){return(t,i)=>t.match(/^\s*\|\s*/u)?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match(/^\s*\}\}/u)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):t.match(/^\s*<!--.*?-->/u)?this.makeLocalStyle(S.tags.comment,i):e&&t.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):t.match(/^\s*[^\s|&~{}<>[\]]+/u)?(i.tokenize=this.inTemplatePageName(!0),this.makeLocalStyle(S.tags.templateName,i)):t.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalStyle(S.tags.error,i):t.eatSpace()?this.makeLocalStyle(S.tags.templateName,i):this.eatWikiText(S.tags.templateName)(t,i)}inTemplateArgument(e){return(t,i)=>e&&t.eatWhile(/[^=|}{[<&~]/u)?t.eat("=")?(i.tokenize=this.inTemplateArgument(!1),this.makeLocalStyle(S.tags.templateArgumentName,i)):this.makeLocalStyle(S.tags.template,i):t.eatWhile(/[^|}{[<&~]/u)?this.makeLocalStyle(S.tags.template,i):t.eat("|")?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):this.eatWikiText(S.tags.template)(t,i)}eatExternalLinkProtocol(e){return(t,i)=>{for(let r=0;r<e;r++)t.next();return t.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(S.tags.extLinkProtocol,i)}}inExternalLink(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.match(/^\s*\]/u)?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.eatSpace()?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):e.match(/^[^\s\]{&~']+/u)?(e.peek()==="'"&&(e.match("''",!1)?t.tokenize=this.inExternalLinkText.bind(this):e.next()),this.makeLocalStyle(S.tags.extLink,t)):this.eatWikiText(S.tags.extLink)(e,t)}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.match(/^[^'\]{&~<]+/u)?this.makeStyle(S.tags.extLinkText,t):this.eatWikiText(S.tags.extLinkText)(e,t)}inLink(e){return(t,i)=>{if(t.sol())return i.nLink--,i.tokenize=i.stack.pop(),"";if(t.match(/^\s*#\s*/u))return i.tokenize=this.inLinkToSection(e),this.makeStyle(S.tags.link,i);if(t.match(/^\s*\|\s*/u))return i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i);if(t.match(/^\s*\]\]/u))return i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink");if(t.match(/^(?:[<>[\]}]|\{(?!\{))/u))return this.makeStyle(S.tags.error,i);let r=`${S.tags.linkPageName} ${S.tags.pageName}`;return t.match(/^[^#|[\]&~{}<>]+/u)?this.makeStyle(r,i):this.eatWikiText(r)(t,i)}}inLinkToSection(e){return(t,i)=>t.sol()?(i.nLink--,i.tokenize=i.stack.pop(),""):t.match(/^[^|\]&~{}]+/u)?this.makeStyle(S.tags.linkToSection,i):t.eat("|")?(i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i)):t.match("]]")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink")):this.eatWikiText(S.tags.linkToSection)(t,i)}inLinkText(e){let t,i;return(r,s)=>{let o=`${S.tags.linkText} ${t?S.tags.strong:""} ${i?S.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.tokenize=s.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,s,"nLink"));if(e&&r.eat("|"))return this.makeLocalStyle(S.tags.linkDelimiter,s);if(r.match("'''"))return t=!t,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);if(r.match("''"))return i=!i,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);let l=r.match(e?/^(?:[^'\]{&~<|[]|\[(?!\[))+/u:/^[^'\]{&~<]+/u);return l&&l[0].includes("[")&&(s.lbrack=!0),l?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}eatTagName(e,t,i){return(r,s)=>{let o="";for(let l=0;l<e;l++)o+=r.next();return r.eatSpace(),o=o.toLowerCase(),i?(s.tokenize=t?this.inChar(">",S.tags.htmlTagBracket):this.inHtmlTagAttribute(o),this.makeLocalStyle(S.tags.htmlTagName,s)):(s.tokenize=t?this.inChar(">",S.tags.extTagBracket):this.inExtTagAttribute(o),this.makeLocalStyle(S.tags.extTagName,s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^[^>/<{]+/u)?this.makeLocalStyle(S.tags.htmlTagAttribute,i):t.match(/^\/?>/u)?(S.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.push(e),i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.htmlTagBracket,i)):this.eatWikiText(S.tags.htmlTagAttribute)(t,i)}eatNowiki(){return e=>e.match(/^[^&]+/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^[^>/]+/u)?this.makeLocalStyle(S.tags.extTagAttribute,i):t.eat(">")?(i.extName=e,e==="nowiki"||e==="pre"?(i.extMode={startState:()=>({}),token:this.eatNowiki()},i.extState={}):e in this.config.tagModes&&(i.extMode=this[this.config.tagModes[e]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(e),this.makeLocalStyle(S.tags.extTagBracket,i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.extTagBracket,i)):this.eatWikiText(S.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu"),o=s.exec(r?t.string.slice(r):t.string),l=!1;if(o){if(o.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);let a=o.index+r;l=t.string,t.string=l.slice(0,a)}return i.stack.push(i.tokenize),i.tokenize=this.inExtTokens(l),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0,!1),this.makeLocalStyle(S.tags.extTagBracket,i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=S.tags.extTag,t.skipToEnd()):r=`mw-tag-${i.extName} ${i.extMode.token(t,i.extState)}`,t.eol()&&(e!==!1&&(t.string=e),i.tokenize=i.stack.pop()),r}}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):this.eatWikiText(S.tags.tableDefinition)(e,t)}inTableCaption(e,t){return e.sol()&&e.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1)?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):e.match(/^\s*(?:\||\{\{\s*!\s*\}\}){2}/u,!1)?(t.tokenize=this.inTableRow(!1,!1),""):this.eatWikiText(S.tags.tableCaption)(e,t)}inTable(e,t){if(e.sol()){if(e.eatSpace(),e.match(/^(?:\||\{\{\s*!\s*\}\})/u))return e.match(/^-+\s*/u)?(t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("+")?(e.eatSpace(),t.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.tableBracket,t)):(e.eatSpace(),t.tokenize=this.inTableRow(!0,!1),this.makeLocalStyle(S.tags.tableDelimiter,t));if(e.eat("!"))return e.eatSpace(),t.tokenize=this.inTableRow(!0,!0),this.makeLocalStyle(S.tags.tableDelimiter,t)}return this.eatWikiText("")(e,t)}inTableRow(e,t){return(i,r)=>{if(i.sol()){if(i.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return r.tokenize=this.inTable.bind(this),this.inTable(i,r)}else{if(i.match(/^[^'|{[<&~!]+/u))return this.makeStyle(t?S.tags.strong:"",r);if(i.match(/^(?:\||\{\{\s*!\s*\}\}){2}/u)||t&&i.match("!!")||e&&i.match(/^(?:\||\{\{\s*!\s*\}\})/u))return this.isBold=!1,this.isItalic=!1,e&&(r.tokenize=this.inTableRow(!1,t)),this.makeLocalStyle(S.tags.tableDelimiter,r)}return this.eatWikiText(t?S.tags.strong:"")(i,r)}}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,t)}inFreeExternalLink(e,t){if(!e.eol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u);if(t.lpar||(t.lpar=i[0].includes("(")),e.peek()==="~"){if(e.match(/^~{1,2}(?!~)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="{"){if(e.match(/^\{(?!\{)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="'"){if(e.match(/^'(?!')/u))return this.makeStyle(S.tags.freeExtLink,t)}else{if(t.lpar&&e.peek()===")")return e.next(),this.makeStyle(S.tags.freeExtLink,t);if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeStyle(S.tags.freeExtLink,t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeStyle(S.tags.freeExtLink,t)}eatWikiText(e){return(t,i)=>{let r;if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return i.stack.push(i.tokenize),i.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return S.tags.hr;break;case"=":{let o=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->.*\S).*)?)$/u);if(o)return t.backUp(o[2].length),i.stack.push(i.tokenize),i.tokenize=this.inSectionHeader(o[3].length),this.makeLocalStyle(`${S.tags.sectionHeader} ${S.tags[`sectionHeader${o[1].length+1}`]}`,i);break}case"*":case"#":case";":return t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case":":return t.match(/^:*(?:\{\||\{{3}\s*!\s*\}\})/u,!1)&&(i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this)),t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case" ":{let o=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(o){if(o[1])return i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this),this.makeLocalStyle(S.tags.list,i);t.eat("{")}else return S.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return i.stack.push(i.tokenize),i.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,i);break;default:}}else r=t.next();switch(r){case"&":return this.makeStyle(this.eatHtmlEntity(t,e),i);case"'":if(t.match(/^'*(?='{5})/u)||t.match(/^'''(?!')/u,!1))break;if(t.match("''"))return this.firstSingleLetterWord||t.match("''",!1)||this.prepareItalicForCorrection(t),this.isBold=!this.isBold,this.makeLocalStyle(S.tags.apostrophesBold,i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(S.tags.apostrophesItalic,i);break;case"[":if(t.eat("[")){if(t.eatSpace(),/[^\]|[]/u.test(t.peek()||""))return i.nLink++,i.stack.push(i.tokenize),i.lbrack=!1,i.tokenize=this.inLink(!!t.match(this.fileRegex,!1)),this.makeLocalStyle(S.tags.linkBracket,i)}else{let o=t.match(this.urlProtocols,!1);if(o)return i.nLink++,i.stack.push(i.tokenize),i.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(S.tags.extLinkBracket,i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/u))return t.eatSpace(),i.stack.push(i.tokenize),i.tokenize=this.inVariable.bind(this),this.makeLocalStyle(S.tags.templateVariableBracket,i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i);let o=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return o&&(o[2]===":"||o[4]===void 0||o[3]==="}}")&&(o[1].toLowerCase()in this.config.functionSynonyms[0]||o[1]in this.config.functionSynonyms[1])?(i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i)):(i.nTemplate++,i.stack.push(i.tokenize),i.tokenize=this.inTemplatePageName(!1),this.makeLocalStyle(S.tags.templateBracket,i))}break;case"<":{if(t.match("!--"))return i.stack.push(i.tokenize),i.tokenize=this.inBlock(S.tags.comment,"-->"),this.makeLocalStyle(S.tags.comment,i);let o=!!t.eat("/"),l=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/u);if(l){let a=l[0].toLowerCase();if(a in this.config.tags)return o?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!1),this.makeLocalStyle(S.tags.extTagBracket,i));if(S.permittedHtmlTags.has(a))return o&&a!==i.inHtmlTag.pop()?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):o&&S.implicitlyClosedHtmlTags.has(a)?this.makeLocalStyle(S.tags.error,i):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!0),this.makeLocalStyle(S.tags.htmlTagBracket,i));t.backUp(a.length)}break}case"~":if(t.match(/^~{2,4}/u))return S.tags.signature;break;case"_":{let o=1;for(;t.eat("_");)o++;if(o>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(o===2){let l=t.match(/^\w+?__/u);if(l)return`__${l[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${l[0]}`in this.config.doubleUnderscore[1]?S.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}default:if(/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//")))return i.stack.push(i.tokenize),i.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(e,i);break}return t.match(/^[^\s_>}[\]<{'|&:~=]+/u),this.makeStyle(e,i)}}prepareItalicForCorrection(e){let t=e.pos,i=e.string.slice(0,t-3),r=i.slice(-1),s=i.slice(-2,-1);if(r===" "){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=t}else if(s===" ")this.firstSingleLetterWord=t;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=t}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,lpar:!1,lbrack:!1}),copyState:e=>{let t=Pu(e);return e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i,r=null,s,o,l=[],a=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),e.pos=s.pos,s.style;e.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do if(i=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==r&&(r=o,l.length>0&&(a.push(...l),l=[])),l.push({pos:e.pos,style:i,state:(t.extMode&&t.extMode.copyState||Pu)(t)});else return this.oldStyle=i,i;while(!e.eol());if(this.isBold&&this.isItalic)if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,a.length>0)a[a.length-1].pos++,this.oldTokens=a;else return e.pos=l[0].pos-2,this.oldStyle||"";else this.oldTokens=[...a,...l];return s=this.oldTokens.shift(),e.pos=s.pos,s.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Nn))Object.defineProperty(Ls.prototype,n,{get(){return e}});var Zl=n=>{let e=new Ls(n),t=e.mediawiki,i=Ri.define(t),r=Kr(Pi.define(e.getTagStyles()));return new Bi(i,r)},Iu=n=>Zl({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"}});var Ql={plain:()=>[],mediawiki:Zl,html:Iu};for(let[n,e]of Object.entries(Nn))Ql[n]=()=>new Bi(Ri.define(e));var Ds={},eb={highlightSpecialChars:[bc,{}],highlightActiveLine:[kc,{}],highlightWhitespace:[Ac,{}],highlightTrailingWhitespace:[Tc,{}],bracketMatching:[Zc,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[mu,{}]},Os=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`https://testingcf.jsdelivr.net/${n}`,i.onload=()=>{t()},document.head.append(i)}),zn,Wi,qt,ji,qi,me,Nu=class{constructor(e,t="plain",i){Gt(this,zn,void 0);Gt(this,Wi,void 0);Gt(this,qt,void 0);Gt(this,ji,void 0);Gt(this,qi,void 0);Gt(this,me,void 0);Ut(this,zn,e),this.lang=t,Ut(this,Wi,new xt),Ut(this,qt,new xt),Ut(this,ji,new xt),Ut(this,qi,new xt);let r,s=[ee(this,Wi).of(Ql[t](i)),ee(this,qt).of([]),ee(this,ji).of([]),ee(this,qi).of(Ht.of(" ")),Kr(Uc),z.contentAttributes.of({accesskey:e.accessKey,dir:e.dir,lang:e.lang}),oe.readOnly.of(e.readOnly),Sc(),z.lineWrapping,pf(),_c(),Pr.of([...qf,...kf,...Qf]),z.updateListener.of(({state:{doc:p},docChanged:g})=>{g&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=p.toString()},400))})];Ut(this,me,new z({extensions:s,doc:e.value}));let{offsetHeight:o,selectionStart:l,selectionEnd:a,scrollTop:h}=e,{fontSize:c,lineHeight:f}=getComputedStyle(e),u=document.activeElement===e;e.parentNode.insertBefore(ee(this,me).dom,e),ee(this,me).dom.style.minHeight="2em",ee(this,me).dom.style.height=`${o}px`,ee(this,me).dom.style.fontSize=c,ee(this,me).scrollDOM.style.lineHeight=f,ee(this,me).requestMeasure(),ee(this,me).dispatch({selection:{anchor:l,head:a}}),e.style.display="none",u&&ee(this,me).focus(),window.requestAnimationFrame(()=>{ee(this,me).scrollDOM.scrollTop=h})}get textarea(){return ee(this,zn)}get view(){return ee(this,me)}setLanguage(e="plain",t){var i;ee(this,me).dispatch({effects:[ee(this,Wi).reconfigure(Ql[e](t)),ee(this,qt).reconfigure((i=Ds[e])!=null?i:[])]}),this.lang=e,(Ds[e]?Kl:In)(ee(this,me))}lint(e){let{lang:t}=this,i=e?[su(r=>e(r.state.doc)),fu()]:[];e?Ds[t]=i:delete Ds[t],ee(this,me).dispatch({effects:[ee(this,qt).reconfigure(i)]}),(e?Kl:In)(ee(this,me))}update(){let e=ee(this,qt).get(ee(this,me).state);if(e.length>0){let t=ee(this,me).plugin(e[0][1]);t.set=!0,t.force()}}prefer(e){let{lang:t}=this;ee(this,me).dispatch({effects:[ee(this,ji).reconfigure(e.map(i=>{let[r,s]=eb[i];return r(s[t])}))]})}setIndent(e){ee(this,me).dispatch({effects:[ee(this,qi).reconfigure(Ht.of(e))]})}async getLinter(){switch(this.lang){case"html":case"mediawiki":{await Os("combine/npm/wikiparser-node@1.3.0-b/extensions/dist/base.min.js,npm/wikiparser-node@1.3.0-b/extensions/dist/lint.min.js","wikiparse");let t=new wikiparse.Linter;return i=>t.codemirror(i.toString())}case"javascript":{await Os("npm/eslint-linter-browserify","eslint");let e=new eslint.Linter,t={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{}};for(let[i,{meta:r}]of e.getRules())r!=null&&r.docs.recommended&&(t.rules[i]=2);return i=>e.verify(i.toString(),t).map(({message:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>{let c=i.line(o).from+l-1;return{message:r,severity:s===1?"warning":"error",from:c,to:a===void 0?c+1:i.line(a).from+h-1}})}case"css":{await Os("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let e={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0}};return async t=>{let{results:i}=await stylelint.lint({code:t.toString(),config:e});return i.flatMap(({warnings:r})=>r).map(({text:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>({message:r,severity:s,from:t.line(o).from+l-1,to:a===void 0?t.line(o).to:t.line(a).from+h-1}))}}case"lua":return await Os("npm/luaparse","luaparse"),e=>{try{luaparse.parse(e.toString())}catch(t){if(t instanceof luaparse.SyntaxError)return[{message:t.message,severity:"error",from:t.index,to:t.index}]}return[]};default:return}}};zn=new WeakMap,Wi=new WeakMap,qt=new WeakMap,ji=new WeakMap,qi=new WeakMap,me=new WeakMap;export{Nu as CodeMirror6};
|
|
14
14
|
/**
|
|
15
15
|
* @author MusikAnimal and others
|
|
16
16
|
* @license GPL-2.0-or-later
|