/** * 由 Fantastic-admin 提供技术支持 * Powered by Fantastic-admin * Gitee https://gitee.com/hooray/fantastic-admin * Github https://github.com/hooray/fantastic-admin */ import{E as qt,C as lr,a as ar,t as y,d as hr,s as Dn,l as fr,L as cr,i as ur,g as Et,f as Or,h as dr,b as pr,I as gr,N as mr}from"./notice-8204c0df.js";import"./index-8b6b646b.js";import"./index-a62c661f.js";import"./config-68c3151c.js";class Q{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=$e(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),J.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=$e(this,e,t);let i=[];return this.decompose(e,t,i,0),J.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new Ze(this),r=new Ze(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new Ze(this,e)}iterRange(e,t=this.length){return new Zn(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ln(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Q.empty:e.length<=32?new V(e):J.from(V.split(e,[]))}}class V extends Q{constructor(e,t=xr(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new Sr(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new V(Yi(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=gt(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new V(l,o.length+r.length));else{let a=l.length>>1;i.push(new V(l.slice(0,a)),new V(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof V))return super.replace(e,t,i);[e,t]=$e(this,e,t);let n=gt(this.text,gt(i.text,Yi(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new V(n,r):J.from(V.split(n,[]),r)}sliceString(e,t=this.length,i=` `){[e,t]=$e(this,e,t);let n="";for(let r=0,o=0;r<=t&&oe&&o&&(n+=i),er&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new V(i,n)),i=[],n=-1);return n>-1&&t.push(new V(i,n)),t}}class J extends Q{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r=o){let f=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!f?i.push(l):l.decompose(e-o,t-o,i,f)}o=a+1}}replace(e,t,i){if([e,t]=$e(this,e,t),i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),f=this.lines-o.lines+a.lines;if(a.lines>5-1&&a.lines>f>>5+1){let h=this.children.slice();return h[n]=a,new J(h,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=$e(this,e,t);let n="";for(let r=0,o=0;re&&r&&(n+=i),eo&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof J))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],f=e.children[r];if(a!=f)return i+a.scanIdentical(f,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let O of e)i+=O.lines;if(i<32){let O=[];for(let d of e)d.flatten(O);return new V(O,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,f=-1,h=[];function c(O){let d;if(O.lines>r&&O instanceof J)for(let g of O.children)c(g);else O.lines>o&&(a>o||!a)?(u(),l.push(O)):O instanceof V&&a&&(d=h[h.length-1])instanceof V&&O.lines+d.lines<=32?(a+=O.lines,f+=O.length+1,h[h.length-1]=new V(d.text.concat(O.text),d.length+1+O.length)):(a+O.lines>n&&u(),a+=O.lines,f+=O.length+1,h.push(O))}function u(){a!=0&&(l.push(h.length==1?h[0]:J.from(h,f)),f=-1,a=h.length=0)}for(let O of e)c(O);return u(),l.length==1?l[0]:new J(l,t)}}Q.empty=new V([""],0);function xr(s){let e=-1;for(let t of s)e+=t.length+1;return e}function gt(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-n)),n0?1:(e instanceof V?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof V?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(n instanceof V){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof V?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Zn{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ze(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ln{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},Ze.prototype[Symbol.iterator]=Zn.prototype[Symbol.iterator]=Ln.prototype[Symbol.iterator]=function(){return this});class Sr{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function $e(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}let Qe="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s=>s?parseInt(s,36):1);for(let s=1;ss)return Qe[e-1]<=s;return!1}function Di(s){return s>=127462&&s<=127487}const Zi=8205;function ie(s,e,t=!0,i=!0){return(t?Gn:Tr)(s,e,i)}function Gn(s,e,t){if(e==s.length)return e;e&&Bn(s.charCodeAt(e))&&In(s.charCodeAt(e-1))&&e--;let i=mt(s,e);for(e+=Ut(i);e=0&&Di(mt(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Tr(s,e,t){for(;e>0;){let i=Gn(s,e-2,t);if(i=56320&&s<57344}function In(s){return s>=55296&&s<56320}function mt(s,e){let t=s.charCodeAt(e);if(!In(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Bn(i)?(t-55296<<10)+(i-56320)+65536:t}function Ut(s){return s<65536?1:2}const Nt=/\r\n?|\n/;var G=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(G||(G={}));class se{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-n);r+=l}else{if(i!=G.Simple&&f>=e&&(i==G.TrackDel&&ne||i==G.TrackBefore&&ne))return null;if(f>e||f==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=f}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i=0&&n<=t&&l>=e)return nt?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t=0?":"+n:"")}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 se(e)}static create(e){return new se(e)}}class C extends se{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 zt(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return _t(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length0&&fe(i,t,r.text),r.forward(h),l+=h}let f=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(h=!1){if(!h&&!n.length)return;ou||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let d=O?typeof O=="string"?Q.of(O.split(i||Nt)):O:Q.empty,g=d.length;if(c==u&&g==0)return;co&&D(n,c-o,-1),D(n,u-c,g),fe(r,n,d),o=u}}return f(e),a(!l),l}static empty(e){return new C(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;nl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==s[n+1]?s[n]+=e:e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function fe(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,f,r,h,c),n=f,r=h}}}function _t(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Ie(s),l=new Ie(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let f=Math.min(o.len,l.len);D(n,f,-1),o.forward(f),l.forward(f)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let f=0,h=o.len;for(;h;)if(l.ins==-1){let c=Math.min(h,l.len);f+=c,h-=c,l.forward(c)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>f),r.forward2(a),o.forward(a)}}}}class Ie{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ge{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ge(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return S.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return S.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return S.range(e.anchor,e.head)}static create(e,t,i){return new ge(e,t,i)}}class S{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:S.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.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 S(e.ranges.map(t=>ge.fromJSON(t)),e.main)}static single(e,t=e){return new S([S.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;ne?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;nr.head?S.range(a,l):S.range(l,a))}}return new S(e,t)}}function Un(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let bi=0;class b{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=bi++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new b(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:yi),!!e.static,e.enables)}of(e){return new xt([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xt(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xt(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function yi(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class xt{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=bi++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,f=!1,h=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?f=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||h.push(e[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(a&&u.docChanged||f&&(u.docChanged||u.selection)||jt(c,h)){let O=i(c);if(l?!Li(O,c.values[o],n):!n(O,c.values[o]))return c.values[o]=O,1}return 0},reconfigure:(c,u)=>{let O,d=u.config.address[r];if(d!=null){let g=yt(u,d);if(this.dependencies.every(p=>p instanceof b?u.facet(p)===c.facet(p):p instanceof be?u.field(p,!1)==c.field(p,!1):!0)||(l?Li(O=i(c),g,n):n(O=i(c),g)))return c.values[o]=g,0}else O=i(c);return c.values[o]=O,1}}}}function Li(s,e,t){if(s.length!=e.length)return!1;for(let i=0;is[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let f=[];for(let h=0;hi===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Gi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Gi.of({field:this,create:e})]}get extension(){return this}}const pe={lowest:4,low:3,default:2,high:1,highest:0};function Xe(s){return e=>new Nn(e,s)}const Pi={highest:Xe(pe.highest),high:Xe(pe.high),default:Xe(pe.default),low:Xe(pe.low),lowest:Xe(pe.lowest)};class Nn{constructor(e,t){this.inner=e,this.prec=t}}class $t{of(e){return new Ht(this,e)}reconfigure(e){return $t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ht{constructor(e,t){this.compartment=e,this.inner=t}}class bt{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of yr(e,t,o))u instanceof be?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],f=[];for(let u of n)l[u.id]=f.length<<1,f.push(O=>u.slot(O));let h=i==null?void 0:i.config.facets;for(let u in r){let O=r[u],d=O[0].facet,g=h&&h[u]||[];if(O.every(p=>p.type==0))if(l[d.id]=a.length<<1|1,yi(g,O))a.push(i.facet(d));else{let p=d.combine(O.map(m=>m.value));a.push(i&&d.compare(p,i.facet(d))?i.facet(d):p)}else{for(let p of O)p.type==0?(l[p.id]=a.length<<1|1,a.push(p.value)):(l[p.id]=f.length<<1,f.push(m=>p.dynamicSlot(m)));l[d.id]=f.length<<1,f.push(p=>br(p,d,O))}}let c=f.map(u=>u(l));return new bt(e,o,c,l,a,r)}}function yr(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let f=i[a].indexOf(o);f>-1&&i[a].splice(f,1),o instanceof Ht&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let f of o)r(f,l);else if(o instanceof Ht){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(o.compartment)||o.inner;t.set(o.compartment,f),r(f,l)}else if(o instanceof Nn)r(o.inner,o.prec);else if(o instanceof be)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof xt)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,pe.default);else{let f=o.extension;if(!f)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(f,l)}}return r(s,pe.default),i.reduce((o,l)=>o.concat(l))}function Le(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function yt(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const zn=b.define(),Kt=b.define({combine:s=>s.some(e=>e),static:!0}),_n=b.define({combine:s=>s.length?s[0]:void 0,static:!0}),jn=b.define(),Hn=b.define(),Kn=b.define(),Jn=b.define({combine:s=>s.length?s[0]:!1});class ye{constructor(e,t){this.type=e,this.value=t}static define(){return new Pr}}class Pr{of(e){return new ye(this,e)}}class Qr{constructor(e){this.map=e}of(e){return new X(this,e)}}class X{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 X(this.type,t)}is(e){return this.type==e}static define(e={}){return new Qr(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}X.reconfigure=X.define();X.appendConfig=X.define();class L{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Un(i,t.newLength),r.some(l=>l.type==L.time)||(this.annotations=r.concat(L.time.of(Date.now())))}static create(e,t,i,n,r,o){return new L(e,t,i,n,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(L.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}L.time=ye.define();L.userEvent=ye.define();L.addToHistory=ye.define();L.remote=ye.define();function vr(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i=s[i]))r=s[i++],o=s[i++];else if(n=0;n--){let r=i[n](s);r instanceof L?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof L?s=r[0]:s=ts(e,ve(r),!1)}return s}function qr(s){let e=s.startState,t=e.facet(Kn),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=es(i,Jt(e,r,s.changes.newLength),!0))}return i==s?s:L.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const $r=[];function ve(s){return s==null?$r:Array.isArray(s)?s:[s]}var ne=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(ne||(ne={}));const Rr=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ei;try{ei=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Wr(s){if(ei)return ei.test(s);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Rr.test(t)))return!0}return!1}function Ar(s){return e=>{if(!/\S/.test(e))return ne.Space;if(Wr(e))return ne.Word;for(let t=0;t-1)return ne.Word;return ne.Other}}class ${constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ln.set(f,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(X.reconfigure)?(t=null,i=l.value):l.is(X.appendConfig)&&(t=null,i=ve(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=bt.resolve(i,n,this),r=new $(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,f)=>f.reconfigure(a,this),null).values);let o=e.startState.facet(Kt)?e.newSelection:e.newSelection.asSingle();new $(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:S.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=ve(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return $.create({doc:e.doc,selection:S.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=bt.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet($.lineSeparator)||Nt)),n=e.selection?e.selection instanceof S?e.selection:S.single(e.selection.anchor,e.selection.head):S.single(0);return Un(n,i.length),t.staticFacet(Kt)||(n=n.asSingle()),new $(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet($.tabSize)}get lineBreak(){return this.facet($.lineSeparator)||` `}get readOnly(){return this.facet(Jn)}phrase(e,...t){for(let i of this.facet($.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(zn))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){return Ar(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=ie(t,o,!1);if(r(t.slice(a,o))!=ne.Word)break;o=a}for(;ls.length?s[0]:4});$.lineSeparator=_n;$.readOnly=Jn;$.phrases=b.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(n=>s[n]==e[n])}});$.languageData=zn;$.changeFilter=jn;$.transactionFilter=Hn;$.transactionExtender=Kn;$t.reconfigure=X.define();class Se{eq(e){return this==e}range(e,t=e){return Fe.create(e,t,this)}}Se.prototype.startSide=Se.prototype.endSide=0;Se.prototype.point=!1;Se.prototype.mapMode=G.TrackDel;class Fe{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Fe(e,t,i)}}function ti(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class Qi{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,f=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return f>=0?o:l;f>=0?l=a:o=a+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rO||u==O&&f.startSide>0&&f.endSide<=0)continue;(O-u||f.endSide-f.startSide)<0||(o<0&&(o=u),f.point&&(l=Math.max(l,O-u)),i.push(f),n.push(u-o),r.push(O-o))}return{mapped:i.length?new Qi(n,r,i,l):null,pos:o}}}class R{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new R(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(ti)),this.isEmpty)return t.length?R.of(t):this;let l=new is(this,null,-1).goto(0),a=0,f=[],h=new Pt;for(;l.value||a=0){let c=t[a++];h.addInner(c.from,c.to,c.value)||f.push(c)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ue.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ue.from(e).goto(t)}static compare(e,t,i,n,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=Bi(o,l,i),f=new Ee(o,a,r),h=new Ee(l,a,r);i.iterGaps((c,u,O)=>Ii(f,c,h,u,O,n)),i.empty&&i.length==0&&Ii(f,0,h,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=1e9-1);let r=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Bi(r,o),a=new Ee(r,l,0).goto(i),f=new Ee(o,l,0).goto(i);for(;;){if(a.to!=f.to||!ii(a.active,f.active)||a.point&&(!f.point||!a.point.eq(f.point)))return!1;if(a.to>n)return!0;a.next(),f.next()}}static spans(e,t,i,n,r=-1){let o=new Ee(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let f=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),c=o.pointFroml&&(n.span(l,f,o.active,a),a=o.openEnd(f));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Pt;for(let n of e instanceof Fe?[e]:t?Vr(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return R.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=R.empty;n=n.nextLayer)t=new R(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}R.empty=new R([],[],null,-1);function Vr(s){if(s.length>1)for(let e=s[0],t=1;t0)return s.slice().sort(ti);e=i}return s}R.empty.nextLayer=R.empty;class Pt{finishChunk(e){this.chunks.push(new Qi(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Pt)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(R.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=R.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Bi(s,e,t){let i=new Map;for(let r of s)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new is(o,t,i,r));return n.length==1?n[0]:new Ue(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Ct(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Ct(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Ct(this.heap,0)}}}function Ct(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1=0&&(n=s[i+1],i++),t.compare(n)<0)break;s[i]=t,s[e]=n,e=i}}class Ee{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ue.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){st(this.active,e),st(this.activeTo,e),st(this.activeRank,e),this.minActive=Fi(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t0;)t++;rt(this.active,t,i),rt(this.activeTo,t,n),rt(this.activeRank,t,r),e&&rt(e,t,this.cursor.from),this.minActive=Fi(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&st(i,n)}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(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[n]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Ii(s,e,t,i,n,r){s.goto(e),t.goto(i);let o=i+n,l=i,a=i-e;for(;;){let f=s.to+a-t.to||s.endSide-t.endSide,h=f<0?s.to+a:t.to,c=Math.min(h,o);if(s.point||t.point?s.point&&t.point&&(s.point==t.point||s.point.eq(t.point))&&ii(s.activeForPoint(s.to),t.activeForPoint(t.to))||r.comparePoint(l,c,s.point,t.point):c>l&&!ii(s.active,t.active)&&r.compareRange(l,c,s.active,t.active),h>o)break;l=h,f<=0&&s.next(),f>=0&&t.next()}}function ii(s,e){if(s.length!=e.length)return!1;for(let t=0;t=e;i--)s[i+1]=s[i];s[e]=t}function Fi(s,e){let t=-1,i=1e9;for(let n=0;n=e)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?t-r%t:1,n=ie(s,n)}return i===!0?-1:s.length}const ni="ͼ",Ui=typeof Symbol>"u"?"__"+ni:Symbol.for(ni),si=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ni=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Re{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,f){let h=[],c=/^@(\w+)\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let O in l){let d=l[O];if(/&/.test(O))r(O.split(/,\s*/).map(g=>o.map(p=>g.replace(/&/,p))).reduce((g,p)=>g.concat(p)),d,a);else if(d&&typeof d=="object"){if(!c)throw new RangeError("The value of a property ("+O+") should be a primitive value.");r(n(O),d,h,u)}else d!=null&&h.push(O.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+d+";")}(h.length||u)&&a.push((i&&!c&&!f?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)r(n(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Ni[Ui]||1;return Ni[Ui]=e+1,ni+e.toString(36)}static mount(e,t,i){let n=e[si],r=i&&i.nonce;n?r&&n.setNonce(r):n=new Er(e,r),n.mount(Array.isArray(t)?t:[t])}}let zi=new Map;class Er{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=zi.get(i);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[si]=r;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],zi.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[si]=this}mount(e){let t=this.sheet,i=0,n=0;for(let r=0;r-1&&(this.modules.splice(l,1),n--,l=-1),l==-1){if(this.modules.splice(n++,0,o),t)for(let a=0;a",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Cr=typeof navigator<"u"&&/Mac/.test(navigator.platform),Mr=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Y=0;Y<10;Y++)Oe[48+Y]=Oe[96+Y]=String(Y);for(var Y=1;Y<=24;Y++)Oe[Y+111]="F"+Y;for(var Y=65;Y<=90;Y++)Oe[Y]=String.fromCharCode(Y+32),Ne[Y]=String.fromCharCode(Y);for(var Mt in Oe)Ne.hasOwnProperty(Mt)||(Ne[Mt]=Oe[Mt]);function Yr(s){var e=Cr&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||Mr&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?Ne:Oe)[s.keyCode]||s.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 Qt(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function ri(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Dr(s){let e=s.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function St(s,e){if(!e.anchorNode)return!1;try{return ri(s,e.anchorNode)}catch{return!1}}function ze(s){return s.nodeType==3?we(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function Ge(s,e,t,i){return t?_i(s,e,t,i,-1)||_i(s,e,t,i,1):!1}function _e(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function _i(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:oe(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=_e(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?oe(s):0}else return!1}}function oe(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function vi(s,e){let t=e?s.left:s.right;return{left:t,right:t,top:s.top,bottom:s.bottom}}function Zr(s){return{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function ns(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Lr(s,e,t,i,n,r,o,l){let a=s.ownerDocument,f=a.defaultView||window;for(let h=s,c=!1;h&&!c;)if(h.nodeType==1){let u,O=h==a.body,d=1,g=1;if(O)u=Zr(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(c=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let w=h.getBoundingClientRect();({scaleX:d,scaleY:g}=ns(h,w)),u={left:w.left,right:w.left+h.clientWidth*d,top:w.top,bottom:w.top+h.clientHeight*g}}let p=0,m=0;if(n=="nearest")e.top0&&e.bottom>u.bottom+m&&(m=e.bottom-u.bottom+m+o)):e.bottom>u.bottom&&(m=e.bottom-u.bottom+o,t<0&&e.top-m0&&e.right>u.right+p&&(p=e.right-u.right+p+r)):e.right>u.right&&(p=e.right-u.right+r,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class Br{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?oe(t):0),i,Math.min(e.focusOffset,i?oe(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let Pe=null;function ss(s){if(s.setActive)return s.setActive();if(Pe)return s.focus(Pe);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(Pe==null?{get preventScroll(){return Pe={preventScroll:!0},!0}}:void 0),!Pe){Pe=!1;for(let t=0;tMath.max(1,s.scrollHeight-s.clientHeight-4)}class Z{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Z(e.parentNode,_e(e),t)}static after(e,t){return new Z(e.parentNode,_e(e)+1,t)}}const ki=[];class W{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,n=null,r;for(let o of this.children){if(o.flags&7){if(!o.dom&&(r=n?n.nextSibling:i.firstChild)){let l=W.get(r);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(r)}o.sync(e,t),o.flags&=-8}if(r=n?n.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&r!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;r&&r!=o.dom;)r=Hi(r);else i.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:i.firstChild,r&&t&&t.node==i&&(t.written=!0);r;)r=Hi(r)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let n=oe(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;n==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?n=-1:n=1),e=r}n<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!W.get(i);)i=i.nextSibling;if(!i)return this.length;for(let n=0,r=0;;n++){let o=this.children[n];if(o.dom==i)return r;r+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let n=-1,r=-1,o=-1,l=-1;for(let a=0,f=i,h=i;at)return c.domBoundsAround(e,t,f);if(u>=e&&n==-1&&(n=a,r=f),f>t&&c.dom.parentNode==this.dom){o=a,l=h;break}h=u,f=u+c.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=ki){this.markDirty();for(let n=e;nthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function as(s,e,t,i,n,r,o,l,a){let{children:f}=s,h=f.length?f[e]:null,c=r.length?r[r.length-1]:null,u=c?c.breakAfter:o;if(!(e==i&&h&&!o&&!u&&r.length<2&&h.merge(t,n,r.length?c:null,t==0,l,a))){if(i0&&(!o&&r.length&&h.merge(t,h.length,r[0],!1,l,0)?h.breakAfter=r.shift().breakAfter:(t2);var x={mac:en||/Mac/.test(N.platform),windows:/Win/.test(N.platform),linux:/Linux|X11/.test(N.platform),ie:Rt,ie_version:fs?oi.documentMode||6:ai?+ai[1]:li?+li[1]:0,gecko:Ki,gecko_version:Ki?+(/Firefox\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,chrome:!!Yt,chrome_version:Yt?+Yt[1]:0,ios:en,android:/Android\b/.test(N.userAgent),webkit:Ji,safari:cs,webkit_version:Ji?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:oi.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Ur=256;class le extends W{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof le)||this.length-(t-e)+i.length>Ur||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new le(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Z(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Nr(this.dom,e,t)}}class ae extends W{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let n of t)n.setParent(this)}setAttrs(e){if(rs(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,n,r,o){return i&&(!(i instanceof ae&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(n=r),i=a,r++}let o=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new ae(this.mark,t,o)}domAtPos(e){return us(this,e)}coordsAt(e,t){return ds(this,e,t)}}function Nr(s,e,t){let i=s.nodeValue.length;e>i&&(e=i);let n=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?x.chrome||x.gecko||(e?(n--,o=1):r=0)?0:l.length-1];return x.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,f=>f.width)||a),o?vi(a,o<0):a||null}class me extends W{static create(e,t,i){return new me(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=me.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,n,r,o){return i&&(!(i instanceof me)||!this.widget.compare(i.widget)||e>0&&r<=0||t0)?Z.before(this.dom):Z.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let n=this.dom.getClientRects(),r=null;if(!n.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?n.length-1:0;r=n[l],!(e>0?l==0:l==n.length-1||r.top0?Z.before(this.dom):Z.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Q.empty}get isHidden(){return!0}}le.prototype.children=me.prototype.children=We.prototype.children=ki;function us(s,e){let t=s.dom,{children:i}=s,n=0;for(let r=0;nr&&e0;r--){let o=i[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=n;r0&&e instanceof ae&&n.length&&(i=n[n.length-1])instanceof ae&&i.mark.eq(e.mark)?Os(i,e.children[0],t-1):(n.push(e),e.setParent(s)),s.length+=e.length}function ds(s,e,t){let i=null,n=-1,r=null,o=-1;function l(f,h){for(let c=0,u=0;c=h&&(O.children.length?l(O,h-u):(!r||r.isHidden&&t>0)&&(d>h||u==d&&O.getSide()>0)?(r=O,o=h-u):(u-1?1:0)!=n.length-(t&&n.indexOf(t)>-1?1:0))return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function fi(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function _r(s){let e=Object.create(null);for(let t=0;t0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){qi(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Os(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=hi(t,this.attrs||{})),i&&(this.attrs=hi({class:i},this.attrs||{}))}domAtPos(e){return us(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(rs(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(fi(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let n=this.dom.lastChild;for(;n&&W.get(n)instanceof ae;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((i=W.get(n))===null||i===void 0?void 0:i.isEditable)==!1&&(!x.ios||!this.children.some(r=>r instanceof le))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof le)||/[^ -~]/.test(i.text))return null;let n=ze(i.dom);if(n.length!=1)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=ds(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:n}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-n.lineHeight)<2&&n.textHeight=t){if(r instanceof E)return r;if(o>t)break}n=o+r.breakAfter}return null}}class ue extends W{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,r,o){return i&&(!(i instanceof ue)||!this.widget.compare(i.widget)||e>0&&r<=0||t0}}class Wt{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var re=function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s}(re||(re={}));class F extends Se{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new tt(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new de(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=ps(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new de(e,i,n,t,e.widget||null,!0)}static line(e){return new it(e)}static set(e,t=!1){return R.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}F.none=R.empty;class tt extends F{constructor(e){let{start:t,end:i}=ps(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof tt&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&qi(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}tt.prototype.point=!1;class it extends F{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof it&&this.spec.class==e.spec.class&&qi(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)}}it.prototype.mapMode=G.TrackBefore;it.prototype.point=!0;class de extends F{constructor(e,t,i,n,r,o){super(t,i,r,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?G.TrackBefore:G.TrackAfter:G.TrackDel}get type(){return this.startSide!=this.endSide?re.WidgetRange:this.startSide<=0?re.WidgetBefore:re.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof de&&jr(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)}}de.prototype.point=!0;function ps(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function jr(s,e){return s==e||!!(s&&e&&s.compare(e))}function ci(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}class Be{constructor(e,t,i,n){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof ue&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new E),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ot(new We(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof ue)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ot(new le(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof de){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof de)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ue(i.widget||new nn("div"),l,i));else{let a=me.create(i.widget||new nn("span"),l,l?0:i.startSide),f=this.atCursorPos&&!a.isEditable&&r<=n.length&&(e0),h=!a.isEditable&&(en.length||i.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!f&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(n),f&&(c.append(ot(new We(1),n),r),r=n.length+Math.max(0,r-n.length)),c.append(ot(a,n),r),this.atCursorPos=h,this.pendingBuffer=h?en.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,n,r){let o=new Be(e,t,i,r);return o.openEnd=R.spans(n,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function ot(s,e){for(let t of e)s=new ae(t,[s],s.length);return s}class nn extends Wt{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}}var B=function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s}(B||(B={}));const Te=B.LTR,$i=B.RTL;function gs(s){let e=[];for(let t=0;t=t){if(l.level==i)return o;(r<0||(n!=0?n<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function xs(s,e){if(s.length!=e.length)return!1;for(let t=0;t=0;g-=3)if(K[g+1]==-O){let p=K[g+2],m=p&2?n:p&4?p&1?r:n:0;m&&(k[c]=k[K[g]]=m),l=g;break}}else{if(K.length==189)break;K[l++]=c,K[l++]=u,K[l++]=a}else if((d=k[c])==2||d==1){let g=d==n;a=g?0:1;for(let p=l-3;p>=0;p-=3){let m=K[p+2];if(m&2)break;if(g)K[p+2]|=2;else{if(m&4)break;K[p+2]|=4}}}}}function io(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let o=n?t[n-1].to:s,l=na;)d==p&&(d=t[--g].from,p=g?t[g-1].to:s),k[--d]=O;a=h}else r=f,a++}}}function Oi(s,e,t,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=e,f=0;aa&&o.push(new ce(a,g.from,O));let p=g.direction==Te!=!(O%2);di(s,p?i+1:i,n,g.inner,g.from,g.to,o),a=g.to}d=g.to}else{if(d==t||(h?k[d]!=l:k[d]==l))break;d++}u?Oi(s,a,d,i+1,n,u,o):ae;){let h=!0,c=!1;if(!f||a>r[f-1].to){let g=k[a-1];g!=l&&(h=!1,c=g==16)}let u=!h&&l==1?[]:null,O=h?i:i+1,d=a;e:for(;;)if(f&&d==r[f-1].to){if(c)break e;let g=r[--f];if(!h)for(let p=g.from,m=f;;){if(p==e)break e;if(m&&r[m-1].to==p)p=r[--m].from;else{if(k[p-1]==l)break e;break}}if(u)u.push(g);else{g.tok.length;)k[k.length]=256;let i=[],n=e==Te?0:1;return di(s,n,n,t,0,s.length,i),i}function Ss(s){return[new ce(0,s,0)]}let ws="";function so(s,e,t,i,n){var r;let o=i.head-s.from,l=ce.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],f=a.side(n,t);if(o==f){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),f=a.side(n,t)}let h=ie(s.text,o,a.forward(n,t));(ha.to)&&(h=f),ws=s.text.slice(Math.min(o,h),Math.max(o,h));let c=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return c&&h==f&&c.level+(n?0:1)s.some(e=>e)}),oo=b.define({combine:s=>s.some(e=>e)});class qe{constructor(e,t="nearest",i="nearest",n=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new qe(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 qe(S.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const lt=X.define({map:(s,e)=>s.map(e)});function xe(s,e,t){let i=s.facet(Ps);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const At=b.define({combine:s=>s.length?s[0]:!0});let lo=0;const Ce=b.define();class je{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new je(lo++,e,i,n,l=>{let a=[Ce.of(l)];return o&&a.push(He.of(f=>{let h=f.plugin(l);return h?o(h):F.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return je.define(i=>new e(i),t)}}class Dt{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(xe(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){xe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){xe(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const qs=b.define(),Ri=b.define(),He=b.define(),$s=b.define(),Wi=b.define(),Rs=b.define();function sn(s,e){let t=s.state.facet(Rs);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return R.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let f=r-e.from,h=o-e.from,c=n;for(let u=l.length-1;u>=0;u--,a--){let O=l[u].spec.bidiIsolate,d;if(O==null&&(O=ro(e.text,f,h)),a>0&&c.length&&(d=c[c.length-1]).to==f&&d.direction==O)d.to=h,c=d.inner;else{let g={from:f,to:h,direction:O,inner:[]};c.push(g),c=g.inner}}}}),n}const Ws=b.define();function As(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Ws)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const Me=b.define();class _{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new _(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toAh)break;r+=2}if(!a)return i;new _(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}}class vt{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=C.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new _(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new vt(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class rn extends W{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new E],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new _(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:h})=>hthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!po(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?ho(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:f,to:h}=this.hasComposition;i=new _(f,h,e.changes.mapPos(f,-1),e.changes.mapPos(h,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(x.ie||x.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=uo(o,l,e.changes);return i=_.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=x.chrome||x.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?n[o]:null;if(!l)break;let{fromA:a,toA:f,fromB:h,toB:c}=l,u,O,d,g;if(i&&i.range.fromBh){let T=Be.build(this.view.state.doc,h,i.range.fromB,this.decorations,this.dynamicDecorationMap),A=Be.build(this.view.state.doc,i.range.toB,c,this.decorations,this.dynamicDecorationMap);O=T.breakAtStart,d=T.openStart,g=A.openEnd;let z=this.compositionView(i);A.breakAtStart?z.breakAfter=1:A.content.length&&z.merge(z.length,z.length,A.content[0],!1,A.openStart,0)&&(z.breakAfter=A.content[0].breakAfter,A.content.shift()),T.content.length&&z.merge(0,0,T.content[T.content.length-1],!0,0,T.openEnd)&&T.content.pop(),u=T.content.concat(z).concat(A.content)}else({content:u,breakAtStart:O,openStart:d,openEnd:g}=Be.build(this.view.state.doc,h,c,this.decorations,this.dynamicDecorationMap));let{i:p,off:m}=r.findPos(f,1),{i:w,off:P}=r.findPos(a,-1);as(this,w,P,p,m,u,O,d,g)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new le(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new ae(n,[t],t.length);let i=new E;return i.append(t,0),i}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=W.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},i=this.childPos(e.range.fromB,1),n=this.children[i.i];t(e.line,n);for(let r=e.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],t(r>=0?e.marks[r].node:e.text,n)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&St(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),f=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(x.gecko&&l.empty&&!this.hasComposition&&ao(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=f=new Z(c,0),o=!0}let h=this.view.observer.selectionRange;(o||!h.focusNode||(!Ge(a.node,a.offset,h.anchorNode,h.anchorOffset)||!Ge(f.node,f.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,l))&&(this.view.observer.ignore(()=>{x.android&&x.chrome&&this.dom.contains(h.focusNode)&&Oo(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=Qt(this.view.root);if(c)if(l.empty){if(x.gecko){let u=fo(a.node,a.offset);if(u&&u!=3){let O=Xs(a.node,a.offset,u==1?1:-1);O&&(a=new Z(O.node,O.offset))}}c.collapse(a.node,a.offset),l.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=l.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(f.node,f.offset)}catch{}}else{let u=document.createRange();l.anchor>l.head&&([a,f]=[f,a]),u.setEnd(f.node,f.offset),u.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(u)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,f)),this.impreciseAnchor=a.precise?null:new Z(h.anchorNode,h.anchorOffset),this.impreciseHead=f.precise?null:new Z(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ge(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,i=Qt(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=E.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),f=this.coordsAt(t.head,1);if(!a||!f||a.bottom>f.top)return;let h=this.domAtPos(t.head+t.assoc);i.collapse(h.node,h.offset),i.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&&i.collapse(n,r)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let n=e.offset;!i&&n=0;n--){let r=W.get(t.childNodes[n]);r instanceof E&&(i=r.domAtPos(r.length))}return i?new Z(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=W.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=r-l.breakAfter,f=a-l.length;if(ae||l.covers(1))&&(!i||l instanceof E&&!(i instanceof E&&t>=0))&&(i=l,n=f),r=f}return i?i.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),n=this.children[t];if(!(n instanceof E))return null;for(;n.children.length;){let{i:l,off:a}=n.childPos(i,1);for(;;l++){if(l==n.children.length)return null;if((n=n.children[l]).length)break}i=a}if(!(n instanceof le))return null;let r=ie(n.text,i);if(r==i)return null;let o=we(n.dom,i,r).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==B.LTR;for(let f=0,h=0;hn)break;if(f>=i){let O=c.dom.getBoundingClientRect();if(t.push(O.height),o){let d=c.dom.lastChild,g=d?ze(d):[];if(g.length){let p=g[g.length-1],m=a?p.right-O.left:O.right-p.left;m>l&&(l=m,this.minWidth=r,this.minWidthFrom=f,this.minWidthTo=u)}}}f=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?B.RTL:B.LTR}measureTextSize(){for(let r of this.children)if(r instanceof E){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=ze(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,n=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new ls(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(F.replace({widget:new on(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return F.set(e)}updateDeco(){let e=this.view.state.facet(He).map((n,r)=>(this.dynamicDecorationMap[r]=typeof n=="function")?n(this.view):n),t=!1,i=this.view.state.facet($s).map((n,r)=>{let o=typeof n=="function";return o&&(t=!0),o?n(this.view):n});i.length&&(this.dynamicDecorationMap[e.length]=t,e.push(R.join(i)));for(let n=e.length;nt.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=As(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Lr(this.view.scrollDOM,o,t.head0)i=i.childNodes[n-1],n=oe(i);else break}if(t>=0)for(let i=s,n=e;;){if(i.nodeType==3)return{node:i,offset:n};if(i.nodeType==1&&n=0)i=i.childNodes[n],n=0;else break}return null}function fo(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}function go(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return S.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=ie(n.text,r,!1):l=ie(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let f=ie(n.text,o,!1);if(i(n.text.slice(f,o))!=a)break;o=f}for(;ls?e.left-s:Math.max(0,s-e.right)}function xo(s,e){return e.top>s?e.top-s:Math.max(0,s-e.bottom)}function Zt(s,e){return s.tope.top+1}function ln(s,e){return es.bottom?{top:s.top,left:s.left,right:s.right,bottom:e}:s}function gi(s,e,t){let i,n,r,o,l=!1,a,f,h,c;for(let d=s.firstChild;d;d=d.nextSibling){let g=ze(d);for(let p=0;pP||o==P&&r>w){i=d,n=m,r=w,o=P;let T=P?t0?p0)}w==0?t>m.bottom&&(!h||h.bottomm.top)&&(f=d,c=m):h&&Zt(h,m)?h=an(h,m.bottom):c&&Zt(c,m)&&(c=ln(c,m.top))}}if(h&&h.bottom>=t?(i=a,n=h):c&&c.top<=t&&(i=f,n=c),!i)return{node:s,offset:0};let u=Math.max(n.left,Math.min(n.right,e));if(i.nodeType==3)return hn(i,u,t);if(l&&i.contentEditable!="false")return gi(i,u,t);let O=Array.prototype.indexOf.call(s.childNodes,i)+(e>=(n.left+n.right)/2?1:0);return{node:s,offset:O}}function hn(s,e,t){let i=s.nodeValue.length,n=-1,r=1e9,o=0;for(let l=0;lt?h.top-t:t-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c=(h.left+h.right)/2,O=u;if((x.chrome||x.gecko)&&we(s,l).getBoundingClientRect().left==h.right&&(O=!u),c<=0)return{node:s,offset:l+(O?1:0)};n=l+(O?1:0),r=c}}}return{node:s,offset:n>-1?n:o>0?s.nodeValue.length:0}}function Es(s,e,t,i=-1){var n,r;let o=s.contentDOM.getBoundingClientRect(),l=o.top+s.viewState.paddingTop,a,{docHeight:f}=s.viewState,{x:h,y:c}=e,u=c-l;if(u<0)return 0;if(u>f)return s.state.doc.length;for(let T=s.viewState.heightOracle.textHeight/2,A=!1;a=s.elementAtHeight(u),a.type!=re.Text;)for(;u=i>0?a.bottom+T:a.top-T,!(u>=0&&u<=f);){if(A)return t?null:0;A=!0,i=-i}c=l+u;let O=a.from;if(Os.viewport.to)return s.viewport.to==s.state.doc.length?s.state.doc.length:t?null:fn(s,o,a,h,c);let d=s.dom.ownerDocument,g=s.root.elementFromPoint?s.root:d,p=g.elementFromPoint(h,c);p&&!s.contentDOM.contains(p)&&(p=null),p||(h=Math.max(o.left+1,Math.min(o.right-1,h)),p=g.elementFromPoint(h,c),p&&!s.contentDOM.contains(p)&&(p=null));let m,w=-1;if(p&&((n=s.docView.nearest(p))===null||n===void 0?void 0:n.isEditable)!=!1){if(d.caretPositionFromPoint){let T=d.caretPositionFromPoint(h,c);T&&({offsetNode:m,offset:w}=T)}else if(d.caretRangeFromPoint){let T=d.caretRangeFromPoint(h,c);T&&({startContainer:m,startOffset:w}=T,(!s.contentDOM.contains(m)||x.safari&&So(m,w,h)||x.chrome&&wo(m,w,h))&&(m=void 0))}}if(!m||!s.docView.dom.contains(m)){let T=E.find(s.docView,O);if(!T)return u>a.top+a.height/2?a.to:a.from;({node:m,offset:w}=gi(T.dom,h,c))}let P=s.docView.nearest(m);if(!P)return null;if(P.isWidget&&((r=P.dom)===null||r===void 0?void 0:r.nodeType)==1){let T=P.dom.getBoundingClientRect();return e.ys.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+Xr(o,r,s.state.tabSize)}function So(s,e,t){let i;if(s.nodeType!=3||e!=(i=s.nodeValue.length))return!1;for(let n=s.nextSibling;n;n=n.nextSibling)if(n.nodeType!=1||n.nodeName!="BR")return!1;return we(s,i-1,i).getBoundingClientRect().left>t}function wo(s,e,t){if(e!=0)return!1;for(let n=s;;){let r=n.parentNode;if(!r||r.nodeType!=1||r.firstChild!=n)return!1;if(r.classList.contains("cm-line"))break;n=r}let i=s.nodeType==1?s.getBoundingClientRect():we(s,0,Math.max(s.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function To(s,e){let t=s.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==re.Text))return i}return t}function bo(s,e,t,i){let n=To(s,e.head),r=!i||n.type!=re.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==B.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return S.cursor(a,t?-1:1)}return S.cursor(t?n.to:n.from,t?-1:1)}function cn(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let f=so(n,r,o,l,t),h=ws;if(!f){if(n.number==(t?s.state.doc.lines:1))return l;h=` `,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),f=s.visualLineSide(n,!t)}if(a){if(!a(h))return l}else{if(!i)return f;a=i(h)}l=f}}function yo(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==ne.Space&&(n=o),n==o}}function Po(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return S.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),f=s.coordsAtPos(n,e.assoc||-1),h=s.documentTop;if(f)o==null&&(o=f.left-a.left),l=r<0?f.top:f.bottom;else{let O=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-O.from))),l=(r<0?O.top:O.bottom)+h}let c=a.left+o,u=i??s.viewState.heightOracle.textHeight>>1;for(let O=0;;O+=10){let d=l+(u+O)*r,g=Es(s,{x:c,y:d},!1,r);if(da.bottom||(r<0?gn)){let p=s.docView.coordsForChar(g),m=!p||d{if(e>r&&en(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:S.cursor(i,inull),x.gecko&&Lo(e.contentDOM.ownerDocument)}handleEvent(e){!Vo(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=vo(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()i.keyCode==e.keyCode))&&!e.ctrlKey||ko.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,ke(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:x.safari&&!x.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function un(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){xe(t.state,n)}}}function vo(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec;if(n&&n.domEventHandlers)for(let r in n.domEventHandlers){let o=n.domEventHandlers[r];o&&t(r).handlers.push(un(i.value,o))}if(n&&n.domEventObservers)for(let r in n.domEventObservers){let o=n.domEventObservers[r];o&&t(r).observers.push(un(i.value,o))}}for(let i in j)t(i).handlers.push(j[i]);for(let i in H)t(i).observers.push(H[i]);return e}const Cs=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ko="dthko",Ms=[16,17,18,20,91,92,224,225],at=6;function ht(s){return Math.max(0,s)*.7+8}function qo(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class $o{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Gr(e.contentDOM),this.atoms=e.state.facet(Wi).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($.allowMultipleSelections)&&Ro(e,t),this.dragging=Ao(e,t)&&Ls(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&qo(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,n=0,r=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=As(this.view);e.clientX-o.left<=r.left+at?i=-ht(r.left-e.clientX):e.clientX+o.right>=r.right-at&&(i=ht(e.clientX-r.right)),e.clientY-o.top<=r.top+at?n=-ht(r.top-e.clientY):e.clientY+o.bottom>=r.bottom-at&&(n=ht(e.clientY-r.bottom)),this.setScrollSpeed(i,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;ithis.select(this.lastEvent),20)}}function Ro(s,e){let t=s.state.facet(Ts);return t.length?t[0](e):x.mac?e.metaKey:e.ctrlKey}function Wo(s,e){let t=s.state.facet(bs);return t.length?t[0](e):x.mac?!e.altKey:!e.ctrlKey}function Ao(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Qt(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Vo(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=W.get(t))&&i.ignoreEvent(e))return!1;return!0}const j=Object.create(null),H=Object.create(null),Ys=x.ie&&x.ie_version<15||x.ios&&x.webkit_version<604;function Xo(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Ds(s,t.value)},50)}function Ds(s,e){let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(mi!=null&&t.selection.ranges.every(a=>a.empty)&&mi==r.toString()){let a=-1;i=t.changeByRange(f=>{let h=t.doc.lineAt(f.from);if(h.from==a)return{range:f};a=h.from;let c=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:c},range:S.cursor(f.from+c.length)}})}else o?i=t.changeByRange(a=>{let f=r.line(n++);return{changes:{from:a.from,to:a.to,insert:f.text},range:S.cursor(a.from+f.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}H.scroll=s=>{s.inputState.lastScrollTop=s.scrollDOM.scrollTop,s.inputState.lastScrollLeft=s.scrollDOM.scrollLeft};j.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&(s.inputState.lastEscPress=Date.now()),!1);H.touchstart=(s,e)=>{s.inputState.lastTouchTime=Date.now(),s.inputState.setSelectionOrigin("select.pointer")};H.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};j.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(ys))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=Mo(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new $o(s,e,t,i)),i&&s.observer.ignore(()=>ss(s.contentDOM));let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function On(s,e,t,i){if(i==1)return S.cursor(e,t);if(i==2)return go(s.state,e,t);{let n=E.find(s.docView,e),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return ls>=e.top&&s<=e.bottom,dn=(s,e,t)=>Zs(e,t)&&s>=t.left&&s<=t.right;function Eo(s,e,t,i){let n=E.find(s.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(r==0)return 1;if(r==n.length)return-1;let o=n.coordsAt(r,-1);if(o&&dn(t,i,o))return-1;let l=n.coordsAt(r,1);return l&&dn(t,i,l)?1:o&&Zs(i,o)?-1:1}function pn(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Eo(s,t,e.clientX,e.clientY)}}const Co=x.ie&&x.ie_version<=11;let gn=null,mn=0,xn=0;function Ls(s){if(!Co)return s.detail;let e=gn,t=xn;return gn=s,xn=Date.now(),mn=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(mn+1)%3:1}function Mo(s,e){let t=pn(s,e),i=Ls(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=pn(s,r),f,h=On(s,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let c=On(s,t.pos,t.bias,i),u=Math.min(c.from,h.from),O=Math.max(c.to,h.to);h=u1&&(f=Yo(n,a.pos))?f:l?n.addRange(h):S.create([h])}}}function Yo(s,e){for(let t=0;t=e)return S.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}j.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.nearest(e.target);if(n&&n.isWidget){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=S.range(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",s.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};j.dragend=s=>(s.inputState.draggedContent=null,!1);function Sn(s,e,t,i){if(!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&Wo(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}j.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&Sn(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Sn(s,e,i,!0),!0}return!1};j.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Ys?null:e.clipboardData;return t?(Ds(s,t.getData("text/plain")||t.getData("text/uri-text")),!0):(Xo(s),!1)};function Do(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function Zo(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:e.join(s.lineBreak),ranges:t,linewise:i}}let mi=null;j.copy=j.cut=(s,e)=>{let{text:t,ranges:i,linewise:n}=Zo(s.state);if(!t&&!n)return!1;mi=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ys?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Do(s,t),!1)};const Gs=ye.define();function Bs(s,e){let t=[];for(let i of s.facet(vs)){let n=i(s,e);n&&t.push(n)}return t?s.update({effects:t,annotations:Gs.of(!0)}):null}function Is(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Bs(s.state,e);t?s.dispatch(t):s.update([])}},10)}H.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),Is(s)};H.blur=s=>{s.observer.clearSelectionRange(),Is(s)};H.compositionstart=H.compositionupdate=s=>{s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0)};H.compositionend=s=>{s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,x.chrome&&x.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50)};H.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};j.beforeinput=(s,e)=>{var t;let i;if(x.chrome&&x.android&&(i=Cs.find(n=>n.inputType==e.inputType))&&(s.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let n=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>n+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return!1};const wn=new Set;function Lo(s){wn.has(s)||(wn.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const Tn=["pre-wrap","normal","pre-line","break-spaces"];class Go{constructor(e){this.lineWrapping=e,this.doc=Q.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Tn.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let f=0;f0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Tt&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return I.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:f,fromB:h,toB:c}=n[l],u=r.lineAt(a,q.ByPosNoHeight,i.setDoc(t),0,0),O=u.to>=f?u:r.lineAt(f,q.ByPosNoHeight,i,0,0);for(c+=O.to-f,f=O.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,h=n[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n=r&&o(this.blockAt(0,i,n,r))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(e,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class U extends Fs{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,n){return new ee(n,this.length,i,this.height,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof U||n instanceof M&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof M?n=new U(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):I.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(e,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class M extends I{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let f=n+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),h=t.doc.lineAt(f),c=l+h.length*a,u=Math.max(i,e-c/2);return new ee(h.from,h.length,u,c,0)}else{let f=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:h,length:c}=t.doc.line(r+f);return new ee(h,c,i+l*f,l,0)}}lineAt(e,t,i,n,r){if(t==q.ByHeight)return this.blockAt(e,i,n,r);if(t==q.ByPosNoHeight){let{from:O,to:d}=i.doc.lineAt(e);return new ee(O,d-O,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),f=i.doc.lineAt(e),h=l+f.length*a,c=f.number-o,u=n+l*c+a*(f.from-r-c);return new ee(f.from,f.length,Math.max(n,Math.min(u,n+this.height-h)),h,0)}forEachLine(e,t,i,n,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:f}=this.heightMetrics(i,r);for(let h=e,c=n;h<=t;){let u=i.doc.lineAt(h);if(h==e){let d=u.number-l;c+=a*d+f*(e-r-d)}let O=a+f*u.length;o(new ee(u.from,u.length,c,O,0)),c+=O,h=u.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let r=i[i.length-1];r instanceof M?i[i.length-1]=new M(r.length+n):i.push(null,new M(n-1))}if(e>0){let r=i[0];r instanceof M?i[0]=new M(e+r.length):i.unshift(new M(e-1),null)}return I.of(i)}decomposeLeft(e,t){t.push(new M(e-1),null)}decomposeRight(e,t){t.push(null,new M(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new M(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++];a==-1?a=c:Math.abs(c-a)>=Tt&&(a=-2);let u=new U(h,c);u.outdated=!1,o.push(u),l+=h+1}l<=r&&o.push(null,new M(r-l).updateHeight(e,l));let f=I.of(o);return(a<0||Math.abs(f.height-this.height)>=Tt||Math.abs(a-this.heightMetrics(e,t).perLine)>=Tt)&&(e.heightChanged=!0),f}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Io extends I{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return el))return f;let h=t==q.ByPosNoHeight?q.ByPosNoHeight:q.ByPos;return a?f.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,n,r).join(f)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let f=this.lineAt(a,q.ByPos,i,n,r);e=e&&f.from<=t&&o(f),t>f.to&&this.right.forEachLine(f.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&bn(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?I.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function bn(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof M&&(i=s[e+1])instanceof M&&s.splice(e-1,3,new M(t.length+1+i.length))}const Fo=5;class Ai{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof U?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new U(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Fo)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new U(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new M(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof U)return e;let t=new U(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof U)&&!this.isCovered?this.nodes.push(new U(0,-1)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&c.overflow!="visible"){let u=h.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=f==s.parentNode?u.bottom:Math.min(a,u.bottom)}f=c.position=="absolute"||c.position=="fixed"?h.offsetParent:h.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function _o(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Gt{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Go(t),this.stateDeco=e.facet(He).filter(i=>typeof i!="function"),this.heightMap=I.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle.setDoc(e.doc),[new _(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=F.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new ft(r,o))}}this.viewports=e.sort((i,n)=>i.from-n.from),this.scaler=this.heightMap.height<=7e6?Pn:new Jo(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:Ye(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(He).filter(h=>typeof h!="function");let n=e.changedRanges,r=_.extendWithRanges(n,Uo(i,this.stateDeco,e?e.changes:C.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let f=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),f&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(oo)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?B.RTL:B.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let f=0,h=0;if(l.width&&l.height){let{scaleX:T,scaleY:A}=ns(t,l);(this.scaleX!=T||this.scaleY!=A)&&(this.scaleX=T,this.scaleY=A,f|=8,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,f|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=8);let O=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=O&&(this.scrollAnchorHeight=-1,this.scrollTop=O),this.scrolledToBottom=os(e.scrollDOM);let d=(this.printing?_o:zo)(t,this.paddingTop),g=d.top-this.pixelViewport.top,p=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,f|=8),a){let T=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(T)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:A,charWidth:z,textHeight:or}=e.docView.measureTextSize();o=A>0&&n.refresh(r,A,z,or,w/z,T),o&&(e.docView.minWidth=0,f|=8)}g>0&&p>0?h=Math.max(g,p):g<0&&p<0&&(h=Math.min(g,p)),n.heightChanged=!1;for(let A of this.viewports){let z=A.from==this.viewport.from?T:e.docView.measureVisibleLineHeights(A);this.heightMap=(o?I.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle,[new _(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Bo(A.from,z))}n.heightChanged&&(f|=2)}let P=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return P&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(f&2||P)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new ft(n.lineAt(o-i*1e3,q.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,q.ByHeight,r,0,0).to);if(t){let{head:f}=t.range;if(fa.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(f,q.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&f=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r>1,o=n<<1;if(this.defaultTextDirection!=B.LTR&&!i)return[];let l=[],a=(f,h,c,u)=>{if(h-ff&&pp.from>=c.from&&p.to<=c.to&&Math.abs(p.from-f)p.fromm));if(!g){if(hp.from<=h&&p.to>=h)){let p=t.moveToLineBoundary(S.cursor(h),!1,!0).head;p>f&&(h=p)}g=new Gt(f,h,this.gapSize(c,f,h,u))}l.push(g)};for(let f of this.viewportLines){if(f.lengthf.from&&a(f.from,u,f,h),Ot.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];R.spans(e,this.viewport.from,this.viewport.to,{span(n,r){t.push({from:n,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((n,r)=>n.from!=t[r].from||n.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Ye(this.heightMap.lineAt(e,q.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return Ye(this.heightMap.lineAt(this.scaler.fromDOM(e),q.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Ye(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ft{constructor(e,t){this.from=e,this.to=t}}function Ho(s,e,t){let i=[],n=s,r=0;return R.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function ut(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function Ko(s,e){for(let t of s)if(e(t))return t}const Pn={toDOM(s){return s},fromDOM(s){return s},scale:1};class Jo{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let f=t.lineAt(l,q.ByPos,e,0,0).top,h=t.lineAt(a,q.ByPos,e,0,0).bottom;return n+=h-f,{from:l,to:a,top:f,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=tYe(n,e)):s._content)}const Ot=b.define({combine:s=>s.join(" ")}),xi=b.define({combine:s=>s.indexOf(!0)>-1}),Si=Re.newName(),Us=Re.newName(),Ns=Re.newName(),zs={"&light":"."+Us,"&dark":"."+Ns};function wi(s,e,t){return new Re(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}const el=wi("."+Si,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},zs),De="￿";class tl{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet($.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=De}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let o=n.nextSibling;if(o==t)break;let l=W.get(n),a=W.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:Qn(n))||Qn(o)&&(n.nodeName!="BR"||n.cmIgnore)&&this.text.length>r)&&this.lineBreak(),n=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=W.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(il(e,i.node,i.offset)?t:0))}}function il(s,e,t){for(;;){if(!e||t-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:ol(e),a=new tl(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=ll(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!ri(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),f=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!ri(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),h=e.viewport;if(x.ios&&e.state.selection.main.empty&&a!=f&&(h.from>0||h.toDate.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=n.from,f=null;(r===8||x.android&&e.text.length=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,t.from).append(t.insert).append(s.state.doc.slice(t.to,n.to))}:(x.mac||x.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=S.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:Q.of([" "])}):x.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==` `&&s.lineWrapping&&(i&&(i=S.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:Q.of([" "])}),t){if(x.ios&&s.inputState.flushIOSKey()||x.android&&(t.from==n.from&&t.to==n.to&&t.insert.length==1&&t.insert.lines==2&&ke(s.contentDOM,"Enter",13)||(t.from==n.from-1&&t.to==n.to&&t.insert.length==0||r==8&&t.insert.lengthn.head)&&ke(s.contentDOM,"Backspace",8)||t.from==n.from&&t.to==n.to+1&&t.insert.length==0&&ke(s.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let l,a=()=>l||(l=sl(s,t,i));return s.state.facet(Qs).some(f=>f(s,t.from,t.to,o,a))||s.dispatch(a()),!0}else if(i&&!i.main.eq(n)){let o=!1,l="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(o=!0),l=s.inputState.lastSelectionOrigin),s.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function sl(s,e,t){let i,n=s.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let l=r.frome.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(l+e.insert.sliceString(0,void 0,s.state.lineBreak)+a))}else{let l=n.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(n.selection.ranges.length>1&&s.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let f=s.state.sliceDoc(e.from,e.to),h,c=t&&Vs(s,t.main.head);if(c){let d=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-d}}else h=s.state.doc.lineAt(r.head);let u=r.to-e.to,O=r.to-r.from;i=n.changeByRange(d=>{if(d.from==r.from&&d.to==r.to)return{changes:l,range:a||d.map(l)};let g=d.to-u,p=g-f.length;if(d.to-d.from!=O||s.state.sliceDoc(p,g)!=f||d.to>=h.from&&d.from<=h.to)return{range:d};let m=n.changes({from:p,to:g,insert:e.insert}),w=d.to-r.to;return{changes:m,range:a?S.range(Math.max(0,a.anchor+w),Math.max(0,a.head+w)):d.map(m)}})}else i={changes:l,selection:a&&n.selection.replaceRange(a)}}let o="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,o+=".compose",s.inputState.compositionFirstChange&&(o+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:o,scrollIntoView:!0})}function rl(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function ol(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new vn(t,i)),(n!=t||r!=i)&&e.push(new vn(n,r))),e}function ll(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?S.single(t+e,i+e):null}const al={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Bt=x.ie&&x.ie_version<=11;class hl{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Br,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(x.ie&&x.ie_version<=11||x.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Bt&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(At)?i.root.activeElement!=this.dom:!St(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(x.ie&&x.ie_version<=11||x.android&&x.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Ge(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=x.safari&&e.root.nodeType==11&&Dr(this.dom.ownerDocument)==this.dom&&fl(this.view)||Qt(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=St(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ke(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&St(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new nl(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=_s(this.view,t);return this.view.state==i&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=kn(t,e.previousSibling||e.target.previousSibling,-1),n=kn(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function kn(s,e,t){for(;e;){let i=W.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function fl(s){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(s.contentDOM.addEventListener("beforeinput",t,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,n=e.startOffset,r=e.endContainer,o=e.endOffset,l=s.docView.domAtPos(s.state.selection.main.anchor);return Ge(l.node,l.offset,r,o)&&([i,n,r,o]=[r,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:o}}class v{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(n=>t(n,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Ir(e.parent)||document,this.viewState=new yn(e.state||$.create(e)),e.scrollTo&&e.scrollTo.is(lt)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ce).map(i=>new Dt(i));for(let i of this.plugins)i.update(this);this.observer=new hl(this),this.inputState=new Qo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new rn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof L?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,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(Gs))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Bs(r,o),a||(l=1));let f=this.observer.delayedAndroidKey,h=null;if(f?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet($.phrases)!=this.state.facet($.phrases))return this.setState(r);n=vt.create(this,r,e),n.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:O}=u.state.selection;c=new qe(O.empty?O:S.cursor(O.head,O.head>O.anchor?-1:1))}for(let O of u.effects)O.is(lt)&&(c=O.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=kt.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(Me)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Ot)!=n.state.facet(Ot)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!n.empty)for(let u of this.state.facet(pi))try{u(n)}catch(O){xe(this.state,O,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!_s(this,h)&&f.force&&ke(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new yn(e),this.plugins=e.facet(Ce).map(i=>new Dt(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new rn(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(Ce),i=e.state.facet(Ce);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new Dt(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(os(i))r=-1,o=this.viewState.heightMap.height;else{let O=this.viewState.scrollAnchorAt(n);r=O.from,o=O.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];a&4||([this.measureRequests,f]=[f,this.measureRequests]);let h=f.map(O=>{try{return O.read(this)}catch(d){return xe(this.state,d),qn}}),c=vt.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));for(let O=0;O1||d<-1){n=n+d,i.scrollTop=n/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(pi))l(t)}get themeClasses(){return Si+" "+(this.state.facet(xi)?Ns:Us)+" "+this.state.facet(Ot)}updateAttrs(){let e=$n(this,qs,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(At)?"true":"false",class:"cm-content",style:`${x.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$n(this,Ri,t);let i=this.observer.ignore(()=>{let n=fi(this.contentDOM,this.contentAttrs,t),r=fi(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(v.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(Me);let e=this.state.facet(v.cspNonce);Re.mount(this.root,this.styleModules.concat(el).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;ti.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Lt(this,e,cn(this,e,t,i))}moveByGroup(e,t){return Lt(this,e,cn(this,e,t,i=>yo(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return S.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return bo(this,e,t,i)}moveVertically(e,t,i){return Lt(this,e,Po(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Es(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),o=r[ce.find(r,e-n.from,-1,t)];return vi(i,o.dir==B.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(ks)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>cl)return Ss(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||xs(r.isolates,i=sn(this,e))))return r.order;i||(i=sn(this,e));let n=no(e.text,t,i);return this.bidiCache.push(new kt(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||x.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ss(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return lt.of(new qe(typeof e=="number"?S.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return lt.of(new qe(S.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return je.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return je.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Re.newName(),n=[Ot.of(i),Me.of(wi(`.${i}`,e))];return t&&t.dark&&n.push(xi.of(!0)),n}static baseTheme(e){return Pi.lowest(Me.of(wi("."+Si,e,zs)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&W.get(i)||W.get(e);return((t=n==null?void 0:n.rootView)===null||t===void 0?void 0:t.view)||null}}v.styleModule=Me;v.inputHandler=Qs;v.focusChangeEffect=vs;v.perLineTextDirection=ks;v.exceptionSink=Ps;v.updateListener=pi;v.editable=At;v.mouseSelectionStyle=ys;v.dragMovesSelection=bs;v.clickAddsSelectionRange=Ts;v.decorations=He;v.outerDecorations=$s;v.atomicRanges=Wi;v.bidiIsolatedRanges=Rs;v.scrollMargins=Ws;v.darkTheme=xi;v.cspNonce=b.define({combine:s=>s.length?s[0]:""});v.contentAttributes=Ri;v.editorAttributes=qs;v.lineWrapping=v.contentAttributes.of({class:"cm-lineWrapping"});v.announce=X.define();const cl=4096,qn={};class kt{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:B.LTR;for(let r=Math.max(0,e.length-10);r=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&hi(o,t)}return t}const ul=x.mac?"mac":x.windows?"win":x.linux?"linux":"key";function Ol(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;ai.concat(n),[]))),t}let he=null;const gl=4e3;function ml(s,e=ul){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,f,h)=>{var c,u;let O=t[o]||(t[o]=Object.create(null)),d=l.split(/ (?!$)/).map(m=>Ol(m,e));for(let m=1;m{let T=he={view:P,prefix:w,scope:o};return setTimeout(()=>{he==T&&(he=null)},gl),!0}]})}let g=d.join(" ");n(g,!1);let p=O[g]||(O[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=O._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&p.run.push(a),f&&(p.preventDefault=!0),h&&(p.stopPropagation=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of l){let h=t[f]||(t[f]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let c in h)h[c].run.push(o.any)}let a=o[e]||o.key;if(a)for(let f of l)r(f,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(f,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function xl(s,e,t,i){let n=Yr(e),r=mt(n,0),o=Ut(r)==n.length&&n!=" ",l="",a=!1,f=!1,h=!1;he&&he.view==t&&he.scope==i&&(l=he.prefix+" ",Ms.indexOf(e.keyCode)<0&&(f=!0,he=null));let c=new Set,u=p=>{if(p){for(let m of p.run)if(!c.has(m)&&(c.add(m),m(t,e)))return p.stopPropagation&&(h=!0),!0;p.preventDefault&&(p.stopPropagation&&(h=!0),f=!0)}return!1},O=s[i],d,g;return O&&(u(O[l+dt(n,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(x.windows&&e.ctrlKey&&e.altKey)&&(d=Oe[e.keyCode])&&d!=n?(u(O[l+dt(d,e,!0)])||e.shiftKey&&(g=Ne[e.keyCode])!=n&&g!=d&&u(O[l+dt(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(O[l+dt(n,e,!0)])&&(a=!0),!a&&u(O._any)&&(a=!0)),f&&(a=!0),a&&h&&e.stopPropagation(),a}const Sl=!x.ios,Wn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Sl&&(Wn[".cm-line"].caretColor="transparent !important",Wn[".cm-content"]={caretColor:"transparent !important"});class Ae extends Se{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ae.prototype.elementClass="";Ae.prototype.toDOM=void 0;Ae.prototype.mapMode=G.TrackBefore;Ae.prototype.startSide=Ae.prototype.endSide=-1;Ae.prototype.point=!0;const wl=1,Hs=196,Ks=197,Tl=198,An=199,bl=200,yl=201,Pl=202,Ql=2,vl=203,kl=204,ql=3,$l=205,Rl=206,Wl=4,Al=207,Vl=208,Xl=5,El=209,Cl=26,Ml=27,Yl=51,Dl=52,Zl=57,Ll=58,Gl=59,Bl=61,Il=62,Fl=63,Ul=64,Nl=65,zl=67,_l=246,jl=74,Hl=265,Kl=129,Jl=150,ea=151,ta=154,Ke=10,Je=13,Vi=32,Vt=9,Xi=35,ia=40,na=46,Vn=123,Js=39,er=34,sa=new Set([Ml,Yl,Dl,Hl,zl,Kl,Ll,Gl,_l,Ul,Nl,jl,Il,Fl,Jl,ea,ta]);function It(s){return s==Ke||s==Je}const ra=new qt((s,e)=>{if(s.next<0)s.acceptToken(yl);else if(e.context.depth<0)It(s.next)&&s.acceptToken(bl,1);else if(It(s.peek(-1))&&e.canShift(An)){let t=0;for(;s.next==Vi||s.next==Vt;)s.advance(),t++;(s.next==Ke||s.next==Je||s.next==Xi)&&s.acceptToken(An,-t)}else It(s.next)&&s.acceptToken(Tl,1)},{contextual:!0}),oa=new qt((s,e)=>{let t=e.context.depth;if(t<0)return;let i=s.peek(-1);if(i==Ke||i==Je){let n=0,r=0;for(;;){if(s.next==Vi)n++;else if(s.next==Vt)n+=8-n%8;else break;s.advance(),r++}n!=t&&s.next!=Ke&&s.next!=Je&&s.next!=Xi&&(n{for(let e=0;e<5;e++){if(s.next!="print".charCodeAt(e))return;s.advance()}if(!/\w/.test(String.fromCharCode(s.next)))for(let e=0;;e++){let t=s.peek(e);if(!(t==Vi||t==Vt)){t!=ia&&t!=na&&t!=Ke&&t!=Je&&t!=Xi&&s.acceptToken(wl);return}}});function Xt(s,e,t,i,n){return new qt(r=>{let o=r.pos;for(;!(r.next<0);)if(r.next==Vn)if(r.peek(1)==Vn)r.advance(2);else{if(r.pos==o){r.acceptToken(i,1);return}break}else if(r.next=="\\")r.advance(),r.next>=0&&r.advance();else if(r.next==s&&(e==1||r.peek(1)==s&&r.peek(2)==s)){if(r.pos==o){r.acceptToken(n,e);return}break}else r.advance();r.pos>o&&r.acceptToken(t)})}const ca=Xt(Js,1,Pl,Ql,vl),ua=Xt(er,1,kl,ql,$l),Oa=Xt(Js,3,Rl,Wl,Al),da=Xt(er,3,Vl,Xl,El),pa=ar({'async "*" "**" FormatConversion FormatSpec':y.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":y.controlKeyword,"in not and or is del":y.operatorKeyword,"from def class global nonlocal lambda":y.definitionKeyword,import:y.moduleKeyword,"with as print":y.keyword,Boolean:y.bool,None:y.null,VariableName:y.variableName,"CallExpression/VariableName":y.function(y.variableName),"FunctionDefinition/VariableName":y.function(y.definition(y.variableName)),"ClassDefinition/VariableName":y.definition(y.className),PropertyName:y.propertyName,"CallExpression/MemberExpression/PropertyName":y.function(y.propertyName),Comment:y.lineComment,Number:y.number,String:y.string,FormatString:y.special(y.string),UpdateOp:y.updateOperator,"ArithOp!":y.arithmeticOperator,BitOp:y.bitwiseOperator,CompareOp:y.compareOperator,AssignOp:y.definitionOperator,Ellipsis:y.punctuation,At:y.meta,"( )":y.paren,"[ ]":y.squareBracket,"{ }":y.brace,".":y.derefOperator,", ;":y.separator}),ga={__proto__:null,await:48,or:58,and:60,in:64,not:66,is:68,if:74,else:76,lambda:80,yield:98,from:100,async:106,for:108,None:168,True:170,False:170,del:184,pass:188,break:192,continue:196,return:200,raise:208,import:212,as:214,global:218,nonlocal:220,assert:224,elif:234,while:238,try:244,except:246,finally:248,with:252,def:256,class:266,match:277,case:283},ma=hr.deserialize({version:14,states:"#!OO`Q#yOOP$_OSOOO%hQ&nO'#H^OOQS'#Cq'#CqOOQS'#Cr'#CrO'WQ#xO'#CpO(yQ&nO'#H]OOQS'#H^'#H^OOQS'#DW'#DWOOQS'#H]'#H]O)gQ#xO'#DaO)zQ#xO'#DhO*[Q#xO'#DlOOQS'#Dw'#DwO*oO,UO'#DwO*wO7[O'#DwO+POWO'#DxO+[O`O'#DxO+gOpO'#DxO+rO!bO'#DxO-tQ&nO'#G}OOQS'#G}'#G}O'WQ#xO'#G|O/WQ&nO'#G|OOQS'#Ee'#EeO/oQ#xO'#EfOOQS'#G{'#G{O/yQ#xO'#GzOOQV'#Gz'#GzO0UQ#xO'#FXOOQS'#G`'#G`O0ZQ#xO'#FWOOQV'#IS'#ISOOQV'#Gy'#GyOOQV'#Fp'#FpQ`Q#yOOO'WQ#xO'#CsO0iQ#xO'#DPO0pQ#xO'#DTO1OQ#xO'#HbO1`Q&nO'#EYO'WQ#xO'#EZOOQS'#E]'#E]OOQS'#E_'#E_OOQS'#Ea'#EaO1tQ#xO'#EcO2[Q#xO'#EgO0UQ#xO'#EiO2oQ&nO'#EiO0UQ#xO'#ElO/oQ#xO'#EoO/oQ#xO'#EsO/oQ#xO'#EvO2zQ#xO'#ExO3RQ#xO'#E}O3^Q#xO'#EyO/oQ#xO'#E}O0UQ#xO'#FPO0UQ#xO'#FUO3cQ#xO'#FZP3jO#xO'#GxPOOO)CBl)CBlOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Ck'#CkOOQS'#Cl'#ClOOQS'#Cn'#CnO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO3uQ#xO'#DqOOQS,5:[,5:[O4YQ#xO'#HlOOQS,5:_,5:_O4gQMlO,5:_O4lQ&nO,59[O0iQ#xO,59dO0iQ#xO,59dO0iQ#xO,59dO7[Q#xO,59dO7aQ#xO,59dO7hQ#xO,59lO7oQ#xO'#H]O8uQ#xO'#H[OOQS'#H['#H[OOQS'#D^'#D^O9^Q#xO,59cO'WQ#xO,59cO9lQ#xO,59cOOQS,59{,59{O9qQ#xO,5:TO'WQ#xO,5:TOOQS,5:S,5:SO:PQ#xO,5:SO:UQ#xO,5:ZO'WQ#xO,5:ZO'WQ#xO,5:XOOQS,5:W,5:WO:gQ#xO,5:WO:lQ#xO,5:YOOOO'#Fx'#FxO:qO,UO,5:cOOQS,5:c,5:cOOOO'#Fy'#FyO:yO7[O,5:cO;RQ#xO'#DyOOOW'#Fz'#FzO;cOWO,5:dOOQS,5:d,5:dO;RQ#xO'#D}OOO`'#F}'#F}O;nO`O,5:dO;RQ#xO'#EOOOOp'#GO'#GOO;yOpO,5:dO;RQ#xO'#EPOOO!b'#GP'#GPOWOOQS'#Du'#DuOOQS1G/y1G/yOOQS1G/O1G/OO!-ZQ&nO1G/OO!-bQ&nO1G/OO0iQ#xO1G/OO!-}Q#xO1G/WOOQS'#D]'#D]O/oQ#xO,59vOOQS1G.}1G.}O!.UQ#xO1G/gO!.fQ#xO1G/gO!.nQ#xO1G/hO'WQ#xO'#HdO!.sQ#xO'#HdO!.xQ&nO1G.}O!/YQ#xO,59kO!0`Q#xO,5>SO!0pQ#xO,5>SO!0xQ#xO1G/oO!0}Q&nO1G/oOOQS1G/n1G/nO!1_Q#xO,5=}O!2UQ#xO,5=}O/oQ#xO1G/sO!2sQ#xO1G/uO!2xQ&nO1G/uO!3YQ&nO1G/sOOQS1G/r1G/rOOQS1G/t1G/tOOOO-E9v-E9vOOQS1G/}1G/}OOOO-E9w-E9wO!3jQ#xO'#HwO/oQ#xO'#HwO!3xQ#xO,5:eOOOW-E9x-E9xOOQS1G0O1G0OO!4TQ#xO,5:iOOO`-E9{-E9{O!4`Q#xO,5:jOOOp-E9|-E9|O!4kQ#xO,5:kOOO!b-E9}-E9}OOQS-E:O-E:OO!4vQ!LUO1G3SO!5gQ&nO1G3SO'WQ#xO,5jOOQS1G1_1G1_O!6gQ#xO1G1_OOQS'#DX'#DXO/oQ#xO,5=yOOQS,5=y,5=yO!6lQ#xO'#FqO!6wQ#xO,59qO!7PQ#xO1G/ZO!7ZQ&nO,5=}OOQS1G3h1G3hOOQS,5:p,5:pO!7zQ#xO'#G|OOQS,5PO!8{Q#xO,5>PO/oQ#xO1G0mO/oQ#xO1G0mO0UQ#xO1G0oOOQS-E:T-E:TO!9^Q#xO1G0oO!9iQ#xO1G0oO!9nQ#xO,5>mO!9|Q#xO,5>mO!:[Q#xO,5>iO!:rQ#xO,5>iO!;TQ#{O1G0yO!>cQ#{O1G0|O!AnQ#xO,5>oO!AxQ#xO,5>oO!BQQ&nO,5>oO/oQ#xO1G1OO!B[Q#xO1G1OO3^Q#xO1G1TO! RQ#xO1G1VOOQV,5;`,5;`O!BaQ#zO,5;`O!BfQ#{O1G1PO!EwQ#xO'#G]O3^Q#xO1G1PO3^Q#xO1G1PO!FUQ#xO,5>pO!FcQ#xO,5>pO0UQ#xO,5>pOOQV1G1T1G1TO!FkQ#xO'#FRO!F|QMlO1G1VOOQV1G1[1G1[O3^Q#xO1G1[O!GUQ#xO'#F]OOQV1G1a1G1aO! `Q&nO1G1aPOOO1G3O1G3OP!GZOSO1G3OOOQS,5>V,5>VOOQS'#Dr'#DrO/oQ#xO,5>VO!G`Q#xO,5>UO!GsQ#xO,5>UOOQS1G/w1G/wO!G{Q#xO,5>XO!H]Q#xO,5>XO!HeQ#xO,5>XO!HxQ#xO,5>XO!IYQ#xO,5>XOOQS1G3r1G3rOOQS7+$j7+$jO!7PQ#xO7+$rO!J{Q#xO1G/OO!KSQ#xO1G/OOOQS1G/b1G/bOOQS,5<_,5<_O'WQ#xO,5<_OOQS7+%R7+%RO!KZQ#xO7+%ROOQS-E9q-E9qOOQS7+%S7+%SO!KkQ#xO,5>OO'WQ#xO,5>OOOQS7+$i7+$iO!KpQ#xO7+%RO!KxQ#xO7+%SO!K}Q#xO1G3nOOQS7+%Z7+%ZO!L_Q#xO1G3nO!LgQ#xO7+%ZOOQS,5<^,5<^O'WQ#xO,5<^O!LlQ#xO1G3iOOQS-E9p-E9pO!McQ#xO7+%_OOQS7+%a7+%aO!MqQ#xO1G3iO!N`Q#xO7+%aO!NeQ#xO1G3oO!NuQ#xO1G3oO!N}Q#xO7+%_O# SQ#xO,5>cO# jQ#xO,5>cO# jQ#xO,5>cO# xO$ISO'#D{O#!TO#tO'#HxOOOW1G0P1G0PO#!YQ#xO1G0POOO`1G0T1G0TO#!bQ#xO1G0TOOOp1G0U1G0UO#!jQ#xO1G0UOOO!b1G0V1G0VO#!rQ#xO1G0VO#!zQ!LUO7+(nO##kQ&nO1G2XP#$UQ#xO'#GROOQS,5d,5>dOOOW7+%k7+%kOOO`7+%o7+%oOOOp7+%p7+%pOOO!b7+%q7+%qO#7{Q#xO1G3SO#8fQ#xO1G3SP'WQ#xO'#FtO/oQ#xO<lO#9YQ#xO,5>lO0UQ#xO,5>lO#9kQ#xO,5>kOOQS<rO#AdQ#xO,5>rOOQS,5>r,5>rO#AoQ#xO,5>qO#BQQ#xO,5>qOOQS1G1X1G1XOOQS,5;o,5;oO#BYQ#xO1G1cP#B_Q#xO'#FvO#BoQ#xO1G1}O#CSQ#xO1G1}O#CdQ#xO1G1}P#CoQ#xO'#FwO#C|Q#xO7+)_O#D^Q#xO7+)_O#D^Q#xO7+)_O#DfQ#xO7+)_O#DvQ#xO7+)UO7hQ#xO7+)UOOQSAN>XAN>XO#EaQ#xO<eAN>eO/oQ#xO1G1{O#EqQ&nO1G1{P#E{Q#xO'#FuOOQS1G2R1G2RP#FYQ#xO'#F{O#FgQ#xO7+)iO#F}Q#xO,5:hOOOO-E9z-E9zO#GYQ#xO7+(nOOQSAN?_AN?_O#GsQ#xO,5QOOQSANB[ANB[OOOO7+%n7+%nOOQS7+'x7+'xO$'{Q#xO<tO$*qQ#xO,5>tO0UQ#xO,5vO#MRQ#xO,5>vOOQS1G1o1G1oO$.iQ&nO,5wO$.wQ#xO,5>wOOQS1G1r1G1rOOQS7+'R7+'RP#MRQ#xO'#GfO$/PQ#xO1G4bO$/ZQ#xO1G4bO$/cQ#xO1G4bOOQS7+%V7+%VO$/qQ#xO1G1sO$0PQ&nO'#F`O$0WQ#xO,5=POOQS,5=P,5=PO$0fQ#xO1G4cOOQS-E:c-E:cO#MRQ#xO,5=OO$0mQ#xO,5=OO$0rQ#xO7+)|OOQS-E:b-E:bO$0|Q#xO7+)|O#MRQ#xO,5e>hPP'Z'ZPP?QPP'Z'ZPP'Z'Z'Z'Z'Z?U?{'ZP@OP@UD]GyPG}HZH_HcHg'ZPPPHkHq'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RPHwPIOIUPIOPIOIOPPPIOPKTPK^KdKjKTPIOKpPIOPKwK}PLRLgMUMoLRLRMuNSLRLRLRLRNhNnNqNvNy! T! Z! g! y!!P!!Z!!a!!}!#T!#Z!#a!#k!#q!#w!#}!$T!$Z!$m!$w!$}!%T!%Z!%e!%k!%q!%w!&R!&X!&c!&i!&r!&x!'X!'a!'k!'rPPPPPPPPPPPPPPPPP!'x!'{!(R!([!(f!(qPPPPPPPPPPPP!-e!.y!2s!6TPP!6]!6o!6x!7n!7e!7w!7}!8Q!8T!8W!8`!9PPPPPPPPPP!9S!9cPPPP!:R!:_!:k!:q!:z!:}!;T!;Z!;a!;dP!;l!;u!x|}#@S}!O#AW!O!P#Ci!P!Q#N_!Q!R$!y!R![$&w![!]$1e!]!^$3s!^!_$4w!_!`$7c!`!a$8m!a!b%T!b!c$;U!c!d$W!e!h$W#V#Y$Q<%lO$Xc&m!b&eS&hW%k!TOX%TXY=|Y[%T[]=|]p%Tpq=|qr%Trs&Vsw%Twx/Xx#O%T#O#P?d#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#s?i[&m!bOY%TYZ=|Z]%T]^=|^#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=P;=`<%l8^<%lO%T!q@hd&m!b&eS&hWOr%Trs&Vsw%Twx/Xx!_%T!_!`Av!`#O%T#O#P7o#P#T%T#T#UBz#U#f%T#f#gBz#g#hBz#h#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T!qBR]oR&m!b&eS&hWOr%Trs&Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T!qCV]!nR&m!b&eS&hWOr%Trs&Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#cDXa&m!b&eS&csOYE^YZ%TZ]E^]^%T^rE^rs!)|swE^wxGpx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cEia&m!b&eS&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxGpx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cFw]&m!b&eS&csOr%Trs'Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#cGya&m!b&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxIOx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cIXa&m!b&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxJ^x#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#_Jg_&m!b&hW&csOYJ^YZ1XZ]J^]^1X^rJ^rsKfs#OJ^#O#PL`#P#oJ^#o#pL}#p#qJ^#q#rL}#r;'SJ^;'S;=`!!o<%lOJ^#_KmZ&m!b&csOr1Xrs2ys#O1X#O#P3q#P#o1X#o#p4`#p#q1X#q#r4`#r;'S1X;'S;=`7i<%lO1X#_LeW&m!bO#oJ^#o#pL}#p#qJ^#q#rL}#r;'SJ^;'S;=`! r;=`<%lL}<%lOJ^{MUZ&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l<%lOL}{M|V&csOr4`rs5ds#O4`#O#P5y#P;'S4`;'S;=`6t<%lO4`{NfRO;'SL};'S;=`No;=`OL}{Nv[&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l;=`<%lL}<%lOL}{! oP;=`<%lL}#_! y[&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l;=`<%lJ^<%lOL}#_!!rP;=`<%lJ^#c!!zW&m!bO#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!(q;=`<%l!#d<%lOE^!P!#m]&eS&hW&csOY!#dYZ8^Z]!#d]^8^^r!#drs!$fsw!#dwx!%Yx#O!#d#O#P!'Y#P;'S!#d;'S;=`!(k<%lO!#d!P!$mX&eS&csOr8^rs9rsw8^wx:dx#O8^#O#P;v#P;'S8^;'S;=`^s#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!>e_U!T&m!bOY!=UYZ1XZ]!=U]^1X^r!=Urs!?ds#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!?k_U!T&m!bOY!=UYZ1XZ]!=U]^1X^r!=Urs!3`s#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!@q[U!T&m!bOY!=UYZ1XZ]!=U]^1X^#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!Ec;=`<%l4`<%lO!=U!]!AnZU!T&hWOY!AgYZ4`Z]!Ag]^4`^r!Agrs!Bas#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!BfZU!TOY!AgYZ4`Z]!Ag]^4`^r!Agrs!CXs#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!C^ZU!TOY!AgYZ4`Z]!Ag]^4`^r!Agrs!4Ys#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!DUWU!TOY!AgYZ4`Z]!Ag]^4`^;'S!Ag;'S;=`!Dn;=`<%l4`<%lO!Ag!]!DsW&hWOr4`rs4zs#O4`#O#P5y#P;'S4`;'S;=`6t;=`<%l!Ag<%lO4`!]!E`P;=`<%l!Ag#o!EhW&hWOr4`rs4zs#O4`#O#P5y#P;'S4`;'S;=`6t;=`<%l!=U<%lO4`#o!FTP;=`<%l!=U#s!F_[U!T&m!bOY!+|YZ%TZ]!+|]^%T^#o!+|#o#p!GT#p#q!+|#q#r!GT#r;'S!+|;'S;=`!Mq;=`<%l8^<%lO!+|!a!G^]U!T&eS&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!H^]U!T&eSOY!GTYZ8^Z]!GT]^8^^r!GTrs!IVsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!I^]U!T&eSOY!GTYZ8^Z]!GT]^8^^r!GTrs!5wsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!J^]U!T&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!KVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!K^]U!T&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!Agx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!L[WU!TOY!GTYZ8^Z]!GT]^8^^;'S!GT;'S;=`!Lt;=`<%l8^<%lO!GT!a!L{Y&eS&hWOr8^rs9Qsw8^wx:dx#O8^#O#P;v#P;'S8^;'S;=`Q<%lO$TP;=`<%l$ei&m!b&eS&hW&b`%}sOr%Trs$@Ssw%Twx$C`x!Q%T!Q![$Q<%lO$Q<%lO$Q<%lO$Q<%lO$Q<%lO$ga[s]||-1}],tokenPrec:7205});function Xn(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function xa(s){let e=Object.create(null),t=Object.create(null);for(let{label:n}of s){e[n[0]]=!0;for(let r=1;rtypeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:xa(e);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:e,validFor:t}:null}}function wa(s,e){return t=>{for(let i=Dn(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(s.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}const Ta=ye.define(),ba=v.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class ya{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class Ei{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,G.TrackDel),i=e.mapPos(this.to,1,G.TrackDel);return t==null||i==null?null:new Ei(this.field,t,i)}}class Ci{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let f=o,h=/^\t*/.exec(a)[0].length;for(let c=0;cnew Ei(a.field,n[a.line]+a.from,n[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],n=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",f=-1;for(let h=0;h=f&&c.field++}n.push(new ya(f,i.length,r.index,r.index+a.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}for(let l;l=/\\([{}])/.exec(o);){o=o.slice(0,l.index)+l[1]+o.slice(l.index+l[0].length);for(let a of n)a.line==i.length&&a.from>l.index&&(a.from--,a.to--)}i.push(o)}return new Ci(i,n)}}let Pa=F.widget({widget:new class extends Wt{toDOM(){let s=document.createElement("span");return s.className="cm-snippetFieldPosition",s}ignoreEvent(){return!1}}}),Qa=F.mark({class:"cm-snippetField"});class Ve{constructor(e,t){this.ranges=e,this.active=t,this.deco=F.set(e.map(i=>(i.from==i.to?Pa:Qa).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new Ve(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const nt=X.define({map(s,e){return s&&s.map(e)}}),va=X.define(),et=be.define({create(){return null},update(s,e){for(let t of e.effects){if(t.is(nt))return t.value;if(t.is(va)&&s)return new Ve(s.ranges,t.value)}return s&&e.docChanged&&(s=s.map(e.changes)),s&&e.selection&&!s.selectionInsideField(e.selection)&&(s=null),s},provide:s=>v.decorations.from(s,e=>e?e.deco:F.none)});function Mi(s,e){return S.create(s.filter(t=>t.field==e).map(t=>S.range(t.from,t.to)))}function ka(s){let e=Ci.parse(s);return(t,i,n,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,n),a={changes:{from:n,to:r,insert:Q.of(o)},scrollIntoView:!0,annotations:i?Ta.of(i):void 0};if(l.length&&(a.selection=Mi(l,0)),l.length>1){let f=new Ve(l,0),h=a.effects=[nt.of(f)];t.state.field(et,!1)===void 0&&h.push(X.appendConfig.of([et,Aa,Va,ba]))}t.dispatch(t.state.update(a))}}function tr(s){return({state:e,dispatch:t})=>{let i=e.field(et,!1);if(!i||s<0&&i.active==0)return!1;let n=i.active+s,r=s>0&&!i.ranges.some(o=>o.field==n+s);return t(e.update({selection:Mi(i.ranges,n),effects:nt.of(r?null:new Ve(i.ranges,n))})),!0}}const qa=({state:s,dispatch:e})=>s.field(et,!1)?(e(s.update({effects:nt.of(null)})),!0):!1,$a=tr(1),Ra=tr(-1),Wa=[{key:"Tab",run:$a,shift:Ra},{key:"Escape",run:qa}],En=b.define({combine(s){return s.length?s[0]:Wa}}),Aa=Pi.highest(js.compute([En],s=>s.facet(En)));function te(s,e){return Object.assign(Object.assign({},e),{apply:ka(s)})}const Va=v.domEventHandlers({mousedown(s,e){let t=e.state.field(et,!1),i;if(!t||(i=e.posAtCoords({x:s.clientX,y:s.clientY}))==null)return!1;let n=t.ranges.find(r=>r.from<=i&&r.to>=i);return!n||n.field==t.active?!1:(e.dispatch({selection:Mi(t.ranges,n.field),effects:nt.of(t.ranges.some(r=>r.field>n.field)?new Ve(t.ranges,n.field):null)}),!0)}}),ir=new class extends Se{};ir.startSide=1;ir.endSide=-1;const Cn=new mr,nr=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function pt(s){return(e,t,i)=>{if(i)return!1;let n=e.node.getChild("VariableName");return n&&t(n,s),!0}}const Xa={FunctionDefinition:pt("function"),ClassDefinition:pt("class"),ForStatement(s,e,t){if(t){for(let i=s.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")e(i,"variable");else if(i.name=="in")break}},ImportStatement(s,e){var t,i;let{node:n}=s,r=((t=n.firstChild)===null||t===void 0?void 0:t.name)=="from";for(let o=n.getChild("import");o;o=o.nextSibling)o.name=="VariableName"&&((i=o.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&e(o,r?"variable":"namespace")},AssignStatement(s,e){for(let t=s.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(s,e){for(let t=null,i=s.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(i,"variable"),t=i},CapturePattern:pt("variable"),AsPattern:pt("variable"),__proto__:null};function sr(s,e){let t=Cn.get(e);if(t)return t;let i=[],n=!0;function r(o,l){let a=s.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(gr.IncludeAnonymous).iterate(o=>{if(o.name){let l=Xa[o.name];if(l&&l(o,r,n)||!n&&nr.has(o.name))return!1;n=!1}else if(o.to-o.from>8192){for(let l of sr(s,o.node))i.push(l);return!1}}),Cn.set(e,i),i}const Mn=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,rr=["String","FormatString","Comment","PropertyName"];function Ea(s){let e=Dn(s.state).resolveInner(s.pos,-1);if(rr.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Mn.test(s.state.sliceDoc(e.from,e.to));if(!t&&!s.explicit)return null;let i=[];for(let n=e;n;n=n.parent)nr.has(n.name)&&(i=i.concat(sr(s.state.doc,n)));return{options:i,from:t?e.from:s.pos,validFor:Mn}}const Ca=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(s=>({label:s,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(s=>({label:s,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(s=>({label:s,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(s=>({label:s,type:"function"}))),Ma=[te("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),te("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),te("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),te("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),te(`if \${}: `,{label:"if",detail:"block",type:"keyword"}),te("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),te("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),te("import ${module}",{label:"import",detail:"statement",type:"keyword"}),te("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],Ya=wa(rr,Sa(Ca.concat(Ma)));function Yn(s,e){let t=s.lineIndent(e.from),i=s.lineAt(s.pos,-1),n=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&s.node.tot?null:t+s.unit}const Ft=cr.define({name:"python",parser:ma.configure({props:[ur.add({Body:s=>{var e;return(e=Yn(s,s.node))!==null&&e!==void 0?e:s.continue()},IfStatement:s=>/^\s*(else:|elif )/.test(s.textAfter)?s.baseIndent:s.continue(),TryStatement:s=>/^\s*(except |finally:|else:)/.test(s.textAfter)?s.baseIndent:s.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Et({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Et({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Et({closing:"]"}),"String FormatString":()=>null,Script:s=>{if(s.pos+/\s*/.exec(s.textAfter)[0].length>=s.node.to){let e=null;for(let t=s.node,i=t.to;t=t.lastChild,!(!t||t.to!=i);)t.type.name=="Body"&&(e=t);if(e){let t=Yn(s,e);if(t!=null)return t}}return s.continue()}}),Or.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":dr,Body:(s,e)=>({from:s.from+1,to:s.to-(s.to==e.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/}});function Ia(){return new pr(Ft,[Ft.data.of({autocomplete:Ea}),Ft.data.of({autocomplete:Ya})])}export{Ya as globalCompletion,Ea as localCompletionSource,Ia as python,Ft as pythonLanguage};