varq=classi{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,n){letr=[];returnthis.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){returnthis.replace(this.length,this.length,e)}slice(e,t=this.length){letn=[];returnthis.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;lett=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=newGt(this),s=newGt(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>=n)return!0}}iter(e=1){returnnewGt(this,e)}iterRange(e,t=this.length){returnnewXn(this,e,t)}iterLines(e,t){letn;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);letr=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))}returnnewWn(n)}toString(){returnthis.sliceString(0)}toJSON(){lete=[];returnthis.flatten(e),e}constructor(){}staticof(e){if(e.length==0)thrownewRangeError("A document must have at least one line");returne.length==1&&!e[0]?i.empty:e.length<=32?newze(e):oi.from(ze.split(e,[]))}},ze=classiextendsq{constructor(e,t=gd(e)){super(),this.text=e,this.length=t}getlines(){returnthis.text.length}getchildren(){returnnull}lineInner(e,t,n,r){for(lets=0;;s++){leto=this.text[s],O=r+o.length;if((t?n:O)>=e)returnnewJr(r,O,n,o);r=O+1,n++}}decompose(e,t,n,r){lets=e<=0&&t>=this.length?this:newi(Ol(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){leto=n.pop(),O=zn(s.text,o.text.slice(),0,s.length);if(O.length<=32)n.push(newi(O,o.length+s.length));else{letl=O.length>>1;n.push(newi(O.slice(0,l)),newi(O.slice(l)))}}elsen.push(s)}replace(e,t,n){if(!(ninstanceofi))returnsuper.replace(e,t,n);letr=zn(this.text,zn(n.text,Ol(this.text,0,e)),t),s=this.length+n.length-(t-e);returnr.length<=32?newi(r,s):oi.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}},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(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 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 gd(i){let e=-1;for(let t of i)e+=t.length+1;return e}function zn(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 Ol(i,e,t){return zn(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=`
`,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 fp(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 up(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=Ma(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 Ln(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 $s(i,e,t){let n=Ln(i.state.facet(oo).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 Vs=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.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&Tp(e.contentDOM.ownerDocument)}handleEvent(e){!Qp(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=dp(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&&Da.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=La.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||pp.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,pi(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),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Dl(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){ft(t.state,r)}}}function dp(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers
}`,{label:"class",detail:"definition",type:"keyword"}),be('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),be('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],xS=bf.concat([be("interface ${name} {\n${}\n}",{label:"interface",detail:"definition",type:"keyword"}),be("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),be("enum ${name} {\n${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Sf=new $i,Pf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function gn(i){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,i),!0}}var wS=["FunctionDeclaration"],kS={FunctionDeclaration:gn("function"),ClassDeclaration:gn("class"),ClassExpression:()=>!0,EnumDeclaration:gn("constant"),TypeAliasDeclaration:gn("type"),NamespaceDeclaration:gn("namespace"),VariableDefinition(i,e){i.matchContext(wS)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function xf(i,e){let t=Sf.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=kS[o.name];if(O&&O(o,s)||Pf.has(o.name))return!1}else if(o.to-o.from>8192){for(let O of xf(i,o.node))n.push(O);return!1}}),Sf.set(e,n),n}var Qf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,wf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function vS(i){let e=A(i.state).resolveInner(i.pos,-1);if(wf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Qf.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let r=e;r;r=r.parent)Pf.has(r.name)&&(n=n.concat(xf(i.state.doc,r)));return{options:n,from:t?e.from:i.pos,validFor:Qf}}var He=de.define({name:"javascript",parser:ff.configure({props:[ye.add({IfStatement:Ze({except:/^\s*({|else\b)/}),TryStatement:Ze({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:qh,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:vr({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}}),Te.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:"$"}}),kf={test:i=>/^JSX/.test(i.name),facet:bi({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dO=He.configure({dialect:"ts"},"typescript"),pO=He.configure({dialect:"jsx",props:[kr.add(i=>i.isTop?[kf]:void 0)]}),mO=He.configure({dialect:"jsx ts",props:[kr.add(i=>i.isTop?[kf]:void 0)]},"typescript"),vf=i=>({label:i,type:"keyword"}),Tf="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(vf),TS=Tf.concat(["declare","implements","private","protected","public"].map(vf));function ei(i={}){let e=i.jsx?i.typescript?mO:pO:i.typescript?dO:He,t=i.typescript?xS.concat(TS):bf.concat(Tf);return new re(e,[He.data.of({autocomplete:mf(wf,pf(t))}),He.data.of({autocomplete:vS}),i.jsx?WS:[]])}function zS(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 yf(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)&&yn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,U(b.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(Zu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(U(b.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Wu(e,yn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=yn(e,this.pos),n=0;if(t>this.pos){let r=Ru(e,t,this.start);if(r){let s=TO(e,r.to-this.start);s>0&&(this.nextStage(r),n=s)}}return n||(n=TO(e,this.pos)),n>0&&n<e.length?n:-1}else return TO(e,this.pos)}}};function TO(i,e){for(;e<i.length;e++){let t=i.charCodeAt(e);if(t==10)break;if(!Ie(t))return-1}return e}var VO=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Pu(t),s=t.next;if(r<0)return!1;let o=U(b.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,U(s==61?b.SetextHeading1:b.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}},yQ={LinkReference(i,e){return e.content.charCodeAt(0)==91?new YO(e):null},SetextHeading(){return new VO}},bQ=[(i,e)=>bu(e)>=0,(i,e)=>Su(e)>=0,(i,e)=>Qu(e)>=0,(i,e)=>GO(e,i,!0)>=0,(i,e)=>IO(e,i,!0)>=0,(i,e)=>EO(e,i,!0)>=0,(i,e)=>ku(e,i,!0)>=0],PQ={text:"",end:0},CO=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new WO,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=Lr.create(b.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new AO(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 XO(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=Yu(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=PQ;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 "+b[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==`
`);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=Lr.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],zi,zi,(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(_O(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?vu(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=_O(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(b.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return typeof e=="string"?U(this.parser.getNodeType(e),t,n,r):new Br(e,t)}get buffer(){return new Dr(this.parser.nodeSet)}};function vu(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=vu(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 Pn=class i extends mt{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 CO(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let t=qO(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(Sn(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(P=>P.name==m))continue;$&&(r[f.length]=(P,w,Z)=>$(w,Z,P.value));let k=f.length,y=$?["Block","BlockContext"]:g?k>=b.ATXHeading1&&k<=b.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(F.define({id:k,name:m,props:y&&[[R.group,y]]})),Q&&(d||(d={}),Array.isArray(Q)||Q instanceof je?d[m]=Q:Object.assign(d,Q))}n=new dt(f),d&&(n=n.extend(ne(d)))}if(Sn(t.props)&&(n=n.extend(...t.props)),Sn(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(Sn(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(Sn(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(`Unknownnodetype'${e}'`);return t}parseInline(e,t){let n=new UO(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
`);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=Wi({parent:r,doc:t,extensions:Ho(r)});new _t(s).setMode(n,t),i.remove(),Cb(s)}function bP(i){let e=i.querySelectorAll("pre");for(let t of e)md(t)}function PP(){let i=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of i)md(e)}function xP(i,e,t,n){let r=Wi({parent:i,doc:t,extensions:Ho(i),root:e}),s=new _t(r);return s.setMode(n,t),s}function wP(i,e){let t=i.textContent,n={parent:i.parentElement,doc:t,extensions:[...Vr(i.parentElement),v.updateListener.of(s=>{s.docChanged})]},r=new _t(Wi(n));return r.setMode(e,t),i.style.display="none",r}function kP(i,e){let t=i.value,n={parent:i.parentElement,doc:t,extensions:[...Vr(i.parentElement),v.updateListener.of(o=>{o.docChanged&&(i.value=o.state.doc.toString())})]},r=Wi(n),s=new _t(r);return s.setMode(e,t),i.style.display="none",s}function vP(i,e,t,n){let r=i.textContent,s={parent:i.parentElement,doc:r,extensions:[st.of(n),...Vr(i.parentElement),v.updateListener.of(O=>{e(O)}),v.domEventHandlers(t)]};window.$events.emitPublic(i,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let o=Wi(s);return new _t(o).setMode("markdown",""),i.style.display="none",o}export{PP as highlight,bP as highlightWithin,kP as inlineEditor,vP as markdownEditor,wP as popupEditor,xP as wysiwygView};