UNPKG

@bhsd/codemirror-mediawiki

Version:

Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror

5 lines 721 kB
var Cw=Object.create;var Ma=Object.defineProperty;var Zw=Object.getOwnPropertyDescriptor;var ru=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),cr=t=>{throw TypeError(t)};var nu=(t,e,i)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var iu=(t,e)=>Ma(t,"name",{value:e,configurable:!0});var su=t=>{var e;return[,,,Cw((e=t==null?void 0:t[ru("metadata")])!=null?e:null)]},ou=["class","method","getter","setter","accessor","field","value","get","set"],Jr=t=>t!==void 0&&typeof t!="function"?cr("Function expected"):t,Aw=(t,e,i,r,n)=>({kind:ou[t],name:e,metadata:r,addInitializer:s=>i._?cr("Already initialized"):n.push(Jr(s||null))}),Ea=(t,e)=>nu(e,ru("metadata"),t[3]),au=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)e&1?s[n].call(i):r=s[n].call(i,r);return r},ee=(t,e,i,r,n,s)=>{var o,a,l,h,c,f=e&7,u=!!(e&8),d=!!(e&16),p=f>3?t.length+1:f?u?1:2:0,O=ou[f+5],g=f>3&&(t[p-1]=[]),v=t[p]||(t[p]=[]),y=f&&(!d&&!u&&(n=n.prototype),f<5&&(f>3||!d)&&Zw(f<4?n:{get[i](){return b(this,s)},set[i](w){return Te(this,s,w)}},i));f?d&&f<4&&iu(s,(f>2?"set ":f>1?"get ":"")+i):iu(n,i);for(var S=r.length-1;S>=0;S--)h=Aw(f,i,l={},t[3],v),f&&(h.static=u,h.private=d,c=h.access={has:d?w=>Rw(n,w):w=>i in w},f^3&&(c.get=d?w=>(f^1?b:U)(w,n,f^4?s:y.get):w=>w[i]),f>2&&(c.set=d?(w,Q)=>Te(w,n,Q,f^4?s:y.set):(w,Q)=>w[i]=Q)),a=(0,r[S])(f?f<4?d?s:y[O]:f>4?void 0:{get:y.get,set:y.set}:n,h),l._=1,f^4||a===void 0?Jr(a)&&(f>4?g.unshift(a):f?d?s=a:y[O]=a:n=a):typeof a!="object"||a===null?cr("Object expected"):(Jr(o=a.get)&&(y.get=o),Jr(o=a.set)&&(y.set=o),Jr(o=a.init)&&g.unshift(o));return f||Ea(t,n),y&&Ma(n,i,y),d?f^4?s:y:n},qa=(t,e,i)=>nu(t,typeof e!="symbol"?e+"":e,i),Da=(t,e,i)=>e.has(t)||cr("Cannot "+i),Rw=(t,e)=>Object(e)!==e?cr('Cannot use the "in" operator on this value'):t.has(e),b=(t,e,i)=>(Da(t,e,"read from private field"),i?i.call(t):e.get(t)),ie=(t,e,i)=>e.has(t)?cr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),Te=(t,e,i,r)=>(Da(t,e,"write to private field"),r?r.call(t,i):e.set(t,i),i),U=(t,e,i)=>(Da(t,e,"access private method"),i);var vt,us,or,ds,ps,Os,ms,gs,vs,bs,L,bt,Yi,_i,Fr,ys,$e,If,pi,Wa,kw,ny,sy,oy,ay,ly,cy,hy,fy,uy,dy,py,Oy,my,gy,vy,by,yy,wy,Sy,ky,xy,Qy,$y,Py,Ty,Cy,Zy,Ay,Ry,Wy,Xy,J,F,ar,Kf,Pw,My,Ey,qy,Dy,Vy,Yy,_y,Ly,jy,By,Li,Oi,qt,be,De,ws,Hr,Ss,Kr,ks,we,Jf,Tw,eu,gt,Ww=Object.create,lu=Object.defineProperty,Xw=Object.getOwnPropertyDescriptor,Va=Object.getOwnPropertyNames,Mw=Object.getPrototypeOf,Ew=Object.prototype.hasOwnProperty,qw=(t,e)=>function(){return t&&(e=(0,t[Va(t)[0]])(t=0)),e},Dw=(t,e)=>function(){return e||(0,t[Va(t)[0]])((e={exports:{}}).exports,e),e.exports},Vw=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Va(e))!Ew.call(t,n)&&n!==i&&lu(t,n,{get:()=>e[n],enumerable:!(r=Xw(e,n))||r.enumerable});return t},Yw=(t,e,i)=>(i=t!=null?Ww(Mw(t)):{},Vw(e||!t||!t.__esModule?lu(i,"default",{value:t,enumerable:!0}):i,t)),cu,A=qw({"<define:$LANGS>"(){cu=["en","zh-hans","zh-hant"]}}),_w=Dw({"../node_modules/stylelint-config-recommended/index.js"(t,e){"use strict";A(),e.exports={rules:{"annotation-no-unknown":!0,"at-rule-descriptor-no-unknown":!0,"at-rule-descriptor-value-no-unknown":!0,"at-rule-no-deprecated":!0,"at-rule-no-unknown":!0,"at-rule-prelude-no-invalid":[!0,{ignoreAtRules:["media"]}],"block-no-empty":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"declaration-property-value-keyword-no-deprecated":!0,"declaration-property-value-no-unknown":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-feature-name-value-no-unknown":!0,"media-query-no-invalid":!0,"media-type-no-deprecated":!0,"named-grid-areas-no-invalid":!0,"nesting-selector-no-missing-scoping-root":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-invalid-position-declaration":!0,"no-irregular-whitespace":!0,"property-no-deprecated":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":[!0,{ignore:["at-rule-preludes","declaration-values"]}],"syntax-string-no-invalid":!0}}}});A(),A();var Lw=["zh-hans","zh-hant"],jw=t=>decodeURIComponent(t.replace(/%(?![\da-f]{2})/giu,"%25")),Qs="https://testingcf.jsdelivr.net",hu=typeof document=="object"?document.createElement("textarea"):void 0,fu=t=>(hu.innerHTML=t,hu.value),Bw=t=>{const e=jw(t);return/[<>[\]|{}]/u.test(e)?e:fu(e)},Ya=new Map,hr=(t,e,i)=>{if(Ya.has(t))return Ya.get(t);const r=new Promise(n=>{const s=/^https?:\/\//iu.test(t)?t:`${Qs}/${t}`;let o=globalThis;for(const a of e.split("."))o=o==null?void 0:o[a];if(o)n();else if(i&&typeof define=="function"&&"amd"in define){const a=globalThis.require;a.config({paths:{[e]:s}}),a([e],l=>{Object.assign(globalThis,{[e]:l}),n()})}else{const a=document.createElement("script");a.src=s,a.onload=()=>{n()},document.head.append(a)}});return Ya.set(t,r),r},mi=t=>JSON.parse(String(localStorage.getItem(t))),gi=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},uu=t=>t.split(".",3).map(Number),du=(t,e)=>{const[i,r]=uu(t),[n,s]=uu(e);return i>n||i===n&&r>=s},pu=async(t,e,i,r,n,s=(o=>(o=mi(n))!=null?o:{})())=>{const{version:a,lang:l}=s,h=Array.isArray(i)?i:[i];if(a===e&&h.includes(l))return s;for(const c of h){const f=c.toLowerCase();if(r.includes(f))try{const u=await fetch(`${t}/${f}.json`);return Object.assign(s,await u.json(),{version:e,lang:c}),gi(n,s),s}catch{}}throw new Error(`Failed to fetch the localization for ${h[0]}.`)},Ou=!1,mu=!1,gu=async(t,e,i)=>{const r="extensions/dist";let n=i||`npm/wikiparser-node/${r}/base.min.js`;if(n.endsWith(".js")||(n=`${n}${n.endsWith("/")?"":"/"}${r}/base.js`),await hr(n,"wikiparse"),await hr(`${wikiparse.CDN}/${r}/lsp.js`,"wikiparse.LanguageService"),!Ou&&typeof t=="function"){Ou=!0;try{wikiparse.setConfig(await t())}catch{}}if(!mu&&e){mu=!0;const s="wikiparse-i18n",{version:o}=wikiparse;try{wikiparse.setI18N(await pu(`${wikiparse.CDN}/i18n`,o,e,Lw,s))}catch{gi(s,{version:o,lang:"en"})}}},_a=new WeakMap,ei=(t,e,i,r)=>{if(gu(i,r),typeof wikiparse!="object"||!wikiparse.LanguageService||_a.has(t))return _a.get(t);const n=new wikiparse.LanguageService(e);return _a.set(t,n),n};A(),A(),A(),A(),A();var La=[],vu=[];(()=>{let t="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(e=>e?parseInt(e,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?vu:La).push(i=i+t[e])})();function Nw(t){if(t<768)return!1;for(let e=0,i=La.length;;){let r=e+i>>1;if(t<La[r])i=r;else if(t>=vu[r])e=r+1;else return!0;if(e==i)return!1}}function bu(t){return t>=127462&&t<=127487}var yu=8205;function zw(t,e,i=!0,r=!0){return(i?wu:Iw)(t,e,r)}function wu(t,e,i){if(e==t.length)return e;e&&Su(t.charCodeAt(e))&&ku(t.charCodeAt(e-1))&&e--;let r=ja(t,e);for(e+=xu(r);e<t.length;){let n=ja(t,e);if(r==yu||n==yu||i&&Nw(n))e+=xu(n),r=n;else if(bu(n)){let s=0,o=e-2;for(;o>=0&&bu(ja(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Iw(t,e,i){for(;e>0;){let r=wu(t,e-2,i);if(r<e)return r;e--}return 0}function ja(t,e){let i=t.charCodeAt(e);if(!ku(i)||e+1==t.length)return i;let r=t.charCodeAt(e+1);return Su(r)?(i-55296<<10)+(r-56320)+65536:i}function Su(t){return t>=56320&&t<57344}function ku(t){return t>=55296&&t<56320}function xu(t){return t<65536?1:2}var H=class Ny{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,i,r){[e,i]=fr(this,e,i);let n=[];return this.decompose(0,e,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(i,this.length,n,1),$s.from(n,this.length-(i-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=fr(this,e,i);let r=[];return this.decompose(e,i,r,0),$s.from(r,i-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let i=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),n=new en(this),s=new en(e);for(let o=i,a=i;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(a+=n.value.length,n.done||a>=r)return!0}}iter(e=1){return new en(this,e)}iterRange(e,i=this.length){return new $u(this,e,i)}iterLines(e,i){let r;if(e==null)r=this.iter();else{i==null&&(i=this.lines+1);let n=this.line(e).from;r=this.iterRange(n,Math.max(n,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new Pu(r)}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]?Ny.empty:e.length<=32?new yt(e):$s.from(yt.split(e,[]))}},yt=class Kt extends H{constructor(e,i=Gw(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,r,n){for(let s=0;;s++){let o=this.text[s],a=n+o.length;if((i?r:a)>=e)return new Uw(n,a,r,o);n=a+1,r++}}decompose(e,i,r,n){let s=e<=0&&i>=this.length?this:new Kt(Qu(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(n&1){let o=r.pop(),a=Ps(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Kt(a,o.length+s.length));else{let l=a.length>>1;r.push(new Kt(a.slice(0,l)),new Kt(a.slice(l)))}}else r.push(s)}replace(e,i,r){if(!(r instanceof Kt))return super.replace(e,i,r);[e,i]=fr(this,e,i);let n=Ps(this.text,Ps(r.text,Qu(this.text,0,e)),i),s=this.length+r.length-(i-e);return n.length<=32?new Kt(n,s):$s.from(Kt.split(n,[]),s)}sliceString(e,i=this.length,r=` `){[e,i]=fr(this,e,i);let n="";for(let s=0,o=0;s<=i&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(n+=r),e<l&&i>s&&(n+=a.slice(Math.max(0,e-s),i-s)),s=l+1}return n}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let r=[],n=-1;for(let s of e)r.push(s),n+=s.length+1,r.length==32&&(i.push(new Kt(r,n)),r=[],n=-1);return n>-1&&i.push(new Kt(r,n)),i}},$s=class Ur extends H{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,i,r,n){for(let s=0;;s++){let o=this.children[s],a=n+o.length,l=r+o.lines-1;if((i?l:a)>=e)return o.lineInner(e,i,r,n);n=a+1,r=l+1}}decompose(e,i,r,n){for(let s=0,o=0;o<=i&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&i>=o){let h=n&((o<=e?1:0)|(l>=i?2:0));o>=e&&l<=i&&!h?r.push(a):a.decompose(e-o,i-o,r,h)}o=l+1}}replace(e,i,r){if([e,i]=fr(this,e,i),r.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],a=s+o.length;if(e>=s&&i<=a){let l=o.replace(e-s,i-s,r),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let c=this.children.slice();return c[n]=l,new Ur(c,this.length-(i-e)+r.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,i,r)}sliceString(e,i=this.length,r=` `){[e,i]=fr(this,e,i);let n="";for(let s=0,o=0;s<this.children.length&&o<=i;s++){let a=this.children[s],l=o+a.length;o>e&&s&&(n+=r),e<l&&i>o&&(n+=a.sliceString(e-o,i-o,r)),o=l+1}return n}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof Ur))return 0;let r=0,[n,s,o,a]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=i,s+=i){if(n==o||s==a)return r;let l=this.children[n],h=e.children[s];if(l!=h)return r+l.scanIdentical(h,i);r+=l.length+1}}static from(e,i=e.reduce((r,n)=>r+n.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new yt(d,i)}let n=Math.max(32,r>>5),s=n<<1,o=n>>1,a=[],l=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Ur)for(let O of d.children)f(O);else d.lines>o&&(l>o||!l)?(u(),a.push(d)):d instanceof yt&&l&&(p=c[c.length-1])instanceof yt&&d.lines+p.lines<=32?(l+=d.lines,h+=d.length+1,c[c.length-1]=new yt(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>n&&u(),l+=d.lines,h+=d.length+1,c.push(d))}function u(){l!=0&&(a.push(c.length==1?c[0]:Ur.from(c,h)),h=-1,l=c.length=0)}for(let d of e)f(d);return u(),a.length==1?a[0]:new Ur(a,i)}};H.empty=new yt([""],0);function Gw(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Ps(t,e,i=0,r=1e9){for(let n=0,s=0,o=!0;s<t.length&&n<=r;s++){let a=t[s],l=n+a.length;l>=i&&(l>r&&(a=a.slice(0,r-n)),n<i&&(a=a.slice(i-n)),o?(e[e.length-1]+=a,o=!1):e.push(a)),n=l+1}return e}function Qu(t,e,i){return Ps(t,[""],e,i)}var en=class{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof yt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],n=this.offsets[i],s=n>>1,o=r instanceof yt?r.text.length:r.children.length;if(s==(e>0?o:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=` `,this;t--}else if(r instanceof yt){let a=r.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=r.children[s+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof yt?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},$u=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new en(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*e,this.value=r.length<=i?r:e<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Pu=class{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:r}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(H.prototype[Symbol.iterator]=function(){return this.iter()},en.prototype[Symbol.iterator]=$u.prototype[Symbol.iterator]=Pu.prototype[Symbol.iterator]=function(){return this});var Uw=class{constructor(t,e,i,r){this.from=t,this.to=e,this.number=i,this.text=r}get length(){return this.to-this.from}};function fr(t,e,i){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,i))]}function We(t,e,i=!0,r=!0){return zw(t,e,i,r)}function Fw(t){return t>=56320&&t<57344}function Hw(t){return t>=55296&&t<56320}function ot(t,e){let i=t.charCodeAt(e);if(!Hw(i)||e+1==t.length)return i;let r=t.charCodeAt(e+1);return Fw(r)?(i-55296<<10)+(r-56320)+65536:i}function Ba(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function ti(t){return t<65536?1:2}var Na=/\r\n?|\n/,Xe=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Xe||(Xe={})),ur=class Pa{constructor(e){this.sections=e}get length(){let e=0;for(let i=0;i<this.sections.length;i+=2)e+=this.sections[i];return e}get newLength(){let e=0;for(let i=0;i<this.sections.length;i+=2){let r=this.sections[i+1];e+=r<0?this.sections[i]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let i=0,r=0,n=0;i<this.sections.length;){let s=this.sections[i++],o=this.sections[i++];o<0?(e(r,n,s),n+=s):n+=o,r+=s}}iterChangedRanges(e,i=!1){za(this,e,i)}get invertedDesc(){let e=[];for(let i=0;i<this.sections.length;){let r=this.sections[i++],n=this.sections[i++];n<0?e.push(r,n):e.push(n,r)}return new Pa(e)}composeDesc(e){return this.empty?e:e.empty?this:Tu(this,e)}mapDesc(e,i=!1){return e.empty?this:Ia(this,e,i)}mapPos(e,i=-1,r=Xe.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],h=n+a;if(l<0){if(h>e)return s+(e-n);s+=a}else{if(r!=Xe.Simple&&h>=e&&(r==Xe.TrackDel&&n<e&&h>e||r==Xe.TrackBefore&&n<e||r==Xe.TrackAfter&&h>e))return null;if(h>e||h==e&&i<0&&!a)return e==n||i<0?s:s+l;s+=l}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,i=e){for(let r=0,n=0;r<this.sections.length&&n<=i;){let s=this.sections[r++],o=this.sections[r++],a=n+s;if(o>=0&&n<=i&&a>=e)return n<e&&a>i?"cover":!0;n=a}return!1}toString(){let e="";for(let i=0;i<this.sections.length;){let r=this.sections[i++],n=this.sections[i++];e+=(e?" ":"")+r+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(i=>typeof i!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Pa(e)}static create(e){return new Pa(e)}},wt=class Vi extends ur{constructor(e,i){super(e),this.inserted=i}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return za(this,(i,r,n,s,o)=>e=e.replace(n,n+(r-i),o),!1),e}mapDesc(e,i=!1){return Ia(this,e,i,!0)}invert(e){let i=this.sections.slice(),r=[];for(let n=0,s=0;n<i.length;n+=2){let o=i[n],a=i[n+1];if(a>=0){i[n]=a,i[n+1]=o;let l=n>>1;for(;r.length<l;)r.push(H.empty);r.push(o?e.slice(s,s+o):H.empty)}s+=o}return new Vi(i,r)}compose(e){return this.empty?e:e.empty?this:Tu(this,e,!0)}map(e,i=!1){return e.empty?this:Ia(this,e,i,!0)}iterChanges(e,i=!1){za(this,e,i)}get desc(){return ur.create(this.sections)}filter(e){let i=[],r=[],n=[],s=new tn(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,l-a);Ee(n,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Ee(i,c,f),f>0&&vi(r,i,s.text),s.forward(c),a+=c}let h=e[o++];for(;a<h;){if(s.done)break e;let c=Math.min(s.len,h-a);Ee(i,c,-1),Ee(n,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),a+=c}}return{changes:new Vi(i,r),filtered:ur.create(n)}}toJSON(){let e=[];for(let i=0;i<this.sections.length;i+=2){let r=this.sections[i],n=this.sections[i+1];n<0?e.push(r):n==0?e.push([r]):e.push([r].concat(this.inserted[i>>1].toJSON()))}return e}static of(e,i,r){let n=[],s=[],o=0,a=null;function l(c=!1){if(!c&&!n.length)return;o<i&&Ee(n,i-o,-1);let f=new Vi(n,s);a=a?a.compose(f.map(a)):f,n=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof Vi){if(c.length!=i)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${i})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>i)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${i})`);let p=d?typeof d=="string"?H.of(d.split(r||Na)):d:H.empty,O=p.length;if(f==u&&O==0)return;f<o&&l(),f>o&&Ee(n,f-o,-1),Ee(n,u-f,O),vi(s,n,p),o=u}}return h(e),l(!a),a}static empty(e){return new Vi(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],r=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="number")i.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)i.push(s[0],0);else{for(;r.length<n;)r.push(H.empty);r[n]=H.of(s.slice(1)),i.push(s[0],r[n].length)}}}return new Vi(i,r)}static createSet(e,i){return new Vi(e,i)}};function Ee(t,e,i,r=!1){if(e==0&&i<=0)return;let n=t.length-2;n>=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&e==0&&t[n]==0?t[n+1]+=i:r?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function vi(t,e,i){if(i.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<r;)t.push(H.empty);t.push(i)}}function za(t,e,i){let r=t.inserted;for(let n=0,s=0,o=0;o<t.sections.length;){let a=t.sections[o++],l=t.sections[o++];if(l<0)n+=a,s+=a;else{let h=n,c=s,f=H.empty;for(;h+=a,c+=l,l&&r&&(f=f.append(r[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],l=t.sections[o++];e(n,h,s,c,f),n=h,s=c}}}function Ia(t,e,i,r=!1){let n=[],s=r?[]:null,o=new tn(t),a=new tn(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);Ee(n,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!i))){let h=a.len;for(Ee(n,a.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&l<o.i&&o.len<=c&&(Ee(n,0,o.ins),s&&vi(s,n,o.text),l=o.i),o.forward(c),h-=c}a.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(a.ins==-1){let f=Math.min(c,a.len);h+=f,c-=f,a.forward(f)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;Ee(n,h,l<o.i?o.ins:0),s&&l<o.i&&vi(s,n,o.text),l=o.i,o.forward(o.len-c)}else{if(o.done&&a.done)return s?wt.createSet(n,s):ur.create(n);throw new Error("Mismatched change set lengths")}}}function Tu(t,e,i=!1){let r=[],n=i?[]:null,s=new tn(t),o=new tn(e);for(let a=!1;;){if(s.done&&o.done)return n?wt.createSet(r,n):ur.create(r);if(s.ins==0)Ee(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)Ee(r,0,o.ins,a),n&&vi(n,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),h=r.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Ee(r,l,c,a),n&&c&&vi(n,r,o.text)}else o.ins==-1?(Ee(r,s.off?0:s.len,l,a),n&&vi(n,r,s.textBit(l))):(Ee(r,s.off?0:s.len,o.off?0:o.ins,a),n&&!o.off&&vi(n,r,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>h),s.forward2(l),o.forward(l)}}}}var tn=class{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?H.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?H.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}},rn=class Af{constructor(e,i,r){this.from=e,this.to=i,this.flags=r}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,i=-1){let r,n;return this.empty?r=n=e.mapPos(this.from,i):(r=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),r==this.from&&n==this.to?this:new Af(r,n,this.flags)}extend(e,i=e){if(e<=this.anchor&&i>=this.anchor)return k.range(e,i);let r=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return k.range(this.anchor,r)}eq(e,i=!1){return this.anchor==e.anchor&&this.head==e.head&&(!i||!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 k.range(e.anchor,e.head)}static create(e,i,r){return new Af(e,i,r)}},k=class it{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:it.create(this.ranges.map(r=>r.map(e,i)),this.mainIndex)}eq(e,i=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],i))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new it([this.main],0)}addRange(e,i=!0){return it.create([e].concat(this.ranges),i?0:this.mainIndex+1)}replaceRange(e,i=this.mainIndex){let r=this.ranges.slice();return r[i]=e,it.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new it(e.ranges.map(i=>rn.fromJSON(i)),e.main)}static single(e,i=e){return new it([it.range(e,i)],0)}static create(e,i=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,n=0;n<e.length;n++){let s=e[n];if(s.empty?s.from<=r:s.from<r)return it.normalized(e.slice(),i);r=s.to}return new it(e,i)}static cursor(e,i=0,r,n){return rn.create(e,e,(i==0?0:i<0?8:16)|(r==null?7:Math.min(6,r))|(n!=null?n:16777215)<<6)}static range(e,i,r,n){let s=(r!=null?r:16777215)<<6|(n==null?7:Math.min(6,n));return i<e?rn.create(i,e,48|s):rn.create(e,i,(i>e?8:0)|s)}static normalized(e,i=0){let r=e[i];e.sort((n,s)=>n.from-s.from),i=e.indexOf(r);for(let n=1;n<e.length;n++){let s=e[n],o=e[n-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);n<=i&&i--,e.splice(--n,2,s.anchor>s.head?it.range(l,a):it.range(a,l))}}return new it(e,i)}};function Cu(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}var Ga=0,M=class zy{constructor(e,i,r,n,s){this.combine=e,this.compareInput=i,this.compare=r,this.isStatic=n,this.id=Ga++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new zy(e.combine||(i=>i),e.compareInput||((i,r)=>i===r),e.compare||(e.combine?(i,r)=>i===r:Ua),!!e.static,e.enables)}of(e){return new Ts([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ts(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ts(e,this,2,i)}from(e,i){return i||(i=r=>r),this.compute([e],r=>i(r.field(e)))}};function Ua(t,e){return t==e||t.length==e.length&&t.every((i,r)=>i===e[r])}var Ts=class{constructor(t,e,i,r){this.dependencies=t,this.facet=e,this.type=i,this.value=r,this.id=Ga++}dynamicSlot(t){var e;let i=this.value,r=this.facet.compareInput,n=this.id,s=t[n]>>1,o=this.type==2,a=!1,l=!1,h=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?l=!0:(((e=t[c.id])!==null&&e!==void 0?e:1)&1)==0&&h.push(t[c.id]);return{create(c){return c.values[s]=i(c),1},update(c,f){if(a&&f.docChanged||l&&(f.docChanged||f.selection)||Fa(c,h)){let u=i(c);if(o?!Zu(u,c.values[s],r):!r(u,c.values[s]))return c.values[s]=u,1}return 0},reconfigure:(c,f)=>{let u,d=f.config.address[n];if(d!=null){let p=Zs(f,d);if(this.dependencies.every(O=>O instanceof M?f.facet(O)===c.facet(O):O instanceof Se?f.field(O,!1)==c.field(O,!1):!0)||(o?Zu(u=i(c),p,r):r(u=i(c),p)))return c.values[s]=p,0}else u=i(c);return c.values[s]=u,1}}}};function Zu(t,e,i){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!i(t[r],e[r]))return!1;return!0}function Fa(t,e){let i=!1;for(let r of e)sn(t,r)&1&&(i=!0);return i}function Kw(t,e,i){let r=i.map(l=>t[l.id]),n=i.map(l=>l.type),s=r.filter(l=>!(l&1)),o=t[e.id]>>1;function a(l){let h=[];for(let c=0;c<r.length;c++){let f=Zs(l,r[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(l){for(let h of r)sn(l,h);return l.values[o]=a(l),1},update(l,h){if(!Fa(l,s))return 0;let c=a(l);return e.compare(c,l.values[o])?0:(l.values[o]=c,1)},reconfigure(l,h){let c=Fa(l,r),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ua(i,f))return l.values[o]=u,0;let d=a(l);return e.compare(d,u)?(l.values[o]=u,0):(l.values[o]=d,1)}}}var Cs=M.define({static:!0}),Se=class Iy{constructor(e,i,r,n,s){this.id=e,this.createF=i,this.updateF=r,this.compareF=n,this.spec=s,this.provides=void 0}static define(e){let i=new Iy(Ga++,e.create,e.update,e.compare||((r,n)=>r===n),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(Cs).find(r=>r.field==this);return((i==null?void 0:i.create)||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:r=>(r.values[i]=this.create(r),1),update:(r,n)=>{let s=r.values[i],o=this.updateF(s,n);return this.compareF(s,o)?0:(r.values[i]=o,1)},reconfigure:(r,n)=>{let s=r.facet(Cs),o=n.facet(Cs),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[i]=a.create(r),1):n.config.address[this.id]!=null?(r.values[i]=n.field(this),0):(r.values[i]=this.create(r),1)}}}init(e){return[this,Cs.of({field:this,create:e})]}get extension(){return this}},Bi={lowest:4,low:3,default:2,high:1,highest:0};function nn(t){return e=>new Au(e,t)}var ii={highest:nn(Bi.highest),high:nn(Bi.high),default:nn(Bi.default),low:nn(Bi.low),lowest:nn(Bi.lowest)},Au=class{constructor(t,e){this.inner=t,this.prec=e}},St=class Gy{of(e){return new Ha(this,e)}reconfigure(e){return Gy.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Ha=class{constructor(t,e){this.compartment=t,this.inner=e}},Ru=class Uy{constructor(e,i,r,n,s,o){for(this.base=e,this.compartments=i,this.dynamicSlots=r,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let i=this.address[e.id];return i==null?e.default:this.staticValues[i>>1]}static resolve(e,i,r){let n=[],s=Object.create(null),o=new Map;for(let u of Jw(e,i,o))u instanceof Se?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let a=Object.create(null),l=[],h=[];for(let u of n)a[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=r==null?void 0:r.config.facets;for(let u in s){let d=s[u],p=d[0].facet,O=c&&c[u]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,Ua(O,d))l.push(r.facet(p));else{let g=p.combine(d.map(v=>v.value));l.push(r&&p.compare(g,r.facet(p))?r.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=h.length<<1,h.push(v=>g.dynamicSlot(v)));a[p.id]=h.length<<1,h.push(g=>Kw(g,p,d))}}let f=h.map(u=>u(a));return new Uy(e,o,f,a,l,s)}};function Jw(t,e,i){let r=[[],[],[],[],[]],n=new Map;function s(o,a){let l=n.get(o);if(l!=null){if(l<=a)return;let h=r[l].indexOf(o);h>-1&&r[l].splice(h,1),o instanceof Ha&&i.delete(o.compartment)}if(n.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof Ha){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;i.set(o.compartment,h),s(h,a)}else if(o instanceof Au)s(o.inner,o.prec);else if(o instanceof Se)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Ts)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,Bi.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,a)}}return s(t,Bi.default),r.reduce((o,a)=>o.concat(a))}function sn(t,e){if(e&1)return 2;let i=e>>1,r=t.status[i];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function Zs(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var Wu=M.define(),Ka=M.define({combine:t=>t.some(e=>e),static:!0}),Xu=M.define({combine:t=>t.length?t[0]:void 0,static:!0}),Mu=M.define(),Eu=M.define(),qu=M.define(),Du=M.define({combine:t=>t.length?t[0]:!1}),ri=class{constructor(t,e){this.type=t,this.value=e}static define(){return new eS}},eS=class{of(t){return new ri(this,t)}},tS=class{constructor(t){this.map=t}of(t){return new N(this,t)}},N=class Fy{constructor(e,i){this.type=e,this.value=i}map(e){let i=this.type.map(this.value,e);return i===void 0?void 0:i==this.value?this:new Fy(this.type,i)}is(e){return this.type==e}static define(e={}){return new tS(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let r=[];for(let n of e){let s=n.map(i);s&&r.push(s)}return r}};N.reconfigure=N.define(),N.appendConfig=N.define();var Ye=class ns{constructor(e,i,r,n,s,o){this.startState=e,this.changes=i,this.selection=r,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Cu(r,i.newLength),s.some(a=>a.type==ns.time)||(this.annotations=s.concat(ns.time.of(Date.now())))}static create(e,i,r,n,s,o){return new ns(e,i,r,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let i of this.annotations)if(i.type==e)return i.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let i=this.annotation(ns.userEvent);return!!(i&&(i==e||i.length>e.length&&i.slice(0,e.length)==e&&i[e.length]=="."))}};Ye.time=ri.define(),Ye.userEvent=ri.define(),Ye.addToHistory=ri.define(),Ye.remote=ri.define();function iS(t,e){let i=[];for(let r=0,n=0;;){let s,o;if(r<t.length&&(n==e.length||e[n]>=t[r]))s=t[r++],o=t[r++];else if(n<e.length)s=e[n++],o=e[n++];else return i;!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function Vu(t,e,i){var r;let n,s,o;return i?(n=e.changes,s=wt.empty(e.changes.length),o=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(n),effects:N.mapEffects(t.effects,n).concat(N.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Ja(t,e,i){let r=e.selection,n=dr(e.annotations);return e.userEvent&&(n=n.concat(Ye.userEvent.of(e.userEvent))),{changes:e.changes instanceof wt?e.changes:wt.of(e.changes||[],i,t.facet(Xu)),selection:r&&(r instanceof k?r:k.single(r.anchor,r.head)),effects:dr(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Yu(t,e,i){let r=Ja(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(i=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(i=!1);let o=!!e[s].sequential;r=Vu(r,Ja(t,e[s],o?r.changes.newLength:t.doc.length),o)}let n=Ye.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return nS(i?rS(n):n)}function rS(t){let e=t.startState,i=!0;for(let n of e.facet(Mu)){let s=n(t);if(s===!1){i=!1;break}Array.isArray(s)&&(i=i===!0?s:iS(i,s))}if(i!==!0){let n,s;if(i===!1)s=t.changes.invertedDesc,n=wt.empty(e.doc.length);else{let o=t.changes.filter(i);n=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Ye.create(e,n,t.selection&&t.selection.map(s),N.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(Eu);for(let n=r.length-1;n>=0;n--){let s=r[n](t);s instanceof Ye?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ye?t=s[0]:t=Yu(e,dr(s),!1)}return t}function nS(t){let e=t.startState,i=e.facet(qu),r=t;for(let n=i.length-1;n>=0;n--){let s=i[n](t);s&&Object.keys(s).length&&(r=Vu(r,Ja(e,s,t.changes.newLength),!0))}return r==t?t:Ye.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}var sS=[];function dr(t){return t==null?sS:Array.isArray(t)?t:[t]}var pe=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(pe||(pe={})),oS=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,el;try{el=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function aS(t){if(el)return el.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||oS.test(i)))return!0}return!1}function lS(t){return e=>{if(!/\S/.test(e))return pe.Space;if(aS(e))return pe.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return pe.Word;return pe.Other}}var fe=class Mt{constructor(e,i,r,n,s,o){this.config=e,this.doc=i,this.selection=r,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)sn(this,a<<1);this.computeSlot=null}field(e,i=!0){let r=this.config.address[e.id];if(r==null){if(i)throw new RangeError("Field is not present in this state");return}return sn(this,r),Zs(this,r)}update(...e){return Yu(this,e,!0)}applyTransaction(e){let i=this.config,{base:r,compartments:n}=i;for(let a of e.effects)a.is(St.reconfigure)?(i&&(n=new Map,i.compartments.forEach((l,h)=>n.set(h,l)),i=null),n.set(a.value.compartment,a.value.extension)):a.is(N.reconfigure)?(i=null,r=a.value):a.is(N.appendConfig)&&(i=null,r=dr(r).concat(a.value));let s;i?s=e.startState.values.slice():(i=Ru.resolve(r,n,this),s=new Mt(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values);let o=e.startState.facet(Ka)?e.newSelection:e.newSelection.asSingle();new Mt(i,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:e},range:k.cursor(i.from+e.length)}))}changeByRange(e){let i=this.selection,r=e(i.ranges[0]),n=this.changes(r.changes),s=[r.range],o=dr(r.effects);for(let a=1;a<i.ranges.length;a++){let l=e(i.ranges[a]),h=this.changes(l.changes),c=h.map(n);for(let u=0;u<a;u++)s[u]=s[u].map(c);let f=n.mapDesc(h,!0);s.push(l.range.map(f)),n=n.compose(c),o=N.mapEffects(o,c).concat(N.mapEffects(dr(l.effects),f))}return{changes:n,selection:k.create(s,i.mainIndex),effects:o}}changes(e=[]){return e instanceof wt?e:wt.of(e,this.doc.length,this.facet(Mt.lineSeparator))}toText(e){return H.of(e.split(this.facet(Mt.lineSeparator)||Na))}sliceDoc(e=0,i=this.doc.length){return this.doc.sliceString(e,i,this.lineBreak)}facet(e){let i=this.config.address[e.id];return i==null?e.default:(sn(this,i),Zs(this,i))}toJSON(e){let i={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let n=e[r];n instanceof Se&&this.config.address[n.id]!=null&&(i[r]=n.spec.toJSON(this.field(e[r]),this))}return i}static fromJSON(e,i={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];n.push(o.init(l=>o.spec.fromJSON(a,l)))}}return Mt.create({doc:e.doc,selection:k.fromJSON(e.selection),extensions:i.extensions?n.concat([i.extensions]):n})}static create(e={}){let i=Ru.resolve(e.extensions||[],new Map),r=e.doc instanceof H?e.doc:H.of((e.doc||"").split(i.staticFacet(Mt.lineSeparator)||Na)),n=e.selection?e.selection instanceof k?e.selection:k.single(e.selection.anchor,e.selection.head):k.single(0);return Cu(n,r.length),i.staticFacet(Ka)||(n=n.asSingle()),new Mt(i,r,n,i.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||` `}get readOnly(){return this.facet(Du)}phrase(e,...i){for(let r of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(r,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>i.length?r:i[s-1]})),e}languageDataAt(e,i,r=-1){let n=[];for(let s of this.facet(Wu))for(let o of s(this,i,r))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){return lS(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:i,from:r,length:n}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,a=e-r;for(;o>0;){let l=We(i,o,!1);if(s(i.slice(l,o))!=pe.Word)break;o=l}for(;a<n;){let l=We(i,a);if(s(i.slice(a,l))!=pe.Word)break;a=l}return o==a?null:k.range(o+r,a+r)}};fe.allowMultipleSelections=Ka,fe.tabSize=M.define({combine:t=>t.length?t[0]:4}),fe.lineSeparator=Xu,fe.readOnly=Du,fe.phrases=M.define({compare(t,e){let i=Object.keys(t),r=Object.keys(e);return i.length==r.length&&i.every(n=>t[n]==e[n])}}),fe.languageData=Wu,fe.changeFilter=Mu,fe.transactionFilter=Eu,fe.transactionExtender=qu,St.reconfigure=N.define();function kt(t,e,i={}){let r={};for(let n of t)for(let s of Object.keys(n)){let o=n[s],a=r[s];if(a===void 0)r[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(i,s))r[s]=i[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let n in e)r[n]===void 0&&(r[n]=e[n]);return r}var Ni=class{eq(t){return this==t}range(t,e=t){return tl.create(t,e,this)}};Ni.prototype.startSide=Ni.prototype.endSide=0,Ni.prototype.point=!1,Ni.prototype.mapMode=Xe.TrackDel;var tl=class Hy{constructor(e,i,r){this.from=e,this.to=i,this.value=r}static create(e,i,r){return new Hy(e,i,r)}};function il(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var cS=class Ky{constructor(e,i,r,n){this.from=e,this.to=i,this.value=r,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,i,r,n=0){let s=r?this.to:this.from;for(let o=n,a=s.length;;){if(o==a)return o;let l=o+a>>1,h=s[l]-e||(r?this.value[l].endSide:this.value[l].startSide)-i;if(l==o)return h>=0?o:a;h>=0?a=l:o=l+1}}between(e,i,r,n){for(let s=this.findIndex(i,-1e9,!0),o=this.findIndex(r,1e9,!1,s);s<o;s++)if(n(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,i){let r=[],n=[],s=[],o=-1,a=-1;for(let l=0;l<this.value.length;l++){let h=this.value[l],c=this.from[l]+e,f=this.to[l]+e,u,d;if(c==f){let p=i.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=i.mapPos(c,h.endSide),d<u)))continue}else if(u=i.mapPos(c,h.startSide),d=i.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(a=Math.max(a,d-u)),r.push(h),n.push(u-o),s.push(d-o))}return{mapped:r.length?new Ky(n,s,r,a):null,pos:o}}},se=class di{constructor(e,i,r,n){this.chunkPos=e,this.chunk=i,this.nextLayer=r,this.maxPoint=n}static create(e,i,r,n){return new di(e,i,r,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 i of this.chunk)e+=i.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:i=[],sort:r=!1,filterFrom:n=0,filterTo:s=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(r&&(i=i.slice().sort(il)),this.isEmpty)return i.length?di.of(i):this;let a=new Lu(this,null,-1).goto(0),l=0,h=[],c=new ni;for(;a.value||l<i.length;)if(l<i.length&&(a.from-i[l].from||a.startSide-i[l].value.startSide)>=0){let f=i[l++];c.addInner(f.from,f.to,f.value)||h.push(f)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==i.length||this.chunkEnd(a.chunkIndex)<i[l].from)&&(!o||n>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&c.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!o||n>a.to||s<a.from||o(a.from,a.to,a.value))&&(c.addInner(a.from,a.to,a.value)||h.push(tl.create(a.from,a.to,a.value))),a.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?di.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let i=[],r=[],n=-1;for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],l=this.chunk[o],h=e.touchesRange(a,a+l.length);if(h===!1)n=Math.max(n,l.maxPoint),i.push(l),r.push(e.mapPos(a));else if(h===!0){let{mapped:c,pos:f}=l.map(a,e);c&&(n=Math.max(n,c.maxPoint),i.push(c),r.push(f))}}let s=this.nextLayer.map(e);return i.length==0?s:new di(r,i,s||di.empty,n)}between(e,i,r){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(i>=s&&e<=s+o.length&&o.between(s,e-s,i-s,r)===!1)return}this.nextLayer.between(e,i,r)}}iter(e=0){return rl.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return rl.from(e).goto(i)}static compare(e,i,r,n,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=i.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=_u(o,a,r),h=new on(o,l,s),c=new on(a,l,s);r.iterGaps((f,u,d)=>ju(h,f,c,u,d,n)),r.empty&&r.length==0&&ju(h,0,c,0,0,n)}static eq(e,i,r=0,n){n==null&&(n=999999999);let s=e.filter(c=>!c.isEmpty&&i.indexOf(c)<0),o=i.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=_u(s,o),l=new on(s,a,0).goto(r),h=new on(o,a,0).goto(r);for(;;){if(l.to!=h.to||!sl(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>n)return!0;l.next(),h.next()}}static spans(e,i,r,n,s=-1){let o=new on(e,null,s).goto(i),a=i,l=o.openStart;for(;;){let h=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<i?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,l);n.point(a,h,o.point,c,f,o.pointRank),l=Math.min(o.openEnd(h),c.length)}else h>a&&(n.span(a,h,o.active,l),l=o.openEnd(h));if(o.to>r)return l+(o.point&&o.to>r?1:0);a=o.to,o.next()}}static of(e,i=!1){let r=new ni;for(let n of e instanceof tl?[e]:i?hS(e):e)r.add(n.from,n.to,n.value);return r.finish()}static join(e){if(!e.length)return di.empty;let i=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let n=e[r];n!=di.empty;n=n.nextLayer)i=new di(n.chunkPos,n.chunk,i,Math.max(n.maxPoint,i.maxPoint));return i}};se.empty=new se([],[],null,-1);function hS(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let r=t[i];if(il(e,r)>0)return t.slice().sort(il);e=r}return t}se.empty.nextLayer=se.empty;var ni=class Jy{finishChunk(e){this.chunks.push(new cS(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,i,r){this.addInner(e,i,r)||(this.nextLayer||(this.nextLayer=new Jy)).add(e,i,r)}addInner(e,i,r){let n=e-this.lastTo||r.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||r.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(i-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=i,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,i-e)),!0)}addChunk(e,i){if((e-this.lastTo||i.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,i.maxPoint),this.chunks.push(i),this.chunkPos.push(e);let r=i.value.length-1;return this.last=i.value[r],this.lastFrom=i.from[r]+e,this.lastTo=i.to[r]+e,!0}finish(){return this.finishInner(se.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=se.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}};function _u(t,e,i){let r=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&r.set(s.chunk[o],s.chunkPos[o]);let n=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let a=r.get(s.chunk[o]);a!=null&&(i?i.mapPos(a):a)==s.chunkPos[o]&&!(i!=null&&i.touchesRange(a,a+s.chunk[o].length))&&n.add(s.chunk[o])}return n}var Lu=class{constructor(t,e,i,r=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(t