vzcode 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,7 +85,7 @@ Source:
85
85
  `&&t.lineWrapping&&(n&&(n=le.single(n.main.anchor-1,n.main.head-1)),r={from:i.from,to:i.to,insert:Bt.of([" "])}),r){if(Xe.ios&&t.inputState.flushIOSKey(r)||Xe.android&&(r.to==i.to&&(r.from==i.from||r.from==i.from-1&&t.state.sliceDoc(r.from,i.from)==" ")&&r.insert.length==1&&r.insert.lines==2&&Ql(t.contentDOM,"Enter",13)||(r.from==i.from-1&&r.to==i.to&&r.insert.length==0||o==8&&r.insert.length<r.to-r.from&&r.to>i.head)&&Ql(t.contentDOM,"Backspace",8)||r.from==i.from&&r.to==i.to+1&&r.insert.length==0&&Ql(t.contentDOM,"Delete",46)))return!0;let s=r.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a,l=()=>a||(a=_q(t,r,n));return t.state.facet(LE).some(c=>c(t,r.from,r.to,s,l))||t.dispatch(l()),!0}else if(n&&!n.main.eq(i)){let s=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(s=!0),a=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:s,userEvent:a}),!0}else return!1}function _q(t,e,r){let n,i=t.state,o=i.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!r||r.main.empty&&r.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=o.from<e.from?i.sliceDoc(o.from,e.from):"",l=o.to>e.to?i.sliceDoc(e.to,o.to):"";n=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+l))}else{let a=i.changes(e),l=r&&r.main.to<=a.newLength?r.main:void 0;if(i.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let c=t.state.sliceDoc(e.from,e.to),u,f=r&&JE(t,r.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=t.state.doc.lineAt(o.head);let h=o.to-e.to,d=o.to-o.from;n=i.changeByRange(p=>{if(p.from==o.from&&p.to==o.to)return{changes:a,range:l||p.map(a)};let O=p.to-h,m=O-c.length;if(p.to-p.from!=d||t.state.sliceDoc(m,O)!=c||p.to>=u.from&&p.from<=u.to)return{range:p};let y=i.changes({from:m,to:O,insert:e.insert}),g=p.to-o.to;return{changes:y,range:l?le.range(Math.max(0,l.anchor+g),Math.max(0,l.head+g)):p.map(y)}})}else n={changes:a,selection:l&&i.selection.replaceRange(l)}}let s="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,s+=".compose",t.inputState.compositionFirstChange&&(s+=".start",t.inputState.compositionFirstChange=!1)),i.update(n,{userEvent:s,scrollIntoView:!0})}function $q(t,e,r,n){let i=Math.min(t.length,e.length),o=0;for(;o<i&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==i&&t.length==e.length)return null;let s=t.length,a=e.length;for(;s>0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(n=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&t.length<e.length){let l=r<=o&&r>=s?o-r:0;o-=l,a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function Qq(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:o}=t.observer.selectionRange;return r&&(e.push(new XS(r,n)),(i!=r||o!=n)&&e.push(new XS(i,o))),e}function Eq(t,e){if(t.length==0)return null;let r=t[0].pos,n=t.length==2?t[1].pos:r;return r>-1&&n>-1?le.single(r+e,n+e):null}const Cq={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},yg=Xe.ie&&Xe.ie_version<=11;class Tq{constructor(e){this.view=e,this.active=!1,this.selectionRange=new pD,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(r=>{for(let n of r)this.queue.push(n);(Xe.ie&&Xe.ie_version<=11||Xe.ios&&e.composing)&&r.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),yg&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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 r;((r=this.view.docView)===null||r===void 0?void 0:r.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(r=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),r.length>0&&r[r.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(r=>{r.length>0&&r[r.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.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!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((r,n)=>r!=e[n]))){this.gapIntersection.disconnect();for(let r of e)this.gapIntersection.observe(r);this.gaps=e}}onSelectionChange(e){let r=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(PO)?n.root.activeElement!=this.dom:!jd(n.dom,i))return;let o=i.anchorNode&&n.docView.nearest(i.anchorNode);if(o&&o.ignoreEvent(e)){r||(this.selectionChanged=!1);return}(Xe.ie&&Xe.ie_version<=11||Xe.android&&Xe.chrome)&&!n.state.selection.main.empty&&i.focusNode&&mc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,r=Pp(e.root);if(!r)return!1;let n=Xe.safari&&e.root.nodeType==11&&cD(this.dom.ownerDocument)==this.dom&&Rq(this.view,r)||r;if(!n||this.selectionRange.eq(n))return!1;let i=jd(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&gD(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,r){this.selectionRange.set(e.node,e.offset,r.node,r.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,r=null;for(let n=this.dom;n;)if(n.nodeType==1)!r&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:r||(r=this.scrollTargets.slice(0,e)),r&&r.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!r&&(r=this.scrollTargets.slice(0,e)),r){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=r)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Cq),yg&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),yg&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,r){var n;if(!this.delayedAndroidKey){let i=()=>{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&Ql(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:r,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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 r=-1,n=-1,i=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(i=!0),r==-1?{from:r,to:n}=s:(r=Math.min(s.from,r),n=Math.max(s.to,n)))}return{from:r,to:n,typeOver:i}}readChange(){let{from:e,to:r,typeOver:n}=this.processRecords(),i=this.selectionChanged&&jd(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new xq(this.view,e,r,n);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let r=this.readChange();if(!r)return this.view.requestMeasure(),!1;let n=this.view.state,i=pC(this.view,r);return this.view.state==n&&this.view.update([]),i}readMutation(e){let r=this.view.docView.nearest(e.target);if(!r||r.ignoreMutation(e))return null;if(r.markDirty(e.type=="attributes"),e.type=="attributes"&&(r.flags|=4),e.type=="childList"){let n=US(r,e.previousSibling||e.target.previousSibling,-1),i=US(r,e.nextSibling||e.target.nextSibling,1);return{from:n?r.posAfter(n):r.posAtStart,to:i?r.posBefore(i):r.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:r.posAtStart,to:r.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("change",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("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,r,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(r=this.gapIntersection)===null||r===void 0||r.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function US(t,e,r){for(;e;){let n=rr.get(e);if(n&&n.parent==t)return n;let i=e.parentNode;e=i!=t.dom?i:r>0?e.nextSibling:e.previousSibling}return null}function FS(t,e){let r=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.docView.domAtPos(t.state.selection.main.anchor);return mc(s.node,s.offset,i,o)&&([r,n,i,o]=[i,o,r,n]),{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:o}}function Rq(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return FS(t,i)}let r=null;function n(i){i.preventDefault(),i.stopImmediatePropagation(),r=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),r?FS(t,r):null}class Ae{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={}){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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(n=>n.forEach(i=>r(i,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||OD(e.parent)||document,this.viewState=new LS(e.state||Dt.create(e)),e.scrollTo&&e.scrollTo.is(nh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Hu).map(n=>new pg(n));for(let n of this.plugins)n.update(this);this.observer=new Tq(this),this.inputState=new FD(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let r=e.length==1&&e[0]instanceof Nr?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(r,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let r=!1,n=!1,i,o=this.state;for(let h of e){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(aC))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=lC(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(u=null)):this.observer.clear(),o.facet(Dt.phrases)!=this.state.facet(Dt.phrases))return this.setState(o);i=xp.create(this,o,e),i.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection;f=new El(d.empty?d:le.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of h.effects)d.is(nh)&&(f=d.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=_p.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),r=this.docView.update(i),this.state.facet(Ku)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(r,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(uh)!=i.state.facet(uh)&&(this.viewState.mustMeasureContent=!0),(r||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),r&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(Ey))try{h(i)}catch(d){Tn(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!pC(this,u)&&c.force&&Ql(this.contentDOM,c.key,c.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 r=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new LS(e),this.plugins=e.facet(Hu).map(n=>new pg(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new xS(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}r&&this.focus(),this.requestMeasure()}updatePlugins(e){let r=e.startState.facet(Hu),n=e.state.facet(Hu);if(r!=n){let i=[];for(let o of n){let s=r.indexOf(o);if(s<0)i.push(new pg(o));else{let a=this.plugins[s];a.mustUpdate=e,i.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);r!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let r=e.value;if(r&&r.docViewUpdate)try{r.docViewUpdate(this)}catch(n){Tn(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let r=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(wE(n))o=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(i);o=d.from,s=d.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Tn(this.state,p),YS}}),f=xp.create(this,this.state,[]),h=!1;f.flags|=l,r?r.flags|=l:r=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(u[d]!=YS)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){Tn(this.state,p)}if(h&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let p=(o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-s;if(p>1||p<-1){i=i+p,n.scrollTop=i/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(r&&!r.empty)for(let a of this.state.facet(Ey))a(r)}get themeClasses(){return jy+" "+(this.state.facet(Ay)?hC:fC)+" "+this.state.facet(uh)}updateAttrs(){let e=zS(this,YE,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),r={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(PO)?"true":"false",class:"cm-content",style:`${Xe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(r["aria-readonly"]="true"),zS(this,A0,r);let n=this.observer.ignore(()=>{let i=ky(this.contentDOM,this.contentAttrs,r),o=ky(this.dom,this.editorAttrs,e);return i||o});return this.editorAttrs=e,this.contentAttrs=r,n}showAnnouncements(e){let r=!0;for(let n of e)for(let i of n.effects)if(i.is(Ae.announce)){r&&(this.announceDOM.textContent=""),r=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Ku);let e=this.state.facet(Ae.cspNonce);Ps.mount(this.root,this.styleModules.concat(wq).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 r=0;r<this.measureRequests.length;r++)if(this.measureRequests[r].key===e.key){this.measureRequests[r]=e;return}}this.measureRequests.push(e)}}plugin(e){let r=this.pluginMap.get(e);return(r===void 0||r&&r.spec!=e)&&this.pluginMap.set(e,r=this.plugins.find(n=>n.spec==e)||null),r&&r.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,r,n){return gg(this,e,TS(this,e,r,n))}moveByGroup(e,r){return gg(this,e,TS(this,e,r,n=>XD(this,e.head,n)))}visualLineSide(e,r){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),o=n[r?n.length-1:0];return le.cursor(o.side(r,i)+e.from,o.forward(!r,i)?1:-1)}moveToLineBoundary(e,r,n=!0){return VD(this,e,r,n)}moveVertically(e,r,n){return gg(this,e,UD(this,e,r,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,r=0){return this.docView.posFromDOM(e,r)}posAtCoords(e,r=!0){return this.readMeasured(),eC(this,e,r)}coordsAtPos(e,r=1){this.readMeasured();let n=this.docView.coordsAt(e,r);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),o=this.bidiSpans(i),s=o[ss.find(o,e-i.from,-1,r)];return E0(n,s.dir==dr.LTR==r>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(XE)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Aq)return qE(e.length);let r=this.textDirectionAt(e.from),n;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==r&&(o.fresh||DE(o.isolates,n=kS(this,e))))return o.order;n||(n=kS(this,e));let i=QD(e.text,r,n);return this.bidiCache.push(new _p(e.from,e.to,r,n,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Xe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{bE(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(){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,r={}){return nh.of(new El(typeof e=="number"?le.cursor(e):e,r.y,r.x,r.yMargin,r.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:r}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return nh.of(new El(le.cursor(n.from),"start","start",n.top-e,r,!0))}static domEventHandlers(e){return ar.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ar.define(()=>({}),{eventObservers:e})}static theme(e,r){let n=Ps.newName(),i=[uh.of(n),Ku.of(My(`.${n}`,e))];return r&&r.dark&&i.push(Ay.of(!0)),i}static baseTheme(e){return Zo.lowest(Ku.of(My("."+jy,e,dC)))}static findFromDOM(e){var r;let n=e.querySelector(".cm-content"),i=n&&rr.get(n)||rr.get(e);return((r=i==null?void 0:i.rootView)===null||r===void 0?void 0:r.view)||null}}Ae.styleModule=Ku;Ae.inputHandler=LE;Ae.scrollHandler=FE;Ae.focusChangeEffect=VE;Ae.perLineTextDirection=XE;Ae.exceptionSink=BE;Ae.updateListener=Ey;Ae.editable=PO;Ae.mouseSelectionStyle=WE;Ae.dragMovesSelection=IE;Ae.clickAddsSelectionRange=NE;Ae.decorations=Lc;Ae.outerDecorations=zE;Ae.atomicRanges=j0;Ae.bidiIsolatedRanges=GE;Ae.scrollMargins=HE;Ae.darkTheme=Ay;Ae.cspNonce=Ne.define({combine:t=>t.length?t[0]:""});Ae.contentAttributes=A0;Ae.editorAttributes=YE;Ae.lineWrapping=Ae.contentAttributes.of({class:"cm-lineWrapping"});Ae.announce=yt.define();const Aq=4096,YS={};class _p{constructor(e,r,n,i,o,s){this.from=e,this.to=r,this.dir=n,this.isolates=i,this.fresh=o,this.order=s}static update(e,r){if(r.empty&&!e.some(o=>o.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:dr.LTR;for(let o=Math.max(0,e.length-10);o<e.length;o++){let s=e[o];s.dir==i&&!r.touchesRange(s.from,s.to)&&n.push(new _p(r.mapPos(s.from,1),r.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return n}}function zS(t,e,r){for(let n=t.state.facet(e),i=n.length-1;i>=0;i--){let o=n[i],s=typeof o=="function"?o(t):o;s&&Py(s,r)}return r}const jq=Xe.mac?"mac":Xe.windows?"win":Xe.linux?"linux":"key";function Mq(t,e){const r=t.split(/-(?!$)/);let n=r[r.length-1];n=="Space"&&(n=" ");let i,o,s,a;for(let l=0;l<r.length-1;++l){const c=r[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:o=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(n="Alt-"+n),o&&(n="Ctrl-"+n),a&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function ch(t,e,r){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r!==!1&&e.shiftKey&&(t="Shift-"+t),t}const Dq=Zo.default(Ae.domEventHandlers({keydown(t,e){return gC(OC(e.state),t,e,"editor")}})),gf=Ne.define({enables:Dq}),GS=new WeakMap;function OC(t){let e=t.facet(gf),r=GS.get(e);return r||GS.set(e,r=Nq(e.reduce((n,i)=>n.concat(i),[]))),r}function qq(t,e,r){return gC(OC(t.state),e,t,r)}let es=null;const Zq=4e3;function Nq(t,e=jq){let r=Object.create(null),n=Object.create(null),i=(s,a)=>{let l=n[s];if(l==null)n[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c,u)=>{var f,h;let d=r[s]||(r[s]=Object.create(null)),p=a.split(/ (?!$)/).map(y=>Mq(y,e));for(let y=1;y<p.length;y++){let g=p.slice(0,y).join(" ");i(g,!0),d[g]||(d[g]={preventDefault:!0,stopPropagation:!1,run:[v=>{let b=es={view:v,prefix:g,scope:s};return setTimeout(()=>{es==b&&(es=null)},Zq),!0}]})}let O=p.join(" ");i(O,!1);let m=d[O]||(d[O]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let s of t){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=r[c]||(r[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in u)u[f].run.push(s.any)}let l=s[e]||s.key;if(l)for(let c of a)o(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return r}function gC(t,e,r,n){let i=uD(e),o=ln(i,0),s=di(o)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;es&&es.view==r&&es.scope==n&&(a=es.prefix+" ",rC.indexOf(e.keyCode)<0&&(c=!0,es=null));let f=new Set,h=m=>{if(m){for(let y of m.run)if(!f.has(y)&&(f.add(y),y(r,e)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},d=t[n],p,O;return d&&(h(d[a+ch(i,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Xe.windows&&e.ctrlKey&&e.altKey)&&(p=ks[e.keyCode])&&p!=i?(h(d[a+ch(p,e,!0)])||e.shiftKey&&(O=Wc[e.keyCode])!=i&&O!=p&&h(d[a+ch(O,e,!1)]))&&(l=!0):s&&e.shiftKey&&h(d[a+ch(i,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),l}class mf{constructor(e,r,n,i,o){this.className=e,this.left=r,this.top=n,this.width=i,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,r){return r.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,r,n){if(n.empty){let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let o=mC(e);return[new mf(r,i.left-o.left,i.top-o.top,null,i.bottom-i.top)]}else return Iq(e,r,n)}}function mC(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==dr.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function HS(t,e,r){let n=le.cursor(e);return{from:Math.max(r.from,t.moveToLineBoundary(n,!1,!0).from),to:Math.min(r.to,t.moveToLineBoundary(n,!0,!0).from),type:An.Text}}function Iq(t,e,r){if(r.to<=t.viewport.from||r.from>=t.viewport.to)return[];let n=Math.max(r.from,t.viewport.from),i=Math.min(r.to,t.viewport.to),o=t.textDirection==dr.LTR,s=t.contentDOM,a=s.getBoundingClientRect(),l=mC(t),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),f=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),h=a.right-(u?parseInt(u.paddingRight):0),d=Ty(t,n),p=Ty(t,i),O=d.type==An.Text?d:null,m=p.type==An.Text?p:null;if(O&&(t.lineWrapping||d.widgetLineBreaks)&&(O=HS(t,n,O)),m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=HS(t,i,m)),O&&m&&O.from==m.from)return g(v(r.from,r.to,O));{let P=O?v(r.from,null,O):b(d,!1),_=m?v(null,r.to,m):b(p,!0),Q=[];return(O||d).to<(m||p).from-(O&&m?1:0)||d.widgetLineBreaks>1&&P.bottom+t.defaultLineHeight/2<_.top?Q.push(y(f,P.bottom,h,_.top)):P.bottom<_.top&&t.elementAtHeight((P.bottom+_.top)/2).type==An.Text&&(P.bottom=_.top=(P.bottom+_.top)/2),g(P).concat(Q).concat(g(_))}function y(P,_,Q,w){return new mf(e,P-l.left,_-l.top-.01,Q-P,w-_+.01)}function g({top:P,bottom:_,horizontal:Q}){let w=[];for(let k=0;k<Q.length;k+=2)w.push(y(Q[k],P,Q[k+1],_));return w}function v(P,_,Q){let w=1e9,k=-1e9,x=[];function E(U,H,j,B,D){let X=t.coordsAtPos(U,U==Q.to?-2:2),G=t.coordsAtPos(j,j==Q.from?2:-2);!X||!G||(w=Math.min(X.top,G.top,w),k=Math.max(X.bottom,G.bottom,k),D==dr.LTR?x.push(o&&H?f:X.left,o&&B?h:G.right):x.push(!o&&B?f:G.left,!o&&H?h:X.right))}let R=P??Q.from,W=_??Q.to;for(let U of t.visibleRanges)if(U.to>R&&U.from<W)for(let H=Math.max(U.from,R),j=Math.min(U.to,W);;){let B=t.state.doc.lineAt(H);for(let D of t.bidiSpans(B)){let X=D.from+B.from,G=D.to+B.from;if(X>=j)break;G>H&&E(Math.max(X,H),P==null&&X<=R,Math.min(G,j),_==null&&G>=W,D.dir)}if(H=B.to+1,H>=j)break}return x.length==0&&E(R,P==null,W,_==null,t.textDirection),{top:w,bottom:k,horizontal:x}}function b(P,_){let Q=a.top+(_?P.top:P.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function Wq(t,e){return t.constructor==e.constructor&&t.eq(e)}class Bq{constructor(e,r){this.view=e,this.layer=r,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),r.above&&this.dom.classList.add("cm-layer-above"),r.class&&this.dom.classList.add(r.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),r.mount&&r.mount(this.dom,e)}update(e){e.startState.facet(qd)!=e.state.facet(qd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let r=0,n=e.facet(qd);for(;r<n.length&&n[r]!=this.layer;)r++;this.dom.style.zIndex=String((this.layer.above?150:-1)-r)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:r}=this.view;(e!=this.scaleX||r!=this.scaleY)&&(this.scaleX=e,this.scaleY=r,this.dom.style.transform=`scale(${1/e}, ${1/r})`)}draw(e){if(e.length!=this.drawn.length||e.some((r,n)=>!Wq(r,this.drawn[n]))){let r=this.dom.firstChild,n=0;for(let i of e)i.update&&r&&i.constructor&&this.drawn[n].constructor&&i.update(r,this.drawn[n])?(r=r.nextSibling,n++):this.dom.insertBefore(i.draw(),r);for(;r;){let i=r.nextSibling;r.remove(),r=i}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const qd=Ne.define();function yC(t){return[ar.define(e=>new Bq(e,t)),qd.of(t)]}const vC=!Xe.ios,Vc=Ne.define({combine(t){return Li(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,r)=>Math.min(e,r),drawRangeCursor:(e,r)=>e||r})}});function Lq(t={}){return[Vc.of(t),Vq,Xq,Uq,UE.of(!0)]}function bC(t){return t.startState.facet(Vc)!=t.state.facet(Vc)}const Vq=yC({above:!0,markers(t){let{state:e}=t,r=e.facet(Vc),n=[];for(let i of e.selection.ranges){let o=i==e.selection.main;if(i.empty?!o||vC:r.drawRangeCursor){let s=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:le.cursor(i.head,i.head>i.anchor?-1:1);for(let l of mf.forRange(t,s,a))n.push(l)}}return n},update(t,e){t.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let r=bC(t);return r&&KS(t.state,e),t.docChanged||t.selectionSet||r},mount(t,e){KS(e.state,t)},class:"cm-cursorLayer"});function KS(t,e){e.style.animationDuration=t.facet(Vc).cursorBlinkRate+"ms"}const Xq=yC({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:mf.forRange(t,"cm-selectionBackground",e)).reduce((e,r)=>e.concat(r))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||bC(t)},class:"cm-selectionLayer"}),Dy={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};vC&&(Dy[".cm-line"].caretColor="transparent !important",Dy[".cm-content"]={caretColor:"transparent !important"});const Uq=Zo.highest(Ae.theme(Dy)),SC=yt.define({map(t,e){return t==null?null:e.mapPos(t)}}),tc=Kr.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((r,n)=>n.is(SC)?n.value:r,t)}}),Fq=ar.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let r=t.state.field(tc);r==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(tc)!=r||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(tc),r=e!=null&&t.coordsAtPos(e);if(!r)return null;let n=t.scrollDOM.getBoundingClientRect();return{left:r.left-n.left+t.scrollDOM.scrollLeft*t.scaleX,top:r.top-n.top+t.scrollDOM.scrollTop*t.scaleY,height:r.bottom-r.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:r}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/r+"px",this.cursor.style.height=t.height/r+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(tc)!=t&&this.view.dispatch({effects:SC.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Yq(){return[tc,Fq]}function JS(t,e,r,n,i){e.lastIndex=0;for(let o=t.iterRange(r,n),s=r,a;!o.next().done;s+=o.value.length)if(!o.lineBreak)for(;a=e.exec(o.value);)i(s+a.index,a)}function zq(t,e){let r=t.visibleRanges;if(r.length==1&&r[0].from==t.viewport.from&&r[0].to==t.viewport.to)return r;let n=[];for(let{from:i,to:o}of r)i=Math.max(t.state.doc.lineAt(i).from,i-e),o=Math.min(t.state.doc.lineAt(o).to,o+e),n.length&&n[n.length-1].to>=i?n[n.length-1].to=o:n.push({from:i,to:o});return n}class Gq{constructor(e){const{regexp:r,decoration:n,decorate:i,boundary:o,maxLength:s=1e3}=e;if(!r.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=r,i)this.addMatch=(a,l,c,u)=>i(u,c,c+a[0].length,a,l);else if(typeof n=="function")this.addMatch=(a,l,c,u)=>{let f=n(a,l,c);f&&u(c,c+a[0].length,f)};else if(n)this.addMatch=(a,l,c,u)=>u(c,c+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=s}createDeco(e){let r=new ws,n=r.add.bind(r);for(let{from:i,to:o}of zq(e,this.maxLength))JS(e.state.doc,this.regexp,i,o,(s,a)=>this.addMatch(a,e,s,n));return r.finish()}updateDeco(e,r){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((o,s,a,l)=>{l>e.view.viewport.from&&a<e.view.viewport.to&&(n=Math.min(a,n),i=Math.max(l,i))}),e.viewportChanged||i-n>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,r.map(e.changes),n,i):r}updateRange(e,r,n,i){for(let o of e.visibleRanges){let s=Math.max(o.from,n),a=Math.min(o.to,i);if(a>s){let l=e.state.doc.lineAt(s),c=l.to<a?e.state.doc.lineAt(a):l,u=Math.max(o.from,l.from),f=Math.min(o.to,c.to);if(this.boundary){for(;s>l.from;s--)if(this.boundary.test(l.text[s-1-l.from])){u=s;break}for(;a<c.to;a++)if(this.boundary.test(c.text[a-c.from])){f=a;break}}let h=[],d,p=(O,m,y)=>h.push(y.range(O,m));if(l==c)for(this.regexp.lastIndex=u-l.from;(d=this.regexp.exec(l.text))&&d.index<f-l.from;)this.addMatch(d,e,d.index+l.from,p);else JS(e.state.doc,this.regexp,u,f,(O,m)=>this.addMatch(m,e,O,p));r=r.update({filterFrom:u,filterTo:f,filter:(O,m)=>O<u||m>f,add:h})}}return r}}const qy=/x/.unicode!=null?"gu":"g",Hq=new RegExp(`[\0-\b
86
86
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,qy),Kq={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let vg=null;function Jq(){var t;if(vg==null&&typeof document<"u"&&document.body){let e=document.body.style;vg=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return vg||!1}const Zd=Ne.define({combine(t){let e=Li(t,{render:null,specialChars:Hq,addSpecialChars:null});return(e.replaceTabs=!Jq())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,qy)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,qy)),e}});function eZ(t={}){return[Zd.of(t),tZ()]}let ew=null;function tZ(){return ew||(ew=ar.fromClass(class{constructor(t){this.view=t,this.decorations=Ye.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Zd)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Gq({regexp:t.specialChars,decoration:(e,r,n)=>{let{doc:i}=r.state,o=ln(e[0],0);if(o==9){let s=i.lineAt(n),a=r.state.tabSize,l=Ii(s.text,a,n-s.from);return Ye.replace({widget:new oZ((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Ye.replace({widget:new iZ(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Zd);t.startState.facet(Zd)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const rZ="•";function nZ(t){return t>=32?rZ:t==10?"␤":String.fromCharCode(9216+t)}class iZ extends ki{constructor(e,r){super(),this.options=e,this.code=r}eq(e){return e.code==this.code}toDOM(e){let r=nZ(this.code),n=e.state.phrase("Control character")+" "+(Kq[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,r);if(i)return i;let o=document.createElement("span");return o.textContent=r,o.title=n,o.setAttribute("aria-label",n),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class oZ extends ki{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function sZ(){return lZ}const aZ=Ye.line({class:"cm-activeLine"}),lZ=ar.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,r=[];for(let n of t.state.selection.ranges){let i=t.lineBlockAt(n.head);i.from>e&&(r.push(aZ.range(i.from)),e=i.from)}return Ye.set(r)}},{decorations:t=>t.decorations}),Zy=2e3;function uZ(t,e,r){let n=Math.min(e.line,r.line),i=Math.max(e.line,r.line),o=[];if(e.off>Zy||r.off>Zy||e.col<0||r.col<0){let s=Math.min(e.off,r.off),a=Math.max(e.off,r.off);for(let l=n;l<=i;l++){let c=t.doc.line(l);c.length<=a&&o.push(le.range(c.from+s,c.to+a))}}else{let s=Math.min(e.col,r.col),a=Math.max(e.col,r.col);for(let l=n;l<=i;l++){let c=t.doc.line(l),u=gy(c.text,s,t.tabSize,!0);if(u<0)o.push(le.cursor(c.to));else{let f=gy(c.text,a,t.tabSize);o.push(le.range(c.from+u,c.from+f))}}}return o}function cZ(t,e){let r=t.coordsAtPos(t.viewport.from);return r?Math.round(Math.abs((r.left-e)/t.defaultCharacterWidth)):-1}function tw(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(r),i=r-n.from,o=i>Zy?-1:i==n.length?cZ(t,e.clientX):Ii(n.text,t.state.tabSize,r-n.from);return{line:n.number,col:o,off:i}}function fZ(t,e){let r=tw(t,e),n=t.state.selection;return r?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(r.line).from),s=i.state.doc.lineAt(o);r={line:s.number,col:r.col,off:Math.min(r.off,s.length)},n=n.map(i.changes)}},get(i,o,s){let a=tw(t,i);if(!a)return n;let l=uZ(t.state,r,a);return l.length?s?le.create(l.concat(n.ranges)):le.create(l):n}}:null}function hZ(t){let e=(t==null?void 0:t.eventFilter)||(r=>r.altKey&&r.button==0);return Ae.mouseSelectionStyle.of((r,n)=>e(n)?fZ(r,n):null)}const dZ={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},pZ={style:"cursor: crosshair"};function OZ(t={}){let[e,r]=dZ[t.key||"Alt"],n=ar.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||r(i))},keyup(i){(i.keyCode==e||!r(i))&&this.set(!1)},mousemove(i){this.set(r(i))}}});return[n,Ae.contentAttributes.of(i=>{var o;return!((o=i.plugin(n))===null||o===void 0)&&o.isDown?pZ:null})]}const Eu="-10000px";class wC{constructor(e,r,n,i){this.facet=r,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(r),this.tooltips=this.input.filter(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=n(s,o))}update(e,r){var n;let i=e.state.facet(this.facet),o=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let s=[],a=r?[]:null;for(let l=0;l<o.length;l++){let c=o[l],u=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let h=this.tooltips[f];h&&h.create==c.create&&(u=f)}if(u<0)s[l]=this.createTooltipView(c,l?s[l-1]:null),a&&(a[l]=!!c.above);else{let f=s[l]=this.tooltipViews[u];a&&(a[l]=r[u]),f.update&&f.update(e)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(n=l.destroy)===null||n===void 0||n.call(l));return r&&(a.forEach((l,c)=>r[c]=l),r.length=a.length),this.input=i,this.tooltips=o,this.tooltipViews=s,!0}}function gZ(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const bg=Ne.define({combine:t=>{var e,r,n;return{position:Xe.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((r=t.find(i=>i.parent))===null||r===void 0?void 0:r.parent)||null,tooltipSpace:((n=t.find(i=>i.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||gZ}}}),rw=new WeakMap,D0=ar.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(bg);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new wC(t,q0,(r,n)=>this.createTooltip(r,n),r=>{this.resizeObserver&&this.resizeObserver.unobserve(r.dom),r.dom.remove()}),this.above=this.manager.tooltips.map(r=>!!r.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(r=>{Date.now()>this.lastTransaction-50&&r.length>0&&r[r.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let r=e||t.geometryChanged,n=t.state.facet(bg);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;r=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);r=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);r&&this.maybeMeasure()}createTooltip(t,e){let r=t.create(this.view),n=e?e.dom:null;if(r.dom.classList.add("cm-tooltip"),t.arrow&&!r.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",r.dom.appendChild(i)}return r.dom.style.position=this.position,r.dom.style.top=Eu,r.dom.style.left="0px",this.container.insertBefore(r.dom,n),r.mount&&r.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(r.dom),r}destroy(){var t,e,r;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(t=n.destroy)===null||t===void 0||t.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(r=this.intersectionObserver)===null||r===void 0||r.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,r=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:i}=this.manager.tooltipViews[0];if(Xe.gecko)n=i.offsetParent!=this.container.ownerDocument.body;else if(i.style.top==Eu&&i.style.left=="0px"){let o=i.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(e=i.width/this.parent.offsetWidth,r=i.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:r}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((i,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(i.pos):this.view.coordsAtPos(i.pos)}),size:this.manager.tooltipViews.map(({dom:i})=>i.getBoundingClientRect()),space:this.view.state.facet(bg).tooltipSpace(this.view),scaleX:e,scaleY:r,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{editor:r,space:n,scaleX:i,scaleY:o}=t,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,f=t.pos[a],h=t.size[a];if(!f||f.bottom<=Math.max(r.top,n.top)||f.top>=Math.min(r.bottom,n.bottom)||f.right<Math.max(r.left,n.left)-.1||f.left>Math.min(r.right,n.right)+.1){u.style.top=Eu;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,O=h.right-h.left,m=(e=rw.get(c))!==null&&e!==void 0?e:h.bottom-h.top,y=c.offset||yZ,g=this.view.textDirection==dr.LTR,v=h.width>n.right-n.left?g?n.left:n.right-h.width:g?Math.min(f.left-(d?14:0)+y.x,n.right-O):Math.max(n.left,f.left-O+(d?14:0)-y.x),b=this.above[a];!l.strictSide&&(b?f.top-(h.bottom-h.top)-y.y<n.top:f.bottom+(h.bottom-h.top)+y.y>n.bottom)&&b==n.bottom-f.bottom>f.top-n.top&&(b=this.above[a]=!b);let P=(b?f.top-n.top:n.bottom-f.bottom)-p;if(P<m&&c.resize!==!1){if(P<this.view.defaultLineHeight){u.style.top=Eu;continue}rw.set(c,m),u.style.height=(m=P)/o+"px"}else u.style.height&&(u.style.height="");let _=b?f.top-m-p-y.y:f.bottom+p+y.y,Q=v+O;if(c.overlap!==!0)for(let w of s)w.left<Q&&w.right>v&&w.top<_+m&&w.bottom>_&&(_=b?w.top-m-2-p:w.bottom+p+2);if(this.position=="absolute"?(u.style.top=(_-t.parent.top)/o+"px",u.style.left=(v-t.parent.left)/i+"px"):(u.style.top=_/o+"px",u.style.left=v/i+"px"),d){let w=f.left+(g?y.x:-y.x)-(v+14-7);d.style.left=w/i+"px"}c.overlap!==!0&&s.push({left:v,top:_,right:Q,bottom:_+m}),u.classList.toggle("cm-tooltip-above",b),u.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Eu}},{eventObservers:{scroll(){this.maybeMeasure()}}}),mZ=Ae.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"}}}),yZ={x:0,y:0},q0=Ne.define({enables:[D0,mZ]}),$p=Ne.define({combine:t=>t.reduce((e,r)=>e.concat(r),[])});class kO{static create(e){return new kO(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new wC(e,$p,(r,n)=>this.createHostedView(r,n),r=>r.dom.remove())}createHostedView(e,r){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,r?r.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let r of this.manager.tooltipViews)r.mount&&r.mount(e);this.mounted=!0}positioned(e){for(let r of this.manager.tooltipViews)r.positioned&&r.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let r of this.manager.tooltipViews)(e=r.destroy)===null||e===void 0||e.call(r)}passProp(e){let r;for(let n of this.manager.tooltipViews){let i=n[e];if(i!==void 0){if(r===void 0)r=i;else if(r!==i)return}}return r}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const vZ=q0.compute([$p],t=>{let e=t.facet($p);return e.length===0?null:{pos:Math.min(...e.map(r=>r.pos)),end:Math.max(...e.map(r=>{var n;return(n=r.end)!==null&&n!==void 0?n:r.pos})),create:kO.create,above:e[0].above,arrow:e.some(r=>r.arrow)}});class bZ{constructor(e,r,n,i,o){this.view=e,this.source=r,this.field=n,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:r}=this,n=e.docView.nearest(r.target);if(!n)return;let i,o=1;if(n instanceof os)i=n.posAtStart;else{if(i=e.posAtCoords(r),i==null)return;let a=e.coordsAtPos(i);if(!a||r.y<a.top||r.y>a.bottom||r.x<a.left-e.defaultCharacterWidth||r.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==dr.RTL?-1:1;o=r.x<a.left?-c:c}let s=this.source(e,i,o);if(s!=null&&s.then){let a=this.pending={pos:i};s.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Tn(e.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(D0),r=e?e.manager.tooltips.findIndex(n=>n.create==kO.create):-1;return r>-1?e.manager.tooltipViews[r]:null}mousemove(e){var r,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:o}=this;if(i.length&&o&&!SZ(o.dom,e)||this.pending){let{pos:s}=i[0]||this.pending,a=(n=(r=i[0])===null||r===void 0?void 0:r.end)!==null&&n!==void 0?n:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!wZ(this.view,s,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:r}=this;if(r.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let r=n=>{e.removeEventListener("mouseleave",r),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",r)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const fh=4;function SZ(t,e){let r=t.getBoundingClientRect();return e.clientX>=r.left-fh&&e.clientX<=r.right+fh&&e.clientY>=r.top-fh&&e.clientY<=r.bottom+fh}function wZ(t,e,r,n,i,o){let s=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(s.left>n||s.right<n||s.top>i||Math.min(s.bottom,a)<i)return!1;let l=t.posAtCoords({x:n,y:i},!1);return l>=e&&l<=r}function PZ(t,e={}){let r=yt.define(),n=Kr.define({create(){return[]},update(i,o){if(i.length&&(e.hideOnChange&&(o.docChanged||o.selection)?i=[]:e.hideOn&&(i=i.filter(s=>!e.hideOn(o,s))),o.docChanged)){let s=[];for(let a of i){let l=o.changes.mapPos(a.pos,-1,Yr.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=o.changes.mapPos(c.end)),s.push(c)}}i=s}for(let s of o.effects)s.is(r)&&(i=s.value),s.is(kZ)&&(i=[]);return i},provide:i=>$p.from(i)});return[n,ar.define(i=>new bZ(i,t,n,r,e.hoverTime||300)),vZ]}function PC(t,e){let r=t.plugin(D0);if(!r)return null;let n=r.manager.tooltips.indexOf(e);return n<0?null:r.manager.tooltipViews[n]}const kZ=yt.define(),nw=Ne.define({combine(t){let e,r;for(let n of t)e=e||n.topContainer,r=r||n.bottomContainer;return{topContainer:e,bottomContainer:r}}});function Xc(t,e){let r=t.plugin(kC),n=r?r.specs.indexOf(e):-1;return n>-1?r.panels[n]:null}const kC=ar.fromClass(class{constructor(t){this.input=t.state.facet(Uc),this.specs=this.input.filter(r=>r),this.panels=this.specs.map(r=>r(t));let e=t.state.facet(nw);this.top=new hh(t,!0,e.topContainer),this.bottom=new hh(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(r=>r.top)),this.bottom.sync(this.panels.filter(r=>!r.top));for(let r of this.panels)r.dom.classList.add("cm-panel"),r.mount&&r.mount()}update(t){let e=t.state.facet(nw);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new hh(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new hh(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let r=t.state.facet(Uc);if(r!=this.input){let n=r.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of n){let c=this.specs.indexOf(l),u;c<0?(u=l(t.view),a.push(u)):(u=this.panels[c],u.update&&u.update(t)),i.push(u),(u.top?o:s).push(u)}this.specs=n,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ae.scrollMargins.of(e=>{let r=e.plugin(t);return r&&{top:r.top.scrollMargin(),bottom:r.bottom.scrollMargin()}})});class hh{constructor(e,r,n){this.view=e,this.top=r,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let r of this.panels)r.destroy&&e.indexOf(r)<0&&r.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let r=this.container||this.view.dom;r.insertBefore(this.dom,this.top?r.firstChild:null)}let e=this.dom.firstChild;for(let r of this.panels)if(r.dom.parentNode==this.dom){for(;e!=r.dom;)e=iw(e);e=e.nextSibling}else this.dom.insertBefore(r.dom,e);for(;e;)e=iw(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function iw(t){let e=t.nextSibling;return t.remove(),e}const Uc=Ne.define({enables:kC});class _s extends wa{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}_s.prototype.elementClass="";_s.prototype.toDOM=void 0;_s.prototype.mapMode=Yr.TrackBefore;_s.prototype.startSide=_s.prototype.endSide=-1;_s.prototype.point=!0;const Nd=Ne.define(),Id=Ne.define(),Ny=Ne.define({combine:t=>t.some(e=>e)});function xZ(t){let e=[_Z];return t&&t.fixed===!1&&e.push(Ny.of(!0)),e}const _Z=ar.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Id).map(e=>new sw(t,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(Ny),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,r=t.view.viewport,n=Math.min(e.to,r.to)-Math.max(e.from,r.from);this.syncGutters(n<(r.to-r.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Ny)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let r=qt.iter(this.view.state.facet(Nd),this.view.viewport.from),n=[],i=this.gutters.map(o=>new $Z(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(o.type)){let s=!0;for(let a of o.type)if(a.type==An.Text&&s){Iy(r,n,a.from);for(let l of i)l.line(this.view,a,n);s=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(o.type==An.Text){Iy(r,n,o.from);for(let s of i)s.line(this.view,o,n)}else if(o.widget)for(let s of i)s.widget(this.view,o);for(let o of i)o.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Id),r=t.state.facet(Id),n=t.docChanged||t.heightChanged||t.viewportChanged||!qt.eq(t.startState.facet(Nd),t.state.facet(Nd),t.view.viewport.from,t.view.viewport.to);if(e==r)for(let i of this.gutters)i.update(t)&&(n=!0);else{n=!0;let i=[];for(let o of r){let s=e.indexOf(o);s<0?i.push(new sw(this.view,o)):(this.gutters[s].update(t),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)this.dom.appendChild(o.dom);this.gutters=i}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>Ae.scrollMargins.of(e=>{let r=e.plugin(t);return!r||r.gutters.length==0||!r.fixed?null:e.textDirection==dr.LTR?{left:r.dom.offsetWidth*e.scaleX}:{right:r.dom.offsetWidth*e.scaleX}})});function ow(t){return Array.isArray(t)?t:[t]}function Iy(t,e,r){for(;t.value&&t.from<=r;)t.from==r&&e.push(t.value),t.next()}class $Z{constructor(e,r,n){this.gutter=e,this.height=n,this.i=0,this.cursor=qt.iter(e.markers,r.from)}addElement(e,r,n){let{gutter:i}=this,o=(r.top-this.height)/e.scaleY,s=r.height/e.scaleY;if(this.i==i.elements.length){let a=new xC(e,s,o,n);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,s,o,n);this.height=r.bottom,this.i++}line(e,r,n){let i=[];Iy(this.cursor,i,r.from),n.length&&(i=i.concat(n));let o=this.gutter.config.lineMarker(e,r,i);o&&i.unshift(o);let s=this.gutter;i.length==0&&!s.config.renderEmptyElements||this.addElement(e,r,i)}widget(e,r){let n=this.gutter.config.widgetMarker(e,r.widget,r);n&&this.addElement(e,r,[n])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let r=e.elements.pop();e.dom.removeChild(r.dom),r.destroy()}}}class sw{constructor(e,r){this.view=e,this.config=r,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in r.domEventHandlers)this.dom.addEventListener(n,i=>{let o=i.target,s;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let l=o.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=i.clientY;let a=e.lineBlockAtHeight(s-e.documentTop);r.domEventHandlers[n](e,a,i)&&i.preventDefault()});this.markers=ow(r.markers(e)),r.initialSpacer&&(this.spacer=new xC(e,0,0,[r.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let r=this.markers;if(this.markers=ow(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let n=e.view.viewport;return!qt.eq(this.markers,r,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class xC{constructor(e,r,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,r,n,i)}update(e,r,n,i){this.height!=r&&(this.height=r,this.dom.style.height=r+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),QZ(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,r){let n="cm-gutterElement",i=this.dom.firstChild;for(let o=0,s=0;;){let a=s,l=o<r.length?r[o++]:null,c=!1;if(l){let u=l.elementClass;u&&(n+=" "+u);for(let f=s;f<this.markers.length;f++)if(this.markers[f].compare(l)){a=f,c=!0;break}}else a=this.markers.length;for(;s<a;){let u=this.markers[s++];if(u.toDOM){u.destroy(i);let f=i.nextSibling;i.remove(),i=f}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),c&&s++}this.dom.className=n,this.markers=r}destroy(){this.setMarkers(null,[])}}function QZ(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].compare(e[r]))return!1;return!0}const EZ=Ne.define(),ml=Ne.define({combine(t){return Li(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,r){let n=Object.assign({},e);for(let i in r){let o=n[i],s=r[i];n[i]=o?(a,l,c)=>o(a,l,c)||s(a,l,c):s}return n}})}});class Sg extends _s{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function wg(t,e){return t.state.facet(ml).formatNumber(e,t.state)}const CZ=Id.compute([ml],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(EZ)},lineMarker(e,r,n){return n.some(i=>i.toDOM)?null:new Sg(wg(e,e.state.doc.lineAt(r.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(ml)!=e.state.facet(ml),initialSpacer(e){return new Sg(wg(e,aw(e.state.doc.lines)))},updateSpacer(e,r){let n=wg(r.view,aw(r.view.state.doc.lines));return n==e.number?e:new Sg(n)},domEventHandlers:t.facet(ml).domEventHandlers}));function TZ(t={}){return[ml.of(t),xZ(),CZ]}function aw(t){let e=9;for(;e<t;)e=e*10+9;return e}const RZ=new class extends _s{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},AZ=Nd.compute(["selection"],t=>{let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.head).from;i>r&&(r=i,e.push(RZ.range(i)))}return qt.of(e)});function jZ(){return AZ}const _C=1024;let MZ=0;class Oi{constructor(e,r){this.from=e,this.to=r}}class pt{constructor(e={}){this.id=MZ++,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=Gr.match(e)),r=>{let n=e(r);return n===void 0?null:[this,n]}}}pt.closedBy=new pt({deserialize:t=>t.split(" ")});pt.openedBy=new pt({deserialize:t=>t.split(" ")});pt.group=new pt({deserialize:t=>t.split(" ")});pt.isolate=new pt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});pt.contextHash=new pt({perNode:!0});pt.lookAhead=new pt({perNode:!0});pt.mounted=new pt({perNode:!0});class Fc{constructor(e,r,n){this.tree=e,this.overlay=r,this.parser=n}static get(e){return e&&e.props&&e.props[pt.mounted.id]}}const DZ=Object.create(null);class Gr{constructor(e,r,n,i=0){this.name=e,this.props=r,this.id=n,this.flags=i}static define(e){let r=e.props&&e.props.length?Object.create(null):DZ,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Gr(e.name||"",r,e.id,n);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[o[0].id]=o[1]}}return i}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 r=this.prop(pt.group);return r?r.indexOf(e)>-1:!1}return this.id==e}static match(e){let r=Object.create(null);for(let n in e)for(let i of n.split(" "))r[i]=e[n];return n=>{for(let i=n.prop(pt.group),o=-1;o<(i?i.length:0);o++){let s=r[o<0?n.name:i[o]];if(s)return s}}}}Gr.none=new Gr("",Object.create(null),0,8);class yf{constructor(e){this.types=e;for(let r=0;r<e.length;r++)if(e[r].id!=r)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let r=[];for(let n of this.types){let i=null;for(let o of e){let s=o(n);s&&(i||(i=Object.assign({},n.props)),i[s[0].id]=s[1])}r.push(i?new Gr(n.name,i,n.id,n.flags):n)}return new yf(r)}}const dh=new WeakMap,lw=new WeakMap;var or;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(or||(or={}));class zt{constructor(e,r,n,i,o){if(this.type=e,this.children=r,this.positions=n,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=Fc.get(this);if(e&&!e.overlay)return e.tree.toString();let r="";for(let n of this.children){let i=n.toString();i&&(r&&(r+=","),r+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(e=0){return new Qp(this.topNode,e)}cursorAt(e,r=0,n=0){let i=dh.get(this)||this.topNode,o=new Qp(i);return o.moveTo(e,r),dh.set(this,o._tree),o}get topNode(){return new Sn(this,0,0,null)}resolve(e,r=0){let n=Yc(dh.get(this)||this.topNode,e,r,!1);return dh.set(this,n),n}resolveInner(e,r=0){let n=Yc(lw.get(this)||this.topNode,e,r,!0);return lw.set(this,n),n}resolveStack(e,r=0){return NZ(this,e,r)}iterate(e){let{enter:r,leave:n,from:i=0,to:o=this.length}=e,s=e.mode||0,a=(s&or.IncludeAnonymous)>0;for(let l=this.cursor(s|or.IncludeAnonymous);;){let c=!1;if(l.from<=o&&l.to>=i&&(!a&&l.type.isAnonymous||r(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;c=!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 r in this.props)e.push([+r,this.props[r]]);return e}balance(e={}){return this.children.length<=8?this:I0(Gr.none,this.children,this.positions,0,this.children.length,0,this.length,(r,n,i)=>new zt(this.type,r,n,i,this.propValues),e.makeTree||((r,n,i)=>new zt(Gr.none,r,n,i)))}static build(e){return IZ(e)}}zt.empty=new zt(Gr.none,[],[],0);class Z0{constructor(e,r){this.buffer=e,this.index=r}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 Z0(this.buffer,this.index)}}class $s{constructor(e,r,n){this.buffer=e,this.length=r,this.set=n}get type(){return Gr.none}toString(){let e=[];for(let r=0;r<this.buffer.length;)e.push(this.childString(r)),r=this.buffer[r+3];return e.join(",")}childString(e){let r=this.buffer[e],n=this.buffer[e+3],i=this.set.types[r],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),e+=4,n==e)return o;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return o+"("+s.join(",")+")"}findChild(e,r,n,i,o){let{buffer:s}=this,a=-1;for(let l=e;l!=r&&!($C(o,i,s[l+1],s[l+2])&&(a=l,n>0));l=s[l+3]);return a}slice(e,r,n){let i=this.buffer,o=new Uint16Array(r-e),s=0;for(let a=e,l=0;a<r;){o[l++]=i[a++],o[l++]=i[a++]-n;let c=o[l++]=i[a++]-n;o[l++]=i[a++]-e,s=Math.max(s,c)}return new $s(o,s,this.set)}}function $C(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function Yc(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let s=!n&&t instanceof Sn&&t.index<0?null:t.parent;if(!s)return t;t=s}let o=n?0:or.IgnoreOverlays;if(n)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Sn&&s.index<0&&((i=a.enter(e,r,o))===null||i===void 0?void 0:i.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,r,o);if(!s)return t;t=s}}class QC{cursor(e=0){return new Qp(this,e)}getChild(e,r=null,n=null){let i=uw(this,e,r,n);return i.length?i[0]:null}getChildren(e,r=null,n=null){return uw(this,e,r,n)}resolve(e,r=0){return Yc(this,e,r,!1)}resolveInner(e,r=0){return Yc(this,e,r,!0)}matchContext(e){return Wy(this,e)}enterUnfinishedNodesBefore(e){let r=this.childBefore(e),n=this;for(;r;){let i=r.lastChild;if(!i||i.to!=r.to)break;i.type.isError&&i.from==i.to?(n=r,r=i.prevSibling):r=i}return n}get node(){return this}get next(){return this.parent}}class Sn extends QC{constructor(e,r,n,i){super(),this._tree=e,this.from=r,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,r,n,i,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=r>0?a.length:-1;e!=c;e+=r){let u=a[e],f=l[e]+s.from;if($C(i,n,f,f+u.length)){if(u instanceof $s){if(o&or.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,r,n-f,i);if(h>-1)return new lo(new qZ(s,u,e,f),null,h)}else if(o&or.IncludeAnonymous||!u.type.isAnonymous||N0(u)){let h;if(!(o&or.IgnoreMounts)&&(h=Fc.get(u))&&!h.overlay)return new Sn(h.tree,f,e,s);let d=new Sn(u,f,e,s);return o&or.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(r<0?u.children.length-1:0,r,n,i)}}}if(o&or.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+r:e=r<0?-1:s._parent._tree.children.length,s=s._parent,!s))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,r,n=0){let i;if(!(n&or.IgnoreOverlays)&&(i=Fc.get(this._tree))&&i.overlay){let o=e-this.from;for(let{from:s,to:a}of i.overlay)if((r>0?s<=o:s<o)&&(r<0?a>=o:a>o))return new Sn(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,r,n)}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 uw(t,e,r,n){let i=t.cursor(),o=[];if(!i.firstChild())return o;if(r!=null){for(let s=!1;!s;)if(s=i.type.is(r),!i.nextSibling())return o}for(;;){if(n!=null&&i.type.is(n))return o;if(i.type.is(e)&&o.push(i.node),!i.nextSibling())return n==null?o:[]}}function Wy(t,e,r=e.length-1){for(let n=t.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}class qZ{constructor(e,r,n,i){this.parent=e,this.buffer=r,this.index=n,this.start=i}}class lo extends QC{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,r,n){super(),this.context=e,this._parent=r,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,r,n){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.context.start,n);return o<0?null:new lo(this.context,this,o)}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,r,n=0){if(n&or.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],r>0?1:-1,e-this.context.start,r);return o<0?null:new lo(this.context,this,o)}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,r=e.buffer[this.index+3];return r<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new lo(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new lo(this.context,this._parent,e.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],r=[],{buffer:n}=this.context,i=this.index+4,o=n.buffer[this.index+3];if(o>i){let s=n.buffer[this.index+1];e.push(n.slice(i,o,s)),r.push(0)}return new zt(this.type,e,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function EC(t){if(!t.length)return null;let e=0,r=t[0];for(let o=1;o<t.length;o++){let s=t[o];(s.from>r.from||s.to<r.to)&&(r=s,e=o)}let n=r instanceof Sn&&r.index<0?null:r.parent,i=t.slice();return n?i[e]=n:i.splice(e,1),new ZZ(i,r)}class ZZ{constructor(e,r){this.heads=e,this.node=r}get next(){return EC(this.heads)}}function NZ(t,e,r){let n=t.resolveInner(e,r),i=null;for(let o=n instanceof Sn?n:n.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(i||(i=[n])).push(s.resolve(e,r)),o=s}else{let s=Fc.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Sn(s.tree,s.overlay[0].from+o.from,-1,o);(i||(i=[n])).push(Yc(a,e,r,!1))}}return i?EC(i):n}class Qp{get name(){return this.type.name}constructor(e,r=0){if(this.mode=r,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Sn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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,r){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=r||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return e?e instanceof Sn?(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,r,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,r,n,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.buffer.start,n);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,r,n=this.mode){return this.buffer?n&or.ExcludeBuffers?!1:this.enterChild(1,e,r):this.yield(this._tree.enter(e,r,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&or.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&or.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:r}=this.buffer,n=this.stack.length-1;if(e<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(r.findChild(i,this.index,-1,0,4))}else{let i=r.buffer[this.index+3];if(i<(n<0?r.buffer.length:r.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<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 r,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(i.buffer.buffer[o+3]<this.index)return!1;({index:r,parent:n}=i)}else({index:r,_parent:n}=this._tree);for(;n;{index:r,_parent:n}=n)if(r>-1)for(let o=r+e,s=e<0?-1:n._tree.children.length;o!=s;o+=e){let a=n._tree.children[o];if(this.mode&or.IncludeAnonymous||a instanceof $s||!a.type.isAnonymous||N0(a))return!1}return!0}move(e,r){if(r&&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,r=0){for(;(this.from==this.to||(r<1?this.from>=e:this.from>e)||(r>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,r););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,r=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,o=this.stack.length;o>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;r=s,n=o+1;break e}i=this.stack[--o]}for(let i=n;i<this.stack.length;i++)r=new lo(this.buffer,r,this.stack[i]);return this.bufferNode=new lo(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,r){for(let n=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;i&&r&&r(this),i=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return Wy(this.node,e);let{buffer:r}=this.buffer,{types:n}=r.set;for(let i=e.length-1,o=this.stack.length-1;i>=0;o--){if(o<0)return Wy(this.node,e,i);let s=n[r.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}}function N0(t){return t.children.some(e=>e instanceof $s||!e.type.isAnonymous||N0(e))}function IZ(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=_C,reused:o=[],minRepeatType:s=n.types.length}=t,a=Array.isArray(r)?new Z0(r,r.length):r,l=n.types,c=0,u=0;function f(P,_,Q,w,k,x){let{id:E,start:R,end:W,size:U}=a,H=u;for(;U<0;)if(a.next(),U==-1){let G=o[E];Q.push(G),w.push(R-P);return}else if(U==-3){c=E;return}else if(U==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${U}`);let j=l[E],B,D,X=R-P;if(W-R<=i&&(D=m(a.pos-_,k))){let G=new Uint16Array(D.size-D.skip),se=a.pos-D.size,ue=G.length;for(;a.pos>se;)ue=y(D.start,G,ue);B=new $s(G,W-D.start,n),X=D.start-P}else{let G=a.pos-U;a.next();let se=[],ue=[],F=E>=s?E:-1,K=0,oe=W;for(;a.pos>G;)F>=0&&a.id==F&&a.size>=0?(a.end<=oe-i&&(p(se,ue,R,K,a.end,oe,F,H),K=se.length,oe=a.end),a.next()):x>2500?h(R,G,se,ue):f(R,G,se,ue,F,x+1);if(F>=0&&K>0&&K<se.length&&p(se,ue,R,K,R,oe,F,H),se.reverse(),ue.reverse(),F>-1&&K>0){let Ee=d(j);B=I0(j,se,ue,0,se.length,0,W-R,Ee,Ee)}else B=O(j,se,ue,W-R,H-W)}Q.push(B),w.push(X)}function h(P,_,Q,w){let k=[],x=0,E=-1;for(;a.pos>_;){let{id:R,start:W,end:U,size:H}=a;if(H>4)a.next();else{if(E>-1&&W<E)break;E<0&&(E=U-i),k.push(R,W,U),x++,a.next()}}if(x){let R=new Uint16Array(x*4),W=k[k.length-2];for(let U=k.length-3,H=0;U>=0;U-=3)R[H++]=k[U],R[H++]=k[U+1]-W,R[H++]=k[U+2]-W,R[H++]=H;Q.push(new $s(R,k[2]-W,n)),w.push(W-P)}}function d(P){return(_,Q,w)=>{let k=0,x=_.length-1,E,R;if(x>=0&&(E=_[x])instanceof zt){if(!x&&E.type==P&&E.length==w)return E;(R=E.prop(pt.lookAhead))&&(k=Q[x]+E.length+R)}return O(P,_,Q,w,k)}}function p(P,_,Q,w,k,x,E,R){let W=[],U=[];for(;P.length>w;)W.push(P.pop()),U.push(_.pop()+Q-k);P.push(O(n.types[E],W,U,x-k,R-x)),_.push(k-Q)}function O(P,_,Q,w,k=0,x){if(c){let E=[pt.contextHash,c];x=x?[E].concat(x):[E]}if(k>25){let E=[pt.lookAhead,k];x=x?[E].concat(x):[E]}return new zt(P,_,Q,w,x)}function m(P,_){let Q=a.fork(),w=0,k=0,x=0,E=Q.end-i,R={size:0,start:0,skip:0};e:for(let W=Q.pos-P;Q.pos>W;){let U=Q.size;if(Q.id==_&&U>=0){R.size=w,R.start=k,R.skip=x,x+=4,w+=4,Q.next();continue}let H=Q.pos-U;if(U<0||H<W||Q.start<E)break;let j=Q.id>=s?4:0,B=Q.start;for(Q.next();Q.pos>H;){if(Q.size<0)if(Q.size==-3)j+=4;else break e;else Q.id>=s&&(j+=4);Q.next()}k=B,w+=U,x+=j}return(_<0||w==P)&&(R.size=w,R.start=k,R.skip=x),R.size>4?R:void 0}function y(P,_,Q){let{id:w,start:k,end:x,size:E}=a;if(a.next(),E>=0&&w<s){let R=Q;if(E>4){let W=a.pos-(E-4);for(;a.pos>W;)Q=y(P,_,Q)}_[--Q]=R,_[--Q]=x-P,_[--Q]=k-P,_[--Q]=w}else E==-3?c=w:E==-4&&(u=w);return Q}let g=[],v=[];for(;a.pos>0;)f(t.start||0,t.bufferStart||0,g,v,-1,0);let b=(e=t.length)!==null&&e!==void 0?e:g.length?v[0]+g[0].length:0;return new zt(l[t.topID],g.reverse(),v.reverse(),b)}const cw=new WeakMap;function Wd(t,e){if(!t.isAnonymous||e instanceof $s||e.type!=t)return 1;let r=cw.get(e);if(r==null){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof zt)){r=1;break}r+=Wd(t,n)}cw.set(e,r)}return r}function I0(t,e,r,n,i,o,s,a,l){let c=0;for(let p=n;p<i;p++)c+=Wd(t,e[p]);let u=Math.ceil(c*1.5/8),f=[],h=[];function d(p,O,m,y,g){for(let v=m;v<y;){let b=v,P=O[v],_=Wd(t,p[v]);for(v++;v<y;v++){let Q=Wd(t,p[v]);if(_+Q>=u)break;_+=Q}if(v==b+1){if(_>u){let Q=p[b];d(Q.children,Q.positions,0,Q.children.length,O[b]+g);continue}f.push(p[b])}else{let Q=O[v-1]+p[v-1].length-P;f.push(I0(t,p,O,b,v,P,Q,null,l))}h.push(P+g-o)}}return d(e,r,n,i,0),(a||l)(f,h,s)}class CC{constructor(){this.map=new WeakMap}setBuffer(e,r,n){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(r,n)}getBuffer(e,r){let n=this.map.get(e);return n&&n.get(r)}set(e,r){e instanceof lo?this.setBuffer(e.context.buffer,e.index,r):e instanceof Sn&&this.map.set(e.tree,r)}get(e){return e instanceof lo?this.getBuffer(e.context.buffer,e.index):e instanceof Sn?this.map.get(e.tree):void 0}cursorSet(e,r){e.buffer?this.setBuffer(e.buffer.buffer,e.index,r):this.map.set(e.tree,r)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Co{constructor(e,r,n,i,o=!1,s=!1){this.from=e,this.to=r,this.tree=n,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,r=[],n=!1){let i=[new Co(0,e.length,e,0,!1,n)];for(let o of r)o.to>e.length&&i.push(o);return i}static applyChanges(e,r,n=128){if(!r.length)return e;let i=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<r.length?r[a]:null,f=u?u.fromA:1e9;if(f-l>=n)for(;s&&s.from<f;){let h=s;if(l>=h.from||f<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,f)-c;h=d>=p?null:new Co(d,p,h.tree,h.offset+c,a>0,!!u)}if(h&&i.push(h),s.to>f)break;s=o<e.length?e[o++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class W0{startParse(e,r,n){return typeof e=="string"&&(e=new WZ(e)),n=n?n.length?n.map(i=>new Oi(i.from,i.to)):[new Oi(0,0)]:[new Oi(0,e.length)],this.createParse(e,r||[],n)}parse(e,r,n){let i=this.startParse(e,r,n);for(;;){let o=i.advance();if(o)return o}}}class WZ{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,r){return this.string.slice(e,r)}}function B0(t){return(e,r,n,i)=>new LZ(e,t,r,n,i)}class fw{constructor(e,r,n,i,o){this.parser=e,this.parse=r,this.overlay=n,this.target=i,this.from=o}}function hw(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class BZ{constructor(e,r,n,i,o,s,a){this.parser=e,this.predicate=r,this.mounts=n,this.index=i,this.start=o,this.target=s,this.prev=a,this.depth=0,this.ranges=[]}}const By=new pt({perNode:!0});class LZ{constructor(e,r,n,i,o){this.nest=r,this.input=n,this.fragments=i,this.ranges=o,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new zt(n.type,n.children,n.positions,n.length,n.propValues.concat([[By,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],r=e.parse.advance();if(r){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[pt.mounted.id]=new Fc(r,e.overlay,e.parser),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let r=this.innerDone;r<this.inner.length;r++)this.inner[r].from<e&&(e=Math.min(e,this.inner[r].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let r=this.innerDone;r<this.inner.length;r++)this.inner[r].parse.stopAt(e)}startInner(){let e=new UZ(this.fragments),r=null,n=null,i=new Qp(new Sn(this.baseTree,this.ranges[0].from,0,null),or.IncludeAnonymous|or.IgnoreMounts);e:for(let o,s;;){let a=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)a=!1;else if(e.hasNode(i)){if(r){let c=r.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let f=u.from+c.pos,h=u.to+c.pos;f>=i.from&&h<=i.to&&!r.ranges.some(d=>d.from<h&&d.to>f)&&r.ranges.push({from:f,to:h})}}a=!1}else if(n&&(s=VZ(n.ranges,i.from,i.to)))a=s!=2;else if(!i.type.isAnonymous&&(o=this.nest(i,this.input))&&(i.from<i.to||!o.overlay)){i.tree||XZ(i);let c=e.findMounts(i.from,o.parser);if(typeof o.overlay=="function")r=new BZ(o.parser,o.overlay,c,this.inner.length,i.from,i.tree,r);else{let u=Ow(this.ranges,o.overlay||(i.from<i.to?[new Oi(i.from,i.to)]:[]));u.length&&hw(u),(u.length||!o.overlay)&&this.inner.push(new fw(o.parser,u.length?o.parser.startParse(this.input,gw(c,u),u):o.parser.startParse(""),o.overlay?o.overlay.map(f=>new Oi(f.from-i.from,f.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),o.overlay?u.length&&(n={ranges:u,depth:0,prev:n}):a=!1}}else r&&(l=r.predicate(i))&&(l===!0&&(l=new Oi(i.from,i.to)),l.from<l.to&&r.ranges.push(l));if(a&&i.firstChild())r&&r.depth++,n&&n.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(r&&!--r.depth){let c=Ow(this.ranges,r.ranges);c.length&&(hw(c),this.inner.splice(r.index,0,new fw(r.parser,r.parser.startParse(this.input,gw(r.mounts,c),c),r.ranges.map(u=>new Oi(u.from-r.start,u.to-r.start)),r.target,c[0].from))),r=r.prev}n&&!--n.depth&&(n=n.prev)}}}}function VZ(t,e,r){for(let n of t){if(n.from>=r)break;if(n.to>e)return n.from<=e&&n.to>=r?2:1}return 0}function dw(t,e,r,n,i,o){if(e<r){let s=t.buffer[e+1];n.push(t.slice(e,r,s)),i.push(s-o)}}function XZ(t){let{node:e}=t,r=[],n=e.context.buffer;do r.push(t.index),t.parent();while(!t.tree);let i=t.tree,o=i.children.indexOf(n),s=i.children[o],a=s.buffer,l=[o];function c(u,f,h,d,p,O){let m=r[O],y=[],g=[];dw(s,u,m,y,g,d);let v=a[m+1],b=a[m+2];l.push(y.length);let P=O?c(m+4,a[m+3],s.set.types[a[m]],v,b-v,O-1):e.toTree();return y.push(P),g.push(v-d),dw(s,a[m+3],f,y,g,d),new zt(h,y,g,p)}i.children[o]=c(0,a.length,Gr.none,0,s.length,r.length-1);for(let u of l){let f=t.tree.children[u],h=t.tree.positions[u];t.yield(new Sn(f,h+t.from,u,t._tree))}}class pw{constructor(e,r){this.offset=r,this.done=!1,this.cursor=e.cursor(or.IncludeAnonymous|or.IgnoreMounts)}moveTo(e){let{cursor:r}=this,n=e-this.offset;for(;!this.done&&r.from<n;)r.to>=e&&r.enter(n,1,or.IgnoreOverlays|or.ExcludeBuffers)||r.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let r=this.cursor.tree;;){if(r==e.tree)return!0;if(r.children.length&&r.positions[0]==0&&r.children[0]instanceof zt)r=r.children[0];else break}return!1}}let UZ=class{constructor(e){var r;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(r=n.tree.prop(By))!==null&&r!==void 0?r:n.to,this.inner=new pw(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let r=this.curFrag=this.fragments[this.fragI];this.curTo=(e=r.tree.prop(By))!==null&&e!==void 0?e:r.to,this.inner=new pw(r.tree,-r.offset)}}findMounts(e,r){var n;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let o=this.inner.cursor.node;o;o=o.parent){let s=(n=o.tree)===null||n===void 0?void 0:n.prop(pt.mounted);if(s&&s.parser==r)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=o.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:o.from-l.offset,mount:s})}}}return i}};function Ow(t,e){let r=null,n=e;for(let i=1,o=0;i<t.length;i++){let s=t[i-1].to,a=t[i].from;for(;o<n.length;o++){let l=n[o];if(l.from>=a)break;l.to<=s||(r||(n=r=e.slice()),l.from<s?(r[o]=new Oi(l.from,s),l.to>a&&r.splice(o+1,0,new Oi(a,l.to))):l.to>a?r[o--]=new Oi(a,l.to):r.splice(o--,1))}}return n}function FZ(t,e,r,n){let i=0,o=0,s=!1,a=!1,l=-1e9,c=[];for(;;){let u=i==t.length?1e9:s?t[i].to:t[i].from,f=o==e.length?1e9:a?e[o].to:e[o].from;if(s!=a){let h=Math.max(l,r),d=Math.min(u,f,n);h<d&&c.push(new Oi(h,d))}if(l=Math.min(u,f),l==1e9)break;u==l&&(s?(s=!1,i++):s=!0),f==l&&(a?(a=!1,o++):a=!0)}return c}function gw(t,e){let r=[];for(let{pos:n,mount:i,frag:o}of t){let s=n+(i.overlay?i.overlay[0].from:0),a=s+i.tree.length,l=Math.max(o.from,s),c=Math.min(o.to,a);if(i.overlay){let u=i.overlay.map(h=>new Oi(h.from+n,h.to+n)),f=FZ(e,u,l,c);for(let h=0,d=l;;h++){let p=h==f.length,O=p?c:f[h].from;if(O>d&&r.push(new Co(d,O,i.tree,-s,o.from>=d||o.openStart,o.to<=O||o.openEnd)),p)break;d=f[h].to}}else r.push(new Co(l,c,i.tree,-s,o.from>=s||o.openStart,o.to<=a||o.openEnd))}return r}let YZ=0;class Ai{constructor(e,r,n){this.set=e,this.base=r,this.modified=n,this.id=YZ++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let r=new Ai([],null,[]);if(r.set.push(r),e)for(let n of e.set)r.set.push(n);return r}static defineModifier(){let e=new Ep;return r=>r.modified.indexOf(e)>-1?r:Ep.get(r.base||r,r.modified.concat(e).sort((n,i)=>n.id-i.id))}}let zZ=0;class Ep{constructor(){this.instances=[],this.id=zZ++}static get(e,r){if(!r.length)return e;let n=r[0].instances.find(a=>a.base==e&&GZ(r,a.modified));if(n)return n;let i=[],o=new Ai(i,e,r);for(let a of r)a.instances.push(o);let s=HZ(r);for(let a of e.set)if(!a.modified.length)for(let l of s)i.push(Ep.get(a,l));return o}}function GZ(t,e){return t.length==e.length&&t.every((r,n)=>r==e[n])}function HZ(t){let e=[[]];for(let r=0;r<t.length;r++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(t[r]));return e.sort((r,n)=>n.length-r.length)}function As(t){let e=Object.create(null);for(let r in t){let n=t[r];Array.isArray(n)||(n=[n]);for(let i of r.split(" "))if(i){let o=[],s=2,a=i;for(let f=0;;){if(a=="..."&&f>0&&f+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let d=i[f++];if(f==i.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);a=i.slice(f)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Cp(n,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return TC.add(e)}const TC=new pt;class Cp{constructor(e,r,n,i){this.tags=e,this.mode=r,this.context=n,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Cp.empty=new Cp([],2,null);function RC(t,e){let r=Object.create(null);for(let o of t)if(!Array.isArray(o.tag))r[o.tag.id]=o.class;else for(let s of o.tag)r[s.id]=o.class;let{scope:n,all:i=null}=e||{};return{style:o=>{let s=i;for(let a of o)for(let l of a.set){let c=r[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function KZ(t,e){let r=null;for(let n of t){let i=n.style(e);i&&(r=r?r+" "+i:i)}return r}function JZ(t,e,r,n=0,i=t.length){let o=new eN(n,Array.isArray(e)?e:[e],r);o.highlightRange(t.cursor(),n,i,"",o.highlighters),o.flush(i)}class eN{constructor(e,r,n){this.at=e,this.highlighters=r,this.span=n,this.class=""}startSpan(e,r){r!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=r)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,r,n,i,o){let{type:s,from:a,to:l}=e;if(a>=n||l<=r)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=i,u=tN(e)||Cp.empty,f=KZ(o,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(r,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(pt.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),O=e.firstChild();for(let m=0,y=a;;m++){let g=m<h.overlay.length?h.overlay[m]:null,v=g?g.from+a:l,b=Math.max(r,y),P=Math.min(n,v);if(b<P&&O)for(;e.from<P&&(this.highlightRange(e,b,P,i,o),this.startSpan(Math.min(P,e.to),c),!(e.to>=v||!e.nextSibling())););if(!g||v>n)break;y=g.to+a,y>r&&(this.highlightRange(d.cursor(),Math.max(r,g.from+a),Math.min(n,y),"",p),this.startSpan(Math.min(n,y),c))}O&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=r)){if(e.from>=n)break;this.highlightRange(e,r,n,i,o),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}}function tN(t){let e=t.type.prop(TC);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Me=Ai.define,ph=Me(),Yo=Me(),mw=Me(Yo),yw=Me(Yo),zo=Me(),Oh=Me(zo),Pg=Me(zo),zi=Me(),Us=Me(zi),Fi=Me(),Yi=Me(),Ly=Me(),Cu=Me(Ly),gh=Me(),S={comment:ph,lineComment:Me(ph),blockComment:Me(ph),docComment:Me(ph),name:Yo,variableName:Me(Yo),typeName:mw,tagName:Me(mw),propertyName:yw,attributeName:Me(yw),className:Me(Yo),labelName:Me(Yo),namespace:Me(Yo),macroName:Me(Yo),literal:zo,string:Oh,docString:Me(Oh),character:Me(Oh),attributeValue:Me(Oh),number:Pg,integer:Me(Pg),float:Me(Pg),bool:Me(zo),regexp:Me(zo),escape:Me(zo),color:Me(zo),url:Me(zo),keyword:Fi,self:Me(Fi),null:Me(Fi),atom:Me(Fi),unit:Me(Fi),modifier:Me(Fi),operatorKeyword:Me(Fi),controlKeyword:Me(Fi),definitionKeyword:Me(Fi),moduleKeyword:Me(Fi),operator:Yi,derefOperator:Me(Yi),arithmeticOperator:Me(Yi),logicOperator:Me(Yi),bitwiseOperator:Me(Yi),compareOperator:Me(Yi),updateOperator:Me(Yi),definitionOperator:Me(Yi),typeOperator:Me(Yi),controlOperator:Me(Yi),punctuation:Ly,separator:Me(Ly),bracket:Cu,angleBracket:Me(Cu),squareBracket:Me(Cu),paren:Me(Cu),brace:Me(Cu),content:zi,heading:Us,heading1:Me(Us),heading2:Me(Us),heading3:Me(Us),heading4:Me(Us),heading5:Me(Us),heading6:Me(Us),contentSeparator:Me(zi),list:Me(zi),quote:Me(zi),emphasis:Me(zi),strong:Me(zi),link:Me(zi),monospace:Me(zi),strikethrough:Me(zi),inserted:Me(),deleted:Me(),changed:Me(),invalid:Me(),meta:gh,documentMeta:Me(gh),annotation:Me(gh),processingInstruction:Me(gh),definition:Ai.defineModifier(),constant:Ai.defineModifier(),function:Ai.defineModifier(),standard:Ai.defineModifier(),local:Ai.defineModifier(),special:Ai.defineModifier()};RC([{tag:S.link,class:"tok-link"},{tag:S.heading,class:"tok-heading"},{tag:S.emphasis,class:"tok-emphasis"},{tag:S.strong,class:"tok-strong"},{tag:S.keyword,class:"tok-keyword"},{tag:S.atom,class:"tok-atom"},{tag:S.bool,class:"tok-bool"},{tag:S.url,class:"tok-url"},{tag:S.labelName,class:"tok-labelName"},{tag:S.inserted,class:"tok-inserted"},{tag:S.deleted,class:"tok-deleted"},{tag:S.literal,class:"tok-literal"},{tag:S.string,class:"tok-string"},{tag:S.number,class:"tok-number"},{tag:[S.regexp,S.escape,S.special(S.string)],class:"tok-string2"},{tag:S.variableName,class:"tok-variableName"},{tag:S.local(S.variableName),class:"tok-variableName tok-local"},{tag:S.definition(S.variableName),class:"tok-variableName tok-definition"},{tag:S.special(S.variableName),class:"tok-variableName2"},{tag:S.definition(S.propertyName),class:"tok-propertyName tok-definition"},{tag:S.typeName,class:"tok-typeName"},{tag:S.namespace,class:"tok-namespace"},{tag:S.className,class:"tok-className"},{tag:S.macroName,class:"tok-macroName"},{tag:S.propertyName,class:"tok-propertyName"},{tag:S.operator,class:"tok-operator"},{tag:S.comment,class:"tok-comment"},{tag:S.meta,class:"tok-meta"},{tag:S.invalid,class:"tok-invalid"},{tag:S.punctuation,class:"tok-punctuation"}]);var kg;const ua=new pt;function L0(t){return Ne.define({combine:t?e=>e.concat(t):void 0})}const V0=new pt;class gi{constructor(e,r,n=[],i=""){this.data=e,this.name=i,Dt.prototype.hasOwnProperty("tree")||Object.defineProperty(Dt.prototype,"tree",{get(){return Qr(this)}}),this.parser=r,this.extension=[Yl.of(this),Dt.languageData.of((o,s,a)=>{let l=vw(o,s,a),c=l.type.prop(ua);if(!c)return[];let u=o.facet(c),f=l.type.prop(V0);if(f){let h=l.resolve(s-l.from,a);for(let d of f)if(d.test(h,o)){let p=o.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,r,n=-1){return vw(e,r,n).type.prop(ua)==this.data}findRegions(e){let r=e.facet(Yl);if((r==null?void 0:r.data)==this.data)return[{from:0,to:e.doc.length}];if(!r||!r.allowsNesting)return[];let n=[],i=(o,s)=>{if(o.prop(ua)==this.data){n.push({from:s,to:s+o.length});return}let a=o.prop(pt.mounted);if(a){if(a.tree.prop(ua)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+s,to:l.to+s});else n.push({from:s,to:s+o.length});return}else if(a.overlay){let l=n.length;if(i(a.tree,a.overlay[0].from+s),n.length>l)return}}for(let l=0;l<o.children.length;l++){let c=o.children[l];c instanceof zt&&i(c,o.positions[l]+s)}};return i(Qr(e),0),n}get allowsNesting(){return!0}}gi.setState=yt.define();function vw(t,e,r){let n=t.facet(Yl),i=Qr(t).topNode;if(!n||n.allowsNesting)for(let o=i;o;o=o.enter(e,r,or.ExcludeBuffers))o.type.isTop&&(i=o);return i}class Qs extends gi{constructor(e,r,n){super(e,r,[],n),this.parser=r}static define(e){let r=L0(e.languageData);return new Qs(r,e.parser.configure({props:[ua.add(n=>n.isTop?r:void 0)]}),e.name)}configure(e,r){return new Qs(this.data,this.parser.configure(e),r||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Qr(t){let e=t.field(gi.state,!1);return e?e.tree:zt.empty}class rN{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,r){let n=this.cursorPos-this.string.length;return e<n||r>=this.cursorPos?this.doc.sliceString(e,r):this.string.slice(e-n,r-n)}}let Tu=null;class zc{constructor(e,r,n=[],i,o,s,a,l){this.parser=e,this.state=r,this.fragments=n,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,r,n){return new zc(e,r,[],zt.empty,0,n,[],null)}startParse(){return this.parser.startParse(new rN(this.state.doc),this.fragments)}work(e,r){return r!=null&&r>=this.state.doc.length&&(r=void 0),this.tree!=zt.empty&&this.isDone(r??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r<this.state.doc.length&&this.parse.stopAt(r);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Co.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(r??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,r;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(r=this.parse.advance()););}),this.treeLen=e,this.tree=r,this.fragments=this.withoutTempSkipped(Co.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let r=Tu;Tu=this;try{return e()}finally{Tu=r}}withoutTempSkipped(e){for(let r;r=this.tempSkipped.pop();)e=bw(e,r.from,r.to);return e}changes(e,r){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,h)=>l.push({fromA:c,toA:u,fromB:f,toB:h})),n=Co.applyChanges(n,l),i=zt.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);u<f&&a.push({from:u,to:f})}}}return new zc(this.parser,r,n,i,o,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let r=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:i,to:o}=this.skipped[n];i<e.to&&o>e.from&&(this.fragments=bw(this.fragments,i,o),this.skipped.splice(n--,1))}return this.skipped.length>=r?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,r){this.skipped.push({from:e,to:r})}static getSkippingParser(e){return new class extends W0{createParse(r,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let l=Tu;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new zt(Gr.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let r=this.fragments;return this.treeLen>=e&&r.length&&r[0].from==0&&r[0].to>=e}static get(){return Tu}}function bw(t,e,r){return Co.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class Fl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),r.viewport.to);return r.work(20,n)||r.takeTree(),new Fl(r)}static init(e){let r=Math.min(3e3,e.doc.length),n=zc.create(e.facet(Yl).parser,e,{from:0,to:r});return n.work(20,r)||n.takeTree(),new Fl(n)}}gi.state=Kr.define({create:Fl.init,update(t,e){for(let r of e.effects)if(r.is(gi.setState))return r.value;return e.startState.facet(Yl)!=e.state.facet(Yl)?Fl.init(e.state):t.apply(e)}});let AC=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(AC=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const xg=typeof navigator<"u"&&(!((kg=navigator.scheduling)===null||kg===void 0)&&kg.isInputPending)?()=>navigator.scheduling.isInputPending():null,nN=ar.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 r=this.view.state.field(gi.state).context;(r.updateViewport(e.view.viewport)||this.view.viewport.to>r.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(r)}scheduleWork(){if(this.working)return;let{state:e}=this.view,r=e.field(gi.state);(r.tree!=r.context.tree||!r.context.isDone(e.doc.length))&&(this.working=AC(this.work))}work(e){this.working=null;let r=Date.now();if(this.chunkEnd<r&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=r+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,o=n.field(gi.state);if(o.tree==o.context.tree&&o.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!xg?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<i&&n.doc.length>i+1e3,l=o.context.work(()=>xg&&xg()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-r,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:gi.setState.of(new Fl(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(r=>Tn(this.view.state,r)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Yl=Ne.define({combine(t){return t.length?t[0]:null},enables:t=>[gi.state,nN,Ae.contentAttributes.compute([t],e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}})]});class _a{constructor(e,r=[]){this.language=e,this.support=r,this.extension=[e,r]}}class Tp{constructor(e,r,n,i,o,s=void 0){this.name=e,this.alias=r,this.extensions=n,this.filename=i,this.loadFunc=o,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:r,support:n}=e;if(!r){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");r=()=>Promise.resolve(n)}return new Tp(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,r,n)}static matchFilename(e,r){for(let i of e)if(i.filename&&i.filename.test(r))return i;let n=/\.([^.]+)$/.exec(r);if(n){for(let i of e)if(i.extensions.indexOf(n[1])>-1)return i}return null}static matchLanguageName(e,r,n=!0){r=r.toLowerCase();for(let i of e)if(i.alias.some(o=>o==r))return i;if(n)for(let i of e)for(let o of i.alias){let s=r.indexOf(o);if(s>-1&&(o.length>2||!/\w/.test(r[s-1])&&!/\w/.test(r[s+o.length])))return i}return null}}const iN=Ne.define(),vf=Ne.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(r=>r!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function zl(t){let e=t.facet(vf);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Rp(t,e){let r="",n=t.tabSize,i=t.facet(vf)[0];if(i==" "){for(;e>=n;)r+=" ",e-=n;i=" "}for(let o=0;o<e;o++)r+=i;return r}function jC(t,e){t instanceof Dt&&(t=new X0(t));for(let n of t.state.facet(iN)){let i=n(t,e);if(i!==void 0)return i}let r=Qr(t.state);return r.length>=e?oN(t,r,e):null}class X0{constructor(e,r={}){this.state=e,this.options=r,this.unit=zl(e)}lineAt(e,r=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:o}=this.options;return i!=null&&i>=n.from&&i<=n.to?o&&i==e?{text:"",from:e}:(r<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,r=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,r);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,r=1){let{text:n,from:i}=this.lineAt(e,r),o=this.countColumn(n,e-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(o+=s-this.countColumn(n,n.search(/\S|$/))),o}countColumn(e,r=e.length){return Ii(e,this.state.tabSize,r)}lineIndent(e,r=1){let{text:n,from:i}=this.lineAt(e,r),o=this.options.overrideIndentation;if(o){let s=o(i);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ea=new pt;function oN(t,e,r){let n=e.resolveStack(r),i=n.node.enterUnfinishedNodesBefore(r);if(i!=n.node){let o=[];for(let s=i;s!=n.node;s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)n={node:o[s],next:n}}return MC(n,t,r)}function MC(t,e,r){for(let n=t;n;n=n.next){let i=aN(n.node);if(i)return i(U0.create(e,r,n))}return 0}function sN(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function aN(t){let e=t.type.prop(Ea);if(e)return e;let r=t.firstChild,n;if(r&&(n=r.type.prop(pt.closedBy))){let i=t.lastChild,o=i&&n.indexOf(i.name)>-1;return s=>DC(s,!0,1,void 0,o&&!sN(s)?i.from:void 0)}return t.parent==null?lN:null}function lN(){return 0}class U0 extends X0{constructor(e,r,n){super(e.state,e.options),this.base=e,this.pos=r,this.context=n}get node(){return this.context.node}static create(e,r,n){return new U0(e,r,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let r=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(r.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(uN(n,e))break;r=this.state.doc.lineAt(n.from)}return this.lineIndent(r.from)}continue(){return MC(this.context.next,this.base,this.pos)}}function uN(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function cN(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,o=t.state.doc.lineAt(r.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=r.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.from<s?r:null;a=l.to}}function fN({closing:t,align:e=!0,units:r=1}){return n=>DC(n,e,r,t)}function DC(t,e,r,n,i){let o=t.textAfter,s=o.match(/^\s*/)[0].length,a=n&&o.slice(s,s+n.length)==n||i==t.pos+s,l=e?cN(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*r)}const hN=t=>t.baseIndent;function Cl({except:t,units:e=1}={}){return r=>{let n=t&&t.test(r.textAfter);return r.baseIndent+(n?0:e*r.unit)}}const dN=200;function pN(){return Dt.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+dN)return t;let o=r.sliceString(i.from,n);if(!e.some(c=>c.test(o)))return t;let{state:s}=t,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=jC(s,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=Rp(s,f);h!=d&&l.push({from:u.from,to:u.from+h.length,insert:d})}return l.length?[t,{changes:l,sequential:!0}]:t})}const qC=Ne.define(),js=new pt;function F0(t){let e=t.firstChild,r=t.lastChild;return e&&e.to<r.from?{from:e.to,to:r.type.isError?t.to:r.from}:null}function ON(t,e,r){let n=Qr(t);if(n.length<r)return null;let i=n.resolveStack(r,1),o=null;for(let s=i;s;s=s.next){let a=s.node;if(a.to<=r||a.from>r)continue;if(o&&a.from<e)break;let l=a.type.prop(js);if(l&&(a.to<n.length-50||n.length==t.doc.length||!gN(a))){let c=l(a,t);c&&c.from<=r&&c.from>=e&&c.to>r&&(o=c)}}return o}function gN(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function ZC(t,e,r){for(let n of t.facet(qC)){let i=n(t,e,r);if(i)return i}return ON(t,e,r)}function NC(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}const Y0=yt.define({map:NC}),xO=yt.define({map:NC});function IC(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(n=>n.from<=r&&n.to>=r)||e.push(t.lineBlockAt(r));return e}const bf=Kr.define({create(){return Ye.none},update(t,e){t=t.map(e.changes);for(let r of e.effects)if(r.is(Y0)&&!mN(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(z0),i=n?Ye.replace({widget:new kN(n(e.state,r.value))}):Sw;t=t.update({add:[i.range(r.value.from,r.value.to)]})}else r.is(xO)&&(t=t.update({filter:(n,i)=>r.value.from!=n||r.value.to!=i,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){let r=!1,{head:n}=e.selection.main;t.between(n,n,(i,o)=>{i<n&&o>n&&(r=!0)}),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(i,o)=>o<=n||i>=n}))}return t},provide:t=>Ae.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,(n,i)=>{r.push(n,i)}),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],i=t[r++];if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(Sw.range(n,i))}return Ye.set(e,!0)}});function WC(t,e,r){var n;let i=null;return(n=t.field(bf,!1))===null||n===void 0||n.between(e,r,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function mN(t,e,r){let n=!1;return t.between(e,e,(i,o)=>{i==e&&o==r&&(n=!0)}),n}function BC(t,e){return t.field(bf,!1)?e:e.concat(yt.appendConfig.of(PN()))}const yN=t=>{for(let e of IC(t)){let r=ZC(t.state,e.from,e.to);if(r)return t.dispatch({effects:BC(t.state,[Y0.of(r),LC(t,r)])}),!0}return!1},vN=t=>{if(!t.state.field(bf,!1))return!1;let e=[];for(let r of IC(t)){let n=WC(t.state,r.from,r.to);n&&e.push(xO.of(n),LC(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function LC(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return Ae.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}const bN=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let i=t.lineBlockAt(n),o=ZC(e,i.from,i.to);o&&r.push(Y0.of(o)),n=(o?t.lineBlockAt(o.to):i).to+1}return r.length&&t.dispatch({effects:BC(t.state,r)}),!!r.length},SN=t=>{let e=t.state.field(bf,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(n,i)=>{r.push(xO.of({from:n,to:i}))}),t.dispatch({effects:r}),!0},wN={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},z0=Ne.define({combine(t){return Li(t,wN)}});function PN(t){let e=[bf,xN];return t&&e.push(z0.of(t)),e}function VC(t,e){let{state:r}=t,n=r.facet(z0),i=s=>{let a=t.lineBlockAt(t.posAtDOM(s.target)),l=WC(t.state,a.from,a.to);l&&t.dispatch({effects:xO.of(l)}),s.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,i,e);let o=document.createElement("span");return o.textContent=n.placeholderText,o.setAttribute("aria-label",r.phrase("folded code")),o.title=r.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const Sw=Ye.replace({widget:new class extends ki{toDOM(t){return VC(t,null)}}});class kN extends ki{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return VC(e,this.value)}}const xN=Ae.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class su{constructor(e,r){this.specs=e;let n;function i(a){let l=Ps.newName();return(n||(n=Object.create(null)))["."+l]=a,l}const o=typeof r.all=="string"?r.all:r.all?i(r.all):void 0,s=r.scope;this.scope=s instanceof gi?a=>a.prop(ua)==s.data:s?a=>a==s:void 0,this.style=RC(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=n?new Ps(n):null,this.themeType=r.themeType}static define(e,r){return new su(e,r||{})}}const Vy=Ne.define(),XC=Ne.define({combine(t){return t.length?[t[0]]:null}});function _g(t){let e=t.facet(Vy);return e.length?e:t.facet(XC)}function G0(t,e){let r=[$N],n;return t instanceof su&&(t.module&&r.push(Ae.styleModule.of(t.module)),n=t.themeType),e!=null&&e.fallback?r.push(XC.of(t)):n?r.push(Vy.computeN([Ae.darkTheme],i=>i.facet(Ae.darkTheme)==(n=="dark")?[t]:[])):r.push(Vy.of(t)),r}class _N{constructor(e){this.markCache=Object.create(null),this.tree=Qr(e.state),this.decorations=this.buildDeco(e,_g(e.state)),this.decoratedTo=e.viewport.to}update(e){let r=Qr(e.state),n=_g(e.state),i=n!=_g(e.startState),{viewport:o}=e.view,s=e.changes.mapPos(this.decoratedTo,1);r.length<o.to&&!i&&r.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(r!=this.tree||e.viewportChanged||i)&&(this.tree=r,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=o.to)}buildDeco(e,r){if(!r||!this.tree.length)return Ye.none;let n=new ws;for(let{from:i,to:o}of e.visibleRanges)JZ(this.tree,r,(s,a,l)=>{n.add(s,a,this.markCache[l]||(this.markCache[l]=Ye.mark({class:l})))},i,o);return n.finish()}}const $N=Zo.high(ar.fromClass(_N,{decorations:t=>t.decorations})),QN=su.define([{tag:S.meta,color:"#404740"},{tag:S.link,textDecoration:"underline"},{tag:S.heading,textDecoration:"underline",fontWeight:"bold"},{tag:S.emphasis,fontStyle:"italic"},{tag:S.strong,fontWeight:"bold"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.keyword,color:"#708"},{tag:[S.atom,S.bool,S.url,S.contentSeparator,S.labelName],color:"#219"},{tag:[S.literal,S.inserted],color:"#164"},{tag:[S.string,S.deleted],color:"#a11"},{tag:[S.regexp,S.escape,S.special(S.string)],color:"#e40"},{tag:S.definition(S.variableName),color:"#00f"},{tag:S.local(S.variableName),color:"#30a"},{tag:[S.typeName,S.namespace],color:"#085"},{tag:S.className,color:"#167"},{tag:[S.special(S.variableName),S.macroName],color:"#256"},{tag:S.definition(S.propertyName),color:"#00c"},{tag:S.comment,color:"#940"},{tag:S.invalid,color:"#f00"}]),EN=Ae.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),UC=1e4,FC="()[]{}",YC=Ne.define({combine(t){return Li(t,{afterCursor:!0,brackets:FC,maxScanDistance:UC,renderMatch:RN})}}),CN=Ye.mark({class:"cm-matchingBracket"}),TN=Ye.mark({class:"cm-nonmatchingBracket"});function RN(t){let e=[],r=t.matched?CN:TN;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}const AN=Kr.define({create(){return Ye.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(YC);for(let i of e.state.selection.ranges){if(!i.empty)continue;let o=as(e.state,i.head,-1,n)||i.head>0&&as(e.state,i.head-1,1,n)||n.afterCursor&&(as(e.state,i.head,1,n)||i.head<e.state.doc.length&&as(e.state,i.head+1,-1,n));o&&(r=r.concat(n.renderMatch(o,e.state)))}return Ye.set(r,!0)},provide:t=>Ae.decorations.from(t)}),jN=[AN,EN];function MN(t={}){return[YC.of(t),jN]}const zC=new pt;function Xy(t,e,r){let n=t.prop(e<0?pt.openedBy:pt.closedBy);if(n)return n;if(t.name.length==1){let i=r.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[r[i+e]]}return null}function Uy(t){let e=t.type.prop(zC);return e?e(t.node):t}function as(t,e,r,n={}){let i=n.maxScanDistance||UC,o=n.brackets||FC,s=Qr(t),a=s.resolveInner(e,r);for(let l=a;l;l=l.parent){let c=Xy(l.type,r,o);if(c&&l.from<l.to){let u=Uy(l);if(u&&(r>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return DN(t,e,r,l,u,c,o)}}return qN(t,e,r,s,a.type,i,o)}function DN(t,e,r,n,i,o,s){let a=n.parent,l={from:i.from,to:i.to},c=0,u=a==null?void 0:a.cursor();if(u&&(r<0?u.childBefore(n.from):u.childAfter(n.to)))do if(r<0?u.to<=n.from:u.from>=n.to){if(c==0&&o.indexOf(u.type.name)>-1&&u.from<u.to){let f=Uy(u);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Xy(u.type,r,s))c++;else if(Xy(u.type,-r,s)){if(c==0){let f=Uy(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(r<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function qN(t,e,r,n,i,o,s){let a=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=r>0)return null;let c={from:r<0?e-1:e,to:r>0?e+1:e},u=t.doc.iterRange(e,r>0?t.doc.length:0),f=0;for(let h=0;!u.next().done&&h<=o;){let d=u.value;r<0&&(h+=d.length);let p=e+h*r;for(let O=r>0?0:d.length-1,m=r>0?d.length:-1;O!=m;O+=r){let y=s.indexOf(d[O]);if(!(y<0||n.resolveInner(p+O,1).type!=i))if(y%2==0==r>0)f++;else{if(f==1)return{start:c,end:{from:p+O,to:p+O+1},matched:y>>1==l>>1};f--}}r>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}const ZN=Object.create(null),ww=[Gr.none],Pw=[],kw=Object.create(null),NN=Object.create(null);for(let[t,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"]])NN[t]=IN(ZN,e);function $g(t,e){Pw.indexOf(t)>-1||(Pw.push(t),console.warn(e))}function IN(t,e){let r=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=t[c]||S[c];u?typeof u=="function"?l.length?l=l.map(u):$g(c,`Modifier ${c} used at start of tag`):l.length?$g(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:$g(c,`Unknown highlighting tag ${c}`)}for(let c of l)r.push(c)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+r.map(a=>a.id),o=kw[i];if(o)return o.id;let s=kw[i]=Gr.define({id:ww.length,name:n,props:[As({[n]:r})]});return ww.push(s),s.id}dr.RTL,dr.LTR;const WN="#e5c07b",xw="#e06c75",BN="#56b6c2",LN="#ffffff",Bd="#abb2bf",Fy="#7d8799",VN="#61afef",XN="#98c379",_w="#d19a66",UN="#c678dd",FN="#21252b",$w="#2c313a",Qw="#282c34",Qg="#353a42",YN="#3E4451",Ew="#528bff",zN=Ae.theme({"&":{color:Bd,backgroundColor:Qw},".cm-content":{caretColor:Ew},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ew},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:YN},".cm-panels":{backgroundColor:FN,color:Bd},".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:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Qw,color:Fy,border:"none"},".cm-activeLineGutter":{backgroundColor:$w},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Qg},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Qg,borderBottomColor:Qg},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:$w,color:Bd}}},{dark:!0}),GN=su.define([{tag:S.keyword,color:UN},{tag:[S.name,S.deleted,S.character,S.propertyName,S.macroName],color:xw},{tag:[S.function(S.variableName),S.labelName],color:VN},{tag:[S.color,S.constant(S.name),S.standard(S.name)],color:_w},{tag:[S.definition(S.name),S.separator],color:Bd},{tag:[S.typeName,S.className,S.number,S.changed,S.annotation,S.modifier,S.self,S.namespace],color:WN},{tag:[S.operator,S.operatorKeyword,S.url,S.escape,S.regexp,S.link,S.special(S.string)],color:BN},{tag:[S.meta,S.comment],color:Fy},{tag:S.strong,fontWeight:"bold"},{tag:S.emphasis,fontStyle:"italic"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.link,color:Fy,textDecoration:"underline"},{tag:S.heading,fontWeight:"bold",color:xw},{tag:[S.atom,S.bool,S.special(S.variableName)],color:_w},{tag:[S.processingInstruction,S.string,S.inserted],color:XN},{tag:S.invalid,color:LN}]),HN=[zN,G0(GN)];function qr(){return qr=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},qr.apply(this,arguments)}var xi=t=>{var{theme:e,settings:r={},styles:n=[]}=t,i={".cm-gutters":{}},o={};r.background&&(o.backgroundColor=r.background),r.backgroundImage&&(o.backgroundImage=r.backgroundImage),r.foreground&&(o.color=r.foreground),r.fontSize&&(o.fontSize=r.fontSize),(r.background||r.foreground)&&(i["&"]=o),r.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(i[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(i[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(i[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(i[".cm-content"]={caretColor:r.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var s={};r.gutterActiveForeground&&(s.color=r.gutterActiveForeground),r.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:r.lineHighlight},s.backgroundColor=r.lineHighlight),i[".cm-activeLineGutter"]=s,r.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var a=Ae.theme(i,{dark:e==="dark"}),l=su.define(n),c=[a,G0(l)];return c},KN={background:"#272822",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#49483E",selectionMatch:"#49483E",gutterBackground:"#272822",gutterForeground:"#FFFFFF70",lineHighlight:"#0000003b"},JN=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},KN,r),styles:[{tag:[S.comment,S.documentMeta],color:"#8292a2"},{tag:[S.number,S.bool,S.null,S.atom],color:"#ae81ff"},{tag:[S.attributeValue,S.className,S.name],color:"#e6db74"},{tag:[S.propertyName,S.attributeName],color:"#a6e22e"},{tag:[S.variableName],color:"#9effff"},{tag:[S.squareBracket],color:"#bababa"},{tag:[S.string,S.special(S.brace)],color:"#e6db74"},{tag:[S.regexp,S.className,S.typeName,S.definition(S.typeName)],color:"#66d9ef"},{tag:[S.definition(S.variableName),S.definition(S.propertyName),S.function(S.variableName)],color:"#fd971f"},{tag:[S.keyword,S.definitionKeyword,S.modifier,S.tagName,S.angleBracket],color:"#f92672"},...n]})},eI=JN(),tI={background:"#0f0f0f",foreground:"#defdef",caret:"#00FF00",selection:"#515151",selectionMatch:"#515151",gutterBackground:"#555",gutterForeground:"#FFFFFF",lineHighlight:"#0a6bcb3d"},rI=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},tI,r),styles:[{tag:S.keyword,color:"darkgoldenrod",fontWeight:"bold"},{tag:S.atom,color:"#77F"},{tag:S.comment,color:"#7a7b7c",fontStyle:"italic"},{tag:S.number,color:"violet"},{tag:S.definition(S.variableName),color:"#fffabc"},{tag:S.variableName,color:"#abcdef"},{tag:S.function(S.variableName),color:"#fffabc"},{tag:S.typeName,color:"#FFDD44"},{tag:S.tagName,color:"#def"},{tag:S.string,color:"#2b4"},{tag:S.meta,color:"#C9F"},{tag:S.bracket,color:"#8a8a8a"},{tag:S.attributeName,color:"#DDFF00"},{tag:S.heading,color:"aquamarine",fontWeight:"bold"},{tag:S.link,color:"blueviolet",fontWeight:"bold"},...n]})},nI=rI(),iI={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},oI=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},iI,r),styles:[{tag:S.comment,color:"#6272a4"},{tag:S.string,color:"#f1fa8c"},{tag:S.atom,color:"#bd93f9"},{tag:S.meta,color:"#f8f8f2"},{tag:[S.keyword,S.operator,S.tagName],color:"#ff79c6"},{tag:[S.function(S.propertyName),S.propertyName],color:"#66d9ef"},{tag:[S.definition(S.variableName),S.function(S.variableName),S.className,S.attributeName],color:"#50fa7b"},{tag:S.atom,color:"#bd93f9"},...n]})},sI=oI(),aI={background:"#fff",foreground:"#000",caret:"#FFFFFF",selection:"#d7d4f0",selectionMatch:"#d7d4f0",gutterBackground:"#f7f7f7",gutterForeground:"#999",lineHighlight:"#006fff1c",gutterBorder:"transparent"},lI=t=>{var{theme:e="light",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},aI,r),styles:[{tag:[S.comment],color:"#3F7F5F"},{tag:[S.documentMeta],color:"#FF1717"},{tag:S.keyword,color:"#7F0055",fontWeight:"bold"},{tag:S.atom,color:"#00f"},{tag:S.number,color:"#164"},{tag:S.propertyName,color:"#164"},{tag:[S.variableName,S.definition(S.variableName)],color:"#0000C0"},{tag:S.function(S.variableName),color:"#0000C0"},{tag:S.string,color:"#2A00FF"},{tag:S.operator,color:"black"},{tag:S.tagName,color:"#170"},{tag:S.attributeName,color:"#00c"},{tag:S.link,color:"#219"},...n]})},uI=lI(),cI={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},fI=t=>{var{theme:e="light",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},cI,r),styles:[{tag:[S.standard(S.tagName),S.tagName],color:"#116329"},{tag:[S.comment,S.bracket],color:"#6a737d"},{tag:[S.className,S.propertyName],color:"#6f42c1"},{tag:[S.variableName,S.attributeName,S.number,S.operator],color:"#005cc5"},{tag:[S.keyword,S.typeName,S.typeOperator,S.typeName],color:"#d73a49"},{tag:[S.string,S.meta,S.regexp],color:"#032f62"},{tag:[S.name,S.quote],color:"#22863a"},{tag:[S.heading,S.strong],color:"#24292e",fontWeight:"bold"},{tag:[S.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[S.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[S.atom,S.bool,S.special(S.variableName)],color:"#e36209"},{tag:[S.url,S.escape,S.regexp,S.link],color:"#032f62"},{tag:S.link,textDecoration:"underline"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.invalid,color:"#cb2431"},...n]})};fI();var hI={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},dI=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},hI,r),styles:[{tag:[S.standard(S.tagName),S.tagName],color:"#7ee787"},{tag:[S.comment,S.bracket],color:"#8b949e"},{tag:[S.className,S.propertyName],color:"#d2a8ff"},{tag:[S.variableName,S.attributeName,S.number,S.operator],color:"#79c0ff"},{tag:[S.keyword,S.typeName,S.typeOperator,S.typeName],color:"#ff7b72"},{tag:[S.string,S.meta,S.regexp],color:"#a5d6ff"},{tag:[S.name,S.quote],color:"#7ee787"},{tag:[S.heading,S.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[S.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[S.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[S.atom,S.bool,S.special(S.variableName)],color:"#ffab70"},{tag:S.link,textDecoration:"underline"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.invalid,color:"#f97583"},...n]})},pI=dI(),OI={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},GC=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},OI,r),styles:[{tag:S.keyword,color:"#cf6edf"},{tag:[S.name,S.deleted,S.character,S.macroName],color:"#56c8d8"},{tag:[S.propertyName],color:"#facf4e"},{tag:[S.variableName],color:"#bdbdbd"},{tag:[S.function(S.variableName)],color:"#56c8d8"},{tag:[S.labelName],color:"#cf6edf"},{tag:[S.color,S.constant(S.name),S.standard(S.name)],color:"#facf4e"},{tag:[S.definition(S.name),S.separator],color:"#fa5788"},{tag:[S.brace],color:"#cf6edf"},{tag:[S.annotation],color:"#ff5f52"},{tag:[S.number,S.changed,S.annotation,S.modifier,S.self,S.namespace],color:"#ffad42"},{tag:[S.typeName,S.className],color:"#ffad42"},{tag:[S.operator,S.operatorKeyword],color:"#7186f0"},{tag:[S.tagName],color:"#99d066"},{tag:[S.squareBracket],color:"#ff5f52"},{tag:[S.angleBracket],color:"#606f7a"},{tag:[S.attributeName],color:"#bdbdbd"},{tag:[S.regexp],color:"#ff5f52"},{tag:[S.quote],color:"#6abf69"},{tag:[S.string],color:"#99d066"},{tag:S.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[S.url,S.escape,S.special(S.string)],color:"#facf4e"},{tag:[S.meta],color:"#707d8b"},{tag:[S.comment],color:"#707d8b",fontStyle:"italic"},{tag:S.monospace,color:"#bdbdbd"},{tag:S.strong,fontWeight:"bold",color:"#ff5f52"},{tag:S.emphasis,fontStyle:"italic",color:"#99d066"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.heading,fontWeight:"bold",color:"#facf4e"},{tag:S.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[S.heading2,S.heading3,S.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[S.heading5,S.heading6],color:"#facf4e"},{tag:[S.atom,S.bool,S.special(S.variableName)],color:"#56c8d8"},{tag:[S.processingInstruction,S.inserted],color:"#ff5f52"},{tag:[S.contentSeparator],color:"#56c8d8"},{tag:S.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"},...n]})};GC();var gI=GC(),mI={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},yI=t=>{var{theme:e="light",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},mI,r),styles:[{tag:S.keyword,color:"#39ADB5"},{tag:[S.name,S.deleted,S.character,S.macroName],color:"#90A4AE"},{tag:[S.propertyName],color:"#6182B8"},{tag:[S.processingInstruction,S.string,S.inserted,S.special(S.string)],color:"#91B859"},{tag:[S.function(S.variableName),S.labelName],color:"#6182B8"},{tag:[S.color,S.constant(S.name),S.standard(S.name)],color:"#39ADB5"},{tag:[S.definition(S.name),S.separator],color:"#90A4AE"},{tag:[S.className],color:"#E2931D"},{tag:[S.number,S.changed,S.annotation,S.modifier,S.self,S.namespace],color:"#F76D47"},{tag:[S.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[S.operator,S.operatorKeyword],color:"#39ADB5"},{tag:[S.url,S.escape,S.regexp,S.link],color:"#91B859"},{tag:[S.meta,S.comment],color:"#90A4AE"},{tag:S.strong,fontWeight:"bold"},{tag:S.emphasis,fontStyle:"italic"},{tag:S.link,textDecoration:"underline"},{tag:S.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[S.atom,S.bool,S.special(S.variableName)],color:"#90A4AE"},{tag:S.invalid,color:"#E5393570"},{tag:S.strikethrough,textDecoration:"line-through"},...n]})};yI();var vI={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},bI=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},vI,r),styles:[{tag:S.keyword,color:"#5e81ac"},{tag:[S.name,S.deleted,S.character,S.propertyName,S.macroName],color:"#88c0d0"},{tag:[S.variableName],color:"#8fbcbb"},{tag:[S.function(S.variableName)],color:"#8fbcbb"},{tag:[S.labelName],color:"#81a1c1"},{tag:[S.color,S.constant(S.name),S.standard(S.name)],color:"#5e81ac"},{tag:[S.definition(S.name),S.separator],color:"#a3be8c"},{tag:[S.brace],color:"#8fbcbb"},{tag:[S.annotation],color:"#d30102"},{tag:[S.number,S.changed,S.annotation,S.modifier,S.self,S.namespace],color:"#b48ead"},{tag:[S.typeName,S.className],color:"#ebcb8b"},{tag:[S.operator,S.operatorKeyword],color:"#a3be8c"},{tag:[S.tagName],color:"#b48ead"},{tag:[S.squareBracket],color:"#bf616a"},{tag:[S.angleBracket],color:"#d08770"},{tag:[S.attributeName],color:"#ebcb8b"},{tag:[S.regexp],color:"#5e81ac"},{tag:[S.quote],color:"#b48ead"},{tag:[S.string],color:"#a3be8c"},{tag:S.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[S.url,S.escape,S.special(S.string)],color:"#8fbcbb"},{tag:[S.meta],color:"#88c0d0"},{tag:[S.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[S.comment],color:"#4c566a",fontStyle:"italic"},{tag:S.strong,fontWeight:"bold",color:"#5e81ac"},{tag:S.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:S.heading,fontWeight:"bold",color:"#5e81ac"},{tag:S.special(S.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:S.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[S.heading2,S.heading3,S.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[S.heading5,S.heading6],color:"#5e81ac"},{tag:[S.atom,S.bool,S.special(S.variableName)],color:"#d08770"},{tag:[S.processingInstruction,S.inserted],color:"#8fbcbb"},{tag:[S.contentSeparator],color:"#ebcb8b"},{tag:S.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"},...n]})},SI=bI(),wI={background:"#fff",foreground:"#3D3D3D",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#AFAFAF",lineHighlight:"#d5e6ff69"};function PI(t){var{theme:e="light",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},wI,r),styles:[{tag:[S.comment,S.quote],color:"#707F8D"},{tag:[S.typeName,S.typeOperator],color:"#aa0d91"},{tag:[S.keyword],color:"#aa0d91",fontWeight:"bold"},{tag:[S.string,S.meta],color:"#D23423"},{tag:[S.name],color:"#032f62"},{tag:[S.typeName],color:"#522BB2"},{tag:[S.variableName],color:"#23575C"},{tag:[S.definition(S.variableName)],color:"#327A9E"},{tag:[S.regexp,S.link],color:"#0e0eff"},...n]})}var kI=PI(),xI={background:"#292A30",foreground:"#CECFD0",caret:"#fff",selection:"#727377",selectionMatch:"#727377",lineHighlight:"#ffffff0f"},_I=t=>{var{theme:e="dark",settings:r={},styles:n=[]}=t||{};return xi({theme:e,settings:qr({},xI,r),styles:[{tag:[S.comment,S.quote],color:"#7F8C98"},{tag:[S.keyword],color:"#FF7AB2",fontWeight:"bold"},{tag:[S.string,S.meta],color:"#FF8170"},{tag:[S.typeName],color:"#DABAFF"},{tag:[S.definition(S.variableName)],color:"#6BDFFF"},{tag:[S.name],color:"#6BAA9F"},{tag:[S.variableName],color:"#ACF2E4"},{tag:[S.regexp,S.link],color:"#FF8170"},...n]})};_I();const Cw="#202e46",HC="#e2e2e2",$I="#b9c7e6",QI="rgba(255,255,255,0.2)",EI="rgba(255,255,255,0.5)",CI="#000",TI="rgba(0,0,0,0.4)",RI="rgba(0,0,0,0.1)",AI="white",au=["#77fd8c","#00ffff","#66ecff","#ffb9ff","#ffabb3","#ffdb56"],Tw=au[0],Ru=au[1],jI=au[2],Rw=au[3],MI=au[4],Aw=au[5],DI="#ff2222",qI=t=>{let{state:e}=t,r=e.doc.lineAt(e.selection.main.from),n=H0(t.state,r.from);return n.line?ZI(t):n.block?BI(t):!1};function Sf(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}const ZI=Sf(K0,0),NI=Sf(K0,1),II=Sf(K0,2),WI=Sf(KC,0),BI=Sf((t,e)=>KC(t,e,VI(e)),0);function H0(t,e){let r=t.languageDataAt("commentTokens",e);return r.length?r[0]:{}}const Au=50;function LI(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-Au,n),s=t.sliceDoc(i,i+Au),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let u,f;i-n<=2*Au?u=f=t.sliceDoc(n,i):(u=t.sliceDoc(n,n+Au),f=t.sliceDoc(i-Au,i));let h=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-r.length;return u.slice(h,h+e.length)==e&&f.slice(p,p+r.length)==r?{open:{pos:n+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:i-d-r.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function VI(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to),o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to})}return e}function KC(t,e,r=e.selection.ranges){let n=r.map(o=>H0(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>LI(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let l=n[s],{open:c,close:u}=a;o.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:o}}return null}function K0(t,e,r=e.selection.ranges){let n=[],i=-1;for(let{from:o,to:s}of r){let a=n.length,l=1e9,c=H0(e,o).line;if(c){for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(f.from>i&&(o==s||s>f.from)){i=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+c.length)==c?h:-1;h<f.text.length&&h<l&&(l=h),n.push({line:f,comment:p,token:c,indent:h,empty:d,single:!1})}u=f.to+1}if(l<1e9)for(let u=a;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=l);n.length==a+1&&(n[a].single=!0)}}if(t!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of n)(f||!u)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of n)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,o.push({from:c,to:u})}return{changes:o}}return null}const Yy=Oo.define(),XI=Oo.define(),UI=Ne.define(),JC=Ne.define({combine(t){return Li(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,r)=>(n,i)=>e(n,i)||r(n,i)})}}),eT=Kr.define({create(){return uo.empty},update(t,e){let r=e.state.facet(JC),n=e.annotation(Yy);if(n){let l=Ln.fromTransaction(e,n.selection),c=n.side,u=c==0?t.undone:t.done;return l?u=Ap(u,u.length,r.minDepth,l):u=nT(u,e.startState.selection),new uo(c==0?n.rest:u,c==0?u:n.rest)}let i=e.annotation(XI);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Nr.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=Ln.fromTransaction(e),s=e.annotation(Nr.time),a=e.annotation(Nr.userEvent);return o?t=t.addChanges(o,s,a,r,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new uo(t.done.map(Ln.fromJSON),t.undone.map(Ln.fromJSON))}});function FI(t={}){return[eT,JC.of(t),Ae.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?tT:e.inputType=="historyRedo"?zy:null;return n?(e.preventDefault(),n(r)):!1}})]}function J0(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(eT,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}const tT=J0(0,!1),zy=J0(1,!1),YI=J0(0,!0);class Ln{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new Ln(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Ln(e.changes&&Fr.fromJSON(e.changes),[],e.mapped&&ho.fromJSON(e.mapped),e.startSelection&&le.fromJSON(e.startSelection),e.selectionsAfter.map(le.fromJSON))}static fromTransaction(e,r){let n=mi;for(let i of e.startState.facet(UI)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new Ln(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,mi)}static selection(e){return new Ln(void 0,mi,void 0,void 0,e)}}function Ap(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function zI(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let l=0;l<r.length;){let c=r[l++],u=r[l++];a>=c&&s<=u&&(n=!0)}}),n}function GI(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function rT(t,e){return t.length?e.length?t.concat(e):t:e}const mi=[],HI=200;function nT(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-HI));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Ap(t,t.length-1,1e9,r.setSelAfter(n)))}else return[Ln.selection([e])]}function KI(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function Eg(t,e){if(!t.length)return t;let r=t.length,n=mi;for(;r;){let i=JI(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[Ln.selection(n)]:mi}function JI(t,e,r){let n=rT(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):mi,r);if(!t.changes)return Ln.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new Ln(i,yt.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}const eW=/^(input\.type|delete)($|\.)/;class uo{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new uo(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||eW.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,zI(a.changes,e.changes))||n=="input.type.compose")?s=Ap(s,s.length-1,i.minDepth,new Ln(e.changes.compose(a.changes),rT(e.effects,a.effects),a.mapped,a.startSelection,mi)):s=Ap(s,s.length,i.minDepth,e),new uo(s,mi,r,n)}addSelection(e,r,n,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:mi;return o.length>0&&r-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&GI(o[o.length-1],e)?this:new uo(nT(this.done,e),this.undone,r,n)}addMapping(e){return new uo(Eg(this.done,e),Eg(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,r,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||r.selection;if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Yy.of({side:e,rest:KI(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?mi:i.slice(0,i.length-1);return o.mapped&&(a=Eg(a,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Yy.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}uo.empty=new uo(mi,mi);function wf(t,e){return le.create(t.ranges.map(e),t.mainIndex)}function Ms(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ca({state:t,dispatch:e},r){let n=wf(t.selection,r);return n.eq(t.selection,!0)?!1:(e(Ms(t,n)),!0)}function _O(t,e){return le.cursor(e?t.to:t.from)}function iT(t,e){return Ca(t,r=>r.empty?t.moveByChar(r,e):_O(r,e))}function Ds(t){return t.textDirectionAt(t.state.selection.main.head)==dr.LTR}const jw=t=>iT(t,!Ds(t)),Mw=t=>iT(t,Ds(t));function oT(t,e){return Ca(t,r=>r.empty?t.moveByGroup(r,e):_O(r,e))}const tW=t=>oT(t,!Ds(t)),rW=t=>oT(t,Ds(t));function sT(t,e){return Ca(t,r=>{if(!r.empty)return _O(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}const Dw=t=>sT(t,!1),qw=t=>sT(t,!0);function aT(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,r=0,n=0,i;if(e){for(let o of t.state.facet(Ae.scrollMargins)){let s=o(t);s!=null&&s.top&&(r=Math.max(s==null?void 0:s.top,r)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}i=t.scrollDOM.clientHeight-r-n}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function lT(t,e){let r=aT(t),{state:n}=t,i=wf(n.selection,s=>s.empty?t.moveVertically(s,e,r.height):_O(s,e));if(i.eq(n.selection))return!1;let o;if(r.selfScroll){let s=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+r.marginTop,c=a.bottom-r.marginBottom;s&&s.top>l&&s.bottom<c&&(o=Ae.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-l}))}return t.dispatch(Ms(n,i),{effects:o}),!0}const Cg=t=>lT(t,!1),Tg=t=>lT(t,!0);function $O(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=le.cursor(n.from+o))}return i}const Zw=t=>Ca(t,e=>$O(t,e,!0)),Nw=t=>Ca(t,e=>$O(t,e,!1)),nW=t=>Ca(t,e=>le.cursor(t.lineBlockAt(e.head).from,1)),iW=t=>Ca(t,e=>le.cursor(t.lineBlockAt(e.head).to,-1));function oW(t,e,r){let n=!1,i=wf(t.selection,o=>{let s=as(t,o.head,-1)||as(t,o.head,1)||o.head>0&&as(t,o.head-1,1)||o.head<t.doc.length&&as(t,o.head+1,-1);if(!s||!s.end)return o;n=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return r?le.range(o.anchor,a):le.cursor(a)});return n?(e(Ms(t,i)),!0):!1}const sW=({state:t,dispatch:e})=>oW(t,e,!1);function qs(t,e){let r=wf(t.state.selection,n=>{let i=e(n);return le.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return r.eq(t.state.selection)?!1:(t.dispatch(Ms(t.state,r)),!0)}function uT(t,e){return qs(t,r=>t.moveByChar(r,e))}const Iw=t=>uT(t,!Ds(t)),Ww=t=>uT(t,Ds(t));function cT(t,e){return qs(t,r=>t.moveByGroup(r,e))}const aW=t=>cT(t,!Ds(t)),lW=t=>cT(t,Ds(t));function fT(t,e){return qs(t,r=>t.moveVertically(r,e))}const Bw=t=>fT(t,!1),Lw=t=>fT(t,!0);function hT(t,e){return qs(t,r=>t.moveVertically(r,e,aT(t).height))}const Vw=t=>hT(t,!1),Xw=t=>hT(t,!0),Uw=t=>qs(t,e=>$O(t,e,!0)),Fw=t=>qs(t,e=>$O(t,e,!1)),uW=t=>qs(t,e=>le.cursor(t.lineBlockAt(e.head).from)),cW=t=>qs(t,e=>le.cursor(t.lineBlockAt(e.head).to)),Yw=({state:t,dispatch:e})=>(e(Ms(t,{anchor:0})),!0),zw=({state:t,dispatch:e})=>(e(Ms(t,{anchor:t.doc.length})),!0),Gw=({state:t,dispatch:e})=>(e(Ms(t,{anchor:t.selection.main.anchor,head:0})),!0),Hw=({state:t,dispatch:e})=>(e(Ms(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),fW=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),hW=({state:t,dispatch:e})=>{let r=EO(t).map(({from:n,to:i})=>le.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:le.create(r),userEvent:"select"})),!0};function QO(t,e){if(t.state.readOnly)return!1;let r="delete.selection",{state:n}=t,i=n.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);l<s?(r="delete.backward",l=mh(t,l,!1)):l>s&&(r="delete.forward",l=mh(t,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=mh(t,s,!1),a=mh(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:le.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(n.update(i,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?Ae.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function mh(t,e,r){if(t instanceof Ae)for(let n of t.state.facet(Ae.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{i<e&&o>e&&(e=r?o:i)});return e}const dT=(t,e)=>QO(t,r=>{let n=r.from,{state:i}=t,o=i.doc.lineAt(n),s,a;if(!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,n-o.from))){if(s[s.length-1]==" ")return n-1;let l=Ii(s,i.tabSize),c=l%zl(i)||zl(i);for(let u=0;u<c&&s[s.length-1-u]==" ";u++)n--;a=n}else a=fn(o.text,n-o.from,e,e)+o.from,a==n&&o.number!=(e?i.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=fn(o.text,a-o.from,!1,!1)+o.from);return a}),Rg=t=>dT(t,!1),Kw=t=>dT(t,!0),pT=(t,e)=>QO(t,r=>{let n=r.head,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r.head&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let l=fn(o.text,n-o.from,e)+o.from,c=o.text.slice(Math.min(n,l)-o.from,Math.max(n,l)-o.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||n!=r.head)&&(a=u),n=l}return n}),Jw=t=>pT(t,!1),dW=t=>pT(t,!0),eP=t=>QO(t,e=>{let r=t.lineBlockAt(e.head).to;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),pW=t=>QO(t,e=>{let r=t.lineBlockAt(e.head).from;return e.head>r?r:Math.max(0,e.head-1)}),OW=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Bt.of(["",""])},range:le.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},gW=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:fn(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:fn(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:le.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function EO(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function OT(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of EO(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let l of o.ranges)i.push(le.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let l of o.ranges)i.push(le.range(l.anchor-a,l.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:le.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const mW=({state:t,dispatch:e})=>OT(t,e,!1),yW=({state:t,dispatch:e})=>OT(t,e,!0);function gT(t,e,r){if(t.readOnly)return!1;let n=[];for(let i of EO(t))r?n.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):n.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vW=({state:t,dispatch:e})=>gT(t,e,!1),bW=({state:t,dispatch:e})=>gT(t,e,!0),SW=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(EO(e).map(({from:i,to:o})=>(i>0?i--:o<e.doc.length&&o++,{from:i,to:o}))),n=wf(e.selection,i=>t.moveVertically(i,!0)).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function wW(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=Qr(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(pt.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const tP=PW(!1);function PW(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),l=!t&&o==s&&wW(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new X0(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=jC(c,o);for(u==null&&(u=Ii(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",Rp(e,u)];return l&&f.push(Rp(e,c.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:Bt.of(f)},range:le.cursor(o+1+f[1].length)}});return r(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function mT(t,e){let r=-1;return t.changeByRange(n=>{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:le.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const rP=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(mT(t,(r,n)=>{n.push({from:r.from,insert:t.facet(vf)})}),{userEvent:"input.indent"})),!0),nP=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(mT(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=Ii(i,t.tabSize),s=0,a=Rp(t,Math.max(0,o-zl(t)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0);function ir(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var i=r[n];typeof i=="string"?t.setAttribute(n,i):i!=null&&(t[n]=i)}e++}for(;e<arguments.length;e++)yT(t,arguments[e]);return t}function yT(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var r=0;r<e.length;r++)yT(t,e[r]);else throw new RangeError("Unsupported child node: "+e)}const iP=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class Gl{constructor(e,r,n=0,i=e.length,o,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?a=>o(iP(a)):iP,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ln(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=x0(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=di(e);let i=this.normalize(r);for(let o=0,s=n;;o++){let a=i.charCodeAt(o),l=this.match(a,s,this.bufferPos+this.bufferStart);if(o==i.length-1){if(l)return this.value=l,this;break}s==n&&o<r.length&&r.charCodeAt(o)==a&&s++}}}match(e,r,n){let i=null;for(let o=0;o<this.matches.length;o+=2){let s=this.matches[o],a=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[o+1],to:n}:(this.matches[o]++,a=!0)),a||(this.matches.splice(o,2),o-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:r,to:n}:this.matches.push(1,r)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(Gl.prototype[Symbol.iterator]=function(){return this});const vT={from:-1,to:-1,match:/.*/.exec("")},e1="gm"+(/x/.unicode==null?"":"u");class bT{constructor(e,r,n,i=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=vT,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new ST(e,r,n,i,o);this.re=new RegExp(r,e1+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=jp(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=jp(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Ag=new WeakMap;class Tl{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let i=Ag.get(e);if(!i||i.from>=n||i.to<=r){let a=new Tl(r,e.sliceString(r,n));return Ag.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to<n&&(o+=e.sliceString(i.to,n)),Ag.set(e,new Tl(s,o)),new Tl(r,o.slice(r-s,n-s))}}class ST{constructor(e,r,n,i,o){this.text=e,this.to=o,this.done=!1,this.value=vT,this.matchPos=jp(e,i),this.re=new RegExp(r,e1+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=Tl.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,i=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,match:r},this.matchPos=jp(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Tl.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(bT.prototype[Symbol.iterator]=ST.prototype[Symbol.iterator]=function(){return this});function kW(t){try{return new RegExp(t,e1),!0}catch{return!1}}function jp(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}function Gy(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),r=ir("input",{class:"cm-textfield",name:"line",value:e}),n=ir("form",{class:"cm-gotoLine",onkeydown:o=>{o.keyCode==27?(o.preventDefault(),t.dispatch({effects:Mp.of(!1)}),t.focus()):o.keyCode==13&&(o.preventDefault(),i())},onsubmit:o=>{o.preventDefault(),i()}},ir("label",t.state.phrase("Go to line"),": ",r)," ",ir("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function i(){let o=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.value);if(!o)return;let{state:s}=t,a=s.doc.lineAt(s.selection.main.head),[,l,c,u,f]=o,h=u?+u.slice(1):0,d=c?+c:a.number;if(c&&f){let m=d/100;l&&(m=m*(l=="-"?-1:1)+a.number/s.doc.lines),d=Math.round(s.doc.lines*m)}else c&&l&&(d=d*(l=="-"?-1:1)+a.number);let p=s.doc.line(Math.max(1,Math.min(s.doc.lines,d))),O=le.cursor(p.from+Math.max(0,Math.min(h,p.length)));t.dispatch({effects:[Mp.of(!1),Ae.scrollIntoView(O.from,{y:"center"})],selection:O}),t.focus()}return{dom:n}}const Mp=yt.define(),oP=Kr.define({create(){return!0},update(t,e){for(let r of e.effects)r.is(Mp)&&(t=r.value);return t},provide:t=>Uc.from(t,e=>e?Gy:null)}),xW=t=>{let e=Xc(t,Gy);if(!e){let r=[Mp.of(!0)];t.state.field(oP,!1)==null&&r.push(yt.appendConfig.of([oP,_W])),t.dispatch({effects:r}),e=Xc(t,Gy)}return e&&e.dom.querySelector("input").select(),!0},_W=Ae.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),$W={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},wT=Ne.define({combine(t){return Li(t,$W,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function QW(t){let e=[AW,RW];return t&&e.push(wT.of(t)),e}const EW=Ye.mark({class:"cm-selectionMatch"}),CW=Ye.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function sP(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=Sr.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=Sr.Word)}function TW(t,e,r,n){return t(e.sliceDoc(r,r+1))==Sr.Word&&t(e.sliceDoc(n-1,n))==Sr.Word}const RW=ar.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(wT),{state:r}=t,n=r.selection;if(n.ranges.length>1)return Ye.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return Ye.none;let l=r.wordAt(i.head);if(!l)return Ye.none;s=r.charCategorizer(i.head),o=r.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return Ye.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(sP(s,r,i.from,i.to)&&TW(s,r,i.from,i.to)))return Ye.none}else if(o=r.sliceDoc(i.from,i.to),!o)return Ye.none}let a=[];for(let l of t.visibleRanges){let c=new Gl(r.doc,o,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!s||sP(s,r,u,f))&&(i.empty&&u<=i.from&&f>=i.to?a.push(CW.range(u,f)):(u>=i.to||f<=i.from)&&a.push(EW.range(u,f)),a.length>e.maxMatches))return Ye.none}}return Ye.set(a)}},{decorations:t=>t.decorations}),AW=Ae.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),jW=({state:t,dispatch:e})=>{let{selection:r}=t,n=le.create(r.ranges.map(i=>t.wordAt(i.head)||le.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function MW(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Gl(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Gl(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(l=>l.from==a.value.from))continue;if(o){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const DW=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return jW({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=MW(t,n);return i?(e(t.update({selection:t.selection.addRange(le.range(i.from,i.to),!1),effects:Ae.scrollIntoView(i.to)})),!0):!1},lu=Ne.define({combine(t){return Li(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new XW(e),scrollToMatch:e=>Ae.scrollIntoView(e)})}});class PT{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||kW(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
87
87
  `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new IW(this):new ZW(this)}getCursor(e,r=0,n){let i=e.doc?e:Dt.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?tl(this,i,r,n):el(this,i,r,n)}}class kT{constructor(e){this.spec=e}}function el(t,e,r,n){return new Gl(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:i=>i.toLowerCase(),t.wholeWord?qW(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function qW(t,e){return(r,n,i,o)=>((o>r||o+i.length<n)&&(o=Math.max(0,r-2),i=t.sliceString(o,Math.min(t.length,n+2))),(e(Dp(i,r-o))!=Sr.Word||e(qp(i,r-o))!=Sr.Word)&&(e(qp(i,n-o))!=Sr.Word||e(Dp(i,n-o))!=Sr.Word))}class ZW extends kT{constructor(e){super(e)}nextMatch(e,r,n){let i=el(this.spec,e,n,e.doc.length).nextOverlapping();return i.done&&(i=el(this.spec,e,0,r).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let o=Math.max(r,i-1e4-this.spec.unquoted.length),s=el(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==r)return null;i-=1e4}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=el(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=el(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function tl(t,e,r,n){return new bT(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?NW(e.charCategorizer(e.selection.main.head)):void 0},r,n)}function Dp(t,e){return t.slice(fn(t,e,!1),e)}function qp(t,e){return t.slice(e,fn(t,e))}function NW(t){return(e,r,n)=>!n[0].length||(t(Dp(n.input,n.index))!=Sr.Word||t(qp(n.input,n.index))!=Sr.Word)&&(t(qp(n.input,n.index+n[0].length))!=Sr.Word||t(Dp(n.input,n.index+n[0].length))!=Sr.Word)}class IW extends kT{nextMatch(e,r,n){let i=tl(this.spec,e,n,e.doc.length).next();return i.done&&(i=tl(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let o=Math.max(r,n-i*1e4),s=tl(this.spec,e,o,n),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==r||a.from>o+10))return a;if(o==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(r,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n<e.match.length?e.match[n]:r)}matchAll(e,r){let n=tl(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=tl(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const Gc=yt.define(),t1=yt.define(),ys=Kr.define({create(t){return new jg(Hy(t).create(),null)},update(t,e){for(let r of e.effects)r.is(Gc)?t=new jg(r.value.create(),t.panel):r.is(t1)&&(t=new jg(t.query,r.value?r1:null));return t},provide:t=>Uc.from(t,e=>e.panel)});class jg{constructor(e,r){this.query=e,this.panel=r}}const WW=Ye.mark({class:"cm-searchMatch"}),BW=Ye.mark({class:"cm-searchMatch cm-searchMatch-selected"}),LW=ar.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(ys))}update(t){let e=t.state.field(ys);(e!=t.startState.field(ys)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Ye.none;let{view:r}=this,n=new ws;for(let i=0,o=r.visibleRanges,s=o.length;i<s;i++){let{from:a,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-2*250;)l=o[++i].to;t.highlight(r.state,a,l,(c,u)=>{let f=r.state.selection.ranges.some(h=>h.from==c&&h.to==u);n.add(c,u,f?BW:WW)})}return n.finish()}},{decorations:t=>t.decorations});function Pf(t){return e=>{let r=e.state.field(ys,!1);return r&&r.query.spec.valid?t(e,r):ET(e)}}const aP=Pf((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=le.single(n.from,n.to),o=t.state.facet(lu);return t.dispatch({selection:i,effects:[n1(t,n),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),QT(t),!0}),lP=Pf((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let o=le.single(i.from,i.to),s=t.state.facet(lu);return t.dispatch({selection:o,effects:[n1(t,i),s.scrollToMatch(o.main,t)],userEvent:"select.search"}),QT(t),!0}),xT=Pf((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:le.create(r.map(n=>le.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),VW=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,o=[],s=0;for(let a=new Gl(t.doc,t.sliceDoc(n,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(s=o.length),o.push(le.range(a.value.from,a.value.to))}return e(t.update({selection:le.create(o,s),userEvent:"select.search.matches"})),!0},uP=Pf((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let o=e.nextMatch(r,n,n);if(!o)return!1;let s=[],a,l,c=[];if(o.from==n&&o.to==i&&(l=r.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=e.nextMatch(r,o.from,o.to),c.push(Ae.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+"."))),o){let u=s.length==0||s[0].from>=o.to?0:o.to-o.from-l.length;a=le.single(o.from-u,o.to-u),c.push(n1(t,o)),c.push(r.facet(lu).scrollToMatch(a.main,t))}return t.dispatch({changes:s,selection:a,effects:c,userEvent:"input.replace"}),!0}),_T=Pf((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(i=>{let{from:o,to:s}=i;return{from:o,to:s,insert:e.getReplacement(i)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:Ae.announce.of(n),userEvent:"input.replace.all"}),!0});function r1(t){return t.state.facet(lu).createPanel(t)}function Hy(t,e){var r,n,i,o,s;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(lu);return new PT({search:((r=e==null?void 0:e.literal)!==null&&r!==void 0?r:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:c.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:c.wholeWord})}function $T(t){let e=Xc(t,r1);return e&&e.dom.querySelector("[main-field]")}function QT(t){let e=$T(t);e&&e==t.root.activeElement&&e.select()}const ET=t=>{let e=t.state.field(ys,!1);if(e&&e.panel){let r=$T(t);if(r&&r!=t.root.activeElement){let n=Hy(t.state,e.query.spec);n.valid&&t.dispatch({effects:Gc.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[t1.of(!0),e?Gc.of(Hy(t.state,e.query.spec)):yt.appendConfig.of(FW)]});return!0},CT=t=>{let e=t.state.field(ys,!1);if(!e||!e.panel)return!1;let r=Xc(t,r1);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:t1.of(!1)}),!0};class XW{constructor(e){this.view=e;let r=this.query=e.state.field(ys).query.spec;this.commit=this.commit.bind(this),this.searchField=ir("input",{value:r.search,placeholder:Yn(e,"Find"),"aria-label":Yn(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ir("input",{value:r.replace,placeholder:Yn(e,"Replace"),"aria-label":Yn(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ir("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=ir("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=ir("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,o,s){return ir("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=ir("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>aP(e),[Yn(e,"next")]),n("prev",()=>lP(e),[Yn(e,"previous")]),n("select",()=>xT(e),[Yn(e,"all")]),ir("label",null,[this.caseField,Yn(e,"match case")]),ir("label",null,[this.reField,Yn(e,"regexp")]),ir("label",null,[this.wordField,Yn(e,"by word")]),...e.state.readOnly?[]:[ir("br"),this.replaceField,n("replace",()=>uP(e),[Yn(e,"replace")]),n("replaceAll",()=>_T(e),[Yn(e,"replace all")])],ir("button",{name:"close",onclick:()=>CT(e),"aria-label":Yn(e,"close"),type:"button"},["×"])])}commit(){let e=new PT({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Gc.of(e)}))}keydown(e){qq(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?lP:aP)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),uP(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(Gc)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(lu).top}}function Yn(t,e){return t.state.phrase(e)}const yh=30,vh=/[\s\.,:;?!]/;function n1(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,o=Math.max(n.from,e-yh),s=Math.min(i,r+yh),a=t.state.sliceDoc(o,s);if(o!=n.from){for(let l=0;l<yh;l++)if(!vh.test(a[l+1])&&vh.test(a[l])){a=a.slice(l);break}}if(s!=i){for(let l=a.length-1;l>a.length-yh;l--)if(!vh.test(a[l-1])&&vh.test(a[l])){a=a.slice(0,l);break}}return Ae.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const UW=Ae.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),FW=[ys,Zo.low(LW),UW];class i1{constructor(e,r,n){this.state=e,this.pos=r,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let r=Qr(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),i=r.text.slice(n-r.from,this.pos-r.from),o=i.search(RT(e,!1));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,r){e=="abort"&&this.abortListeners&&this.abortListeners.push(r)}}function cP(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function YW(t){let e=Object.create(null),r=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let o=1;o<i.length;o++)r[i[o]]=!0}let n=cP(e)+cP(r)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function TT(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[r,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:YW(e);return i=>{let o=i.matchBefore(n);return o||i.explicit?{from:o?o.from:i.pos,options:e,validFor:r}:null}}function zW(t,e){return r=>{for(let n=Qr(r.state).resolveInner(r.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(r)}}class fP{constructor(e,r,n,i){this.completion=e,this.source=r,this.match=n,this.score=i}}function vs(t){return t.selection.main.from}function RT(t,e){var r;let{source:n}=t,i=e&&n[0]!="^",o=n[n.length-1]!="$";return!i&&!o?t:new RegExp(`${i?"^":""}(?:${n})${o?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}const o1=Oo.define();function GW(t,e,r,n){let{main:i}=t.selection,o=r-i.from,s=n-i.from;return Object.assign(Object.assign({},t.changeByRange(a=>a!=i&&r!=n&&t.sliceDoc(a.from+o,a.from+s)!=t.sliceDoc(r,n)?{range:a}:{changes:{from:a.from+o,to:n==i.from?a.to:a.from+s,insert:e},range:le.cursor(a.from+o+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const hP=new WeakMap;function HW(t){if(!Array.isArray(t))return t;let e=hP.get(t);return e||hP.set(t,e=TT(t)),e}const Zp=yt.define(),Hc=yt.define();class KW{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let r=0;r<e.length;){let n=ln(e,r),i=di(n);this.chars.push(n);let o=e.slice(r,r+i),s=o.toUpperCase();this.folded.push(ln(s==o?o.toLowerCase():s,0)),r+=i}this.astral=e.length!=this.chars.length}ret(e,r){return this.score=e,this.matched=r,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:r,folded:n,any:i,precise:o,byWord:s}=this;if(r.length==1){let g=ln(e,0),v=di(g),b=v==e.length?0:-100;if(g!=r[0])if(g==n[0])b+=-200;else return null;return this.ret(b,[0,v])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=r.length,c=0;if(a<0){for(let g=0,v=Math.min(e.length,200);g<v&&c<l;){let b=ln(e,g);(b==r[c]||b==n[c])&&(i[c++]=g),g+=di(b)}if(c<l)return null}let u=0,f=0,h=!1,d=0,p=-1,O=-1,m=/[a-z]/.test(e),y=!0;for(let g=0,v=Math.min(e.length,200),b=0;g<v&&f<l;){let P=ln(e,g);a<0&&(u<l&&P==r[u]&&(o[u++]=g),d<l&&(P==r[d]||P==n[d]?(d==0&&(p=g),O=g+1,d++):d=0));let _,Q=P<255?P>=48&&P<=57||P>=97&&P<=122?2:P>=65&&P<=90?1:0:(_=x0(P))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!g||Q==1&&m||b==0&&Q!=0)&&(r[f]==P||n[f]==P&&(h=!0)?s[f++]=g:s.length&&(y=!1)),b=Q,g+=di(P)}return f==l&&s[0]==0&&y?this.result(-100+(h?-200:0),s,e):d==l&&p==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,O]):f==l?this.result(-100+(h?-200:0)+-700+(y?0:-1100),s,e):r.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,r,n){let i=[],o=0;for(let s of r){let a=s+(this.astral?di(ln(n,s)):1);o&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return this.ret(e-n.length,i)}}class JW{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let r=e.slice(0,this.pattern.length),n=r==this.pattern?0:r.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,r.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const cn=Ne.define({combine(t){return Li(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:eB,filterStrict:!1,compareCompletions:(e,r)=>e.label.localeCompare(r.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,tooltipClass:(e,r)=>n=>dP(e(n),r(n)),optionClass:(e,r)=>n=>dP(e(n),r(n)),addToOptions:(e,r)=>e.concat(r),filterStrict:(e,r)=>e||r})}});function dP(t,e){return t?e?t+" "+e:t:e}function eB(t,e,r,n,i,o){let s=t.textDirection==dr.RTL,a=s,l=!1,c="top",u,f,h=e.left-i.left,d=i.right-e.right,p=n.right-n.left,O=n.bottom-n.top;if(a&&h<Math.min(p,d)?a=!1:!a&&d<Math.min(p,h)&&(a=!0),p<=(a?h:d))u=Math.max(i.top,Math.min(r.top,i.bottom-O))-e.top,f=Math.min(400,a?h:d);else{l=!0,f=Math.min(400,(s?e.right:i.right-e.left)-30);let g=i.bottom-e.bottom;g>=O||g>e.top?u=r.bottom-e.top:(c="bottom",u=e.bottom-r.top)}let m=(e.bottom-e.top)/o.offsetHeight,y=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${f/y}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}function tB(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,i,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=r.displayLabel||r.label,l=0;for(let c=0;c<o.length;){let u=o[c++],f=o[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(r){if(!r.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=r.detail,n},position:80}),e.sort((r,n)=>r.position-n.position).map(r=>r.render)}function Mg(t,e,r){if(t<=r)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/r);return{from:i*r,to:(i+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}class rB{constructor(e,r,n){this.view=e,this.stateField=r,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(r),{options:o,selected:s}=i.open,a=e.state.facet(cn);this.optionContent=tB(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Mg(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(r).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(cn).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Hc.of(null)})}),this.showOptions(o,i.id)}mount(){this.updateSel()}showOptions(e,r){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,r,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var r;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:o,selected:s,disabled:a}=n.open;(!i.open||i.open.options!=o)&&(this.range=Mg(o.length,s,e.state.facet(cn).maxRenderedOptions),this.showOptions(o,n.id)),this.updateSel(),a!=((r=i.open)===null||r===void 0?void 0:r.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let r=this.tooltipClass(e);if(r!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of r.split(" "))n&&this.dom.classList.add(n);this.currentClass=r}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;if((r.selected>-1&&r.selected<this.range.from||r.selected>=this.range.to)&&(this.range=Mg(r.options.length,r.selected,this.view.state.facet(cn).maxRenderedOptions),this.showOptions(r.options,e.id)),this.updateSelectedOption(r.selected)){this.destroyInfo();let{completion:n}=r.options[r.selected],{info:i}=n;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,n)}).catch(s=>Tn(this.view.state,s,"completion info")):this.addInfoPane(o,n)}}addInfoPane(e,r){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:o}=e;n.appendChild(i),this.infoDestroy=o||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return r&&iB(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.defaultView||window;o={left:0,top:0,right:s.innerWidth,bottom:s.innerHeight}}return i.top>Math.min(o.bottom,r.bottom)-10||i.bottom<Math.max(o.top,r.top)+10?null:this.view.state.facet(cn).positionInfo(this.view,r,i,n,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,r,n){const i=document.createElement("ul");i.id=r,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let o=null;for(let s=n.from;s<n.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=o&&(s>n.from||n.from==0))if(o=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let d=i.appendChild(document.createElement("completion-section"));d.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=r+"-"+s,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&u.appendChild(d)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function nB(t,e){return r=>new rB(r,t,e)}function iB(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),i=r.height/t.offsetHeight;n.top<r.top?t.scrollTop-=(r.top-n.top)/i:n.bottom>r.bottom&&(t.scrollTop+=(n.bottom-r.bottom)/i)}function pP(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function oB(t,e){let r=[],n=null,i=c=>{r.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let f=typeof u=="string"?u:u.name;n.some(h=>h.name==f)||n.push(typeof u=="string"?{name:f}:u)}},o=e.facet(cn);for(let c of t)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)i(new fP(f,c.source,u?u(f):[],1e9-r.length));else{let f=e.sliceDoc(c.from,c.to),h,d=o.filterStrict?new JW(f):new KW(f);for(let p of c.result.options)if(h=d.match(p.label)){let O=p.displayLabel?u?u(p,h.matched):[]:h.matched;i(new fP(p,c.source,O,h.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,f=(h,d)=>{var p,O;return((p=h.rank)!==null&&p!==void 0?p:1e9)-((O=d.rank)!==null&&O!==void 0?O:1e9)||(h.name<d.name?-1:1)};for(let h of n.sort(f))u-=1e5,c[h.name]=u;for(let h of r){let{section:d}=h.completion;d&&(h.score+=c[typeof d=="string"?d:d.name])}}let s=[],a=null,l=o.compareCompletions;for(let c of r.sort((u,f)=>f.score-u.score||l(u.completion,f.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?s.push(c):pP(c.completion)>pP(a)&&(s[s.length-1]=c),a=c.completion}return s}class yl{constructor(e,r,n,i,o,s){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new yl(this.options,OP(r,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,r,n,i,o){let s=oB(e,r);if(!s.length)return i&&e.some(l=>l.state==1)?new yl(i.options,i.attrs,i.tooltip,i.timestamp,i.selected,!0):null;let a=r.facet(cn).selectOnOpen?0:-1;if(i&&i.selected!=a&&i.selected!=-1){let l=i.options[i.selected].completion;for(let c=0;c<s.length;c++)if(s[c].completion==l){a=c;break}}return new yl(s,OP(n,a),{pos:e.reduce((l,c)=>c.hasResult()?Math.min(l,c.from):l,1e8),create:cB,above:o.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new yl(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Np{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new Np(lB,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(cn),o=(n.override||r.languageDataAt("autocomplete",vs(r)).map(HW)).map(a=>(this.active.find(c=>c.source==a)||new Cn(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));o.length==this.active.length&&o.every((a,l)=>a==this.active[l])&&(o=this.active);let s=this.open;s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!sB(o,this.active)?s=yl.build(o,r,this.id,s,n):s&&s.disabled&&!o.some(a=>a.state==1)&&(s=null),!s&&o.every(a=>a.state!=1)&&o.some(a=>a.hasResult())&&(o=o.map(a=>a.hasResult()?new Cn(a.source,0):a));for(let a of e.effects)a.is(jT)&&(s=s&&s.setSelected(a.value,this.id));return o==this.active&&s==this.open?this:new Np(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:aB}}function sB(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;r<t.length&&!t[r].hasResult;)r++;for(;n<e.length&&!e[n].hasResult;)n++;let i=r==t.length,o=n==e.length;if(i||o)return i==o;if(t[r++].result!=e[n++].result)return!1}}const aB={"aria-autocomplete":"list"};function OP(t,e){let r={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(r["aria-activedescendant"]=t+"-"+e),r}const lB=[];function Ky(t,e){if(t.isUserEvent("input.complete")){let r=t.annotation(o1);if(r&&e.activateOnCompletion(r))return"input"}return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class Cn{constructor(e,r,n=-1){this.source=e,this.state=r,this.explicitPos=n}hasResult(){return!1}update(e,r){let n=Ky(e,r),i=this;n?i=i.handleUserEvent(e,n,r):e.docChanged?i=i.handleChange(e):e.selection&&i.state!=0&&(i=new Cn(i.source,0));for(let o of e.effects)if(o.is(Zp))i=new Cn(i.source,1,o.value?vs(e.state):-1);else if(o.is(Hc))i=new Cn(i.source,0);else if(o.is(AT))for(let s of o.value)s.source==i.source&&(i=s);return i}handleUserEvent(e,r,n){return r=="delete"||!n.activateOnTyping?this.map(e.changes):new Cn(this.source,1)}handleChange(e){return e.changes.touchesRange(vs(e.startState))?new Cn(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Cn(this.source,this.state,e.mapPos(this.explicitPos))}}class Rl extends Cn{constructor(e,r,n,i,o){super(e,2,r),this.result=n,this.from=i,this.to=o}hasResult(){return!0}handleUserEvent(e,r,n){var i;let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let s=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=vs(e.state);if((this.explicitPos<0?l<=s:l<this.from)||l>a||!o||r=="delete"&&vs(e.startState)==this.from)return new Cn(this.source,r=="input"&&n.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return uB(o.validFor,e.state,s,a)?new Rl(this.source,c,o,s,a):o.update&&(o=o.update(o,s,a,new i1(e.state,l,c>=0)))?new Rl(this.source,c,o,o.from,(i=o.to)!==null&&i!==void 0?i:vs(e.state)):new Cn(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Cn(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Rl(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Cn(this.source,0)}}function uB(t,e,r,n){if(!t)return!1;let i=e.sliceDoc(r,n);return typeof t=="function"?t(i,r,n,e):RT(t,!0).test(i)}const AT=yt.define({map(t,e){return t.map(r=>r.map(e))}}),jT=yt.define(),Wn=Kr.define({create(){return Np.start()},update(t,e){return t.update(e)},provide:t=>[q0.from(t,e=>e.tooltip),Ae.contentAttributes.from(t,e=>e.attrs)]});function s1(t,e){const r=e.completion.apply||e.completion.label;let n=t.state.field(Wn).active.find(i=>i.source==e.source);return n instanceof Rl?(typeof r=="string"?t.dispatch(Object.assign(Object.assign({},GW(t.state,r,n.from,n.to)),{annotations:o1.of(e.completion)})):r(t,e.completion,n.from,n.to),!0):!1}const cB=nB(Wn,s1);function ls(t,e="option"){return r=>{let n=r.state.field(Wn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<r.state.facet(cn).interactionDelay)return!1;let i=1,o;e=="page"&&(o=PC(r,n.open.tooltip))&&(i=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,a=n.open.selected>-1?n.open.selected+i*(t?1:-1):t?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),r.dispatch({effects:jT.of(a)}),!0}}const Jy=t=>{let e=t.state.field(Wn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(cn).interactionDelay?!1:s1(t,e.open.options[e.open.selected])},MT=t=>t.state.field(Wn,!1)?(t.dispatch({effects:Zp.of(!0)}),!0):!1,DT=t=>{let e=t.state.field(Wn,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:Hc.of(null)}),!0)};class fB{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}}const hB=50,dB=1e3,pB=ar.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Wn).active)e.state==1&&this.startQuery(e)}update(t){let e=t.state.field(Wn),r=t.state.facet(cn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Wn)==e)return;let n=t.transactions.some(o=>(o.selection||o.docChanged)&&!Ky(o,r));for(let o=0;o<this.running.length;o++){let s=this.running[o];if(n||s.updates.length+t.transactions.length>hB&&Date.now()-s.time>dB){for(let a of s.context.abortListeners)try{a()}catch(l){Tn(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(o=>o.effects.some(s=>s.is(Zp)))&&(this.pendingStart=!0);let i=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.state==1&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let o of t.transactions)Ky(o,r)=="input"?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Wn);for(let r of e.active)r.state==1&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r)}startQuery(t){let{state:e}=this.view,r=vs(e),n=new i1(e,r,t.explicitPos==r),i=new fB(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Hc.of(null)}),Tn(this.view.state,o)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(cn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(cn);for(let n=0;n<this.running.length;n++){let i=this.running[n];if(i.done===void 0)continue;if(this.running.splice(n--,1),i.done){let s=new Rl(i.active.source,i.active.explicitPos,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:vs(i.updates.length?i.updates[0].startState:this.view.state));for(let a of i.updates)s=s.update(a,r);if(s.hasResult()){e.push(s);continue}}let o=this.view.state.field(Wn).active.find(s=>s.source==i.active.source);if(o&&o.state==1)if(i.done==null){let s=new Cn(i.active.source,0);for(let a of i.updates)s=s.update(a,r);s.state!=1&&e.push(s)}else this.startQuery(o)}e.length&&this.view.dispatch({effects:AT.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Wn,!1);if(e&&e.tooltip&&this.view.state.facet(cn).closeOnBlur){let r=e.open&&PC(this.view,e.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Hc.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Zp.of(!1)}),20),this.composing=0}}}),OB=typeof navigator=="object"&&/Win/.test(navigator.platform),gB=Zo.highest(Ae.domEventHandlers({keydown(t,e){let r=e.state.field(Wn,!1);if(!r||!r.open||r.open.disabled||r.open.selected<0||t.key.length>1||t.ctrlKey&&!(OB&&t.altKey)||t.metaKey)return!1;let n=r.open.options[r.open.selected],i=r.active.find(s=>s.source==n.source),o=n.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(t.key)>-1&&s1(e,n),!1}})),qT=Ae.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class mB{constructor(e,r,n,i){this.field=e,this.line=r,this.from=n,this.to=i}}class a1{constructor(e,r,n){this.field=e,this.from=r,this.to=n}map(e){let r=e.mapPos(this.from,-1,Yr.TrackDel),n=e.mapPos(this.to,1,Yr.TrackDel);return r==null||n==null?null:new a1(this.field,r,n)}}class l1{constructor(e,r){this.lines=e,this.fieldPositions=r}instantiate(e,r){let n=[],i=[r],o=e.doc.lineAt(r),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(n.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(vf);i.push(r+c.length-u),l=c+l.slice(u)}n.push(l),r+=l.length+1}let a=this.fieldPositions.map(l=>new a1(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:n,ranges:a}}static parse(e){let r=[],n=[],i=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1;for(let u=0;u<r.length;u++)(a!=null?r[u].seq==a:l&&r[u].name==l)&&(c=u);if(c<0){let u=0;for(;u<r.length&&(a==null||r[u].seq!=null&&r[u].seq<a);)u++;r.splice(u,0,{seq:a,name:l}),c=u;for(let f of i)f.field>=c&&f.field++}i.push(new mB(c,n.length,o.index,o.index+l.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}for(let a;a=/\\([{}])/.exec(s);){s=s.slice(0,a.index)+a[1]+s.slice(a.index+a[0].length);for(let l of i)l.line==n.length&&l.from>a.index&&(l.from--,l.to--)}n.push(s)}return new l1(n,i)}}let yB=Ye.widget({widget:new class extends ki{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),vB=Ye.mark({class:"cm-snippetField"});class uu{constructor(e,r){this.ranges=e,this.active=r,this.deco=Ye.set(e.map(n=>(n.from==n.to?yB:vB).range(n.from,n.to)))}map(e){let r=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;r.push(i)}return new uu(r,this.active)}selectionInsideField(e){return e.ranges.every(r=>this.ranges.some(n=>n.field==this.active&&n.from<=r.from&&n.to>=r.to))}}const kf=yt.define({map(t,e){return t&&t.map(e)}}),bB=yt.define(),Kc=Kr.define({create(){return null},update(t,e){for(let r of e.effects){if(r.is(kf))return r.value;if(r.is(bB)&&t)return new uu(t.ranges,r.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>Ae.decorations.from(t,e=>e?e.deco:Ye.none)});function u1(t,e){return le.create(t.filter(r=>r.field==e).map(r=>le.range(r.from,r.to)))}function SB(t){let e=l1.parse(t);return(r,n,i,o)=>{let{text:s,ranges:a}=e.instantiate(r.state,i),l={changes:{from:i,to:o,insert:Bt.of(s)},scrollIntoView:!0,annotations:n?[o1.of(n),Nr.userEvent.of("input.complete")]:void 0};if(a.length&&(l.selection=u1(a,0)),a.some(c=>c.field>0)){let c=new uu(a,0),u=l.effects=[kf.of(c)];r.state.field(Kc,!1)===void 0&&u.push(yt.appendConfig.of([Kc,_B,$B,qT]))}r.dispatch(r.state.update(l))}}function ZT(t){return({state:e,dispatch:r})=>{let n=e.field(Kc,!1);if(!n||t<0&&n.active==0)return!1;let i=n.active+t,o=t>0&&!n.ranges.some(s=>s.field==i+t);return r(e.update({selection:u1(n.ranges,i),effects:kf.of(o?null:new uu(n.ranges,i)),scrollIntoView:!0})),!0}}const wB=({state:t,dispatch:e})=>t.field(Kc,!1)?(e(t.update({effects:kf.of(null)})),!0):!1,PB=ZT(1),kB=ZT(-1),xB=[{key:"Tab",run:PB,shift:kB},{key:"Escape",run:wB}],gP=Ne.define({combine(t){return t.length?t[0]:xB}}),_B=Zo.highest(gf.compute([gP],t=>t.facet(gP)));function Nn(t,e){return Object.assign(Object.assign({},e),{apply:SB(t)})}const $B=Ae.domEventHandlers({mousedown(t,e){let r=e.state.field(Kc,!1),n;if(!r||(n=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let i=r.ranges.find(o=>o.from<=n&&o.to>=n);return!i||i.field==r.active?!1:(e.dispatch({selection:u1(r.ranges,i.field),effects:kf.of(r.ranges.some(o=>o.field>i.field)?new uu(r.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Jc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ca=yt.define({map(t,e){let r=e.mapPos(t,-1,Yr.TrackAfter);return r??void 0}}),c1=new class extends wa{};c1.startSide=1;c1.endSide=-1;const NT=Kr.define({create(){return qt.empty},update(t,e){if(t=t.map(e.changes),e.selection){let r=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:n=>n>=r.from&&n<=r.to})}for(let r of e.effects)r.is(ca)&&(t=t.update({add:[c1.range(r.value,r.value+1)]}));return t}});function QB(){return[CB,NT]}const Dg="()[]{}<>";function IT(t){for(let e=0;e<Dg.length;e+=2)if(Dg.charCodeAt(e)==t)return Dg.charAt(e+1);return x0(t<128?t:t+1)}function WT(t,e){return t.languageDataAt("closeBrackets",e)[0]||Jc}const EB=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),CB=Ae.inputHandler.of((t,e,r,n)=>{if((EB?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(n.length>2||n.length==2&&di(ln(n,0))==1||e!=i.from||r!=i.to)return!1;let o=RB(t.state,n);return o?(t.dispatch(o),!0):!1}),TB=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=WT(t,t.selection.main.head).brackets||Jc.brackets,i=null,o=t.changeByRange(s=>{if(s.empty){let a=AB(t.doc,s.head);for(let l of n)if(l==a&&CO(t.doc,s.head)==IT(ln(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:le.cursor(s.head-l.length)}}return{range:i=s}});return i||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!i};function RB(t,e){let r=WT(t,t.selection.main.head),n=r.brackets||Jc.brackets;for(let i of n){let o=IT(ln(i,0));if(e==i)return o==i?DB(t,i,n.indexOf(i+i+i)>-1,r):jB(t,i,o,r.before||Jc.before);if(e==o&&BT(t,t.selection.main.from))return MB(t,i,o)}return null}function BT(t,e){let r=!1;return t.field(NT).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function CO(t,e){let r=t.sliceString(e,e+2);return r.slice(0,di(ln(r,0)))}function AB(t,e){let r=t.sliceString(e-2,e);return di(ln(r,0))==r.length?r:r.slice(1)}function jB(t,e,r,n){let i=null,o=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:r,from:s.to}],effects:ca.of(s.to+e.length),range:le.range(s.anchor+e.length,s.head+e.length)};let a=CO(t.doc,s.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+r,from:s.head},effects:ca.of(s.head+e.length),range:le.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function MB(t,e,r){let n=null,i=t.changeByRange(o=>o.empty&&CO(t.doc,o.head)==r?{changes:{from:o.head,to:o.head+r.length,insert:r},range:le.cursor(o.head+r.length)}:n={range:o});return n?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function DB(t,e,r,n){let i=n.stringPrefixes||Jc.stringPrefixes,o=null,s=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:ca.of(a.to+e.length),range:le.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=CO(t.doc,l),u;if(c==e){if(mP(t,l))return{changes:{insert:e+e,from:l},effects:ca.of(l+e.length),range:le.cursor(l+e.length)};if(BT(t,l)){let h=r&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:le.cursor(l+h.length)}}}else{if(r&&t.sliceDoc(l-2*e.length,l)==e+e&&(u=yP(t,l-2*e.length,i))>-1&&mP(t,u))return{changes:{insert:e+e+e+e,from:l},effects:ca.of(l+e.length),range:le.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=Sr.Word&&yP(t,l,i)>-1&&!qB(t,l,e,i))return{changes:{insert:e+e,from:l},effects:ca.of(l+e.length),range:le.cursor(l+e.length)}}return{range:o=a}});return o?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function mP(t,e){let r=Qr(t).resolveInner(e+1);return r.parent&&r.from==e}function qB(t,e,r,n){let i=Qr(t).resolveInner(e,-1),o=n.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=t.sliceDoc(i.from,Math.min(i.to,i.from+r.length+o)),l=a.indexOf(r);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>r.length+l;){if(t.sliceDoc(u.to-r.length,u.to)==r)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function yP(t,e,r){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=Sr.Word)return e;for(let i of r){let o=e-i.length;if(t.sliceDoc(o,e)==i&&n(t.sliceDoc(o-1,o))!=Sr.Word)return o}return-1}function LT(t={}){return[gB,Wn,cn.of(t),pB,NB,qT]}const ZB=[{key:"Ctrl-Space",run:MT},{key:"Escape",run:DT},{key:"ArrowDown",run:ls(!0)},{key:"ArrowUp",run:ls(!1)},{key:"PageDown",run:ls(!0,"page")},{key:"PageUp",run:ls(!1,"page")},{key:"Enter",run:Jy}],NB=Zo.highest(gf.computeN([cn],t=>t.facet(cn).defaultKeymap?[ZB]:[]));class IB{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}}class ra{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=e,o=n.facet(fa).markerFilter;o&&(i=o(i,n));let s=Ye.set(i.map(a=>a.from==a.to||a.from==a.to-1&&n.doc.lineAt(a.from).to==a.from?Ye.widget({widget:new GB(a),diagnostic:a}).range(a.from):Ye.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new ra(s,r,Hl(s))}}function Hl(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostic!=e))return n=new IB(i,o,s.diagnostic),!1}),n}function WB(t,e){let r=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(n=>n.is(f1))||t.changes.touchesRange(r.from,r.to))}function VT(t,e){return t.field(ti,!1)?e:e.concat(yt.appendConfig.of(YT))}function BB(t,e){return{effects:VT(t,[f1.of(e)])}}const f1=yt.define(),h1=yt.define(),XT=yt.define(),ti=Kr.define({create(){return new ra(Ye.none,null,null)},update(t,e){if(e.docChanged){let r=t.diagnostics.map(e.changes),n=null;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);n=Hl(r,t.selected.diagnostic,i)||Hl(r,null,i)}t=new ra(r,t.panel,n)}for(let r of e.effects)r.is(f1)?t=ra.init(r.value,t.panel,e.state):r.is(h1)?t=new ra(t.diagnostics,r.value?TO.open:null,t.selected):r.is(XT)&&(t=new ra(t.diagnostics,t.panel,r.value));return t},provide:t=>[Uc.from(t,e=>e.panel),Ae.decorations.from(t,e=>e.diagnostics)]}),LB=Ye.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function VB(t,e,r){let{diagnostics:n}=t.state.field(ti),i=[],o=2e8,s=0;n.between(e-(r<0?1:0),e+(r>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||r>0)&&(e<c||r<0))&&(i.push(u.diagnostic),o=Math.min(l,o),s=Math.max(c,s))});let a=t.state.facet(fa).tooltipFilter;return a&&(i=a(i,t.state)),i.length?{pos:o,end:s,above:t.state.doc.lineAt(o).to<s,create(){return{dom:XB(t,i)}}}:null}function XB(t,e){return ir("ul",{class:"cm-tooltip-lint"},e.map(r=>FT(t,r,!1)))}const UB=t=>{let e=t.state.field(ti,!1);(!e||!e.panel)&&t.dispatch({effects:VT(t.state,[h1.of(!0)])});let r=Xc(t,TO.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},vP=t=>{let e=t.state.field(ti,!1);return!e||!e.panel?!1:(t.dispatch({effects:h1.of(!1)}),!0)},FB=t=>{let e=t.state.field(ti,!1);if(!e)return!1;let r=t.state.selection.main,n=e.diagnostics.iter(r.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},YB=ar.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(fa);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:r}=e.facet(fa);r.length&&Promise.all(r.map(n=>Promise.resolve(n(this.view)))).then(n=>{let i=n.reduce((o,s)=>o.concat(s));this.view.state.doc==e.doc&&this.view.dispatch(BB(this.view.state,i))},n=>{Tn(this.view.state,n)})}}update(t){let e=t.state.facet(fa);(t.docChanged||e!=t.startState.facet(fa)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),fa=Ne.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},Li(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r}))}});function zB(t,e={}){return[fa.of({source:t,config:e}),YB,YT]}function UT(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let i=r[n];if(/[a-zA-Z]/.test(i)&&!e.some(o=>o.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function FT(t,e,r){var n;let i=r?UT(e.actions):[];return ir("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ir("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(n=e.actions)===null||n===void 0?void 0:n.map((o,s)=>{let a=!1,l=h=>{if(h.preventDefault(),a)return;a=!0;let d=Hl(t.state.field(ti).diagnostics,e);d&&o.apply(t,d.from,d.to)},{name:c}=o,u=i[s]?c.indexOf(i[s]):-1,f=u<0?c:[c.slice(0,u),ir("u",c.slice(u,u+1)),c.slice(u+1)];return ir("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[s]})"`}.`},f)}),e.source&&ir("div",{class:"cm-diagnosticSource"},e.source))}class GB extends ki{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ir("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class bP{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=FT(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class TO{constructor(e){this.view=e,this.items=[];let r=i=>{if(i.keyCode==27)vP(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=UT(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=Hl(this.view.state.field(ti).diagnostics,o);l&&o.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},n=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=ir("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=ir("div",{class:"cm-panel-lint"},this.list,ir("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>vP(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ti).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(ti),n=0,i=!1,o=null;for(e.between(0,this.view.state.doc.length,(s,a,{spec:l})=>{let c=-1,u;for(let f=n;f<this.items.length;f++)if(this.items[f].diagnostic==l.diagnostic){c=f;break}c<0?(u=new bP(this.view,l.diagnostic),this.items.splice(n,0,u),i=!0):(u=this.items[c],c>n&&(this.items.splice(n,c-n),i=!0)),r&&u.diagnostic==r.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),o=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new bP(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:a})=>{let l=a.height/this.list.offsetHeight;s.top<a.top?this.list.scrollTop-=(a.top-s.top)/l:s.bottom>a.bottom&&(this.list.scrollTop+=(s.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(ti),n=Hl(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:XT.of(n)})}static open(e){return new TO(e)}}function HB(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function bh(t){return HB(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const KB=Ae.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:bh("#d11")},".cm-lintRange-warning":{backgroundImage:bh("orange")},".cm-lintRange-info":{backgroundImage:bh("#999")},".cm-lintRange-hint":{backgroundImage:bh("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),YT=[ti,Ae.decorations.compute([ti],t=>{let{selected:e,panel:r}=t.field(ti);return!e||!r||e.from==e.to?Ye.none:Ye.set([LB.range(e.from,e.to)])}),PZ(VB,{hideOn:WB}),KB],SP="500",JB={background:Cw,foreground:HC,caret:AI,selection:CI,selectionMatch:TI,lineHighlight:RI,gutterBackground:Cw,gutterForeground:QI,gutterActiveForeground:EI};function e7(t){const{theme:e="dark",settings:r={},styles:n=[]}=t||{};return[xi({theme:e,settings:{...JB,...r},styles:[{tag:[S.keyword,S.operatorKeyword,S.modifier,S.color,S.constant(S.name),S.standard(S.name),S.standard(S.tagName),S.special(S.brace),S.atom,S.bool,S.special(S.variableName)],color:Tw},{tag:[S.controlKeyword,S.moduleKeyword],color:Tw},{tag:[S.name,S.deleted,S.character,S.macroName,S.variableName,S.labelName,S.definition(S.name)],color:Ru},{tag:[S.propertyName],color:Aw},{tag:S.heading,fontWeight:SP,color:jI},{tag:[S.typeName,S.className,S.tagName,S.number,S.changed,S.annotation,S.self,S.namespace],color:Ru},{tag:[S.function(S.variableName),S.function(S.propertyName)],color:Ru},{tag:[S.number],color:MI},{tag:[S.operator,S.punctuation,S.separator,S.url,S.escape,S.regexp],color:HC},{tag:[S.regexp],color:Rw},{tag:[S.special(S.string),S.string,S.inserted],color:Rw},{tag:[S.processingInstruction],color:Ru},{tag:[S.angleBracket],color:Ru},{tag:S.strong,fontWeight:SP},{tag:S.emphasis,fontStyle:"italic"},{tag:S.strikethrough,textDecoration:"line-through"},{tag:[S.meta,S.comment],color:$I},{tag:S.link,color:Aw,textDecoration:"underline"},{tag:S.invalid,color:DI},...n]}),Ae.theme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"transparent",outline:"1px solid #888888"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"transparent",outline:"1px solid #ff2222"}},{dark:!0})]}const t7=e7(),zT=[{value:nI,label:"abcdef"},{value:sI,label:"dracula"},{value:uI,label:"eclipse"},{value:gI,label:"material"},{value:SI,label:"nord"},{value:HN,label:"oneDark"},{value:eI,label:"okaidia"},{value:pI,label:"github"},{value:kI,label:"xcode"},{value:t7,label:"vizhub"}],GT=zT.reduce((t,e)=>(t[e.label]=e,t),{}),r7="vizhub",n7=(t,e)=>{const r=N.useRef(!0);N.useEffect(()=>{if(r.current)r.current=!1;else for(const n of Array.from(t.values())){const{editor:i,themeCompartment:o}=n;i.dispatch({effects:o.reconfigure([GT[e].value])})}},[e,t])},i7=t=>{const e=N.useCallback(d=>{t({type:"set_active_file_id",activeFileId:d})},[t]),r=N.useCallback(()=>{t({type:"set_active_file_left"})},[t]),n=N.useCallback(()=>{t({type:"set_active_file_right"})},[t]),i=N.useCallback(d=>{t({type:"open_tab",fileId:d.fileId,isTransient:d.isTransient})},[t]),o=N.useCallback(d=>{t({type:"close_tabs",fileIdsToClose:d})},[t]),s=N.useCallback(d=>{t({type:"set_theme",themeLabel:d})},[t]),a=N.useCallback(d=>{t({type:"set_is_settings_open",value:d})},[t]),l=N.useCallback(d=>{t({type:"set_is_doc_open",value:d})},[t]),c=N.useCallback(()=>{a(!1)},[a]),u=N.useCallback(()=>{l(!1)},[l]),f=N.useCallback(()=>{t({type:"editor_no_longer_wants_focus"})},[t]),h=N.useCallback(d=>{t({type:"set_username",username:d})},[t]);return{setActiveFileId:e,setActiveFileLeft:r,setActiveFileRight:n,openTab:i,closeTabs:o,setTheme:s,setIsSettingsOpen:a,setIsDocOpen:l,closeSettings:c,closeDoc:u,editorNoLongerWantsFocus:f,setUsername:h}},o7=()=>{const[t,e]=N.useState(new Set),r=N.useCallback(i=>t.has(i),[t]),n=N.useCallback(i=>{const o=new Set(t);r(i)?o.delete(i):o.add(i),e(o)},[t,r]);return{isDirectoryOpen:r,toggleDirectory:n}},s7=8,ev=()=>{let t="";for(let e=0;e<s7;e++)t+=Math.floor(Math.random()*10);return t},a7=({submitOperation:t,closeTabs:e,openTab:r})=>{const n=N.useCallback((c,u="")=>{if(c){const f=ev();t(h=>({...h,files:{...h.files,[f]:{name:c,text:u}}})),r({fileId:f,isTransient:!1})}},[t]),i=N.useCallback((c,u=null)=>{if(c){c+="/";const f=ev();t(h=>({...h,files:{...h.files,[f]:{name:c,text:u}}}))}},[t]),o=N.useCallback((c,u)=>{t(f=>({...f,files:{...f.files,[c]:{...f.files[c],name:f.files[c].name.substring(0,f.files[c].name.lastIndexOf("/")+1)+u}}}))},[t]),s=N.useCallback((c,u,f)=>{console.log(c),console.log(u),t(h=>{const d=Object.keys(h.files).reduce((p,O)=>{const m=h.files[O],y=m.name;if(y.includes(c+"/")){const v=y.substring(0,y.indexOf(c)+c.length).lastIndexOf(u),b=y.substring(0,v)+f+y.substring(v+u.length);p[O]={...m,name:b}}else p[O]=m;return p},{});return{...h,files:d}})},[t]),a=N.useCallback(c=>{e([c]),t(u=>{const f={...u.files};return delete f[c],{...u,files:f}})},[t,e]),l=N.useCallback(c=>{const u=[];t(f=>{const h={...f.files};for(const d in h)h[d].name.includes(c+"/")&&(u.push(d),delete h[d]);return{...f,files:h}}),e(u)},[t,e]);return{createFile:n,renameFile:o,deleteFile:a,createDirectory:i,renameDirectory:s,deleteDirectory:l}},l7=()=>N.useRef(new Map).current;/**
88
- * @remix-run/router v1.16.0
88
+ * @remix-run/router v1.16.1
89
89
  *
90
90
  * Copyright (c) Remix Software Inc.
91
91
  *
@@ -94,7 +94,7 @@ Source:
94
94
  *
95
95
  * @license MIT
96
96
  */function ef(){return ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ef.apply(this,arguments)}var ha;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(ha||(ha={}));const wP="popstate";function u7(t){t===void 0&&(t={});function e(n,i){let{pathname:o,search:s,hash:a}=n.location;return tv("",{pathname:o,search:s,hash:a},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function r(n,i){return typeof i=="string"?i:HT(i)}return f7(e,r,null,t)}function po(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function c7(){return Math.random().toString(36).substr(2,8)}function PP(t,e){return{usr:t.state,key:t.key,idx:e}}function tv(t,e,r,n){return r===void 0&&(r=null),ef({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?RO(e):e,{state:r,key:e&&e.key||n||c7()})}function HT(t){let{pathname:e="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function RO(t){let e={};if(t){let r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function f7(t,e,r,n){n===void 0&&(n={});let{window:i=document.defaultView,v5Compat:o=!1}=n,s=i.history,a=ha.Pop,l=null,c=u();c==null&&(c=0,s.replaceState(ef({},s.state,{idx:c}),""));function u(){return(s.state||{idx:null}).idx}function f(){a=ha.Pop;let m=u(),y=m==null?null:m-c;c=m,l&&l({action:a,location:O.location,delta:y})}function h(m,y){a=ha.Push;let g=tv(O.location,m,y);r&&r(g,m),c=u()+1;let v=PP(g,c),b=O.createHref(g);try{s.pushState(v,"",b)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;i.location.assign(b)}o&&l&&l({action:a,location:O.location,delta:1})}function d(m,y){a=ha.Replace;let g=tv(O.location,m,y);r&&r(g,m),c=u();let v=PP(g,c),b=O.createHref(g);s.replaceState(v,"",b),o&&l&&l({action:a,location:O.location,delta:0})}function p(m){let y=i.location.origin!=="null"?i.location.origin:i.location.href,g=typeof m=="string"?m:HT(m);return g=g.replace(/ $/,"%20"),po(y,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,y)}let O={get action(){return a},get location(){return t(i,s)},listen(m){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(wP,f),l=m,()=>{i.removeEventListener(wP,f),l=null}},createHref(m){return e(i,m)},createURL:p,encodeLocation(m){let y=p(m);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:h,replace:d,go(m){return s.go(m)}};return O}var kP;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(kP||(kP={}));function h7(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let r=e.endsWith("/")?e.length-1:e.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function d7(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:i=""}=typeof t=="string"?RO(t):t;return{pathname:r?r.startsWith("/")?r:p7(r,e):e,search:v7(n),hash:b7(i)}}function p7(t,e){let r=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?r.length>1&&r.pop():i!=="."&&r.push(i)}),r.length>1?r.join("/"):"/"}function qg(t,e,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function O7(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function g7(t,e){let r=O7(t);return e?r.map((n,i)=>i===t.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function m7(t,e,r,n){n===void 0&&(n=!1);let i;typeof t=="string"?i=RO(t):(i=ef({},t),po(!i.pathname||!i.pathname.includes("?"),qg("?","pathname","search",i)),po(!i.pathname||!i.pathname.includes("#"),qg("#","pathname","hash",i)),po(!i.search||!i.search.includes("#"),qg("#","search","hash",i)));let o=t===""||i.pathname==="",s=o?"/":i.pathname,a;if(s==null)a=r;else{let f=e.length-1;if(!n&&s.startsWith("..")){let h=s.split("/");for(;h[0]==="..";)h.shift(),f-=1;i.pathname=h.join("/")}a=f>=0?e[f]:"/"}let l=d7(i,a),c=s&&s!=="/"&&s.endsWith("/"),u=(o||s===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}const y7=t=>t.join("/").replace(/\/\/+/g,"/"),v7=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,b7=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,KT=["post","put","patch","delete"];new Set(KT);const S7=["get",...KT];new Set(S7);/**
97
- * React Router v6.23.0
97
+ * React Router v6.23.1
98
98
  *
99
99
  * Copyright (c) Remix Software Inc.
100
100
  *
@@ -103,7 +103,7 @@ Source:
103
103
  *
104
104
  * @license MIT
105
105
  */function Ip(){return Ip=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Ip.apply(this,arguments)}const JT=N.createContext(null),d1=N.createContext(null),p1=N.createContext(null),O1=N.createContext({outlet:null,matches:[],isDataRoute:!1});function g1(){return N.useContext(p1)!=null}function eR(){return g1()||po(!1),N.useContext(p1).location}function tR(t){N.useContext(d1).static||N.useLayoutEffect(t)}function w7(){let{isDataRoute:t}=N.useContext(O1);return t?$7():P7()}function P7(){g1()||po(!1);let t=N.useContext(JT),{basename:e,future:r,navigator:n}=N.useContext(d1),{matches:i}=N.useContext(O1),{pathname:o}=eR(),s=JSON.stringify(g7(i,r.v7_relativeSplatPath)),a=N.useRef(!1);return tR(()=>{a.current=!0}),N.useCallback(function(c,u){if(u===void 0&&(u={}),!a.current)return;if(typeof c=="number"){n.go(c);return}let f=m7(c,JSON.parse(s),o,u.relative==="path");t==null&&e!=="/"&&(f.pathname=f.pathname==="/"?e:y7([e,f.pathname])),(u.replace?n.replace:n.push)(f,u.state,u)},[e,n,s,o,t])}var rR=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(rR||{}),nR=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(nR||{});function k7(t){let e=N.useContext(JT);return e||po(!1),e}function x7(t){let e=N.useContext(O1);return e||po(!1),e}function _7(t){let e=x7(),r=e.matches[e.matches.length-1];return r.route.id||po(!1),r.route.id}function $7(){let{router:t}=k7(rR.UseNavigateStable),e=_7(nR.UseNavigateStable),r=N.useRef(!1);return tR(()=>{r.current=!0}),N.useCallback(function(i,o){o===void 0&&(o={}),r.current&&(typeof i=="number"?t.navigate(i):t.navigate(i,Ip({fromRouteId:e},o)))},[t,e])}function Q7(t){let{basename:e="/",children:r=null,location:n,navigationType:i=ha.Pop,navigator:o,static:s=!1,future:a}=t;g1()&&po(!1);let l=e.replace(/^\/*/,"/"),c=N.useMemo(()=>({basename:l,navigator:o,static:s,future:Ip({v7_relativeSplatPath:!1},a)}),[l,a,o,s]);typeof n=="string"&&(n=RO(n));let{pathname:u="/",search:f="",hash:h="",state:d=null,key:p="default"}=n,O=N.useMemo(()=>{let m=h7(u,l);return m==null?null:{location:{pathname:m,search:f,hash:h,state:d,key:p},navigationType:i}},[l,u,f,h,d,p,i]);return O==null?null:N.createElement(d1.Provider,{value:c},N.createElement(p1.Provider,{children:r,value:O}))}new Promise(()=>{});/**
106
- * React Router DOM v6.23.0
106
+ * React Router DOM v6.23.1
107
107
  *
108
108
  * Copyright (c) Remix Software Inc.
109
109
  *
package/dist/index.html CHANGED
@@ -20,7 +20,7 @@
20
20
  href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
21
21
  rel="stylesheet"
22
22
  />
23
- <script type="module" crossorigin src="/assets/index-DacyImKg.js"></script>
23
+ <script type="module" crossorigin src="/assets/index-BPHulZpL.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/assets/index-CWMOj-be.css">
25
25
  </head>
26
26
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -103,15 +103,15 @@
103
103
  "@replit/codemirror-vscode-keymap": "^6.0.2",
104
104
  "@teamwork/websocket-json-stream": "^2.0.0",
105
105
  "@typescript/vfs": "^1.5.0",
106
- "@uiw/codemirror-theme-abcdef": "^4.22.0",
107
- "@uiw/codemirror-theme-dracula": "^4.22.0",
108
- "@uiw/codemirror-theme-eclipse": "^4.22.0",
109
- "@uiw/codemirror-theme-github": "^4.22.0",
110
- "@uiw/codemirror-theme-material": "^4.22.0",
111
- "@uiw/codemirror-theme-nord": "^4.22.0",
112
- "@uiw/codemirror-theme-okaidia": "^4.22.0",
113
- "@uiw/codemirror-theme-xcode": "^4.22.0",
114
- "@uiw/codemirror-themes": "^4.22.0",
106
+ "@uiw/codemirror-theme-abcdef": "^4.22.1",
107
+ "@uiw/codemirror-theme-dracula": "^4.22.1",
108
+ "@uiw/codemirror-theme-eclipse": "^4.22.1",
109
+ "@uiw/codemirror-theme-github": "^4.22.1",
110
+ "@uiw/codemirror-theme-material": "^4.22.1",
111
+ "@uiw/codemirror-theme-nord": "^4.22.1",
112
+ "@uiw/codemirror-theme-okaidia": "^4.22.1",
113
+ "@uiw/codemirror-theme-xcode": "^4.22.1",
114
+ "@uiw/codemirror-themes": "^4.22.1",
115
115
  "body-parser": "^1.20.2",
116
116
  "codemirror": "^6.0.1",
117
117
  "codemirror-ot": "^4.4.0",
@@ -124,26 +124,26 @@
124
124
  "json0-ot-diff": "^1.1.2",
125
125
  "ngrok": "^4.3.3",
126
126
  "open": "^10.1.0",
127
- "openai": "^4.40.0",
127
+ "openai": "^4.47.1",
128
128
  "prettier-plugin-svelte": "^3.2.3",
129
129
  "react": "^18.3.1",
130
130
  "react-bootstrap": "^2.10.2",
131
131
  "react-dom": "^18.3.1",
132
- "react-router-dom": "^6.23.0",
133
- "sharedb": "^4.1.4",
134
- "sharedb-client-browser": "^4.5.0",
132
+ "react-router-dom": "^6.23.1",
133
+ "sharedb": "^5.0.0",
134
+ "sharedb-client-browser": "^5.0.1",
135
135
  "vizhub-ui": "^3.23.0",
136
136
  "ws": "^8.17.0"
137
137
  },
138
138
  "devDependencies": {
139
- "@types/react": "^18.3.1",
139
+ "@types/react": "^18.3.3",
140
140
  "@types/react-dom": "^18.3.0",
141
- "@vitejs/plugin-react": "^4.2.1",
141
+ "@vitejs/plugin-react": "^4.3.0",
142
142
  "concurrently": "^8.2.2",
143
143
  "prettier": "^3.2.5",
144
- "sass": "^1.76.0",
144
+ "sass": "^1.77.2",
145
145
  "typescript": "^5.4.5",
146
- "vite": "^5.2.10",
147
- "vitest": "^1.5.3"
146
+ "vite": "^5.2.11",
147
+ "vitest": "^1.6.0"
148
148
  }
149
149
  }