bookstack/public/dist/code.js

31 lines
601 KiB
JavaScript
Raw Normal View History

var q=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ci(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),oi.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ci(this,e,t);let n=[];return this.decompose(e,t,n,0),oi.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Gt(this),s=new Gt(e);for(let o=t,O=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(O+=r.value.length,r.done||O>=n)return!0}}iter(e=1){return new Gt(this,e)}iterRange(e,t=this.length){return new Rn(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Zn(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new ze(e):oi.from(ze.split(e,[]))}},ze=class i extends q{constructor(e,t=Qd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],O=r+o.length;if((t?n:O)>=e)return new ts(r,O,n,o);r=O+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(cl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),O=Wn(s.text,o.text.slice(),0,s.length);if(O.length<=32)n.push(new i(O,o.length+s.length));else{let l=O.length>>1;n.push(new i(O.slice(0,l)),new i(O.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=ci(this,e,t);let r=Wn(this.text,Wn(n.text,cl(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):oi.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){[e,t]=ci(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let O=this.text[o],l=s+O.length;s>e&&o&&(r+=n),e<l&&t>s&&(r+=O.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},oi=class i extends q{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],O=r+o.length,l=n+o.lines-1;if((t?l:O)>=e)return o.lineInner(e,t,n,r);r=O+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let O=this.children[s],l=o+O.length;if(e<=l&&t>=o){let a=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!a?n.push(O):O.decompose(e-o,t-o,n,a)}o=l+1}}replace(e,t,n){if([e,t]=ci(this,e,t),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],O=s+o.length;if(e>=s&&t<=O){let l=o.replace(e-s,t-s,n),a=this.lines-o.lines+l.lines;if(l.lines<a>>5-1&&l.lines>a>>5+1){let h=this.children.slice();return h[r]=l,new i(h,this.length-(t-e)+n.length)}return super.replace(s,O,l)}s=O+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
`){[e,t]=ci(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let O=this.children[s],l=o+O.length;o>e&&s&&(r+=n),e<l&&t>o&&(r+=O.sliceString(e-o,t-o,n)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,O]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==O)return n;let l=this.children[r],a=e.children[s];if(l!=a)return n+l.scanIdentical(a,t);n+=l.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ze(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,O=[],l=0,a=-1,h=[];function c(d){let p;if(d.lines>s&&d instanceof i)for(let m of d.children)c(m);else d.lines>o&&(l>o||!l)?(f(),O.push(d)):d instanceof ze&&l&&(p=h[h.length-1])instanceof ze&&d.lines+p.lines<=32?(l+=d.lines,a+=d.length+1,h[h.length-1]=new ze(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>r&&f(),l+=d.lines,a+=d.length+1,h.push(d))}function f(){l!=0&&(O.push(h.length==1?h[0]:i.from(h,a)),a=-1,l=h.length=0)}for(let d of e)c(d);return f(),O.length==1?O[0]:new i(O,t)}};q.empty=new ze([""],0);function Qd(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Wn(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let O=i[s],l=r+O.length;l>=t&&(l>n&&(O=O.slice(0,n-r)),r<t&&(O=O.slice(t-r)),o?(e[e.length-1]+=O,o=!1):e.push(O)),r=l+1}return e}function cl(i,e,t){return Wn(i,[""],e,t)}var Gt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ze?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,O=r instanceof ze?r.text.length:r.children.length;if(o==(t>0?O:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof ze){let l=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof ze?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Rn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Gt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Zn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(q.prototype[Symbol.iterator]=function(){return this.iter()},Gt.prototype[Symbol.iterator]=Rn.prototype[Symbol.iterator]=Zn.prototype[Symbol.iterator]=function(){return this});var ts=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function ci(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var Oi="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(i=>i?parseInt(i,36):1);for(let i=1;i<Oi.length;i++)Oi[i]+=Oi[i-1];function yd(i){for(let e=1;e<Oi.length;e+=2)if(Oi[e]>i)return Oi[e-1]<=i;return!1}function fl(i){return i>=127462&&i<=127487}var ul=8205;function le(i,e,t=!0,n=!0){return(t?Sl:bd)(i,e,n)}function Sl(i,e,t){if(e==i.length)return e;e&&Ql(i.charCodeAt(e))&&yl(i.charCodeAt(e-1))&&e--;let n=li(i,e);for(e+=Vi(n);e<i.length;){let r=li(i,e);if(n==ul||r==ul||t&&yd(r))e+=Vi(r),n=r;else if(fl(r)){let s=0,o=e-2;for(;o>=0&&fl(li(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function bd(i,e,t){for(;e>0;){let n=Sl(i,e-2,t);if(n<e)return n;e--}return 0}function Ql(i){return i>=56320&&i<57344}function yl(i){return i>=55296&&i<56320}function li(i,e){let t=i.charCodeAt(e);if(!yl(t)||e+1=
`}get readOnly(){return this.facet(zl)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(xl))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Wd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,O=e-n;for(;o>0;){let l=le(t,o,!1);if(s(t.slice(l,o))!=qe.Word)break;o=l}for(;O<r;){let l=le(t,O);if(s(t.slice(O,l))!=qe.Word)break;O=l}return o==O?null:S.range(o+n,O+n)}};j.allowMultipleSelections=os;j.tabSize=W.define({combine:i=>i.length?i[0]:4});j.lineSeparator=wl;j.readOnly=zl;j.phrases=W.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});j.languageData=xl;j.changeFilter=kl;j.transactionFilter=vl;j.transactionExtender=Tl;ft.reconfigure=E.define();function bt(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],O=n[s];if(O===void 0)n[s]=o;else if(!(O===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](O,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Ie=class{eq(e){return this==e}range(e,t=e){return qi.create(e,t,this)}};Ie.prototype.startSide=Ie.prototype.endSide=0;Ie.prototype.point=!1;Ie.prototype.mapMode=Oe.TrackDel;var qi=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function cs(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var fs=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,O=s.length;;){if(o==O)return o;let l=o+O>>1,a=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return a>=0?o:O;a>=0?O=l:o=l+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],o=-1,O=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,f,d;if(h==c){let p=t.mapPos(h,a.startSide,a.mapMode);if(p==null||(f=d=p,a.startSide!=a.endSide&&(d=t.mapPos(h,a.endSide),d<f)))continue}else if(f=t.mapPos(h,a.startSide),d=t.mapPos(c,a.endSide),f>d||f==d&&a.startSide>0&&a.endSide<=0)continue;(d-f||a.endSide-a.startSide)<0||(o<0&&(o=f),a.point&&(O=Math.max(O,d-f)),n.push(a),r.push(f-o),s.push(d-o))}return{mapped:n.length?new i(r,s,n,O):null,pos:o}}},B=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(cs)),this.isEmpty)return t.length?i.of(t):this;let O=new qn(this,null,-1).goto(0),l=0,a=[],h=new It;for(;O.value||l<t.length;)if(l<t.length&&(O.from-t[l].from||O.startSide-t[l].value.startSide)>=0){let c=t[l++];h.addInner(c.from,c.to,c.value)||a.push(c)}else O.rangeIndex==1&&O.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(O.chunkIndex)<t[l].from)&&(!o||r>this.chunkEnd(O.chunkIndex)||s<this.chunkPos[O.chunkIndex])&&h.addChunk(this.chunkPos[O.chunkIndex],this.chunk[O.chunkIndex])?O.nextChunk():((!o||r>O.to||s<O.from||o(O.from,O.to,O.value))&&(h.addInner(O.from,O.to,O.value)||a.push(qi.create(O.from,O.to,O.value))),O.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?i.empty:this.nextLayer.update({add:a,filter:o,filterFrom:r,filt
`)}static newName(){let e=Zl[Rl]||1;return Zl[Rl]=e+1,ms+e.toString(36)}static mount(e,t,n){let r=e[gs],s=n&&n.nonce;r?s&&r.setNonce(s):r=new $s(e,s),r.mount(Array.isArray(t)?t:[t])}},Yl=new Map,$s=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Yl.get(n);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[gs]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Yl.set(n,this)}else{this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[gs]=this}mount(e){let t=this.sheet,n=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],O=this.modules.indexOf(o);if(O<r&&O>-1&&(this.modules.splice(O,1),r--,O=-1),O==-1){if(this.modules.splice(r++,0,o),t)for(let l=0;l<o.rules.length;l++)t.insertRule(o.rules[l],n++)}else{for(;r<O;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var ut={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Yd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ee=0;ee<10;ee++)ut[48+ee]=ut[96+ee]=String(ee);var ee;for(ee=1;ee<=24;ee++)ut[ee+111]="F"+ee;var ee;for(ee=65;ee<=90;ee++)ut[ee]=String.fromCharCode(ee+32),fi[ee]=String.fromCharCode(ee);var ee;for(_n in ut)fi.hasOwnProperty(_n)||(fi[_n]=ut[_n]);var _n;function Vl(i){var e=Zd&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Yd&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?fi:ut)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function er(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function xs(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Vd(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Dn(i,e){if(!e.anchorNode)return!1;try{return xs(i,e.anchorNode)}catch{return!1}}function Ni(i){return i.nodeType==3?Lt(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function tr(i,e,t,n){return t?Cl(i,e,t,n,-1)||Cl(i,e,t,n,1):!1}function Fi(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Cl(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:dt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Fi(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?dt(i):0}else return!1}}function dt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function oo(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Cd(i){return{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function ga(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function qd(i,e,t,n,r,s,o,O){let l=i.ownerDocument,a=l.defaultView||window;for(let h=i,c=!1;h&&!c;)if(h.nodeType==1){let f,d=h==l.body,p=1,m=1;if(d)f=Cd(a);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 Q=h.getBoundingClientRect();({scaleX:p,scaleY:m}=ga(h,Q)),f={left:Q.left,right:Q.left+h.clientWidth*p,top:Q.top,bottom:Q.top+h.clientHeight*m}}let g=0,$=0;if(r=="nearest")e.top<f.top?($=-(f.top-e.top+o),t>0&&e.bottom>f.bottom+$&&($=e.bottom-f.bottom+$+o)):e.bottom>f.bottom&&($=e.bottom-f.bottom+o,t<0&&e.top-$<f.top&&($=-(f.top+$-e.top+o)));else{let Q=e.bottom-e.top,k=f.bottom-f.top;$=(r=="center"&&Q<=k?e.top+Q/2-k/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-k+o)-f.top}if(n=="nearest"?e.left<f.left?(g=-(f.left-e.left+s),t>0&&e.right>f.right+g&&(g=e.right-f.right+g+s)):e.right>f.right&&(g=e.right-f.right+s,t<0&&e.left<f.left+g&&(g=-(f.left+g-e.left+s))):g=(n=="center"?e.left+(e.right-e.left)/2
`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),a=S.cursor(t?r.from:r.to)}if(l){if(!l(h))return O}else{if(!n)return a;l=n(h)}O=a}}function pp(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==qe.Space&&(r=o),r==o}}function mp(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return S.cursor(r,e.assoc);let o=e.goalColumn,O,l=i.contentDOM.getBoundingClientRect(),a=i.coordsAtPos(r,e.assoc||-1),h=i.documentTop;if(a)o==null&&(o=a.left-l.left),O=s<0?a.top:a.bottom;else{let d=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,i.defaultCharacterWidth*(r-d.from))),O=(s<0?d.top:d.bottom)+h}let c=l.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=O+(f+d)*s,m=Da(i,{x:c,y:p},!1,s);if(p<l.top||p>l.bottom||(s<0?m<r:m>r)){let g=i.docView.coordsForChar(m),$=!g||p<g.top?-1:1;return S.cursor(m,$,void 0,o)}}}function Nn(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,O)=>{if(e>s&&e<o){let l=n||t||(e-s<o-e?-1:1);e=l<0?s:o,n=l}});if(!n)return e}}function ys(i,e,t){let n=Nn(i.state.facet(ho).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:S.cursor(n,n<t.from?1:-1)}var Us=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&Wp(e.contentDOM.ownerDocument)}handleEvent(e){!Pp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=gp(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,O=n[s];O&&o!=!O.handlers.length&&(r.removeEventListener(s,this.handleEvent),O=null),O||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&Fa.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Na.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||$p.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,mi(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:z.safari&&!z.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 Nl(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){rt(t.state,r)}}}function gp(i){let e=Object.create(null);function t(n){return e[n]||(e
`&&i.lineWrapping&&(n&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:q.of([" "])}),t){if(z.ios&&i.inputState.flushIOSKey()||z.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&mi(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&mi(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&mi(i.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let O,l=()=>O||(O=Ap(i,t,n));return i.state.facet(Za).some(a=>a(i,t.from,t.to,o,l))||i.dispatch(l()),!0}else if(n&&!n.main.eq(r)){let o=!1,O="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),O=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:O}),!0}else return!1}function Ap(i,e,t){let n,r=i.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let O=s.from<e.from?r.sliceDoc(s.from,e.from):"",l=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(O+e.insert.sliceString(0,void 0,i.state.lineBreak)+l))}else{let O=r.changes(e),l=t&&t.main.to<=O.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let a=i.state.sliceDoc(e.from,e.to),h,c=t&&La(i,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-p}}else h=i.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:O,range:l||p.map(O)};let m=p.to-f,g=m-a.length;if(p.to-p.from!=d||i.state.sliceDoc(g,m)!=a||p.to>=h.from&&p.from<=h.to)return{range:p};let $=r.changes({from:g,to:m,insert:e.insert}),Q=p.to-s.to;return{changes:$,range:l?S.range(Math.max(0,l.anchor+Q),Math.max(0,l.head+Q)):p.map($)}})}else n={changes:O,selection:l&&r.selection.replaceRange(l)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:o,scrollIntoView:!0})}function jp(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,O=e.length;for(;o>0&&O>0&&i.charCodeAt(o-1)==e.charCodeAt(O-1);)o--,O--;if(n=="end"){let l=Math.max(0,s-Math.min(o,O));t-=o+l-s}if(o<s&&i.length<e.length){let l=t<=s&&t>=o?s-t:0;s-=l,O=s+(O-o),o=s}else if(O<s){let l=t<=s&&t>=O?s-t:0;s-=l,o=s+(o-O),O=s}return{from:s,toA:o,toB:O}}function Ep(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new hr(t,n)),(r!=t||s!=n)&&e.push(new hr(r,s))),e}function Gp(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?S.single(t+e,n+e):null}var Mp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},bs=z.ie&&z.ie_version<=11,Js=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new ws,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 n of t)this.queue.push(n);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),bs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChan
`&&(t="");else{let n=t.indexOf(`
`);n>-1&&(t=t.slice(0,n))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=n||(t=t.slice(0,s-(n-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,O=this.lineAfter(o);t+=O,n=o+O.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(n>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(n,s,-1),n+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,n,r),s}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new wr(t,e?e.state.tabSize:4,e?Wt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let O=Dh(s.token,o,this.state);if(O&&(r=this.emitToken(this.lang.tokenTable.resolve(O),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=Y.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Fm,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new Y(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Y(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Dh(i,e,t){e.start=e.pos;for(let n=0;n<10;n++){let r=i(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var Go=Object.create(null),hn=[F.none],Fm=new pt(hn),Yh=[],Vh=Object.create(null),Nh=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Nh[i]=Fh(Go,e);var vr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Nh)}resolve(e){return e?this.table[e]||(this.table[e]=Fh(this.extra,e)):0}},Hm=new vr(Go);function Ro(i,e){Yh.indexOf(i)>-1||(Yh.push(i),console.warn(e))}function Fh(i,e){let t=[];for(let O of e.split(" ")){let l=[];for(let a of O.split(".")){let h=i[a]||u[a];h?typeof h=="function"?l.length?l=l.map(h):Ro(a,`Modifier ${a} used at start of tag`):l.length?Ro(a,`Tag ${a} used as modifier`):l=Array.isArray(h)?h:[h]:Ro(a,`Unknown highlighting tag ${a}`)}for(let a of l)t.push(a)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(O=>O.id),s=Vh[r];if(s)return s.id;let o=Vh[r]=F.define({id:hn.length,name:n,props:[ne({[n]:t})]});return hn.push(o),o.id}function Km(i){let e=F.define({id:hn.length,name:"Document",props:[$t.add(()=>i)],top:!0});return hn.push(e),e}var Jm=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Fo(i.state,t.from);return n.line?eg(i):n.block?ig(i):!1};function No(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}var eg=No(sg,0);var tg=No(rc,0);var ig=No((i,e)=>rc(i,e,rg(e)),0);function Fo(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var un=50;function ng(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-un,n),o=i.sliceDoc(r,r+un),O=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,a=s.length-O;if(s.slice(a-e.length,a)==e&&o.slice(l,l+t.length)==t)return{open:{pos:n-O,margin:O&&1},close:{pos:r+l,margin:l&&1}};let h,c;r-n<=2*un?h=c=i.sliceDoc(n,r):(h=i.sliceDoc(n,n+un),c=i.sliceDoc(r-un,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-t.length;return h.slice(f,f+e.length)==e&&c.sli
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),Pe("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Pe(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),Pe(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),Pe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Pe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],kS=wf.concat([Pe("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Pe("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Pe("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),bf=new Si,kf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Sn(i){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,i),!0}}var vS=["FunctionDeclaration"],TS={FunctionDeclaration:Sn("function"),ClassDeclaration:Sn("class"),ClassExpression:()=>!0,EnumDeclaration:Sn("constant"),TypeAliasDeclaration:Sn("type"),NamespaceDeclaration:Sn("namespace"),VariableDefinition(i,e){i.matchContext(vS)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function vf(i,e){let t=bf.get(e);if(t)return t;let n=[],r=!0;function s(o,O){let l=i.sliceString(o.from,o.to);n.push({label:l,type:O})}return e.cursor(_.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let O=TS[o.name];if(O&&O(o,s)||kf.has(o.name))return!1}else if(o.to-o.from>8192){for(let O of vf(i,o.node))n.push(O);return!1}}),bf.set(e,n),n}var Pf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Tf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function zS(i){let e=A(i.state).resolveInner(i.pos,-1);if(Tf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Pf.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let r=e;r;r=r.parent)kf.has(r.name)&&(n=n.concat(vf(i.state.doc,r)));return{options:n,from:t?e.from:i.pos,validFor:Pf}}var Ke=de.define({name:"javascript",parser:pf.configure({props:[ye.add({IfStatement:Ze({except:/^\s*({|else\b)/}),TryStatement:Ze({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ah,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:n?1:2)*i.unit},Block:zr({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ze({except:/^{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),be.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Zt,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),zf={test:i=>/^JSX/.test(i.name),facet:Pi({commentTokens:{block:{open:"{/*",close:"*/}"}}})},$O=Ke.configure({dialect:"ts"},"typescript"),SO=Ke.configure({dialect:"jsx",props:[Tr.add(i=>i.isTop?[zf]:void 0)]}),QO=Ke.configure({dialect:"jsx ts",props:[Tr.add(i=>i.isTop?[zf]:void 0)]},"typescript"),Xf=i=>({label:i,type:"keyword"}),Wf="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Xf),XS=Wf.concat(["declare","implements","private","protected","public"].map(Xf));function ei(i={}){let e=i.jsx?i.typescript?QO:SO:i.typescript?$O:Ke,t=i.typescript?kS.concat(XS):wf.concat(Wf);return new re(e,[Ke.data.of({autocomplete:Sf(Tf,$f(t))}),Ke.data.of({autocomplete:zS}),i.jsx?ZS:[]])}function WS(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function xf(i,e,t=i.length){for(let n=e?.firstChild;n;n=n.nextSiblin
`+t.scrub(),s=this.advance(r);return s>-1&&s<r.length?this.complete(e,n,s):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Pn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,U(y.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Cu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(U(y.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Yu(e,Pn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Pn(e,this.pos),n=0;if(t>this.pos){let r=Vu(e,t,this.start);if(r){let s=RO(e,r.to-this.start);s>0&&(this.nextStage(r),n=s)}}return n||(n=RO(e,this.pos)),n>0&&n<e.length?n:-1}else return RO(e,this.pos)}}};function RO(i,e){for(;e<i.length;e++){let t=i.charCodeAt(e);if(t==10)break;if(!Me(t))return-1}return e}var _O=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:ku(t),s=t.next;if(r<0)return!1;let o=U(y.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,U(s==61?y.SetextHeading1:y.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}},PQ={LinkReference(i,e){return e.content.charCodeAt(0)==91?new UO(e):null},SetextHeading(){return new _O}},xQ=[(i,e)=>wu(e)>=0,(i,e)=>bu(e)>=0,(i,e)=>Pu(e)>=0,(i,e)=>BO(e,i,!0)>=0,(i,e)=>DO(e,i,!0)>=0,(i,e)=>LO(e,i,!0)>=0,(i,e)=>zu(e,i,!0)>=0],wQ={text:"",end:0},AO=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new VO,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Dr.create(y.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new MO(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(;e.depth<this.stack.length;)this.finishContext();for(let n of e.markers)this.addNode(n.type,n.from,n.to);if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let r=n(this,e);if(r!=!1){if(r==!0)return null;e.forward();continue e}}break}let t=new YO(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let r=n(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break e}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
`+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=qu(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=wQ;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let n=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<t.end;){r++;let s=this.ranges[r].from,o=this.lineChunkAt(s);t.end=s+o.length,t.text=t.text.slice(0,this.ranges[r-1].to-n)+o,n=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let r=this.stack[e.depth],s=this.parser.skipContextMarkup[r.type];if(!s)throw new Error("Unhandled block context "+y[r.type]);if(!s(r,this,e))break;e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
`?"":t;else{let r=t.indexOf(`
`);n=r<0?t:t.slice(0,r)}return e+n.length>this.to?n.slice(0,this.to-e):n}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=Dr.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){typeof e=="number"&&(e=new Y(this.parser.nodeSet.types[e],Xi,Xi,(n??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(GO(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Xu(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let n of e.parsers)if(n.finish(this,e))return;let t=GO(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(y.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return typeof e=="string"?U(this.parser.getNodeType(e),t,n,r):new Fr(e,t)}get buffer(){return new Nr(this.parser.nodeSet)}};function Xu(i,e,t,n,r){let s=i[e].to,o=[],O=[],l=t.from+n;function a(h,c){for(;c?h>=s:h>s;){let f=i[e+1].from-s;n+=f,h+=f,e++,s=i[e].to}}for(let h=t.firstChild;h;h=h.nextSibling){a(h.from+n,!0);let c=h.from+n,f,d=r.get(h.tree);d?f=d:h.to+n>s?(f=Xu(i,e,h,n,r),a(h.to+n,!1)):f=h.toTree(),o.push(f),O.push(c-l)}return a(t.to+n,!1),new Y(t.type,o,O,t.to+n-l,t.tree?t.tree.propValues:void 0)}var wn=class i extends gt{constructor(e,t,n,r,s,o,O,l,a){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=o,this.inlineParsers=O,this.inlineNames=l,this.wrappers=a,this.nodeTypes=Object.create(null);for(let h of e.types)this.nodeTypes[h.name]=h.id}createParse(e,t,n){let r=new AO(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let t=jO(e);if(!t)return this;let{nodeSet:n,skipContextMarkup:r}=this,s=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),O=this.blockNames.slice(),l=this.inlineParsers.slice(),a=this.inlineNames.slice(),h=this.endLeafBlock.slice(),c=this.wrappers;if(yn(t.defineNodes)){r=Object.assign({},r);let f=n.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:g,composite:$,style:Q}=typeof p=="string"?{name:p}:p;if(f.some(x=>x.name==m))continue;$&&(r[f.length]=(x,w,Z)=>$(w,Z,x.value));let k=f.length,b=$?["Block","BlockContext"]:g?k>=y.ATXHeading1&&k<=y.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(F.define({id:k,name:m,props:b&&[[R.group,b]]})),Q&&(d||(d={}),Array.isArray(Q)||Q instanceof je?d[m]=Q:Object.assign(d,Q))}n=new pt(f),d&&(n=n.extend(ne(d)))}if(yn(t.props)&&(n=n.extend(...t.props)),yn(t.remove))for(let f of t.remove){let d=this.blockNames.indexOf(f),p=this.inlineNames.indexOf(f);d>-1&&(s[d]=o[d]=void 0),p>-1&&(l[p]=void 0)}if(yn(t.parseBlock))for(let f of t.parseBlock){let d=O.indexOf(f.name);if(d>-1)s[d]=f.parse,o[d]=f.leaf;else{let p=f.before?Br(O,f.before):f.after?Br(O,f.after)+1:O.length-1;s.splice(p,0,f.parse),o.splice(p,0,f.leaf),O.splice(p,0,f.name)}f.endLeaf&&h.push(f.endLeaf)}if(yn(t.parseInline))for(let f of t.parseInline){let d=a.indexOf(f.name);if(d>-1)l[d]=f.parse;else{let p=f.before?Br(a,f.before):f.after?Br(a,f.after)+1:a.length-1;l.splice(p,0,f.parse),a.splice(p,0,f.name)}}return t.wrap&&(c=c.concat(t.wrap)),new i(n,s,o,O,h,r,l,a,c)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new EO(this,e,t);e:for(let r=t;r<n.end;){let s=n.char(r);for(let o of this.inlineParsers)if(o){let O=o(n,s,r);if(O>=0){r=O;continue e}}r++}return n.resolv
`;)s--;this.fragmentEnd=s?s-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(R.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,O=e.block.children.length,l=o,a=O;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let h=qu(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,h);else{let c=new Y(e.parser.nodeSet.types[y.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(c,t.tree),e.addNode(c,h)}if(t.type.is("Block")&&(vQ.indexOf(t.type.id)<0?(o=t.to-n,O=e.block.children.length):(o=l,O=a,l=t.to-n,a=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>O;)e.block.children.pop(),e.block.positions.pop();return o-s}};function qu(i,e){let t=i;for(let n=1;n<e.length;n++){let r=e[n-1].to,s=e[n].from;r<i&&(t-=s-r)}return t}var TQ=ne({"Blockquote/...":u.quote,HorizontalRule:u.contentSeparator,"ATXHeading1/... SetextHeading1/...":u.heading1,"ATXHeading2/... SetextHeading2/...":u.heading2,"ATXHeading3/...":u.heading3,"ATXHeading4/...":u.heading4,"ATXHeading5/...":u.heading5,"ATXHeading6/...":u.heading6,"Comment CommentBlock":u.comment,Escape:u.escape,Entity:u.character,"Emphasis/...":u.emphasis,"StrongEmphasis/...":u.strong,"Link/... Image/...":u.link,"OrderedList/... BulletList/...":u.list,"BlockQuote/...":u.quote,"InlineCode CodeText":u.monospace,URL:u.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":u.processingInstruction,"CodeInfo LinkLabel":u.labelName,LinkTitle:u.string,Paragraph:u.content}),Uu=new wn(new pt(Wu).extend(TQ),Object.keys(Lr).map(i=>Lr[i]),Object.keys(Lr).map(i=>PQ[i]),Object.keys(Lr),xQ,yu,Object.keys(ZO).map(i=>ZO[i]),Object.keys(ZO),[]);function zQ(i,e,t){let n=[];for(let r=i.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:t;if(o>s&&n.push({from:s,to:o}),!r)break;s=r.to}return n}function _u(i){let{codeParser:e,htmlParser:t}=i;return{wrap:Qi((r,s)=>{let o=r.type.id;if(e&&(o==y.CodeBlock||o==y.FencedCode)){let O="";if(o==y.FencedCode){let a=r.node.getChild(y.CodeInfo);a&&(O=s.read(a.from,a.to))}let l=e(O);if(l)return{parser:l,overlay:a=>a.type.id==y.CodeText}}else if(t&&(o==y.HTMLBlock||o==y.HTMLTag))return{parser:t,overlay:zQ(r.node,r.from,r.to)};return null})}}var XQ={resolve:"Strikethrough",mark:"StrikethroughMark"},WQ={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":u.strikethrough}},{name:"StrikethroughMark",style:u.processingInstruction}],parseInline:[{name:"Strikethrough",parse(i,e,t){if(e!=126||i.char(t+1)!=126||i.char(t+2)==126)return-1;let n=i.slice(t-1,t),r=i.slice(t+2,t+3),s=/\s|^$/.test(n),o=/\s|^$/.test(r),O=kn.test(n),l=kn.test(r);return i.addDelimiter(XQ,t,t+2,!o&&(!l||s||O),!s&&(!O||o||l))},after:"Emphasis"}]};function xn(i,e,t=0,n,r=0){let s=0,o=!0,O=-1,l=-1,a=!1,h=()=>{n.push(i.elt("TableCell",r+O,r+l,i.parser.parseInline(e.slice(O,l),r+O)))};for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);f==124&&!a?((!o||O>-1)&&s++,o=!1,n&&(O>-1&&h(),n.push(i.elt("TableDelimiter",c+r,c+r+1))),O=l=-1):(a||f!=32&&f!=9)&&(O<0&&(O=c),l=c+1),a=!a&&f==92}return O>-1&&(s++,n&&h()),s}function du(i,e){for(let t=e;t<i.length;t++){let n=i.charCodeAt(t);if(n==124)return!0;n==92&&t++}return!1}var Au=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Hr=class{constructor(){this.rows=null}nextLine(e,t,n){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&Au.test(r=t.text.slice(t.pos))){let s=[];xn(e,n.content,0,s,n.start)==xn(e,r,t.pos)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,s),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let r=[];xn(e,t.text,t.pos,r,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,r))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,
`);let t=i.textContent.trimEnd(),n="";e!==null&&(n=e.className.replace("language-",""));let r=document.createElement("div");i.parentNode.insertBefore(r,i);let s=e.getAttribute("dir")||i.getAttribute("dir")||"";s&&r.setAttribute("dir",s);let o=Ri("content-code-block",{parent:r,doc:t,extensions:tO(r)});new _t(o).setMode(n,t),i.remove(),Ub(o)}function xP(i){let e=i.querySelectorAll("pre");for(let t of e)Sd(t)}function wP(){let i=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of i)Sd(e)}function kP(i,e,t,n){let r=Ri("content-code-block",{parent:i,doc:t,extensions:tO(i),root:e}),s=new _t(r);return s.setMode(n,t),s}function vP(i,e){let t=i.textContent,n={parent:i.parentElement,doc:t,extensions:[...qr(i.parentElement)]},r=new _t(Ri("code-editor",n));return r.setMode(e,t),i.style.display="none",r}function TP(i,e){let t=i.value,n={parent:i.parentElement,doc:t,extensions:[...qr(i.parentElement),v.updateListener.of(o=>{o.docChanged&&(i.value=o.state.doc.toString())})]},r=Ri("code-input",n),s=new _t(r);return s.setMode(e,t),i.style.display="none",s}function zP(i,e,t,n){let r=i.textContent,s={parent:i.parentElement,doc:r,extensions:[ot.of(n),...qr(i.parentElement),v.updateListener.of(O=>{e(O)}),v.domEventHandlers(t)]};window.$events.emitPublic(i,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let o=Ri("markdown-editor",s);return new _t(o).setMode("markdown",""),i.style.display="none",o}export{wP as highlight,xP as highlightWithin,TP as inlineEditor,zP as markdownEditor,vP as popupEditor,kP as wysiwygView};
//# sourceMappingURL=code.js.map