a&&o.push(new je(a,m.from,d));let g=m.direction==zt!=!(d%2);Zr(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(f?j[p]!=l:j[p]==l))break;p++}u?Qr(s,a,p,i+1,n,u,o):ae;){let f=!0,c=!1;if(!h||a>r[h-1].to){let m=j[a-1];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(c)break e;let m=r[--h];if(!f)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(j[g-1]==l)break e;break}}if(u)u.push(m);else{m.toj.length;)j[j.length]=256;let i=[],n=e==zt?0:1;return Zr(s,n,n,t,0,s.length,i),i}function dh(s){return[new je(0,s,0)]}var ph="";function Nu(s,e,t,i,n){var r;let o=i.head-s.from,l=je.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(n,t);if(o==h){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),h=a.side(n,t)}let f=Ke(s.text,o,a.forward(n,t));(fa.to)&&(f=h),ph=s.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return c&&f==h&&c.level+(n?0:1)s.some(e=>e)}),Lu=R.define({combine:s=>s.some(e=>e)}),vh=R.define(),Ui=class s{constructor(e,t="nearest",i="nearest",n=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new s(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new s(P.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Gs=J.define({map:(s,e)=>s.map(e)}),xh=J.define();function Le(s,e,t){let i=s.facet(bh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var bt=R.define({combine:s=>s.length?s[0]:!0}),Pu=0,_i=R.define(),Ut=class s{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(e,t){let{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new s(Pu++,e,i,n,l=>{let a=[_i.of(l)];return o&&a.push(is.of(h=>{let f=h.plugin(l);return f?o(f):Q.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return s.define(i=>new e(i),t)}},Yi=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Le(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(n){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Le(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Le(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Ch=R.define(),Co=R.define(),is=R.define(),Ah=R.define(),Ao=R.define(),Mh=R.define();function Ma(s,e){let t=s.state.facet(Mh);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return Z.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,f=o-e.from,c=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Du(e.text,h,f)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let m={from:h,to:f,direction:d,inner:[]};c.push(m),c=m.inner}}}}),n}var Oh=R.define();function Th(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Oh)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}var Ki=R.define(),Ue=class s{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new s(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toAf)break;r+=2}if(!a)return i;new s(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},hn=class s{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ye.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new Ue(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new s(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},fn=class extends z{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Q.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new re],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ue(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Hu(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Iu(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;i=new Ue(h,f,e.changes.mapPos(h,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(T.ie||T.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=$u(o,l,e.changes);return i=Ue.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=T.chrome||T.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?n[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:f,toB:c}=l,u,d,p,m;if(i&&i.range.fromBf){let S=zi.build(this.view.state.doc,f,i.range.fromB,this.decorations,this.dynamicDecorationMap),v=zi.build(this.view.state.doc,i.range.toB,c,this.decorations,this.dynamicDecorationMap);d=S.breakAtStart,p=S.openStart,m=v.openEnd;let M=this.compositionView(i);v.breakAtStart?M.breakAfter=1:v.content.length&&M.merge(M.length,M.length,v.content[0],!1,v.openStart,0)&&(M.breakAfter=v.content[0].breakAfter,v.content.shift()),S.content.length&&M.merge(0,0,S.content[S.content.length-1],!0,0,S.openEnd)&&S.content.pop(),u=S.content.concat(M).concat(v.content)}else({content:u,breakAtStart:d,openStart:p,openEnd:m}=zi.build(this.view.state.doc,f,c,this.decorations,this.dynamicDecorationMap));let{i:g,off:y}=r.findPos(h,1),{i:w,off:x}=r.findPos(a,-1);ih(this,w,x,g,y,u,d,p,m)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(xh)&&(this.editContextFormatting=i.value)}compositionView(e){let t=new Ye(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new kt(n,[t],t.length);let i=new re;return i.append(t,0),i}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=z.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},i=this.childPos(e.range.fromB,1),n=this.children[i.i];t(e.line,n);for(let r=e.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],t(r>=0?e.marks[r].node:e.text,n)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&tn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(T.gecko&&l.empty&&!this.hasComposition&&Bu(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=h=new fe(c,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!ji(a.node,a.offset,f.anchorNode,f.anchorOffset)||!ji(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{T.android&&T.chrome&&this.dom.contains(f.focusNode)&&Vu(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=Ji(this.view.root);if(c)if(l.empty){if(T.gecko){let u=Ru(a.node,a.offset);if(u&&u!=3){let d=(u==1?eh:th)(a.node,a.offset);d&&(a=new fe(d.node,d.offset))}}c.collapse(a.node,a.offset),l.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=l.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(u)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new fe(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new fe(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ji(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ji(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=re.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc);i.collapse(f.node,f.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(n,r)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let n=e.offset;!i&&n=0;n--){let r=z.get(t.childNodes[n]);r instanceof re&&(i=r.domAtPos(r.length))}return i?new fe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=z.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=r-l.breakAfter,h=a-l.length;if(ae||l.covers(1))&&(!i||l instanceof re&&!(i instanceof re&&t>=0)))i=l,n=h;else if(i&&h==e&&a==e&&l instanceof Wt&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(i=null)}r=h}return i?i.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),n=this.children[t];if(!(n instanceof re))return null;for(;n.children.length;){let{i:l,off:a}=n.childPos(i,1);for(;;l++){if(l==n.children.length)return null;if((n=n.children[l]).length)break}i=a}if(!(n instanceof Ye))return null;let r=Ke(n.text,i);if(r==i)return null;let o=jt(n.dom,i,r).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ie.LTR;for(let h=0,f=0;fn)break;if(h>=i){let d=c.dom.getBoundingClientRect();if(t.push(d.height),o){let p=c.dom.lastChild,m=p?Xi(p):[];if(m.length){let g=m[m.length-1],y=a?g.right-d.left:d.right-g.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ie.RTL:ie.LTR}measureTextSize(){for(let r of this.children)if(r instanceof re){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=Xi(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,n=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new on(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Q.replace({widget:new ts(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return Q.set(e)}updateDeco(){let e=1,t=this.view.state.facet(is).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Ah).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(Z.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=Th(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;pu(this.view.scrollDOM,o,t.head{ie.from&&(t=!0)}),t}function _u(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return P.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=Ke(n.text,r,!1):l=Ke(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=Ke(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;ls?e.left-s:Math.max(0,s-e.right)}function Wu(s,e){return e.top>s?e.top-s:Math.max(0,s-e.bottom)}function Hr(s,e){return s.tope.top+1}function Oa(s,e){return es.bottom?{top:s.top,left:s.left,right:s.right,bottom:e}:s}function to(s,e,t){let i,n,r,o,l=!1,a,h,f,c;for(let p=s.firstChild;p;p=p.nextSibling){let m=Xi(p);for(let g=0;gx||o==x&&r>w){i=p,n=y,r=w,o=x;let S=x?t0?g0)}w==0?t>y.bottom&&(!f||f.bottomy.top)&&(h=p,c=y):f&&Hr(f,y)?f=Ta(f,y.bottom):c&&Hr(c,y)&&(c=Oa(c,y.top))}}if(f&&f.bottom>=t?(i=a,n=f):c&&c.top<=t&&(i=h,n=c),!i)return{node:s,offset:0};let u=Math.max(n.left,Math.min(n.right,e));if(i.nodeType==3)return Ea(i,u,t);if(l&&i.contentEditable!="false")return to(i,u,t);let d=Array.prototype.indexOf.call(s.childNodes,i)+(e>=(n.left+n.right)/2?1:0);return{node:s,offset:d}}function Ea(s,e,t){let i=s.nodeValue.length,n=-1,r=1e9,o=0;for(let l=0;lt?f.top-t:t-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&c=(f.left+f.right)/2,d=u;if((T.chrome||T.gecko)&&jt(s,l).getBoundingClientRect().left==f.right&&(d=!u),c<=0)return{node:s,offset:l+(d?1:0)};n=l+(d?1:0),r=c}}}return{node:s,offset:n>-1?n:o>0?s.nodeValue.length:0}}function Nh(s,e,t,i=-1){var n,r;let o=s.contentDOM.getBoundingClientRect(),l=o.top+s.viewState.paddingTop,a,{docHeight:h}=s.viewState,{x:f,y:c}=e,u=c-l;if(u<0)return 0;if(u>h)return s.state.doc.length;for(let S=s.viewState.heightOracle.textHeight/2,v=!1;a=s.elementAtHeight(u),a.type!=ze.Text;)for(;u=i>0?a.bottom+S:a.top-S,!(u>=0&&u<=h);){if(v)return t?null:0;v=!0,i=-i}c=l+u;let d=a.from;if(ds.viewport.to)return s.viewport.to==s.state.doc.length?s.state.doc.length:t?null:Na(s,o,a,f,c);let p=s.dom.ownerDocument,m=s.root.elementFromPoint?s.root:p,g=m.elementFromPoint(f,c);g&&!s.contentDOM.contains(g)&&(g=null),g||(f=Math.max(o.left+1,Math.min(o.right-1,f)),g=m.elementFromPoint(f,c),g&&!s.contentDOM.contains(g)&&(g=null));let y,w=-1;if(g&&((n=s.docView.nearest(g))===null||n===void 0?void 0:n.isEditable)!=!1){if(p.caretPositionFromPoint){let S=p.caretPositionFromPoint(f,c);S&&({offsetNode:y,offset:w}=S)}else if(p.caretRangeFromPoint){let S=p.caretRangeFromPoint(f,c);S&&({startContainer:y,startOffset:w}=S,(!s.contentDOM.contains(y)||T.safari&&qu(y,w,f)||T.chrome&&ju(y,w,f))&&(y=void 0))}}if(!y||!s.docView.dom.contains(y)){let S=re.find(s.docView,d);if(!S)return u>a.top+a.height/2?a.to:a.from;({node:y,offset:w}=to(S.dom,f,c))}let x=s.docView.nearest(y);if(!x)return null;if(x.isWidget&&((r=x.dom)===null||r===void 0?void 0:r.nodeType)==1){let S=x.dom.getBoundingClientRect();return e.ys.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+ma(o,r,s.state.tabSize)}function qu(s,e,t){let i;if(s.nodeType!=3||e!=(i=s.nodeValue.length))return!1;for(let n=s.nextSibling;n;n=n.nextSibling)if(n.nodeType!=1||n.nodeName!="BR")return!1;return jt(s,i-1,i).getBoundingClientRect().left>t}function ju(s,e,t){if(e!=0)return!1;for(let n=s;;){let r=n.parentNode;if(!r||r.nodeType!=1||r.firstChild!=n)return!1;if(r.classList.contains("cm-line"))break;n=r}let i=s.nodeType==1?s.getBoundingClientRect():jt(s,0,Math.max(s.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function zu(s,e){let t=s.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==ze.Text))return i}return t}function Uu(s,e,t,i){let n=zu(s,e.head),r=!i||n.type!=ze.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==ie.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return P.cursor(a,t?-1:1)}return P.cursor(t?n.to:n.from,t?-1:1)}function Da(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let h=Nu(n,r,o,l,t),f=ph;if(!h){if(n.number==(t?s.state.doc.lines:1))return l;f=`\n`,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!t)}if(a){if(!a(f))return l}else{if(!i)return h;a=i(f)}l=h}}function Yu(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==_e.Space&&(n=o),n==o}}function Gu(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return P.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,e.assoc||-1),f=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let d=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-d.from))),l=(r<0?d.top:d.bottom)+f}let c=a.left+o,u=i!=null?i:s.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*r,m=Nh(s,{x:c,y:p},!1,r);if(pa.bottom||(r<0?mn)){let g=s.docView.coordsForChar(m),y=!g||p{if(e>r&&en(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:P.cursor(i,ir)&&this.lineBreak(),n=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\\r\\n?|\\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=z.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Ju(e,i.node,i.offset)?t:0))}};function Ju(s,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:Zu(e),a=new io(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=ed(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Wr(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Wr(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=e.viewport;if((T.ios||T.chrome)&&e.state.selection.main.empty&&a!=h&&(f.from>0||f.toDate.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=n.from,h=null;(r===8||T.android&&e.text.length=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,t.from).append(t.insert).append(s.state.doc.slice(t.to,n.to))}:(T.mac||T.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=P.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:K.of([" "])}):T.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`\n `&&s.lineWrapping&&(i&&(i=P.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:K.of([" "])}),t)return Mo(s,t,i,r);if(i&&!i.main.eq(n)){let o=!1,l="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(o=!0),l=s.inputState.lastSelectionOrigin),s.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Mo(s,e,t,i=-1){if(T.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(T.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ci(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.lengthn.head)&&ci(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ci(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=Xu(s,e,t));return s.state.facet(wh).some(a=>a(s,e.from,e.to,r,l))||s.dispatch(l()),!0}function Xu(s,e,t){let i,n=s.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let l=r.frome.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(l+e.insert.sliceString(0,void 0,s.state.lineBreak)+a))}else{let l=n.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(n.selection.ranges.length>1&&s.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=s.state.sliceDoc(e.from,e.to),f,c=t&&Eh(s,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);f={from:c.from,to:c.to-p}}else f=s.state.doc.lineAt(r.head);let u=r.to-e.to,d=r.to-r.from;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:a||p.map(l)};let m=p.to-u,g=m-h.length;if(p.to-p.from!=d||s.state.sliceDoc(g,m)!=h||p.to>=f.from&&p.from<=f.to)return{range:p};let y=n.changes({from:g,to:m,insert:e.insert}),w=p.to-r.to;return{changes:y,range:a?P.range(Math.max(0,a.anchor+w),Math.max(0,a.head+w)):p.map(y)}})}else i={changes:l,selection:a&&n.selection.replaceRange(a)}}let o="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,o+=".compose",s.inputState.compositionFirstChange&&(o+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:o,scrollIntoView:!0})}function Qu(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Zu(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new cn(t,i)),(n!=t||r!=i)&&e.push(new cn(n,r))),e}function ed(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?P.single(t+e,i+e):null}var no=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.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,T.safari&&e.contentDOM.addEventListener("input",()=>null),T.gecko&&gd(e.contentDOM.ownerDocument)}handleEvent(e){!ad(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=td(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&sd.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),T.android&&T.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return T.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Lh.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||id.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(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:T.safari&&!T.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.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function La(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){Le(t.state,n)}}}function td(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec;if(n&&n.domEventHandlers)for(let r in n.domEventHandlers){let o=n.domEventHandlers[r];o&&t(r).handlers.push(La(i.value,o))}if(n&&n.domEventObservers)for(let r in n.domEventObservers){let o=n.domEventObservers[r];o&&t(r).observers.push(La(i.value,o))}}for(let i in Pe)t(i).handlers.push(Pe[i]);for(let i in Ce)t(i).observers.push(Ce[i]);return e}var Lh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],id="dthko",sd=[16,17,18,20,91,92,224,225],Js=6;function Xs(s){return Math.max(0,s)*.7+8}function nd(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}var ro=class{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=mu(e.contentDOM),this.atoms=e.state.facet(Ao).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(X.allowMultipleSelections)&&rd(e,t),this.dragging=ld(e,t)&&Ih(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&nd(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Th(this.view);e.clientX-a.left<=n+Js?t=-Xs(n-e.clientX):e.clientX+a.right>=o-Js&&(t=Xs(e.clientX-o)),e.clientY-a.top<=r+Js?i=-Xs(r-e.clientY):e.clientY+a.bottom>=l-Js&&(i=Xs(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;it.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function rd(s,e){let t=s.state.facet(mh);return t.length?t[0](e):T.mac?e.metaKey:e.ctrlKey}function od(s,e){let t=s.state.facet(gh);return t.length?t[0](e):T.mac?!e.altKey:!e.ctrlKey}function ld(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Ji(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function ad(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=z.get(t))&&i.ignoreEvent(e))return!1;return!0}var Pe=Object.create(null),Ce=Object.create(null),Ph=T.ie&&T.ie_version<15||T.ios&&T.webkit_version<604;function hd(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Bh(s,t.value)},50)}function bn(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function Bh(s,e){e=bn(s.state,vo,e);let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(oo!=null&&t.selection.ranges.every(a=>a.empty)&&oo==r.toString()){let a=-1;i=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:P.cursor(h.from+c.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:P.cursor(a.from+h.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ce.scroll=s=>{s.inputState.lastScrollTop=s.scrollDOM.scrollTop,s.inputState.lastScrollLeft=s.scrollDOM.scrollLeft};Pe.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);Ce.touchstart=(s,e)=>{s.inputState.lastTouchTime=Date.now(),s.inputState.setSelectionOrigin("select.pointer")};Ce.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};Pe.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(yh))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=ud(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new ro(s,e,t,i)),i&&s.observer.ignore(()=>{Xa(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function Pa(s,e,t,i){if(i==1)return P.cursor(e,t);if(i==2)return _u(s.state,e,t);{let n=re.find(s.docView,e),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return le>=t.top&&e<=t.bottom&&s>=t.left&&s<=t.right;function fd(s,e,t,i){let n=re.find(s.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(r==0)return 1;if(r==n.length)return-1;let o=n.coordsAt(r,-1);if(o&&Ba(t,i,o))return-1;let l=n.coordsAt(r,1);return l&&Ba(t,i,l)?1:o&&o.bottom>=i?-1:1}function Ia(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:fd(s,t,e.clientX,e.clientY)}}var cd=T.ie&&T.ie_version<=11,Ra=null,Fa=0,$a=0;function Ih(s){if(!cd)return s.detail;let e=Ra,t=$a;return Ra=s,$a=Date.now(),Fa=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(Fa+1)%3:1}function ud(s,e){let t=Ia(s,e),i=Ih(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=Ia(s,r),h,f=Pa(s,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let c=Pa(s,t.pos,t.bias,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u1&&(h=dd(n,a.pos))?h:l?n.addRange(f):P.create([f])}}}function dd(s,e){for(let t=0;t=e)return P.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}Pe.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.nearest(e.target);if(n&&n.isWidget){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=P.range(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",bn(s.state,xo,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Pe.dragend=s=>(s.inputState.draggedContent=null,!1);function Va(s,e,t,i){if(t=bn(s.state,vo,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&od(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}Pe.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&Va(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o{/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Va(s,e,i,!0),!0}return!1};Pe.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Ph?null:e.clipboardData;return t?(Bh(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(hd(s),!1)};function pd(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function md(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:bn(s,xo,e.join(s.lineBreak)),ranges:t,linewise:i}}var oo=null;Pe.copy=Pe.cut=(s,e)=>{let{text:t,ranges:i,linewise:n}=md(s.state);if(!t&&!n)return!1;oo=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ph?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(pd(s,t),!1)};var Rh=ht.define();function Fh(s,e){let t=[];for(let i of s.facet(kh)){let n=i(s,e);n&&t.push(n)}return t?s.update({effects:t,annotations:Rh.of(!0)}):null}function $h(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Fh(s.state,e);t?s.dispatch(t):s.update([])}},10)}Ce.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),$h(s)};Ce.blur=s=>{s.observer.clearSelectionRange(),$h(s)};Ce.compositionstart=Ce.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};Ce.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,T.chrome&&T.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};Ce.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};Pe.beforeinput=(s,e)=>{var t,i;if(e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return Mo(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(T.chrome&&T.android&&(n=Lh.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return T.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),T.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>Ce.compositionend(s,e),20),!1};var Ha=new Set;function gd(s){Ha.has(s)||(Ha.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}var _a=["pre-wrap","normal","pre-line","break-spaces"],di=!1;function Ka(){di=!1}var lo=class{constructor(e){this.lineWrapping=e,this.doc=K.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return _a.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>nn&&(di=!0),this.height=e)}replace(e,t,i){return s.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=n[l],u=r.lineAt(a,U.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,U.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,f=n[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n=r&&o(this.blockAt(0,i,n,r))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},xe=class s extends dn{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,n){return new qe(n,this.length,i,this.height,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof s||n instanceof wt&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof wt?n=new s(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):be.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},wt=class s extends be{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let h=n+(e0){let r=i[i.length-1];r instanceof s?i[i.length-1]=new s(r.length+n):i.push(null,new s(n-1))}if(e>0){let r=i[0];r instanceof s?i[0]=new s(e+r.length):i.unshift(new s(e-1),null)}return be.of(i)}decomposeLeft(e,t){t.push(new s(e-1),null)}decomposeRight(e,t){t.push(null,new s(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new s(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++];a==-1?a=c:Math.abs(c-a)>=nn&&(a=-2);let u=new xe(f,c);u.outdated=!1,o.push(u),l+=f+1}l<=r&&o.push(null,new s(r-l).updateHeight(e,l));let h=be.of(o);return(a<0||Math.abs(h.height-this.height)>=nn||Math.abs(a-this.heightMetrics(e,t).perLine)>=nn)&&(di=!0),un(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},ho=class extends be{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return el))return h;let f=t==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return a?h.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,n,r).join(h)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,U.ByPos,i,n,r);e=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Wa(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?be.of(this.break?[e,null,t]:[e,t]):(this.left=un(this.left,e),this.right=un(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Wa(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof wt&&(i=s[e+1])instanceof wt&&s.splice(e-1,3,new wt(t.length+1+i.length))}var yd=5,fo=class s{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof xe?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new xe(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=yd)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new xe(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new wt(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof xe)return e;let t=new xe(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof xe)&&!this.isCovered?this.nodes.push(new xe(0,-1)):(this.writtenTof.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function kd(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Gi=class{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new lo(t),this.stateDeco=e.facet(is).filter(i=>typeof i!="function"),this.heightMap=be.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle.setDoc(e.doc),[new Ue(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Q.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new fi(r,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?qa:new po(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(qi(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(is).filter(f=>typeof f!="function");let n=e.changedRanges,r=Ue.extendWithRanges(n,bd(i,this.stateDeco,e?e.changes:ye.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Ka(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||di)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Lu)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ie.RTL:ie.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:S,scaleY:v}=Ja(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=S,this.scaleY=v,h|=8,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Za(e.scrollDOM);let p=(this.printing?kd:wd)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(S)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:v,charWidth:M,textHeight:O}=e.docView.measureTextSize();o=v>0&&n.refresh(r,v,M,O,w/M,S),o&&(e.docView.minWidth=0,h|=8)}m>0&&g>0?f=Math.max(m,g):m<0&&g<0&&(f=Math.min(m,g)),Ka();for(let v of this.viewports){let M=v.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?be.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle,[new Ue(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new ao(v.from,M))}di&&(h|=2)}let x=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new fi(n.lineAt(o-i*1e3,U.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,U.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(ha.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(h,U.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r>1,o=n<<1;if(this.defaultTextDirection!=ie.LTR&&!i)return[];let l=[],a=(f,c,u,d)=>{if(c-ff&&yy.from>=u.from&&y.to<=u.to&&Math.abs(y.from-f)y.fromw));if(!g){if(cy.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(P.cursor(c),!1,!0).head;y>f&&(c=y)}g=new Gi(f,c,this.gapSize(u,f,c,d))}l.push(g)},h=f=>{if(f.lengthf.from&&a(f.from,d,f,c),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Z.spans(e,this.viewport.from,this.viewport.to,{span(n,r){t.push({from:n,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((n,r)=>n.from!=t[r].from||n.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||qi(this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||qi(this.heightMap.lineAt(this.scaler.fromDOM(e),U.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return qi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},fi=class{constructor(e,t){this.from=e,this.to=t}};function Sd(s,e,t){let i=[],n=s,r=0;return Z.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function Zs(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function vd(s,e){for(let t of s)if(e(t))return t}var qa={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}},po=class s{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,U.ByPos,e,0,0).top,f=t.lineAt(a,U.ByPos,e,0,0).bottom;return n+=f-h,{from:l,to:a,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function qi(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new qe(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>qi(n,e)):s._content)}var en=R.define({combine:s=>s.join(" ")}),mo=R.define({combine:s=>s.indexOf(!0)>-1}),go=ve.newName(),Vh=ve.newName(),Hh=ve.newName(),_h={"&light":"."+Vh,"&dark":"."+Hh};function yo(s,e,t){return new ve(e,{finish(i){return/&/.test(i)?i.replace(/&\\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}var xd=yo("."+go,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url(\'data:image/svg+xml,\')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},_h),Cd={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Kr=T.ie&&T.ie_version<=11,bo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new qr,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(T.ie&&T.ie_version<=11||T.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(T.chrome&&T.chrome_version<126)&&(this.editContext=new wo(e),e.state.facet(bt)&&(e.contentDOM.editContext=this.editContext.editContext)),Kr&&(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),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(bt)?i.root.activeElement!=this.dom:!tn(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(T.ie&&T.ie_version<=11||T.android&&T.chrome)&&!i.state.selection.main.empty&&n.focusNode&&ji(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ji(e.root);if(!t)return!1;let i=T.safari&&e.root.nodeType==11&&uu(this.dom.ownerDocument)==this.dom&&Ad(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=tn(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ci(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&tn(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new so(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Dh(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=ja(t,e.previousSibling||e.target.previousSibling,-1),n=ja(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(bt)!=e.state.facet(bt)&&(e.view.contentDOM.editContext=e.state.facet(bt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function ja(s,e,t){for(;e;){let i=z.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function za(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor);return ji(o.node,o.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Ad(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return za(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?za(s,t):null}var wo=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let{anchor:n}=e.state.selection.main,r={from:this.toEditorPos(i.updateRangeStart),to:this.toEditorPos(i.updateRangeEnd),insert:K.of(i.text.split(`\n`))};r.from==this.from&&nthis.to&&(r.to=n),!(r.from==r.to&&!r.insert.length)&&(this.pendingContextChange=r,e.state.readOnly||Mo(e,r,P.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(o!="None"&&l!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;n.push(Q.mark({attributes:{style:a}}).range(this.toEditorPos(r.rangeStart),this.toEditorPos(r.rangeEnd)))}}e.dispatch({effects:xh.of(Q.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=Ji(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=f,this.to+=f;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(rthis.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},$=class s{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||gu(e.parent)||document,this.viewState=new pn(e.state||X.create(e)),e.scrollTo&&e.scrollTo.is(Gs)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(_i).map(n=>new Yi(n));for(let n of this.plugins)n.update(this);this.observer=new bo(this),this.inputState=new no(this),this.inputState.ensureHandlers(this.plugins),this.docView=new fn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof de?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn\'t start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Rh))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Fh(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(X.phrases)!=this.state.facet(X.phrases))return this.setState(r);n=hn.create(this,r,e),n.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new Ui(d.empty?d:P.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Gs)&&(c=d.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=mn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(Ki)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(en)!=n.state.facet(en)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(eo))try{u(n)}catch(d){Le(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Dh(this,f)&&h.force&&ci(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new pn(e),this.plugins=e.facet(_i).map(i=>new Yi(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new fn(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(_i),i=e.state.facet(_i);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new Yi(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Za(i))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(n);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(d=>{try{return d.read(this)}catch(p){return Le(this.state,p),Ua}}),c=hn.create(this,this.state,[]),u=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d1||p<-1){n=n+p,i.scrollTop=n/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(eo))l(t)}get themeClasses(){return go+" "+(this.state.facet(mo)?Hh:Vh)+" "+this.state.facet(en)}updateAttrs(){let e=Ya(this,Ch,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(bt)?"true":"false",class:"cm-content",style:`${T.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ya(this,Co,t);let i=this.observer.ignore(()=>{let n=Gr(this.contentDOM,this.contentAttrs,t),r=Gr(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(s.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(Ki);let e=this.state.facet(s.cspNonce);ve.mount(this.root,this.styleModules.concat(xd).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn\'t allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return _r(this,e,Da(this,e,t,i))}moveByGroup(e,t){return _r(this,e,Da(this,e,t,i=>Yu(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return P.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return Uu(this,e,t,i)}moveVertically(e,t,i){return _r(this,e,Gu(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Nh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),o=r[je.find(r,e-n.from,-1,t)];return gn(i,o.dir==ie.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Sh)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Md)return dh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||uh(r.isolates,i=Ma(this,e))))return r.order;i||(i=Ma(this,e));let n=Eu(e.text,t,i);return this.bidiCache.push(new mn(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||T.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Xa(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Gs.of(new Ui(typeof e=="number"?P.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Gs.of(new Ui(P.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ut.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ut.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ve.newName(),n=[en.of(i),Ki.of(yo(`.${i}`,e))];return t&&t.dark&&n.push(mo.of(!0)),n}static baseTheme(e){return js.lowest(Ki.of(yo("."+go,e,_h)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&z.get(i)||z.get(e);return((t=n==null?void 0:n.rootView)===null||t===void 0?void 0:t.view)||null}};$.styleModule=Ki;$.inputHandler=wh;$.clipboardInputFilter=vo;$.clipboardOutputFilter=xo;$.scrollHandler=vh;$.focusChangeEffect=kh;$.perLineTextDirection=Sh;$.exceptionSink=bh;$.updateListener=eo;$.editable=bt;$.mouseSelectionStyle=yh;$.dragMovesSelection=gh;$.clickAddsSelectionRange=mh;$.decorations=is;$.outerDecorations=Ah;$.atomicRanges=Ao;$.bidiIsolatedRanges=Mh;$.scrollMargins=Oh;$.darkTheme=mo;$.cspNonce=R.define({combine:s=>s.length?s[0]:""});$.contentAttributes=Co;$.editorAttributes=Ch;$.lineWrapping=$.contentAttributes.of({class:"cm-lineWrapping"});$.announce=J.define();var Md=4096,Ua={},mn=class s{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:ie.LTR;for(let r=Math.max(0,e.length-10);r=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&Yr(o,t)}return t}var tm=T.mac?"mac":T.windows?"win":T.linux?"linux":"key";var Od=!T.ios;var Ga={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Od&&(Ga[".cm-line"].caretColor=Ga[".cm-content"].caretColor="transparent !important");var im=/x/.unicode!=null?"gu":"g";var sm=$.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"\'\'",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var ut=class extends ft{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};ut.prototype.elementClass="";ut.prototype.toDOM=void 0;ut.prototype.mapMode=ue.TrackBefore;ut.prototype.startSide=ut.prototype.endSide=-1;ut.prototype.point=!0;var Td=0,ss=class{constructor(e,t){this.from=e,this.to=t}},W=class{constructor(e={}){this.id=Td++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn\'t define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can\'t add per-node props to node types");return typeof e!="function"&&(e=we.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};W.closedBy=new W({deserialize:s=>s.split(" ")});W.openedBy=new W({deserialize:s=>s.split(" ")});W.group=new W({deserialize:s=>s.split(" ")});W.isolate=new W({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});W.contextHash=new W({perNode:!0});W.lookAhead=new W({perNode:!0});W.mounted=new W({perNode:!0});var pi=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[W.mounted.id]}},Ed=Object.create(null),we=class s{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Ed,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new s(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can\'t store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(W.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(W.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}};we.none=new we("",Object.create(null),0,8);var wn=new WeakMap,Kh=new WeakMap,se;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays"})(se||(se={}));var ae=class s{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=pi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new os(this.topNode,e)}cursorAt(e,t=0,i=0){let n=wn.get(this)||this.topNode,r=new os(n);return r.moveTo(e,t),wn.set(this,r._tree),r}get topNode(){return new Ge(this,0,0,null)}resolve(e,t=0){let i=ns(wn.get(this)||this.topNode,e,t,!1);return wn.set(this,i),i}resolveInner(e,t=0){let i=ns(Kh.get(this)||this.topNode,e,t,!0);return Kh.set(this,i),i}resolveStack(e,t=0){return Nd(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&se.IncludeAnonymous)>0;for(let a=this.cursor(o|se.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Po(we.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new s(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new s(we.none,t,i,n)))}static build(e){return Dd(e)}};ae.empty=new ae(we.none,[],[],0);var Oo=class s{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new s(this.buffer,this.index)}},xt=class s{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return we.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ns(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to0?l.length:-1;e!=h;e+=t){let f=l[e],c=a[e]+o.from;if(jh(n,i,c,c+f.length)){if(f instanceof xt){if(r&se.ExcludeBuffers)continue;let u=f.findChild(0,f.buffer.length,t,i-c,n);if(u>-1)return new rs(new Eo(o,f,e,c),null,u)}else if(r&se.IncludeAnonymous||!f.type.isAnonymous||Lo(f)){let u;if(!(r&se.IgnoreMounts)&&(u=pi.get(f))&&!u.overlay)return new s(u.tree,c,e,o);let d=new s(f,c,e,o);return r&se.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?f.children.length-1:0,t,i,n)}}}if(r&se.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let n;if(!(i&se.IgnoreOverlays)&&(n=pi.get(this._tree))&&n.overlay){let r=e-this.from;for(let{from:o,to:l}of n.overlay)if((t>0?o<=r:o=r:l>r))return new s(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Wh(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function To(s,e,t=e.length-1){for(let i=s.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Eo=class{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}},rs=class s extends Sn{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new s(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&se.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new s(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new s(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new s(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new ae(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function zh(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;rt.from||o.to=e){let l=new Ge(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(ns(l,e,t,!1))}}return n?zh(n):i}var os=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Ge)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof Ge?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&se.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&se.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&se.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&se.IncludeAnonymous||l instanceof xt||!l.type.isAnonymous||Lo(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n=0;r--){if(r<0)return To(this.node,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}};function Lo(s){return s.children.some(e=>e instanceof xt||!e.type.isAnonymous||Lo(e))}function Dd(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=1024,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new Oo(t,t.length):t,a=i.types,h=0,f=0;function c(v,M,O,C,L,N){let{id:D,start:B,end:q,size:I}=l,ne=f;for(;I<0;)if(l.next(),I==-1){let lt=r[D];O.push(lt),C.push(B-v);return}else if(I==-3){h=D;return}else if(I==-4){f=D;return}else throw new RangeError(`Unrecognized record size: ${I}`);let Pt=a[D],ti,Bt,Nl=B-v;if(q-B<=n&&(Bt=g(l.pos-M,L))){let lt=new Uint16Array(Bt.size-Bt.skip),Se=l.pos-Bt.size,He=lt.length;for(;l.pos>Se;)He=y(Bt.start,lt,He);ti=new xt(lt,q-Bt.start,i),Nl=Bt.start-v}else{let lt=l.pos-I;l.next();let Se=[],He=[],It=D>=o?D:-1,ii=0,Ds=q;for(;l.pos>lt;)It>=0&&l.id==It&&l.size>=0?(l.end<=Ds-n&&(p(Se,He,B,ii,l.end,Ds,It,ne),ii=Se.length,Ds=l.end),l.next()):N>2500?u(B,lt,Se,He):c(B,lt,Se,He,It,N+1);if(It>=0&&ii>0&&ii-1&&ii>0){let Dl=d(Pt);ti=Po(Pt,Se,He,0,Se.length,0,q-B,Dl,Dl)}else ti=m(Pt,Se,He,q-B,ne-q)}O.push(ti),C.push(Nl)}function u(v,M,O,C){let L=[],N=0,D=-1;for(;l.pos>M;){let{id:B,start:q,end:I,size:ne}=l;if(ne>4)l.next();else{if(D>-1&&q=0;I-=3)B[ne++]=L[I],B[ne++]=L[I+1]-q,B[ne++]=L[I+2]-q,B[ne++]=ne;O.push(new xt(B,L[2]-q,i)),C.push(q-v)}}function d(v){return(M,O,C)=>{let L=0,N=M.length-1,D,B;if(N>=0&&(D=M[N])instanceof ae){if(!N&&D.type==v&&D.length==C)return D;(B=D.prop(W.lookAhead))&&(L=O[N]+D.length+B)}return m(v,M,O,C,L)}}function p(v,M,O,C,L,N,D,B){let q=[],I=[];for(;v.length>C;)q.push(v.pop()),I.push(M.pop()+O-L);v.push(m(i.types[D],q,I,N-L,B-N)),M.push(L-O)}function m(v,M,O,C,L=0,N){if(h){let D=[W.contextHash,h];N=N?[D].concat(N):[D]}if(L>25){let D=[W.lookAhead,L];N=N?[D].concat(N):[D]}return new ae(v,M,O,C,N)}function g(v,M){let O=l.fork(),C=0,L=0,N=0,D=O.end-n,B={size:0,start:0,skip:0};e:for(let q=O.pos-v;O.pos>q;){let I=O.size;if(O.id==M&&I>=0){B.size=C,B.start=L,B.skip=N,N+=4,C+=4,O.next();continue}let ne=O.pos-I;if(I<0||ne=o?4:0,ti=O.start;for(O.next();O.pos>ne;){if(O.size<0)if(O.size==-3)Pt+=4;else break e;else O.id>=o&&(Pt+=4);O.next()}L=ti,C+=I,N+=Pt}return(M<0||C==v)&&(B.size=C,B.start=L,B.skip=N),B.size>4?B:void 0}function y(v,M,O){let{id:C,start:L,end:N,size:D}=l;if(l.next(),D>=0&&C4){let q=l.pos-(D-4);for(;l.pos>q;)O=y(v,M,O)}M[--O]=B,M[--O]=N-v,M[--O]=L-v,M[--O]=C}else D==-3?h=C:D==-4&&(f=C);return O}let w=[],x=[];for(;l.pos>0;)c(s.start||0,s.bufferStart||0,w,x,-1,0);let S=(e=s.length)!==null&&e!==void 0?e:w.length?x[0]+w[0].length:0;return new ae(a[s.topID],w.reverse(),x.reverse(),S)}var qh=new WeakMap;function kn(s,e){if(!s.isAnonymous||e instanceof xt||e.type!=s)return 1;let t=qh.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof ae)){t=1;break}t+=kn(s,i)}qh.set(e,t)}return t}function Po(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p=f)break;M+=O}if(x==S+1){if(M>f){let O=p[S];d(O.children,O.positions,0,O.children.length,m[S]+w);continue}c.push(p[S])}else{let O=m[x-1]+p[x-1].length-v;c.push(Po(s,p,m,S,x,v,O,null,a))}u.push(v+w-r)}}return d(e,t,i,n,0),(l||a)(c,u,o)}var Yt=class s{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new s(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l=i)for(;o&&o.from=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new s(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&n.push(u),o.to>c)break;o=rnew ss(n.from,n.to)):[new ss(0,0)]:[new ss(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}},Do=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var rm=new W({perNode:!0});var Ld=0,Be=class s{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=Ld++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof s&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let n=new s(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new Mn(e);return i=>i.modified.indexOf(t)>-1?i:Mn.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}},Pd=0,Mn=class s{constructor(e){this.name=e,this.instances=[],this.id=Pd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Bd(t,l.modified));if(i)return i;let n=[],r=new Be(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=Id(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(s.get(l,a));return r}};function Bd(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function Id(s){let e=[[]];for(let t=0;ti.length-t.length)}function Gh(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],o=2,l=n;for(let c=0;;){if(l=="..."&&c>0&&c+3==n.length){o=1;break}let u=/^"(?:[^"\\\\]|\\\\.)*?"|[^\\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]==\'"\'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==n.length)break;let d=n[c++];if(c==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let f=new mi(i,o,a>0?r.slice(0,a):null);e[h]=f.sort(e[h])}}return Jh.add(e)}var Jh=new W,mi=class{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Rd(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Xh(s,e,t,i=0,n=s.length){let r=new Io(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}var Io=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,f=Fd(e)||mi.empty,c=Rd(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,l),h),f.opaque)return;let u=e.tree&&e.tree.prop(W.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let w=g=x||!e.nextSibling())););if(!w||x>i)break;y=w.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function Fd(s){let e=s.type.prop(Jh);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}var A=Be.define,xn=A(),Ct=A(),Uh=A(Ct),Yh=A(Ct),At=A(),Cn=A(At),Bo=A(At),Qe=A(),Gt=A(Qe),Je=A(),Xe=A(),Ro=A(),ls=A(Ro),An=A(),b={comment:xn,lineComment:A(xn),blockComment:A(xn),docComment:A(xn),name:Ct,variableName:A(Ct),typeName:Uh,tagName:A(Uh),propertyName:Yh,attributeName:A(Yh),className:A(Ct),labelName:A(Ct),namespace:A(Ct),macroName:A(Ct),literal:At,string:Cn,docString:A(Cn),character:A(Cn),attributeValue:A(Cn),number:Bo,integer:A(Bo),float:A(Bo),bool:A(At),regexp:A(At),escape:A(At),color:A(At),url:A(At),keyword:Je,self:A(Je),null:A(Je),atom:A(Je),unit:A(Je),modifier:A(Je),operatorKeyword:A(Je),controlKeyword:A(Je),definitionKeyword:A(Je),moduleKeyword:A(Je),operator:Xe,derefOperator:A(Xe),arithmeticOperator:A(Xe),logicOperator:A(Xe),bitwiseOperator:A(Xe),compareOperator:A(Xe),updateOperator:A(Xe),definitionOperator:A(Xe),typeOperator:A(Xe),controlOperator:A(Xe),punctuation:Ro,separator:A(Ro),bracket:ls,angleBracket:A(ls),squareBracket:A(ls),paren:A(ls),brace:A(ls),content:Qe,heading:Gt,heading1:A(Gt),heading2:A(Gt),heading3:A(Gt),heading4:A(Gt),heading5:A(Gt),heading6:A(Gt),contentSeparator:A(Qe),list:A(Qe),quote:A(Qe),emphasis:A(Qe),strong:A(Qe),link:A(Qe),monospace:A(Qe),strikethrough:A(Qe),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:An,documentMeta:A(An),annotation:A(An),processingInstruction:A(An),definition:Be.defineModifier("definition"),constant:Be.defineModifier("constant"),function:Be.defineModifier("function"),standard:Be.defineModifier("standard"),local:Be.defineModifier("local"),special:Be.defineModifier("special")};for(let s in b){let e=b[s];e instanceof Be&&(e.name=s)}var am=Fo([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);var $o,hs=new W;var $d=new W,Ae=class{constructor(e,t,i=[],n=""){this.data=e,this.name=n,X.prototype.hasOwnProperty("tree")||Object.defineProperty(X.prototype,"tree",{get(){return fs(this)}}),this.parser=t,this.extension=[gi.of(this),X.languageData.of((r,o,l)=>{let a=Qh(r,o,l),h=a.type.prop(hs);if(!h)return[];let f=r.facet(h),c=a.type.prop($d);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(e,t,i=-1){return Qh(e,t,i).type.prop(hs)==this.data}findRegions(e){let t=e.facet(gi);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(hs)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(W.mounted);if(l){if(l.tree.prop(hs)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},as=null,Wo=class s{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new s(e,t,[],ae.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Ko(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ae.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Yt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=as;as=this;try{return e()}finally{as=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Zh(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=Yt.applyChanges(i,a),n=ae.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);fe.from&&(this.fragments=Zh(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends vn{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=as;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ae(we.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return as}};function Zh(s,e,t){return Yt.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}var cs=class s{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new s(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Wo.create(e.facet(gi).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new s(i)}};Ae.state=at.define({create:cs.init,update(s,e){for(let t of e.effects)if(t.is(Ae.setState))return t.value;return e.startState.facet(gi)!=e.state.facet(gi)?cs.init(e.state):s.apply(e)}});var nf=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(nf=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Vo=typeof navigator!="undefined"&&(!(($o=navigator.scheduling)===null||$o===void 0)&&$o.isInputPending)?()=>navigator.scheduling.isInputPending():null,Vd=Ut.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Ae.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Ae.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=nf(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,a=r.context.work(()=>Vo&&Vo()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ae.setState.of(new cs(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Le(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),gi=R.define({combine(s){return s.length?s[0]:null},enables:s=>[Ae.state,Vd,$.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});var Mt=class s{constructor(e,t){this.specs=e;let i;function n(l){let a=ve.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof Ae?l=>l.prop(hs)==o.data:o?l=>l==o:void 0,this.style=Fo(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new ve(i):null,this.themeType=t.themeType}static define(e,t){return new s(e,t||{})}},qo=R.define(),rf=R.define({combine(s){return s.length?[s[0]]:null}});function Ho(s){let e=s.facet(qo);return e.length?e:s.facet(rf)}function On(s,e){let t=[Hd],i;return s instanceof Mt&&(s.module&&t.push($.styleModule.of(s.module)),i=s.themeType),e!=null&&e.fallback?t.push(rf.of(s)):i?t.push(qo.computeN([$.darkTheme],n=>n.facet($.darkTheme)==(i=="dark")?[s]:[])):t.push(qo.of(s)),t}var jo=class{constructor(e){this.markCache=Object.create(null),this.tree=fs(e.state),this.decorations=this.buildDeco(e,Ho(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=fs(e.state),i=Ho(e.state),n=i!=Ho(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return Q.none;let i=new _t;for(let{from:n,to:r}of e.visibleRanges)Xh(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Q.mark({class:a})))},n,r);return i.finish()}},Hd=js.high(Ut.fromClass(jo,{decorations:s=>s.decorations})),bm=Mt.define([{tag:b.meta,color:"#404740"},{tag:b.link,textDecoration:"underline"},{tag:b.heading,textDecoration:"underline",fontWeight:"bold"},{tag:b.emphasis,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold"},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.keyword,color:"#708"},{tag:[b.atom,b.bool,b.url,b.contentSeparator,b.labelName],color:"#219"},{tag:[b.literal,b.inserted],color:"#164"},{tag:[b.string,b.deleted],color:"#a11"},{tag:[b.regexp,b.escape,b.special(b.string)],color:"#e40"},{tag:b.definition(b.variableName),color:"#00f"},{tag:b.local(b.variableName),color:"#30a"},{tag:[b.typeName,b.namespace],color:"#085"},{tag:b.className,color:"#167"},{tag:[b.special(b.variableName),b.macroName],color:"#256"},{tag:b.definition(b.propertyName),color:"#00c"},{tag:b.comment,color:"#940"},{tag:b.invalid,color:"#f00"}]);var _d=Object.create(null),ef=[we.none];var tf=[],sf=Object.create(null),Kd=Object.create(null);for(let[s,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"]])Kd[s]=Wd(_d,e);function _o(s,e){tf.indexOf(s)>-1||(tf.push(s),console.warn(e))}function Wd(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=s[h]||b[h];f?typeof f=="function"?a.length?a=a.map(f):_o(h,`Modifier ${h} used at start of tag`):a.length?_o(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:_o(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=sf[n];if(r)return r.id;let o=sf[n]=we.define({id:ef.length,name:i,props:[Gh({[i]:t})]});return ef.push(o),o.id}var wm={rtl:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ie.RTL}),ltr:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ie.LTR}),auto:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var qd="#abb2bf",jd="#7d8799",zd="#ffffff",Ud="#21252b",zo="rgba(0, 0, 0, 0.5)",Yd="#292d3e",Uo="#353a42",Gd="rgba(128, 203, 196, 0.2)",of="#ffcc00",Jd=$.theme({"&":{color:"#ffffff",backgroundColor:Yd},".cm-content":{caretColor:of},"&.cm-focused .cm-cursor":{borderLeftColor:of},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Gd},".cm-panels":{backgroundColor:Ud,color:"#ffffff"},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:zo},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{background:"#292d3e",color:"#676e95",border:"none"},".cm-activeLineGutter":{backgroundColor:zo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Uo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Uo,borderBottomColor:Uo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:zo,color:qd}}},{dark:!0}),Xd=Mt.define([{tag:b.keyword,color:"#c792ea"},{tag:b.operator,color:"#89ddff"},{tag:b.special(b.variableName),color:"#eeffff"},{tag:b.typeName,color:"#f07178"},{tag:b.atom,color:"#f78c6c"},{tag:b.number,color:"#ff5370"},{tag:b.definition(b.variableName),color:"#82aaff"},{tag:b.string,color:"#c3e88d"},{tag:b.special(b.string),color:"#f07178"},{tag:b.comment,color:jd},{tag:b.variableName,color:"#f07178"},{tag:b.tagName,color:"#ff5370"},{tag:b.bracket,color:"#a2a1a4"},{tag:b.meta,color:"#ffcb6b"},{tag:b.attributeName,color:"#c792ea"},{tag:b.propertyName,color:"#c792ea"},{tag:b.className,color:"#decb6b"},{tag:b.invalid,color:zd}]),Qd=[Jd,On(Xd)];var lf="#2e3440",Zo="#3b4252",af="#434c5e",Tn="#4c566a";var hf="#e5e9f0",Qo="#eceff4",Yo="#8fbcbb",ff="#88c0d0",Zd="#81a1c1",Ie="#5e81ac",ep="#bf616a",yi="#d08770",Go="#ebcb8b",cf="#a3be8c",tp="#b48ead",uf="#d30102",el=Qo,Jo=el,ip="#ffffff",Xo=Zo,sp=el,df=Zo,pf=$.theme({"&":{color:lf,backgroundColor:ip},".cm-content":{caretColor:df},".cm-cursor, .cm-dropCursor":{borderLeftColor:df},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:sp},".cm-panels":{backgroundColor:el,color:Tn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${Tn}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:hf},".cm-activeLine":{backgroundColor:Jo},".cm-selectionMatch":{backgroundColor:hf},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Tn}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Qo},".cm-gutters":{backgroundColor:Qo,color:lf,border:"none"},".cm-activeLineGutter":{backgroundColor:Jo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Xo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Xo,borderBottomColor:Xo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Jo,color:Tn}}},{dark:!1}),np=Mt.define([{tag:b.keyword,color:Ie},{tag:[b.name,b.deleted,b.character,b.propertyName,b.macroName],color:yi},{tag:[b.variableName],color:yi},{tag:[b.function(b.variableName)],color:Ie},{tag:[b.labelName],color:Zd},{tag:[b.color,b.constant(b.name),b.standard(b.name)],color:Ie},{tag:[b.definition(b.name),b.separator],color:cf},{tag:[b.brace],color:Yo},{tag:[b.annotation],color:uf},{tag:[b.number,b.changed,b.annotation,b.modifier,b.self,b.namespace],color:ff},{tag:[b.typeName,b.className],color:Go},{tag:[b.operator,b.operatorKeyword],color:cf},{tag:[b.tagName],color:tp},{tag:[b.squareBracket],color:ep},{tag:[b.angleBracket],color:yi},{tag:[b.attributeName],color:Go},{tag:[b.regexp],color:Ie},{tag:[b.quote],color:Zo},{tag:[b.string],color:yi},{tag:b.link,color:Yo,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[b.url,b.escape,b.special(b.string)],color:yi},{tag:[b.meta],color:ff},{tag:[b.comment],color:af,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold",color:Ie},{tag:b.emphasis,fontStyle:"italic",color:Ie},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.heading,fontWeight:"bold",color:Ie},{tag:b.special(b.heading1),fontWeight:"bold",color:Ie},{tag:b.heading1,fontWeight:"bold",color:Ie},{tag:[b.heading2,b.heading3,b.heading4],fontWeight:"bold",color:Ie},{tag:[b.heading5,b.heading6],color:Ie},{tag:[b.atom,b.bool,b.special(b.variableName)],color:yi},{tag:[b.processingInstruction,b.inserted],color:Yo},{tag:[b.contentSeparator],color:Go},{tag:b.invalid,color:af,borderBottom:`1px dotted ${uf}`}]),Nm=[pf,On(np)];var us=(s,e=0)=>{let t=[];if(e==5||!s||s==null)return"";if(typeof s=="string")return s;if(typeof s=="number")return`${s}`;if(Array.isArray(s))t.push(`${s.map(i=>us(i,e++)).join(" ")}`);else if(typeof s=="object")for(let[i,n]of Object.entries(s))t.push(us(i,e++),us(n,e++));return t.join(" ")};function bi(s=[],e=[]){s||(s=[]),Array.isArray(s)||(s=[s]),e||(e=[]),Array.isArray(e)||(e=[e]);for(let t of e!=null?e:[])if(t)if(Array.isArray(t)){let i=us(t.slice(1));s=s.filter(n=>n.name!=t[0]&&n.desc!=i),s.push({name:t[0],desc:i})}else typeof t=="object"&&("name"in t||"desc"in t)&&(s=s.filter(i=>{var n;return(!((n=i.name)!=null&&n.length)||i.name!=t.name)&&i.desc!=t.desc}),s.push(Rl(Il({},t),{name:t.name,desc:us(t.desc)})));return s}var Ol={};Fl(Ol,{Alias:()=>it,CST:()=>Cl,Composer:()=>Xt,Document:()=>nt,Lexer:()=>Pi,LineCounter:()=>Bi,Pair:()=>Y,Parser:()=>Zt,Scalar:()=>E,Schema:()=>Ti,YAMLError:()=>Ni,YAMLMap:()=>G,YAMLParseError:()=>ke,YAMLSeq:()=>oe,YAMLWarning:()=>Di,isAlias:()=>Oe,isCollection:()=>_,isDocument:()=>Ze,isMap:()=>Te,isNode:()=>H,isPair:()=>V,isScalar:()=>F,isSeq:()=>Ee,parse:()=>fc,parseAllDocuments:()=>hc,parseDocument:()=>Ml,stringify:()=>cc,visit:()=>Ne,visitAsync:()=>ds});var En=Symbol.for("yaml.alias"),Nn=Symbol.for("yaml.document"),Re=Symbol.for("yaml.map"),tl=Symbol.for("yaml.pair"),Me=Symbol.for("yaml.scalar"),dt=Symbol.for("yaml.seq"),ce=Symbol.for("yaml.node.type"),Oe=s=>!!s&&typeof s=="object"&&s[ce]===En,Ze=s=>!!s&&typeof s=="object"&&s[ce]===Nn,Te=s=>!!s&&typeof s=="object"&&s[ce]===Re,V=s=>!!s&&typeof s=="object"&&s[ce]===tl,F=s=>!!s&&typeof s=="object"&&s[ce]===Me,Ee=s=>!!s&&typeof s=="object"&&s[ce]===dt;function _(s){if(s&&typeof s=="object")switch(s[ce]){case Re:case dt:return!0}return!1}function H(s){if(s&&typeof s=="object")switch(s[ce]){case En:case Re:case Me:case dt:return!0}return!1}var mf=s=>(F(s)||_(s))&&!!s.anchor;var me=Symbol("break visit"),gf=Symbol("skip children"),et=Symbol("remove node");function Ne(s,e){let t=yf(e);Ze(s)?wi(null,s.contents,t,Object.freeze([s]))===et&&(s.contents=null):wi(null,s,t,Object.freeze([]))}Ne.BREAK=me;Ne.SKIP=gf;Ne.REMOVE=et;function wi(s,e,t,i){let n=bf(s,e,t,i);if(H(n)||V(n))return wf(s,i,n),wi(s,n,t,i);if(typeof n!="symbol"){if(_(e)){i=Object.freeze(i.concat(e));for(let r=0;rs.replace(/[!,[\\]{}]/g,e=>rp[e]),tt=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \\t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\\d+\\.\\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren\'t resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(new RegExp("^(.*!)([^!]*)$","s"));n||t(`The ${e} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return t(String(o)),null}return i==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,i]of Object.entries(this.tags))if(e.startsWith(i))return t+op(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&H(e.contents)){let r={};Ne(e.contents,(o,l)=>{H(l)&&l.tag&&(r[l.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`\n`)}};tt.defaultYaml={explicit:!1,version:"1.2"};tt.defaultTags={"!!":"tag:yaml.org,2002:"};function Dn(s){if(/[\\x00-\\x19\\s,[\\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function il(s){let e=new Set;return Ne(s,{Value(t,i){i.anchor&&e.add(i.anchor)}}),e}function sl(s,e){for(let t=1;;++t){let i=`${s}${t}`;if(!e.has(i))return i}}function kf(s,e){let t=[],i=new Map,n=null;return{onAnchor:r=>{t.push(r),n||(n=il(s));let o=sl(e,n);return n.add(o),o},setAnchors:()=>{for(let r of t){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(F(o.node)||_(o.node)))o.node.anchor=o.anchor;else{let l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=r,l}}},sourceObjects:i}}function Ot(s,e,t,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;nte(i,String(n),t));if(s&&typeof s.toJSON=="function"){if(!t||!mf(s))return s.toJSON(e,t);let i={aliasCount:0,count:1,res:void 0};t.anchors.set(s,i),t.onCreate=r=>{i.res=r,delete t.onCreate};let n=s.toJSON(e,t);return t.onCreate&&t.onCreate(n),n}return typeof s=="bigint"&&!(t!=null&&t.keep)?Number(s):s}var Tt=class{constructor(e){Object.defineProperty(this,ce,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:i,onAnchor:n,reviver:r}={}){if(!Ze(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=te(this,"",o);if(typeof n=="function")for(let{count:a,res:h}of o.anchors.values())n(h,a);return typeof r=="function"?Ot(r,{"":l},"",l):l}};var it=class extends Tt{constructor(e){super(En),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return Ne(e,{Node:(i,n)=>{if(n===this)return Ne.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=t,o=this.resolve(n);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}let l=i.get(o);if(l||(te(o,null,t),l=i.get(o)),!l||l.res===void 0){let a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(r>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Ln(n,o,i)),l.count*l.aliasCount>r)){let a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return l.res}toString(e,t,i){let n=`*${this.source}`;if(e){if(Dn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${n} `}return n}};function Ln(s,e,t){if(Oe(e)){let i=e.resolve(s),n=t&&i&&t.get(i);return n?n.count*n.aliasCount:0}else if(_(e)){let i=0;for(let n of e.items){let r=Ln(s,n,t);r>i&&(i=r)}return i}else if(V(e)){let i=Ln(s,e.key,t),n=Ln(s,e.value,t);return Math.max(i,n)}return 1}var Pn=s=>!s||typeof s!="function"&&typeof s!="object",E=class extends Tt{constructor(e){super(Me),this.value=e}toJSON(e,t){return t!=null&&t.keep?this.value:te(this.value,e,t)}toString(){return String(this.value)}};E.BLOCK_FOLDED="BLOCK_FOLDED";E.BLOCK_LITERAL="BLOCK_LITERAL";E.PLAIN="PLAIN";E.QUOTE_DOUBLE="QUOTE_DOUBLE";E.QUOTE_SINGLE="QUOTE_SINGLE";var lp="tag:yaml.org,2002:";function ap(s,e,t){var i;if(e){let n=t.filter(o=>o.tag===e),r=(i=n.find(o=>!o.format))!=null?i:n[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return t.find(n=>{var r;return((r=n.identify)==null?void 0:r.call(n,s))&&!n.format})}function pt(s,e,t){var c,u,d;if(Ze(s)&&(s=s.contents),H(s))return s;if(V(s)){let p=(u=(c=t.schema[Re]).createNode)==null?void 0:u.call(c,t.schema,null,t);return p.items.push(s),p}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt!="undefined"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:l}=t,a;if(i&&s&&typeof s=="object"){if(a=l.get(s),a)return a.anchor||(a.anchor=n(s)),new it(a.anchor);a={anchor:null,node:null},l.set(s,a)}e!=null&&e.startsWith("!!")&&(e=lp+e.slice(2));let h=ap(s,e,o.tags);if(!h){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let p=new E(s);return a&&(a.node=p),p}h=s instanceof Map?o[Re]:Symbol.iterator in Object(s)?o[dt]:o[Re]}r&&(r(h),delete t.onTagObj);let f=h!=null&&h.createNode?h.createNode(t.schema,s,t):typeof((d=h==null?void 0:h.nodeClass)==null?void 0:d.from)=="function"?h.nodeClass.from(t.schema,s,t):new E(s);return e?f.tag=e:h.default||(f.tag=h.tag),a&&(a.node=f),f}function ps(s,e,t){let i=t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return pt(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var vi=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,Si=class extends Tt{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(i=>H(i)||V(i)?i.clone(e):i),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(vi(e))this.add(t);else{let[i,...n]=e,r=this.get(i,!0);if(_(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(i,ps(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[t,...i]=e;if(i.length===0)return this.delete(t);let n=this.get(t,!0);if(_(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${i}`)}getIn(e,t){let[i,...n]=e,r=this.get(i,!0);return n.length===0?!t&&F(r)?r.value:r:_(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!V(t))return!1;let i=t.value;return i==null||e&&F(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[t,...i]=e;if(i.length===0)return this.has(t);let n=this.get(t,!0);return _(n)?n.hasIn(i):!1}setIn(e,t){let[i,...n]=e;if(n.length===0)this.set(i,t);else{let r=this.get(i,!0);if(_(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(i,ps(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};var Sf=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function De(s,e){return/^\\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var st=(s,e,t)=>s.endsWith(`\n`)?De(t,e):t.includes(`\n`)?`\n`+De(t,e):(s.endsWith(" ")?"":" ")+t;var nl="flow",Bn="block",ms="quoted";function gs(s,e,t="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:l}={}){if(!n||n<0)return s;nn-Math.max(2,r)?h.push(0):c=n-i);let u,d,p=!1,m=-1,g=-1,y=-1;t===Bn&&(m=vf(s,m,e.length),m!==-1&&(c=m+a));for(let x;x=s[m+=1];){if(t===ms&&x==="\\\\"){switch(g=m,s[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(x===`\n`)t===Bn&&(m=vf(s,m,e.length)),c=m+e.length+a,u=void 0;else{if(x===" "&&d&&d!==" "&&d!==`\n`&&d!==" "){let S=s[m+1];S&&S!==" "&&S!==`\n`&&S!==" "&&(u=m)}if(m>=c)if(u)h.push(u),c=u+a,u=void 0;else if(t===ms){for(;d===" "||d===" ";)d=x,x=s[m+=1],p=!0;let S=m>y+1?m-2:g-1;if(f[S])return s;h.push(S),f[S]=!0,c=S+a,u=void 0}else p=!0}d=x}if(p&&l&&l(),h.length===0)return s;o&&o();let w=s.slice(0,h[0]);for(let x=0;x({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),Fn=s=>/^(%|---|\\.\\.\\.)/m.test(s);function hp(s,e,t){if(!e||e<0)return!1;let i=e-t,n=s.length;if(n<=i)return!1;for(let r=0,o=0;ri)return!0;if(o=r+1,n-o<=i)return!1}return!0}function ys(s,e){let t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(Fn(s)?" ":""),o="",l=0;for(let a=0,h=t[a];h;h=t[++a])if(h===" "&&t[a+1]==="\\\\"&&t[a+2]==="n"&&(o+=t.slice(l,a)+"\\\\ ",a+=1,l=a,h="\\\\"),h==="\\\\")switch(t[a+1]){case"u":{o+=t.slice(l,a);let f=t.substr(a+2,4);switch(f){case"0000":o+="\\\\0";break;case"0007":o+="\\\\a";break;case"000b":o+="\\\\v";break;case"001b":o+="\\\\e";break;case"0085":o+="\\\\N";break;case"00a0":o+="\\\\_";break;case"2028":o+="\\\\L";break;case"2029":o+="\\\\P";break;default:f.substr(0,2)==="00"?o+="\\\\x"+f.substr(2):o+=t.substr(a,6)}a+=5,l=a+1}break;case"n":if(i||t[a+2]===\'"\'||t.length\n`;let c,u;for(u=t.length;u>0;--u){let M=t[u-1];if(M!==`\n`&&M!==" "&&M!==" ")break}let d=t.substring(u),p=d.indexOf(`\n`);p===-1?c="-":t===d||p!==d.length-1?(c="+",r&&r()):c="",d&&(t=t.slice(0,-d.length),d[d.length-1]===`\n`&&(d=d.slice(0,-1)),d=d.replace(ol,`$&${h}`));let m=!1,g,y=-1;for(g=0;g")+(m?h?"2":"1":"")+c;if(s&&(S+=" "+l(s.replace(/ ?[\\r\\n]+/g," ")),n&&n()),f)return t=t.replace(/\\n+/g,`$&${h}`),`${S}\n${h}${w}${t}${d}`;t=t.replace(/\\n+/g,`\n$&`).replace(/(?:^|\\n)([\\t ].*)(?:([\\n\\t ]*)\\n(?![\\n\\t ]))?/g,"$1$2").replace(/\\n+/g,`$&${h}`);let v=gs(`${w}${t}${d}`,h,Bn,Rn(i,!0));return`${S}\n${h}${v}`}function fp(s,e,t,i){let{type:n,value:r}=s,{actualString:o,implicitKey:l,indent:a,indentStep:h,inFlow:f}=e;if(l&&r.includes(`\n`)||f&&/[[\\]{},]/.test(r))return xi(r,e);if(!r||/^[\\n\\t ,[\\]{}#&*!|>\'"%@`]|^[?-]$|^[?-][ \\t]|[\\n:][ \\t]|[ \\t]\\n|[\\n\\t ]#|[\\n\\t :]$/.test(r))return l||f||!r.includes(`\n`)?xi(r,e):In(s,e,t,i);if(!l&&!f&&n!==E.PLAIN&&r.includes(`\n`))return In(s,e,t,i);if(Fn(r)){if(a==="")return e.forceBlockIndent=!0,In(s,e,t,i);if(l&&a===h)return xi(r,e)}let c=r.replace(/\\n+/g,`$&\n${a}`);if(o){let u=m=>{var g;return m.default&&m.tag!=="tag:yaml.org,2002:str"&&((g=m.test)==null?void 0:g.test(c))},{compat:d,tags:p}=e.doc.schema;if(p.some(u)||d!=null&&d.some(u))return xi(r,e)}return l?c:gs(c,a,nl,Rn(e,!1))}function mt(s,e,t,i){let{implicitKey:n,inFlow:r}=e,o=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)}),{type:l}=s;l!==E.QUOTE_DOUBLE&&/[\\x00-\\x08\\x0b-\\x1f\\x7f-\\x9f\\u{D800}-\\u{DFFF}]/u.test(o.value)&&(l=E.QUOTE_DOUBLE);let a=f=>{switch(f){case E.BLOCK_FOLDED:case E.BLOCK_LITERAL:return n||r?xi(o.value,e):In(o,e,t,i);case E.QUOTE_DOUBLE:return ys(o.value,e);case E.QUOTE_SINGLE:return rl(o.value,e);case E.PLAIN:return fp(o,e,t,i);default:return null}},h=a(l);if(h===null){let{defaultKeyType:f,defaultStringType:c}=e.options,u=n&&f||c;if(h=a(u),h===null)throw new Error(`Unsupported default string type ${u}`)}return h}function $n(s,e){let t=Object.assign({blockQuote:!0,commentString:Sf,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e),i;switch(t.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:i,options:t}}function cp(s,e){var n,r,o,l;if(e.tag){let a=s.filter(h=>h.tag===e.tag);if(a.length>0)return(n=a.find(h=>h.format===e.format))!=null?n:a[0]}let t,i;if(F(e)){i=e.value;let a=s.filter(h=>{var f;return(f=h.identify)==null?void 0:f.call(h,i)});t=(r=a.find(h=>h.format===e.format))!=null?r:a.find(h=>!h.format)}else i=e,t=s.find(a=>a.nodeClass&&i instanceof a.nodeClass);if(!t){let a=(l=(o=i==null?void 0:i.constructor)==null?void 0:o.name)!=null?l:typeof i;throw new Error(`Tag not resolved for ${a} value`)}return t}function up(s,e,{anchors:t,doc:i}){if(!i.directives)return"";let n=[],r=(F(s)||_(s))&&s.anchor;r&&Dn(r)&&(t.add(r),n.push(`&${r}`));let o=s.tag?s.tag:e.default?null:e.tag;return o&&n.push(i.directives.tagString(o)),n.join(" ")}function gt(s,e,t,i){var a,h;if(V(s))return s.toString(e,t,i);if(Oe(s)){if(e.doc.directives)return s.toString(e);if((a=e.resolvedAliases)!=null&&a.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let n,r=H(s)?s:e.doc.createNode(s,{onTagObj:f=>n=f});n||(n=cp(e.doc.schema.tags,r));let o=up(r,n,e);o.length>0&&(e.indentAtStart=((h=e.indentAtStart)!=null?h:0)+o.length+1);let l=typeof n.stringify=="function"?n.stringify(r,e,t,i):F(r)?mt(r,e,t,i):r.toString(e,t,i);return o?F(r)||l[0]==="{"||l[0]==="["?`${o} ${l}`:`${o}\n${e.indent}${l}`:l}function xf({key:s,value:e},t,i,n){var O,C;let{allNullValues:r,doc:o,indent:l,indentStep:a,options:{commentString:h,indentSeq:f,simpleKeys:c}}=t,u=H(s)&&s.comment||null;if(c){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(_(s)||!H(s)&&typeof s=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let d=!c&&(!s||u&&e==null&&!t.inFlow||_(s)||(F(s)?s.type===E.BLOCK_FOLDED||s.type===E.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!d&&(c||!r),indent:l+a});let p=!1,m=!1,g=gt(s,t,()=>p=!0,()=>m=!0);if(!d&&!t.inFlow&&g.length>1024){if(c)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(t.inFlow){if(r||e==null)return p&&i&&i(),g===""?"?":d?`? ${g}`:g}else if(r&&!c||e==null&&d)return g=`? ${g}`,u&&!p?g+=st(g,t.indent,h(u)):m&&n&&n(),g;p&&(u=null),d?(u&&(g+=st(g,t.indent,h(u))),g=`? ${g}\n${l}:`):(g=`${g}:`,u&&(g+=st(g,t.indent,h(u))));let y,w,x;H(e)?(y=!!e.spaceBefore,w=e.commentBefore,x=e.comment):(y=!1,w=null,x=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!d&&!u&&F(e)&&(t.indentAtStart=g.length+1),m=!1,!f&&a.length>=2&&!t.inFlow&&!d&&Ee(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1,v=gt(e,t,()=>S=!0,()=>m=!0),M=" ";if(u||y||w){if(M=y?`\n`:"",w){let L=h(w);M+=`\n${De(L,t.indent)}`}v===""&&!t.inFlow?M===`\n`&&(M=`\n\n`):M+=`\n${t.indent}`}else if(!d&&_(e)){let L=v[0],N=v.indexOf(`\n`),D=N!==-1,B=(C=(O=t.inFlow)!=null?O:e.flow)!=null?C:e.items.length===0;if(D||!B){let q=!1;if(D&&(L==="&"||L==="!")){let I=v.indexOf(" ");L==="&"&&I!==-1&&Is===Cf||F(s)&&s.value===Cf&&(!s.type||s.type===E.PLAIN);function ll(s,e,t){let i=s&&Oe(t)?t.resolve(s.doc):t;if(!Te(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,s,Map);for(let[r,o]of n)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function pp(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(H(s)&&(t!=null&&t.doc)){let i=$n(t.doc,{});i.anchors=new Set;for(let r of t.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=s.toString(i);if(!t.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+\'..."\'),Vn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return n}return JSON.stringify(e)}function Ci(s,e,t){let i=pt(s,void 0,t),n=pt(e,void 0,t);return new Y(i,n)}var Y=class s{constructor(e,t=null){Object.defineProperty(this,ce,{value:tl}),this.key=e,this.value=t}clone(e){let{key:t,value:i}=this;return H(t)&&(t=t.clone(e)),H(i)&&(i=i.clone(e)),new s(t,i)}toJSON(e,t){let i=t!=null&&t.mapAsMap?new Map:{};return Hn(t,i,this)}toString(e,t,i){return e!=null&&e.doc?xf(this,e,t,i):JSON.stringify(this)}};function Kn(s,e,t){var r;return(((r=e.inFlow)!=null?r:s.flow)?gp:mp)(s,e,t)}function mp({comment:s,items:e},t,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:l}){let{indent:a,options:{commentString:h}}=t,f=Object.assign({},t,{indent:r,type:null}),c=!1,u=[];for(let p=0;pg=null,()=>c=!0);g&&(y+=st(y,r,h(g))),c&&g&&(c=!1),u.push(i+y)}let d;if(u.length===0)d=n.start+n.end;else{d=u[0];for(let p=1;p