varU=class{constructor(){}lineAt(e){if(e<0||e>this.length)thrownewRangeError(`Invalid position ${e} in document of length ${this.length}`);returnthis.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)thrownewRangeError(`Invalid line number ${e} in ${this.lines}-line document`);returnthis.lineInner(e,!0,1,0)}replace(e,t,i){letr=[];returnthis.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),je.from(r,this.length-(t-e)+i.length)}append(e){returnthis.replace(this.length,this.length,e)}slice(e,t=this.length){leti=[];returnthis.decompose(e,t,i,0),je.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;lett=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=newFt(this),s=newFt(e);for(letO=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>=i)return!0}}iter(e=1){returnnewFt(this,e)}iterRange(e,t=this.length){returnnewjn(this,e,t)}iterLines(e,t){leti;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);letr=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}returnnewGn(i)}toString(){returnthis.sliceString(0)}toJSON(){lete=[];returnthis.flatten(e),e}staticof(e){if(e.length==0)thrownewRangeError("A document must have at least one line");returne.length==1&&!e[0]?U.empty:e.length<=32?newF(e):je.from(F.split(e,[]))}},F=classextendsU{constructor(e,t=nd(e)){super(),this.text=e,this.length=t}getlines(){returnthis.text.length}getchildren(){returnnull}lineInner(e,t,i,r){for(lets=0;;s++){letO=this.text[s],o=r+O.length;if((t?i:o)>=e)returnnewOs(r,o,i,O);r=o+1,i++}}decompose(e,t,i,r){lets=e<=0&&t>=this.length?this:newF(tl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){letO=i.pop(),o=An(s.text,O.text.slice(),0,s.length);if(o.length<=32)i.push(newF(o,O.length+s.length));else{letl=o.length>>1;i.push(newF(o.slice(0,l)),newF(o.slice(l)))}}elsei.push(s)}replace(e,t,i){if(!(iinstanceofF))returnsuper.replace(e,t,i);letr=An(this.text,An(i.text,tl(this.text,0,e)),t),s=this.length+i.length-(t-e);returnr.length<=32?newF(r,s):je.from(F.split(r,[]),s)}sliceString(e,t=this.length,i=`
`}get readOnly(){return this.facet(Sl)}phrase(e,...t){for(let i of this.facet(Y.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(dl))for(let O of s(this,t,i))Object.prototype.hasOwnProperty.call(O,e)&&r.push(O[e]);return r}charCategorizer(e){return dd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),O=e-i,o=e-i;for(;O>0;){let l=we(t,O,!1);if(s(t.slice(l,O))!=Ge.Word)break;O=l}for(;o<r;){let l=we(t,o);if(s(t.slice(o,l))!=Ge.Word)break;o=l}return O==o?null:Q.range(O+i,o+i)}};Y.allowMultipleSelections=pl;Y.tabSize=W.define({combine:n=>n.length?n[0]:4});Y.lineSeparator=$l;Y.readOnly=Sl;Y.phrases=W.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});Y.languageData=dl;Y.changeFilter=ml;Y.transactionFilter=gl;Y.transactionExtender=Ql;lt.reconfigure=G.define();function Vt(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let O=r[s],o=i[s];if(o===void 0)i[s]=O;else if(!(o===O||O===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](o,O);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ke=class{eq(e){return this==e}range(e,t=e){return Kt.create(e,t,this)}};Ke.prototype.startSide=Ke.prototype.endSide=0;Ke.prototype.point=!1;Ke.prototype.mapMode=pe.TrackDel;var Kt=class{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kt(e,t,i)}};function ps(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var en=class{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?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||(i?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,i,r){for(let s=this.findIndex(t,-1e9,!0),O=this.findIndex(i,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 i=[],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)),i.push(a),r.push(f-O),s.push(d-O))}return{mapped:i.length?new en(r,s,i,o):null,pos:O}}},j=class{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new j(e,t,i,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:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,O=e.filter;if(t.length==0&&!O)return this;if(i&&(t=t.slice().sort(ps)),this.isEmpty)return t.length?j.of(t):this;let o=new Mn(this,null,-1).goto(0),l=0,a=[],h=new Pt;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(Kt.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?j.empty:this.nextLayer.update({add:a,filter:O,filterFrom:r,filterTo
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),a=Q.cursor(t?r.from:r.to)}if(l){if(!l(h))return o}else{if(!i)return a;l=i(h)}o=a}}function Ld(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let O=i(s);return r==Ge.Space&&(r=O),r==O}}function Nd(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return Q.cursor(r,e.assoc);let O=e.goalColumn,o,l=n.contentDOM.getBoundingClientRect(),a=n.coordsAtPos(r),h=n.documentTop;if(a)O==null&&(O=a.left-l.left),o=s<0?a.top:a.bottom;else{let d=n.viewState.lineBlockAt(r);O==null&&(O=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-d.from))),o=(s<0?d.top:d.bottom)+h}let c=l.left+O,f=i??n.defaultLineHeight>>1;for(let d=0;;d+=10){let p=o+(f+d)*s,m=qa(n,{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 xs(n,e,t){let i=n.state.facet(za).map(r=>r(n));for(;;){let r=!1;for(let s of i)s.between(t.from-1,t.from+1,(O,o,l)=>{t.from>O&&t.from<o&&(t=e.head>t.from?Q.cursor(O,1):Q.cursor(o,-1),r=!0)});if(!r)return t}}var Gs=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=(i,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():i(e,r))};for(let i in le){let r=le[i];e.contentDOM.addEventListener(i,s=>{jl(e,s)&&t(r,s)},Is[i]),this.registeredEvents.push(i)}e.scrollDOM.addEventListener("mousedown",i=>{if(i.target==e.scrollDOM&&i.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(le.mousedown,i),!i.defaultPrevented&&i.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),z.chrome&&z.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,z.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let r;this.customHandlers=[];for(let s of t)if(r=(i=s.update(e).spec)===null||i===void 0?void 0:i.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=>{jl(e,o)&&this.runCustomHandlers(O,e,o)&&o.preventDefault()}))}}runCustomHandlers(e,t,i){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,i,t)||i.defaultPrevented)return!0}catch(O){ft(t.state,O)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let i of this.customHandlers){let r=i.handlers.scroll;if(r)try{r.call(i.plugin,t,e)}catch(s){ft(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(z.android&&z.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let i;return z.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((i=Ua.find(r=>r.keyCode==t.keyCode))&&!t.ctrlKey||Hd.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=i||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Pi(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.
}`,{label:"class",detail:"definition",type:"keyword"}),Fe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Fe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],$f=new Xi,Qf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function zn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}var Lg=["FunctionDeclaration"],Ng={FunctionDeclaration:zn("function"),ClassDeclaration:zn("class"),ClassExpression:()=>!0,EnumDeclaration:zn("constant"),TypeAliasDeclaration:zn("type"),NamespaceDeclaration:zn("namespace"),VariableDefinition(n,e){n.matchContext(Lg)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function Sf(n,e){let t=$f.get(e);if(t)return t;let i=[],r=!0;function s(O,o){let l=n.sliceString(O.from,O.to);i.push({label:l,type:o})}return e.cursor(E.IncludeAnonymous).iterate(O=>{if(r)r=!1;else if(O.name){let o=Ng[O.name];if(o&&o(O,s)||Qf.has(O.name))return!1}else if(O.to-O.from>8192){for(let o of Sf(n,O.node))i.push(o);return!1}}),$f.set(e,i),i}var mf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,yf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Hg(n){let e=I(n.state).resolveInner(n.pos,-1);if(yf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&mf.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)Qf.has(r.name)&&(i=i.concat(Sf(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:mf}}var St=he.define({name:"javascript",parser:af.configure({props:[ve.add({IfStatement:Ye({except:/^\s*({|else\b)/}),TryStatement:Ye({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Th,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:Zr({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ye({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Ce.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":jt,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Pf={test:n=>/^JSX/.test(n.name),facet:qi({commentTokens:{block:{open:"{/*",close:"*/}"}}})},ho=St.configure({dialect:"ts"},"typescript"),co=St.configure({dialect:"jsx",props:[Vr.add(n=>n.isTop?[Pf]:void 0)]}),fo=St.configure({dialect:"jsx ts",props:[Vr.add(n=>n.isTop?[Pf]:void 0)]},"typescript"),Fg="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(n=>({label:n,type:"keyword"}));function li(n={}){let e=n.jsx?n.typescript?fo:co:n.typescript?ho:St;return new ce(e,[St.data.of({autocomplete:uf(yf,ff(Bg.concat(Fg)))}),St.data.of({autocomplete:Hg}),n.jsx?eQ:[]])}function Jg(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function gf(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}var Kg=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),eQ=x.inputHandler.of((n,e,t,i)=>{if((Kg?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!St.isActiveAt(n.state,e,-1))return
`+t.scrub(),s=this.advance(r);return s>-1&&s<r.length?this.complete(e,i,s):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Vn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,i){return e.addLeafElement(t,A(S.LinkReference,this.start,this.start+i,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(Qu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(A(S.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(mu(e,Vn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Vn(e,this.pos),i=0;if(t>this.pos){let r=gu(e,t,this.start);if(r){let s=wo(e,r.to-this.start);s>0&&(this.nextStage(r),i=s)}}return i||(i=wo(e,this.pos)),i>0&&i<e.length?i:-1}else return wo(e,this.pos)}}};function wo(n,e){for(;e<n.length;e++){let t=n.charCodeAt(e);if(t==10)break;if(!Je(t))return-1}return e}var Ro=class{nextLine(e,t,i){let r=t.depth<e.stack.length?-1:au(t),s=t.next;if(r<0)return!1;let O=A(S.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(i,A(s==61?S.SetextHeading1:S.SetextHeading2,i.start,e.prevLineEnd(),[...e.parser.parseInline(i.content,i.start),O])),!0}finish(){return!1}},IQ={LinkReference(n,e){return e.content.charCodeAt(0)==91?new Wo(e):null},SetextHeading(){return new Ro}},MQ=[(n,e)=>lu(e)>=0,(n,e)=>su(e)>=0,(n,e)=>Ou(e)>=0,(n,e)=>Ao(e,n,!0)>=0,(n,e)=>jo(e,n,!0)>=0,(n,e)=>_o(e,n,!0)>=0,(n,e)=>fu(e,n,!0)>=0],DQ={text:"",end:0},Vo=class{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.line=new To,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=Di.create(S.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=i.length?new Uo(i,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 i of e.markers)this.addNode(i.type,i.from,i.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 i of this.parser.blockParsers)if(i){let r=i(this,e);if(r!=!1){if(r==!0)return null;e.forward();continue e}}break}let t=new vo(this.lineStart+e.pos,e.text.slice(e.pos));for(let i of this.parser.leafBlockParsers)if(i){let r=i(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let i of this.parser.endLeafBlock)if(i(this,e,t))break e}for(let i of t.parsers)if(i.nextLine(this,e,t))return null;t.content+=`
`+e.scrub();for(let i of e.markers)t.marks.push(i)}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 i=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&&(i-=o-O)}return this.lineStart+=i,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=DQ;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 i=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-i)+O,i=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:i}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=i,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),i;if(this.input.lineChunks)i=t==`
`);i=r<0?t:t.slice(0,r)}return e+i.length>this.to?i.slice(0,this.to-e):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,i=0){this.block=Di.create(e,i,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,i=0){this.startContext(this.parser.getNodeType(e),t,i)}addNode(e,t,i){typeof e=="number"&&(e=new Z(this.parser.nodeSet.types[e],Bi,Bi,(i??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(qo(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?uu(this.ranges,0,e.topNode,this.ranges[0].from,this.dontInject):e}finishLeaf(e){for(let i of e.parsers)if(i.finish(this,e))return;let t=qo(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,i,r){return typeof e=="string"?A(this.parser.getNodeType(e),t,i,r):new ts(e,t)}get buffer(){return new es(this.parser.nodeSet)}};function uu(n,e,t,i,r){if(r.has(t.tree))return t.tree;let s=n[e].to,O=[],o=[],l=t.from+i;function a(h,c){for(;c?h>=s:h>s;){let f=n[e+1].from-s;i+=f,h+=f,e++,s=n[e].to}}for(let h=t.firstChild;h;h=h.nextSibling){a(h.from+i,!0);let c=h.from+i,f;h.to+i>s?(f=uu(n,e,h,i,r),a(h.to+i,!1)):f=h.toTree(),O.push(f),o.push(c-l)}return a(t.to+i,!1),new Z(t.type,O,o,t.to+i-l,t.tree?t.tree.propValues:void 0)}var hi=class extends zt{constructor(e,t,i,r,s,O,o,l,a){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,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,i){let r=new Vo(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}configure(e){let t=Zo(e);if(!t)return this;let{nodeSet:i,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(Wn(t.defineNodes)){r=Object.assign({},r);let f=i.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:$,composite:g,style:P}=typeof p=="string"?{name:p}:p;if(f.some(v=>v.name==m))continue;g&&(r[f.length]=(v,w,V)=>g(w,V,v.value));let k=f.length,b=g?["Block","BlockContext"]:$?k>=S.ATXHeading1&&k<=S.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(H.define({id:k,name:m,props:b&&[[R.group,b]]})),P&&(d||(d={}),Array.isArray(P)||P instanceof Ze?d[m]=P:Object.assign(d,P))}i=new it(f),d&&(i=i.extend(ae(d)))}if(Wn(t.props)&&(i=i.extend(...t.props)),Wn(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(Wn(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?Kr(o,f.before):f.after?Kr(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(Wn(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?Kr(a,f.before):f.after?Kr(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 hi(i,s,O,o,h,r,l,a,c)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknownnodetype'${e}'`);return t}parseInline(e,t){let i=new Co(this,e,t);e:for(let r=t;r<i.end;){let s=i.char(r);for(let O of this.inlineParsers)if(O){let o=O(i,s,r);if(o>=0){r=o;continue e}}r++}return i.resol
`);let t=n.textContent.trimEnd(),i="";e!==null&&(i=e.className.replace("language-",""));let r=document.createElement("div");n.parentNode.insertBefore(r,n);let s=Ni({parent:r,doc:t,extensions:FO(r)});new Bt(s).setMode(i,t),n.remove(),tP(s)}function _0(n){let e=n.querySelectorAll("pre");for(let t of e)id(t)}function A0(){let n=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of n)id(e)}function j0(n,e,t,i){let r=Ni({parent:n,doc:t,extensions:FO(n),root:e}),s=new Bt(r);return s.setMode(i,t),s}function G0(n,e){let t=n.textContent,i={parent:n.parentElement,doc:t,extensions:[...Er(n.parentElement),x.updateListener.of(s=>{s.docChanged})]},r=new Bt(Ni(i));return r.setMode(e,t),n.style.display="none",r}function E0(n,e){let t=n.value,i={parent:n.parentElement,doc:t,extensions:[...Er(n.parentElement),x.updateListener.of(O=>{O.docChanged&&(n.value=O.state.doc.toString())})]},r=Ni(i),s=new Bt(r);return s.setMode(e,t),n.style.display="none",s}function I0(n,e,t,i){let r=n.textContent,s={parent:n.parentElement,doc:r,extensions:[dt.of(i),...Er(n.parentElement),x.updateListener.of(o=>{e(o)}),x.domEventHandlers(t)]};window.$events.emitPublic(n,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let O=Ni(s);return new Bt(O).setMode("markdown",""),n.style.display="none",O}export{A0 as highlight,_0 as highlightWithin,E0 as inlineEditor,I0 as markdownEditor,G0 as popupEditor,j0 as wysiwygView};