bookstack/public/dist/code.js

31 lines
596 KiB
JavaScript
Raw Normal View History

var U=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){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),ni.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),ni.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 _t(this),s=new _t(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 _t(this,e)}iterRange(e,t=this.length){return new wn(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 kn(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 ve(e):ni.from(ve.split(e,[]))}},ve=class i extends U{constructor(e,t=sd(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 Jr(r,o,n,O);r=o+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(rl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let O=n.pop(),o=xn(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);let r=xn(this.text,xn(n.text,rl(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):ni.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){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}},ni=class i extends U{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(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=`
`){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 ve(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 ve&&l&&(p=h[h.length-1])instanceof ve&&d.lines+p.lines<=32?(l+=d.lines,a+=d.length+1,h[h.length-1]=new ve(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)}};U.empty=new ve([""],0);function sd(i){let e=-1;for(let t of i)e+=t.length+1;return e}function xn(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 rl(i,e,t){return xn(i,[""],e,t)}var _t=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 ve?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 ve?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 ve){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 ve?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)}},wn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new _t(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!=""}},kn=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.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"&&(U.prototype[Symbol.iterator]=function(){return this.iter()},_t.prototype[Symbol.iterator]=wn.prototype[Symbol.iterator]=kn.prototype[Symbol.iterator]=function(){return this});var Jr=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}},ri="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<ri.length;i++)ri[i]+=ri[i-1];function Od(i){for(let e=1;e<ri.length;e+=2)if(ri[e]>i)return ri[e-1]<=i;return!1}function sl(i){return i>=127462&&i<=127487}var Ol=8205;function ue(i,e,t=!0,n=!0){return(t?fl:od)(i,e,n)}function fl(i,e,t){if(e==i.length)return e;e&&ul(i.charCodeAt(e))&&dl(i.charCodeAt(e-1))&&e--;let n=si(i,e);for(e+=Vi(n);e<i.length;){let r=si(i,e);if(n==Ol||r==Ol||t&&Od(r))e+=Vi(r),n=r;else if(sl(r)){let s=0,O=e-2;for(;O>=0&&sl(si(i,O));)s++,O-=2;if(s%2==0)break;e+=2}else break}return e}function od(i,e,t){for(;e>0;){let n=fl(i,e-2,t);if(n<e)return n;e--}return 0}function ul(i){return i>=56320&&i<57344}function dl(i){return i>=55296&&i<56320}function si(i,e){let t=i.charCodeAt(e);if(!dl(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return ul(n)?(t-55296<<10)+(n-56320)+65536:t}function Vi(i){return i<65536?1:2}var Kr=/\r\n?|\n/,ae=function(i){r
`}get readOnly(){return this.facet(bl)}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(ml))for(let O of s(this,t,n))Object.prototype.hasOwnProperty.call(O,e)&&r.push(O[e]);return r}charCategorizer(e){return $d(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=ue(t,O,!1);if(s(t.slice(l,O))!=Ze.Word)break;O=l}for(;o<r;){let l=ue(t,o);if(s(t.slice(o,l))!=Ze.Word)break;o=l}return O==o?null:Q.range(O+n,o+n)}};E.allowMultipleSelections=gl;E.tabSize=W.define({combine:i=>i.length?i[0]:4});E.lineSeparator=Ql;E.readOnly=bl;E.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])}});E.languageData=ml;E.changeFilter=Sl;E.transactionFilter=yl;E.transactionExtender=Pl;gt.reconfigure=j.define();function Qt(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 Ge=class{eq(e){return this==e}range(e,t=e){return Ci.create(e,t,this)}};Ge.prototype.startSide=Ge.prototype.endSide=0;Ge.prototype.point=!1;Ge.prototype.mapMode=ae.TrackDel;var Ci=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 os(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var ls=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}}},L=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(os)),this.isEmpty)return t.length?i.of(t):this;let o=new zn(this,null,-1).goto(0),l=0,a=[],h=new jt;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(Ci.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=vl[kl]||1;return vl[kl]=e+1,fs+e.toString(36)}static mount(e,t){(e[us]||new ds(e)).mount(Array.isArray(t)?t:[t])}},Tl=new Map,ds=class{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=Tl.get(t);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[us]=r;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Tl.set(t,this)}else{this.styleTag=t.createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[us]=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}}};var at={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:"'"},li={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Xl=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),fP=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),gd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Sd=gd||Xl&&+Xl[1]<57;for(te=0;te<10;te++)at[48+te]=at[96+te]=String(te);var te;for(te=1;te<=24;te++)at[te+111]="F"+te;var te;for(te=65;te<=90;te++)at[te]=String.fromCharCode(te+32),li[te]=String.fromCharCode(te);var te;for(Rn in at)li.hasOwnProperty(Rn)||(li[Rn]=at[Rn]);var Rn;function zl(i){var e=Sd&&(i.ctrlKey||i.altKey||i.metaKey)||Qd&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?li:at)[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 Bn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Ss(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function yd(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function An(i,e){if(!e.anchorNode)return!1;try{return Ss(i,e.anchorNode)}catch{return!1}}function Ii(i){return i.nodeType==3?Et(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Dn(i,e,t,n){return t?Wl(i,e,t,n,-1)||Wl(i,e,t,n,1):!1}function Ln(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Wl(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:bt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Ln(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?bt(i):0}else return!1}}function bt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function tO(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Pd(i){return{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function bd(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;if(d)f=Pd(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 $=h.getBoundingClientRect();f={left:$.left,right:$.left+h.clientWidth,top:$.top,bottom:$.top+h.clientHeight}}let p=0,m=0;if(r=="nearest")e.top<f.top?(m=-(f.top-e.top+O),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+O)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+O,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+O)));else{let $=e.bottom-e.top,g=f.bottom-f.top;m=(r=="center"&&$<=g?e.top+$/2-g/2:r=="start"||r=="center"&&t<0?e.top-O:e.bottom-g+O)-f.top}if(n=="nearest"?e.left<f.left?(p=-(f.left-e.left+s),t>0&&e.right>f.right+p&&(p=e.right-f.right+p+s)):e.right>f.right&&(p=e.right-f.right+s,t<0&&e.left<f.left+p&&(p=-(f.left+p-e.left+s))):p=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==o?e.left-s:e.right-(f.right-f.left)+s)-f.left,p||m)if(d)a.scrollBy(p,m);else{let $=0,g=0;if(m){let b=h.scrollTop;h.scrollTop+=m,g=h.scrollTop-b}if(p){let b=h.scrollLeft;h.scrollLeft+=p,$=h.scrollLeft-b}e={left:e.left-$,top
`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),a=Q.cursor(t?r.from:r.to)}if(l){if(!l(h))return o}else{if(!n)return a;l=n(h)}o=a}}function Fd(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let O=n(s);return r==Ze.Space&&(r=O),r==O}}function Jd(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return Q.cursor(r,e.assoc);let O=e.goalColumn,o,l=i.contentDOM.getBoundingClientRect(),a=i.coordsAtPos(r),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=Ya(i,{x:c,y:p},!1,s);if(p<l.top||p>l.bottom||(s<0?m<r:m>r))return Q.cursor(m,e.assoc,void 0,O)}}function jn(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 ms(i,e,t){let n=jn(i.state.facet(sO).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:Q.cursor(n,n<t.from?1:-1)}var Zs=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let t=(n,r)=>{this.ignoreDuringComposition(r)||r.type=="keydown"&&this.keydown(e,r)||(this.mustFlushObserver(r)&&e.observer.forceFlush(),this.runCustomHandlers(r.type,e,r)?r.preventDefault():n(e,r))};for(let n in ie){let r=ie[n];e.contentDOM.addEventListener(n,s=>{Il(e,s)&&t(r,s)},qs[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(ie.mousedown,n),!n.defaultPrevented&&n.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(ie.drop,n)}),X.chrome&&X.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,X.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let r;this.customHandlers=[];for(let s of t)if(r=(n=s.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:r});for(let O in r)this.registeredEvents.indexOf(O)<0&&O!="scroll"&&(this.registeredEvents.push(O),e.contentDOM.addEventListener(O,o=>{Il(e,o)&&this.runCustomHandlers(O,e,o)&&o.preventDefault()}))}}runCustomHandlers(e,t,n){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,n,t)||n.defaultPrevented)return!0}catch(O){Ke(t.state,O)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let r=n.handlers.scroll;if(r)try{r.call(n.plugin,t,e)}catch(s){Ke(e.state,s)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(t.keyCode!=27&&Aa.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0),X.android&&X.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let n;return X.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((n=_a.find(r=>r.keyCode==t.keyCode))&&!t.ctrlKey||Kd.i
`&&i.lineWrapping&&(n&&(n=Q.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:U.of([" "])}),t){let O=i.state;if(X.ios&&i.inputState.flushIOSKey(i)||X.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&ui(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)&&ui(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&ui(i.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();if(i.state.facet(ka).some(h=>h(i,t.from,t.to,o)))return!0;i.inputState.composing>=0&&i.inputState.composing++;let l;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&i.inputState.composing<0){let h=r.from<t.from?O.sliceDoc(r.from,t.from):"",c=r.to>t.to?O.sliceDoc(t.to,r.to):"";l=O.replaceSelection(i.state.toText(h+t.insert.sliceString(0,void 0,i.state.lineBreak)+c))}else{let h=O.changes(t),c=n&&n.main.to<=h.newLength?n.main:void 0;if(O.selection.ranges.length>1&&i.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let f=i.state.sliceDoc(t.from,t.to),d=qa(i)||i.state.doc.lineAt(r.head),p=r.to-t.to,m=r.to-r.from;l=O.changeByRange($=>{if($.from==r.from&&$.to==r.to)return{changes:h,range:c||$.map(h)};let g=$.to-p,b=g-f.length;if($.to-$.from!=m||i.state.sliceDoc(b,g)!=f||d&&$.to>=d.from&&$.from<=d.to)return{range:$};let k=O.changes({from:b,to:g,insert:t.insert}),y=$.to-r.to;return{changes:k,range:c?Q.range(Math.max(0,c.anchor+y),Math.max(0,c.head+y)):$.map(k)}})}else l={changes:h,selection:c&&O.selection.replaceRange(c)}}let a="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,a+=".compose",i.inputState.compositionFirstChange&&(a+=".start",i.inputState.compositionFirstChange=!1)),i.dispatch(l,{scrollIntoView:!0,userEvent:a}),!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 gp(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 Qp(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 Fn(t,n)),(r!=t||s!=n)&&e.push(new Fn(r,s))),e}function Sp(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?Q.single(t+e,n+e):null}var yp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},gs=X.ie&&X.ie_version<=11,Ns=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new ys,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.resizeContent=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);(X.ie&&X.ie_version<=11||X.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()}),gs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typ
`&&(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 yr(t,e?e.state.tabSize:4,e?Xt(e.state):2);if(O.eol())s.blankLine(this.state,O.indentUnit);else for(;!O.eol();){let o=Uh(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=C.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:k$,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new C(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 C(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Uh(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 qO=Object.create(null),rn=[F.none],k$=new ct(rn),xh=[],Yh=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"]])Yh[i]=_h(qO,e);var br=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Yh)}resolve(e){return e?this.table[e]||(this.table[e]=_h(this.extra,e)):0}},v$=new br(qO);function wO(i,e){xh.indexOf(i)>-1||(xh.push(i),console.warn(e))}function _h(i,e){let t=null;for(let s of e.split(".")){let O=i[s]||u[s];O?typeof O=="function"?t?t=O(t):wO(s,`Modifier ${s} used at start of tag`):t?wO(s,`Tag ${s} used as modifier`):t=O:wO(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),r=F.define({id:rn.length,name:n,props:[se({[n]:t})]});return rn.push(r),r.id}function T$(i){let e=F.define({id:rn.length,name:"Document",props:[dt.add(()=>i)],top:!0});return rn.push(e),e}var X$=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=EO(i.state,t.from);return n.line?z$(i):n.block?R$(i):!1};function GO(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 z$=GO(C$,0);var W$=GO(Dh,0);var R$=GO((i,e)=>Dh(i,e,Z$(e)),0);function EO(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var on=50;function V$(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-on,n),O=i.sliceDoc(r,r+on),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*on?h=c=i.sliceDoc(n,r):(h=i.sliceDoc(n,n+on),c=i.sliceDoc(r-on,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.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function Z$(i){let e=[];for(let
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),Ae("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Ae(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),Ae(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),Ae('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ae('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],mf=new pi,Sf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function fn(i){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,i),!0}}var eQ=["FunctionDeclaration"],tQ={FunctionDeclaration:fn("function"),ClassDeclaration:fn("class"),ClassExpression:()=>!0,EnumDeclaration:fn("constant"),TypeAliasDeclaration:fn("type"),NamespaceDeclaration:fn("namespace"),VariableDefinition(i,e){i.matchContext(eQ)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function yf(i,e){let t=mf.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(A.IncludeAnonymous).iterate(O=>{if(r)r=!1;else if(O.name){let o=tQ[O.name];if(o&&o(O,s)||Sf.has(O.name))return!1}else if(O.to-O.from>8192){for(let o of yf(i,O.node))n.push(o);return!1}}),mf.set(e,n),n}var gf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Pf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function iQ(i){let e=_(i.state).resolveInner(i.pos,-1);if(Pf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&gf.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let r=e;r;r=r.parent)Sf.has(r.name)&&(n=n.concat(yf(i.state.doc,r)));return{options:n,from:t?e.from:i.pos,validFor:gf}}var ot=pe.define({name:"javascript",parser:hf.configure({props:[Se.add({IfStatement:We({except:/^\s*({|else\b)/}),TryStatement:We({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Xh,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:wr({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":We({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}}),ke.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:"$"}}),bf={test:i=>/^JSX/.test(i.name),facet:Qi({commentTokens:{block:{open:"{/*",close:"*/}"}}})},co=ot.configure({dialect:"ts"},"typescript"),fo=ot.configure({dialect:"jsx",props:[xr.add(i=>i.isTop?[bf]:void 0)]}),uo=ot.configure({dialect:"jsx ts",props:[xr.add(i=>i.isTop?[bf]:void 0)]},"typescript"),nQ="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(i=>({label:i,type:"keyword"}));function Ft(i={}){let e=i.jsx?i.typescript?uo:fo:i.typescript?co:ot;return new Oe(e,[ot.data.of({autocomplete:df(Pf,uf(Kg.concat(nQ)))}),ot.data.of({autocomplete:iQ}),i.jsx?oQ:[]])}function rQ(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 Qf(i,e,t=i.length){for(let n=e?.firstChild;n;n=n.nextSibling)if(n.name=="JSXIdentifier"||n.name=="JSXBuiltin"||n.name=="JSXNamespacedName"||n.name=="JSXMemberExpression")return i.sliceString(n.from,Math.min(n.to,t));return""}function sQ(i){return i&&(i.name=="JSXEndTag"||i.name=="JSXSelfCloseEndTag")}var OQ=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oQ=v.inputHandler.of((i,e,t,n)=>{if((OQ?i.composing:i.compositio
`+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)&&$n(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,Y(S.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Pu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Y(S.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Su(e,$n(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=$n(e,this.pos),n=0;if(t>this.pos){let r=yu(e,t,this.start);if(r){let s=ko(e,r.to-this.start);s>0&&(this.nextStage(r),n=s)}}return n||(n=ko(e,this.pos)),n>0&&n<e.length?n:-1}else return ko(e,this.pos)}}};function ko(i,e){for(;e<i.length;e++){let t=i.charCodeAt(e);if(t==10)break;if(!je(t))return-1}return e}var Vo=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:fu(t),s=t.next;if(r<0)return!1;let O=Y(S.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,Y(s==61?S.SetextHeading1:S.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),O])),!0}finish(){return!1}},HQ={LinkReference(i,e){return e.content.charCodeAt(0)==91?new Ro(e):null},SetextHeading(){return new Vo}},FQ=[(i,e)=>cu(e)>=0,(i,e)=>lu(e)>=0,(i,e)=>au(e)>=0,(i,e)=>jo(e,i,!0)>=0,(i,e)=>Go(e,i,!0)>=0,(i,e)=>Ao(e,i,!0)>=0,(i,e)=>pu(e,i,!0)>=0],JQ={text:"",end:0},Zo=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new Xo,this.atEnd=!1,this.dontInject=new Set,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Ir.create(S.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Yo(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 To(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);if(!t)return!1;let n=t,r=this.absoluteLineStart+t;for(let s=1;s<this.ranges.length;s++){let O=this.ranges[s-1].to,o=this.ranges[s].from;O>=this.lineStart&&o<r&&(n-=o-O)}return this.lineStart+=n,this.absoluteLineStart+=t,this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0}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=JQ;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 "+S[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=Ir.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 C(this.parser.nodeSet.types[e],Ti,Ti,(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(Uo(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?$u(this.ranges,0,e.topNode,this.ranges[0].from,this.dontInject):e}finishLeaf(e){for(let n of e.parsers)if(n.finish(this,e))return;let t=Uo(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(S.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return typeof e=="string"?Y(this.parser.getNodeType(e),t,n,r):new Dr(e,t)}get buffer(){return new Br(this.parser.nodeSet)}};function $u(i,e,t,n,r){if(r.has(t.tree))return t.tree;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;h.to+n>s?(f=$u(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 C(t.type,O,o,t.to+n-l,t.tree?t.tree.propValues:void 0)}var gn=class i extends ut{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 Zo(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let t=Co(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(dn(t.defineNodes)){r=Object.assign({},r);let f=n.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:$,composite:g,style:b}=typeof p=="string"?{name:p}:p;if(f.some(w=>w.name==m))continue;g&&(r[f.length]=(w,x,V)=>g(x,V,w.value));let k=f.length,y=g?["Block","BlockContext"]:$?k>=S.ATXHeading1&&k<=S.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(F.define({id:k,name:m,props:y&&[[R.group,y]]})),b&&(d||(d={}),Array.isArray(b)||b instanceof Ue?d[m]=b:Object.assign(d,b))}n=new ct(f),d&&(n=n.extend(se(d)))}if(dn(t.props)&&(n=n.extend(...t.props)),dn(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(dn(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?Mr(o,f.before):f.after?Mr(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(dn(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?Mr(a,f.before):f.after?Mr(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 qo(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.reso
`;)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}if(e.dontInject.add(t.tree),e.addNode(t.tree,t.from-n),t.type.is("Block")&&(eS.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}},tS=se({"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}),bu=new gn(new ct(mu).extend(tS),Object.keys(Er).map(i=>Er[i]),Object.keys(Er).map(i=>HQ[i]),Object.keys(Er),FQ,ou,Object.keys(vo).map(i=>vo[i]),Object.keys(vo),[]);function iS(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 xu(i){let{codeParser:e,htmlParser:t}=i;return{wrap:$i((r,s)=>{let O=r.type.id;if(e&&(O==S.CodeBlock||O==S.FencedCode)){let o="";if(O==S.FencedCode){let a=r.node.getChild(S.CodeInfo);a&&(o=s.read(a.from,a.to))}let l=e(o);if(l)return{parser:l,overlay:a=>a.type.id==S.CodeText}}else if(t&&(O==S.HTMLBlock||O==S.HTMLTag))return{parser:t,overlay:iS(r.node,r.from,r.to)};return null})}}var nS={resolve:"Strikethrough",mark:"StrikethroughMark"},rS={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=Qn.test(n),l=Qn.test(r);return i.addDelimiter(nS,t,t+2,!O&&(!l||s||o),!s&&(!o||O||l))},after:"Emphasis"}]};function mn(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 Ou(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 wu=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Lr=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)&&wu.test(r=t.text.slice(t.pos))){let s=[];mn(e,n.content,0,s,n.start)==mn(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=[];mn(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,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0):!1}},sS={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":u.heading}},"TableRow",{name:"TableCell",style:u.content},{name:"TableDelimiter",style:u.processingInstruction}
`);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=zi({parent:r,doc:t,extensions:LO(r)});new Ct(s).setMode(n,t),i.remove(),aP(s)}function L0(i){let e=i.querySelectorAll("pre");for(let t of e)rd(t)}function N0(){let i=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of i)rd(e)}function H0(i,e,t,n){let r=zi({parent:i,doc:t,extensions:LO(i),root:e}),s=new Ct(r);return s.setMode(n,t),s}function F0(i,e){let t=i.textContent,n={parent:i.parentElement,doc:t,extensions:[...Zr(i.parentElement),v.updateListener.of(s=>{s.docChanged})]},r=new Ct(zi(n));return r.setMode(e,t),i.style.display="none",r}function J0(i,e){let t=i.value,n={parent:i.parentElement,doc:t,extensions:[...Zr(i.parentElement),v.updateListener.of(O=>{O.docChanged&&(i.value=O.state.doc.toString())})]},r=zi(n),s=new Ct(r);return s.setMode(e,t),i.style.display="none",s}function K0(i,e,t,n){let r=i.textContent,s={parent:i.parentElement,doc:r,extensions:[tt.of(n),...Zr(i.parentElement),v.updateListener.of(o=>{e(o)}),v.domEventHandlers(t)]};window.$events.emitPublic(i,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let O=zi(s);return new Ct(O).setMode("markdown",""),i.style.display="none",O}export{N0 as highlight,L0 as highlightWithin,J0 as inlineEditor,K0 as markdownEditor,F0 as popupEditor,H0 as wysiwygView};
//# sourceMappingURL=code.js.map