varU=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),ni.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),ni.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=new_t(this),s=new_t(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){returnnew_t(this,e)}iterRange(e,t=this.length){returnnewwn(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))}returnnewkn(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?newve(e):ni.from(ve.split(e,[]))}},ve=classiextendsU{constructor(e,t=sd(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(rl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){letO=n.pop(),o=xn(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=xn(this.text,xn(n.text,rl(this.text,0,e)),t),s=this.length+n.length-(t-e);returnr.length<=32?newi(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=`
`,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
}`,{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==`
`);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(`Unknownnodetype'${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
`);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};