rumdl 0.2.63

A fast Markdown linter and formatter written in Rust
Documentation
var Sr=[],Ma=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?Ma:Sr).push(t=t+i[e])})();function Rd(i){if(i<768)return!1;for(let e=0,t=Sr.length;;){let n=e+t>>1;if(i<Sr[n])t=n;else if(i>=Ma[n])e=n+1;else return!0;if(e==t)return!1}}function Sa(i){return i>=127462&&i<=127487}var Ca=8205;function La(i,e,t=!0,n=!0){return(t?Ta:Pd)(i,e,n)}function Ta(i,e,t){if(e==i.length)return e;e&&Da(i.charCodeAt(e))&&Ba(i.charCodeAt(e-1))&&e--;let n=vr(i,e);for(e+=Aa(n);e<i.length;){let s=vr(i,e);if(n==Ca||s==Ca||t&&Rd(s))e+=Aa(s),n=s;else if(Sa(s)){let r=0,o=e-2;for(;o>=0&&Sa(vr(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Pd(i,e,t){for(;e>1;){let n=Ta(i,e-2,t);if(n<e)return n;e--}return 0}function vr(i,e){let t=i.charCodeAt(e);if(!Ba(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Da(n)?(t-55296<<10)+(n-56320)+65536:t}function Da(i){return i>=56320&&i<57344}function Ba(i){return i>=55296&&i<56320}function Aa(i){return i<65536?1:2}var F=class i{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,n){[e,t]=hi(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),oi.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=hi(this,e,t);let n=[];return this.decompose(e,t,n,0),oi.from(n,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),n=this.length-this.scanIdentical(e,-1),s=new Ht(this),r=new Ht(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=n)return!0}}iter(e=1){return new Ht(this,e)}iterRange(e,t=this.length){return new Vn(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new zn(n)}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]?i.empty:e.length<=32?new Le(e):oi.from(Le.split(e,[]))}},Le=class i extends F{constructor(e,t=Nd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?n:l)>=e)return new Ar(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new i(Oa(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=Wn(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new i(l,o.length+r.length));else{let a=l.length>>1;n.push(new i(l.slice(0,a)),new i(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=hi(this,e,t);let s=Wn(this.text,Wn(n.text,Oa(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new i(s,r):oi.from(i.split(s,[]),r)}sliceString(e,t=this.length,n=`
`){[e,t]=hi(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=n),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let r of e)n.push(r),s+=r.length+1,n.length==32&&(t.push(new i(n,s)),n=[],s=-1);return s>-1&&t.push(new i(n,s)),t}},oi=class i extends F{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,s);s=l+1,n=a+1}}decompose(e,t,n,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?n.push(l):l.decompose(e-o,t-o,n,h)}o=a+1}}replace(e,t,n){if([e,t]=hi(this,e,t),n.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,n),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let f=this.children.slice();return f[s]=a,new i(f,this.length-(t-e)+n.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
`){[e,t]=hi(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=n),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,n)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return n;let a=this.children[s],h=e.children[r];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Le(d,t)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,f=[];function c(d){let p;if(d.lines>r&&d instanceof i)for(let m of d.children)c(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof Le&&a&&(p=f[f.length-1])instanceof Le&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,f[f.length-1]=new Le(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,f.push(d))}function u(){a!=0&&(l.push(f.length==1?f[0]:i.from(f,h)),h=-1,a=f.length=0)}for(let d of e)c(d);return u(),l.length==1?l[0]:new i(l,t)}};F.empty=new Le([""],0);function Nd(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Wn(i,e,t=0,n=1e9){for(let s=0,r=0,o=!0;r<i.length&&s<=n;r++){let l=i[r],a=s+l.length;a>=t&&(a>n&&(l=l.slice(0,n-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Oa(i,e,t){return Wn(i,[""],e,t)}var Ht=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 Le?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,l=s instanceof Le?s.text.length:s.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(s instanceof Le){let a=s.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Le?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)}},Vn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Ht(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}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 n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=n?s:t<0?s.slice(s.length-n):s.slice(0,n),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!=""}},zn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(F.prototype[Symbol.iterator]=function(){return this.iter()},Ht.prototype[Symbol.iterator]=Vn.prototype[Symbol.iterator]=zn.prototype[Symbol.iterator]=function(){return this});var Ar=class{constructor(e,t,n,s){this.from=e,this.to=t,this.number=n,this.text=s}get length(){return this.to-this.from}};function hi(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function oe(i,e,t=!0,n=!0){return La(i,e,t,n)}function Hd(i){return i>=56320&&i<57344}function Fd(i){return i>=55296&&i<56320}function je(i,e){let t=i.charCodeAt(e);if(!Fd(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Hd(n)?(t-55296<<10)+(n-56320)+65536:t}function Gn(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function wt(i){return i<65536?1:2}var Mr=/\r\n?|\n/,ce=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(ce||(ce={})),ht=class i{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 n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,s,r),s+=r):s+=o,n+=r}}iterChangedRanges(e,t=!1){Lr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];s<0?e.push(n,s):e.push(s,n)}return new i(e)}composeDesc(e){return this.empty?e:e.empty?this:Pa(this,e)}mapDesc(e,t=!1){return e.empty?this:Tr(this,e,t)}mapPos(e,t=-1,n=ce.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(n!=ce.Simple&&h>=e&&(n==ce.TrackDel&&s<e&&h>e||n==ce.TrackBefore&&s<e||n==ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let n=0,s=0;n<this.sections.length&&s<=t;){let r=this.sections[n++],o=this.sections[n++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},ge=class i extends ht{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 Lr(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return Tr(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;n.length<a;)n.push(F.empty);n.push(o?e.slice(r,r+o):F.empty)}r+=o}return new i(t,n)}compose(e){return this.empty?e:e.empty?this:Pa(this,e,!0)}map(e,t=!1){return e.empty?this:Tr(this,e,t,!0)}iterChanges(e,t=!1){Lr(this,e,t)}get desc(){return ht.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new Ft(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let f=Math.min(r.len,a-l);de(s,f,-1);let c=r.ins==-1?-1:r.off==0?r.ins:0;de(t,f,c),c>0&&yt(n,t,r.text),r.forward(f),l+=f}let h=e[o++];for(;l<h;){if(r.done)break e;let f=Math.min(r.len,h-l);de(t,f,-1),de(s,f,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(f),l+=f}}return{changes:new i(t,n),filtered:ht.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],s=this.sections[t+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let s=[],r=[],o=0,l=null;function a(f=!1){if(!f&&!s.length)return;o<t&&de(s,t-o,-1);let c=new i(s,r);l=l?l.compose(c.map(l)):c,s=[],r=[],o=0}function h(f){if(Array.isArray(f))for(let c of f)h(c);else if(f instanceof i){if(f.length!=t)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${t})`);a(),l=l?l.compose(f.map(l)):f}else{let{from:c,to:u=c,insert:d}=f;if(c>u||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?F.of(d.split(n||Mr)):d:F.empty,m=p.length;if(c==u&&m==0)return;c<o&&a(),c>o&&de(s,c-o,-1),de(s,u-c,m),yt(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;n.length<s;)n.push(F.empty);n[s]=F.of(r.slice(1)),t.push(r[0],n[s].length)}}}return new i(t,n)}static createSet(e,t){return new i(e,t)}};function de(i,e,t,n=!1){if(e==0&&t<=0)return;let s=i.length-2;s>=0&&t<=0&&t==i[s+1]?i[s]+=e:s>=0&&e==0&&i[s]==0?i[s+1]+=t:n?(i[s]+=e,i[s+1]+=t):i.push(e,t)}function yt(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(F.empty);i.push(t)}}function Lr(i,e,t){let n=i.inserted;for(let s=0,r=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,f=r,c=F.empty;for(;h+=l,f+=a,a&&n&&(c=c.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(s,h,r,f,c),s=h,r=f}}}function Tr(i,e,t,n=!1){let s=[],r=n?[]:null,o=new Ft(i),l=new Ft(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);de(s,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(de(s,l.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=f&&(de(s,0,o.ins),r&&yt(r,s,o.text),a=o.i),o.forward(f),h-=f}l.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);h+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;de(s,h,a<o.i?o.ins:0),r&&a<o.i&&yt(r,s,o.text),a=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return r?ge.createSet(s,r):ht.create(s);throw new Error("Mismatched change set lengths")}}}function Pa(i,e,t=!1){let n=[],s=t?[]:null,r=new Ft(i),o=new Ft(e);for(let l=!1;;){if(r.done&&o.done)return s?ge.createSet(n,s):ht.create(n);if(r.ins==0)de(n,r.len,0,l),r.next();else if(o.len==0&&!o.done)de(n,0,o.ins,l),s&&yt(s,n,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=n.length;if(r.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;de(n,a,f,l),s&&f&&yt(s,n,o.text)}else o.ins==-1?(de(n,r.off?0:r.len,a,l),s&&yt(s,n,r.textBit(a))):(de(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&yt(s,n,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>h),r.forward2(a),o.forward(a)}}}}var Ft=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?F.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?F.empty:t[n].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)}},Rt=class i{constructor(e,t,n,s){this.from=e,this.to=t,this.flags=n,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new i(n,s,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.range(this.anchor,s,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return w.range(e.anchor,e.head)}static create(e,t,n,s){return new i(e,t,n,s)}},w=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new i([this.main],0)}addRange(e,t=!0){return i.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,i.create(n,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 i(e.ranges.map(t=>Rt.fromJSON(t)),e.main)}static single(e,t=e){return new i([i.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 n=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=n:r.from<n)return i.normalized(e.slice(),t);n=r.to}return new i(e,t)}static cursor(e,t=0,n,s){return Rt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),s)}static range(e,t,n,s,r){let o=s==null?7:Math.min(6,s);return!r&&e!=t&&(r=t<e?1:-1),r&&(o|=r<0?8:16),t<e?Rt.create(t,e,o|32,n):Rt.create(e,t,o,n)}static undirectionalRange(e,t){return Rt.create(e,t,64,void 0)}static normalized(e,t=0){let n=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(n);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?i.range(a,l):i.range(l,a))}}return new i(e,t)}};function Na(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Hr=0,L=class i{constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=Hr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new i(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Fr),!!e.static,e.enables)}of(e){return new li([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new li(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new li(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Fr(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var li=class{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=Hr++}dynamicSlot(e){var t;let n=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:(((t=e[c.id])!==null&&t!==void 0?t:1)&1)==0&&f.push(e[c.id]);return{create(c){return c.values[o]=n(c),1},update(c,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Dr(c,f)){let d=n(c);if(l?!Ea(d,c.values[o],s):!s(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Kn(u,p);if(this.dependencies.every(g=>g instanceof L?u.facet(g)===c.facet(g):g instanceof te?u.field(g,!1)==c.field(g,!1):!0)||(l?Ea(d=n(c),m,s):s(d=n(c),m)))return c.values[o]=m,0}else d=n(c);return c.values[o]=d,1}}}get extension(){return this}};function Ea(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function Dr(i,e){let t=!1;for(let n of e)Pi(i,n)&1&&(t=!0);return t}function Wd(i,e,t){let n=t.map(a=>i[a.id]),s=t.map(a=>a.type),r=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let h=[];for(let f=0;f<n.length;f++){let c=Kn(a,n[f]);if(s[f]==2)for(let u of c)h.push(u);else h.push(c)}return e.combine(h)}return{create(a){for(let h of n)Pi(a,h);return a.values[o]=l(a),1},update(a,h){if(!Dr(a,r))return 0;let f=l(a);return e.compare(f,a.values[o])?0:(a.values[o]=f,1)},reconfigure(a,h){let f=Dr(a,n),c=h.config.facets[e.id],u=h.facet(e);if(c&&!f&&Fr(t,c))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}var Nn=L.define({static:!0}),te=class i{constructor(e,t,n,s,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new i(Hr++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Nn).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,s)=>{let r=n.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(n.values[t]=o,1)},reconfigure:(n,s)=>{let r=n.facet(Nn),o=s.facet(Nn),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):s.config.address[this.id]!=null?(n.values[t]=s.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,Nn.of({field:this,create:e})]}get extension(){return this}},Pt={lowest:4,low:3,default:2,high:1,highest:0};function Ri(i){return e=>new qn(e,i)}var ft={highest:Ri(Pt.highest),high:Ri(Pt.high),default:Ri(Pt.default),low:Ri(Pt.low),lowest:Ri(Pt.lowest)},qn=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},$n=class i{of(e){return new Ni(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Ni=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},jn=class i{constructor(e,t,n,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.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,n){let s=[],r=Object.create(null),o=new Map;for(let u of Vd(e,t,o))u instanceof te?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let f=n?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=f&&f[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Fr(m,d))a.push(n.facet(p));else{let g=p.combine(d.map(b=>b.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(b=>g.dynamicSlot(b)));l[p.id]=h.length<<1,h.push(g=>Wd(g,p,d))}}let c=h.map(u=>u(l));return new i(e,o,c,l,a,r)}};function Vd(i,e,t){let n=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof Ni&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Ni){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),r(h,l)}else if(o instanceof qn)r(o.inner,o.prec);else if(o instanceof te)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof li)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,Pt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(i,Pt.default),n.reduce((o,l)=>o.concat(l))}function Pi(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let s=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|s}function Kn(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var Ha=L.define(),Br=L.define({combine:i=>i.some(e=>e),static:!0}),Fa=L.define({combine:i=>i.length?i[0]:void 0,static:!0}),Wa=L.define(),Va=L.define(),za=L.define(),qa=L.define({combine:i=>i.length?i[0]:!1}),be=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Or}},Or=class{of(e){return new be(this,e)}},Er=class{constructor(e){this.map=e}of(e){return new R(this,e)}},R=class i{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 i(this.type,t)}is(e){return this.type==e}static define(e={}){return new Er(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let s of e){let r=s.map(t);r&&n.push(r)}return n}};R.reconfigure=R.define();R.appendConfig=R.define();var se=class i{constructor(e,t,n,s,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Na(n,t.newLength),r.some(l=>l.type==i.time)||(this.annotations=r.concat(i.time.of(Date.now())))}static create(e,t,n,s,r,o){return new i(e,t,n,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(i.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};se.time=be.define();se.userEvent=be.define();se.addToHistory=be.define();se.remote=be.define();function zd(i,e){let t=[];for(let n=0,s=0;;){let r,o;if(n<i.length&&(s==e.length||e[s]>=i[n]))r=i[n++],o=i[n++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function $a(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=ge.empty(e.changes.length),o=i.changes.compose(e.changes)):(s=e.changes.map(i.changes),r=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(n=i.selection)===null||n===void 0?void 0:n.map(s),effects:R.mapEffects(i.effects,s).concat(R.mapEffects(e.effects,r)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function Ir(i,e,t){let n=e.selection,s=ai(e.annotations);return e.userEvent&&(s=s.concat(se.userEvent.of(e.userEvent))),{changes:e.changes instanceof ge?e.changes:ge.of(e.changes||[],t,i.facet(Fa)),selection:n&&(n instanceof w?n:w.single(n.anchor,n.head)),effects:ai(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function ja(i,e,t){let n=Ir(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;n=$a(n,Ir(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=se.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return $d(t?qd(s):s)}function qd(i){let e=i.startState,t=!0;for(let s of e.facet(Wa)){let r=s(i);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:zd(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=ge.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=se.create(e,s,i.selection&&i.selection.map(r),R.mapEffects(i.effects,r),i.annotations,i.scrollIntoView)}let n=e.facet(Va);for(let s=n.length-1;s>=0;s--){let r=n[s](i);r instanceof se?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof se?i=r[0]:i=ja(e,ai(r),!1)}return i}function $d(i){let e=i.startState,t=e.facet(za),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=$a(n,Ir(e,r,i.changes.newLength),!0))}return n==i?i:se.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var jd=[];function ai(i){return i==null?jd:Array.isArray(i)?i:[i]}var U=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(U||(U={})),Kd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,_r;try{_r=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ud(i){if(_r)return _r.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Kd.test(t)))return!0}return!1}function Gd(i){return e=>{if(!/\S/.test(e))return U.Space;if(Ud(e))return U.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return U.Word;return U.Other}}var G=class i{constructor(e,t,n,s,r,o){this.config=e,this.doc=t,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Pi(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Pi(this,n),Kn(this,n)}update(...e){return ja(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is($n.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(R.reconfigure)?(t=null,n=l.value):l.is(R.appendConfig)&&(t=null,n=ai(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=jn.resolve(n,s,this),r=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Br)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:w.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),s=this.changes(n.changes),r=[n.range],o=ai(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),f=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(f);let c=s.mapDesc(h,!0);r.push(a.range.map(c)),s=s.compose(f),o=R.mapEffects(o,f).concat(R.mapEffects(ai(a.effects),c))}return{changes:s,selection:w.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ge?e:ge.of(e,this.doc.length,this.facet(i.lineSeparator))}toText(e){return F.of(e.split(this.facet(i.lineSeparator)||Mr))}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:(Pi(this,t),Kn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof te&&this.config.address[s.id]!=null&&(t[n]=s.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let r in n)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return i.create({doc:e.doc,selection:w.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=jn.resolve(e.extensions||[],new Map),n=e.doc instanceof F?e.doc:F.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||Mr)),s=e.selection?e.selection instanceof w?e.selection:w.single(e.selection.anchor,e.selection.head):w.single(0);return Na(s,n.length),t.staticFacet(Br)||(s=s.asSingle()),new i(t,n,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||`
`}get readOnly(){return this.facet(qa)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?n:t[r-1]})),e}languageDataAt(e,t,n=-1){let s=[];for(let r of this.facet(Ha))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Gd(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=oe(t,o,!1);if(r(t.slice(a,o))!=U.Word)break;o=a}for(;l<s;){let a=oe(t,l);if(r(t.slice(l,a))!=U.Word)break;l=a}return o==l?null:w.range(o+n,l+n)}};G.allowMultipleSelections=Br;G.tabSize=L.define({combine:i=>i.length?i[0]:4});G.lineSeparator=Fa;G.readOnly=qa;G.phrases=L.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(s=>i[s]==e[s])}});G.languageData=Ha;G.changeFilter=Wa;G.transactionFilter=Va;G.transactionExtender=za;$n.reconfigure=R.define();function ye(i,e,t={}){let n={};for(let s of i)for(let r of Object.keys(s)){let o=s[r],l=n[r];if(l===void 0)n[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))n[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)n[s]===void 0&&(n[s]=e[s]);return n}var Pe=class{eq(e){return this==e}range(e,t=e){return Hi.create(e,t,this)}};Pe.prototype.startSide=Pe.prototype.endSide=0;Pe.prototype.point=!1;Pe.prototype.mapMode=ce.TrackDel;function Wr(i,e){return i==e||i.constructor==e.constructor&&i.eq(e)}var Hi=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function Rr(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Pr=class i{constructor(e,t,n,s){this.from=e,this.to=t,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,s=0){let r=n?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(n?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,n,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let n=[],s=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],f=this.from[a]+e,c=this.to[a]+e,u,d;if(f==c){let p=t.mapPos(f,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(f,h.endSide),d<u)))continue}else if(u=t.mapPos(f,h.startSide),d=t.mapPos(c,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),n.push(h),s.push(u-o),r.push(d-o))}return{mapped:n.length?new i(s,r,n,l):null,pos:o}}},V=class i{constructor(e,t,n,s){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=s}static create(e,t,n,s){return new i(e,t,n,s)}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:n=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Rr)),this.isEmpty)return t.length?i.of(t):this;let l=new Un(this,null,-1).goto(0),a=0,h=[],f=new Ne;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let c=t[a++];f.addInner(c.from,c.to,c.value)||h.push(c)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&f.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(f.addInner(l.from,l.to,l.value)||h.push(Hi.create(l.from,l.to,l.value))),l.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?i.empty:this.nextLayer.update({add:h,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],s=-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)s=Math.max(s,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(h===!0){let{mapped:f,pos:c}=a.map(l,e);f&&(s=Math.max(s,f.maxPoint),t.push(f),n.push(c))}}let r=this.nextLayer.map(e);return t.length==0?r:new i(n,t,r||i.empty,s)}between(e,t,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Fi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Fi.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),l=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),a=Ia(o,l,n),h=new Nt(o,a,r),f=new Nt(l,a,r);n.iterGaps((c,u,d)=>_a(h,c,f,u,d,s)),n.empty&&n.length==0&&_a(h,0,f,0,0,s)}static eq(e,t,n=0,s){s==null&&(s=999999999);let r=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),o=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Ia(r,o),a=new Nt(r,l,0).goto(n),h=new Nt(o,l,0).goto(n);for(;;){if(a.to!=h.to||!Nr(a.active,h.active)||a.point&&(!h.point||!Wr(a.point,h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,n,s,r=-1){let o=new Nt(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFrom<t?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,a);s.point(l,h,o.point,f,c,o.pointRank),a=Math.min(o.openEnd(h),f.length)}else h>l&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Ne;for(let s of e instanceof Hi?[e]:t?Xd(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=i.empty;s=s.nextLayer)t=new i(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}};V.empty=new V([],[],null,-1);function Xd(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(Rr(e,n)>0)return i.slice().sort(Rr);e=n}return i}V.empty.nextLayer=V.empty;var Ne=class i{finishChunk(e){this.chunks.push(new Pr(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,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,n)}addInner(e,t,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<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=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.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 n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(V.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=V.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Ia(i,e,t){let n=new Map;for(let r of i)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&n.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=n.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!t?.touchesRange(l,l+r.chunk[o].length)&&s.add(r.chunk[o])}return s}var Un=class{constructor(e,t,n,s=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=s}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,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}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],n=e+t.from[this.rangeIndex];if(this.from=n,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}},Fi=class i{constructor(e){this.heap=e}static from(e,t=null,n=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&s.push(new Un(o,t,n,r));return s.length==1?s[0]:new i(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Cr(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Cr(this.heap,n);(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(),Cr(this.heap,0)}}};function Cr(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let s=i[n];if(n+1<i.length&&s.compare(i[n+1])>=0&&(s=i[n+1],n++),t.compare(s)<0)break;i[n]=t,i[e]=s,e=n}}var Nt=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Fi.from(e,t,n)}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){Hn(this.active,e),Hn(this.activeTo,e),Hn(this.activeRank,e),this.minActive=Ra(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;Fn(this.active,t,n),Fn(this.activeTo,t,s),Fn(this.activeRank,t,r),e&&Fn(e,t,this.cursor.from),this.minActive=Ra(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&Hn(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function _a(i,e,t,n,s,r){i.goto(e),t.goto(n);let o=n+s,l=n,a=n-e,h=!!r.boundChange;for(let f=!1;;){let c=i.to+a-t.to,u=c||i.endSide-t.endSide,d=u<0?i.to+a:t.to,p=Math.min(d,o);if(i.point||t.point?(i.point&&t.point&&Wr(i.point,t.point)&&Nr(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,p,i.point,t.point),f=!1):(f&&r.boundChange(l),p>l&&!Nr(i.active,t.active)&&r.compareRange(l,p,i.active,t.active),h&&p<o&&(c||i.openEnd(d)!=t.openEnd(d))&&(f=!0)),d>o)break;l=d,u<=0&&i.next(),u>=0&&t.next()}}function Nr(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!Wr(i[t],e[t]))return!1;return!0}function Hn(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function Fn(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Ra(i,e){let t=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||i[s].endSide-i[t].endSide)<0&&(t=s,n=e[s]);return t}function ct(i,e,t=i.length){let n=0;for(let s=0;s<t&&s<i.length;)i.charCodeAt(s)==9?(n+=e-n%e,s++):(n++,s=oe(i,s));return n}function Xn(i,e,t,n){for(let s=0,r=0;;){if(r>=e)return s;if(s==i.length)break;r+=i.charCodeAt(s)==9?t-r%t:1,s=oe(i,s)}return n===!0?-1:i.length}var Ka=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),Vr=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ua=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},He=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let f=[],c=/^@(\w+)\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,f,u)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(f.length||u)&&a.push((n&&!c&&!h?o.map(n):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=Ua[Ka]||1;return Ua[Ka]=e+1,"\u037C"+e.toString(36)}static mount(e,t,n){let s=e[Vr],r=n&&n.nonce;s?r&&s.setNonce(r):s=new zr(e,r),s.mount(Array.isArray(t)?t:[t],e)}},Ga=new Map,zr=class{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=Ga.get(n);if(r)return e[Vr]=r;this.sheet=new s.CSSStyleSheet,Ga.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Vr]=this}mount(e,t){let n=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),n)for(let h=0;h<l.rules.length;h++)n.insertRule(l.rules[h],s++)}else{for(;r<a;)s+=this.modules[r++].rules.length;s+=l.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var ut={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:"'"},fi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Jd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(le=0;le<10;le++)ut[48+le]=ut[96+le]=String(le);var le;for(le=1;le<=24;le++)ut[le+111]="F"+le;var le;for(le=65;le<=90;le++)ut[le]=String.fromCharCode(le+32),fi[le]=String.fromCharCode(le);var le;for(Yn in ut)fi.hasOwnProperty(Yn)||(fi[Yn]=ut[Yn]);var Yn;function Xa(i){var e=Yd&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Jd&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?fi:ut)[i.keyCode]||i.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 q(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var s=t[n];typeof s=="string"?i.setAttribute(n,s):s!=null&&(i[n]=s)}e++}for(;e<arguments.length;e++)Ya(i,arguments[e]);return i}function Ya(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Ya(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}var we=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Qr=typeof document<"u"?document:{documentElement:{style:{}}},Zr=/Edge\/(\d+)/.exec(we.userAgent),Ph=/MSIE \d/.test(we.userAgent),eo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(we.userAgent),Ls=!!(Ph||eo||Zr),Ja=!Ls&&/gecko\/(\d+)/i.test(we.userAgent),qr=!Ls&&/Chrome\/(\d+)/.exec(we.userAgent),Qa="webkitFontSmoothing"in Qr.documentElement.style,to=!Ls&&/Apple Computer/.test(we.vendor),Za=to&&(/Mobile\/\w+/.test(we.userAgent)||we.maxTouchPoints>2),T={mac:Za||/Mac/.test(we.platform),windows:/Win/.test(we.platform),linux:/Linux|X11/.test(we.platform),ie:Ls,ie_version:Ph?Qr.documentMode||6:eo?+eo[1]:Zr?+Zr[1]:0,gecko:Ja,gecko_version:Ja?+(/Firefox\/(\d+)/.exec(we.userAgent)||[0,0])[1]:0,chrome:!!qr,chrome_version:qr?+qr[1]:0,ios:Za,android:/Android\b/.test(we.userAgent),webkit:Qa,webkit_version:Qa?+(/\bAppleWebKit\/(\d+)/.exec(we.userAgent)||[0,0])[1]:0,safari:to,safari_version:to?+(/\bVersion\/(\d+(\.\d+)?)/.exec(we.userAgent)||[0,0])[1]:0,tabSize:Qr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Xo(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}var fs=Object.create(null);function Yo(i,e,t){if(i==e)return!0;i||(i=fs),e||(e=fs);let n=Object.keys(i),s=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of n)if(r!=t&&(s.indexOf(r)==-1||i[r]!==e[r]))return!1;return!0}function Qd(i,e){for(let t=i.attributes.length-1;t>=0;t--){let n=i.attributes[t].name;e[n]==null&&i.removeAttribute(n)}for(let t in e){let n=e[t];t=="style"?i.style.cssText=n:i.getAttribute(t)!=n&&i.setAttribute(t,n)}}function eh(i,e,t){let n=!1;if(e)for(let s in e)t&&s in t||(n=!0,s=="style"?i.style.cssText="":i.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(n=!0,s=="style"?i.style.cssText=t[s]:i.setAttribute(s,t[s]));return n}function Zd(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}var De=class{eq(e){return!1}updateDOM(e,t,n){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,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},ue=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(ue||(ue={})),O=class extends Pe{constructor(e,t,n,s){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new Zi(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new qt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:r,end:o}=Nh(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new qt(e,n,s,t,e.widget||null,!0)}static line(e){return new en(e)}static set(e,t=!1){return V.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};O.none=V.empty;var Zi=class i extends O{constructor(e){let{start:t,end:n}=Nh(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Xo(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||fs}eq(e){return this==e||e instanceof i&&this.tagName==e.tagName&&Yo(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Zi.prototype.point=!1;var en=class i extends O{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&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)}};en.prototype.mapMode=ce.TrackBefore;en.prototype.point=!0;var qt=class i extends O{constructor(e,t,n,s,r,o){super(t,n,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?ce.TrackBefore:ce.TrackAfter:ce.TrackDel}get type(){return this.startSide!=this.endSide?ue.WidgetRange:this.startSide<=0?ue.WidgetBefore:ue.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&ep(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)}};qt.prototype.point=!0;function Nh(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function ep(i,e){return i==e||!!(i&&e&&i.compare(e))}function gi(i,e,t,n=0){let s=t.length-1;s>=0&&t[s]+n>=i?t[s]=Math.max(t[s],e):t.push(i,e)}var cs=class i extends Pe{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(e){return e==this||e instanceof i&&this.tagName==e.tagName&&Yo(this.attributes,e.attributes)}static create(e){return new i(e.tagName,e.attributes||fs,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return V.of(e,t)}};cs.prototype.startSide=cs.prototype.endSide=-1;function tn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function io(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function qi(i,e){if(!e.anchorNode)return!1;try{return io(i,e.anchorNode)}catch{return!1}}function $i(i){return i.nodeType==3?sn(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function ji(i,e,t,n){return t?th(i,e,t,n,-1)||th(i,e,t,n,1):!1}function vt(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function us(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function th(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:mt(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=vt(i)+(s<0?0:1),i=r}else if(i.nodeType==1){if(i=i.childNodes[e+(s<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=s<0?mt(i):0}else return!1}}function mt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function nn(i,e){let{left:t,right:n}=i;if(t==n)return i;let s=e?t:n;return{left:s,right:s,top:i.top,bottom:i.bottom}}function tp(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function Hh(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function ip(i,e,t,n,s,r,o,l){let a=i.ownerDocument,h=a.defaultView||window;for(let f=i,c=!1;f&&!c;)if(f.nodeType==1){let u,d=f==a.body,p=1,m=1;if(d)u=tp(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let k=f.getBoundingClientRect();({scaleX:p,scaleY:m}=Hh(f,k)),u={left:k.left,right:k.left+f.clientWidth*p,top:k.top,bottom:k.top+f.clientHeight*m}}let g=0,b=0;if(s=="nearest")e.top<u.top+o?(b=e.top-(u.top+o),t>0&&e.bottom>u.bottom+b&&(b=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(b=e.bottom-u.bottom+o,t<0&&e.top-b<u.top&&(b=e.top-(u.top+o)));else{let k=e.bottom-e.top,x=u.bottom-u.top;b=(s=="center"&&k<=x?e.top+k/2-x/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(n=="nearest"?e.left<u.left+r?(g=e.left-(u.left+r),t>0&&e.right>u.right+g&&(g=e.right-u.right+r)):e.right>u.right-r&&(g=e.right-u.right+r,t<0&&e.left<u.left+g&&(g=e.left-(u.left+r))):g=(n=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:n=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left,g||b)if(d)h.scrollBy(g,b);else{let k=0,x=0;if(b){let B=f.scrollTop;f.scrollTop+=b/m,x=(f.scrollTop-B)*m}if(g){let B=f.scrollLeft;f.scrollLeft+=g/p,k=(f.scrollLeft-B)*p}e={left:e.left-k,top:e.top-x,right:e.right-k,bottom:e.bottom-x},k&&Math.abs(k-g)<1&&(n="nearest"),x&&Math.abs(x-b)<1&&(s="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function Fh(i,e=!0){let t=i.ownerDocument,n=null,s=null;for(let r=i.parentNode;r&&!(r==t.body||(!e||n)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:n,y:s}}var no=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:n}=e;this.set(t,Math.min(e.anchorOffset,t?mt(t):0),n,Math.min(e.focusOffset,n?mt(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}};function Wh(i){let e=[];for(let t=i;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Vh(i,e=!0){for(let{node:t,left:n,top:s}of i)e&&t.scrollTop!=s&&(t.scrollTop=s),t.scrollLeft!=n&&(t.scrollLeft=n)}var Wt=null;T.safari&&T.safari_version>=26&&(Wt=!1);function zh(i){if(i.setActive)return i.setActive();if(Wt)return i.focus(Wt);let e=Wh(i);i.focus(Wt==null?{get preventScroll(){return Wt={preventScroll:!0},!0}}:void 0),Wt||(Wt=!1,Vh(e))}var ih;function sn(i,e,t=e){let n=ih||(ih=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function bi(i,e,t,n){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,i.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,i.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function np(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function sp(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,mt(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=mt(t))}else{if(t==i)return!0;n=vt(t),t=t.parentNode}}function qh(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function $h(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=mt(t)}else if(t.parentNode&&!us(t))n=vt(t),t=t.parentNode;else return null}}function jh(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!us(t))n=vt(t)+1,t=t.parentNode;else return null}}var it=class i{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new i(e.parentNode,vt(e),t)}static after(e,t){return new i(e.parentNode,vt(e)+1,t)}},K=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(K||(K={})),$t=K.LTR,Jo=K.RTL;function Kh(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}var rp=Kh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),op=Kh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),so=Object.create(null),tt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);so[e]=t,so[t]=-e}function Uh(i){return i<=247?rp[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?op[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}var lp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Ve=class{get dir(){return this.level%2?Jo:$t}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}};function Gh(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],s=e[t];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!Gh(n.inner,s.inner))return!1}return!0}var J=[];function ap(i,e,t,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t,a=r?256:s;for(let h=o,f=a,c=a;h<l;h++){let u=Uh(i.charCodeAt(h));u==512?u=f:u==8&&c==4&&(u=16),J[h]=u==4?2:u,u&7&&(c=u),f=u}for(let h=o,f=a,c=a;h<l;h++){let u=J[h];if(u==128)h<l-1&&f==J[h+1]&&f&24?u=J[h]=f:J[h]=256;else if(u==64){let d=h+1;for(;d<l&&J[d]==64;)d++;let p=h&&f==8||d<t&&J[d]==8?c==1?1:8:256;for(let m=h;m<d;m++)J[m]=p;h=d-1}else u==8&&c==1&&(J[h]=1);f=u,u&7&&(c=u)}}}function hp(i,e,t,n,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,f=o<n.length?n[o].from:t;for(let c=h,u,d,p;c<f;c++)if(d=so[u=i.charCodeAt(c)])if(d<0){for(let m=l-3;m>=0;m-=3)if(tt[m+1]==-d){let g=tt[m+2],b=g&2?s:g&4?g&1?r:s:0;b&&(J[c]=J[tt[m]]=b),l=m;break}}else{if(tt.length==189)break;tt[l++]=c,tt[l++]=u,tt[l++]=a}else if((p=J[c])==2||p==1){let m=p==s;a=m?0:1;for(let g=l-3;g>=0;g-=3){let b=tt[g+2];if(b&2)break;if(m)tt[g+2]|=2;else{if(b&4)break;tt[g+2]|=4}}}}}function fp(i,e,t,n){for(let s=0,r=n;s<=t.length;s++){let o=s?t[s-1].to:i,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let h=J[a];if(h==256){let f=a+1;for(;;)if(f==l){if(s==t.length)break;f=t[s++].to,l=s<t.length?t[s].from:e}else if(J[f]==256)f++;else break;let c=r==1,u=(f<e?J[f]:n)==1,d=c==u?c?1:2:n;for(let p=f,m=s,g=m?t[m-1].to:i;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),J[--p]=d;a=f}else r=h,a++}}}function ro(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,h=0;a<t;){let f=!0,c=!1;if(h==r.length||a<r[h].from){let m=J[a];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?n:n+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(c)break e;let m=r[h];if(!f)for(let g=m.to,b=h+1;;){if(g==t)break e;if(b<r.length&&r[b].from==g)g=r[b++].to;else{if(J[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Ve(a,m.from,d));let g=m.direction==$t!=!(d%2);oo(i,g?n+1:n,s,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(f?J[p]!=l:J[p]==l))break;p++}u?ro(i,a,p,n+1,s,u,o):a<p&&o.push(new Ve(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let f=!0,c=!1;if(!h||a>r[h-1].to){let m=J[a-1];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?n:n+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(c)break e;let m=r[--h];if(!f)for(let g=m.from,b=h;;){if(g==e)break e;if(b&&r[b-1].to==g)g=r[--b].from;else{if(J[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Ve(m.to,a,d));let g=m.direction==$t!=!(d%2);oo(i,g?n+1:n,s,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(f?J[p-1]!=l:J[p-1]==l))break;p--}u?ro(i,p,a,n+1,s,u,o):p<a&&o.push(new Ve(p,a,d)),a=p}}function oo(i,e,t,n,s,r,o){let l=e%2?2:1;ap(i,s,r,n,l),hp(i,s,r,n,l),fp(s,r,n,l),ro(i,s,r,e,t,n,o)}function cp(i,e,t){if(!i)return[new Ve(0,0,e==Jo?1:0)];if(e==$t&&!t.length&&!lp.test(i))return Xh(i.length);if(t.length)for(;i.length>J.length;)J[J.length]=256;let n=[],s=e==$t?0:1;return oo(i,s,s,t,0,i.length,n),n}function Xh(i){return[new Ve(0,i,0)]}var Yh="";function up(i,e,t,n,s){var r;let o=n.head-i.from,l=Ve.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),a=e[l],h=a.side(s,t);if(o==h){let u=l+=s?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!s,t),h=a.side(s,t)}let f=oe(i.text,o,a.forward(s,t));(f<a.from||f>a.to)&&(f=h),Yh=i.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return c&&f==h&&c.level+(s?0:1)<a.level?w.cursor(c.side(!s,t)+i.from,c.forward(s,t)?1:-1,c.level):w.cursor(f+i.from,a.forward(s,t)?-1:1,a.level)}function dp(i,e,t){for(let n=e;n<t;n++){let s=Uh(i.charCodeAt(n));if(s==1)return $t;if(s==2||s==4)return Jo}return $t}var Jh=L.define(),Qh=L.define(),Zh=L.define(),ef=L.define(),lo=L.define(),tf=L.define(),nf=L.define(),Qo=L.define(),Zo=L.define(),sf=L.define({combine:i=>i.some(e=>e)}),rf=L.define({combine:i=>i.some(e=>e)}),of=L.define(),Ki=class i{constructor(e,t,n,s,r,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new i(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 i(w.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Jn=R.define({map:(i,e)=>i.map(e)}),lf=R.define();function Ce(i,e,t){let n=i.facet(ef);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var dt=L.define({combine:i=>i.length?i[0]:!0}),pp=0,ui=L.define({combine(i){return i.filter((e,t)=>{for(let n=0;n<t;n++)if(i[n].plugin==e.plugin)return!1;return!0})}}),ne=class i{constructor(e,t,n,s,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(ui.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(ui.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new i(pp++,e,n,s,l=>{let a=[];return o&&a.push(Ds.of(h=>{let f=h.plugin(l);return f?o(f):O.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return i.define((n,s)=>new e(n,s),t)}},Ui=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}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(n){if(Ce(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ce(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(n){Ce(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},af=L.define(),Ts=L.define(),Ds=L.define(),hf=L.define(),el=L.define(),rn=L.define(),ff=L.define();function nh(i,e){let t=i.state.facet(ff);if(!t.length)return t;let n=t.map(r=>r instanceof Function?r(i):r),s=[];return V.spans(n,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,f=o-e.from,c=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=dp(e.text,h,f)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let m={from:h,to:f,direction:d,inner:[]};c.push(m),c=m.inner}}}}),s}var cf=L.define();function tl(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(cf)){let o=r(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:n,bottom:s}}var Wi=L.define(),Ue=class i{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new i(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,n=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>n.toA)){if(s.toA<n.fromA)break;n=n.join(s),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let s=0,r=0,o=0;;){let l=s<e.length?e[s].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let f=h+o,c=h,u=f;for(;;)if(r<t.length&&t[r]<=c){let d=t[r+1];r+=2,c=Math.max(c,d);for(let p=s;p<e.length&&e[p].fromB<=c;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(s<e.length&&e[s].fromB<=c){let d=e[s++];c=Math.max(c,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;n.push(new i(f,u,h,c))}return n}},ds=class i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ge.empty(this.startState.doc.length);for(let r of n)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Ue(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},mp=[],ie=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return mp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Qd(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let s of this.children){if(s==e)return n;n+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=vt(this.dom),s=this.length?e>0:t>0;return new it(this.parent.dom,n+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof wi)return e;return null}static get(e){return e.cmTile}},yi=class extends ie{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,s,r=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,s=n?n.nextSibling:t.firstChild,r&&s!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;s&&s!=l.dom;)s=sh(s);else t.insertBefore(l.dom,s);n=l.dom}for(s=n?n.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=sh(s);this.length=o}};function sh(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var wi=class extends yi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=ie.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,s=0,r=0;;)if(s==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&r++,s=t.pop()}else{let o=n.children[s++];if(o instanceof pt)t.push(s),n=o,s=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let n,s=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(n=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,s=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:s}:{tile:r,offset:o}}},pt=class i extends yi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new i(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}},xi=class i extends yi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let s=new i(t||document.createElement("div"),e);return(!t||!n)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,n){let s=null,r=-1,o=null,l=-1;function a(f,c){for(let u=0,d=0;u<f.children.length&&d<=c;u++){let p=f.children[u],m=d+p.length;m>=c&&(p.isComposite()?a(p,c-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||n&&bp(o,p)))&&(m>c||p.flags&32&&t<=1)?(o=p,l=c-d):(d<c||p.flags&16&&!p.isHidden&&t>=-1)&&(s=p,r=c-d)),d=m}}a(this,e);let h=(t<0?s:o)||s||o;return h?{tile:h,offset:h==s?r:l}:null}coordsIn(e,t,n){let s=this.resolveInline(e,t,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),t,n):gp(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:s,offset:r}=n;if(this.dom.contains(s.dom))return s.isText()?new it(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:t);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new it(a.dom,0);a==n.tile&&(l=!0)}}return new it(this.dom,0)}};function gp(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=$i(e);return t[t.length-1]||null}function bp(i,e){let t=i.coordsIn(0,1),n=e.coordsIn(0,1);return t&&n&&n.top<t.bottom}var Se=class i extends yi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new i(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}},Vt=class i extends ie{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,n){let s=this.dom.nodeValue.length;e>s&&(e=s);let r=e,o=e,l=0;e==0&&t<0||e==s&&t>=0?T.chrome||T.gecko||(e?(r--,l=1):o<s&&(o++,l=-1)):t<0?r--:o<s&&o++;let a=sn(this.dom,r,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:t>=0)?0:a.length-1];return T.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,f=>f.width)||h),n==null?h:nn(h,(l?l>0:t<0)==n)}static of(e,t){let n=new i(t||document.createTextNode(e),e);return t||(n.flags|=2),n}},jt=class i extends ie{constructor(e,t,n,s){super(e,t,s),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(n)return nn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return nn(o,!l)}}get overrideDOMText(){if(!this.length)return F.empty;let{root:e}=this;if(!e)return F.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,s,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new i(r,n,e,s)}},ki=class extends ie{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return F.empty}coordsIn(e,t,n){let s=this.dom.getBoundingClientRect();return n==null?s:nn(s,t>0==n)}},ao=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:s,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(s.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!l.length)break;n&&n.leave(s),o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++}else{let a=s.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:s,index:r}),s=a,r=0,n&&a.isComposite()&&n.enter(a))}else{let a=s.length;if(r<a&&e){let h=Math.min(e,a-r);n&&n.skip(s,r,r+h),e-=h,r+=h}if(r==a)o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++;else if(!e)break}return this.tile=s,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},ho=class{constructor(e,t,n,s){this.from=e,this.to=t,this.wrapper=n,this.rank=s}},fo=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,s){var r;this.flushBuffer();let o=this.ensureMarks(t,n),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Vt(l.dom,l.text+e);a.parent=o}else o.append(s||Vt.of(e,(r=this.cache.find(Vt))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?$r(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let s=n;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=s.lastChild;if(h instanceof Se&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM($r(a.dom)),s=h;else{if(this.cache.reused.get(a)){let c=ie.get(a.dom);c&&c.setDOM($r(a.dom))}let f=Se.of(a.mark,a.dom);s.append(f),s=f}this.cache.reused.set(a,2)}let r=ie.get(e.text);r&&this.cache.reused.set(r,2);let o=new Vt(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,t,n){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,n);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=uf);let s=xi.start(e,t||((n=this.cache.find(xi))===null||n===void 0?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=s.lastChild)&&l instanceof Se&&l.mark.eq(o))s=l,t--;else{let a=Se.of(o,(n=this.cache.find(Se,h=>h.mark.eq(o)))===null||n===void 0?void 0:n.dom);s.append(a),s=a,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!rh(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(T.ios&&rh(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(jr,0,32)||new jt(jr.toDOM(),0,jr,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new ho(e.from,e.to,e.value,t),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-n.rank||this.wrappers[s-1].to-n.to)<0;)s--;this.wrappers.splice(s,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let s=t.lastChild;if(n.from<this.pos&&s instanceof pt&&s.wrapper.eq(n.wrapper))t=s;else{let r=pt.of(n.wrapper,(e=this.cache.find(pt,o=>o.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(ki,void 0,1);return n&&(n.flags=t),n||new ki(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},co=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},ps=[jt,xi,Vt,Se,ki,pt,wi];for(let i=0;i<ps.length;i++)ps[i].bucket=i;var uo=class{constructor(e){this.view=e,this.buckets=ps.map(()=>[]),this.index=ps.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let l=0;l<r.length;l++){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[s]--,this.reused.set(h,n),h}return null}findWidget(e,t,n){let s=this.buckets[0];if(s.length)for(let r=0,o=0;;r++){if(r==s.length){if(o)return null;o=1,r=0}let l=s[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return s.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==n?(this.reused.set(l,1),l):(this.reused.set(l,2),new jt(l.dom,t,e,l.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},po=class{constructor(e,t,n,s,r){this.view=e,this.decorations=s,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new uo(e),this.text=new co(e.state.doc),this.builder=new fo(this.cache,new wi(e,e.contentDOM),V.iter(n)),this.cache.reused.set(t,2),this.old=new ao(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>s){let h=a-s;this.preserve(h,!o,!l),s=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,s=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let s=xp(this.old),r=this.openMarks;this.old.advance(e,n?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?jt.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,s,r),r=s.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),s,r)),r=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof ki)this.cache.add(o);else if(o instanceof Se)this.builder.ensureLine(null),this.builder.addMark(o,s,r),this.cache.reused.set(o,1),r=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Se&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof Se&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,s=this.builder,r=-1,o=V.spans(this.decorations,e,t,{point:(l,a,h,f,c,u)=>{if(h instanceof qt){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=f.length,c>f.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?St.block:St.inline),p=yp(h),m=this.cache.findWidget(d,a-l,p)||jt.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(n),s.addBlockWidget(m)):(s.ensureLine(n),s.addInlineWidget(m,f,c))}n=null}else n=wp(n,h);a>l&&this.text.skip(a-l)},span:(l,a,h,f)=>{for(let c=l;c<a;){let u=this.text.next(Math.min(512,a-c));u==null?(s.addLineStartIfNotCovered(n),s.addBreak(),c++):(s.ensureLine(n),s.addText(u,h,c==l?f:h.length),c+=u.length),n=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||s.addLineStartIfNotCovered(n),this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let s=e.parentNode;;s=s.parentNode){let r=ie.get(s);if(s==this.view.contentDOM)break;r instanceof Se?t.push(r):r?.isLine()?n=r:r instanceof pt||(s.nodeName=="DIV"&&!n&&s!=this.view.contentDOM?n=new xi(s,uf):n||t.push(Se.of(new Zi({tagName:s.nodeName.toLowerCase(),attributes:Zd(s)}),s)))}return{line:n,marks:t}}};function rh(i,e){let t=n=>{for(let s of n.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(i)}function yp(i){let e=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(e|=256),e}var uf={class:"cm-line"};function wp(i,e){let t=e.spec.attributes,n=e.spec.class;return!t&&!n||(i||(i={class:"cm-line"}),t&&Xo(t,i),n&&(i.class+=" "+n)),i}function xp(i){let e=[];for(let t=i.parents.length;t>1;t--){let n=t==i.parents.length?i.tile:i.parents[t].tile;n instanceof Se&&e.push(n.mark)}return e}function $r(i){let e=ie.get(i);return e&&e.setDOM(i.cloneNode()),i}var St=class extends De{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}};St.inline=new St("span");St.block=new St("div");var jr=new class extends De{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},ms=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=O.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new wi(e,e.contentDOM),this.updateInner([new Ue(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:f,toA:c})=>c<this.minWidthFrom||f>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),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!Tp(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?vp(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:f,to:c}=this.hasComposition;n=new Ue(f,c,e.changes.mapPos(f,-1),e.changes.mapPos(c,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(T.ie||T.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Ap(o,this.decorations,e.changes);a.length&&(n=Ue.extendWithRanges(n,a));let h=Mp(l,this.blockWrappers,e.changes);return h.length&&(n=Ue.extendWithRanges(n,h)),r&&!n.some(f=>f.fromA<=r.range.fromA&&f.toA>=r.range.toA)&&(n=r.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let o=this.tile,l=new po(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&ie.get(t.text)&&l.cache.reused.set(ie.get(t.text),2),this.tile=l.run(e,t),mo(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=T.chrome||T.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Gi&&s.push(r.dom);n.updateGaps(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(lf)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,s=this.view.root.activeElement,r=s==n,o=!r&&!(this.view.state.facet(dt)||n.tabIndex>-1)&&qi(n,this.view.observer.selectionRange)&&!(s&&n.contains(s));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,f;if(a.empty?f=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(f=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),T.gecko&&a.empty&&!this.hasComposition&&kp(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=f=new it(u,0),l=!0}let c=this.view.observer.selectionRange;(l||!c.focusNode||(!ji(h.node,h.offset,c.anchorNode,c.anchorOffset)||!ji(f.node,f.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{T.android&&T.chrome&&n.contains(c.focusNode)&&Lp(c.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let u=tn(this.view.root);if(u)if(a.empty){if(T.gecko){let d=Sp(h.node,h.offset);if(d&&d!=3){let p=(d==1?$h:jh)(h.node,h.offset);p&&(h=new it(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(f.node,f.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,f]=[f,h]),d.setEnd(f.node,f.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==n&&(n.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new it(c.anchorNode,c.anchorOffset),this.impreciseHead=f.precise?null:new it(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ji(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=tn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=this.lineAt(t.head,t.assoc);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 f=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(f.node,f.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(s,r)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=n.posAtStart;if(n.isComposite()){let r;if(e==n.dom)r=n.dom.childNodes[t];else{let o=mt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==n.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==n.dom.firstChild)return s;for(;r&&!ie.get(r);)r=r.nextSibling;if(!r)return s+n.length;for(let o=0,l=s;;o++){let a=n.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return n.isText()?e==n.dom?s+t:s+(t?n.length:0):s}domAtPos(e,t){let{tile:n,offset:s}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(s,t):n.domIn(s,t)}inlineDOMNearPos(e,t){let n,s=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,f)=>{if(h.isWidget()){if(h.flags&32&&f>=e)return!0;h.flags&16&&(r=!0)}else{let c=f+h.length;if(f<=e&&(n=h,s=e-f,r=c<e),c>=e&&!o&&(o=h,l=e-f,a=f>e),f>e&&o)return!0}}),!n&&!o?this.domAtPos(e,t):(r&&o?n=null:a&&n&&(o=null),n&&t<0||!o?n.domIn(s,t):o.domIn(l,t))}coordsAt(e,t,n){let{tile:s,offset:r}=this.tile.resolveBlock(e,t);return s.isWidget()?s.widget instanceof Gi?null:s.coordsInWidget(r,t,!0):s.coordsIn(r,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=oe(r.text,o);if(l==o)return null;let a=sn(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let f=a[h];if(h==a.length-1||f.top<f.bottom&&f.left<f.right)return f}}return null}return s(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==K.LTR,h=0,f=(c,u,d)=>{for(let p=0;p<c.children.length&&!(u>s);p++){let m=c.children[p],g=u+m.length,b=m.dom.getBoundingClientRect(),{height:k}=b;if(d&&!p&&(h+=b.top-d.top),m instanceof pt)g>n&&f(m,u,b);else if(u>=n&&(h>0&&t.push(-h),t.push(k+h),h=0,o)){let x=m.dom.lastChild,B=x?$i(x):[];if(B.length){let v=B[B.length-1],C=a?v.right-b.left:b.right-v.left;C>l&&(l=C,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==c.children.length-1&&(h+=d.bottom-b.bottom),u=g+m.breakAfter}};return f(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?K.RTL:K.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let f=$i(h.dom);if(f.length!=1)return;l+=f[0].width,a=f[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=$i(t.firstChild)[0];n=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:n,t.remove()}),{lineHeight:n,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(O.replace({widget:new Gi(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return O.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Ds).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(el).map((r,o)=>{let l=typeof r=="function";return l&&(n=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=n,t.push(V.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(hf).map(r=>typeof r=="function"?r(this.view):r)}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}for(let h of this.view.state.facet(of))try{if(h(this.view,e.range,e))return!0}catch(f){Ce(this.view.state,f,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),s;if(!n)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)});let r=tl(this.view),o={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(ip(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==K.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);if(h){let f=Wh(h.dom);h.dom.scrollIntoView({block:"nearest"}),Vh(f,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){mo(this.tile)}};function mo(i,e){let t=e?.get(i);if(t!=1){t==null&&i.destroy();for(let n of i.children)mo(n,e)}}function kp(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function df(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=$h(t.focusNode,t.focusOffset),s=jh(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=ie.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=ie.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(r=s)}}if(i.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function vp(i,e,t){let n=df(i,t);if(!n)return null;let{node:s,from:r,to:o}=n,l=s.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc;return{range:new Ue(a.mapPos(r),a.mapPos(o),r,o),text:s}}function Sp(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}var Cp=class{constructor(){this.changes=[]}compareRange(e,t){gi(e,t,this.changes)}comparePoint(e,t){gi(e,t,this.changes)}boundChange(e){gi(e,e,this.changes)}};function Ap(i,e,t){let n=new Cp;return V.compare(i,e,t,n),n.changes}var go=class{constructor(){this.changes=[]}compareRange(e,t){gi(e,t,this.changes)}comparePoint(){}boundChange(e){gi(e,e,this.changes)}};function Mp(i,e,t){let n=new go;return V.compare(i,e,t,n),n.changes}function Lp(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Tp(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}var Gi=class extends De{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Dp(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return w.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=oe(s.text,r,!1):l=oe(s.text,r);let a=n(s.text.slice(o,l));for(;o>0;){let h=oe(s.text,o,!1);if(n(s.text.slice(h,o))!=a)break;o=h}for(;l<s.length;){let h=oe(s.text,l);if(n(s.text.slice(l,h))!=a)break;l=h}return w.undirectionalRange(o+s.from,l+s.from)}function Bp(i,e,t,n,s){let r=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(i.defaultLineHeight-l)*.5)/l);r+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Xn(o,r,i.state.tabSize)}function bo(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let s;for(let r of n.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==ue.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function Op(i,e,t,n){let s=bo(i,e.head,e.assoc||-1),r=!n||s.type!=ue.Text||!(i.lineWrapping||s.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(s.from),a=i.posAtCoords({x:t==(l==K.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return w.cursor(a,t?-1:1)}return w.cursor(t?s.to:s.from,t?-1:1)}function oh(i,e,t,n){let s=i.state.doc.lineAt(e.head),r=i.bidiSpans(s),o=i.textDirectionAt(s.from);for(let l=e,a=null;;){let h=up(s,r,o,l,t),f=Yh;if(!h){if(s.number==(t?i.state.doc.lines:1))return l;f=`
`,s=i.state.doc.line(s.number+(t?1:-1)),r=i.bidiSpans(s),h=i.visualLineSide(s,!t)}if(a){if(!a(f))return l}else{if(!n)return h;a=n(f)}l=h}}function Ep(i,e,t){let n=i.state.charCategorizer(e),s=n(t);return r=>{let o=n(r);return s==U.Space&&(s=o),s==o}}function Ip(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return w.cursor(s,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),h=i.coordsAtPos(s,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),f=i.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=i.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+f}let c=a.left+o,u=i.viewState.heightOracle.textHeight>>1,d=n??u;for(let p=0;;p+=u){let m=l+(d+p)*r,g=yo(i,{x:c,y:m},!1,r);if(t?m>a.bottom:m<a.top)return w.cursor(g.pos,g.assoc);let b=i.coordsAtPos(g.pos,g.assoc),k=b?(b.top+b.bottom)/2:0;if(!b||(t?k>l:k<l))return w.cursor(g.pos,g.assoc,void 0,o)}}function Xi(i,e,t){for(;;){let n=0;for(let s of i)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=n||t||(e-r<o-e?-1:1);e=a<0?r:o,n=a}});if(!n)return e}}function pf(i,e){let t=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=Xi(i,s.from,0);o!=s.from&&(r=w.cursor(o,-1))}else{let o=Xi(i,s.from,-1),l=Xi(i,s.to,1);(o!=s.from||l!=s.to)&&(s.undirectional?r=w.undirectionalRange(s.from,s.to):r=w.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?w.create(t,e.mainIndex):e}function Kr(i,e,t){let n=Xi(i.state.facet(rn).map(s=>s(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:w.cursor(n,n<t.from?1:-1)}var We=class{constructor(e,t){this.pos=e,this.assoc=t}};function yo(i,e,t,n){let s=i.contentDOM.getBoundingClientRect(),r=s.top+i.viewState.paddingTop,{x:o,y:l}=e,a=l-r,h;for(;;){if(a<0)return new We(0,1);if(a>i.viewState.docHeight)return new We(i.state.doc.length,-1);if(h=i.elementAtHeight(a),n==null)break;if(h.type==ue.Text){if(n<0?h.to<i.viewport.from:h.from>i.viewport.to)break;let u=i.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(u&&(n<0?u.top<=a+r:u.bottom>=a+r))break}let c=i.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+c:h.top-c}if(i.viewport.from>=h.to||i.viewport.to<=h.from){if(t)return null;if(h.type==ue.Text){let c=Bp(i,s,h,o,l);return new We(c,c==h.from?1:-1)}}if(h.type!=ue.Text)return a<(h.top+h.bottom)/2?new We(h.from,1):new We(h.to,-1);let f=i.docView.lineAt(h.from,2);return(!f||f.length!=h.length)&&(f=i.docView.lineAt(h.from,-2)),new wo(i,o,l,i.textDirectionAt(h.from)).scanTile(f,h.from)}var wo=class{constructor(e,t,n,s){this.view=e,this.x=t,this.y=n,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:s}=this.bidiSpansAt(e);return s[Ve.find(s,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:s}=this.bidiSpansAt(e);return s[Ve.find(s,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:s}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+s.from<t)}scan(e,t,n=!1){let s=0,r=e.length-1,o=new Set,l=this.bidiIn(e[0],e[r]),a,h,f=-1,c=1e9,u;e:for(;s<r;){let p=r-s,m=s+r>>1;t:if(o.has(m)){for(let k=1;k<p;k++){let x=m+k;if(x>=r&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let g=t(m),b=0;if(g)for(let k=0;k<g.length;k++){let x=g[k];if(!(x.width==0&&g.length>1))if(x.bottom<this.y)(!a||a.bottom<x.bottom)&&(a=x),b=1;else if(x.top>this.y)(!h||h.top>x.top)&&(h=x),b=-1;else{let B=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,v=Math.abs(B);v<c&&(f=m,c=v,u=x),B&&(b=B<0==(this.baseDir==K.LTR)?-1:1)}}b==-1&&(!l||this.baseDirAt(e[m],1))?r=m:b==1&&(!l||this.baseDirAt(e[m+1],-1))&&(s=m+1)}if(!u){if(!h&&!a)return{i:e[0],after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(c&&!n){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[f],1):this.baseDir)==K.LTR;return{i:f,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=oe(e.text,r))n.push(t+r);n.push(t+e.length);let s=this.scan(n,r=>{let o=n[r]-t,l=n[r+1]-t;return sn(e.dom,o,l).getClientRects()});return s.after?new We(n[s.i+1],-1):new We(n[s.i],1)}scanTile(e,t){if(!e.length)return new We(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let n=[t];for(let l=0,a=t;l<e.children.length;l++)n.push(a+=e.children[l].length);let s=this.scan(n,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:sn(a.dom,0,a.length)).getClientRects()}),r=e.children[s.i],o=n[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new We(n[s.i+1],-1):new We(o,1)}},ci="\uFFFF",xo=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(G.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ci}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let r=this.text.length;this.readNode(s);let o=ie.get(s),l=s.nextSibling;if(l==t){o?.breakAfter&&!l&&n!=this.view.contentDOM&&this.lineBreak();break}let a=ie.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:us(s))||us(l)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!Rp(l,t)&&this.lineBreak(),s=l}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=r+o}}readNode(e){let t=ie.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let s=n.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(_p(e,n.node,n.offset)?t:0))}};function _p(i,e,t){for(;;){if(!e||t<mt(e))return!1;if(e==i)return!0;t=vt(e)+1,e=e.parentNode}}function Rp(i,e){let t;for(;!(i==e||!i);i=i.nextSibling){let n=ie.get(i);if(!n?.isWidget())return!1;n&&(t||(t=[])).push(n)}if(t)for(let n of t){let s=n.overrideDOMText;if(s?.length)return!1}return!0}var gs=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},ko=class{constructor(e,t,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=mf(e.docView.tile,t,n,0))){let a=r||o?[]:Np(e),h=new xo(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=Hp(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!io(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),f=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!io(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),c=e.viewport;if((T.ios||T.chrome)&&h!=f&&Math.min(h,f)<=l.main.from&&Math.max(h,f)>=l.main.to&&(c.from>0||c.to<e.state.doc.length)){let u=Math.min(h,f),d=Math.max(h,f),p=c.from-u,m=c.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==e.state.doc.length)&&(h=0,f=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(w.range(f,h));else if(e.lineWrapping&&f==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=w.create([w.cursor(h,d)])}else this.newSel=w.single(f,h)}}};function mf(i,e,t,n){if(i.isComposite()){let s=-1,r=-1,o=-1,l=-1;for(let a=0,h=n,f=n;a<i.children.length;a++){let c=i.children[a],u=h+c.length;if(h<e&&u>t)return mf(c,e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&c.dom.parentNode==i.dom){o=a,l=f;break}f=u,h=u+c.breakAfter}return{from:r,to:l<0?n+i.length:l,startDOM:(s?i.children[s-1].dom.nextSibling:null)||i.dom.firstChild,endDOM:o<i.children.length&&o>=0?i.children[o].dom:null}}else return i.isText()?{from:n,to:n+i.length,startDOM:i.dom,endDOM:i.dom.nextSibling}:null}function gf(i,e){let t,{newSel:n}=e,{state:s}=i,r=s.selection.main,o=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,f=null;(o===8||T.android&&e.text.length<a-l)&&(h=r.to,f="end");let c=s.doc.sliceString(l,a,ci),u,d;!r.empty&&r.from>=l&&r.to<=a&&(e.typeOver||c!=e.text)&&c.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&c.slice(r.to-l)==e.text.slice(u=e.text.length-(c.length-(r.to-l)))?t={from:r.from,to:r.to,insert:F.of(e.text.slice(r.from-l,u).split(ci))}:(d=bf(c,e.text,h-l,f))&&(T.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ci+ci&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:F.of(e.text.slice(d.from,d.toB).split(ci))})}else n&&(!i.hasFocus&&s.facet(dt)||bs(n,r))&&(n=null);if(!t&&!n)return!1;if((T.mac||T.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=w.single(n.main.anchor-1,n.main.head-1)),t={from:t.from,to:t.to,insert:F.of([t.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&i.docView.lineHasWidget(r.to)&&i.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:s.toText(i.inputState.insertingText)}:T.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
 `&&i.lineWrapping&&(n&&(n=w.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:F.of([" "])}),t)return il(i,t,n,o);if(n&&!bs(n,r)){let l=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(l=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=pf(s.facet(rn).map(h=>h(i)),n))),i.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function il(i,e,t,n=-1){if(T.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(T.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&i.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&bi(i.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&bi(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&bi(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=Pp(i,e,t));return i.state.facet(tf).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function Pp(i,e,t){let n,s=i.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,h=a<0?r.from:r.to,f=Xi(s.facet(rn).map(c=>c(i)),h,a);e.from==f&&(o=f)}if(o>-1)n={changes:e,selection:w.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let a=r.from<e.from?s.sliceDoc(r.from,e.from):"",h=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+h))}else{let a=s.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(s.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let f=i.state.sliceDoc(e.from,e.to),c,u=t&&df(i,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-p}}else c=i.state.doc.lineAt(r.head);let d=r.to-e.to;n=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-f.length;if(i.state.sliceDoc(g,m)!=f||m>=c.from&&g<=c.to)return{range:p};let b=s.changes({from:g,to:m,insert:e.insert}),k=p.to-r.to;return{changes:b,range:h?w.range(Math.max(0,h.anchor+k),Math.max(0,h.head+k)):p.map(b)}})}else n={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:l,scrollIntoView:!0})}function bf(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r<s&&i.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&i.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Np(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}=i.observer.selectionRange;return t&&(e.push(new gs(t,n)),(s!=t||r!=n)&&e.push(new gs(s,r))),e}function Hp(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?w.single(t+e,n+e):null}function bs(i,e){return e.head==i.main.head&&e.anchor==i.main.anchor}var vo=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,T.safari&&e.contentDOM.addEventListener("input",()=>null),T.gecko&&Zp(e.contentDOM.ownerDocument)}handleEvent(e){!Kp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,t);for(let s of n.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Wp(e),n=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=n[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in n)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&wf.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),T.android&&T.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(T.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(yf.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||Vp.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&T.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Fp(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,bi(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:T.safari&&!T.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Fp(i){return i.visualViewport?i.visualViewport.height*i.visualViewport.scale/i.document.documentElement.clientHeight<.85:!1}function lh(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){Ce(t.state,s)}}}function Wp(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let s=n.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(lh(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(lh(n.value,a))}}for(let n in Ge)t(n).handlers.push(Ge[n]);for(let n in xe)t(n).observers.push(xe[n]);return e}var yf=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Vp="dthko",wf=[16,17,18,20,91,92,224,225],Qn=6;function Zn(i){return Math.max(0,i)*.7+8}function zp(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var So=class{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Fh(e.contentDOM),this.atoms=e.state.facet(rn).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(G.allowMultipleSelections)&&qp(e,t),this.dragging=jp(e,t)&&vf(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&zp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=tl(this.view);e.clientX-a.left<=s+Qn?t=-Zn(s-e.clientX):e.clientX+a.right>=o-Qn&&(t=Zn(e.clientX-o)),e.clientY-a.top<=r+Qn?n=-Zn(r-e.clientY):e.clientY+a.bottom>=l-Qn&&(n=Zn(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=pf(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function qp(i,e){let t=i.state.facet(Jh);return t.length?t[0](e):T.mac?e.metaKey:e.ctrlKey}function $p(i,e){let t=i.state.facet(Qh);return t.length?t[0](e):T.mac?!e.altKey:!e.ctrlKey}function jp(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=tn(i.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Kp(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=ie.get(t))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}var Ge=Object.create(null),xe=Object.create(null),xf=T.ie&&T.ie_version<15||T.ios&&T.webkit_version<604;function Up(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),kf(i,t.value)},50)}function Bs(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function kf(i,e){e=Bs(i.state,Qo,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Co!=null&&t.selection.ranges.every(a=>a.empty)&&Co==r.toString()){let a=-1;n=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:w.cursor(h.from+c.length)}})}else o?n=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:w.cursor(a.from+h.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}xe.scroll=i=>{let e=i.inputState;e.lastScrollTop=i.scrollDOM.scrollTop,e.lastScrollLeft=i.scrollDOM.scrollLeft,T.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};xe.wheel=xe.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};Ge.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);xe.touchstart=(i,e)=>{let t=i.inputState,n=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),n&&(t.lastTouchX=n.clientX,t.lastTouchY=n.clientY),t.setSelectionOrigin("select.pointer")};xe.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};xe.touchend=(i,e)=>{i.inputState.touchActive=!1};Ge.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(Zh))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=Xp(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new So(i,e,t,n)),n&&i.observer.ignore(()=>{zh(i.contentDOM);let r=i.root.activeElement;r&&!r.contains(i.contentDOM)&&r.blur()});let s=i.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function ah(i,e,t,n){if(n==1)return w.cursor(e,t);if(n==2)return Dp(i.state,e,t);{let s=i.docView.lineAt(e,t),r=i.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<i.state.doc.length&&l==r.to&&l++,w.undirectionalRange(o,l)}}var Gp=T.ie&&T.ie_version<=11,hh=null,fh=0,ch=0;function vf(i){if(!Gp)return i.detail;let e=hh,t=ch;return hh=i,ch=Date.now(),fh=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(fh+1)%3:1}function Xp(i,e){let t=i.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=vf(e),s=i.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=i.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,f=ah(i,a.pos,a.assoc,n);if(t.pos!=a.pos&&!o){let c=ah(i,t.pos,t.assoc,n),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u<f.from?w.range(u,d,f.assoc):w.range(d,u,f.assoc)}return o?s.replaceRange(s.main.extend(f.from,f.to,f.assoc)):l&&n==1&&s.ranges.length>1&&(h=Yp(s,a.pos))?h:l?s.addRange(f):w.create([f])}}}function Yp(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:s}=i.ranges[t];if(n<=e&&s>=e)return w.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Ge.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let s=i.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=w.undirectionalRange(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Bs(i.state,Zo,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ge.dragend=i=>(i.inputState.draggedContent=null,!1);function uh(i,e,t,n){if(t=Bs(i.state,Qo,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&$p(i,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Ge.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),s=0,r=()=>{++s==t.length&&uh(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return uh(i,e,n,!0),!0}return!1};Ge.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=xf?null:e.clipboardData;return t?(kf(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Up(i),!1)};function Jp(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function Qp(i){let e=[],t=[],n=!1;for(let s of i.selection.ranges)s.empty||(e.push(i.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of i.selection.ranges){let o=i.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),s=o.number}n=!0}return{text:Bs(i,Zo,e.join(i.lineBreak)),ranges:t,linewise:n}}var Co=null;Ge.copy=Ge.cut=(i,e)=>{if(!qi(i.contentDOM,i.observer.selectionRange))return!1;let{text:t,ranges:n,linewise:s}=Qp(i.state);if(!t&&!s)return!1;Co=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=xf?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Jp(i,t),!1)};var Sf=be.define();function Cf(i,e){let t=[];for(let n of i.facet(nf)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:Sf.of(!0)}):null}function Af(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Cf(i.state,e);t?i.dispatch(t):i.update([])}},10)}xe.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Af(i)};xe.blur=i=>{i.observer.clearSelectionRange(),Af(i)};xe.compositionstart=xe.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};xe.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,T.chrome&&T.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};xe.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Ge.beforeinput=(i,e)=>{var t,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),h=i.posAtDOM(l.endContainer,l.endOffset);return il(i,{from:a,to:h,insert:i.state.toText(r)},null),!0}}let s;if(T.chrome&&T.android&&(s=yf.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return T.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),T.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>xe.compositionend(i,e),20),!1};var dh=new Set;function Zp(i){dh.has(i)||(dh.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var ph=["pre-wrap","normal","pre-line","break-spaces"],vi=!1;function mh(){vi=!1}var Ao=class{constructor(e){this.lineWrapping=e,this.doc=F.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ph.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,n,s,r,o){let l=ph.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return a}},Mo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Ke=class i{constructor(e,t,n,s,r){this.from=e,this.length=t,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?ue.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 qt?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 i(this.from,this.length+e.length,this.top,this.height+e.height,t)}},Z=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(Z||(Z={})),os=.001,Te=class i{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>os&&(vi=!0),this.height=e)}replace(e,t,n){return i.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let r=this,o=n.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=s[l],u=r.lineAt(a,Z.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,Z.ByPosNoHeight,n,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,f=s[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,Z.ByPosNoHeight,n,0,0));f+=u.from-a,a=u.from;let p=To.build(n.setDoc(o),e,f,c);r=ys(r,r.replace(a,h,p))}return r.updateHeight(n,0)}static empty(){return new Fe(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,s=0,r=0;for(;;)if(t==n)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,s-=l.size}else if(r>s*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--n];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new Lo(i.of(e.slice(0,t)),o,i.of(e.slice(n)))}};function ys(i,e){return i==e?i:(i.constructor!=e.constructor&&(vi=!0),e)}Te.prototype.size=1;var em=O.replace({}),ws=class extends Te{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Ke(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,s){return this.spaceAbove&&e<n+this.spaceAbove?new Ke(s,0,n,this.spaceAbove,em):this.mainBlock(n,s)}lineAt(e,t,n,s,r){let o=this.mainBlock(s,r);return this.spaceAbove?this.blockAt(0,n,s,r).join(o):o}forEachLine(e,t,n,s,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,Z.ByPos,n,s,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}},Fe=class i extends ws{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Ke(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof i||s instanceof kt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof kt?s=new i(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Te.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},kt=class i extends Te{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:n,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,n,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let h=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),f=t.doc.lineAt(h),c=l+f.length*a,u=Math.max(n,e-c/2);return new Ke(f.from,f.length,u,c,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:f,length:c}=t.doc.line(r+h);return new Ke(f,c,n+l*h,l,0)}}lineAt(e,t,n,s,r){if(t==Z.ByHeight)return this.blockAt(e,n,s,r);if(t==Z.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new Ke(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),h=n.doc.lineAt(e),f=l+h.length*a,c=h.number-o,u=s+l*c+a*(h.from-r-c);return new Ke(h.from,h.length,Math.max(s,Math.min(u,s+this.height-f)),f,0)}forEachLine(e,t,n,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(n,r);for(let f=e,c=s;f<=t;){let u=n.doc.lineAt(f);if(f==e){let p=u.number-l;c+=a*p+h*(e-r-p)}let d=a+h*u.length;o(new Ke(u.from,u.length,c,d,0)),c+=d,f=u.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof i?n[n.length-1]=new i(r.length+s):n.push(null,new i(s-1))}if(e>0){let r=n[0];r instanceof i?n[0]=new i(e+r.length):n.unshift(new i(e-1),null)}return Te.of(n)}decomposeLeft(e,t){t.push(new i(e-1),null)}decomposeRight(e,t){t.push(null,new i(this.length-e-1))}updateHeight(e,t=0,n=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new i(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let c=s.heights[s.index++],u=0;c<0&&(u=-c,c=s.heights[s.index++]),a==-1?a=c:Math.abs(c-a)>=os&&(a=-2);let d=new Fe(f,c,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new i(r-l).updateHeight(e,l));let h=Te.of(o);return(a<0||Math.abs(h.height-this.height)>=os||Math.abs(a-this.heightMetrics(e,t).perLine)>=os)&&(vi=!0),ys(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Lo=class extends Te{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,s){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,n,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==Z.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let f=t==Z.ByPosNoHeight?Z.ByPosNoHeight:Z.ByPos;return a?h.join(this.right.lineAt(l,f,n,o,l)):this.left.lineAt(l,f,n,s,r).join(h)}forEachLine(e,t,n,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,s,r,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let h=this.lineAt(a,Z.ByPos,n,s,r);e<h.from&&this.left.forEachLine(e,h.from-1,n,s,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,l,a,o)}}replace(e,t,n){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of n)r.push(l);if(e>0&&gh(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),gh(r,l)}return Te.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Te.of(this.break?[e,null,t]:[e,t]):(this.left=ys(this.left,e),this.right=ys(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,n,s):r.updateHeight(e,t,n),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,n,s):o.updateHeight(e,l,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function gh(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof kt&&(n=i[e+1])instanceof kt&&i.splice(e-1,3,new kt(t.length+1+n.length))}var tm=5,To=class i{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Fe?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Fe(n-this.pos,-1,0)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new ws(o,s,n)):(o||r||s>=tm)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Fe(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new kt(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Fe)return e;let t=new Fe(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Fe)&&!this.isCovered?this.nodes.push(new Fe(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof Fe&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new i(n,e);return V.spans(t,n,s,r,0),r.finish(n)}};function im(i,e,t){let n=new Do;return V.compare(i,e,t,n,0),n.changes}var Do=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&gi(e,t,this.changes,5)}};function nm(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,s=n.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let h=i.parentNode;h&&h!=n.body;)if(h.nodeType==1){let f=h,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==i.parentNode?s.innerHeight:a,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function sm(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function rm(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Yi=class{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return O.replace({widget:new Bo(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Bo=class extends De{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}},xs=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=bh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=K.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Ts).some(s=>typeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new Ao(n),this.stateDeco=yh(t),this.heightMap=Te.empty().applyChanges(this.stateDeco,F.empty,this.heightOracle.setDoc(t.doc),[new Ue(0,0,0,t.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=O.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new di(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?bh:new Oo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Vi(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=yh(this.state);let s=e.changedRanges,r=Ue.extendWithRanges(s,im(n,this.stateDeco,e?e.changes:ge.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);mh(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||vi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(rf)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?K.RTL:K.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:v,scaleY:C}=Hh(t,l);(v>.005&&Math.abs(this.scaleX-v)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=v,this.scaleY=C,h|=16,o=a=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=Fh(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=qh(this.scrollParent||e.win);let m=(this.printing?rm:nm)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let k=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(k!=this.inView&&(this.inView=k,k&&(a=!0)),!this.inView&&!this.scrollTarget&&!sm(e.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let v=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(v)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:C,charWidth:A,textHeight:N}=e.docView.measureTextSize();o=C>0&&s.refresh(r,C,A,N,Math.max(5,x/A),v),o&&(e.docView.minWidth=0,h|=16)}g>0&&b>0?f=Math.max(g,b):g<0&&b<0&&(f=Math.min(g,b)),mh();for(let C of this.viewports){let A=C.from==this.viewport.from?v:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?Te.empty().applyChanges(this.stateDeco,F.empty,this.heightOracle,[new Ue(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Mo(C.from,A))}vi&&(h|=2)}let B=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return B&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||B)&&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 n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new di(s.lineAt(o-n*1e3,Z.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,Z.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=s.lineAt(h,Z.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=c.top:u=c.bottom-f,a=new di(s.lineAt(u-1e3/2,Z.ByHeight,r,0,0).from,s.lineAt(u+f+1e3/2,Z.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new di(this.heightMap.lineAt(n,Z.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,Z.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,Z.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,Z.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new Yi(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=K.LTR&&!n)return[];let l=[],a=(f,c,u,d)=>{if(c-f<r)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let b of m)if(b>f&&b<c){a(f,b-10,u,d),a(b+10,c,u,d);return}let g=lm(e,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-f)<r&&Math.abs(b.to-c)<r&&!m.some(k=>b.from<k&&b.to>k));if(!g){if(c<u.to&&t&&n&&t.visibleRanges.some(x=>x.from<=c&&x.to>=c)){let x=t.moveToLineBoundary(w.cursor(c),!1,!0).head;x>f&&(c=x)}let b=this.gapSize(u,f,c,d),k=n||b<2e6?b:2e6;g=new Yi(f,c,b,k)}l.push(g)},h=f=>{if(f.length<o||f.type!=ue.Text)return;let c=om(f.from,f.to,this.stateDeco);if(c.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let m=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,b;if(u!=null){let k=ts(c,u),x=((this.visibleBottom-this.visibleTop)/2+m)/f.height;g=k-x,b=k+x}else g=(this.visibleTop-f.top-m)/f.height,b=(this.visibleBottom-f.top+m)/f.height;d=es(c,g),p=es(c,b)}else{let m=c.total*this.heightOracle.charWidth,g=s*this.heightOracle.charWidth,b=0;if(m>2e6)for(let C of e)C.from>=f.from&&C.from<f.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=C.size-C.displaySize);let k=this.pixelViewport.left+b,x=this.pixelViewport.right+b,B,v;if(u!=null){let C=ts(c,u),A=((x-k)/2+g)/m;B=C-A,v=C+A}else B=(k-g)/m,v=(x+g)/m;d=es(c,B),p=es(c,v)}d>f.from&&a(f.from,d,f,c),p<f.to&&a(p,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return l}gapSize(e,t,n,s){let r=ts(s,n)-ts(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Yi.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=O.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];V.spans(t,this.viewport.from,this.viewport.to,{span(r,o){n.push({from:r,to:o})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let r=0;r<n.length&&!(s&8);r++){let o=this.visibleRanges[r],l=n[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Vi(this.heightMap.lineAt(e,Z.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Vi(this.heightMap.lineAt(this.scaler.fromDOM(e),Z.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}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 Vi(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}},di=class{constructor(e,t){this.from=e,this.to=t}};function om(i,e,t){let n=[],s=i,r=0;return V.spans(t,i,e,{span(){},point(o,l){o>s&&(n.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function es({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(n<=l)return r+n;n-=l}}function ts(i,e){let t=0;for(let{from:n,to:s}of i.ranges){if(e<=s){t+=e-n;break}t+=s-n}return t/i.total}function lm(i,e){for(let t of i)if(e(t))return t}var bh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function yh(i){let e=i.facet(Ds).filter(n=>typeof n!="function"),t=i.facet(el).filter(n=>typeof n!="function");return t.length&&e.push(V.join(t)),e}var Oo=class i{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let h=t.lineAt(l,Z.ByPos,e,0,0).top,f=t.lineAt(a,Z.ByPos,e,0,0).bottom;return s+=f-h,{from:l,to:a,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof i?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}};function Vi(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Ke(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>Vi(s,e)):i._content)}var is=L.define({combine:i=>i.join(" ")}),Eo=L.define({combine:i=>i.indexOf(!0)>-1}),Io=He.newName(),Mf=He.newName(),Lf=He.newName(),Tf={"&light":"."+Mf,"&dark":"."+Lf};function _o(i,e,t){return new He(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return i;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):i+" "+n}})}var am=_o("."+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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Tf),hm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ur=T.ie&&T.ie_version<=11,Ro=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new no,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(T.ie&&T.ie_version<=11||T.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&T.android&&e.constructor.EDIT_CONTEXT!==!1&&!(T.chrome&&T.chrome_version<126)&&(this.editContext=new Po(e),e.state.facet(dt)&&(e.contentDOM.editContext=this.editContext.editContext)),Ur&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(dt)?n.root.activeElement!=this.dom:!qi(this.dom,s))return;let r=s.anchorNode&&n.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(T.ie&&T.ie_version<=11||T.android&&T.chrome)&&!n.state.selection.main.empty&&s.focusNode&&ji(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=tn(e.root);if(!t)return!1;let n=T.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&fm(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=qi(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&sp(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,hm),Ur&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ur&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&bi(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&qi(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ko(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,s=gf(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!bs(this.view.state.selection,t.newSel.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let n=wh(t,e.previousSibling||e.target.previousSibling,-1),s=wh(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(dt)!=e.state.facet(dt)&&(e.view.contentDOM.editContext=e.state.facet(dt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function wh(i,e,t){for(;e;){let n=ie.get(e);if(n&&n.parent==i)return n;let s=e.parentNode;e=s!=i.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function xh(i,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor,1);return ji(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function fm(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return xh(i,s)}let t=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?xh(i,t):null}var Po=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>n.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let f=bf(e.state.sliceDoc(l,a),n.text,(h?s.from:s.to)-l,h?"end":null);if(!f){let u=w.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));bs(u,s)||e.dispatch({selection:u,userEvent:"select"});return}let c={from:f.from+l,to:f.toA+l,insert:F.of(n.text.slice(f.from,f.toB).split(`
`))};if((T.mac||T.android)&&c.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:a,insert:F.of([n.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);il(e,c,w.single(this.toEditorPos(n.selectionStart,u),this.toEditorPos(n.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(n.rangeStart,s)},this.handlers.textformatupdate=n=>{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(O.mark({attributes:{style:f}}).range(a,h))}}}e.dispatch({effects:lf.of(O.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{let s=tn(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(n)return;let f=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,t+=f,this.to+=f;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},D=class i{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||np(e.parent)||document,this.viewState=new xs(this,e.state||G.create(e)),e.scrollTo&&e.scrollTo.is(Jn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ui).map(s=>new Ui(s));for(let s of this.plugins)s.update(this);this.observer=new Ro(this),this.inputState=new vo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ms(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof se?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Sf))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Cf(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(G.phrases)!=this.state.facet(G.phrases))return this.setState(r);s=ds.create(this,r,e),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(i.cursorScrollMargin);c=new Ki(d.empty?d:w.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(Jn)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=ks.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Wi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(is)!=s.state.facet(is)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(lo))try{u(s)}catch(d){Ce(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!gf(this,f)&&h.force&&bi(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 n of this.plugins)n.destroy(this);this.viewState=new xs(this,e),this.plugins=e.facet(ui).map(n=>new Ui(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new ms(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(ui),n=e.state.facet(ui);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new Ui(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Ce(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(qh(n||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();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 f=h.map(d=>{try{return d.read(this)}catch(p){return Ce(this.state,p),kh}}),c=ds.create(this,this.state,[]),u=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(f[d]!=kh)try{let p=h[d];p.write&&p.write(f[d],this)}catch(p){Ce(this.state,p)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((p>1||p<-1)&&!(T.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,n?r<0?n.scrollTop=n.scrollHeight:n.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(lo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(Eo)?Lf:Mf)+" "+this.state.facet(is)}updateAttrs(){let e=vh(this,af,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(dt)?"true":"false",class:"cm-content",style:`${T.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),vh(this,Ts,t);let n=this.observer.ignore(()=>{let s=eh(this.contentDOM,this.contentAttrs,t),r=eh(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Wi);let e=this.state.facet(i.cspNonce);He.mount(this.root,this.styleModules.concat(am).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Kr(this,e,oh(this,e,t,n))}moveByGroup(e,t){return Kr(this,e,oh(this,e,t,n=>Ep(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return w.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return Op(this,e,t,n)}moveVertically(e,t,n){return Kr(this,e,Ip(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=yo(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),yo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),s=this.bidiSpans(n),r=s[Ve.find(s,e-n.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==K.RTL)}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(sf)||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>cm)return Xh(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Gh(r.isolates,n=nh(this,e))))return r.order;n||(n=nh(this,e));let s=cp(e.text,t,n);return this.bidiCache.push(new ks(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||T.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{zh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,s,r,o;return Jn.of(new Ki(typeof e=="number"?w.cursor(e):e,(n=t.y)!==null&&n!==void 0?n:"nearest",(s=t.x)!==null&&s!==void 0?s:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Jn.of(new Ki(w.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ne.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ne.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=He.newName(),s=[is.of(n),Wi.of(_o(`.${n}`,e))];return t&&t.dark&&s.push(Eo.of(!0)),s}static baseTheme(e){return ft.lowest(Wi.of(_o("."+Io,e,Tf)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&ie.get(n)||ie.get(e);return((t=s?.root)===null||t===void 0?void 0:t.view)||null}};D.styleModule=Wi;D.inputHandler=tf;D.clipboardInputFilter=Qo;D.clipboardOutputFilter=Zo;D.scrollHandler=of;D.focusChangeEffect=nf;D.perLineTextDirection=sf;D.exceptionSink=ef;D.updateListener=lo;D.editable=dt;D.mouseSelectionStyle=Zh;D.dragMovesSelection=Qh;D.clickAddsSelectionRange=Jh;D.decorations=Ds;D.blockWrappers=hf;D.outerDecorations=el;D.atomicRanges=rn;D.bidiIsolatedRanges=ff;D.cursorScrollMargin=L.define({combine:i=>{let e=5,t=5;for(let n of i)typeof n=="number"?e=t=n:{x:e,y:t}=n;return{x:e,y:t}}});D.scrollMargins=cf;D.darkTheme=Eo;D.cspNonce=L.define({combine:i=>i.length?i[0]:""});D.contentAttributes=Ts;D.editorAttributes=af;D.lineWrapping=D.contentAttributes.of({class:"cm-lineWrapping"});D.announce=R.define();var cm=4096,kh={},ks=class i{constructor(e,t,n,s,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:K.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&n.push(new i(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}};function vh(i,e,t){for(let n=i.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&Xo(o,t)}return t}var um=T.mac?"mac":T.windows?"win":T.linux?"linux":"key";function dm(i,e){let t=i.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let s,r,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))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function ns(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}var pm=ft.default(D.domEventHandlers({keydown(i,e){return Of(Df(e.state),i,e,"editor")}})),Os=L.define({enables:pm}),Sh=new WeakMap;function Df(i){let e=i.facet(Os),t=Sh.get(e);return t||Sh.set(e,t=gm(e.reduce((n,s)=>n.concat(s),[]))),t}function Bf(i,e,t){return Of(Df(i.state),e,i,t)}var xt=null,mm=4e3;function gm(i,e=um){let t=Object.create(null),n=Object.create(null),s=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,f)=>{var c,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>dm(b,e));for(let b=1;b<p.length;b++){let k=p.slice(0,b).join(" ");s(k,!0),d[k]||(d[k]={preventDefault:!0,stopPropagation:!1,run:[x=>{let B=xt={view:x,prefix:k,scope:o};return setTimeout(()=>{xt==B&&(xt=null)},mm),!0}]})}let m=p.join(" ");s(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),f&&(g.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=t[h]||(t[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,No))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var No=null;function Of(i,e,t,n){No=e;let s=Xa(e),r=je(s,0),o=wt(r)==s.length&&s!=" ",l="",a=!1,h=!1,f=!1;xt&&xt.view==t&&xt.scope==n&&(l=xt.prefix+" ",wf.indexOf(e.keyCode)<0&&(h=!0,xt=null));let c=new Set,u=g=>{if(g){for(let b of g.run)if(!c.has(b)&&(c.add(b),b(t)))return g.stopPropagation&&(f=!0),!0;g.preventDefault&&(g.stopPropagation&&(f=!0),h=!0)}return!1},d=i[n],p,m;return d&&(u(d[l+ns(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(T.windows&&e.ctrlKey&&e.altKey)&&!(T.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ut[e.keyCode])&&p!=s?(u(d[l+ns(p,e,!0)])||e.shiftKey&&(m=fi[e.keyCode])!=s&&m!=p&&u(d[l+ns(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+ns(s,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&f&&e.stopPropagation(),No=null,a}var zt=class i{constructor(e,t,n,s,r){this.className=e,this.left=t,this.top=n,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=Ef(e);return[new i(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return bm(e,t,n)}};function Ef(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==K.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Ch(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let r=i.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=i.posAtCoords({x:r.left+1,y:o}),a=i.posAtCoords({x:r.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function bm(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),r=i.textDirection==K.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Ef(i),h=o.querySelector(".cm-line"),f=h&&window.getComputedStyle(h),c=l.left+(f?parseInt(f.paddingLeft)+Math.min(0,parseInt(f.textIndent)):0),u=l.right-(f?parseInt(f.paddingRight):0),d=bo(i,n,1),p=bo(i,s,-1),m=d.type==ue.Text?d:null,g=p.type==ue.Text?p:null;if(m&&(i.lineWrapping||d.widgetLineBreaks)&&(m=Ch(i,n,1,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=Ch(i,s,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return k(x(t.from,t.to,m));{let v=m?x(t.from,null,m):B(d,!1),C=g?x(null,t.to,g):B(p,!0),A=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&v.bottom+i.defaultLineHeight/2<C.top?A.push(b(c,v.bottom,u,C.top)):v.bottom<C.top&&i.elementAtHeight((v.bottom+C.top)/2).type==ue.Text&&(v.bottom=C.top=(v.bottom+C.top)/2),k(v).concat(A).concat(k(C))}function b(v,C,A,N){return new zt(e,v-a.left,C-a.top,Math.max(0,A-v),N-C)}function k({top:v,bottom:C,horizontal:A}){let N=[];for(let W=0;W<A.length;W+=2)N.push(b(A[W],v,A[W+1],C));return N}function x(v,C,A){let N=1e9,W=-1e9,Y=[];function H($,Q,me,Me,Ze){let fe=i.coordsAtPos($,$==A.to?-2:2),_e=i.coordsAtPos(me,me==A.from?2:-2);!fe||!_e||(N=Math.min(fe.top,_e.top,N),W=Math.max(fe.bottom,_e.bottom,W),Ze==K.LTR?Y.push(r&&Q?c:fe.left,r&&Me?u:_e.right):Y.push(!r&&Me?c:_e.left,!r&&Q?u:fe.right))}let I=v??A.from,j=C??A.to;for(let $ of i.visibleRanges)if($.to>I&&$.from<j)for(let Q=Math.max($.from,I),me=Math.min($.to,j);;){let Me=i.state.doc.lineAt(Q);for(let Ze of i.bidiSpans(Me)){let fe=Ze.from+Me.from,_e=Ze.to+Me.from;if(fe>=me)break;_e>Q&&H(Math.max(fe,Q),v==null&&fe<=I,Math.min(_e,me),C==null&&_e>=j,Ze.dir)}if(Q=Me.to+1,Q>=me)break}return Y.length==0&&H(I,v==null,j,C==null,i.textDirection),{top:N,bottom:W,horizontal:Y}}function B(v,C){let A=l.top+(C?v.top:v.bottom);return{top:A,bottom:A,horizontal:[]}}}function ym(i,e){return i.constructor==e.constructor&&i.eq(e)}var Ho=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(ls)!=e.state.facet(ls)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(ls);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!ym(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,T.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},ls=L.define();function If(i){return[ne.define(e=>new Ho(e,i)),ls.of(i)]}var Si=L.define({combine(i){return ye(i,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function _f(i={}){return[Si.of(i),wm,xm,vm,rf.of(!0)]}function Rf(i){return i.startState.facet(Si)!=i.state.facet(Si)}var wm=If({above:!0,markers(i){let{state:e}=i,t=e.facet(Si),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor&&!(r&&T.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:w.cursor(s.head,s.assoc);for(let a of zt.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Rf(i);return t&&Ah(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Ah(e.state,i)},class:"cm-cursorLayer"});function Ah(i,e){e.style.animationDuration=i.facet(Si).cursorBlinkRate+"ms"}var xm=If({above:!1,markers(i){let e=[],{main:t,ranges:n}=i.state.selection;for(let s of n)if(!s.empty)for(let r of zt.forRange(i,"cm-selectionBackground",s))e.push(r);if(T.ios&&!t.empty&&i.state.facet(Si).iosSelectionHandles){for(let s of zt.forRange(i,"cm-selectionHandle cm-selectionHandle-start",w.cursor(t.from,1)))e.push(s);for(let s of zt.forRange(i,"cm-selectionHandle cm-selectionHandle-end",w.cursor(t.to,1)))e.push(s)}return e},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Rf(i)},class:"cm-selectionLayer"}),km=T.gecko&&T.gecko_version==153?"#ffffff01":"transparent",vm=ft.highest(D.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${km} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Pf=R.define({map(i,e){return i==null?null:e.mapPos(i)}}),zi=te.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(Pf)?n.value:t,i)}}),Sm=ne.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(zi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(zi)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(zi),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(zi)!=i&&this.view.dispatch({effects:Pf.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Nf(){return[zi,Sm]}function Mh(i,e,t,n,s){e.lastIndex=0;for(let r=i.iterRange(t,n),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function Cm(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:r}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),r=Math.min(i.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}var Fo=class{constructor(e){let{regexp:t,decoration:n,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,h,f)=>s(f,h,h+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,h,f)=>{let c=n(l,a,h);c&&f(h,h+l[0].length,c)};else if(n)this.addMatch=(l,a,h,f)=>f(h,h+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Ne,n=t.add.bind(t);for(let{from:s,to:r}of Cm(e,this.maxLength))Mh(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),s=Math.max(a,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,f=Math.max(r.from,a.from),c=Math.min(r.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){f=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){c=l;break}}let u=[],d,p=(m,g,b)=>u.push(b.range(m,g));if(a==h)for(this.regexp.lastIndex=f-a.from;(d=this.regexp.exec(a.text))&&d.index<c-a.from;)this.addMatch(d,e,d.index+a.from,p);else Mh(e.state.doc,this.regexp,f,c,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:f,filterTo:c,filter:(m,g)=>m<f||g>c,add:u})}}return t}},Wo=/x/.unicode!=null?"gu":"g",Am=new RegExp(`[\0-\b
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Wo),Mm={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"},Gr=null;function Lm(){var i;if(Gr==null&&typeof document<"u"&&document.body){let e=document.body.style;Gr=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Gr||!1}var as=L.define({combine(i){let e=ye(i,{render:null,specialChars:Am,addSpecialChars:null});return(e.replaceTabs=!Lm())&&(e.specialChars=new RegExp("	|"+e.specialChars.source,Wo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Wo)),e}});function Hf(i={}){return[as.of(i),Tm()]}var Lh=null;function Tm(){return Lh||(Lh=ne.fromClass(class{constructor(i){this.view=i,this.decorations=O.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(as)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new Fo({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=je(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=ct(o.text,l,n-o.from);return O.replace({widget:new zo((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=O.replace({widget:new Vo(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(as);i.startState.facet(as)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}var Dm="\u2022";function Bm(i){return i>=32?Dm:i==10?"\u2424":String.fromCharCode(9216+i)}var Vo=class extends De{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Bm(this.code),n=e.state.phrase("Control character")+" "+(Mm[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}},zo=class extends De{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}},Th=ne.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(i){let{view:e}=i,t=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;t>=0&&t!=this.height&&(this.height=t,this.attrs={style:`padding-bottom: ${t}px`})}});function Ff(){return[Th,Ts.of(i=>{var e;return((e=i.plugin(Th))===null||e===void 0?void 0:e.attrs)||null})]}function Wf(){return Em}var Om=O.line({class:"cm-activeLine"}),Em=ne.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(Om.range(s.from)),e=s.from)}return O.set(t)}},{decorations:i=>i.decorations}),qo=class extends De{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?$i(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=nn(t[0],n.direction!="rtl"),r=parseInt(n.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}};function Vf(i){let e=ne.fromClass(class{constructor(t){this.view=t,this.placeholder=i?O.set([O.widget({widget:new qo(i),side:1}).range(0)]):O.none}get decorations(){return this.view.state.doc.length?O.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,D.contentAttributes.of({"aria-placeholder":i})]:e}var $o=2e3;function Im(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>$o||t.off>$o||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=s;a++){let h=i.doc.line(a);h.length<=l&&r.push(w.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=s;a++){let h=i.doc.line(a),f=Xn(h.text,o,i.tabSize,!0);if(f<0)r.push(w.cursor(h.to));else{let c=Xn(h.text,l,i.tabSize);r.push(w.range(h.from+f,h.from+c))}}}return r}function _m(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Dh(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,r=s>$o?-1:s==n.length?_m(i,e.clientX):ct(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function Rm(i,e){let t=Dh(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(s.changes)}},get(s,r,o){let l=Dh(i,s);if(!l)return n;let a=Im(i.state,t,l);return a.length?o?w.create(a.concat(n.ranges)):w.create(a):n}}:null}function zf(i){let e=i?.eventFilter||(t=>t.altKey&&t.button==0);return D.mouseSelectionStyle.of((t,n)=>e(n)?Rm(t,n):null)}var Pm={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Nm={style:"cursor: crosshair"};function qf(i={}){let[e,t]=Pm[i.key||"Alt"],n=ne.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,D.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?Nm:null})]}var ss="-10000px",vs=class{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=n(o,r))}update(e,t){var n;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let h=r[a],f=-1;if(h){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==h.create&&(f=c)}if(f<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let c=o[a]=this.tooltipViews[f];l&&(l[a]=t[f]),c.update&&c.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}};function Hm(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Xr=L.define({combine:i=>{var e,t,n;return{position:T.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Hm}}}),Bh=new WeakMap,$f=ne.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Xr);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new vs(i,on,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Xr);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ss,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(T.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(i=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=tl(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Xr).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:r}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:f}=h,c=i.pos[l],u=i.size[l];if(!c||a.clip!==!1&&(c.bottom<=Math.max(t.top,n.top)||c.top>=Math.min(t.bottom,n.bottom)||c.right<Math.max(t.left,n.left)-.1||c.left>Math.min(t.right,n.right)+.1)){f.style.top=ss;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=Bh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,b=h.offset||Wm,k=this.view.textDirection==K.LTR,x=u.width>n.right-n.left?k?n.left:n.right-u.width:k?Math.max(n.left,Math.min(c.left-(d?14:0)+b.x,n.right-m)):Math.min(Math.max(n.left,c.left-m+(d?14:0)-b.x),n.right-m),B=this.above[l];!a.strictSide&&(B?c.top-g-p-b.y<n.top:c.bottom+g+p+b.y>n.bottom)&&B==n.bottom-c.bottom>c.top-n.top&&(B=this.above[l]=!B);let v=(B?c.top-n.top:n.bottom-c.bottom)-p;if(v<g&&h.resize!==!1){if(v<this.view.defaultLineHeight){f.style.top=ss;continue}Bh.set(h,g),f.style.height=(g=v)/r+"px"}else f.style.height&&(f.style.height="");let C=B?c.top-g-p-b.y:c.bottom+p+b.y,A=x+m;if(h.overlap!==!0)for(let N of o)N.left<A&&N.right>x&&N.top<C+g&&N.bottom>C&&(C=B?N.top-g-2-p:N.bottom+p+2);if(this.position=="absolute"?(f.style.top=(C-i.parent.top)/r+"px",Oh(f,(x-i.parent.left)/s)):(f.style.top=C/r+"px",Oh(f,x/s)),d){let N=c.left+(k?b.x:-b.x)-(x+14-7);d.style.left=N/s+"px"}h.overlap!==!0&&o.push({left:x,top:C,right:A,bottom:C+g}),f.classList.toggle("cm-tooltip-above",B),f.classList.toggle("cm-tooltip-below",!B),h.positioned&&h.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=ss}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Oh(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}var Fm=D.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Wm={x:0,y:0},on=L.define({enables:[$f,Fm]}),Ss=L.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])}),Cs=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new vs(e,Ss,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},Vm=on.compute([Ss],i=>{let e=i.facet(Ss);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Cs.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),jf=L.define(),jo=class{constructor(e,t,n,s,r,o){this.view=e,this.source=t,this.field=n,this.locked=s,this.setHover=r,this.hoverTime=o,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(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let s,r=1;if(n.isWidget())s=n.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let o=e.coordsAtPos(s);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),a=l&&l.dir==K.RTL?-1:1;r=t.x<o.left?-a:a}this.activateHover(e,s,r)}activateHover(e,t,n,s){let r=this.source(e,t,n),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];s&&this.locked.set(a,s),e.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:t};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>Ce(e.state,a,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin($f),t=e?e.manager.tooltips.findIndex(n=>n.create==Cs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&!this.locked.has(s)&&r&&!zm(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!qm(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},rs=4;function zm(i,e){let{left:t,right:n,top:s,bottom:r}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-rs&&e.clientX<=n+rs&&e.clientY>=s-rs&&e.clientY<=r+rs}function qm(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=i.posAtCoords({x:n,y:s},!1);return a>=e&&a<=t}function Kf(i,e={}){let t=R.define(),n=new WeakMap,s=te.define({create(){return[]},update(o,l){let a=n.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let f of o){let c=l.changes.mapPos(f.pos,-1,ce.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),f);u.pos=c,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is($m)&&!h.value||h.value==s)&&(o=[]);return o.length&&a&&n.set(o,a),o},provide:o=>Ss.from(o)}),r=ne.define(o=>new jo(o,i,s,n,t,e.hoverTime||300));return{active:s,extension:[s,r,jf.of(r),Vm]}}function Uf(i,e,t,n={}){var s;let r=i.state.facet(jf).map(o=>i.plugin(o)).filter(o=>!!o);if(n.tooltip&&n.tooltip.active){let o=r.find(l=>l.field==n.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(i,e,t,(s=n.until)!==null&&s!==void 0?s:(()=>!1))}var $m=R.define();var Eh=L.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ln(i,e){let t=i.plugin(Gf),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}var Gf=ne.fromClass(class{constructor(i){this.input=i.state.facet(Kt),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(Eh);this.top=new pi(i,!0,e.topContainer),this.bottom=new pi(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(Eh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new pi(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new pi(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Kt);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let h=this.specs.indexOf(a),f;h<0?(f=a(i.view),l.push(f)):(f=this.panels[h],f.update&&f.update(i)),s.push(f),(f.top?r:o).push(f)}this.specs=n,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>D.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),pi=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";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=Ih(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ih(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 Ih(i){let e=i.nextSibling;return i.remove(),e}var Kt=L.define({enables:Gf});function Xf(i,e){let t,n=new Promise(o=>t=o),s=o=>jm(o,e,t);i.state.field(Yr,!1)?i.dispatch({effects:Yf.of(s)}):i.dispatch({effects:R.appendConfig.of(Yr.init(()=>[s]))});let r=Jf.of(s);return{close:r,result:n.then(o=>((i.win.queueMicrotask||(a=>i.win.setTimeout(a,10)))(()=>{i.state.field(Yr).indexOf(s)>-1&&i.dispatch({effects:r})}),o))}}var Yr=te.define({create(){return[]},update(i,e){for(let t of e.effects)t.is(Yf)?i=[t.value].concat(i):t.is(Jf)&&(i=i.filter(n=>n!=t.value));return i},provide:i=>Kt.computeN([i],e=>e.field(i))}),Yf=R.define(),Jf=R.define();function jm(i,e,t){let n=e.content?e.content(i,()=>o(null)):null;if(!n){if(n=q("form"),e.input){let l=q("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),n.appendChild(q("label",(e.label||"")+": ",l))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(q("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let l=0;l<s.length;l++){let a=s[l];a.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let r=q("div",n,q("button",{onclick:()=>o(null),"aria-label":i.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(l){r.contains(r.ownerDocument.activeElement)&&i.focus(),t(l)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=n.querySelector(e.focus):l=n.querySelector("input")||n.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}var Be=class extends Pe{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Be.prototype.elementClass="";Be.prototype.toDOM=void 0;Be.prototype.mapMode=ce.TrackBefore;Be.prototype.startSide=Be.prototype.endSide=-1;Be.prototype.point=!0;var hs=L.define(),Km=L.define(),Um={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>V.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Ji=L.define();function nl(i){return[Qf(),Ji.of({...Um,...i})]}var Ko=L.define({combine:i=>i.some(e=>e)});function Qf(i){let e=[Gm];return i&&i.fixed===!1&&e.push(Ko.of(!0)),e}var Gm=ne.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(Ji).map(e=>new As(i,e)),this.fixed=!i.state.facet(Ko);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ko)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=V.iter(this.view.state.facet(hs),this.view.viewport.from),n=[],s=this.gutters.map(r=>new Go(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==ue.Text&&o){Uo(t,n,l.from);for(let a of s)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==ue.Text){Uo(t,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(Ji),t=i.state.facet(Ji),n=i.docChanged||i.heightChanged||i.viewportChanged||!V.eq(i.startState.facet(hs),i.state.facet(hs),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new As(this.view,r)):(this.gutters[o].update(i),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>D.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==K.LTR?{left:n,right:s}:{right:n,left:s}})});function _h(i){return Array.isArray(i)?i:[i]}function Uo(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var Go=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=V.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Ms(e,o,r,n);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];Uo(this.cursor,s,t.from),n.length&&(s=s.concat(n));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let r of e.state.facet(Km)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},As=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 n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,s)&&s.preventDefault()});this.markers=_h(t.markers(e)),t.initialSpacer&&(this.spacer=new Ms(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=_h(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!V.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Ms=class{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Xm(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let f=a.elementClass;f&&(n+=" "+f);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){l=c,h=!0;break}}else l=this.markers.length;for(;o<l;){let f=this.markers[o++];if(f.toDOM){f.destroy(s);let c=s.nextSibling;s.remove(),s=c}}if(!a)break;a.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),h&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Xm(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}var Ym=L.define(),Jm=L.define(),mi=L.define({combine(i){return ye(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let s in t){let r=n[s],o=t[s];n[s]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return n}})}}),Qi=class extends Be{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Jr(i,e){return i.state.facet(mi).formatNumber(e,i.state)}var Qm=Ji.compute([mi],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Ym)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new Qi(Jr(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(Jm)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(mi)!=e.state.facet(mi),initialSpacer(e){return new Qi(Jr(e,Rh(e.state.doc.lines)))},updateSpacer(e,t){let n=Jr(t.view,Rh(t.view.state.doc.lines));return n==e.number?e:new Qi(n)},domEventHandlers:i.facet(mi).domEventHandlers,side:"before"}));function Zf(i={}){return[mi.of(i),Qf(),Qm]}function Rh(i){let e=9;for(;e<i;)e=e*10+9;return e}var Zm=new class extends Be{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},eg=hs.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(Zm.range(s)))}return V.of(e)});function ec(){return eg}var tg=0,an=class{constructor(e,t){this.from=e,this.to=t}},_=class{constructor(e={}){this.id=tg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=he.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};_.closedBy=new _({deserialize:i=>i.split(" ")});_.openedBy=new _({deserialize:i=>i.split(" ")});_.group=new _({deserialize:i=>i.split(" ")});_.isolate=new _({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});_.contextHash=new _({perNode:!0});_.lookAhead=new _({perNode:!0});_.mounted=new _({perNode:!0});var Ut=class{constructor(e,t,n,s=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=s}static get(e){return e&&e.props&&e.props[_.mounted.id]}},ig=Object.create(null),he=class i{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):ig,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new i(e.name||"",t,e.id,n);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}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(_.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(_.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}};he.none=new he("",Object.create(null),0,8);var Ci=class i{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 n of this.types){let s=null;for(let r of e){let o=r(n);if(o){s||(s=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}t.push(s?new he(n.name,s,n.id,n.flags):n)}return new i(t)}},Es=new WeakMap,tc=new WeakMap,re;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed"})(re||(re={}));var ee=class i{constructor(e,t,n,s,r){if(this.type=e,this.children=t,this.positions=n,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ut.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let s=n.toString();s&&(t&&(t+=","),t+=s)}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 cn(this.topNode,e)}cursorAt(e,t=0,n=0){let s=Es.get(this)||this.topNode,r=new cn(s);return r.moveTo(e,t),Es.set(this,r._tree),r}get topNode(){return new nt(this,0,0,null)}resolve(e,t=0){let n=hn(Es.get(this)||this.topNode,e,t,!1);return Es.set(this,n),n}resolveInner(e,t=0){let n=hn(tc.get(this)||this.topNode,e,t,!0);return tc.set(this,n),n}resolveStack(e,t=0){return ng(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&re.IncludeAnonymous)>0;for(let a=this.cursor(o|re.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(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:fl(he.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new i(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new i(he.none,t,n,s)))}static build(e){return sg(e)}};ee.empty=new ee(he.none,[],[],0);var sl=class i{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 i(this.buffer,this.index)}},Ct=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return he.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],n=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,n==e)return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(sc(r,s,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,t,n){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=s[l++],r[a++]=s[l++]-n;let h=r[a++]=s[l++]-n;r[a++]=s[l++]-e,o=Math.max(o,h)}return new i(r,o,this.set)}};function sc(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function hn(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof nt&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:re.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof nt&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,r);if(!o)return i;i=o}}var _s=class{cursor(e=0){return new cn(this,e)}getChild(e,t=null,n=null){let s=ic(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return ic(this,e,t,n)}resolve(e,t=0){return hn(this,e,t,!1)}resolveInner(e,t=0){return hn(this,e,t,!0)}matchContext(e){return rl(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(n=t,t=s.prevSibling):t=s}return n}get node(){return this}get next(){return this.parent}},nt=class i extends _s{constructor(e,t,n,s){super(),this._tree=e,this.from=t,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let f=l[e],c=a[e]+o.from,u;if(!(!(r&re.EnterBracketed&&f instanceof ee&&(u=Ut.get(f))&&!u.overlay&&u.bracketed&&n>=c&&n<=c+f.length)&&!sc(s,n,c,c+f.length))){if(f instanceof Ct){if(r&re.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,t,n-c,s);if(d>-1)return new fn(new ol(o,f,e,c),null,d)}else if(r&re.IncludeAnonymous||!f.type.isAnonymous||hl(f)){let d;if(!(r&re.IgnoreMounts)&&(d=Ut.get(f))&&!d.overlay)return new i(d.tree,c,e,o);let p=new i(f,c,e,o);return r&re.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?f.children.length-1:0,t,n,s,r)}}}if(r&re.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)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let s;if(!(n&re.IgnoreOverlays)&&(s=Ut.get(this._tree))&&s.overlay){let r=e-this.from,o=n&re.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new i(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 ic(i,e,t,n){let s=i.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(n!=null&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return n==null?r:[]}}function rl(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var ol=class{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}},fn=class i extends _s{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,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new i(this.context,this,r)}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)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&re.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new i(this.context,this,r)}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 i(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 i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,r=n.buffer[this.index+3];if(r>s){let o=n.buffer[this.index+1];e.push(n.slice(s,r,o)),t.push(0)}return new ee(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function rc(i){if(!i.length)return null;let e=0,t=i[0];for(let r=1;r<i.length;r++){let o=i[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let n=t instanceof nt&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new ll(s,t)}var ll=class{constructor(e,t){this.heads=e,this.node=t}get next(){return rc(this.heads)}};function ng(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof nt?n:n.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[n])).push(o.resolve(e,t)),r=o}else{let o=Ut.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new nt(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(hn(l,e,t,!1))}}return s?rc(s):n}var cn=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~re.EnterBracketed,e instanceof nt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof nt?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}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,n=this.mode){return this.buffer?n&re.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&re.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&re.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,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<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,n,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:n}=s)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,o=e<0?-1:n._tree.children.length;r!=o;r+=e){let l=n._tree.children[r];if(this.mode&re.IncludeAnonymous||l instanceof Ct||!l.type.isAnonymous||hl(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,n=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,n=r+1;break e}s=this.stack[--r]}for(let s=n;s<this.stack.length;s++)t=new fn(this.buffer,t,this.stack[s]);return this.bufferNode=new fn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return rl(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return rl(this._tree,e,s);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}};function hl(i){return i.children.some(e=>e instanceof Ct||!e.type.isAnonymous||hl(e))}function sg(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=1024,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new sl(t,t.length):t,a=n.types,h=0,f=0;function c(v,C,A,N,W,Y){let{id:H,start:I,end:j,size:$}=l,Q=f,me=h;if($<0)if(l.next(),$==-1){let at=r[H];A.push(at),N.push(I-v);return}else if($==-3){h=H;return}else if($==-4){f=H;return}else throw new RangeError(`Unrecognized record size: ${$}`);let Me=a[H],Ze,fe,_e=I-v;if(j-I<=s&&(fe=g(l.pos-C,W))){let at=new Uint16Array(fe.size-fe.skip),Re=l.pos-fe.size,et=at.length;for(;l.pos>Re;)et=b(fe.start,at,et);Ze=new Ct(at,j-fe.start,n),_e=fe.start-v}else{let at=l.pos-$;l.next();let Re=[],et=[],_t=H>=o?H:-1,ri=0,Pn=j;for(;l.pos>at;)_t>=0&&l.id==_t&&l.size>=0?(l.end<=Pn-s&&(p(Re,et,I,ri,l.end,Pn,_t,Q,me),ri=Re.length,Pn=l.end),l.next()):Y>2500?u(I,at,Re,et):c(I,at,Re,et,_t,Y+1);if(_t>=0&&ri>0&&ri<Re.length&&p(Re,et,I,ri,I,Pn,_t,Q,me),Re.reverse(),et.reverse(),_t>-1&&ri>0){let va=d(Me,me);Ze=fl(Me,Re,et,0,Re.length,0,j-I,va,va)}else Ze=m(Me,Re,et,j-I,Q-j,me)}A.push(Ze),N.push(_e)}function u(v,C,A,N){let W=[],Y=0,H=-1;for(;l.pos>C;){let{id:I,start:j,end:$,size:Q}=l;if(Q>4)l.next();else{if(H>-1&&j<H)break;H<0&&(H=$-s),W.push(I,j,$),Y++,l.next()}}if(Y){let I=new Uint16Array(Y*4),j=W[W.length-2];for(let $=W.length-3,Q=0;$>=0;$-=3)I[Q++]=W[$],I[Q++]=W[$+1]-j,I[Q++]=W[$+2]-j,I[Q++]=Q;A.push(new Ct(I,W[2]-j,n)),N.push(j-v)}}function d(v,C){return(A,N,W)=>{let Y=0,H=A.length-1,I,j;if(H>=0&&(I=A[H])instanceof ee){if(!H&&I.type==v&&I.length==W)return I;(j=I.prop(_.lookAhead))&&(Y=N[H]+I.length+j)}return m(v,A,N,W,Y,C)}}function p(v,C,A,N,W,Y,H,I,j){let $=[],Q=[];for(;v.length>N;)$.push(v.pop()),Q.push(C.pop()+A-W);v.push(m(n.types[H],$,Q,Y-W,I-Y,j)),C.push(W-A)}function m(v,C,A,N,W,Y,H){if(Y){let I=[_.contextHash,Y];H=H?[I].concat(H):[I]}if(W>25){let I=[_.lookAhead,W];H=H?[I].concat(H):[I]}return new ee(v,C,A,N,H)}function g(v,C){let A=l.fork(),N=0,W=0,Y=0,H=A.end-s,I={size:0,start:0,skip:0};e:for(let j=A.pos-v;A.pos>j;){let $=A.size;if(A.id==C&&$>=0){I.size=N,I.start=W,I.skip=Y,Y+=4,N+=4,A.next();continue}let Q=A.pos-$;if($<0||Q<j||A.start<H)break;let me=A.id>=o?4:0,Me=A.start;for(A.next();A.pos>Q;){if(A.size<0)if(A.size==-3||A.size==-4)me+=4;else break e;else A.id>=o&&(me+=4);A.next()}W=Me,N+=$,Y+=me}return(C<0||N==v)&&(I.size=N,I.start=W,I.skip=Y),I.size>4?I:void 0}function b(v,C,A){let{id:N,start:W,end:Y,size:H}=l;if(l.next(),H>=0&&N<o){let I=A;if(H>4){let j=l.pos-(H-4);for(;l.pos>j;)A=b(v,C,A)}C[--A]=I,C[--A]=Y-v,C[--A]=W-v,C[--A]=N}else H==-3?h=N:H==-4&&(f=N);return A}let k=[],x=[];for(;l.pos>0;)c(i.start||0,i.bufferStart||0,k,x,-1,0);let B=(e=i.length)!==null&&e!==void 0?e:k.length?x[0]+k[0].length:0;return new ee(a[i.topID],k.reverse(),x.reverse(),B)}var nc=new WeakMap;function Is(i,e){if(!i.isAnonymous||e instanceof Ct||e.type!=i)return 1;let t=nc.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof ee)){t=1;break}t+=Is(i,n)}nc.set(e,t)}return t}function fl(i,e,t,n,s,r,o,l,a){let h=0;for(let p=n;p<s;p++)h+=Is(i,e[p]);let f=Math.ceil(h*1.5/8),c=[],u=[];function d(p,m,g,b,k){for(let x=g;x<b;){let B=x,v=m[x],C=Is(i,p[x]);for(x++;x<b;x++){let A=Is(i,p[x]);if(C+A>=f)break;C+=A}if(x==B+1){if(C>f){let A=p[B];d(A.children,A.positions,0,A.children.length,m[B]+k);continue}c.push(p[B])}else{let A=m[x-1]+p[x-1].length-v;c.push(fl(i,p,m,B,x,v,A,null,a))}u.push(v+k-r)}}return d(e,t,n,s,0),(l||a)(c,u,o)}var Gt=class i{constructor(e,t,n,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new i(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<t.length?t[l]:null,c=f?f.fromA:1e9;if(c-a>=n)for(;o&&o.from<c;){let u=o;if(a>=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new i(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=r<e.length?e[r++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return s}},Ai=class{startParse(e,t,n){return typeof e=="string"&&(e=new al(e)),n=n?n.length?n.map(s=>new an(s.from,s.to)):[new an(0,0)]:[new an(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let r=s.advance();if(r)return r}}},al=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 E1=new _({perNode:!0});var rg=0,Oe=class i{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=rg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof i&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new i(n,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new Hs(e);return n=>n.modified.indexOf(t)>-1?n:Hs.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}},og=0,Hs=class i{constructor(e){this.name=e,this.instances=[],this.id=og++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&lg(t,l.modified));if(n)return n;let s=[],r=new Oe(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=ag(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(i.get(l,a));return r}};function lg(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function ag(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function dn(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let f=new Yt(n,o,a>0?r.slice(0,a):null);e[h]=f.sort(e[h])}}return ac.add(e)}var ac=new _({combine(i,e){let t,n,s;for(;i||e;){if(!i||e&&i.depth>=e.depth?(s=e,e=e.next):(s=i,i=i.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Yt(s.tags,s.mode,s.context);t?t.next=r:n=r,t=r}return n}}),Yt=class{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}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}};Yt.empty=new Yt([],2,null);function pl(i,e){let t=Object.create(null);for(let r of i)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function hg(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function hc(i,e,t,n=0,s=i.length){let r=new ul(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}var ul=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,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,n,s,r){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,f=fg(e)||Yt.empty,c=hg(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(t,l),h),f.opaque)return;let u=e.tree&&e.tree.prop(_.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,b=l;;g++){let k=g<u.overlay.length?u.overlay[g]:null,x=k?k.from+l:a,B=Math.max(t,b),v=Math.min(n,x);if(B<v&&m)for(;e.from<v&&(this.highlightRange(e,B,v,s,r),this.startSpan(Math.min(v,e.to),h),!(e.to>=x||!e.nextSibling())););if(!k||x>n)break;b=k.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,k.from+l),Math.min(n,b),"",p),this.startSpan(Math.min(n,b),h))}m&&e.parent()}else if(e.firstChild()){u&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,r),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}};function fg(i){let e=i.type.prop(ac);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var M=Oe.define,Rs=M(),At=M(),oc=M(At),lc=M(At),Mt=M(),Ps=M(Mt),cl=M(Mt),ot=M(),Xt=M(ot),st=M(),rt=M(),dl=M(),un=M(dl),Ns=M(),y={comment:Rs,lineComment:M(Rs),blockComment:M(Rs),docComment:M(Rs),name:At,variableName:M(At),typeName:oc,tagName:M(oc),propertyName:lc,attributeName:M(lc),className:M(At),labelName:M(At),namespace:M(At),macroName:M(At),literal:Mt,string:Ps,docString:M(Ps),character:M(Ps),attributeValue:M(Ps),number:cl,integer:M(cl),float:M(cl),bool:M(Mt),regexp:M(Mt),escape:M(Mt),color:M(Mt),url:M(Mt),keyword:st,self:M(st),null:M(st),atom:M(st),unit:M(st),modifier:M(st),operatorKeyword:M(st),controlKeyword:M(st),definitionKeyword:M(st),moduleKeyword:M(st),operator:rt,derefOperator:M(rt),arithmeticOperator:M(rt),logicOperator:M(rt),bitwiseOperator:M(rt),compareOperator:M(rt),updateOperator:M(rt),definitionOperator:M(rt),typeOperator:M(rt),controlOperator:M(rt),punctuation:dl,separator:M(dl),bracket:un,angleBracket:M(un),squareBracket:M(un),paren:M(un),brace:M(un),content:ot,heading:Xt,heading1:M(Xt),heading2:M(Xt),heading3:M(Xt),heading4:M(Xt),heading5:M(Xt),heading6:M(Xt),contentSeparator:M(ot),list:M(ot),quote:M(ot),emphasis:M(ot),strong:M(ot),link:M(ot),monospace:M(ot),strikethrough:M(ot),inserted:M(),deleted:M(),changed:M(),invalid:M(),meta:Ns,documentMeta:M(Ns),annotation:M(Ns),processingInstruction:M(Ns),definition:Oe.defineModifier("definition"),constant:Oe.defineModifier("constant"),function:Oe.defineModifier("function"),standard:Oe.defineModifier("standard"),local:Oe.defineModifier("local"),special:Oe.defineModifier("special")};for(let i in y){let e=y[i];e instanceof Oe&&(e.name=i)}var R1=pl([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var ml,Jt=new _;function gc(i){return L.define({combine:i?e=>e.concat(i):void 0})}var cg=new _,Ae=class{constructor(e,t,n=[],s=""){this.data=e,this.name=s,G.prototype.hasOwnProperty("tree")||Object.defineProperty(G.prototype,"tree",{get(){return ke(this)}}),this.parser=t,this.extension=[Mi.of(this),G.languageData.of((r,o,l)=>{let a=fc(r,o,l),h=a.type.prop(Jt);if(!h)return[];let f=r.facet(h),c=a.type.prop(cg);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(n)}isActiveAt(e,t,n=-1){return fc(e,t,n).type.prop(Jt)==this.data}findRegions(e){let t=e.facet(Mi);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(Jt)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(_.mounted);if(l){if(l.tree.prop(Jt)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof ee&&s(h,r.positions[a]+o)}};return s(ke(e),0),n}get allowsNesting(){return!0}};Ae.setState=R.define();function fc(i,e,t){let n=i.facet(Mi),s=ke(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,re.ExcludeBuffers|re.EnterBracketed))r.type.isTop&&(s=r);return s}function ke(i){let e=i.field(Ae.state,!1);return e?e.tree:ee.empty}var wl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},pn=null,Fs=class i{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],ee.empty,0,n,[],null)}startParse(){return this.parser.startParse(new wl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ee.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Gt.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Gt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=pn;pn=this;try{return e()}finally{pn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=cc(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),n=Gt.applyChanges(n,a),s=ee.empty,r=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 f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);f<c&&l.push({from:f,to:c})}}}return new i(this.parser,t,n,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=cc(this.fragments,s,r),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ai{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=pn;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ee(he.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return pn}};function cc(i,e,t){return Gt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var mn=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Fs.create(e.facet(Mi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};Ae.state=te.define({create:mn.init,update(i,e){for(let t of e.effects)if(t.is(Ae.setState))return t.value;return e.startState.facet(Mi)!=e.state.facet(Mi)?mn.init(e.state):i.apply(e)}});var bc=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(bc=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var gl=typeof navigator<"u"&&(!((ml=navigator.scheduling)===null||ml===void 0)&&ml.isInputPending)?()=>navigator.scheduling.isInputPending():null,ug=ne.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(Ae.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(Ae.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=bc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,r=n.field(Ae.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!gl?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>gl&&gl()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ae.setState.of(new mn(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ce(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()}}}),Mi=L.define({combine(i){return i.length?i[0]:null},enables:i=>[Ae.state,ug,D.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});var dg=L.define(),Ti=L.define({combine:i=>{if(!i.length)return"  ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function gn(i){let e=i.facet(Ti);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function bn(i,e){let t="",n=i.tabSize,s=i.facet(Ti)[0];if(s=="	"){for(;e>=n;)t+="	",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Al(i,e){i instanceof G&&(i=new Qt(i));for(let n of i.state.facet(dg)){let s=n(i,e);if(s!==void 0)return s}let t=ke(i.state);return t.length>=e?pg(i,t,e):null}var Qt=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=gn(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return ct(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Ml=new _;function pg(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let r=[];for(let o=s;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return yc(n,i,t)}function yc(i,e,t){for(let n=i;n;n=n.next){let s=gg(n.node);if(s)return s(xl.create(e,t,n))}return 0}function mg(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function gg(i){let e=i.type.prop(Ml);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(_.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>xg(o,!0,1,void 0,r&&!mg(o)?s.from:void 0)}return i.parent==null?bg:null}function bg(){return 0}var xl=class i extends Qt{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(yg(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return yc(this.context.next,this.base,this.pos)}};function yg(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function wg(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,r=i.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function xg(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==i.pos+o,a=e?wg(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}var Ll=new _;var Li=class i{constructor(e,t){this.specs=e;let n;function s(l){let a=He.newName();return(n||(n=Object.create(null)))["."+a]=l,a}let r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Ae?l=>l.prop(Jt)==o.data:o?l=>l==o:void 0,this.style=pl(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new He(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},kl=L.define(),wc=L.define({combine(i){return i.length?[i[0]]:null}});function bl(i){let e=i.facet(kl);return e.length?e:i.facet(wc)}function xc(i,e){let t=[kg],n;return i instanceof Li&&(i.module&&t.push(D.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(wc.of(i)):n?t.push(kl.computeN([D.darkTheme],s=>s.facet(D.darkTheme)==(n=="dark")?[i]:[])):t.push(kl.of(i)),t}var vl=class{constructor(e){this.markCache=Object.create(null),this.tree=ke(e.state),this.decorations=this.buildDeco(e,bl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ke(e.state),n=bl(e.state),s=n!=bl(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return O.none;let n=new Ne;for(let{from:s,to:r}of e.visibleRanges)hc(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=O.mark({class:a})))},s,r);return n.finish()}},kg=ft.high(ne.fromClass(vl,{decorations:i=>i.decorations})),q1=Li.define([{tag:y.meta,color:"#404740"},{tag:y.link,textDecoration:"underline"},{tag:y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strong,fontWeight:"bold"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.keyword,color:"#708"},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:"#219"},{tag:[y.literal,y.inserted],color:"#164"},{tag:[y.string,y.deleted],color:"#a11"},{tag:[y.regexp,y.escape,y.special(y.string)],color:"#e40"},{tag:y.definition(y.variableName),color:"#00f"},{tag:y.local(y.variableName),color:"#30a"},{tag:[y.typeName,y.namespace],color:"#085"},{tag:y.className,color:"#167"},{tag:[y.special(y.variableName),y.macroName],color:"#256"},{tag:y.definition(y.propertyName),color:"#00c"},{tag:y.comment,color:"#940"},{tag:y.invalid,color:"#f00"}]),vg=D.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),kc=1e4,vc="()[]{}",Sc=L.define({combine(i){return ye(i,{afterCursor:!0,brackets:vc,maxScanDistance:kc,renderMatch:Ag})}}),Sg=O.mark({class:"cm-matchingBracket"}),Cg=O.mark({class:"cm-nonmatchingBracket"});function Ag(i){let e=[],t=i.matched?Sg:Cg;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}function uc(i){let e=[],t=i.facet(Sc);for(let n of i.selection.ranges){if(!n.empty)continue;let s=Xe(i,n.head,-1,t)||n.head>0&&Xe(i,n.head-1,1,t)||t.afterCursor&&(Xe(i,n.head,1,t)||n.head<i.doc.length&&Xe(i,n.head+1,-1,t));s&&(e=e.concat(t.renderMatch(s,i)))}return O.set(e,!0)}var Mg=ne.fromClass(class{constructor(i){this.paused=!1,this.decorations=uc(i.state)}update(i){(i.docChanged||i.selectionSet||this.paused)&&(i.view.composing?(this.decorations=this.decorations.map(i.changes),this.paused=!0):(this.decorations=uc(i.state),this.paused=!1))}},{decorations:i=>i.decorations}),Lg=[Mg,vg];function Cc(i={}){return[Sc.of(i),Lg]}var Tg=new _;function Sl(i,e,t){let n=i.prop(e<0?_.openedBy:_.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Cl(i){let e=i.type.prop(Tg);return e?e(i.node):i}function Xe(i,e,t,n={}){let s=n.maxScanDistance||kc,r=n.brackets||vc,o=ke(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=Sl(a.type,t,r);if(h&&a.from<a.to){let f=Cl(a);if(f&&(t>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return Dg(i,e,t,a,f,h,r)}}return Bg(i,e,t,o,l.type,s,r)}function Dg(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},h=0,f=l?.cursor();if(f&&(t<0?f.childBefore(n.from):f.childAfter(n.to)))do if(t<0?f.to<=n.from:f.from>=n.to){if(h==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=Cl(f);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Sl(f.type,t,o))h++;else if(Sl(f.type,-t,o)){if(h==0){let c=Cl(f);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(t<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function Bg(i,e,t,n,s,r,o){if(t<0?!e:e==i.doc.length)return null;let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},f=i.doc.iterRange(e,t>0?i.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let b=o.indexOf(d[m]);if(!(b<0||n.resolveInner(p+m,1).type!=s))if(b%2==0==t>0)c++;else{if(c==1)return{start:h,end:{from:p+m,to:p+m+1},matched:b>>1==a>>1};c--}}t>0&&(u+=d.length)}return f.done?{start:h,matched:!1}:null}var Og=Object.create(null),dc=[he.none];var pc=[],mc=Object.create(null),Eg=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Eg[i]=Ig(Og,e);function yl(i,e){pc.indexOf(i)>-1||(pc.push(i),console.warn(e))}function Ig(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=i[h]||y[h];f?typeof f=="function"?a.length?a=a.map(f):yl(h,`Modifier ${h} used at start of tag`):a.length?yl(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:yl(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=mc[s];if(r)return r.id;let o=mc[s]=he.define({id:dc.length,name:n,props:[dn({[n]:t})]});return dc.push(o),o.id}var $1={rtl:O.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:K.RTL}),ltr:O.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:K.LTR}),auto:O.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Q1=typeof navigator=="object"&&/Win/.test(navigator.platform);var yn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Zt=R.define({map(i,e){let t=e.mapPos(i,-1,ce.TrackAfter);return t??void 0}}),Dl=new class extends Pe{};Dl.startSide=1;Dl.endSide=-1;var Lc=te.define({create(){return V.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(Zt)&&(i=i.update({add:[Dl.range(t.value,t.value+1)]}));return i}});function Tc(){return[Rg,Lc]}var Tl="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function Dc(i){for(let e=0;e<Tl.length;e+=2)if(Tl.charCodeAt(e)==i)return Tl.charAt(e+1);return Gn(i<128?i:i+1)}function Bc(i,e){return i.languageDataAt("closeBrackets",e)[0]||yn}var _g=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Rg=D.inputHandler.of((i,e,t,n)=>{if((_g?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&wt(je(n,0))==1||e!=s.from||t!=s.to)return!1;let r=Ng(i.state,n);return r?(i.dispatch(r),!0):!1}),Pg=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Bc(i,i.selection.main.head).brackets||yn.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Hg(i.doc,o.head);for(let a of n)if(a==l&&Ws(i.doc,o.head)==Dc(je(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:w.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Oc=[{key:"Backspace",run:Pg}];function Ng(i,e){let t=Bc(i,i.selection.main.head),n=t.brackets||yn.brackets;for(let s of n){let r=Dc(je(s,0));if(e==s)return r==s?Vg(i,s,n.indexOf(s+s+s)>-1,t):Fg(i,s,r,t.before||yn.before);if(e==r&&Ec(i,i.selection.main.from))return Wg(i,s,r)}return null}function Ec(i,e){let t=!1;return i.field(Lc).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function Ws(i,e){let t=i.sliceString(e,e+2);return t.slice(0,wt(je(t,0)))}function Hg(i,e){let t=i.sliceString(e-2,e);return wt(je(t,0))==t.length?t:t.slice(1)}function Fg(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Zt.of(o.to+e.length),range:w.range(o.anchor+e.length,o.head+e.length)};let l=Ws(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Zt.of(o.head+e.length),range:w.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Wg(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&Ws(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:w.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Vg(i,e,t,n){let s=n.stringPrefixes||yn.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Zt.of(l.to+e.length),range:w.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ws(i.doc,a),f;if(h==e){if(Ac(i,a))return{changes:{insert:e+e,from:a},effects:Zt.of(a+e.length),range:w.cursor(a+e.length)};if(Ec(i,a)){let u=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:w.cursor(a+u.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(f=Mc(i,a-2*e.length,s))>-1&&Ac(i,f))return{changes:{insert:e+e+e+e,from:a},effects:Zt.of(a+e.length),range:w.cursor(a+e.length)};if(i.charCategorizer(a)(h)!=U.Word&&Mc(i,a,s)>-1&&!zg(i,a,e,s))return{changes:{insert:e+e,from:a},effects:Zt.of(a+e.length),range:w.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Ac(i,e){let t=ke(i).resolveInner(e+1);return t.parent&&t.from==e}function zg(i,e,t,n){let s=ke(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let f=s.firstChild;for(;f&&f.from==s.from&&f.to-f.from>t.length+a;){if(i.sliceDoc(f.to-t.length,f.to)==t)return!1;f=f.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function Mc(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=U.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=U.Word)return r}return-1}var qg=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Pl(i.state,t.from);return n.line?$g(i):n.block?Kg(i):!1};function Rl(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}var $g=Rl(Xg,0);var jg=Rl(Vc,0);var Kg=Rl((i,e)=>Vc(i,e,Gg(e)),0);function Pl(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var wn=50;function Ug(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-wn,n),o=i.sliceDoc(s,s+wn),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let f,c;s-n<=2*wn?f=c=i.sliceDoc(n,s):(f=i.sliceDoc(n,n+wn),c=i.sliceDoc(s-wn,s));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-t.length;return f.slice(u,u+e.length)==e&&c.slice(p,p+t.length)==t?{open:{pos:n+u+e.length,margin:/\s/.test(f.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function Gg(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function Vc(i,e,t=e.selection.ranges){let n=t.map(r=>Pl(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>Ug(e,n[o],r.from,r.to));if(i!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(i!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=n[o],{open:h,close:f}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+a.close.length})}return{changes:r}}return null}function Xg(i,e,t=e.selection.ranges){let n=[],s=-1;e:for(let{from:r,to:o}of t){let l=n.length,a=1e9,h;for(let f=r;f<=o;){let c=e.doc.lineAt(f);if(h==null&&(h=Pl(e,c.from).line,!h))continue e;if(c.from>s&&(r==o||o>c.from)){s=c.from;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+h.length)==h?u:-1;u<c.text.length&&u<a&&(a=u),n.push({line:c,comment:p,token:h,indent:u,empty:d,single:!1})}f=c.to+1}if(a<1e9)for(let f=l;f<n.length;f++)n[f].indent<n[f].line.text.length&&(n[f].indent=a);n.length==l+1&&(n[l].single=!0)}if(i!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:f,single:c}of n)(c||!f)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let h=o.from+l,f=h+a.length;o.text[f-o.from]==" "&&f++,r.push({from:h,to:f})}return{changes:r}}return null}var Ol=be.define(),Nl=be.define(),Hl=L.define(),zc=L.define({combine(i){return ye(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),Fl=te.define({create(){return ei.empty},update(i,e){let t=e.state.facet(zc),n=e.annotation(Ol);if(n){let a=Ye.fromTransaction(e,n.selection),h=n.side,f=h==0?i.undone:i.done;return a?f=zs(f,f.length,t.minDepth,a):f=jc(f,e.startState.selection),new ei(h==0?n.rest:f,h==0?f:n.rest)}let s=e.annotation(Nl);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(se.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=Ye.fromTransaction(e),o=e.annotation(se.time),l=e.annotation(se.userEvent);return r?i=i.addChanges(r,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new ei(i.done.map(Ye.fromJSON),i.undone.map(Ye.fromJSON))}});function qc(i={}){return[Fl,zc.of(i),D.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?$s:e.inputType=="historyRedo"?El:null;return n?(e.preventDefault(),n(t)):!1}})]}function qs(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(Fl,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}var $s=qs(0,!1),El=qs(1,!1),Yg=qs(0,!0),Jg=qs(1,!0);function Qg(i){return function(e){let t=e.field(Fl,!1);if(!t)return 0;let n=i==0?t.done:t.undone;return n.length-(n.length&&!n[0].changes?1:0)}}var Wl=Qg(0);var Ye=class i{constructor(e,t,n,s,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new i(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new i(e.changes&&ge.fromJSON(e.changes),[],e.mapped&&ht.fromJSON(e.mapped),e.startSelection&&w.fromJSON(e.startSelection),e.selectionsAfter.map(w.fromJSON))}static fromTransaction(e,t){let n=ze;for(let s of e.startState.facet(Hl)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new i(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,ze)}static selection(e){return new i(void 0,ze,void 0,void 0,e)}};function zs(i,e,t,n){let s=e+1>t+20?e-t-1:0,r=i.slice(s,e);return r.push(n),r}function Zg(i,e){let t=[],n=!1;return i.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],f=t[a++];l>=h&&o<=f&&(n=!0)}}),n}function e0(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function $c(i,e){return i.length?e.length?i.concat(e):i:e}var ze=[],t0=200;function jc(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-t0));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),zs(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Ye.selection([e])]}function i0(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Bl(i,e){if(!i.length)return i;let t=i.length,n=ze;for(;t;){let s=n0(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=i.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Ye.selection(n)]:ze}function n0(i,e,t){let n=$c(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):ze,t);if(!i.changes)return Ye.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new Ye(s,R.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}var s0=/^(input\.type|delete)($|\.)/,ei=class i{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new i(this.done,this.undone):this}addChanges(e,t,n,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||s0.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,Zg(l.changes,e.changes))||n=="input.type.compose")?o=zs(o,o.length-1,s.minDepth,new Ye(e.changes.compose(l.changes),$c(R.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,ze)):o=zs(o,o.length,s.minDepth,e),new i(o,ze,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ze;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&e0(r[r.length-1],e)?this:new i(jc(this.done,e),this.undone,t,n)}addMapping(e){return new i(Bl(this.done,e),Bl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Ol.of({side:e,rest:i0(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?ze:s.slice(0,s.length-1);return r.mapped&&(l=Bl(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ol.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};ei.empty=new ei(ze,ze);var Kc=[{key:"Mod-z",run:$s,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:El,preventDefault:!0},{linux:"Ctrl-Shift-z",run:El,preventDefault:!0},{key:"Mod-u",run:Yg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Jg,preventDefault:!0}];function Di(i,e){return w.create(i.ranges.map(e),i.mainIndex)}function Je(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Qe({state:i,dispatch:e},t){let n=Di(i.selection,t);return n.eq(i.selection,!0)?!1:(e(Je(i,n)),!0)}function js(i,e){return w.cursor(e?i.to:i.from)}function Uc(i,e){return Qe(i,t=>t.empty?i.moveByChar(t,e):js(t,e))}function pe(i){return i.textDirectionAt(i.state.selection.main.head)==K.LTR}var Gc=i=>Uc(i,!pe(i)),Xc=i=>Uc(i,pe(i));function Yc(i,e){return Qe(i,t=>t.empty?i.moveByGroup(t,e):js(t,e))}var r0=i=>Yc(i,!pe(i)),o0=i=>Yc(i,pe(i));var ry=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function l0(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function Ks(i,e,t){let n=ke(i).resolveInner(e.head),s=t?_.closedBy:_.openedBy;for(let a=e.head;;){let h=t?n.childAfter(a):n.childBefore(a);if(!h)break;l0(i,h,s)?n=h:a=t?h.to:h.from}let r=n.type.prop(s),o,l;return r&&(o=t?Xe(i,n.from,1):Xe(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,w.cursor(l,t?-1:1)}var a0=i=>Qe(i,e=>Ks(i.state,e,!pe(i))),h0=i=>Qe(i,e=>Ks(i.state,e,pe(i)));function Jc(i,e){return Qe(i,t=>{if(!t.empty)return js(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}var Qc=i=>Jc(i,!1),Zc=i=>Jc(i,!0);function eu(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(D.scrollMargins)){let o=r(i);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(n=Math.max(o?.bottom,n))}s=i.scrollDOM.clientHeight-t-n}else s=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,s-5)}}function tu(i,e){let t=eu(i),{state:n}=i,s=Di(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):js(o,e));if(s.eq(n.selection))return!1;let r;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=D.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(Je(n,s),{effects:r}),!0}var Ic=i=>tu(i,!1),Il=i=>tu(i,!0);function Lt(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let r=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=w.cursor(n.from+r))}return s}var f0=i=>Qe(i,e=>Lt(i,e,!0)),c0=i=>Qe(i,e=>Lt(i,e,!1)),u0=i=>Qe(i,e=>Lt(i,e,!pe(i))),d0=i=>Qe(i,e=>Lt(i,e,pe(i))),p0=i=>Qe(i,e=>w.cursor(i.lineBlockAt(e.head).from,1)),m0=i=>Qe(i,e=>w.cursor(i.lineBlockAt(e.head).to,-1));function g0(i,e,t){let n=!1,s=Di(i.selection,r=>{let o=Xe(i,r.head,-1)||Xe(i,r.head,1)||r.head>0&&Xe(i,r.head-1,1)||r.head<i.doc.length&&Xe(i,r.head+1,-1);if(!o||!o.end)return r;n=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return t?w.range(r.anchor,l):w.cursor(l)});return n?(e(Je(i,s)),!0):!1}var b0=({state:i,dispatch:e})=>g0(i,e,!1);function qe(i,e,t){let n=Di(i.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=w.range(s.head,s.anchor));let r=t(s);return w.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return n.eq(i.state.selection)?!1:(i.dispatch(Je(i.state,n)),!0)}function iu(i,e){return qe(i,e,t=>i.moveByChar(t,e))}var nu=i=>iu(i,!pe(i)),su=i=>iu(i,pe(i));function ru(i,e){return qe(i,e,t=>i.moveByGroup(t,e))}var y0=i=>ru(i,!pe(i)),w0=i=>ru(i,pe(i));var x0=i=>{let e=!pe(i);return qe(i,e,t=>Ks(i.state,t,e))},k0=i=>{let e=pe(i);return qe(i,e,t=>Ks(i.state,t,e))};function ou(i,e){return qe(i,e,t=>i.moveVertically(t,e))}var lu=i=>ou(i,!1),au=i=>ou(i,!0);function hu(i,e){return qe(i,e,t=>i.moveVertically(t,e,eu(i).height))}var _c=i=>hu(i,!1),Rc=i=>hu(i,!0),v0=i=>qe(i,!0,e=>Lt(i,e,!0)),S0=i=>qe(i,!1,e=>Lt(i,e,!1)),C0=i=>{let e=!pe(i);return qe(i,e,t=>Lt(i,t,e))},A0=i=>{let e=pe(i);return qe(i,e,t=>Lt(i,t,e))},M0=i=>qe(i,!1,e=>w.cursor(i.lineBlockAt(e.head).from)),L0=i=>qe(i,!0,e=>w.cursor(i.lineBlockAt(e.head).to)),Pc=({state:i,dispatch:e})=>(e(Je(i,{anchor:0})),!0),Nc=({state:i,dispatch:e})=>(e(Je(i,{anchor:i.doc.length})),!0),Hc=({state:i,dispatch:e})=>(e(Je(i,{anchor:i.selection.main.anchor,head:0})),!0),Fc=({state:i,dispatch:e})=>(e(Je(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),T0=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),D0=({state:i,dispatch:e})=>{let t=Us(i).map(({from:n,to:s})=>w.undirectionalRange(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:w.create(t),userEvent:"select"})),!0},B0=({state:i,dispatch:e})=>{let t=Di(i.selection,n=>{let s=ke(i),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return w.undirectionalRange(l.from,l.to)}return n});return t.eq(i.selection)?!1:(e(Je(i,t)),!0)};function fu(i,e){let{state:t}=i,n=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<i.state.doc.length:o.from>0)for(let l=r;;){let a=i.moveVertically(l,e);if(a.head<o.from||a.head>o.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==n.ranges.length?!1:(i.dispatch(Je(t,w.create(s,s.length-1))),!0)}var O0=i=>fu(i,!1),E0=i=>fu(i,!0),I0=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=w.create([t.main]):t.main.empty||(n=w.create([w.cursor(t.main.head)])),n?(e(Je(i,n)),!0):!1};function xn(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Vs(i,a,!1)):a>o&&(t="delete.forward",a=Vs(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Vs(i,o,!1),l=Vs(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:w.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(i.dispatch(n.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?D.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Vs(i,e,t){if(i instanceof D)for(let n of i.state.facet(D.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}var cu=(i,e,t)=>xn(i,n=>{let s=n.from,{state:r}=i,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]=="	")return s-1;let h=ct(l,r.tabSize),f=h%gn(r)||gn(r);for(let c=0;c<f&&l[l.length-1-c]==" ";c++)s--;a=s}else a=oe(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=oe(o.text,a-o.from,!1,!1)+o.from);return a}),_l=i=>cu(i,!1,!0);var uu=i=>cu(i,!0,!1),du=(i,e)=>xn(i,t=>{let n=t.head,{state:s}=i,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==t.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=oe(r.text,n-r.from,e)+r.from,h=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),f=o(h);if(l!=null&&f!=l)break;(h!=" "||n!=t.head)&&(l=f),n=a}return n}),pu=i=>du(i,!1),_0=i=>du(i,!0);var R0=i=>xn(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)});var P0=i=>xn(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),N0=i=>xn(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)});var H0=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:F.of(["",""])},range:w.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},F0=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,r=i.doc.lineAt(s),o=s==r.from?s-1:oe(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:oe(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:i.doc.slice(s,l).append(i.doc.slice(o,s))},range:w.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Us(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),r=i.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=i.doc.lineAt(n.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});t=r.number+1}return e}function mu(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of Us(i)){if(t?r.to==i.doc.length:r.from==0)continue;let o=i.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+i.lineBreak});for(let a of r.ranges)s.push(w.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:i.lineBreak+o.text});for(let a of r.ranges)s.push(w.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:w.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}var W0=({state:i,dispatch:e})=>mu(i,e,!1),V0=({state:i,dispatch:e})=>mu(i,e,!0);function gu(i,e,t){if(i.readOnly)return!1;let n=[];for(let r of Us(i))t?n.push({from:r.from,insert:i.doc.slice(r.from,r.to)+i.lineBreak}):n.push({from:r.to,insert:i.lineBreak+i.doc.slice(r.from,r.to)});let s=i.changes(n);return e(i.update({changes:s,selection:i.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var z0=({state:i,dispatch:e})=>gu(i,e,!1),q0=({state:i,dispatch:e})=>gu(i,e,!0),$0=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(Us(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=Di(e.selection,s=>{let r;if(i.lineWrapping){let o=i.lineBlockAt(s.head),l=i.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,r)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function j0(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ke(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(_.closedBy))&&r.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}var Wc=bu(!1),K0=bu(!0);function bu(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!i&&r==o&&j0(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Qt(e,{simulateBreak:r,simulateDoubleBreak:!!a}),f=Al(h,r);for(f==null&&(f=ct(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",bn(e,f)];return a&&c.push(bn(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:F.of(c)},range:w.cursor(r+1+c[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Vl(i,e){let t=-1;return i.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,s,n),t=l.number),o=l.to+1}let r=i.changes(s);return{changes:s,range:w.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}var U0=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new Qt(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Vl(i,(r,o,l)=>{let a=Al(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],f=bn(i,a);(h!=f||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:f}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},G0=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Vl(i,(t,n)=>{n.push({from:t.from,insert:i.facet(Ti)})}),{userEvent:"input.indent"})),!0),X0=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Vl(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=ct(s,i.tabSize),o=0,l=bn(i,Math.max(0,r-gn(i)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Y0=i=>(i.setTabFocusMode(),!0);var J0=[{key:"Ctrl-b",run:Gc,shift:nu,preventDefault:!0},{key:"Ctrl-f",run:Xc,shift:su},{key:"Ctrl-p",run:Qc,shift:lu},{key:"Ctrl-n",run:Zc,shift:au},{key:"Ctrl-a",run:p0,shift:M0},{key:"Ctrl-e",run:m0,shift:L0},{key:"Ctrl-d",run:uu},{key:"Ctrl-h",run:_l},{key:"Ctrl-k",run:R0},{key:"Ctrl-Alt-h",run:pu},{key:"Ctrl-o",run:H0},{key:"Ctrl-t",run:F0},{key:"Ctrl-v",run:Il}],Q0=[{key:"ArrowLeft",run:Gc,shift:nu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:r0,shift:y0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:u0,shift:C0,preventDefault:!0},{key:"ArrowRight",run:Xc,shift:su,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:o0,shift:w0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:d0,shift:A0,preventDefault:!0},{key:"ArrowUp",run:Qc,shift:lu,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Pc,shift:Hc},{mac:"Ctrl-ArrowUp",run:Ic,shift:_c},{key:"ArrowDown",run:Zc,shift:au,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Nc,shift:Fc},{mac:"Ctrl-ArrowDown",run:Il,shift:Rc},{key:"PageUp",run:Ic,shift:_c},{key:"PageDown",run:Il,shift:Rc},{key:"Home",run:c0,shift:S0,preventDefault:!0},{key:"Mod-Home",run:Pc,shift:Hc},{key:"End",run:f0,shift:v0,preventDefault:!0},{key:"Mod-End",run:Nc,shift:Fc},{key:"Enter",run:Wc,shift:Wc},{key:"Mod-a",run:T0},{key:"Backspace",run:_l,shift:_l,preventDefault:!0},{key:"Delete",run:uu,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:pu,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:_0,preventDefault:!0},{mac:"Mod-Backspace",run:P0,preventDefault:!0},{mac:"Mod-Delete",run:N0,preventDefault:!0}].concat(J0.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),yu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:a0,shift:x0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:h0,shift:k0},{key:"Alt-ArrowUp",run:W0},{key:"Shift-Alt-ArrowUp",run:z0},{key:"Alt-ArrowDown",run:V0},{key:"Shift-Alt-ArrowDown",run:q0},{key:"Mod-Alt-ArrowUp",run:O0},{key:"Mod-Alt-ArrowDown",run:E0},{key:"Escape",run:I0},{key:"Mod-Enter",run:K0},{key:"Alt-l",mac:"Ctrl-l",run:D0},{key:"Mod-i",run:B0,preventDefault:!0},{key:"Mod-[",run:X0},{key:"Mod-]",run:G0},{key:"Mod-Alt-\\",run:U0},{key:"Shift-Mod-k",run:$0},{key:"Shift-Mod-\\",run:b0},{key:"Mod-/",run:qg},{key:"Alt-A",mac:"Ctrl-A",run:jg},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Y0}].concat(Q0);var Ys=class i{static create(e,t,n,s,r){let o=s+(s<<8)+e+(t<<4)|0;return new i(e,t,n,o,r,[],[])}constructor(e,t,n,s,r,o,l){this.type=e,this.value=t,this.from=n,this.hash=s,this.end=r,this.children=o,this.positions=l,this.hashProp=[[_.contextHash,s]]}addChild(e,t){e.prop(_.contextHash)!=this.hash&&(e=new ee(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new ee(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(s,r,o)=>new ee(he.none,s,r,o,this.hashProp)})}},S;(function(i){i[i.Document=1]="Document",i[i.CodeBlock=2]="CodeBlock",i[i.FencedCode=3]="FencedCode",i[i.Blockquote=4]="Blockquote",i[i.HorizontalRule=5]="HorizontalRule",i[i.BulletList=6]="BulletList",i[i.OrderedList=7]="OrderedList",i[i.ListItem=8]="ListItem",i[i.ATXHeading1=9]="ATXHeading1",i[i.ATXHeading2=10]="ATXHeading2",i[i.ATXHeading3=11]="ATXHeading3",i[i.ATXHeading4=12]="ATXHeading4",i[i.ATXHeading5=13]="ATXHeading5",i[i.ATXHeading6=14]="ATXHeading6",i[i.SetextHeading1=15]="SetextHeading1",i[i.SetextHeading2=16]="SetextHeading2",i[i.HTMLBlock=17]="HTMLBlock",i[i.LinkReference=18]="LinkReference",i[i.Paragraph=19]="Paragraph",i[i.CommentBlock=20]="CommentBlock",i[i.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",i[i.Escape=22]="Escape",i[i.Entity=23]="Entity",i[i.HardBreak=24]="HardBreak",i[i.Emphasis=25]="Emphasis",i[i.StrongEmphasis=26]="StrongEmphasis",i[i.Link=27]="Link",i[i.Image=28]="Image",i[i.InlineCode=29]="InlineCode",i[i.HTMLTag=30]="HTMLTag",i[i.Comment=31]="Comment",i[i.ProcessingInstruction=32]="ProcessingInstruction",i[i.Autolink=33]="Autolink",i[i.HeaderMark=34]="HeaderMark",i[i.QuoteMark=35]="QuoteMark",i[i.ListMark=36]="ListMark",i[i.LinkMark=37]="LinkMark",i[i.EmphasisMark=38]="EmphasisMark",i[i.CodeMark=39]="CodeMark",i[i.CodeText=40]="CodeText",i[i.CodeInfo=41]="CodeInfo",i[i.LinkTitle=42]="LinkTitle",i[i.LinkLabel=43]="LinkLabel",i[i.URL=44]="URL"})(S||(S={}));var $l=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},jl=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return vn(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let s=t;s<e;s++)n+=this.text.charCodeAt(s)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}};function wu(i,e,t){if(t.pos==t.text.length||i!=e.block&&t.indent>=e.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let n=(i.type==S.OrderedList?na:ia)(t,e,!1);return n>0&&(i.type!=S.BulletList||ta(t,e,!1)<0)&&t.text.charCodeAt(t.pos+n-1)==i.value}var Bu={[S.Blockquote](i,e,t){return t.next!=62?!1:(t.markers.push(z(S.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1)),t.moveBase(t.pos+($e(t.text.charCodeAt(t.pos+1))?2:1)),i.end=e.lineStart+t.text.length,!0)},[S.ListItem](i,e,t){return t.indent<t.baseIndent+i.value&&t.next>-1?!1:(t.moveBaseColumn(t.baseIndent+i.value),!0)},[S.OrderedList]:wu,[S.BulletList]:wu,[S.Document](){return!0}};function $e(i){return i==32||i==9||i==10||i==13}function vn(i,e=0){for(;e<i.length&&$e(i.charCodeAt(e));)e++;return e}function xu(i,e,t){for(;e>t&&$e(i.charCodeAt(e-1));)e--;return e}function Ou(i){if(i.next!=96&&i.next!=126)return-1;let e=i.pos+1;for(;e<i.text.length&&i.text.charCodeAt(e)==i.next;)e++;if(e<i.pos+3)return-1;if(i.next==96){for(let t=e;t<i.text.length;t++)if(i.text.charCodeAt(t)==96)return-1}return e}function Eu(i){return i.next!=62?-1:i.text.charCodeAt(i.pos+1)==32?2:1}function ta(i,e,t){if(i.next!=42&&i.next!=45&&i.next!=95)return-1;let n=1;for(let s=i.pos+1;s<i.text.length;s++){let r=i.text.charCodeAt(s);if(r==i.next)n++;else if(!$e(r))return-1}return t&&i.next==45&&Ru(i)>-1&&i.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(Fu.SetextHeading)>-1||n<3?-1:1}function Iu(i,e){for(let t=i.stack.length-1;t>=0;t--)if(i.stack[t].type==e)return!0;return!1}function ia(i,e,t){return(i.next==45||i.next==43||i.next==42)&&(i.pos==i.text.length-1||$e(i.text.charCodeAt(i.pos+1)))&&(!t||Iu(e,S.BulletList)||i.skipSpace(i.pos+2)<i.text.length)?1:-1}function na(i,e,t){let n=i.pos,s=i.next;for(;s>=48&&s<=57;){n++;if(n==i.text.length)return-1;s=i.text.charCodeAt(n)}return n==i.pos||n>i.pos+9||s!=46&&s!=41||n<i.text.length-1&&!$e(i.text.charCodeAt(n+1))||t&&!Iu(e,S.OrderedList)&&(i.skipSpace(n+1)==i.text.length||n>i.pos+1||i.next!=49)?-1:n+1-i.pos}function _u(i){if(i.next!=35)return-1;let e=i.pos+1;for(;e<i.text.length&&i.text.charCodeAt(e)==35;)e++;if(e<i.text.length&&i.text.charCodeAt(e)!=32)return-1;let t=e-i.pos;return t>6?-1:t}function Ru(i){if(i.next!=45&&i.next!=61||i.indent>=i.baseIndent+4)return-1;let e=i.pos+1;for(;e<i.text.length&&i.text.charCodeAt(e)==i.next;)e++;let t=e;for(;e<i.text.length&&$e(i.text.charCodeAt(e));)e++;return e==i.text.length?t:-1}var Kl=/^[ \t]*$/,Pu=/-->/,Nu=/\?>/,Ul=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pu],[/^\s*<\?/,Nu],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Kl],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Kl]];function Hu(i,e,t){if(i.next!=60)return-1;let n=i.text.slice(i.pos);for(let s=0,r=Ul.length-(t?1:0);s<r;s++)if(Ul[s][0].test(n))return s;return-1}function ku(i,e){let t=i.countIndent(e,i.pos,i.indent),n=i.skipSpace(e),s=i.countIndent(n,e,t);return s>=t+5||n==i.text.length?t+1:s}function Tt(i,e,t){let n=i.length-1;n>=0&&i[n].to==e&&i[n].type==S.CodeText?i[n].to=t:i.push(z(S.CodeText,e,t))}var Gs={LinkReference:void 0,IndentedCode(i,e){let t=e.baseIndent+4;if(e.indent<t)return!1;let n=e.findColumn(t),s=i.lineStart+n,r=i.lineStart+e.text.length,o=[],l=[];for(Tt(o,s,r);i.nextLine()&&e.depth>=i.stack.length;)if(e.pos==e.text.length){Tt(l,i.lineStart-1,i.lineStart);for(let a of e.markers)l.push(a)}else{if(e.indent<t)break;{if(l.length){for(let h of l)h.type==S.CodeText?Tt(o,h.from,h.to):o.push(h);l=[]}Tt(o,i.lineStart-1,i.lineStart);for(let h of e.markers)o.push(h);r=i.lineStart+e.text.length;let a=i.lineStart+e.findColumn(e.baseIndent+4);a<r&&Tt(o,a,r)}}return l.length&&(l=l.filter(a=>a.type!=S.CodeText),l.length&&(e.markers=l.concat(e.markers))),i.addNode(i.buffer.writeElements(o,-s).finish(S.CodeBlock,r-s),s),!0},FencedCode(i,e){let t=Ou(e);if(t<0)return!1;let n=i.lineStart+e.pos,s=e.next,r=t-e.pos,o=e.skipSpace(t),l=xu(e.text,e.text.length,o),a=[z(S.CodeMark,n,n+r)];o<l&&a.push(z(S.CodeInfo,i.lineStart+o,i.lineStart+l));for(let h=!0,f=!0,c=!1;i.nextLine()&&e.depth>=i.stack.length;h=!1){let u=e.pos;if(e.indent-e.baseIndent<4)for(;u<e.text.length&&e.text.charCodeAt(u)==s;)u++;if(u-e.pos>=r&&e.skipSpace(u)==e.text.length){for(let d of e.markers)a.push(d);f&&c&&Tt(a,i.lineStart-1,i.lineStart),a.push(z(S.CodeMark,i.lineStart+e.pos,i.lineStart+u)),i.nextLine();break}else{c=!0,h||(Tt(a,i.lineStart-1,i.lineStart),f=!1);for(let m of e.markers)a.push(m);let d=i.lineStart+e.basePos,p=i.lineStart+e.text.length;d<p&&(Tt(a,d,p),f=!1)}}return i.addNode(i.buffer.writeElements(a,-n).finish(S.FencedCode,i.prevLineEnd()-n),n),!0},Blockquote(i,e){let t=Eu(e);return t<0?!1:(i.startContext(S.Blockquote,e.pos),i.addNode(S.QuoteMark,i.lineStart+e.pos,i.lineStart+e.pos+1),e.moveBase(e.pos+t),null)},HorizontalRule(i,e){if(ta(e,i,!1)<0)return!1;let t=i.lineStart+e.pos;return i.nextLine(),i.addNode(S.HorizontalRule,t),!0},BulletList(i,e){let t=ia(e,i,!1);if(t<0)return!1;i.block.type!=S.BulletList&&i.startContext(S.BulletList,e.basePos,e.next);let n=ku(e,e.pos+1);return i.startContext(S.ListItem,e.basePos,n-e.baseIndent),i.addNode(S.ListMark,i.lineStart+e.pos,i.lineStart+e.pos+t),e.moveBaseColumn(n),null},OrderedList(i,e){let t=na(e,i,!1);if(t<0)return!1;i.block.type!=S.OrderedList&&i.startContext(S.OrderedList,e.basePos,e.text.charCodeAt(e.pos+t-1));let n=ku(e,e.pos+t);return i.startContext(S.ListItem,e.basePos,n-e.baseIndent),i.addNode(S.ListMark,i.lineStart+e.pos,i.lineStart+e.pos+t),e.moveBaseColumn(n),null},ATXHeading(i,e){let t=_u(e);if(t<0)return!1;let n=e.pos,s=i.lineStart+n,r=xu(e.text,e.text.length,n),o=r;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==r||o==n||!$e(e.text.charCodeAt(o-1)))&&(o=e.text.length);let l=i.buffer.write(S.HeaderMark,0,t).writeElements(i.parser.parseInline(e.text.slice(n+t+1,o),s+t+1),-s);o<e.text.length&&l.write(S.HeaderMark,o-n,r-n);let a=l.finish(S.ATXHeading1-1+t,e.text.length-n);return i.nextLine(),i.addNode(a,s),!0},HTMLBlock(i,e){let t=Hu(e,i,!1);if(t<0)return!1;let n=i.lineStart+e.pos,s=Ul[t][1],r=[],o=s!=Kl;for(;!s.test(e.text)&&i.nextLine();){if(e.depth<i.stack.length){o=!1;break}for(let h of e.markers)r.push(h)}o&&i.nextLine();let l=s==Pu?S.CommentBlock:s==Nu?S.ProcessingInstructionBlock:S.HTMLBlock,a=i.prevLineEnd();return i.addNode(i.buffer.writeElements(r,-n).finish(l,a-n),n),!0},SetextHeading:void 0},Gl=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let s=n.content+`
`+t.scrub(),r=this.advance(s);return r>-1&&r<s.length?this.complete(e,n,r):!1}finish(e,t){return(this.stage==2||this.stage==3)&&vn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,z(S.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Ku(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(z(S.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage($u(e,vn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=vn(e,this.pos),n=0;if(t>this.pos){let s=ju(e,t,this.start);if(s){let r=zl(e,s.to-this.start);r>0&&(this.nextStage(s),n=r)}}return n||(n=zl(e,this.pos)),n>0&&n<e.length?n:-1}else return zl(e,this.pos)}}};function zl(i,e){for(;e<i.length;e++){let t=i.charCodeAt(e);if(t==10)break;if(!$e(t))return-1}return e}var Xl=class{nextLine(e,t,n){let s=t.depth<e.stack.length?-1:Ru(t),r=t.next;if(s<0)return!1;let o=z(S.HeaderMark,e.lineStart+t.pos,e.lineStart+s);return e.nextLine(),e.addLeafElement(n,z(r==61?S.SetextHeading1:S.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}},Fu={LinkReference(i,e){return e.content.charCodeAt(0)==91?new Gl(e):null},SetextHeading(){return new Xl}},Z0=[(i,e)=>_u(e)>=0,(i,e)=>Ou(e)>=0,(i,e)=>Eu(e)>=0,(i,e)=>ia(e,i,!0)>=0,(i,e)=>na(e,i,!0)>=0,(i,e)=>ta(e,i,!0)>=0,(i,e)=>Hu(e,i,!0)>=0],eb={text:"",end:0},Yl=class{constructor(e,t,n,s){this.parser=e,this.input=t,this.ranges=s,this.line=new jl,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=s[s.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=s[0].from,this.block=Ys.create(S.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Zl(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let n=0;;){let s=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<e.markers.length&&(!s||e.markers[n].from<s.end);){let r=e.markers[n++];this.addNode(r.type,r.from,r.to)}if(!s)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let s=n(this,e);if(s!=!1){if(s==!0)return null;e.forward();continue e}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new $l(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let s=n(this,t);s&&t.parsers.push(s)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break e}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
`+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=Uu(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=eb;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let n=this.absoluteLineStart,s=this.rangeI;for(;this.ranges[s].to<t.end;){s++;let r=this.ranges[s].from,o=this.lineChunkAt(r);t.end=r+o.length,t.text=t.text.slice(0,this.ranges[s-1].to-n)+o,n=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let s=this.stack[e.depth],r=this.parser.skipContextMarkup[s.type];if(!r)throw new Error("Unhandled block context "+S[s.type]);let o=this.line.markers.length;if(!r(s,this,e)){this.line.markers.length>o&&(s.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
`?"":t;else{let s=t.indexOf(`
`);n=s<0?t:t.slice(0,s)}return e+n.length>this.to?n.slice(0,this.to-e):n}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=Ys.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){typeof e=="number"&&(e=new ee(this.parser.nodeSet.types[e],Bi,Bi,(n??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(Ql(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Wu(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let n of e.parsers)if(n.finish(this,e))return;let t=Ql(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(S.Paragraph,e.content.length),e.start)}elt(e,t,n,s){return typeof e=="string"?z(this.parser.getNodeType(e),t,n,s):new Zs(e,t)}get buffer(){return new Qs(this.parser.nodeSet)}};function Wu(i,e,t,n,s){let r=i[e].to,o=[],l=[],a=t.from+n;function h(f,c){for(;c?f>=r:f>r;){let u=i[e+1].from-r;n+=u,f+=u,e++,r=i[e].to}}for(let f=t.firstChild;f;f=f.nextSibling){h(f.from+n,!0);let c=f.from+n,u,d=s.get(f.tree);d?u=d:f.to+n>r?(u=Wu(i,e,f,n,s),h(f.to+n,!1)):u=f.toTree(),o.push(u),l.push(c-a)}return h(t.to+n,!1),new ee(t.type,o,l,t.to+n-a,t.tree?t.tree.propValues:void 0)}var Js=class i extends Ai{constructor(e,t,n,s,r,o,l,a,h){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=s,this.endLeafBlock=r,this.skipContextMarkup=o,this.inlineParsers=l,this.inlineNames=a,this.wrappers=h,this.nodeTypes=Object.create(null);for(let f of e.types)this.nodeTypes[f.name]=f.id}createParse(e,t,n){let s=new Yl(this,e,t,n);for(let r of this.wrappers)s=r(s,e,t,n);return s}configure(e){let t=Jl(e);if(!t)return this;let{nodeSet:n,skipContextMarkup:s}=this,r=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),l=this.blockNames.slice(),a=this.inlineParsers.slice(),h=this.inlineNames.slice(),f=this.endLeafBlock.slice(),c=this.wrappers;if(kn(t.defineNodes)){s=Object.assign({},s);let u=n.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:g,composite:b,style:k}=typeof p=="string"?{name:p}:p;if(u.some(v=>v.name==m))continue;b&&(s[u.length]=(v,C,A)=>b(C,A,v.value));let x=u.length,B=b?["Block","BlockContext"]:g?x>=S.ATXHeading1&&x<=S.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;u.push(he.define({id:x,name:m,props:B&&[[_.group,B]]})),k&&(d||(d={}),Array.isArray(k)||k instanceof Oe?d[m]=k:Object.assign(d,k))}n=new Ci(u),d&&(n=n.extend(dn(d)))}if(kn(t.props)&&(n=n.extend(...t.props)),kn(t.remove))for(let u of t.remove){let d=this.blockNames.indexOf(u),p=this.inlineNames.indexOf(u);d>-1&&(r[d]=o[d]=void 0),p>-1&&(a[p]=void 0)}if(kn(t.parseBlock))for(let u of t.parseBlock){let d=l.indexOf(u.name);if(d>-1)r[d]=u.parse,o[d]=u.leaf;else{let p=u.before?Xs(l,u.before):u.after?Xs(l,u.after)+1:l.length-1;r.splice(p,0,u.parse),o.splice(p,0,u.leaf),l.splice(p,0,u.name)}u.endLeaf&&f.push(u.endLeaf)}if(kn(t.parseInline))for(let u of t.parseInline){let d=h.indexOf(u.name);if(d>-1)a[d]=u.parse;else{let p=u.before?Xs(h,u.before):u.after?Xs(h,u.after)+1:h.length-1;a.splice(p,0,u.parse),h.splice(p,0,u.name)}}return t.wrap&&(c=c.concat(t.wrap)),new i(n,r,o,l,f,s,a,h,c)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new An(this,e,t);e:for(let s=t;s<n.end;){let r=n.char(s);for(let o of this.inlineParsers)if(o){let l=o(n,r,s);if(l>=0){s=l;continue e}}s++}return n.resolveMarkers(0)}};function kn(i){return i!=null&&i.length>0}function Jl(i){if(!Array.isArray(i))return i;if(i.length==0)return null;let e=Jl(i[0]);if(i.length==1)return e;let t=Jl(i.slice(1));if(!t||!e)return e||t;let n=(o,l)=>(o||Bi).concat(l||Bi),s=e.wrap,r=t.wrap;return{props:n(e.props,t.props),defineNodes:n(e.defineNodes,t.defineNodes),parseBlock:n(e.parseBlock,t.parseBlock),parseInline:n(e.parseInline,t.parseInline),remove:n(e.remove,t.remove),wrap:s?r?(o,l,a,h)=>s(r(o,l,a,h),l,a,h):s:r}}function Xs(i,e){let t=i.indexOf(e);if(t<0)throw new RangeError(`Position specified relative to unknown parser ${e}`);return t}var Vu=[he.none];for(let i=1,e;e=S[i];i++)Vu[i]=he.define({id:i,name:e,props:i>=S.Escape?[]:[[_.group,i in Bu?["Block","BlockContext"]:["Block","LeafBlock"]]],top:e=="Document"});var Bi=[],Qs=class{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,n,s=0){return this.content.push(e,t,n,4+s*4),this}writeElements(e,t=0){for(let n of e)n.writeTo(this,t);return this}finish(e,t){return ee.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}},ii=class{constructor(e,t,n,s=Bi){this.type=e,this.from=t,this.to=n,this.children=s}writeTo(e,t){let n=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-n)}toTree(e){return new Qs(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},Zs=class{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return Bi}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}};function z(i,e,t,n){return new ii(i,e,t,n)}var zu={resolve:"Emphasis",mark:"EmphasisMark"},qu={resolve:"Emphasis",mark:"EmphasisMark"},ti={},er={},ve=class{constructor(e,t,n,s){this.type=e,this.from=t,this.to=n,this.side=s}},vu="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",Cn=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Cn=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}var ql={Escape(i,e,t){if(e!=92||t==i.end-1)return-1;let n=i.char(t+1);for(let s=0;s<vu.length;s++)if(vu.charCodeAt(s)==n)return i.append(z(S.Escape,t,t+2));return-1},Entity(i,e,t){if(e!=38)return-1;let n=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(i.slice(t+1,t+31));return n?i.append(z(S.Entity,t,t+1+n[0].length)):-1},InlineCode(i,e,t){if(e!=96||t&&i.char(t-1)==96)return-1;let n=t+1;for(;n<i.end&&i.char(n)==96;)n++;let s=n-t,r=0;for(;n<i.end;n++)if(i.char(n)==96){if(r++,r==s&&i.char(n+1)!=96)return i.append(z(S.InlineCode,t,n+1,[z(S.CodeMark,t,t+s),z(S.CodeMark,n+1-s,n+1)]))}else r=0;return-1},HTMLTag(i,e,t){if(e!=60||t==i.end-1)return-1;let n=i.slice(t+1,i.end),s=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(n);if(s)return i.append(z(S.Autolink,t,t+1+s[0].length,[z(S.LinkMark,t,t+1),z(S.URL,t+1,t+s[0].length),z(S.LinkMark,t+s[0].length,t+1+s[0].length)]));let r=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);if(r)return i.append(z(S.Comment,t,t+1+r[0].length));let o=/^\?[^]*?\?>/.exec(n);if(o)return i.append(z(S.ProcessingInstruction,t,t+1+o[0].length));let l=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(n);return l?i.append(z(S.HTMLTag,t,t+1+l[0].length)):-1},Emphasis(i,e,t){if(e!=95&&e!=42)return-1;let n=t+1;for(;i.char(n)==e;)n++;let s=i.slice(t-1,t),r=i.slice(n,n+1),o=Cn.test(s),l=Cn.test(r),a=/\s|^$/.test(s),h=/\s|^$/.test(r),f=!h&&(!l||a||o),c=!a&&(!o||h||l),u=f&&(e==42||!c||o),d=c&&(e==42||!f||l);return i.append(new ve(e==95?zu:qu,t,n,(u?1:0)|(d?2:0)))},HardBreak(i,e,t){if(e==92&&i.char(t+1)==10)return i.append(z(S.HardBreak,t,t+2));if(e==32){let n=t+1;for(;i.char(n)==32;)n++;if(i.char(n)==10&&n>=t+2)return i.append(z(S.HardBreak,t,n+1))}return-1},Link(i,e,t){return e==91?i.append(new ve(ti,t,t+1,1)):-1},Image(i,e,t){return e==33&&i.char(t+1)==91?i.append(new ve(er,t,t+2,1)):-1},LinkEnd(i,e,t){if(e!=93)return-1;for(let n=i.parts.length-1;n>=0;n--){let s=i.parts[n];if(s instanceof ve&&(s.type==ti||s.type==er)){if(!s.side||i.skipSpace(s.to)==t&&!/[(\[]/.test(i.slice(t+1,t+2)))return i.parts[n]=null,-1;let r=i.takeContent(n),o=i.parts[n]=tb(i,r,s.type==ti?S.Link:S.Image,s.from,t+1);if(s.type==ti)for(let l=0;l<n;l++){let a=i.parts[l];a instanceof ve&&a.type==ti&&(a.side=0)}return o.to}}return-1}};function tb(i,e,t,n,s){let{text:r}=i,o=i.char(s),l=s;if(e.unshift(z(S.LinkMark,n,n+(t==S.Image?2:1))),e.push(z(S.LinkMark,s-1,s)),o==40){let a=i.skipSpace(s+1),h=$u(r,a-i.offset,i.offset),f;h&&(a=i.skipSpace(h.to),a!=h.to&&(f=ju(r,a-i.offset,i.offset),f&&(a=i.skipSpace(f.to)))),i.char(a)==41&&(e.push(z(S.LinkMark,s,s+1)),l=a+1,h&&e.push(h),f&&e.push(f),e.push(z(S.LinkMark,a,l)))}else if(o==91){let a=Ku(r,s-i.offset,i.offset,!1);a&&(e.push(a),l=a.to)}return z(t,n,l,e)}function $u(i,e,t){if(i.charCodeAt(e)==60){for(let s=e+1;s<i.length;s++){let r=i.charCodeAt(s);if(r==62)return z(S.URL,e+t,s+1+t);if(r==60||r==10)return!1}return null}else{let s=0,r=e;for(let o=!1;r<i.length;r++){let l=i.charCodeAt(r);if($e(l))break;if(o)o=!1;else if(l==40)s++;else if(l==41){if(!s)break;s--}else l==92&&(o=!0)}return r>e?z(S.URL,e+t,r+t):r==i.length?null:!1}}function ju(i,e,t){let n=i.charCodeAt(e);if(n!=39&&n!=34&&n!=40)return!1;let s=n==40?41:n;for(let r=e+1,o=!1;r<i.length;r++){let l=i.charCodeAt(r);if(o)o=!1;else{if(l==s)return z(S.LinkTitle,e+t,r+1+t);l==92&&(o=!0)}}return null}function Ku(i,e,t,n){for(let s=!1,r=e+1,o=Math.min(i.length,r+999);r<o;r++){let l=i.charCodeAt(r);if(s)s=!1;else{if(l==93)return n?!1:z(S.LinkLabel,e+t,r+1+t);if(n&&!$e(l)&&(n=!1),l==91)return!1;l==92&&(s=!0)}}return null}var An=class{constructor(e,t,n){this.parser=e,this.text=t,this.offset=n,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,n,s,r){return this.append(new ve(e,t,n,(s?1:0)|(r?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof ve&&(t.type==ti||t.type==er))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let n=e;n<this.parts.length;n++){let s=this.parts[n];if(!(s instanceof ve&&s.type.resolve&&s.side&2))continue;let r=s.type==zu||s.type==qu,o=s.to-s.from,l,a=n-1;for(;a>=e;a--){let m=this.parts[a];if(m instanceof ve&&m.side&1&&m.type==s.type&&!(r&&(s.side&1||m.side&2)&&(m.to-m.from+o)%3==0&&((m.to-m.from)%3||o%3))){l=m;break}}if(!l)continue;let h=s.type.resolve,f=[],c=l.from,u=s.to;if(r){let m=Math.min(2,l.to-l.from,o);c=l.to-m,u=s.from+m,h=m==1?"Emphasis":"StrongEmphasis"}l.type.mark&&f.push(this.elt(l.type.mark,c,l.to));for(let m=a+1;m<n;m++)this.parts[m]instanceof ii&&f.push(this.parts[m]),this.parts[m]=null;s.type.mark&&f.push(this.elt(s.type.mark,s.from,u));let d=this.elt(h,c,u,f);this.parts[a]=r&&l.from!=c?new ve(l.type,l.from,c,l.side):null,(this.parts[n]=r&&s.to!=u?new ve(s.type,u,s.to,s.side):null)?this.parts.splice(n,0,d):this.parts[n]=d}let t=[];for(let n=e;n<this.parts.length;n++){let s=this.parts[n];s instanceof ii&&t.push(s)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof ve&&n.type==e&&n.side&1)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof ve?t:null}skipSpace(e){return vn(this.text,e-this.offset)+this.offset}elt(e,t,n,s){return typeof e=="string"?z(this.parser.getNodeType(e),t,n,s):new Zs(e,t)}};An.linkStart=ti;An.imageStart=er;function Ql(i,e){if(!e.length)return i;if(!i.length)return e;let t=i.slice(),n=0;for(let s of e){for(;n<t.length&&t[n].to<s.to;)n++;if(n<t.length&&t[n].from<s.from){let r=t[n];r instanceof ii&&(t[n]=new ii(r.type,r.from,r.to,Ql(r.children,[s])))}else t.splice(n++,0,s)}return t}var ib=[S.CodeBlock,S.ListItem,S.OrderedList,S.BulletList],Zl=class{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let r=this.fragment.to;for(;r>0&&this.input.read(r-1,r)!=`
`;)r--;this.fragmentEnd=r?r-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let s=e+this.fragment.offset;for(;n.to<=s;)if(!n.parent())return!1;for(;;){if(n.from>=s)return this.fragment.from<=t;if(!n.childAfter(s))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(_.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,s=this.fragmentEnd-(this.fragment.openEnd?1:0),r=e.absoluteLineStart,o=r,l=e.block.children.length,a=o,h=l;for(;;){if(t.to-n>s){if(t.type.isAnonymous&&t.firstChild())continue;break}let f=Uu(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,f);else{let c=new ee(e.parser.nodeSet.types[S.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(c,t.tree),e.addNode(c,f)}if(t.type.is("Block")&&(ib.indexOf(t.type.id)<0?(o=t.to-n,l=e.block.children.length):(o=a,l=h),a=t.to-n,h=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>l;)e.block.children.pop(),e.block.positions.pop();return o-r}};function Uu(i,e){let t=i;for(let n=1;n<e.length;n++){let s=e[n-1].to,r=e[n].from;s<i&&(t-=r-s)}return t}var nb=dn({"Blockquote/...":y.quote,HorizontalRule:y.contentSeparator,"ATXHeading1/... SetextHeading1/...":y.heading1,"ATXHeading2/... SetextHeading2/...":y.heading2,"ATXHeading3/...":y.heading3,"ATXHeading4/...":y.heading4,"ATXHeading5/...":y.heading5,"ATXHeading6/...":y.heading6,"Comment CommentBlock":y.comment,Escape:y.escape,Entity:y.character,"Emphasis/...":y.emphasis,"StrongEmphasis/...":y.strong,"Link/... Image/...":y.link,"OrderedList/... BulletList/...":y.list,"BlockQuote/...":y.quote,"InlineCode CodeText":y.monospace,"URL Autolink":y.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":y.processingInstruction,"CodeInfo LinkLabel":y.labelName,LinkTitle:y.string,Paragraph:y.content}),Gu=new Js(new Ci(Vu).extend(nb),Object.keys(Gs).map(i=>Gs[i]),Object.keys(Gs).map(i=>Fu[i]),Object.keys(Gs),Z0,Bu,Object.keys(ql).map(i=>ql[i]),Object.keys(ql),[]);var sb={resolve:"Strikethrough",mark:"StrikethroughMark"},rb={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":y.strikethrough}},{name:"StrikethroughMark",style:y.processingInstruction}],parseInline:[{name:"Strikethrough",parse(i,e,t){if(e!=126||i.char(t+1)!=126||i.char(t+2)==126)return-1;let n=i.slice(t-1,t),s=i.slice(t+2,t+3),r=/\s|^$/.test(n),o=/\s|^$/.test(s),l=Cn.test(n),a=Cn.test(s);return i.addDelimiter(sb,t,t+2,!o&&(!a||r||l),!r&&(!l||o||a))},after:"Emphasis"}]};function Sn(i,e,t=0,n,s=0){let r=0,o=!0,l=-1,a=-1,h=!1,f=()=>{n.push(i.elt("TableCell",s+l,s+a,i.parser.parseInline(e.slice(l,a),s+l)))};for(let c=t;c<e.length;c++){let u=e.charCodeAt(c);u==124&&!h?((!o||l>-1)&&r++,o=!1,n&&(l>-1&&f(),n.push(i.elt("TableDelimiter",c+s,c+s+1))),l=a=-1):(h||u!=32&&u!=9)&&(l<0&&(l=c),a=c+1),h=!h&&u==92}return l>-1&&(r++,n&&f()),r}function Su(i,e){for(let t=e;t<i.length;t++){let n=i.charCodeAt(t);if(n==124)return!0;n==92&&t++}return!1}var Xu=/^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,tr=class{constructor(){this.rows=null}nextLine(e,t,n){if(this.rows==null){this.rows=!1;let s;if((t.next==45||t.next==58||t.next==124)&&Xu.test(s=t.text.slice(t.pos))){let r=[];Sn(e,n.content,0,r,n.start)==Sn(e,s,0)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,r),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let s=[];Sn(e,t.text,t.pos,s,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,s))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0):!1}},ob={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":y.heading}},"TableRow",{name:"TableCell",style:y.content},{name:"TableDelimiter",style:y.processingInstruction}],parseBlock:[{name:"Table",leaf(i,e){return Su(e.content,0)?new tr:null},endLeaf(i,e,t){if(t.parsers.some(s=>s instanceof tr)||!Su(e.text,e.basePos))return!1;let n=i.peekLine();return Xu.test(n)&&Sn(i,e.text,e.basePos)==Sn(i,n,e.basePos)},before:"SetextHeading"}]},ea=class{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}},lb={defineNodes:[{name:"Task",block:!0,style:y.list},{name:"TaskMarker",style:y.atom}],parseBlock:[{name:"TaskList",leaf(i,e){return/^\[[ xX]\][ \t]/.test(e.content)&&i.parentType().name=="ListItem"?new ea:null},after:"SetextHeading"}]},Cu=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Au=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,ab=/[\w-]+\.[\w-]+($|[/:])/,Mu=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Lu=/\/[a-zA-Z\d@.]+/gy;function Tu(i,e,t,n){let s=0;for(let r=e;r<t;r++)i[r]==n&&s++;return s}function hb(i,e){Au.lastIndex=e;let t=Au.exec(i);if(!t||ab.exec(t[0])[0].indexOf("_")>-1)return-1;let n=e+t[0].length;for(;;){let s=i[n-1],r;if(/[?!.,:*_~]/.test(s)||s==")"&&Tu(i,e,n,")")>Tu(i,e,n,"("))n--;else if(s==";"&&(r=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(i.slice(e,n))))n=e+r.index;else break}return n}function Du(i,e){Mu.lastIndex=e;let t=Mu.exec(i);if(!t)return-1;let n=t[0][t[0].length-1];return n=="_"||n=="-"?-1:e+t[0].length-(n=="."?1:0)}var fb={parseInline:[{name:"Autolink",parse(i,e,t){let n=t-i.offset;if(n&&/\w/.test(i.text[n-1]))return-1;Cu.lastIndex=n;let s=Cu.exec(i.text),r=-1;if(!s)return-1;if(s[1]||s[2]){if(r=hb(i.text,n+s[0].length),r>-1&&i.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(i.text.slice(n,r));r=n+o[0].length}}else s[3]?r=Du(i.text,n):(r=Du(i.text,n+s[0].length),r>-1&&s[0]=="xmpp:"&&(Lu.lastIndex=r,s=Lu.exec(i.text),s&&(r=s.index+s[0].length)));return r<0?-1:(i.addElement(i.elt("URL",t,r+i.offset)),r+i.offset)}}]},Yu=[ob,lb,rb,fb];function Ju(i,e,t){return(n,s,r)=>{if(s!=i||n.char(r+1)==i)return-1;let o=[n.elt(t,r,r+1)];for(let l=r+1;l<n.end;l++){let a=n.char(l);if(a==i)return n.addElement(n.elt(e,r,l+1,o.concat(n.elt(t,l,l+1))));if(a==92&&o.push(n.elt("Escape",l,l+++2)),$e(a))break}return-1}}var Qu={defineNodes:[{name:"Superscript",style:y.special(y.content)},{name:"SuperscriptMark",style:y.processingInstruction}],parseInline:[{name:"Superscript",parse:Ju(94,"Superscript","SuperscriptMark")}]},Zu={defineNodes:[{name:"Subscript",style:y.special(y.content)},{name:"SubscriptMark",style:y.processingInstruction}],parseInline:[{name:"Subscript",parse:Ju(126,"Subscript","SubscriptMark")}]},ed={defineNodes:[{name:"Emoji",style:y.character}],parseInline:[{name:"Emoji",parse(i,e,t){let n;return e!=58||!(n=/^[a-zA-Z_0-9]+:/.exec(i.slice(t+1,i.end)))?-1:i.addElement(i.elt("Emoji",t,t+1+n[0].length))}}]};var id=gc({commentTokens:{block:{open:"<!--",close:"-->"}}}),cb=new _,ub=Gu.configure({props:[Ll.add(i=>!i.is("Block")||i.is("Document")||td(i)!=null||db(i)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),cb.add(td),Ml.add({Document:()=>null}),Jt.add({Document:id})]});function td(i){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(i.name);return e?+e[1]:void 0}function db(i){return i.name=="OrderedList"||i.name=="BulletList"}function pb(i){return new Ae(id,i,[],"markdown")}var mb=ub.configure([Yu,Zu,Qu,ed,{props:[Ll.add({Table:(i,e)=>({from:e.doc.lineAt(i.from).to,to:i.to})})]}]),nd=pb(mb);var sr=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},ni=class i{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(Mn).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ne,l=[],a=0,h=n.doc.iter(),f=0,c=n.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((x,B)=>Math.min(x,B.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>c)break;g=p.to,l.push(p),d++}for(;d<r.length;){let x=r[d];if(x.from==m&&(x.to>x.from||x.to==m))l.push(x),d++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,c);let b=!1;if(l.some(x=>x.from==m&&(x.to==g||g==c))&&(b=m==g,!b&&g-m<10)){let x=m-(f+h.value.length);x>0&&(h.next(x),f=m);for(let B=m;;){if(B>=g){b=!0;break}if(!h.lineBreak&&f+h.value.length>B)break;B=f+h.value.length,f+=h.value.length,h.next()}}let k=pd(l);if(b)o.add(m,m,O.widget({widget:new sa(k),diagnostics:l.slice()}));else{let x=l.reduce((B,v)=>v.markClass?B+" "+v.markClass:B,"");o.add(m,g,O.mark({class:"cm-lintRange cm-lintRange-"+k+x,diagnostics:l.slice(),inclusiveEnd:l.some(B=>B.to>g)}))}if(a=g,a==c)break;for(let x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1)}let u=o.finish();return new i(u,t,Dt(u))}};function Dt(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new sr(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new sr(n.from,r,n.diagnostic)}}),n}function od(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(Mn).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(lr))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function ld(i,e){return i.field(Ee,!1)?e:e.concat(R.appendConfig.of(Lb))}function ad(i,e){return{effects:ld(i,[lr.of(e)])}}var lr=R.define(),oa=R.define(),hd=R.define(),Ee=te.define({create(){return new ni(O.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=Dt(t,i.selected.diagnostic,r)||Dt(t,null,r)}!t.size&&s&&e.state.facet(Mn).autoPanel&&(s=null),i=new ni(t,s,n)}for(let t of e.effects)if(t.is(lr)){let n=e.state.facet(Mn).autoPanel?t.value.length?Ln.open:null:i.panel;i=ni.init(t.value,n,e.state)}else t.is(oa)?i=new ni(i.diagnostics,t.value?Ln.open:null,i.selected):t.is(hd)&&(i=new ni(i.diagnostics,i.panel,t.value));return i},provide:i=>[Kt.from(i,e=>e.panel),D.decorations.from(i,e=>e.diagnostics)]});var gb=O.mark({class:"cm-lintRange cm-lintRange-active"});function bb(i,e,t){let{diagnostics:n}=i.state.field(Ee),s,r=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:f})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return s=f.diagnostics,r=a,o=h,!1});let l=i.state.facet(Mn).tooltipFilter;return s&&l&&(s=l(s,i.state)),s?{pos:r,end:o,above:!0,create(){return{dom:fd(i,s)}}}:null}function fd(i,e){return q("ul",{class:"cm-tooltip-lint"},e.map(t=>dd(i,t,!1)))}var yb=i=>{let e=i.state.field(Ee,!1);(!e||!e.panel)&&i.dispatch({effects:ld(i.state,[oa.of(!0)])});let t=ln(i,Ln.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},sd=i=>{let e=i.state.field(Ee,!1);return!e||!e.panel?!1:(i.dispatch({effects:oa.of(!1)}),!0)},wb=i=>{let e=i.state.field(Ee,!1);if(!e)return!1;let t=i.state.selection.main,n=Dt(e.diagnostics,null,t.to+1);return!n&&(n=Dt(e.diagnostics,null,0),!n||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),Uf(i,n.from,1,{tooltip:gd,until:s=>s.docChanged||s.newSelection.main.head<n.from||s.newSelection.main.head>n.to}),!0)};var cd=[{key:"Mod-Shift-m",run:yb,preventDefault:!0},{key:"F8",run:wb}];var Mn=L.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...ye(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rd,tooltipFilter:rd,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,r)=>e(n,s,r)||t(n,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function rd(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function ud(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function dd(i,e,t){var n;let s=t?ud(e.actions):[];return q("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},q("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Dt(i.state.field(Ee).diagnostics,e);p&&r.apply(i,p.from,p.to)},{name:h}=r,f=s[o]?h.indexOf(s[o]):-1,c=f<0?h:[h.slice(0,f),q("u",h.slice(f,f+1)),h.slice(f+1)],u=r.markClass?" "+r.markClass:"";return q("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${f<0?"":` (access key "${s[o]})"`}.`},c)}),e.source&&q("div",{class:"cm-diagnosticSource"},e.source))}var sa=class extends De{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return q("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},rr=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=dd(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ln=class i{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)sd(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=ud(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Dt(this.view.state.field(Ee).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()}},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=q("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=q("div",{class:"cm-panel-lint"},this.list,q("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sd(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ee).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(Ee),n=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let f of h.diagnostics){if(o.has(f))continue;o.add(f);let c=-1,u;for(let d=n;d<this.items.length;d++)if(this.items[d].diagnostic==f){c=d;break}c<0?(u=new rr(this.view,f),this.items.splice(n,0,u),s=!0):(u=this.items[c],c>n&&(this.items.splice(n,c-n),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new rr(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ee),n=Dt(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:hd.of(n)})}static open(e){return new i(e)}};function nr(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function ir(i){return nr(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var xb=D.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:ir("#f11")},".cm-lintRange-warning":{backgroundImage:ir("orange")},".cm-lintRange-info":{backgroundImage:ir("#999")},".cm-lintRange-hint":{backgroundImage:ir("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function kb(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function pd(i){let e="hint",t=1;for(let n of i){let s=kb(n.severity);s>t&&(t=s,e=n.severity)}return e}var or=class extends Be{constructor(e){super(),this.diagnostics=e,this.severity=pd(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,s=e.state.facet(ar).tooltipFilter;return s&&(n=s(n,e.state)),n.length&&(t.onmouseover=()=>Sb(e,t,n)),t}};function vb(i,e){let t=n=>{let s=e.getBoundingClientRect();if(!(n.clientX>s.left-10&&n.clientX<s.right+10&&n.clientY>s.top-10&&n.clientY<s.bottom+10)){for(let r=n.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),i.state.field(md)&&i.dispatch({effects:la.of(null)})}};window.addEventListener("mousemove",t)}function Sb(i,e,t){function n(){let o=i.elementAtHeight(e.getBoundingClientRect().top+5-i.documentTop);i.coordsAtPos(o.from)&&i.dispatch({effects:la.of({pos:o.from,above:!1,clip:!1,create(){return{dom:fd(i,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,vb(i,e)}let{hoverTime:s}=i.state.facet(ar),r=setTimeout(n,s);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(n,s)}}function Cb(i,e){let t=Object.create(null);for(let s of e){let r=i.lineAt(s.from);(t[r.from]||(t[r.from]=[])).push(s)}let n=[];for(let s in t)n.push(new or(t[s]).range(+s));return V.of(n,!0)}var Ab=nl({class:"cm-gutter-lint",markers:i=>i.state.field(ra),widgetMarker:(i,e,t)=>{let n=[];return i.state.field(ra).between(t.from,t.to,(s,r,o)=>{s>t.from&&s<t.to&&n.push(...o.diagnostics)}),n.length?new or(n):null}}),ra=te.define({create(){return V.empty},update(i,e){i=i.map(e.changes);let t=e.state.facet(ar).markerFilter;for(let n of e.effects)if(n.is(lr)){let s=n.value;t&&(s=t(s||[],e.state)),i=Cb(e.state.doc,s.slice(0))}return i}}),la=R.define(),md=te.define({create(){return null},update(i,e){return i&&e.docChanged&&(i=od(e,i)?null:{...i,pos:e.changes.mapPos(i.pos)}),e.effects.reduce((t,n)=>n.is(la)?n.value:t,i)},provide:i=>on.from(i)}),Mb=D.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:nr('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:nr('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:nr('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),gd=Kf(bb,{hideOn:od}),Lb=[Ee,D.decorations.compute([Ee],i=>{let{selected:e,panel:t}=i.field(Ee);return!e||!t||e.from==e.to?O.none:O.set([gb.range(e.from,e.to)])}),gd,xb],ar=L.define({combine(i){return ye(i,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function bd(i={}){return[ar.of(i),ra,Ab,Mb,md]}var yd=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i,Ot=class{constructor(e,t,n=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?l=>r(yd(l)):yd,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 je(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=Gn(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=wt(e);let s=this.normalize(t);if(s.length)for(let r=0,o=n,l=!0;;r++){let a=s.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==s.length-1);if(h)return this.value=h,this;if(r==s.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,n,s,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:s,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:s,precise:n&&r}:this.matches.push({from:t,index:1,precise:n})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}};typeof Symbol<"u"&&(Ot.prototype[Symbol.iterator]=function(){return this});var kd={from:-1,to:-1,match:/.*/.exec(""),precise:!0},da="gm"+(/x/.unicode==null?"":"u"),cr=class{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=kd,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new dr(e,t,n,s,r);this.re=new RegExp(t,da+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=pr(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=pr(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,precise:!0,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}}},aa=new WeakMap,ur=class i{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=aa.get(e);if(!s||s.from>=n||s.to<=t){let l=new i(t,e.sliceString(t,n));return aa.set(e,l),l}if(s.from==t&&s.to==n)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<n&&(r+=e.sliceString(s.to,n)),aa.set(e,new i(o,r)),new i(t,r.slice(t-o,n-o))}},dr=class{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=kd,this.matchPos=pr(e,s),this.re=new RegExp(t,da+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=ur.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,precise:!0,match:t},this.matchPos=pr(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ur.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(cr.prototype[Symbol.iterator]=dr.prototype[Symbol.iterator]=function(){return this});function Tb(i){try{return new RegExp(i,da),!0}catch{return!1}}function pr(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}var Db=i=>{let{state:e}=i,t=String(e.doc.lineAt(i.state.selection.main.head).number),{close:n,result:s}=Xf(i,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){i.dispatch({effects:n});return}let l=e.doc.lineAt(e.selection.main.head),[,a,h,f,c]=o,u=f?+f.slice(1):0,d=h?+h:l.number;if(h&&c){let g=d/100;a&&(g=g*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*g)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),m=w.cursor(p.from+Math.max(0,Math.min(u,p.length)));i.dispatch({effects:[n,D.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},Bb={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},vd=L.define({combine(i){return ye(i,Bb,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Sd(i){let e=[Rb,_b];return i&&e.push(vd.of(i)),e}var Ob=O.mark({class:"cm-selectionMatch"}),Eb=O.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function wd(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=U.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=U.Word)}function Ib(i,e,t,n){return i(e.sliceDoc(t,t+1))==U.Word&&i(e.sliceDoc(n-1,n))==U.Word}var _b=ne.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(vd),{state:t}=i,n=t.selection;if(n.ranges.length>1)return O.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return O.none;let a=t.wordAt(s.head);if(!a)return O.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return O.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(wd(o,t,s.from,s.to)&&Ib(o,t,s.from,s.to)))return O.none}else if(r=t.sliceDoc(s.from,s.to),!r)return O.none}let l=[];for(let a of i.visibleRanges){let h=new Ot(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:f,to:c}=h.value;if((!o||wd(o,t,f,c))&&(s.empty&&f<=s.from&&c>=s.to?l.push(Eb.range(f,c)):(f>=s.to||c<=s.from)&&l.push(Ob.range(f,c)),l.length>e.maxMatches))return O.none}}return O.set(l)}},{decorations:i=>i.decorations}),Rb=D.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Pb=({state:i,dispatch:e})=>{let{selection:t}=i,n=w.create(t.ranges.map(s=>i.wordAt(s.head)||w.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function Nb(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Ot(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ot(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(r){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var Hb=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return Pb({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=Nb(i,n);return s?(e(i.update({selection:i.selection.addRange(w.range(s.from,s.to),!1),effects:D.scrollIntoView(s.to)})),!0):!1},Ii=L.define({combine(i){return ye(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ua(e),scrollToMatch:e=>D.scrollIntoView(e)})}});var mr=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||Tb(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
`:n=="r"?"\r":n=="t"?"	":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new fa(this):new ha(this)}getCursor(e,t=0,n){let s=e.doc?e:G.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Ei(this,s,t,n):Oi(this,s,t,n)}},gr=class{constructor(e){this.spec=e}};function Fb(i,e,t){return(n,s,r,o)=>{if(t&&!t(n,s,r,o))return!1;let l=n>=o&&s<=o+r.length?r.slice(n-o,s-o):e.doc.sliceString(n,s);return i(l,e,n,s)}}function Oi(i,e,t,n){let s;return i.wholeWord&&(s=Wb(e.doc,e.charCategorizer(e.selection.main.head))),i.test&&(s=Fb(i.test,e,s)),new Ot(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Wb(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(br(s,t-r))!=U.Word||e(yr(s,t-r))!=U.Word)&&(e(yr(s,n-r))!=U.Word||e(br(s,n-r))!=U.Word))}var ha=class extends gr{constructor(e){super(e)}nextMatch(e,t,n){let s=Oi(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=Oi(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==n?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Oi(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,n){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Oi(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Oi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}};function Vb(i,e,t){return(n,s,r)=>(!t||t(n,s,r))&&i(r[0],e,n,s)}function Ei(i,e,t,n){let s;return i.wholeWord&&(s=zb(e.charCategorizer(e.selection.main.head))),i.test&&(s=Vb(i.test,e,s)),new cr(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:s},t,n)}function br(i,e){return i.slice(oe(i,e,!1),e)}function yr(i,e){return i.slice(e,oe(i,e))}function zb(i){return(e,t,n)=>!n[0].length||(i(br(n.input,n.index))!=U.Word||i(yr(n.input,n.index))!=U.Word)&&(i(yr(n.input,n.index+n[0].length))!=U.Word||i(br(n.input,n.index+n[0].length))!=U.Word)}var fa=class extends gr{nextMatch(e,t,n){let s=Ei(this.spec,e,n,e.doc.length).next();return s.done&&(s=Ei(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Ei(this.spec,e,r,n),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let r=+n.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+n.slice(s)}return t})}matchAll(e,t){let n=Ei(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Ei(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}},Dn=R.define(),pa=R.define(),Bt=te.define({create(i){return new Tn(ca(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Dn)?i=new Tn(t.value.create(),i.panel):t.is(pa)&&(i=new Tn(i.query,t.value?ma:null));return i},provide:i=>Kt.from(i,e=>e.panel)});var Tn=class{constructor(e,t){this.query=e,this.panel=t}},qb=O.mark({class:"cm-searchMatch"}),$b=O.mark({class:"cm-searchMatch cm-searchMatch-selected"}),jb=ne.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(Bt))}update(i){let e=i.state.field(Bt);(e!=i.startState.field(Bt)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return O.none;let{view:t}=this,n=new Ne;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-500;)a=r[++s].to;i.highlight(t.state,l,a,(h,f)=>{let c=t.state.selection.ranges.some(u=>u.from==h&&u.to==f);n.add(h,f,c?$b:qb)})}return n.finish()}},{decorations:i=>i.decorations});function Bn(i){return e=>{let t=e.state.field(Bt,!1);return t&&t.query.spec.valid?i(e,t):Md(e)}}var wr=Bn((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=w.single(n.from,n.to),r=i.state.facet(Ii);return i.dispatch({selection:s,effects:[ga(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),Ad(i),!0}),xr=Bn((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=w.single(s.from,s.to),o=i.state.facet(Ii);return i.dispatch({selection:r,effects:[ga(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),Ad(i),!0}),Kb=Bn((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:w.create(t.map(n=>w.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Ub=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new Ot(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(w.range(l.value.from,l.value.to))}return e(i.update({selection:w.create(r,o),userEvent:"select.search.matches"})),!0},xd=Bn((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=r,l=[],a,h,f=[];o.precise?o.from==n&&o.to==s&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),f.push(D.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))):o=e.nextMatch(t,o.from,o.to);let c=i.state.changes(l);return o&&(a=w.single(o.from,o.to).map(c),f.push(ga(i,o)),f.push(t.facet(Ii).scrollToMatch(a.main,i))),i.dispatch({changes:c,selection:a,effects:f,userEvent:"input.replace"}),!0}),Gb=Bn((i,{query:e})=>{if(i.state.readOnly)return!1;let t=[];for(let s of e.matchAll(i.state,1e9)){let{from:r,to:o,precise:l}=s;l&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:D.announce.of(n),userEvent:"input.replace.all"}),!0});function ma(i){return i.state.facet(Ii).createPanel(i)}function ca(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=i.facet(Ii);return new mr({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Cd(i){let e=ln(i,ma);return e&&e.dom.querySelector("[main-field]")}function Ad(i){let e=Cd(i);e&&e==i.root.activeElement&&e.select()}var Md=i=>{let e=i.state.field(Bt,!1);if(e&&e.panel){let t=Cd(i);if(t&&t!=i.root.activeElement){let n=ca(i.state,e.query.spec);n.valid&&i.dispatch({effects:Dn.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[pa.of(!0),e?Dn.of(ca(i.state,e.query.spec)):R.appendConfig.of(Yb)]});return!0},Ld=i=>{let e=i.state.field(Bt,!1);if(!e||!e.panel)return!1;let t=ln(i,ma);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:pa.of(!1)}),!0},Td=[{key:"Mod-f",run:Md,scope:"editor search-panel"},{key:"F3",run:wr,shift:xr,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:wr,shift:xr,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Ld,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Ub},{key:"Mod-Alt-g",run:Db},{key:"Mod-d",run:Hb,preventDefault:!0}],ua=class{constructor(e){this.view=e;let t=this.query=e.state.field(Bt).query.spec;this.commit=this.commit.bind(this),this.searchField=q("input",{value:t.search,placeholder:Ie(e,"Find"),"aria-label":Ie(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=q("input",{value:t.replace,placeholder:Ie(e,"Replace"),"aria-label":Ie(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=q("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=q("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=q("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return q("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=q("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>wr(e),[Ie(e,"next")]),n("prev",()=>xr(e),[Ie(e,"previous")]),n("select",()=>Kb(e),[Ie(e,"all")]),q("label",null,[this.caseField,Ie(e,"match case")]),q("label",null,[this.reField,Ie(e,"regexp")]),q("label",null,[this.wordField,Ie(e,"by word")]),...e.state.readOnly?[]:[q("br"),this.replaceField,n("replace",()=>xd(e),[Ie(e,"replace")]),n("replaceAll",()=>Gb(e),[Ie(e,"replace all")])],q("button",{name:"close",onclick:()=>Ld(e),"aria-label":Ie(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new mr({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:Dn.of(e)}))}keydown(e){Bf(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?xr:wr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),xd(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Dn)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Ii).top}};function Ie(i,e){return i.state.phrase(e)}var hr=30,fr=/[\s\.,:;?!]/;function ga(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-hr),o=Math.min(s,t+hr),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<hr;a++)if(!fr.test(l[a+1])&&fr.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-hr;a--)if(!fr.test(l[a-1])&&fr.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}var Xb=D.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"}}),Yb=[Bt,ft.low(jb),Xb];var _i=class i{static __wrap(e){e=e>>>0;let t=Object.create(i.prototype);return t.__wbg_ptr=e,ba.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ba.unregister(this),e}free(){let e=this.__destroy_into_raw();E.__wbg_linter_free(e,0)}check(e,t){let n,s;try{let h=E.__wbindgen_add_to_stack_pointer(-16),f=It(e,E.__wbindgen_export,E.__wbindgen_export2),c=lt;var r=Et(t)?0:It(t,E.__wbindgen_export,E.__wbindgen_export2),o=lt;E.linter_check(h,this.__wbg_ptr,f,c,r,o);var l=X().getInt32(h+0,!0),a=X().getInt32(h+4,!0);return n=l,s=a,bt(l,a)}finally{E.__wbindgen_add_to_stack_pointer(16),E.__wbindgen_export4(n,s,1)}}fix(e,t){let n,s;try{let h=E.__wbindgen_add_to_stack_pointer(-16),f=It(e,E.__wbindgen_export,E.__wbindgen_export2),c=lt;var r=Et(t)?0:It(t,E.__wbindgen_export,E.__wbindgen_export2),o=lt;E.linter_fix(h,this.__wbg_ptr,f,c,r,o);var l=X().getInt32(h+0,!0),a=X().getInt32(h+4,!0);return n=l,s=a,bt(l,a)}finally{E.__wbindgen_add_to_stack_pointer(16),E.__wbindgen_export4(n,s,1)}}static from_config_files(e){try{let r=E.__wbindgen_add_to_stack_pointer(-16);E.linter_from_config_files(r,ae(e));var t=X().getInt32(r+0,!0),n=X().getInt32(r+4,!0),s=X().getInt32(r+8,!0);if(s)throw ka(n);return i.__wrap(t)}finally{E.__wbindgen_add_to_stack_pointer(16)}}get_config(){let e,t;try{let r=E.__wbindgen_add_to_stack_pointer(-16);E.linter_get_config(r,this.__wbg_ptr);var n=X().getInt32(r+0,!0),s=X().getInt32(r+4,!0);return e=n,t=s,bt(n,s)}finally{E.__wbindgen_add_to_stack_pointer(16),E.__wbindgen_export4(e,t,1)}}get_config_warnings(){let e,t;try{let r=E.__wbindgen_add_to_stack_pointer(-16);E.linter_get_config_warnings(r,this.__wbg_ptr);var n=X().getInt32(r+0,!0),s=X().getInt32(r+4,!0);return e=n,t=s,bt(n,s)}finally{E.__wbindgen_add_to_stack_pointer(16),E.__wbindgen_export4(e,t,1)}}constructor(e){try{let r=E.__wbindgen_add_to_stack_pointer(-16);E.linter_new(r,ae(e));var t=X().getInt32(r+0,!0),n=X().getInt32(r+4,!0),s=X().getInt32(r+8,!0);if(s)throw ka(n);return this.__wbg_ptr=t>>>0,ba.register(this,this.__wbg_ptr,this),this}finally{E.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(_i.prototype[Symbol.dispose]=_i.prototype.free);function Dd(){let i,e;try{let s=E.__wbindgen_add_to_stack_pointer(-16);E.get_version(s);var t=X().getInt32(s+0,!0),n=X().getInt32(s+4,!0);return i=t,e=n,bt(t,n)}finally{E.__wbindgen_add_to_stack_pointer(16),E.__wbindgen_export4(i,e,1)}}function Jb(){return{__proto__:null,"./rumdl_lib_bg.js":{__proto__:null,__wbg_Error_960c155d3d49e4c2:function(e,t){let n=Error(bt(e,t));return ae(n)},__wbg_Number_32bf70a599af1d4b:function(e){return Number(P(e))},__wbg_String_8564e559799eccda:function(e,t){let n=String(P(t)),s=It(n,E.__wbindgen_export,E.__wbindgen_export2),r=lt;X().setInt32(e+4,r,!0),X().setInt32(e+0,s,!0)},__wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51:function(e,t){let n=P(t),s=typeof n=="bigint"?n:void 0;X().setBigInt64(e+8,Et(s)?BigInt(0):s,!0),X().setInt32(e+0,!Et(s),!0)},__wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff:function(e){let t=P(e),n=typeof t=="boolean"?t:void 0;return Et(n)?16777215:n?1:0},__wbg___wbindgen_debug_string_ab4b34d23d6778bd:function(e,t){let n=xa(P(t)),s=It(n,E.__wbindgen_export,E.__wbindgen_export2),r=lt;X().setInt32(e+4,r,!0),X().setInt32(e+0,s,!0)},__wbg___wbindgen_in_a5d8b22e52b24dd1:function(e,t){return P(e)in P(t)},__wbg___wbindgen_is_bigint_ec25c7f91b4d9e93:function(e){return typeof P(e)=="bigint"},__wbg___wbindgen_is_function_3baa9db1a987f47d:function(e){return typeof P(e)=="function"},__wbg___wbindgen_is_null_52ff4ec04186736f:function(e){return P(e)===null},__wbg___wbindgen_is_object_63322ec0cd6ea4ef:function(e){let t=P(e);return typeof t=="object"&&t!==null},__wbg___wbindgen_is_undefined_29a43b4d42920abd:function(e){return P(e)===void 0},__wbg___wbindgen_jsval_eq_d3465d8a07697228:function(e,t){return P(e)===P(t)},__wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c:function(e,t){return P(e)==P(t)},__wbg___wbindgen_number_get_c7f42aed0525c451:function(e,t){let n=P(t),s=typeof n=="number"?n:void 0;X().setFloat64(e+8,Et(s)?0:s,!0),X().setInt32(e+0,!Et(s),!0)},__wbg___wbindgen_string_get_7ed5322991caaec5:function(e,t){let n=P(t),s=typeof n=="string"?n:void 0;var r=Et(s)?0:It(s,E.__wbindgen_export,E.__wbindgen_export2),o=lt;X().setInt32(e+4,o,!0),X().setInt32(e+0,r,!0)},__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw new Error(bt(e,t))},__wbg_call_14b169f759b26747:function(){return ya(function(e,t){let n=P(e).call(P(t));return ae(n)},arguments)},__wbg_done_9158f7cc8751ba32:function(e){return P(e).done},__wbg_entries_e0b73aa8571ddb56:function(e){let t=Object.entries(P(e));return ae(t)},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,s;try{n=e,s=t,console.error(bt(e,t))}finally{E.__wbindgen_export4(n,s,1)}},__wbg_get_1affdbdd5573b16a:function(){return ya(function(e,t){let n=Reflect.get(P(e),P(t));return ae(n)},arguments)},__wbg_get_8360291721e2339f:function(e,t){let n=P(e)[t>>>0];return ae(n)},__wbg_get_unchecked_17f53dad852b9588:function(e,t){let n=P(e)[t>>>0];return ae(n)},__wbg_get_with_ref_key_6412cf3094599694:function(e,t){let n=P(e)[P(t)];return ae(n)},__wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3:function(e){let t;try{t=P(e)instanceof ArrayBuffer}catch{t=!1}return t},__wbg_instanceof_Map_1b76fd4635be43eb:function(e){let t;try{t=P(e)instanceof Map}catch{t=!1}return t},__wbg_instanceof_Uint8Array_152ba1f289edcf3f:function(e){let t;try{t=P(e)instanceof Uint8Array}catch{t=!1}return t},__wbg_isArray_c3109d14ffc06469:function(e){return Array.isArray(P(e))},__wbg_isSafeInteger_4fc213d1989d6d2a:function(e){return Number.isSafeInteger(P(e))},__wbg_iterator_013bc09ec998c2a7:function(){return ae(Symbol.iterator)},__wbg_length_3d4ecd04bd8d22f1:function(e){return P(e).length},__wbg_length_9f1775224cf1d815:function(e){return P(e).length},__wbg_new_0c7403db6e782f19:function(e){let t=new Uint8Array(P(e));return ae(t)},__wbg_new_227d7c05414eb861:function(){let e=new Error;return ae(e)},__wbg_next_0340c4ae324393c3:function(){return ya(function(e){let t=P(e).next();return ae(t)},arguments)},__wbg_next_7646edaa39458ef7:function(e){let t=P(e).next;return ae(t)},__wbg_prototypesetcall_a6b02eb00b0f4ce2:function(e,t,n){Uint8Array.prototype.set.call(Zb(e,t),P(n))},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=P(t).stack,s=It(n,E.__wbindgen_export,E.__wbindgen_export2),r=lt;X().setInt32(e+4,r,!0),X().setInt32(e+0,s,!0)},__wbg_value_ee3a06f4579184fa:function(e){let t=P(e).value;return ae(t)},__wbindgen_cast_0000000000000001:function(e){return ae(e)},__wbindgen_cast_0000000000000002:function(e,t){let n=bt(e,t);return ae(n)},__wbindgen_cast_0000000000000003:function(e){let t=BigInt.asUintN(64,e);return ae(t)},__wbindgen_object_clone_ref:function(e){let t=P(e);return ae(t)},__wbindgen_object_drop_ref:function(e){ka(e)}}}}var ba=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>E.__wbg_linter_free(i>>>0,1));function ae(i){In===gt.length&&gt.push(gt.length+1);let e=In;return In=gt[e],gt[e]=i,e}function xa(i){let e=typeof i;if(e=="number"||e=="boolean"||i==null)return`${i}`;if(e=="string")return`"${i}"`;if(e=="symbol"){let s=i.description;return s==null?"Symbol":`Symbol(${s})`}if(e=="function"){let s=i.name;return typeof s=="string"&&s.length>0?`Function(${s})`:"Function"}if(Array.isArray(i)){let s=i.length,r="[";s>0&&(r+=xa(i[0]));for(let o=1;o<s;o++)r+=", "+xa(i[o]);return r+="]",r}let t=/\[object ([^\]]+)\]/.exec(toString.call(i)),n;if(t&&t.length>1)n=t[1];else return toString.call(i);if(n=="Object")try{return"Object("+JSON.stringify(i)+")"}catch{return"Object"}return i instanceof Error?`${i.name}: ${i.message}
${i.stack}`:n}function Qb(i){i<1028||(gt[i]=In,In=i)}function Zb(i,e){return i=i>>>0,En().subarray(i/1,i/1+e)}var si=null;function X(){return(si===null||si.buffer.detached===!0||si.buffer.detached===void 0&&si.buffer!==E.memory.buffer)&&(si=new DataView(E.memory.buffer)),si}function bt(i,e){return i=i>>>0,t1(i,e)}var On=null;function En(){return(On===null||On.byteLength===0)&&(On=new Uint8Array(E.memory.buffer)),On}function P(i){return gt[i]}function ya(i,e){try{return i.apply(this,e)}catch(t){E.__wbindgen_export3(ae(t))}}var gt=new Array(1024).fill(void 0);gt.push(void 0,null,!0,!1);var In=gt.length;function Et(i){return i==null}function It(i,e,t){if(t===void 0){let l=_n.encode(i),a=e(l.length,1)>>>0;return En().subarray(a,a+l.length).set(l),lt=l.length,a}let n=i.length,s=e(n,1)>>>0,r=En(),o=0;for(;o<n;o++){let l=i.charCodeAt(o);if(l>127)break;r[s+o]=l}if(o!==n){o!==0&&(i=i.slice(o)),s=t(s,n,n=o+i.length*3,1)>>>0;let l=En().subarray(s+o,s+n),a=_n.encodeInto(i,l);o+=a.written,s=t(s,n,o,1)>>>0}return lt=o,s}function ka(i){let e=P(i);return Qb(i),e}var kr=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});kr.decode();var e1=2146435072,wa=0;function t1(i,e){return wa+=e,wa>=e1&&(kr=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),kr.decode(),wa=e),kr.decode(En().subarray(i,i+e))}var _n=new TextEncoder;"encodeInto"in _n||(_n.encodeInto=function(i,e){let t=_n.encode(i);return e.set(t),{read:i.length,written:t.length}});var lt=0,i1,E;function n1(i,e){return E=i.exports,i1=e,si=null,On=null,E.__wbindgen_start(),E}async function s1(i,e){if(typeof Response=="function"&&i instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,e)}catch(s){if(i.ok&&t(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}let n=await i.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{let n=await WebAssembly.instantiate(i,e);return n instanceof WebAssembly.Instance?{instance:n,module:i}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}async function Bd(i){if(E!==void 0)return E;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("rumdl_lib_bg.wasm",import.meta.url));let e=Jb();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));let{instance:t,module:n}=await s1(await i,e);return n1(t,n)}var Od=be.define(),Rn=R.define(),Ed;async function Wy(){return Ed||=Bd(),await Ed,{Linter:_i,get_version:Dd}}var r1=Li.define([{tag:y.heading,color:"var(--rm-accent)",fontWeight:"700"},{tag:[y.link,y.url],color:"var(--rm-success)",textDecoration:"underline"},{tag:y.strong,color:"var(--rm-ink)",fontWeight:"700"},{tag:y.emphasis,color:"var(--rm-ink)",fontStyle:"italic"},{tag:[y.monospace,y.contentSeparator],color:"var(--rm-warning)"},{tag:[y.meta,y.processingInstruction],color:"var(--rm-muted)"},{tag:y.comment,color:"var(--rm-muted)",fontStyle:"italic"}]);function o1(i,e,t){return Math.min(Math.max(i,e),t)}function Id(i,e,t){let n=o1(Number(e)||1,1,i.lines),s=i.line(n),r=Math.max(0,(Number(t)||1)-1),o=Array.from(s.text).slice(0,r).join("");return Math.min(s.to,s.from+o.length)}function l1(i,e){if(e>=i.length)return e;let t=i.codePointAt(e);return Math.min(i.length,e+(t>65535?2:1))}function _d(i,e){let t=Id(i.doc,e.line,e.column),n=Number(e.end_line)||Number(e.line)||1,s=Number(e.end_column)||(Number(e.column)||1)+1,r=Id(i.doc,n,s);return r<=t&&(r=l1(i.doc.toString(),t)),{from:t,to:Math.max(t,r)}}function a1(i,e,t,n,s){let r=_d(i,e),o=["error","warning","info"].includes(e.severity)?e.severity:"warning";return{...r,severity:o,source:e.rule_name||"rumdl",message:e.message,markClass:e.fix==null?"cm-rumdl-manual":"cm-rumdl-fixable",actions:e.fix==null?void 0:[{name:"Fix",apply(){s(t,n)}}]}}function Vy({parent:i,doc:e="",metadata:t={},onChange:n,onFix:s,onFixAll:r,onHistoryChange:o}){let l=te.define({create(){return t},update(f,c){for(let u of c.effects)u.is(Rn)&&(f=u.value);return f}}),a=G.create({doc:e,extensions:[Zf(),ec(),Hf(),qc(),l,Hl.of(f=>{let c=[];for(let u of f.effects)u.is(Rn)&&c.push(Rn.of(f.startState.field(l)));return c}),_f(),Nf(),G.allowMultipleSelections.of(!0),G.tabSize.of(2),Cc(),Tc(),zf(),qf(),Wf(),Sd(),D.lineWrapping,Ff(),Vf("Type or paste Markdown here\u2026"),nd,xc(r1),bd({hoverTime:180}),Os.of([{key:"Mod-Enter",preventDefault:!0,run(){return r(),!0}},...Oc,...yu,...Td,...Kc,...cd]),D.contentAttributes.of({"aria-label":"Markdown editor","aria-describedby":"pg-editor-help",autocapitalize:"off",autocomplete:"off",spellcheck:"false"}),D.updateListener.of(f=>{o?.({canUndo:Wl(f.state)>0,metadata:f.state.field(l)}),f.docChanged&&(f.transactions.some(u=>u.annotation(Od))||n(f.state.doc.toString(),f.state.field(l)))})]}),h=new D({state:a,parent:i});return{focus(){h.focus()},getValue(){return h.state.doc.toString()},setValue(f,c={}){let u=String(f),d=h.state.doc.toString(),p=c.metadata??h.state.field(l),m=p!==h.state.field(l);u===d&&!m||h.dispatch({changes:{from:0,to:h.state.doc.length,insert:u},effects:Rn.of(p),annotations:[Od.of(!0),se.addToHistory.of(c.addToHistory!==!1),Nl.of("full")]})},setMetadata(f){h.dispatch({effects:Rn.of(f),annotations:se.addToHistory.of(!1)})},canUndo(){return Wl(h.state)>0},undo(){return $s(h)},resetScroll(){h.scrollDOM.scrollTop=0,h.scrollDOM.scrollLeft=0},setWarnings(f,c=h.state.doc.toString()){let u=f.map((d,p)=>a1(h.state,d,p,c,s));h.dispatch(ad(h.state,u))},revealWarning(f){let c=_d(h.state,f);h.dispatch({selection:{anchor:c.from,head:c.to},effects:D.scrollIntoView(c.from,{y:"center"})}),h.focus()},destroy(){h.destroy()}}}export{Vy as createRumdlEditor,Wy as loadRumdl};
/*! CodeMirror 6 and its runtime dependencies are MIT licensed.
 *  See /javascripts/playground-editor.licenses.txt for notices. */