\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},n9),re={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},rt=tF.ie&&tF.ie_version<=11;class ri{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new tO,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(tF.ie&&tF.ie_version<=11||tF.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&!1!==e.constructor.EDIT_CONTEXT&&!(tF.chrome&&tF.chrome_version<126)&&(this.editContext=new rs(e),e.state.facet(iX)&&(e.contentDOM.editContext=this.editContext.editContext)),rt&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(iX)?i.root.activeElement!=this.dom:!to(this.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(tF.ie&&tF.ie_version<=11||tF.android&&tF.chrome)&&!i.state.selection.main.empty&&n.focusNode&&tl(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=tr(e.root);if(!t)return!1;let i=tF.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return rr(e,i)}let i=null;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",n,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",n,!0),i?rr(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=to(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&tx(this.dom,e.key,e.keyCode))})),this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(n=!0),-1==t?{from:t,to:i}=e:(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&to(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new nn(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=nr(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let i=rn(t,e.previousSibling||e.target.previousSibling,-1),n=rn(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(iX)!=e.state.facet(iX)&&(e.view.contentDOM.editContext=e.state.facet(iX)?this.editContext.editContext:null))}destroy(){var e,t,i;for(let n of(this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),this.scrollTargets))n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function rn(e,t,i){for(;t;){let n=tA.get(t);if(n&&n.parent==e)return n;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}function rr(e,t){let i=t.startContainer,n=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return tl(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}class rs{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});for(let i in this.handlers.textupdate=t=>{let i=e.state.selection.main,{anchor:n,head:r}=i,s=this.toEditorPos(t.updateRangeStart),o=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:s,drifted:!1});let a={from:s,to:o,insert:O.of(t.text.split("\n"))};if(a.from==this.from&&nthis.to&&(a.to=n),a.from==a.to&&!a.insert.length){let n=K.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));n.main.eq(i)||e.dispatch({selection:n,userEvent:"select"});return}if((tF.mac||tF.android)&&a.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(a={from:s,to:o,insert:O.of([t.text.replace("."," ")])}),this.pendingContextChange=a,!e.state.readOnly){let i=this.to-this.from+(a.to-a.from+a.insert.length);ns(e,a,K.single(this.toEditorPos(t.selectionStart,i),this.toEditorPos(t.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let t=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);t{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,n=e.underlineThickness;if("None"!=t&&"None"!=n){let r=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(r{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}},this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=tr(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,s,o,a,l)=>{if(i)return;let h=l.length-(s-r);if(n&&s>=n.to){if(n.from==r&&n.to==s&&n.insert.eq(l)){n=this.pendingContextChange=null,t+=h,this.to+=h;return}n=null,this.revertPending(e.state)}if(r+=t,(s+=t)<=this.from)this.from+=h,this.to+=h;else if(rthis.to||this.to-this.from+l.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),l.toString()),this.to+=h}t+=h}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ro{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||i&&(e=>e.forEach(e=>i(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new nN(e.state||eD.create(e)),e.scrollTo&&e.scrollTo.is(iT)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(iB).map(e=>new iL(e)),this.plugins))t.update(this);this.observer=new ri(this),this.inputState=new no(this),this.inputState.ensureHandlers(this.plugins),this.docView=new iJ(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=1==e.length&&e[0]instanceof eP?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let t of e){if(t.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,a=null;e.some(e=>e.annotation(nC))?(this.inputState.notifiedFocused=s,o=1):s==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=s,(a=nP(r,s))||(o=1));let l=this.observer.delayedAndroidKey,h=null;if(l?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(eD.phrases)!=this.state.facet(eD.phrases))return this.setState(r);n=iH.create(this,r,e),n.flags|=o;let u=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;u=new iE(e.empty?e:K.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(iT)&&(u=e.value.clip(this.state))}this.viewState.update(n,u),this.bidiCache=rh.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(iN)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(n2)!=n.state.facet(n2)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let e of this.state.facet(ik))try{e(n)}catch(e){iM(this.state,e,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!nr(this,h)&&l.force&&tx(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);for(let t of(this.viewState=new nN(e),this.plugins=e.facet(iB).map(e=>new iL(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new iJ(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(iB),i=e.state.facet(iB);if(t!=i){let n=[];for(let r of i){let i=t.indexOf(r);if(i<0)n.push(new iL(r));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0){if(ty(i))r=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(n);r=e.from,s=e.top}}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return iM(this.state,e),rl}}),h=iH.create(this,this.state,[]),u=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(u=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e1||e<-1){n+=e,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ik))e(t)}get themeClasses(){return n3+" "+(this.state.facet(n5)?n7:n4)+" "+this.state.facet(n2)}updateAttrs(){let e=ru(this,iV,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(iX)?"true":"false",class:"cm-content",style:`${tF.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),ru(this,i_,t);let i=this.observer.ignore(()=>{let i=tJ(this.contentDOM,this.contentAttrs,t),n=tJ(this.dom,this.editorAttrs,e);return i||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)e.is(ro.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(iN);let e=this.state.facet(ro.cspNonce);e4.mount(this.root,this.styleModules.concat(n8).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;tt.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ne(this,e,i6(this,e,t,i))}moveByGroup(e,t){return ne(this,e,i6(this,e,t,t=>{var i;let n,r;return i=e.head,r=(n=this.state.charCategorizer(i))(t),e=>{let t=n(e);return r==eM.Space&&(r=t),r==t}}))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return K.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let r=i9(e,t.head),s=n&&r.type==t0.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),n=e.textDirectionAt(r.from),o=e.posAtCoords({x:i==(n==ir.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return K.cursor(o,i?-1:1)}return K.cursor(i?r.to:r.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return ne(this,e,function(e,t,i,n){let r=t.head,s=i?1:-1;if(r==(i?e.state.doc.length:0))return K.cursor(r,t.assoc);let o=t.goalColumn,a,l=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r,t.assoc||-1),u=e.documentTop;if(h)null==o&&(o=h.left-l.left),a=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==o&&(o=Math.min(l.right-l.left,e.defaultCharacterWidth*(r-t.from))),a=(s<0?t.top:t.bottom)+u}let c=l.left+o,d=null!=n?n:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let i=a+(d+t)*s,n=i4(e,{x:c,y:i},!1,s);if(il.bottom||(s<0?nr)){let t=e.docView.coordsForChar(n),r=!t||i0)}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(iC)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ra)return ig(e.length);let t=this.textDirectionAt(e.from),i;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==t&&(n.fresh||function e(t,i){if(t.length!=i.length)return!1;for(let n=0;nim.length;)im[im.length]=256;let n=[],r=+(t!=is);return function e(t,i,n,r,s,o,a){let l=i%2?2:1;!function(e,t,i,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:t,a=s=0;e-=3)if(ic[e+1]==-n){let i=ic[e+2],n=2&i?r:4&i?1&i?s:r:0;n&&(im[t]=im[ic[e]]=n),a=e;break}}else if(189==ic.length)break;else ic[a++]=t,ic[a++]=i,ic[a++]=l}else if(2==(o=im[t])||1==o){let e=o==r;l=+!e;for(let t=a-3;t>=0;t-=3){let i=ic[t+2];if(2&i)break;if(e)ic[t+2]|=2;else{if(4&i)break;ic[t+2]|=4}}}}}(t,s,o,r,l),function(e,t,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:e,a=rl;)t==s&&(t=i[--n].from,s=n?i[n-1].to:e),im[--t]=u;l=o}else s=o,l++}}}(s,o,r,l),function t(i,n,r,s,o,a,l){let h=s%2?2:1;if(s%2==o%2)for(let u=n,c=0;uu&&l.push(new iO(u,t.from,p)),e(i,t.direction==is!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,l),u=t.to),O=t.to}else if(O==r||(n?im[O]!=h:im[O]==h))break;else O++;f?t(i,u,O,s+1,o,f,l):un;){let r=!0,d=!1;if(!c||u>a[c-1].to){let e=im[u-1];e!=h&&(r=!1,d=16==e)}let f=r||1!=h?null:[],p=r?s:s+1,O=u;t:for(;;)if(c&&O==a[c-1].to){if(d)break;let t=a[--c];if(!r)for(let e=t.from,i=c;;){if(e==n)break t;if(i&&a[i-1].to==e)e=a[--i].from;else if(im[e-1]==h)break t;else break}f?f.push(t):(t.toDate.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{tg(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return iT.of(new iE("number"==typeof e?K.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return iT.of(new iE(K.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return iq.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return iq.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=e4.newName(),n=[n2.of(i),iN.of(n6(`.${i}`,e))];return t&&t.dark&&n.push(n5.of(!0)),n}static baseTheme(e){return ec.lowest(iN.of(n6("."+n3,e,n9)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&tA.get(i)||tA.get(e);return(null===(t=null==n?void 0:n.rootView)||void 0===t?void 0:t.view)||null}}ro.styleModule=iN,ro.inputHandler=iS,ro.clipboardInputFilter=iA,ro.clipboardOutputFilter=i$,ro.scrollHandler=iZ,ro.focusChangeEffect=iQ,ro.perLineTextDirection=iC,ro.exceptionSink=iw,ro.updateListener=ik,ro.editable=iX,ro.mouseSelectionStyle=iy,ro.dragMovesSelection=iv,ro.clickAddsSelectionRange=ix,ro.decorations=iF,ro.outerDecorations=iW,ro.atomicRanges=ij,ro.bidiIsolatedRanges=iz,ro.scrollMargins=iI,ro.darkTheme=n5,ro.cspNonce=ei.define({combine:e=>e.length?e[0]:""}),ro.contentAttributes=i_,ro.editorAttributes=iV,ro.lineWrapping=ro.contentAttributes.of({class:"cm-lineWrapping"}),ro.announce=eC.define();const ra=4096,rl={};class rh{constructor(e,t,i,n,r,s){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:ir.LTR;for(let r=Math.max(0,e.length-10);r=0;r--){let t=n[r],s="function"==typeof t?t(e):t;s&&tN(s,i)}return i}const rc=tF.mac?"mac":tF.windows?"win":tF.linux?"linux":"key";function rd(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}const rf=ec.default(ro.domEventHandlers({keydown:(e,t)=>rx(rm(t.state),e,t,"editor")})),rp=ei.define({enables:rf}),rO=new WeakMap;function rm(e){let t=e.facet(rp),i=rO.get(t);return i||rO.set(t,i=function(e,t=rc){let i=Object.create(null),n=Object.create(null),r=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,n,s,o,a)=>{var l,h;let u=i[e]||(i[e]=Object.create(null)),c=n.split(/ (?!$)/).map(e=>(function(e,t){let i,n,r,s;let o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(let e=0;e{let n=rg={view:t,prefix:i,scope:e};return setTimeout(()=>{rg==n&&(rg=null)},4e3),!0}]})}let d=c.join(" ");r(d,!1);let f=u[d]||(u[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(l=u._any)||void 0===l?void 0:l.run)||void 0===h?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let n of e){let e=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let t of e){let e=i[t]||(i[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=n;for(let t in e)e[t].run.push(e=>r(e,rb))}let r=n[t]||n.key;if(r)for(let t of e)s(t,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(t,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(t.reduce((e,t)=>e.concat(t),[]))),i}let rg=null,rb=null;function rx(e,t,i,n){var r;rb=t;let s=("Esc"==(r=!(te&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||tt&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?e8:e6)[t.keyCode]||t.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=$(Q(s,0))==s.length&&" "!=s,a="",l=!1,h=!1,u=!1;rg&&rg.view==i&&rg.scope==n&&(a=rg.prefix+" ",0>nu.indexOf(t.keyCode)&&(h=!0,rg=null));let c=new Set,d=e=>{if(e){for(let t of e.run)if(!c.has(t)&&(c.add(t),t(i)))return e.stopPropagation&&(u=!0),!0;e.preventDefault&&(e.stopPropagation&&(u=!0),h=!0)}return!1},f=e[n],p,O;return f&&(d(f[a+rd(s,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(tF.windows&&t.ctrlKey&&t.altKey)&&(p=e6[t.keyCode])&&p!=s?d(f[a+rd(p,t,!0)])?l=!0:t.shiftKey&&(O=e8[t.keyCode])!=s&&O!=p&&d(f[a+rd(O,t,!1)])&&(l=!0):o&&t.shiftKey&&d(f[a+rd(s,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),h&&(l=!0),l&&u&&t.stopPropagation(),rb=null,l}class rv{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(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,t,i){if(!i.empty)return function(e,t,i){if(i.to<=e.viewport.from||i.from>=e.viewport.to)return[];let n=Math.max(i.from,e.viewport.from),r=Math.min(i.to,e.viewport.to),s=e.textDirection==ir.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=ry(e),h=o.querySelector(".cm-line"),u=h&&window.getComputedStyle(h),c=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),f=i9(e,n),p=i9(e,r),O=f.type==t0.Text?f:null,m=p.type==t0.Text?p:null;if(O&&(e.lineWrapping||f.widgetLineBreaks)&&(O=rw(e,n,1,O)),m&&(e.lineWrapping||p.widgetLineBreaks)&&(m=rw(e,r,-1,m)),O&&m&&O.from==m.from&&O.to==m.to)return b(x(i.from,i.to,O));{let t=O?x(i.from,null,O):v(f,!1),n=m?x(null,i.to,m):v(p,!0),r=[];return(O||f).to<(m||p).from-(O&&m?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2h&&n.from=s)break;a>r&&l(Math.max(e,r),null==t&&e<=h,Math.min(a,s),null==i&&a>=u,o.dir)}if((r=n.to+1)>=s)break}return 0==a.length&&l(h,null==t,u,null==i,e.textDirection),{top:r,bottom:o,horizontal:a}}function v(e,t){let i=a.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(e,t,i);{let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=ry(e);return[new rv(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}}}function ry(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==ir.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function rw(e,t,i,n){let r=e.coordsAtPos(t,2*i);if(!r)return n;let s=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,a=e.posAtCoords({x:s.left+1,y:o}),l=e.posAtCoords({x:s.right-1,y:o});return null==a||null==l?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}class rk{constructor(e,t){this.view=e,this.layer=t,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"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(rS)!=e.state.facet(rS)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(rS);for(;t{var i;return i=this.drawn[t],!(e.constructor==i.constructor&&e.eq(i))})){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const rS=ei.define();function rQ(e){return[iq.define(t=>new rk(t,e)),rS.of(e)]}const rA=!(tF.ios&&tF.webkit&&tF.webkit_version<534),r$=ei.define({combine:e=>eB(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function rC(e){return e.startState.facet(r$)!=e.state.facet(r$)}const rP=rQ({above:!0,markers(e){let{state:t}=e,i=t.facet(r$),n=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty?!s||rA:i.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:K.cursor(r.head,r.head>r.anchor?-1:1);for(let r of rv.forRange(e,t,i))n.push(r)}}return n},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let i=rC(e);return i&&rZ(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){rZ(t.state,e)},class:"cm-cursorLayer"});function rZ(e,t){t.style.animationDuration=e.facet(r$).cursorBlinkRate+"ms"}const rE=rQ({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:rv.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||rC(e),class:"cm-selectionLayer"}),rT={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};rA&&(rT[".cm-line"].caretColor=rT[".cm-content"].caretColor="transparent !important");const rR=ec.highest(ro.theme(rT)),rM=eC.define({map:(e,t)=>null==e?null:t.mapPos(e)}),rX=el.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(rM)?t.value:e,e))}),rD=iq.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let i=e.state.field(rX);null==i?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(rX)!=i||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(rX),i=null!=t&&e.coordsAtPos(t);if(!i)return null;let n=e.scrollDOM.getBoundingClientRect();return{left:i.left-n.left+e.scrollDOM.scrollLeft*e.scaleX,top:i.top-n.top+e.scrollDOM.scrollTop*e.scaleY,height:i.bottom-i.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:i}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/i+"px",this.cursor.style.height=e.height/i+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(rX)!=e&&this.view.dispatch({effects:rM.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function rB(e,t,i,n,r){t.lastIndex=0;for(let s=e.iterRange(i,n),o=i,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=t.exec(s.value);)r(o+a.index,a)}class rq{constructor(e){let{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(e,t,i,r)=>n(r,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,n,r)=>{let s=i(e,t,n);s&&r(n,n+e[0].length,s)};else if(i)this.addMatch=(e,t,n,r)=>r(n,n+e[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}createDeco(e){let t=new eW,i=t.add.bind(t);for(let{from:t,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(e,this.maxLength))rB(e.state.doc,this.regexp,t,n,(t,n)=>this.addMatch(n,e,t,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return(e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>=e.view.viewport.from&&s<=e.view.viewport.to&&(i=Math.min(s,i),n=Math.max(o,n))}),e.viewportMoved||n-i>1e3)?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>s){let i=e.state.doc.lineAt(s),n=i.toi.from;s--)if(this.boundary.test(i.text[s-1-i.from])){a=s;break}for(;oh.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=a-i.from;(u=this.regexp.exec(i.text))&&u.indexthis.addMatch(i,e,t,c));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>el,add:h})}}return t}}const rL=null!=/x/.unicode?"gu":"g",rV=RegExp("[\0-\b\n-\x1f-\u2028\u2029\uFEFF-]",rL),r_={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 rF=null;const rW=ei.define({combine(e){let t=eB(e,{render:null,specialChars:rV,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==rF&&"undefined"!=typeof document&&document.body){let t=document.body.style;rF=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)!=null}return rF||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,rL)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,rL)),t}});let rj=null;class rz extends tK{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){var t;let i=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),n=e.state.phrase("Control character")+" "+(r_[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,i);if(r)return r;let s=document.createElement("span");return s.textContent=i,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class rY extends tK{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}}const rI=t1.line({class:"cm-activeLine"}),rU=iq.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,i=[];for(let n of e.state.selection.ranges){let r=e.lineBlockAt(n.head);r.from>t&&(i.push(rI.range(r.from)),t=r.from)}return t1.set(i)}},{decorations:e=>e.decorations});function rN(e,t){var i;let n,r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(r),o=r-s.from,a=o>2e3?-1:o==s.length?(i=t.clientX,(n=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((n.left-i)/e.defaultCharacterWidth)):-1):e0(s.text,e.state.tabSize,r-s.from);return{line:s.number,col:a,off:o}}const rG={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},rH={style:"cursor: crosshair"},rJ="-10000px";class rK{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=i(e,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(e=>e);if(n===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let s=[],o=t?[]:null;for(let i=0;is.indexOf(e)&&(this.removeTooltipView(e),null===(i=e.destroy)||void 0===i||i.call(e));return t&&(o.forEach((e,i)=>t[i]=e),t.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function r0(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const r1=ei.define({combine:e=>{var t,i,n;return{position:tF.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(i=e.find(e=>e.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=e.find(e=>e.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||r0}}}),r2=new WeakMap,r5=iq.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(r1);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new rK(e,r9,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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)for(let e of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(e.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let i=t||e.geometryChanged,n=e.state.facet(r1);if(n.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=n.position,this.manager.tooltipViews))e.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(e.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(e,t){let i=e.create(this.view),n=t?t.dom:null;if(i.dom.classList.add("cm-tooltip"),e.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",i.dom.appendChild(e)}return i.dom.style.position=this.position,i.dom.style.top=rJ,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var e,t,i;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(tF.gecko)i=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==rJ&&"0px"==e.style.left){let t=e.getBoundingClientRect();i=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}}if(i||"absolute"==this.position){if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(e=i.width/this.parent.offsetWidth,t=i.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let n=this.view.scrollDOM.getBoundingClientRect(),r=iU(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(r1).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:i,space:n,scaleX:r,scaleY:s}=e,o=[];for(let a=0;a=Math.min(i.bottom,n.bottom)||c.rightMath.min(i.right,n.right)+.1)){u.style.top=rJ;continue}let f=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!f,O=d.right-d.left,m=null!==(t=r2.get(h))&&void 0!==t?t:d.bottom-d.top,g=h.offset||r7,b=this.view.textDirection==ir.LTR,x=d.width>n.right-n.left?b?n.left:n.right-d.width:b?Math.max(n.left,Math.min(c.left-14*!!f+g.x,n.right-O)):Math.min(Math.max(n.left,c.left-O+14*!!f-g.x),n.right-O),v=this.above[a];!l.strictSide&&(v?c.top-m-p-g.yn.bottom)&&v==n.bottom-c.bottom>c.top-n.top&&(v=this.above[a]=!v);let y=(v?c.top-n.top:n.bottom-c.bottom)-p;if(yx&&e.topw&&(w=v?e.top-m-2-p:e.bottom+p+2);if("absolute"==this.position?(u.style.top=(w-e.parent.top)/s+"px",r3(u,(x-e.parent.left)/r)):(u.style.top=w/s+"px",r3(u,x/r)),f){let e=c.left+(b?g.x:-g.x)-(x+14-7);f.style.left=e/r+"px"}!0!==h.overlap&&o.push({left:x,top:w,right:k,bottom:w+m}),u.classList.toggle("cm-tooltip-above",v),u.classList.toggle("cm-tooltip-below",!v),h.positioned&&h.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=rJ}},{eventObservers:{scroll(){this.maybeMeasure()}}});function r3(e,t){let i=parseInt(e.style.left,10);(isNaN(i)||Math.abs(t-i)>1)&&(e.style.left=t+"px")}const r4=ro.baseTheme({".cm-tooltip":{zIndex:500,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:"14px",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"}}}),r7={x:0,y:0},r9=ei.define({enables:[r5,r4]}),r6=ei.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class r8{static create(e){return new r8(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new rK(e,r6,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(void 0!==n){if(void 0===t)t=n;else if(t!==n)return}}return t}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 se=r9.compute([r6],e=>{let t=e.facet(r6);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:r8.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class st{constructor(e,t,i,n,r){this.view=e,this.source=t,this.field=i,this.setHover=n,this.hoverTime=r,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;ei.bottom||t.xi.right+e.defaultCharacterWidth)return;let s=e.bidiSpans(e.state.doc.lineAt(n)).find(e=>e.from<=n&&e.to>=n),o=s&&s.dir==ir.RTL?-1:1;r=t.x{this.pending==t&&(this.pending=null,i&&!(Array.isArray(i)&&!i.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))},t=>iM(e.state,t,"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(r5),t=e?e.manager.tooltips.findIndex(e=>e.create==r8.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:n,tooltip:r}=this;if(n.length&&r&&!function(e,t){let{left:i,right:n,top:r,bottom:s}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let e=o.getBoundingClientRect();r=Math.min(e.top,r),s=Math.max(e.bottom,s)}return t.clientX>=i-4&&t.clientX<=n+4&&t.clientY>=r-4&&t.clientY<=s+4}(r.dom,e)||this.pending){let{pos:r}=n[0]||this.pending,s=null!==(i=null===(t=n[0])||void 0===t?void 0:t.end)&&void 0!==i?i:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!function(e,t,i,n,r,s){let o=e.scrollDOM.getBoundingClientRect(),a=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>n||o.rightr||Math.min(o.bottom,a)=t&&l<=i}(this.view,r,s,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function si(e,t){let i=e.plugin(r5);if(!i)return null;let n=i.manager.tooltips.indexOf(t);return n<0?null:i.manager.tooltipViews[n]}const sn=eC.define(),sr=ei.define({combine(e){let t,i;for(let n of e)t=t||n.topContainer,i=i||n.bottomContainer;return{topContainer:t,bottomContainer:i}}});function ss(e,t){let i=e.plugin(so),n=i?i.specs.indexOf(t):-1;return n>-1?i.panels[n]:null}const so=iq.fromClass(class{constructor(e){this.input=e.state.facet(sh),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(sr);for(let i of(this.top=new sa(e,!0,t.topContainer),this.bottom=new sa(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(e){let t=e.state.facet(sr);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new sa(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new sa(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(sh);if(i!=this.input){let t=i.filter(e=>e),n=[],r=[],s=[],o=[];for(let i of t){let t=this.specs.indexOf(i),a;t<0?(a=i(e.view),o.push(a)):(a=this.panels[t]).update&&a.update(e),n.push(a),(a.top?r:s).push(a)}for(let e of(this.specs=t,this.panels=n,this.top.sync(r),this.bottom.sync(s),o))e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ro.scrollMargins.of(t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class sa{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=sl(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=sl(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 sl(e){let t=e.nextSibling;return e.remove(),t}const sh=ei.define({enables:so});class su extends eq{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}su.prototype.elementClass="",su.prototype.toDOM=void 0,su.prototype.mapMode=W.TrackBefore,su.prototype.startSide=su.prototype.endSide=-1,su.prototype.point=!0;const sc=ei.define(),sd=ei.define(),sf={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>eF.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},sp=ei.define(),sO=ei.define({combine:e=>e.some(e=>e)});function sm(e){let t=[sg];return e&&!1===e.fixed&&t.push(sO.of(!0)),t}const sg=iq.fromClass(class{constructor(e){for(let t of(this.view=e,this.prevViewport=e.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=e.state.facet(sp).map(t=>new sy(e,t)),this.gutters))this.dom.appendChild(t.dom);this.fixed=!e.state.facet(sO),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,i=e.view.viewport,n=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(sO)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let i=eF.iter(this.view.state.facet(sc),this.view.viewport.from),n=[],r=this.gutters.map(e=>new sv(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(e.type)){let t=!0;for(let s of e.type)if(s.type==t0.Text&&t){for(let e of(sx(i,n,s.from),r))e.line(this.view,s,n);t=!1}else if(s.widget)for(let e of r)e.widget(this.view,s)}else if(e.type==t0.Text)for(let t of(sx(i,n,e.from),r))t.line(this.view,e,n);else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(sp),i=e.state.facet(sp),n=e.docChanged||e.heightChanged||e.viewportChanged||!eF.eq(e.startState.facet(sc),e.state.facet(sc),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=t.indexOf(n);i<0?r.push(new sy(this.view,n)):(this.gutters[i].update(e),r.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),0>r.indexOf(e)&&e.destroy();for(let e of r)this.dom.appendChild(e.dom);this.gutters=r}return n}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>ro.scrollMargins.of(t=>{let i=t.plugin(e);return i&&0!=i.gutters.length&&i.fixed?t.textDirection==ir.LTR?{left:i.dom.offsetWidth*t.scaleX}:{right:i.dom.offsetWidth*t.scaleX}:null})});function sb(e){return Array.isArray(e)?e:[e]}function sx(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class sv{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=eF.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==n.elements.length){let t=new sw(e,s,r,i);n.elements.push(t),n.dom.appendChild(t.dom)}else n.elements[this.i].update(e,s,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];sx(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let i of e.state.facet(sd)){let r=i(e,t.widget,t);r&&(n||(n=[])).push(r)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class sy{constructor(e,t){for(let i in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=n.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[i](e,o,n)&&n.preventDefault()});this.markers=sb(t.markers(e)),t.initialSpacer&&(this.spacer=new sw(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=sb(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let i=e.view.viewport;return!eF.eq(this.markers,t,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class sw{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let i=0;ieB(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],r=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||r(e,t,i):r}return i}})});class sA extends su{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function s$(e,t){return e.state.facet(sQ).formatNumber(t,e.state)}const sC=sp.compute([sQ],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(sk),lineMarker:(e,t,i)=>i.some(e=>e.toDOM)?null:new sA(s$(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,i)=>{for(let n of e.state.facet(sS)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(sQ)!=e.state.facet(sQ),initialSpacer:e=>new sA(s$(e,sP(e.state.doc.lines))),updateSpacer(e,t){let i=s$(t.view,sP(t.view.state.doc.lines));return i==e.number?e:new sA(i)},domEventHandlers:e.facet(sQ).domEventHandlers}));function sP(e){let t=9;for(;t{let t=[],i=-1;for(let n of e.selection.ranges){let r=e.doc.lineAt(n.head).from;r>i&&(i=r,t.push(sZ.range(r)))}return eF.of(t)});let sT=0;class sR{constructor(e,t){this.from=e,this.to=t}}class sM{constructor(e={}){this.id=sT++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=sB.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}sM.closedBy=new sM({deserialize:e=>e.split(" ")}),sM.openedBy=new sM({deserialize:e=>e.split(" ")}),sM.group=new sM({deserialize:e=>e.split(" ")}),sM.isolate=new sM({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),sM.contextHash=new sM({perNode:!0}),sM.lookAhead=new sM({perNode:!0}),sM.mounted=new sM({perNode:!0});class sX{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[sM.mounted.id]}}const sD=Object.create(null);class sB{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):sD,i=+!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),n=new sB(e.name||"",t,e.id,i);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(sM.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return e=>{for(let i=e.prop(sM.group),n=-1;n<(i?i.length:0);n++){let r=t[n<0?e.name:i[n]];if(r)return r}}}}sB.none=new sB("",Object.create(null),0,8);class sq{constructor(e){this.types=e;for(let t=0;t=t){let o=new sI(s.tree,s.overlay[0].from+e.from,-1,e);(r||(r=[n])).push(sz(o,t,i,!1))}}return r?sJ(r):n}(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,s=e.mode||0,o=(s&B.IncludeAnonymous)>0;for(let e=this.cursor(s|B.IncludeAnonymous);;){let s=!1;if(e.from<=r&&e.to>=n&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&i&&(o||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;s=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:s3(sB.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new s_(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new s_(sB.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=e,a=Array.isArray(i)?new sF(i,i.length):i,l=n.types,h=0,u=0;function c(e,t,i,r,s,o,a,l,h){let u=[],c=[];for(;e.length>r;)u.push(e.pop()),c.push(t.pop()+i-s);e.push(d(n.types[a],u,c,o-s,l-o,h)),t.push(s-i)}function d(e,t,i,n,r,s,o){if(s){let e=[sM.contextHash,s];o=o?[e].concat(o):[e]}if(r>25){let e=[sM.lookAhead,r];o=o?[e].concat(o):[e]}return new s_(e,t,i,n,o)}let f=[],p=[];for(;a.pos>0;)!function e(t,i,f,p,O,m){let{id:g,start:b,end:x,size:v}=a,y=u,w=h;for(;v<0;){if(a.next(),-1==v){let e=s[g];f.push(e),p.push(b-t);return}if(-3==v){h=g;return}if(-4==v){u=g;return}else throw RangeError(`Unrecognized record size: ${v}`)}let k=l[g],S,Q,A=b-t;if(x-b<=r&&(Q=function(e,t){let i=a.fork(),n=0,s=0,l=0,h=i.end-r,u={size:0,start:0,skip:0};i:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){u.size=n,u.start=s,u.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-e;if(e<0||a=o),d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3==i.size)c+=4;else break i}else i.id>=o&&(c+=4);i.next()}s=d,n+=e,l+=c}return(t<0||n==e)&&(u.size=n,u.start=s,u.skip=l),u.size>4?u:void 0}(a.pos-i,O))){let e=new Uint16Array(Q.size-Q.skip),i=a.pos-Q.size,r=e.length;for(;a.pos>i;)r=function e(t,i,n){let{id:r,start:s,end:l,size:c}=a;if(a.next(),c>=0&&r4){let r=a.pos-(c-4);for(;a.pos>r;)n=e(t,i,n)}i[--n]=o,i[--n]=l-t,i[--n]=s-t,i[--n]=r}else -3==c?h=r:-4==c&&(u=r);return n}(Q.start,e,r);S=new sW(e,x-Q.start,n),A=Q.start-t}else{let t=a.pos-v;a.next();let i=[],s=[],l=g>=o?g:-1,h=0,u=x;for(;a.pos>t;)l>=0&&a.id==l&&a.size>=0?(a.end<=u-r&&(c(i,s,b,h,a.end,u,l,y,w),h=i.length,u=a.end),a.next()):m>2500?function(e,t,i,s){let o=[],l=0,h=-1;for(;a.pos>t;){let{id:e,start:t,end:i,size:n}=a;if(n>4)a.next();else if(h>-1&&t=0;e-=3)t[i++]=o[e],t[i++]=o[e+1]-r,t[i++]=o[e+2]-r,t[i++]=i;i.push(new sW(t,o[2]-r,n)),s.push(r-e)}}(b,t,i,s):e(b,t,i,s,l,m+1);if(l>=0&&h>0&&h-1&&h>0){let e=function(e,t){return(i,n,r)=>{let s=0,o=i.length-1,a,l;if(o>=0&&(a=i[o])instanceof s_){if(!o&&a.type==e&&a.length==r)return a;(l=a.prop(sM.lookAhead))&&(s=n[o]+a.length+l)}return d(e,i,n,r,s,t)}}(k,w);S=s3(k,i,s,0,i.length,0,x-b,e,e)}else S=d(k,i,s,x-b,y-x,w)}f.push(S),p.push(A)}(e.start||0,e.bufferStart||0,f,p,-1,0);let O=null!==(t=e.length)&&void 0!==t?t:f.length?p[0]+f[0].length:0;return new s_(l[e.topID],f.reverse(),p.reverse(),O)}(e)}}s_.empty=new s_(sB.none,[],[],0);class sF{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new sF(this.buffer,this.index)}}class sW{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return sB.none}toString(){let e=[];for(let t=0;t0)));a=s[a+3]);return o}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),s=0;for(let o=e,a=0;o=t&⁢case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function sz(e,t,i,n){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to0?o.length:-1;e!=l;e+=t){let l=o[e],h=a[e]+s.from;if(sj(n,i,h,h+l.length)){if(l instanceof sW){if(r&B.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,t,i-h,n);if(o>-1)return new sH(new sG(s,l,e,h),null,o)}else if(r&B.IncludeAnonymous||!l.type.isAnonymous||s1(l)){let o;if(!(r&B.IgnoreMounts)&&(o=sX.get(l))&&!o.overlay)return new sI(o.tree,h,e,s);let a=new sI(l,h,e,s);return r&B.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,i,n)}}}if(r&B.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let n;if(!(i&B.IgnoreOverlays)&&(n=sX.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:e,to:r}of n.overlay)if((t>0?e<=i:e=i:r>i))return new sI(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function sU(e,t,i,n){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=i){for(let e=!1;!e;)if(e=r.type.is(i),!r.nextSibling())return s}for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function sN(e,t,i=t.length-1){for(let n=e;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[i]&&t[i]!=n.name)return!1;i--}}return!0}class sG{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class sH extends sY{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new sH(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&B.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new sH(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new sH(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new sH(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];e.push(i.slice(n,r,s)),t.push(0)}return new s_(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function sJ(e){if(!e.length)return null;let t=0,i=e[0];for(let n=1;ni.from||r.to0){if(this.index-1)for(let n=t+e,r=e<0?-1:i._tree.children.length;n!=r;n+=e){let e=i._tree.children[n];if(this.mode&B.IncludeAnonymous||e instanceof sW||!e.type.isAnonymous||s1(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,i=r+1;break i}n=this.stack[--r]}for(let e=i;e=0;r--){if(r<0)return sN(this._tree,e,n);let s=i[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function s1(e){return e.children.some(e=>e instanceof sW||!e.type.isAnonymous||s1(e))}const s2=new WeakMap;function s5(e,t){if(!e.isAnonymous||t instanceof sW||t.type!=e)return 1;let i=s2.get(t);if(null==i){for(let n of(i=1,t.children)){if(n.type!=e||!(n instanceof s_)){i=1;break}i+=s5(e,n)}s2.set(t,i)}return i}function s3(e,t,i,n,r,s,o,a,l){let h=0;for(let i=n;i=u)break;p+=t}if(h==r+1){if(p>u){let e=i[r];t(e.children,e.positions,0,e.children.length,n[r]+a);continue}c.push(i[r])}else{let t=n[h-1]+i[h-1].length-f;c.push(s3(e,i,n,r,h,f,t,null,l))}d.push(f+a-s)}}(t,i,n,r,0),(a||l)(c,d,o)}class s4{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof sH?this.setBuffer(e.context.buffer,e.index,t):e instanceof sI&&this.map.set(e.tree,t)}get(e){return e instanceof sH?this.getBuffer(e.context.buffer,e.index):e instanceof sI?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class s7{constructor(e,t,i,n,r=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=+!!r|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new s7(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,s=e.length?e[0]:null;for(let o=0,a=0,l=0;;o++){let h=o=i)for(;s&&s.from=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,i=Math.min(t.to,u)-l;t=e>=i?null:new s7(e,i,t.tree,t.offset+l,o>0,!!h)}if(t&&n.push(t),s.to>u)break;s=rnew sR(e.from,e.to)):[new sR(0,0)]:[new sR(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let e=n.advance();if(e)return e}}}class s6{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function s8(e){return(t,i,n,r)=>new or(t,e,i,n,r)}class oe{constructor(e,t,i,n,r){this.parser=e,this.parse=t,this.overlay=i,this.target=n,this.from=r}}function ot(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class oi{constructor(e,t,i,n,r,s,o){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=r,this.target=s,this.prev=o,this.depth=0,this.ranges=[]}}const on=new sM({perNode:!0});class or{constructor(e,t,i,n,r){this.nest=t,this.input=i,this.fragments=n,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new s_(e.type,e.children,e.positions,e.length,e.propValues.concat([[on,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[sM.mounted.id]=new sX(t,e.overlay,e.parser),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t=this.stoppedAt)o=!1;else if(e.hasNode(n)){if(t){let e=t.mounts.find(e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay);if(e)for(let i of e.mount.overlay){let r=i.from+e.pos,s=i.to+e.pos;r>=n.from&&s<=n.to&&!t.ranges.some(e=>e.fromr)&&t.ranges.push({from:r,to:s})}}o=!1}else if(i&&(s=function(e,t,i){for(let n of e){if(n.from>=i)break;if(n.to>t)return n.from<=t&&n.to>=i?2:1}return 0}(i.ranges,n.from,n.to)))o=2!=s;else if(!n.type.isAnonymous&&(r=this.nest(n,this.input))&&(n.fromnew sR(e.from-n.from,e.to-n.from)):null,n.tree,e.length?e[0].from:n.from)),r.overlay?e.length&&(i={ranges:e,depth:0,prev:i}):o=!1}}else if(t&&(a=t.predicate(n))&&(!0===a&&(a=new sR(n.from,n.to)),a.from=0&&t.ranges[e].to==a.from?t.ranges[e]={from:t.ranges[e].from,to:a.to}:t.ranges.push(a)}if(o&&n.firstChild())t&&t.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break i;if(t&&!--t.depth){let e=ol(this.ranges,t.ranges);e.length&&(ot(e),this.inner.splice(t.index,0,new oe(t.parser,t.parser.startParse(this.input,oh(t.mounts,e),e),t.ranges.map(e=>new sR(e.from-t.start,e.to-t.start)),t.target,e[0].from))),t=t.prev}!i||--i.depth||(i=i.prev)}}}}function os(e,t,i,n,r,s){if(t=e&&t.enter(i,1,B.IgnoreOverlays|B.ExcludeBuffers)||t.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 t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&0==t.positions[0]&&t.children[0]instanceof s_)t=t.children[0];else break}return!1}}class oa{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=null!==(t=i.tree.prop(on))&&void 0!==t?t:i.to,this.inner=new oo(i.tree,-i.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 t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(on))&&void 0!==e?e:t.to,this.inner=new oo(t.tree,-t.offset)}}findMounts(e,t){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=null===(i=e.tree)||void 0===i?void 0:i.prop(sM.mounted);if(r&&r.parser==t)for(let t=this.fragI;t=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}}function ol(e,t){let i=null,n=t;for(let r=1,s=0;r=a)break;!(e.to<=o)&&(i||(n=i=t.slice()),e.froma&&i.splice(s+1,0,new sR(a,e.to))):e.to>a?i[s--]=new sR(a,e.to):i.splice(s--,1))}}return n}function oh(e,t){let i=[];for(let{pos:n,mount:r,frag:s}of e){let e=n+(r.overlay?r.overlay[0].from:0),o=e+r.tree.length,a=Math.max(s.from,e),l=Math.min(s.to,o);if(r.overlay){let o=function(e,t,i,n){let r=0,s=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let u=r==e.length?1e9:o?e[r].to:e[r].from,c=s==t.length?1e9:a?t[s].to:t[s].from;if(o!=a){let e=Math.max(l,i),t=Math.min(u,c,n);enew sR(e.from+n,e.to+n)),a,l);for(let t=0,n=a;;t++){let a=t==o.length,h=a?l:o[t].from;if(h>n&&i.push(new s7(n,h,r.tree,-e,s.from>=n||s.openStart,s.to<=h||s.openEnd)),a)break;n=o[t].to}}else i.push(new s7(a,l,r.tree,-e,s.from>=e||s.openStart,s.to<=o||s.openEnd))}return i}let ou=0;class oc{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=ou++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){if(e instanceof oc&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let i=new oc("string"==typeof e?e:"?",[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new of(e);return e=>e.modified.indexOf(t)>-1?e:of.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let od=0;class of{constructor(e){this.name=e,this.instances=[],this.id=od++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(i=>{var n,r;return i.base==e&&(n=t,r=i.modified,n.length==r.length&&n.every((e,t)=>e==r[t]))});if(i)return i;let n=[],r=new oc(e.name,n,e,t);for(let e of t)e.instances.push(r);let s=function(e){let t=[[]];for(let i=0;it.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)n.push(of.get(t,e));return r}}function op(e){let t=Object.create(null);for(let i in e){let n=e[i];for(let e of(Array.isArray(n)||(n=[n]),i.split(" ")))if(e){let i=[],r=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw RangeError("Invalid path: "+e);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),(t+=n[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);s=e.slice(t)}let o=i.length-1,a=i[o];if(!a)throw RangeError("Invalid path: "+e);let l=new om(n,r,o>0?i.slice(0,o):null);t[a]=l.sort(t[a])}}return oO.add(t)}const oO=new sM;class om{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth{let t=r;for(let n of e)for(let e of n.set){let n=i[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}om.empty=new om([],2,null);class ob{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:s,from:o,to:a}=e;if(o>=i||a<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let l=n,h=function(e){let t=e.type.prop(oO);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||om.empty,u=function(e,t){let i=null;for(let n of e){let e=n.style(t);e&&(i=i?i+" "+e:e)}return i}(r,h.tags);if(u&&(l&&(l+=" "),l+=u,1==h.mode&&(n+=(n?" ":"")+u)),this.startSpan(Math.max(t,o),l),h.opaque)return;let c=e.tree&&e.tree.prop(sM.mounted);if(c&&c.overlay){let s=e.node.enter(c.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(c.tree.type)),u=e.firstChild();for(let d=0,f=o;;d++){let p=d=O)&&e.nextSibling()););if(!p||O>i)break;(f=p.to+o)>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),l))}u&&e.parent()}else if(e.firstChild()){c&&(n="");do{if(e.to<=t)continue;if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),l)}while(e.nextSibling())e.parent()}}}const ox=oc.define,ov=ox(),oy=ox(),ow=ox(oy),ok=ox(oy),oS=ox(),oQ=ox(oS),oA=ox(oS),o$=ox(),oC=ox(o$),oP=ox(),oZ=ox(),oE=ox(),oT=ox(oE),oR=ox(),oM={comment:ov,lineComment:ox(ov),blockComment:ox(ov),docComment:ox(ov),name:oy,variableName:ox(oy),typeName:ow,tagName:ox(ow),propertyName:ok,attributeName:ox(ok),className:ox(oy),labelName:ox(oy),namespace:ox(oy),macroName:ox(oy),literal:oS,string:oQ,docString:ox(oQ),character:ox(oQ),attributeValue:ox(oQ),number:oA,integer:ox(oA),float:ox(oA),bool:ox(oS),regexp:ox(oS),escape:ox(oS),color:ox(oS),url:ox(oS),keyword:oP,self:ox(oP),null:ox(oP),atom:ox(oP),unit:ox(oP),modifier:ox(oP),operatorKeyword:ox(oP),controlKeyword:ox(oP),definitionKeyword:ox(oP),moduleKeyword:ox(oP),operator:oZ,derefOperator:ox(oZ),arithmeticOperator:ox(oZ),logicOperator:ox(oZ),bitwiseOperator:ox(oZ),compareOperator:ox(oZ),updateOperator:ox(oZ),definitionOperator:ox(oZ),typeOperator:ox(oZ),controlOperator:ox(oZ),punctuation:oE,separator:ox(oE),bracket:oT,angleBracket:ox(oT),squareBracket:ox(oT),paren:ox(oT),brace:ox(oT),content:o$,heading:oC,heading1:ox(oC),heading2:ox(oC),heading3:ox(oC),heading4:ox(oC),heading5:ox(oC),heading6:ox(oC),contentSeparator:ox(o$),list:ox(o$),quote:ox(o$),emphasis:ox(o$),strong:ox(o$),link:ox(o$),monospace:ox(o$),strikethrough:ox(o$),inserted:ox(),deleted:ox(),changed:ox(),invalid:ox(),meta:oR,documentMeta:ox(oR),annotation:ox(oR),processingInstruction:ox(oR),definition:oc.defineModifier("definition"),constant:oc.defineModifier("constant"),function:oc.defineModifier("function"),standard:oc.defineModifier("standard"),local:oc.defineModifier("local"),special:oc.defineModifier("special")};for(let e in oM){let t=oM[e];t instanceof oc&&(t.name=e)}og([{tag:oM.link,class:"tok-link"},{tag:oM.heading,class:"tok-heading"},{tag:oM.emphasis,class:"tok-emphasis"},{tag:oM.strong,class:"tok-strong"},{tag:oM.keyword,class:"tok-keyword"},{tag:oM.atom,class:"tok-atom"},{tag:oM.bool,class:"tok-bool"},{tag:oM.url,class:"tok-url"},{tag:oM.labelName,class:"tok-labelName"},{tag:oM.inserted,class:"tok-inserted"},{tag:oM.deleted,class:"tok-deleted"},{tag:oM.literal,class:"tok-literal"},{tag:oM.string,class:"tok-string"},{tag:oM.number,class:"tok-number"},{tag:[oM.regexp,oM.escape,oM.special(oM.string)],class:"tok-string2"},{tag:oM.variableName,class:"tok-variableName"},{tag:oM.local(oM.variableName),class:"tok-variableName tok-local"},{tag:oM.definition(oM.variableName),class:"tok-variableName tok-definition"},{tag:oM.special(oM.variableName),class:"tok-variableName2"},{tag:oM.definition(oM.propertyName),class:"tok-propertyName tok-definition"},{tag:oM.typeName,class:"tok-typeName"},{tag:oM.namespace,class:"tok-namespace"},{tag:oM.className,class:"tok-className"},{tag:oM.macroName,class:"tok-macroName"},{tag:oM.propertyName,class:"tok-propertyName"},{tag:oM.operator,class:"tok-operator"},{tag:oM.comment,class:"tok-comment"},{tag:oM.meta,class:"tok-meta"},{tag:oM.invalid,class:"tok-invalid"},{tag:oM.punctuation,class:"tok-punctuation"}]);const oX=new sM;function oD(e){return ei.define({combine:e?t=>t.concat(e):void 0})}const oB=new sM;class oq{constructor(e,t,i=[],n=""){this.data=e,this.name=n,eD.prototype.hasOwnProperty("tree")||Object.defineProperty(eD.prototype,"tree",{get(){return o_(this)}}),this.parser=t,this.extension=[oG.of(this),eD.languageData.of((e,t,i)=>{let n=oL(e,t,i),r=n.type.prop(oX);if(!r)return[];let s=e.facet(r),o=n.type.prop(oB);if(o){let r=n.resolve(t-n.from,i);for(let t of o)if(t.test(r,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(s)}}return s})].concat(i)}isActiveAt(e,t,i=-1){return oL(e,t,i).type.prop(oX)==this.data}findRegions(e){let t=e.facet(oG);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(oX)==this.data){i.push({from:t,to:t+e.length});return}let r=e.prop(sM.mounted);if(r){if(r.tree.prop(oX)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;ie.isTop?t:void 0)]}),e.name)}configure(e,t){return new oV(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function o_(e){let t=e.field(oq.state,!1);return t?t.tree:s_.empty}class oF{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,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let oW=null;class oj{constructor(e,t,i=[],n,r,s,o,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new oj(e,t,[],s_.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oF(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=s_.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(s7.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=oW;oW=this;try{return e()}finally{oW=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=oz(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,i,n,r)=>t.push({fromA:e,toA:i,fromB:n,toB:r})),i=s7.applyChanges(i,t),n=s_.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);ie.from&&(this.fragments=oz(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends s9{createParse(t,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let t=oW;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new s_(sB.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return oW}}function oz(e,t,i){return s7.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class oY{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new oY(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=oj.create(e.facet(oG).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new oY(i)}}oq.state=el.define({create:oY.init,update(e,t){for(let e of t.effects)if(e.is(oq.setState))return e.value;return t.startState.facet(oG)!=t.state.facet(oG)?oY.init(t.state):e.apply(t)}});let oI=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(oI=e=>{let t=-1,i=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const oU="undefined"!=typeof navigator&&(null===(q=navigator.scheduling)||void 0===q?void 0:q.isInputPending)?()=>navigator.scheduling.isInputPending():null,oN=iq.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(oq.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(oq.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=oI(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,a=r.context.work(()=>oU&&oU()||Date.now()>s,n+1e5*!o);this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:oq.setState.of(new oY(r.context))})),this.chunkBudget>0&&!(a&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>iM(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),oG=ei.define({combine:e=>e.length?e[0]:null,enables:e=>[oq.state,oN,ro.contentAttributes.compute([e],t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}})]});class oH{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class oJ{constructor(e,t,i,n,r,s){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=r,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:t,support:i}=e;if(!t){if(!i)throw RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new oJ(e.name,(e.alias||[]).concat(e.name).map(e=>e.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let i=/\.([^.]+)$/.exec(t);if(i){for(let t of e)if(t.extensions.indexOf(i[1])>-1)return t}return null}static matchLanguageName(e,t,i=!0){for(let i of(t=t.toLowerCase(),e))if(i.alias.some(e=>e==t))return i;if(i)for(let i of e)for(let e of i.alias){let n=t.indexOf(e);if(n>-1&&(e.length>2||!/\w/.test(t[n-1])&&!/\w/.test(t[n+e.length])))return i}return null}}const oK=ei.define(),o0=ei.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function o1(e){let t=e.facet(o0);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function o2(e,t){let i="",n=e.tabSize,r=e.facet(o0)[0];if(" "==r){for(;t>=n;)i+=" ",t-=n;r=" "}for(let e=0;e=t?function(e,t,i){let n=t.resolveStack(i),r=t.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=n.node){let e=[];for(let t=r;t&&(t.from!=n.node.from||t.type!=n.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)n={node:e[t],next:n}}return o7(n,e,i)}(e,i,t):null}class o3{constructor(e,t={}){this.state=e,this.options=t,this.unit=o1(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return e0(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const o4=new sM;function o7(e,t,i){for(let n=e;n;n=n.next){let e=function(e){let t=e.type.prop(o4);if(t)return t;let i=e.firstChild,n;if(i&&(n=i.type.prop(sM.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>o8(e,!0,1,void 0,i&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?o9:null}(n.node);if(e)return e(o6.create(t,i,n))}return 0}function o9(){return 0}class o6 extends o3{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new o6(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(function(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return o7(this.context.next,this.base,this.pos)}}function o8(e,t,i,n,r){let s=e.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==e.pos+o,l=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==n)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+e}}e=r.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*i)}function ae({except:e,units:t=1}={}){return i=>{let n=e&&e.test(i.textAfter);return i.baseIndent+(n?0:t*i.unit)}}const at=ei.define(),ai=new sM;function an(e){let t=e.firstChild,i=e.lastChild;return t&&t.toi)continue;if(s&&r.from=t&&n.to>i&&(s=n)}}return s}(e,t,i)}function as(e,t){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);return i>=n?void 0:{from:i,to:n}}const ao=eC.define({map:as}),aa=eC.define({map:as});function al(e){let t=[];for(let{head:i}of e.state.selection.ranges)t.some(e=>e.from<=i&&e.to>=i)||t.push(e.lineBlockAt(i));return t}const ah=el.define({create:()=>t1.none,update(e,t){for(let i of(e=e.map(t.changes),t.effects))if(i.is(ao)&&!function(e,t,i){let n=!1;return e.between(t,t,(e,r)=>{e==t&&r==i&&(n=!0)}),n}(e,i.value.from,i.value.to)){let{preparePlaceholder:n}=t.state.facet(aO),r=n?t1.replace({widget:new ax(n(t.state,i.value))}):ab;e=e.update({add:[r.range(i.value.from,i.value.to)]})}else i.is(aa)&&(e=e.update({filter:(e,t)=>i.value.from!=e||i.value.to!=t,filterFrom:i.value.from,filterTo:i.value.to}));if(t.selection){let i=!1,{head:n}=t.selection.main;e.between(n,n,(e,t)=>{en&&(i=!0)}),i&&(e=e.update({filterFrom:n,filterTo:n,filter:(e,t)=>t<=n||e>=n}))}return e},provide:e=>ro.decorations.from(e),toJSON(e,t){let i=[];return e.between(0,t.doc.length,(e,t)=>{i.push(e,t)}),i},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let i=0;i{(!r||r.from>e)&&(r={from:e,to:t})}),r}function ac(e,t){return e.field(ah,!1)?t:t.concat(eC.appendConfig.of(am()))}function ad(e,t,i=!0){let n=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return ro.announce.of(`${e.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${e.state.phrase("to")} ${r}.`)}const af=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of al(e)){let i=ar(e.state,t.from,t.to);if(i)return e.dispatch({effects:ac(e.state,[ao.of(i),ad(e,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(ah,!1))return!1;let t=[];for(let i of al(e)){let n=au(e.state,i.from,i.to);n&&t.push(aa.of(n),ad(e,n,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,i=[];for(let n=0;n{let t=e.state.field(ah,!1);if(!t||!t.size)return!1;let i=[];return t.between(0,e.state.doc.length,(e,t)=>{i.push(aa.of({from:e,to:t}))}),e.dispatch({effects:i}),!0}}],ap={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},aO=ei.define({combine:e=>eB(e,ap)});function am(e){let t=[ah,aw];return e&&t.push(aO.of(e)),t}function ag(e,t){let{state:i}=e,n=i.facet(aO),r=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),n=au(e.state,i.from,i.to);n&&e.dispatch({effects:aa.of(n)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const ab=t1.replace({widget:new class extends tK{toDOM(e){return ag(e,null)}}});class ax extends tK{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ag(e,this.value)}}const av={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ay extends su{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const aw=ro.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 ak{constructor(e,t){let i;function n(e){let t=e4.newName();return(i||(i=Object.create(null)))["."+t]=e,t}this.specs=e;let r="string"==typeof t.all?t.all:t.all?n(t.all):void 0,s=t.scope;this.scope=s instanceof oq?e=>e.prop(oX)==s.data:s?e=>e==s:void 0,this.style=og(e.map(e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=i?new e4(i):null,this.themeType=t.themeType}static define(e,t){return new ak(e,t||{})}}const aS=ei.define(),aQ=ei.define({combine:e=>e.length?[e[0]]:null});function aA(e){let t=e.facet(aS);return t.length?t:e.facet(aQ)}const a$=ec.high(iq.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=o_(e.state),this.decorations=this.buildDeco(e,aA(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=o_(e.state),i=aA(e.state),n=i!=aA(e.startState),{viewport:r}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return t1.none;let i=new eW;for(let{from:n,to:r}of e.visibleRanges)!function(e,t,i,n=0,r=e.length){let s=new ob(n,Array.isArray(t)?t:[t],i);s.highlightRange(e.cursor(),n,r,"",s.highlighters),s.flush(r)}(this.tree,t,(e,t,n)=>{i.add(e,t,this.markCache[n]||(this.markCache[n]=t1.mark({class:n})))},n,r);return i.finish()}},{decorations:e=>e.decorations})),aC=ak.define([{tag:oM.meta,color:"#404740"},{tag:oM.link,textDecoration:"underline"},{tag:oM.heading,textDecoration:"underline",fontWeight:"bold"},{tag:oM.emphasis,fontStyle:"italic"},{tag:oM.strong,fontWeight:"bold"},{tag:oM.strikethrough,textDecoration:"line-through"},{tag:oM.keyword,color:"#708"},{tag:[oM.atom,oM.bool,oM.url,oM.contentSeparator,oM.labelName],color:"#219"},{tag:[oM.literal,oM.inserted],color:"#164"},{tag:[oM.string,oM.deleted],color:"#a11"},{tag:[oM.regexp,oM.escape,oM.special(oM.string)],color:"#e40"},{tag:oM.definition(oM.variableName),color:"#00f"},{tag:oM.local(oM.variableName),color:"#30a"},{tag:[oM.typeName,oM.namespace],color:"#085"},{tag:oM.className,color:"#167"},{tag:[oM.special(oM.variableName),oM.macroName],color:"#256"},{tag:oM.definition(oM.propertyName),color:"#00c"},{tag:oM.comment,color:"#940"},{tag:oM.invalid,color:"#f00"}]),aP=ro.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),aZ="()[]{}",aE=ei.define({combine:e=>eB(e,{afterCursor:!0,brackets:aZ,maxScanDistance:1e4,renderMatch:aM})}),aT=t1.mark({class:"cm-matchingBracket"}),aR=t1.mark({class:"cm-nonmatchingBracket"});function aM(e){let t=[],i=e.matched?aT:aR;return t.push(i.range(e.start.from,e.start.to)),e.end&&t.push(i.range(e.end.from,e.end.to)),t}const aX=[el.define({create:()=>t1.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(aE);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=aL(t.state,e.head,-1,n)||e.head>0&&aL(t.state,e.head-1,1,n)||n.afterCursor&&(aL(t.state,e.head,1,n)||e.headro.decorations.from(e)}),aP],aD=new sM;function aB(e,t,i){let n=e.prop(t<0?sM.openedBy:sM.closedBy);if(n)return n;if(1==e.name.length){let n=i.indexOf(e.name);if(n>-1&&n%2==+(t<0))return[i[n+t]]}return null}function aq(e){let t=e.type.prop(aD);return t?t(e.node):e}function aL(e,t,i,n={}){let r=n.maxScanDistance||1e4,s=n.brackets||aZ,o=o_(e),a=o.resolveInner(t,i);for(let e=a;e;e=e.parent){let n=aB(e.type,i,s);if(n&&e.from0?t>=r.from&&tr.from&&t<=r.to))return function(e,t,i,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},h=0,u=null==a?void 0:a.cursor();if(u&&(i<0?u.childBefore(n.from):u.childAfter(n.to)))do if(i<0?u.to<=n.from:u.from>=n.to){if(0==h&&s.indexOf(u.type.name)>-1&&u.from0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},u=e.doc.iterRange(t,i>0?e.doc.length:0),c=0;for(let e=0;!u.next().done&&e<=s;){let s=u.value;i<0&&(e+=s.length);let a=t+e*i;for(let e=i>0?0:s.length-1,t=i>0?s.length:-1;e!=t;e+=i){let t=o.indexOf(s[e]);if(!(t<0)&&n.resolveInner(a+e,1).type==r){if(t%2==0==i>0)c++;else{if(1==c)return{start:h,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};c--}}}i>0&&(e+=s.length)}return u.done?{start:h,matched:!1}:null}(e,t,i,o,a.type,r,s)}const aV=Object.create(null),a_=[sB.none],aF=[],aW=Object.create(null),aj=Object.create(null);for(let[e,t]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"]])aj[e]=function(e,t){let i=[];for(let n of t.split(" ")){let t=[];for(let i of n.split(".")){let n=e[i]||oM[i];n?"function"==typeof n?t.length?t=t.map(n):az(i,`Modifier ${i} used at start of tag`):t.length?az(i,`Tag ${i} used as modifier`):t=Array.isArray(n)?n:[n]:az(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+i.map(e=>e.id),s=aW[r];if(s)return s.id;let o=aW[r]=sB.define({id:a_.length,name:n,props:[op({[n]:i})]});return a_.push(o),o.id}(aV,t);function az(e,t){aF.indexOf(e)>-1||(aF.push(e),console.warn(t))}function aY(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function aI(e){for(let t=e.iter();!t.next().done;)if(aY(t.value))return!0;return!1}const aU=ei.define({combine:e=>e.some(e=>e)});function aN(e,t,i){let n=new eW,r=e.visibleRanges;for(let{from:s,to:o}of(i||(r=function(e,t){let i=t.iter(),n=0,r=[],s=null;for(let{from:t,to:o}of e)if(!s||!(s.to>t)||!((t=s.to)>=o))for(n+i.value.lengthe-10?s.to=Math.min(o,t):r.push(s={from:e,to:Math.min(o,t)})),t>=o)break;n=t,i.next()}return r}(r,e.state.doc)),r))t.iterate({enter:e=>{let t=e.type.prop(sM.isolate);t&&n.add(e.from,e.to,aG[t])},from:s,to:o});return n.finish()}iq.fromClass(class{constructor(e){this.always=e.state.facet(aU)||e.textDirection!=ir.LTR||e.state.facet(ro.perLineTextDirection),this.hasRTL=!this.always&&aI(e.state.doc),this.tree=o_(e.state),this.decorations=this.always||this.hasRTL?aN(e,this.tree,this.always):t1.none}update(e){var t;let i,n=e.state.facet(aU)||e.view.textDirection!=ir.LTR||e.state.facet(ro.perLineTextDirection);if(!n&&!this.hasRTL&&(t=e.changes,i=!1,t.iterChanges((e,t,n,r,s)=>{!i&&aI(s)&&(i=!0)}),i)&&(this.hasRTL=!0),!n&&!this.hasRTL)return;let r=o_(e.state);(n!=this.always||r!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=r,this.always=n,this.decorations=aN(e.view,r,n))}},{provide:e=>{function t(t){var i,n;return null!==(n=null===(i=t.plugin(e))||void 0===i?void 0:i.decorations)&&void 0!==n?n:t1.none}return[ro.outerDecorations.of(t),ec.lowest(ro.bidiIsolatedRanges.of(t))]}});const aG={rtl:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ir.RTL}),ltr:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ir.LTR}),auto:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function aH(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=e(t,i);return!!r&&(n(i.update(r)),!0)}}const aJ=aH(function(e,t,i=t.selection.ranges){let n=[],r=-1;for(let{from:e,to:s}of i){let i=n.length,o=1e9,a=a1(t,e).line;if(a){for(let i=e;i<=s;){let l=t.doc.lineAt(i);if(l.from>r&&(e==s||s>l.from)){r=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,i=l.text.slice(e,e+a.length)==a?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:i,indent:r,empty:s,single:o}of n)(o||!s)&&e.push({from:t.from+r,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&n.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:i,token:r}of n)if(i>=0){let n=t.from+i,s=n+r.length;" "==t.text[s-t.from]&&s++,e.push({from:n,to:s})}return{changes:e}}return null},0),aK=aH(a2,0),a0=aH((e,t)=>a2(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),r=i.to<=n.to?n:e.doc.lineAt(i.to);r.from>n.from&&r.from==i.to&&(r=i.to==n.to+1?n:e.doc.lineAt(i.to-1));let s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return t}(t)),0);function a1(e,t){let i=e.languageDataAt("commentTokens",t);return i.length?i[0]:{}}function a2(e,t,i=t.selection.ranges){let n=i.map(e=>a1(t,e.from).block);if(!n.every(e=>e))return null;let r=i.map((e,i)=>(function(e,{open:t,close:i},n,r){let s,o,a=e.sliceDoc(n-50,n),l=e.sliceDoc(r,r+50),h=/\s*$/.exec(a)[0].length,u=/^\s*/.exec(l)[0].length,c=a.length-h;if(a.slice(c-t.length,c)==t&&l.slice(u,u+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+u,margin:u&&1}};r-n<=100?s=o=e.sliceDoc(n,r):(s=e.sliceDoc(n,n+50),o=e.sliceDoc(r-50,r));let d=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(d,d+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:n+d+t.length,margin:+!!/\s/.test(s.charAt(d+t.length))},close:{pos:r-f-i.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(t,n[i],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(i.map((e,t)=>r[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t=0,i;teB(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}),a9=el.define({create:()=>lu.empty,update(e,t){let i=t.state.facet(a7),n=t.annotation(a5);if(n){let r=ln.fromTransaction(t,n.selection),s=n.side,o=0==s?e.undone:e.done;return o=r?lr(o,o.length,i.minDepth,r):la(o,t.startState.selection),new lu(0==s?n.rest:o,0==s?o:n.rest)}let r=t.annotation(a3);if(("full"==r||"before"==r)&&(e=e.isolate()),!1===t.annotation(eP.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=ln.fromTransaction(t),o=t.annotation(eP.time),a=t.annotation(eP.userEvent);return s?e=e.addChanges(s,o,a,i,t):t.selection&&(e=e.addSelection(t.startState.selection,o,a,i.newGroupDelay)),("full"==r||"after"==r)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new lu(e.done.map(ln.fromJSON),e.undone.map(ln.fromJSON))});function a6(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let r=i.field(a9,!1);if(!r)return!1;let s=r.pop(e,i,t);return!!s&&(n(s),!0)}}const a8=a6(0,!1),le=a6(1,!1),lt=a6(0,!0),li=a6(1,!0);class ln{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new ln(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new ln(e.changes&&z.fromJSON(e.changes),[],e.mapped&&j.fromJSON(e.mapped),e.startSelection&&K.fromJSON(e.startSelection),e.selectionsAfter.map(K.fromJSON))}static fromTransaction(e,t){let i=lo;for(let t of e.startState.facet(a4)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new ln(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,lo)}static selection(e){return new ln(void 0,lo,void 0,void 0,e)}}function lr(e,t,i,n){let r=e.slice(t+1>i+20?t-i-1:0,t);return r.push(n),r}function ls(e,t){return e.length?t.length?e.concat(t):e:t}const lo=[];function la(e,t){if(!e.length)return[ln.selection([t])];{let i=e[e.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),lr(e,e.length-1,1e9,i.setSelAfter(n)))}}function ll(e,t){if(!e.length)return e;let i=e.length,n=lo;for(;i;){let r=function(e,t,i){let n=ls(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):lo,i);if(!e.changes)return ln.selection(n);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new ln(r,eC.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[ln.selection(n)]:lo}const lh=/^(input\.type|delete)($|\.)/;class lu{constructor(e,t,i=0,n){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new lu(this.done,this.undone):this}addChanges(e,t,i,n,r){var s,o;let a,l,h=this.done,u=h[h.length-1];return new lu(h=u&&u.changes&&!u.changes.empty&&e.changes&&(!i||lh.test(i))&&(!u.selectionsAfter.length&&t-this.prevTimea.push(e,t)),o.iterChangedRanges((e,t,i,n)=>{for(let e=0;e=t&&i<=r&&(l=!0)}}),l))||"input.type.compose"==i)?lr(h,h.length-1,n.minDepth,new ln(e.changes.compose(u.changes),ls(eC.mapEffects(e.effects,u.changes),u.effects),u.mapped,u.startSelection,lo)):lr(h,h.length,n.minDepth,e),lo,t,i)}addSelection(e,t,i,n){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:lo;return s.length>0&&t-this.prevTimet.empty!=e.ranges[i].empty).length?this:new lu(la(this.done,e),this.undone,t,i)}addMapping(e){return new lu(ll(this.done,e),ll(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=0==e?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length){let i,o;return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:a5.of({side:e,rest:(i=n[n.length-1],(o=n.slice())[n.length-1]=i.setSelAfter(i.selectionsAfter.slice(0,i.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let i=1==n.length?lo:n.slice(0,n.length-1);return r.mapped&&(i=ll(i,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:a5.of({side:e,rest:i,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}lu.empty=new lu(lo,lo);function lc(e,t){return K.create(e.ranges.map(t),e.mainIndex)}function ld(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function lf({state:e,dispatch:t},i){let n=lc(e.selection,i);return!n.eq(e.selection,!0)&&(t(ld(e,n)),!0)}function lp(e,t){return K.cursor(t?e.to:e.from)}function lO(e,t){return lf(e,i=>i.empty?e.moveByChar(i,t):lp(i,t))}function lm(e){return e.textDirectionAt(e.state.selection.main.head)==ir.LTR}const lg=e=>lO(e,!lm(e)),lb=e=>lO(e,lm(e));function lx(e,t){return lf(e,i=>i.empty?e.moveByGroup(i,t):lp(i,t))}function lv(e,t,i){let n,r,s=o_(e).resolveInner(t.head),o=i?sM.closedBy:sM.openedBy;for(let n=t.head;;){let t=i?s.childAfter(n):s.childBefore(n);if(!t)break;!function(e,t,i){if(t.type.prop(i))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?n=i?t.to:t.from:s=t}return r=s.type.prop(o)&&(n=i?aL(e,s.from,1):aL(e,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,K.cursor(r,i?-1:1)}function ly(e,t){return lf(e,i=>{if(!i.empty)return lp(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;const lw=e=>ly(e,!1),lk=e=>ly(e,!0);function lS(e){let t=e.scrollDOM.clientHeighti.empty?e.moveVertically(i,t,n.height):lp(i,t));if(s.eq(r.selection))return!1;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),a=o.top+n.marginTop,l=o.bottom-n.marginBottom;t&&t.top>a&&t.bottomlQ(e,!1),l$=e=>lQ(e,!0);function lC(e,t,i){let n=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?n.to:n.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&t.head!=n.from+i&&(r=K.cursor(n.from+i))}return r}function lP(e,t){let i=lc(e.state.selection,e=>{let i=t(e);return K.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(e.state.selection)&&(e.dispatch(ld(e.state,i)),!0)}function lZ(e,t){return lP(e,i=>e.moveByChar(i,t))}const lE=e=>lZ(e,!lm(e)),lT=e=>lZ(e,lm(e));function lR(e,t){return lP(e,i=>e.moveByGroup(i,t))}function lM(e,t){return lP(e,i=>e.moveVertically(i,t))}const lX=e=>lM(e,!1),lD=e=>lM(e,!0);function lB(e,t){return lP(e,i=>e.moveVertically(i,t,lS(e).height))}const lq=e=>lB(e,!1),lL=e=>lB(e,!0),lV=({state:e,dispatch:t})=>(t(ld(e,{anchor:0})),!0),l_=({state:e,dispatch:t})=>(t(ld(e,{anchor:e.doc.length})),!0),lF=({state:e,dispatch:t})=>(t(ld(e,{anchor:e.selection.main.anchor,head:0})),!0),lW=({state:e,dispatch:t})=>(t(ld(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function lj(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:n}=e,r=n.changeByRange(n=>{let{from:r,to:s}=n;if(r==s){let o=t(n);or&&(i="delete.forward",o=lz(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=lz(e,r,!1),s=lz(e,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:K.cursor(r,rt(e)))n.between(t,t,(e,n)=>{et&&(t=i?n:e)});return t}const lY=(e,t,i)=>lj(e,n=>{let r=n.from,{state:s}=e,o=s.doc.lineAt(r),a,l;if(i&&!t&&r>o.from&&rlY(e,!1,!0),lU=e=>lY(e,!0,!1),lN=(e,t)=>lj(e,i=>{let n=i.head,{state:r}=e,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let e=null;;){if(n==(t?s.to:s.from)){n==i.head&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let a=S(s.text,n-s.from,t)+s.from,l=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(l);if(null!=e&&h!=e)break;(" "!=l||n!=i.head)&&(e=h),n=a}return n}),lG=e=>lN(e,!1);function lH(e){let t=[],i=-1;for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=e.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=e.doc.lineAt(n.to-1)),i>=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return t}function lJ(e,t,i){if(e.readOnly)return!1;let n=[],r=[];for(let t of lH(e)){if(i?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(i?t.to+1:t.from-1),o=s.length+1;if(i)for(let i of(n.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))r.push(K.range(Math.min(e.doc.length,i.anchor+o),Math.min(e.doc.length,i.head+o)));else for(let i of(n.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))r.push(K.range(i.anchor-o,i.head-o))}return!!n.length&&(t(e.update({changes:n,scrollIntoView:!0,selection:K.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function lK(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of lH(e))i?n.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):n.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const l0=l2(!1),l1=l2(!0);function l2(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{let{from:n,to:r}=i,s=t.doc.lineAt(n),o=!e&&n==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i=o_(e).resolveInner(t),n=i.childBefore(t),r=i.childAfter(t),s;return n&&r&&n.to<=t&&r.from>=t&&(s=n.type.prop(sM.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}(t,n);e&&(n=r=(r<=s.to?s:t.doc.lineAt(r)).to);let a=new o3(t,{simulateBreak:n,simulateDoubleBreak:!!o}),l=o5(a,n);for(null==l&&(l=e0(/^\s*/.exec(t.doc.lineAt(n).text)[0],t.tabSize));rs.from&&n{let r=[];for(let s=n.from;s<=n.to;){let o=e.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(t(o,r,n),i=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:K.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const l3=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(l5(e,(t,i)=>{i.push({from:t.from,insert:e.facet(o0)})}),{userEvent:"input.indent"})),!0),l4=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(l5(e,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=e0(n,e.tabSize),s=0,o=o2(e,Math.max(0,r-o1(e)));for(;slf(e,t=>K.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>lP(e,t=>K.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>lf(e,t=>K.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>lP(e,t=>K.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:lU},{key:"Ctrl-h",run:lI},{key:"Ctrl-k",run:e=>lj(e,t=>{let i=e.lineBlockAt(t.head).to;return t.head{if(e.readOnly)return!1;let i=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:O.of(["",""])},range:K.cursor(e.from)}));return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let i=t.from,n=e.doc.lineAt(i),r=i==n.from?i-1:S(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:S(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:e.doc.slice(i,s).append(e.doc.slice(r,i))},range:K.cursor(s)}});return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:l$}],l9=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>lf(e,t=>lv(e.state,t,!lm(e))),shift:e=>lP(e,t=>lv(e.state,t,!lm(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>lf(e,t=>lv(e.state,t,lm(e))),shift:e=>lP(e,t=>lv(e.state,t,lm(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>lJ(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>lK(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>lJ(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>lK(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let i=e.selection,n=null;return i.ranges.length>1?n=K.create([i.main]):i.main.empty||(n=K.create([K.cursor(i.main.head)])),!!n&&(t(ld(e,n)),!0)}},{key:"Mod-Enter",run:l1},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=lH(e).map(({from:t,to:i})=>K.range(t,Math.min(i+1,e.doc.length)));return t(e.update({selection:K.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let i=lc(e.selection,t=>{let i=o_(e),n=i.resolveStack(t.from,1);if(t.empty){let e=i.resolveStack(t.from,-1);e.node.from>=n.node.from&&e.node.to<=n.node.to&&(n=e)}for(let e=n;e;e=e.next){let{node:i}=e;if((i.from=t.to||i.to>t.to&&i.from<=t.from)&&e.next)return K.range(i.to,i.from)}return t});return!i.eq(e.selection)&&(t(ld(e,i)),!0)},preventDefault:!0},{key:"Mod-[",run:l4},{key:"Mod-]",run:l3},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),n=new o3(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),r=l5(e,(t,r,s)=>{let o=o5(n,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],l=o2(e,o);(a!=l||s.from{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(lH(t).map(({from:e,to:i})=>(e>0?e--:i{let i;if(e.lineWrapping){let n=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(i=n.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,i)}).map(i);return e.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let i,n;return i=!1,n=lc(e.selection,t=>{let n=aL(e,t.head,-1)||aL(e,t.head,1)||t.head>0&&aL(e,t.head-1,1)||t.head{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),n=a1(e.state,i.from);return n.line?aJ(e):!!n.block&&a0(e)}},{key:"Alt-A",run:aK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:lg,shift:lE,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>lx(e,!lm(e)),shift:e=>lR(e,!lm(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>lf(e,t=>lC(e,t,!lm(e))),shift:e=>lP(e,t=>lC(e,t,!lm(e))),preventDefault:!0},{key:"ArrowRight",run:lb,shift:lT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>lx(e,lm(e)),shift:e=>lR(e,lm(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>lf(e,t=>lC(e,t,lm(e))),shift:e=>lP(e,t=>lC(e,t,lm(e))),preventDefault:!0},{key:"ArrowUp",run:lw,shift:lX,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lV,shift:lF},{mac:"Ctrl-ArrowUp",run:lA,shift:lq},{key:"ArrowDown",run:lk,shift:lD,preventDefault:!0},{mac:"Cmd-ArrowDown",run:l_,shift:lW},{mac:"Ctrl-ArrowDown",run:l$,shift:lL},{key:"PageUp",run:lA,shift:lq},{key:"PageDown",run:l$,shift:lL},{key:"Home",run:e=>lf(e,t=>lC(e,t,!1)),shift:e=>lP(e,t=>lC(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:lV,shift:lF},{key:"End",run:e=>lf(e,t=>lC(e,t,!0)),shift:e=>lP(e,t=>lC(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:l_,shift:lW},{key:"Enter",run:l0,shift:l0},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:lI,shift:lI},{key:"Delete",run:lU},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lG},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>lN(e,!0)},{mac:"Mod-Backspace",run:e=>lj(e,t=>{let i=e.moveToLineBoundary(t,!1).head;return t.head>i?i:Math.max(0,t.head-1)})},{mac:"Mod-Delete",run:e=>lj(e,t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head({mac:e.key,run:e.run,shift:e.shift})))),l6={key:"Tab",run:l3,shift:l4};function l8(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?e.setAttribute(n,r):null!=r&&(e[n]=r)}t++}for(;te.normalize("NFKD"):e=>e;class ht{constructor(e,t,i=0,n=e.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?e=>r(he(e)):he,this.query=this.normalize(t)}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 Q(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 t=A(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=$(e);let n=this.normalize(t);if(n.length)for(let e=0,r=i;;e++){let s=n.charCodeAt(e),o=this.match(s,r,this.bufferPos+this.bufferStart);if(e==n.length-1){if(o)return this.value=o,this;break}r==i&ðis.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 t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=hl(this.text,n+ +(i==n)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length=i||n.to<=t){let n=new ho(t,e.sliceString(t,i));return hs.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:r,from:s}=n;return s>t&&(r=e.sliceString(t,s)+r,s=t),n.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=hl(this.text,i+ +(e==i)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ho.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function hl(e,t){if(t>=e.length)return t;let i=e.lineAt(t),n;for(;t=56320&&n<57344;)t++;return t}function hh(e){let t=l8("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:n}=e,r=n.doc.lineAt(n.selection.main.head),[,s,o,a,l]=i,h=a?+a.slice(1):0,u=o?+o:r.number;if(o&&l){let e=u/100;s&&(e=e*("-"==s?-1:1)+r.number/n.doc.lines),u=Math.round(n.doc.lines*e)}else o&&s&&(u=u*("-"==s?-1:1)+r.number);let c=n.doc.line(Math.max(1,Math.min(n.doc.lines,u))),d=K.cursor(c.from+Math.max(0,Math.min(h,c.length)));e.dispatch({effects:[hu.of(!1),ro.scrollIntoView(d.from,{y:"center"})],selection:d}),e.focus()}return{dom:l8("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:hu.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:e=>{e.preventDefault(),i()}},l8("label",e.state.phrase("Go to line"),": ",t)," ",l8("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),l8("button",{name:"close",onclick:()=>{e.dispatch({effects:hu.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(hr.prototype[Symbol.iterator]=ha.prototype[Symbol.iterator]=function(){return this});const hu=eC.define(),hc=el.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(hu)&&(e=i.value);return e},provide:e=>sh.from(e,e=>e?hh:null)}),hd=ro.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),hf={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},hp=ei.define({combine:e=>eB(e,hf,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),hO=t1.mark({class:"cm-selectionMatch"}),hm=t1.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function hg(e,t,i,n){return(0==i||e(t.sliceDoc(i-1,i))!=eM.Word)&&(n==t.doc.length||e(t.sliceDoc(n,n+1))!=eM.Word)}const hb=iq.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(hp),{state:i}=e,n=i.selection;if(n.ranges.length>1)return t1.none;let r=n.main,s,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return t1.none;let e=i.wordAt(r.head);if(!e)return t1.none;o=i.charCategorizer(r.head),s=i.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e200)return t1.none;if(t.wholeWords){var a,l,h;if(s=i.sliceDoc(r.from,r.to),!(hg(o=i.charCategorizer(r.head),i,r.from,r.to)&&(a=o,l=r.from,h=r.to,a(i.sliceDoc(l,l+1))==eM.Word&&a(i.sliceDoc(h-1,h))==eM.Word)))return t1.none}else if(!(s=i.sliceDoc(r.from,r.to)))return t1.none}let u=[];for(let n of e.visibleRanges){let e=new ht(i.doc,s,n.from,n.to);for(;!e.next().done;){let{from:n,to:s}=e.value;if((!o||hg(o,i,n,s))&&(r.empty&&n<=r.from&&s>=r.to?u.push(hm.range(n,s)):(n>=r.to||s<=r.from)&&u.push(hO.range(n,s)),u.length>t.maxMatches))return t1.none}}return t1.set(u)}},{decorations:e=>e.decorations}),hx=ro.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),hv=({state:e,dispatch:t})=>{let{selection:i}=e,n=K.create(i.ranges.map(t=>e.wordAt(t.head)||K.cursor(t.head)),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)},hy=ei.define({combine:e=>eB(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new hG(e),scrollToMatch:e=>ro.scrollIntoView(e)})});class hw{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||function(e){try{return new RegExp(e,hn),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==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 hP(this):new hQ(this)}getCursor(e,t=0,i){let n=e.doc?e:eD.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?hA(this,n,t,i):hS(this,n,t,i)}}class hk{constructor(e){this.spec=e}}function hS(e,t,i,n){var r,s;return new ht(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,i,n)=>((n>e||n+i.length=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=hS(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function hA(e,t,i,n){var r;return new hr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(r(h$(i.input,i.index))!=eM.Word||r(hC(i.input,i.index))!=eM.Word)&&(r(hC(i.input,i.index+i[0].length))!=eM.Word||r(h$(i.input,i.index+i[0].length))!=eM.Word)):void 0},i,n)}function h$(e,t){return e.slice(S(e,t,!1),t)}function hC(e,t){return e.slice(t,S(e,t))}class hP extends hk{nextMatch(e,t,i){let n=hA(this.spec,e,i,e.doc.length).next();return n.done&&(n=hA(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-1e4*n),s=hA(this.spec,e,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let n=+i.slice(0,t);if(n>0&&n=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=hA(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const hZ=eC.define(),hE=eC.define(),hT=el.define({create:e=>new hR(hj(e).create(),null),update(e,t){for(let i of t.effects)i.is(hZ)?e=new hR(i.value.create(),e.panel):i.is(hE)&&(e=new hR(e.query,i.value?hW:null));return e},provide:e=>sh.from(e,e=>e.panel)});class hR{constructor(e,t){this.query=e,this.panel=t}}const hM=t1.mark({class:"cm-searchMatch"}),hX=t1.mark({class:"cm-searchMatch cm-searchMatch-selected"}),hD=iq.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hT))}update(e){let t=e.state.field(hT);(t!=e.startState.field(hT)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return t1.none;let{view:i}=this,n=new eW;for(let t=0,r=i.visibleRanges,s=r.length;tr[t+1].from-500;)a=r[++t].to;e.highlight(i.state,o,a,(e,t)=>{let r=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);n.add(e,t,r?hX:hM)})}return n.finish()}},{decorations:e=>e.decorations});function hB(e){return t=>{let i=t.state.field(hT,!1);return i&&i.query.spec.valid?e(t,i):hI(t)}}const hq=hB((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=K.single(n.from,n.to),s=e.state.facet(hy);return e.dispatch({selection:r,effects:[hK(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),hY(e),!0}),hL=hB((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=K.single(r.from,r.to),o=e.state.facet(hy);return e.dispatch({selection:s,effects:[hK(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),hY(e),!0}),hV=hB((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!!i&&!!i.length&&(e.dispatch({selection:K.create(i.map(e=>K.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),h_=hB((e,{query:t})=>{let{state:i}=e,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=t.nextMatch(i,n,n);if(!s)return!1;let o=s,a=[],l,h,u=[];if(o.from==n&&o.to==r&&(h=i.toText(t.getReplacement(o)),a.push({from:o.from,to:o.to,insert:h}),o=t.nextMatch(i,o.from,o.to),u.push(ro.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),o){let t=0==a.length||a[0].from>=s.to?0:s.to-s.from-h.length;l=K.single(o.from-t,o.to-t),u.push(hK(e,o)),u.push(i.facet(hy).scrollToMatch(l.main,e))}return e.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),hF=hB((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}});if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:ro.announce.of(n),userEvent:"input.replace.all"}),!0});function hW(e){return e.state.facet(hy).createPanel(e)}function hj(e,t){var i,n,r,s,o;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let h=e.facet(hy);return new hw({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:h.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function hz(e){let t=ss(e,hW);return t&&t.dom.querySelector("[main-field]")}function hY(e){let t=hz(e);t&&t==e.root.activeElement&&t.select()}const hI=e=>{let t=e.state.field(hT,!1);if(t&&t.panel){let i=hz(e);if(i&&i!=e.root.activeElement){let n=hj(e.state,t.query.spec);n.valid&&e.dispatch({effects:hZ.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[hE.of(!0),t?hZ.of(hj(e.state,t.query.spec)):eC.appendConfig.of(h1)]});return!0},hU=e=>{let t=e.state.field(hT,!1);if(!t||!t.panel)return!1;let i=ss(e,hW);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:hE.of(!1)}),!0},hN=[{key:"Mod-f",run:hI,scope:"editor search-panel"},{key:"F3",run:hq,shift:hL,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hq,shift:hL,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hU,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let t=new ht(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(o=s.length),s.push(K.range(t.value.from,t.value.to))}return t(e.update({selection:K.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=ss(e,hh);if(!t){let i=[hu.of(!0)];null==e.state.field(hc,!1)&&i.push(eC.appendConfig.of([hc,hd])),e.dispatch({effects:i}),t=ss(e,hh)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return hv({state:e,dispatch:t});let n=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=n))return!1;let r=function(e,t){let{main:i,ranges:n}=e.selection,r=e.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new ht(e.doc,t,n[n.length-1].to);;)if(r.next(),r.done){if(i)return null;r=new ht(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(e=>e.from==r.value.from))continue;if(s){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}}(e,n);return!!r&&(t(e.update({selection:e.selection.addRange(K.range(r.from,r.to),!1),effects:ro.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class hG{constructor(e){this.view=e;let t=this.query=e.state.field(hT).query.spec;function i(e,t,i){return l8("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=l8("input",{value:t.search,placeholder:hH(e,"Find"),"aria-label":hH(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=l8("input",{value:t.replace,placeholder:hH(e,"Replace"),"aria-label":hH(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=l8("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=l8("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=l8("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=l8("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>hq(e),[hH(e,"next")]),i("prev",()=>hL(e),[hH(e,"previous")]),i("select",()=>hV(e),[hH(e,"all")]),l8("label",null,[this.caseField,hH(e,"match case")]),l8("label",null,[this.reField,hH(e,"regexp")]),l8("label",null,[this.wordField,hH(e,"by word")]),...e.state.readOnly?[]:[l8("br"),this.replaceField,i("replace",()=>h_(e),[hH(e,"replace")]),i("replaceAll",()=>hF(e),[hH(e,"replace all")])],l8("button",{name:"close",onclick:()=>hU(e),"aria-label":hH(e,"close"),type:"button"},["×"])])}commit(){let e=new hw({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:hZ.of(e)}))}keydown(e){var t,i;(t=this.view,i="search-panel",rx(rm(t.state),e,t,i))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?hL:hq)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),h_(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(hZ)&&!e.value.eq(this.query)&&this.setQuery(e.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(hy).top}}function hH(e,t){return e.state.phrase(t)}const hJ=/[\s\.,:;?!]/;function hK(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(n.from,t-30),o=Math.min(r,i+30),a=e.state.sliceDoc(s,o);if(s!=n.from){for(let e=0;e<30;e++)if(!hJ.test(a[e+1])&&hJ.test(a[e])){a=a.slice(e);break}}if(o!=r){for(let e=a.length-1;e>a.length-30;e--)if(!hJ.test(a[e-1])&&hJ.test(a[e])){a=a.slice(0,e);break}}return ro.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${n.number}.`)}const h0=ro.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"}}),h1=[hT,ec.low(hD),h0];class h2{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=o_(this.state).resolveInner(this.pos,-1);for(;t&&0>e.indexOf(t.name);)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),r=n.search(h9(e,!1));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,i){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function h5(e){let t=Object.keys(e).join(""),i=/\w/.test(t);return i&&(t=t.replace(/\w/g,"")),`[${i?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function h3(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[i,n]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),i=Object.create(null);for(let{label:n}of e){t[n[0]]=!0;for(let e=1;e{let r=e.matchBefore(n);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:i}:null}}class h4{constructor(e,t,i,n){this.completion=e,this.source=t,this.match=i,this.score=n}}function h7(e){return e.selection.main.from}function h9(e,t){var i;let{source:n}=e,r=t&&"^"!=n[0],s="$"!=n[n.length-1];return r||s?RegExp(`${r?"^":""}(?:${n})${s?"$":""}`,null!==(i=e.flags)&&void 0!==i?i:e.ignoreCase?"i":""):e}const h6=eQ.define(),h8=new WeakMap;function ue(e){if(!Array.isArray(e))return e;let t=h8.get(e);return t||h8.set(e,t=h3(e)),t}const ut=eC.define(),ui=eC.define();class un{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(b=A(l))!=b.toLowerCase()?1:2*(b!=b.toUpperCase());(!n||1==x&&O||0==g&&0!=x)&&(t[u]==l||i[u]==l&&(c=!0)?s[u++]=n:s.length&&(m=!1)),g=x,n+=$(l)}return u==a&&0==s[0]&&m?this.result(-100+(c?-200:0),s,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):u==a?this.result(-100+(c?-200:0)+-700+(m?0:-1100),s,e):2==t.length?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,i){let n=[],r=0;for(let e of t){let t=e+(this.astral?$(Q(i,e)):1);r&&n[r-1]==e?n[r-1]=t:(n[r++]=e,n[r++]=t)}return this.ret(e-i.length,n)}}class ur{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.lengtheB(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ua,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>uo(e(i),t(i)),optionClass:(e,t)=>i=>uo(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function uo(e,t){return e?t?e+" "+t:e:t}function ua(e,t,i,n,r,s){let o=e.textDirection==ir.RTL,a=o,l=!1,h="top",u,c,d=t.left-r.left,f=r.right-t.right,p=n.right-n.left,O=n.bottom-n.top;if(a&&d=O||e>t.top?u=i.bottom-t.top:(h="bottom",u=t.bottom-i.top)}let m=(t.bottom-t.top)/s.offsetHeight,g=(t.right-t.left)/s.offsetWidth;return{style:`${h}: ${u/m}px; max-width: ${c/g}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function ul(e,t,i){if(e<=i)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/i);return{from:e*i,to:(e+1)*i}}let n=Math.floor((e-t)/i);return{from:e-(n+1)*i,to:e-n*i}}class uh{constructor(e,t,i){let n;this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,a=e.state.facet(us);this.optionContent=(n=a.addToOptions.slice(),a.icons&&n.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),n.push({render(e,t,i,n){let r=document.createElement("span");r.className="cm-completionLabel";let s=e.displayLabel||e.label,o=0;for(let e=0;eo&&r.appendChild(document.createTextNode(s.slice(o,t)));let a=r.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(s.slice(t,i))),a.className="cm-completionMatchedText",o=i}return oe.position-t.position).map(e=>e.render)),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=ul(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",i=>{let{options:n}=e.state.field(t).open;for(let t=i.target,r;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(r=/-(\d+)$/.exec(t.id))&&+r[1]{let i=e.state.field(this.stateField,!1);i&&i.tooltip&&e.state.facet(us).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:ui.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=n){let{options:r,selected:s,disabled:o}=i.open;n.open&&n.open.options==r||(this.range=ul(r.length,s,e.state.facet(us).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),o!=(null===(t=n.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=ul(t.options.length,t.selected,this.view.state.facet(us).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:n}=i;if(!n)return;let r="string"==typeof n?document.createTextNode(n):n(i);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>iM(this.view.state,e,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=e.nodeType)i.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:n}=e;i.appendChild(t),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){var t,i;let n,r,s,o=null;for(let t=this.list.firstChild,i=this.range.from;t;t=t.nextSibling,i++)"LI"==t.nodeName&&t.id?i==e?t.hasAttribute("aria-selected")||(t.setAttribute("aria-selected","true"),o=t):t.hasAttribute("aria-selected")&&t.removeAttribute("aria-selected"):i--;return o&&(t=this.list,i=o,n=t.getBoundingClientRect(),r=i.getBoundingClientRect(),s=n.height/t.offsetHeight,r.topn.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/s)),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return n.top>Math.min(r.bottom,t.bottom)-10||n.bottom{e.target==n&&e.preventDefault()});let r=null;for(let s=i.from;si.from||0==i.from)&&(r=e,"string"!=typeof l&&l.header?n.appendChild(l.header(l)):n.appendChild(document.createElement("completion-section")).textContent=e)}let h=n.appendChild(document.createElement("li"));h.id=t+"-"+s,h.setAttribute("role","option");let u=this.optionClass(o);for(let e of(u&&(h.className=u),this.optionContent)){let t=e(o,this.view.state,this.view,a);t&&h.appendChild(t)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to=this.options.length?this:new uc(this.options,uO(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,n,r,s){if(n&&!s&&e.some(e=>e.isPending))return n.setDisabled();let o=function(e,t){let i=[],n=null,r=e=>{i.push(e);let{section:t}=e.completion;if(t){n||(n=[]);let e="string"==typeof t?t:t.name;n.some(t=>t.name==e)||n.push("string"==typeof t?{name:e}:t)}},s=t.facet(us);for(let n of e)if(n.hasResult()){let e=n.result.getMatch;if(!1===n.result.filter)for(let t of n.result.options)r(new h4(t,n.source,e?e(t):[],1e9-i.length));else{let i=t.sliceDoc(n.from,n.to),o,a=s.filterStrict?new ur(i):new un(i);for(let t of n.result.options)if(o=a.match(t.label)){let i=t.displayLabel?e?e(t,o.matched):[]:o.matched;r(new h4(t,n.source,i,o.score+(t.boost||0)))}}}if(n){let e=Object.create(null),t=0;for(let i of n.sort((e,t)=>{var i,n;return(null!==(i=e.rank)&&void 0!==i?i:1e9)-(null!==(n=t.rank)&&void 0!==n?n:1e9)||(e.namet.score-e.score||l(e.completion,t.completion))){let t=e.completion;a&&a.label==t.label&&a.detail==t.detail&&(null==a.type||null==t.type||a.type==t.type)&&a.apply==t.apply&&a.boost==t.boost?uu(e.completion)>uu(a)&&(o[o.length-1]=e):o.push(e),a=e.completion}return o}(e,t);if(!o.length)return n&&e.some(e=>e.isPending)?n.setDisabled():null;let a=t.facet(us).selectOnOpen?0:-1;if(n&&n.selected!=a&&-1!=n.selected){let e=n.options[n.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e,1e8),create:uS,above:r.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(e){return new uc(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new uc(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ud{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new ud(um,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,i=t.facet(us),n=(i.override||t.languageDataAt("autocomplete",h7(t)).map(ue)).map(t=>(this.active.find(e=>e.source==t)||new ub(t,+!!this.active.some(e=>0!=e.state))).update(e,i));n.length==this.active.length&&n.every((e,t)=>e==this.active[t])&&(n=this.active);let r=this.open,s=e.effects.some(e=>e.is(uv));for(let o of(r&&e.docChanged&&(r=r.map(e.changes)),e.selection||n.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let i=0,n=0;;){for(;ie.isPending)&&(r=null),!r&&n.every(e=>!e.isPending)&&n.some(e=>e.hasResult())&&(n=n.map(e=>e.hasResult()?new ub(e.source,0):e)),e.effects))o.is(uy)&&(r=r&&r.setSelected(o.value,this.id));return n==this.active&&r==this.open?this:new ud(n,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?uf:up}}const uf={"aria-autocomplete":"list"},up={};function uO(e,t){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(i["aria-activedescendant"]=e+"-"+t),i}const um=[];function ug(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(h6);if(i&&t.activateOnCompletion(i))return 12}let i=e.isUserEvent("input.type");return i&&t.activateOnTyping?5:i?1:e.isUserEvent("delete.backward")?2:e.selection?8:16*!!e.docChanged}class ub{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let i=ug(e,t),n=this;for(let t of((8&i||16&i&&this.touches(e))&&(n=new ub(n.source,0)),4&i&&0==n.state&&(n=new ub(this.source,1)),n=n.updateFor(e,i),e.effects))if(t.is(ut))n=new ub(n.source,1,t.value);else if(t.is(ui))n=new ub(n.source,0);else if(t.is(uv))for(let e of t.value)e.source==n.source&&(n=e);return n}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(h7(e.state))}}class ux extends ub{constructor(e,t,i,n,r,s){super(e,3,t),this.limit=i,this.result=n,this.from=r,this.to=s}hasResult(){return!0}updateFor(e,t){var i;if(!(3&t))return this.map(e.changes);let n=this.result;n.map&&!e.changes.empty&&(n=n.map(n,e.changes));let r=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),o=h7(e.state);if(o>s||!n||2&t&&(h7(e.startState)==this.from||oe.map(e=>e.map(t))}),uy=eC.define(),uw=el.define({create:()=>ud.start(),update:(e,t)=>e.update(t),provide:e=>[r9.from(e,e=>e.tooltip),ro.contentAttributes.from(e,e=>e.attrs)]});function uk(e,t){let i=t.completion.apply||t.completion.label,n=e.state.field(uw).active.find(e=>e.source==t.source);return n instanceof ux&&("string"==typeof i?e.dispatch(Object.assign(Object.assign({},function(e,t,i,n){let{main:r}=e.selection,s=i-r.from,o=n-r.from;return Object.assign(Object.assign({},e.changeByRange(a=>{if(a!=r&&i!=n&&e.sliceDoc(a.from+s,a.from+o)!=e.sliceDoc(i,n))return{range:a};let l=e.toText(t);return{changes:{from:a.from+s,to:n==r.from?a.to:a.from+o,insert:l},range:K.cursor(a.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,i,n.from,n.to)),{annotations:h6.of(t.completion)})):i(e,t.completion,n.from,n.to),!0)}const uS=e=>new uh(e,uw,uk);function uQ(e,t="option"){return i=>{let n=i.state.field(uw,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+r*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),i.dispatch({effects:uy.of(a)}),!0}}const uA=e=>!!e.state.field(uw,!1)&&(e.dispatch({effects:ut.of(!0)}),!0);class u${constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const uC=iq.fromClass(class{constructor(e){for(let t of(this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,e.state.field(uw).active))t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(uw),i=e.state.facet(us);if(!e.selectionSet&&!e.docChanged&&e.startState.field(uw)==t)return;let n=e.transactions.some(e=>{let t=ug(e,i);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t50&&Date.now()-i.time>1e3){for(let e of i.context.abortListeners)try{e()}catch(e){iM(this.view.state,e)}i.context.abortListeners=null,this.running.splice(t--,1)}else i.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(ut)))&&(this.pendingStart=!0);let r=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),r):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(uw);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(us).updateSyncTime))}startQuery(e){let{state:t}=this.view,i=h7(t),n=new h2(t,i,e.explicit,this.view),r=new u$(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:ui.of(null)}),iM(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(us).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],i=this.view.state.facet(us),n=this.view.state.field(uw);for(let r=0;re.source==s.active.source);if(o&&o.isPending){if(null==s.done){let e=new ub(s.active.source,0);for(let t of s.updates)e=e.update(t,i);e.isPending||t.push(e)}else this.startQuery(o)}}(t.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:uv.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(uw,!1);if(t&&t.tooltip&&this.view.state.facet(us).closeOnBlur){let i=t.open&&si(this.view,t.open.tooltip);i&&i.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:ui.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:ut.of(!1)}),20),this.composing=0}}}),uP="object"==typeof navigator&&/Win/.test(navigator.platform),uZ=ec.highest(ro.domEventHandlers({keydown(e,t){let i=t.state.field(uw,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||e.key.length>1||e.ctrlKey&&!(uP&&e.altKey)||e.metaKey)return!1;let n=i.open.options[i.open.selected],r=i.active.find(e=>e.source==n.source),s=n.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&uk(t,n),!1}})),uE=ro.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",whiteSpace:"pre-line"},".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:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class uT{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class uR{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,W.TrackDel),i=e.mapPos(this.to,1,W.TrackDel);return null==t||null==i?null:new uR(this.field,t,i)}}class uM{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],r=e.doc.lineAt(t),s=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(i.length){let i=s,o=/^\t*/.exec(r)[0].length;for(let t=0;tnew uR(e.field,n[e.line]+e.from,n[e.line]+e.to))}}static parse(e){let t=[],i=[],n=[],r;for(let s of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let e=r[1]?+r[1]:null,o=r[2]||r[3]||"",a=-1,l=o.replace(/\\[{}]/g,e=>e[1]);for(let i=0;i=a&&r.field++}n.push(new uT(a,i.length,r.index,r.index+l.length)),s=s.slice(0,r.index)+o+s.slice(r.index+r[0].length)}s=s.replace(/\\([{}])/g,(e,t,r)=>{for(let e of n)e.line==i.length&&e.from>r&&(e.from--,e.to--);return t}),i.push(s)}return new uM(i,n)}}let uX=t1.widget({widget:new class extends tK{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),uD=t1.mark({class:"cm-snippetField"});class uB{constructor(e,t){this.ranges=e,this.active=t,this.deco=t1.set(e.map(e=>(e.from==e.to?uX:uD).range(e.from,e.to)))}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new uB(t,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}}const uq=eC.define({map:(e,t)=>e&&e.map(t)}),uL=eC.define(),uV=el.define({create:()=>null,update(e,t){for(let i of t.effects){if(i.is(uq))return i.value;if(i.is(uL)&&e)return new uB(e.ranges,i.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ro.decorations.from(e,e=>e?e.deco:t1.none)});function u_(e,t){return K.create(e.filter(e=>e.field==t).map(e=>K.range(e.from,e.to)))}function uF(e){return({state:t,dispatch:i})=>{let n=t.field(uV,!1);if(!n||e<0&&0==n.active)return!1;let r=n.active+e,s=e>0&&!n.ranges.some(t=>t.field==r+e);return i(t.update({selection:u_(n.ranges,r),effects:uq.of(s?null:new uB(n.ranges,r)),scrollIntoView:!0})),!0}}const uW=[{key:"Tab",run:uF(1),shift:uF(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(uV,!1)&&(t(e.update({effects:uq.of(null)})),!0)}],uj=ei.define({combine:e=>e.length?e[0]:uW}),uz=ec.highest(rp.compute([uj],e=>e.facet(uj)));function uY(e,t){let i;return Object.assign(Object.assign({},t),{apply:(i=uM.parse(e),(e,t,n,r)=>{let{text:s,ranges:o}=i.instantiate(e.state,n),{main:a}=e.state.selection,l={changes:{from:n,to:r==a.from?a.to:r,insert:O.of(s)},scrollIntoView:!0,annotations:t?[h6.of(t),eP.userEvent.of("input.complete")]:void 0};if(o.length&&(l.selection=u_(o,0)),o.some(e=>e.field>0)){let t=new uB(o,0),i=l.effects=[uq.of(t)];void 0===e.state.field(uV,!1)&&i.push(eC.appendConfig.of([uV,uz,uI,uE]))}e.dispatch(e.state.update(l))})})}const uI=ro.domEventHandlers({mousedown(e,t){let i=t.state.field(uV,!1),n;if(!i||null==(n=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let r=i.ranges.find(e=>e.from<=n&&e.to>=n);return!!r&&r.field!=i.active&&(t.dispatch({selection:u_(i.ranges,r.field),effects:uq.of(i.ranges.some(e=>e.field>r.field)?new uB(i.ranges,r.field):null),scrollIntoView:!0}),!0)}}),uU={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},uN=eC.define({map(e,t){let i=t.mapPos(e,-1,W.TrackAfter);return null==i?void 0:i}}),uG=new class extends eq{};uG.startSide=1,uG.endSide=-1;const uH=el.define({create:()=>eF.empty,update(e,t){if(e=e.map(t.changes),t.selection){let i=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=i.from&&e<=i.to})}for(let i of t.effects)i.is(uN)&&(e=e.update({add:[uG.range(i.value,i.value+1)]}));return e}}),uJ="()[]{}<>«»»«[]{}";function uK(e){for(let t=0;t{if((u1?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(n.length>2||2==n.length&&1==$(Q(n,0))||t!=r.from||i!=r.to)return!1;let s=function(e,t){let i=u0(e,e.selection.main.head),n=i.brackets||uU.brackets;for(let r of n){let s=uK(Q(r,0));if(t==r)return s==r?function(e,t,i,n){let r=n.stringPrefixes||uU.stringPrefixes,s=null,o=e.changeByRange(n=>{if(!n.empty)return{changes:[{insert:t,from:n.from},{insert:t,from:n.to}],effects:uN.of(n.to+t.length),range:K.range(n.anchor+t.length,n.head+t.length)};let o=n.head,a=u4(e.doc,o),l;if(a==t){if(u7(e,o))return{changes:{insert:t+t,from:o},effects:uN.of(o+t.length),range:K.cursor(o+t.length)};if(u3(e,o)){let n=i&&e.sliceDoc(o,o+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+n.length,insert:n},range:K.cursor(o+n.length)}}}else if(i&&e.sliceDoc(o-2*t.length,o)==t+t&&(l=u9(e,o-2*t.length,r))>-1&&u7(e,l))return{changes:{insert:t+t+t+t,from:o},effects:uN.of(o+t.length),range:K.cursor(o+t.length)};else if(e.charCategorizer(o)(a)!=eM.Word&&u9(e,o,r)>-1&&!function(e,t,i,n){let r=o_(e).resolveInner(t,-1),s=n.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+i.length+s)),a=o.indexOf(i);if(!a||a>-1&&n.indexOf(o.slice(0,a))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>i.length+a;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let l=r.to==t&&r.parent;if(!l)break;r=l}return!1}(e,o,t,r))return{changes:{insert:t+t,from:o},effects:uN.of(o+t.length),range:K.cursor(o+t.length)};return{range:s=n}});return s?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,n.indexOf(r+r+r)>-1,i):function(e,t,i,n){let r=null,s=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:i,from:s.to}],effects:uN.of(s.to+t.length),range:K.range(s.anchor+t.length,s.head+t.length)};let o=u4(e.doc,s.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:t+i,from:s.head},effects:uN.of(s.head+t.length),range:K.cursor(s.head+t.length)}:{range:r=s}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,s,i.before||uU.before);if(t==s&&u3(e,e.selection.main.from))return function(e,t,i){let n=null,r=e.changeByRange(t=>t.empty&&u4(e.doc,t.head)==i?{changes:{from:t.head,to:t.head+i.length,insert:i},range:K.cursor(t.head+i.length)}:n={range:t});return n?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(e,0,s)}return null}(e.state,n);return!!s&&(e.dispatch(s),!0)}),u5=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=u0(e,e.selection.main.head).brackets||uU.brackets,n=null,r=e.changeByRange(t=>{if(t.empty){var r,s;let n;let o=(r=e.doc,s=t.head,$(Q(n=r.sliceString(s-2,s),0))==n.length?n:n.slice(1));for(let n of i)if(n==o&&u4(e.doc,t.head)==uK(Q(n,0)))return{changes:{from:t.head-n.length,to:t.head+n.length},range:K.cursor(t.head-n.length)}}return{range:n=t}});return n||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function u3(e,t){let i=!1;return e.field(uH).between(0,e.doc.length,e=>{e==t&&(i=!0)}),i}function u4(e,t){let i=e.sliceString(t,t+2);return i.slice(0,$(Q(i,0)))}function u7(e,t){let i=o_(e).resolveInner(t+1);return i.parent&&i.from==t}function u9(e,t,i){let n=e.charCategorizer(t);if(n(e.sliceDoc(t-1,t))!=eM.Word)return t;for(let r of i){let i=t-r.length;if(e.sliceDoc(i,t)==r&&n(e.sliceDoc(i-1,i))!=eM.Word)return i}return -1}const u6=[{key:"Ctrl-Space",run:uA},{mac:"Alt-`",run:uA},{key:"Escape",run:e=>{let t=e.state.field(uw,!1);return!!(t&&t.active.some(e=>0!=e.state))&&(e.dispatch({effects:ui.of(null)}),!0)}},{key:"ArrowDown",run:uQ(!0)},{key:"ArrowUp",run:uQ(!1)},{key:"PageDown",run:uQ(!0,"page")},{key:"PageUp",run:uQ(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(uw,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.facet(us).defaultKeymap?[u6]:[]));class ce{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class ct{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=e,r=i.facet(cf).markerFilter;r&&(n=r(n,i));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new eW,a=[],l=0;for(let e=0;;){let t,n,r=e==s.length?null:s[e];if(!r&&!a.length)break;for(a.length?(t=l,n=a.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8)):(t=r.from,n=r.to,a.push(r),e++);ei.from||i.to==t))a.push(i),e++,n=Math.min(i.to,n);else{n=Math.min(i.from,n);break}}let h=cw(a);if(a.some(e=>e.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from))o.add(t,t,t1.widget({widget:new cm(h),diagnostics:a.slice()}));else{let e=a.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,t1.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:a.slice(),inclusiveEnd:a.some(e=>e.to>n)}))}l=n;for(let e=0;e{if(!(t&&0>r.diagnostics.indexOf(t))){if(n){if(0>r.diagnostics.indexOf(n.diagnostic))return!1;n=new ce(n.from,i,n.diagnostic)}else n=new ce(e,i,t||r.diagnostics[0])}}),n}function cn(e,t){let i=t.pos,n=t.end||i,r=e.state.facet(cf).hideOn(e,i,n);if(null!=r)return r;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(cs))||e.changes.touchesRange(s.from,Math.max(s.to,n)))}function cr(e,t){return e.field(cl,!1)?t:t.concat(eC.appendConfig.of(cA))}const cs=eC.define(),co=eC.define(),ca=eC.define(),cl=el.define({create:()=>new ct(t1.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),n=null,r=e.panel;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);n=ci(i,e.selected.diagnostic,r)||ci(i,null,r)}!i.size&&r&&t.state.facet(cf).autoPanel&&(r=null),e=new ct(i,r,n)}for(let i of t.effects)if(i.is(cs)){let n=t.state.facet(cf).autoPanel?i.value.length?cb.open:null:e.panel;e=ct.init(i.value,n,t.state)}else i.is(co)?e=new ct(e.diagnostics,i.value?cb.open:null,e.selected):i.is(ca)&&(e=new ct(e.diagnostics,e.panel,i.value));return e},provide:e=>[sh.from(e,e=>e.panel),ro.decorations.from(e,e=>e.diagnostics)]}),ch=t1.mark({class:"cm-lintRange cm-lintRange-active"});function cu(e,t){return l8("ul",{class:"cm-tooltip-lint"},t.map(t=>cO(e,t,!1)))}const cc=e=>{let t=e.state.field(cl,!1);return!!t&&!!t.panel&&(e.dispatch({effects:co.of(!1)}),!0)},cd=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(cl,!1);t&&t.panel||e.dispatch({effects:cr(e.state,[co.of(!0)])});let i=ss(e,cb.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(cl,!1);if(!t)return!1;let i=e.state.selection.main,n=t.diagnostics.iter(i.to+1);return(!!n.value||!!(n=t.diagnostics.iter(0)).value&&(n.from!=i.from||n.to!=i.to))&&(e.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)}}];iq.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(cf);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e{n.push(i),clearTimeout(r),n.length==e.length?t(n):r=setTimeout(()=>t(n),200)},i)}(t.map(e=>Promise.resolve(e(this.view))),t=>{if(this.view.state.doc==e.doc){var i,n;this.view.dispatch((i=this.view.state,n=t.reduce((e,t)=>e.concat(t)),{effects:cr(i,[cs.of(n)])}))}},e=>{iM(this.view.state,e)})}}update(e){let t=e.state.facet(cf);(e.docChanged||t!=e.startState.facet(cf)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});const cf=ei.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},eB(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))});function cp(e){let t=[];if(e)n:for(let{name:i}of e){for(let e=0;ee.toLowerCase()==n.toLowerCase())){t.push(n);continue n}}t.push("")}return t}function cO(e,t,i){var n;let r=i?cp(t.actions):[];return l8("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},l8("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(n=t.actions)||void 0===n?void 0:n.map((i,n)=>{let s=!1,o=n=>{if(n.preventDefault(),s)return;s=!0;let r=ci(e.state.field(cl).diagnostics,t);r&&i.apply(e,r.from,r.to)},{name:a}=i,l=r[n]?a.indexOf(r[n]):-1,h=l<0?a:[a.slice(0,l),l8("u",a.slice(l,l+1)),a.slice(l+1)];return l8("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${r[n]})"`}.`},h)}),t.source&&l8("div",{class:"cm-diagnosticSource"},t.source))}class cm extends tK{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return l8("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cg{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=cO(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class cb{constructor(e){this.view=e,this.items=[],this.list=l8("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)cc(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:i}=this.items[this.selectedIndex],n=cp(i.actions);for(let r=0;r{for(let t=0;tcc(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(cl).selected;if(!e)return -1;for(let t=0;t{for(let e of a.diagnostics){if(s.has(e))continue;s.add(e);let o=-1,a;for(let t=i;ti&&(this.items.splice(i,o-i),n=!0)),t&&a.diagnostic==t.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),r=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),i++}});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ci(this.view.state.field(cl).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:ca.of(t)})}static open(e){return new cb(e)}}function cx(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,')`}function cv(e){return cx(``,'width="6" height="3"')}const cy=ro.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:cv("#d11")},".cm-lintRange-warning":{backgroundImage:cv("orange")},".cm-lintRange-info":{backgroundImage:cv("#999")},".cm-lintRange-hint":{backgroundImage:cv("#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}}});function cw(e){let t="hint",i=1;for(let r of e){var n;let e="error"==(n=r.severity)?4:"warning"==n?3:"info"==n?2:1;e>i&&(i=e,t=r.severity)}return t}class ck extends su{constructor(e){super(),this.diagnostics=e,this.severity=cw(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=e.state.facet(c$).tooltipFilter;return n&&(i=n(i,e.state)),i.length&&(t.onmouseover=()=>(function(e,t,i){function n(){let n,r=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(r.from)&&e.dispatch({effects:cS.of({pos:r.from,above:!1,clip:!1,create:()=>({dom:cu(e,i),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,n=i=>{let r=t.getBoundingClientRect();if(!(i.clientX>r.left-10)||!(i.clientXr.top-10)||!(i.clientY{clearTimeout(s),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(s),s=setTimeout(n,r)}})(e,t,i)),t}}el.define({create:()=>eF.empty,update(e,t){e=e.map(t.changes);let i=t.state.facet(c$).markerFilter;for(let n of t.effects)if(n.is(cs)){let r=n.value;i&&(r=i(r||[],t.state)),e=function(e,t){let i=Object.create(null);for(let n of t){let t=e.lineAt(n.from);(i[t.from]||(i[t.from]=[])).push(n)}let n=[];for(let e in i)n.push(new ck(i[e]).range(+e));return eF.of(n,!0)}(t.state.doc,r.slice(0))}return e}});const cS=eC.define(),cQ=el.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=cn(t,e)?null:Object.assign(Object.assign({},e),{pos:t.changes.mapPos(e.pos)})),t.effects.reduce((e,t)=>t.is(cS)?t.value:e,e)),provide:e=>r9.from(e)});ro.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:cx('')},".cm-lint-marker-warning":{content:cx('')},".cm-lint-marker-error":{content:cx('')}});const cA=[cl,ro.decorations.compute([cl],e=>{let{selected:t,panel:i}=e.field(cl);return t&&i&&t.from!=t.to?t1.set([ch.range(t.from,t.to)]):t1.none}),function(e,t={}){let i=eC.define(),n=el.define({create:()=>[],update(e,n){if(e.length&&(t.hideOnChange&&(n.docChanged||n.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(n,e))),n.docChanged)){let t=[];for(let i of e){let e=n.changes.mapPos(i.pos,-1,W.TrackDel);if(null!=e){let r=Object.assign(Object.create(null),i);r.pos=e,null!=r.end&&(r.end=n.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of n.effects)t.is(i)&&(e=t.value),t.is(sn)&&(e=[]);return e},provide:e=>r6.from(e)});return{active:n,extension:[n,iq.define(r=>new st(r,e,n,i,t.hoverTime||300)),se]}}(function(e,t,i){let{diagnostics:n}=e.state.field(cl),r,s=-1,o=-1;n.between(t-+(i<0),t+ +(i>0),(e,n,{spec:a})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t({dom:cu(e,r)})}:null},{hideOn:cn}),cy],c$=ei.define({combine:e=>eB(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}),cC=[function(e={}){return[sQ.of(e),sm(),sC]}(),sE,function(e={}){return[rW.of(e),rj||(rj=iq.fromClass(class{constructor(e){this.view=e,this.decorations=t1.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(rW)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new rq({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:r}=i.state,s=Q(t[0],0);if(9==s){let e=r.lineAt(n),t=i.state.tabSize,s=e0(e.text,t,n-e.from);return t1.replace({widget:new rY((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=t1.replace({widget:new rz(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(rW);e.startState.facet(rW)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}(),function(e={}){return[a9,a7.of(e),ro.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?a8:"historyRedo"==e.inputType?le:null;return!!i&&(e.preventDefault(),i(t))}})]}(),function(e={}){var t;let i=Object.assign(Object.assign({},av),e),n=new ay(i,!0),r=new ay(i,!1),s=iq.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(oG)!=e.state.facet(oG)||e.startState.field(ah,!1)!=e.state.field(ah,!1)||o_(e.startState)!=o_(e.state)||i.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new eW;for(let i of e.viewportLineBlocks){let s=au(e.state,i.from,i.to)?r:ar(e.state,i.from,i.to)?n:null;s&&t.add(i.from,i.from,s)}return t.finish()}}),{domEventHandlers:o}=i;return[s,(t={class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||eF.empty},initialSpacer:()=>new ay(i,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,i)=>{if(o.click&&o.click(e,t,i))return!0;let n=au(e.state,t.from,t.to);if(n)return e.dispatch({effects:aa.of(n)}),!0;let r=ar(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:ao.of(r)}),!0)}})},[sm(),sp.of(Object.assign(Object.assign({},sf),t))]),am()]}(),function(e={}){return[r$.of(e),rP,rE,rR,iP.of(!0)]}(),[rX,rD],eD.allowMultipleSelections.of(!0),eD.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let s=i.sliceString(r.from,n);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let i=o5(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=o2(o,i);n!=r&&l.push({from:t.from,to:t.from+n.length,insert:r})}return l.length?[e,{changes:l,sequential:!0}]:e}),(M={fallback:!0},e=[a$],aC instanceof ak&&(aC.module&&e.push(ro.styleModule.of(aC.module)),t=aC.themeType),(null==M?void 0:M.fallback)?e.push(aQ.of(aC)):t?e.push(aS.computeN([ro.darkTheme],e=>e.facet(ro.darkTheme)==("dark"==t)?[aC]:[])):e.push(aS.of(aC)),e),function(e={}){return[aE.of(e),aX]}(),[u2,uH],function(e={}){return[uZ,uw,us.of(e),uC,u8,uE]}(),(i=e=>e.altKey&&0==e.button,ro.mouseSelectionStyle.of((e,t)=>{let n,r;return i(t)?(n=rN(e,t),r=e.state.selection,n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,s){let o=rN(e,t);if(!o)return r;let a=function(e,t,i){let n=Math.min(t.line,i.line),r=Math.max(t.line,i.line),s=[];if(t.off>2e3||i.off>2e3||t.col<0||i.col<0){let o=Math.min(t.off,i.off),a=Math.max(t.off,i.off);for(let t=n;t<=r;t++){let i=e.doc.line(t);i.length<=a&&s.push(K.range(i.from+o,i.to+a))}}else{let o=Math.min(t.col,i.col),a=Math.max(t.col,i.col);for(let t=n;t<=r;t++){let i=e.doc.line(t),n=e1(i.text,o,e.tabSize,!0);if(n<0)s.push(K.cursor(i.to));else{let t=e1(i.text,a,e.tabSize);s.push(K.range(i.from+n,i.from+t))}}}return s}(e.state,n,o);return a.length?s?K.create(a.concat(r.ranges)):K.create(a):r}}:null):null})),function(e={}){let[t,i]=rG[e.key||"Alt"],n=iq.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||i(e))},keyup(e){e.keyCode!=t&&i(e)||this.set(!1)},mousemove(e){this.set(i(e))}}});return[n,ro.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(n))||void 0===t?void 0:t.isDown)?rH:null})]}(),rU,n=[hx,hb],rp.of([...u5,...l9,...hN,{key:"Mod-z",run:a8,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:le,preventDefault:!0},{linux:"Ctrl-Shift-z",run:le,preventDefault:!0},{key:"Mod-u",run:lt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:li,preventDefault:!0},...af,...u6,...cd])];var cP={},cZ=cP={};function cE(){throw Error("setTimeout has not been defined")}function cT(){throw Error("clearTimeout has not been defined")}function cR(e){if(L===setTimeout)return setTimeout(e,0);if((L===cE||!L)&&setTimeout)return L=setTimeout,setTimeout(e,0);try{return L(e,0)}catch(t){try{return L.call(null,e,0)}catch(t){return L.call(this,e,0)}}}!function(){try{L="function"==typeof setTimeout?setTimeout:cE}catch(e){L=cE}try{V="function"==typeof clearTimeout?clearTimeout:cT}catch(e){V=cT}}();var cM=[],cX=!1,cD=-1;function cB(){cX&&_&&(cX=!1,_.length?cM=_.concat(cM):cD=-1,cM.length&&cq())}function cq(){if(!cX){var e=cR(cB);cX=!0;for(var t=cM.length;t;){for(_=cM,cM=[];++cD1)for(var i=1;it%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new c_(e,[],t,i,i,0,[],0,n?new cF(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=65535&e,{parser:r}=this.p,s=this.reducePos=2e3&&!(null===(t=this.p.parser.nodeSet.types[n])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(n,l)}storeNode(e,t,i,n=4,r=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]0&&0==e.buffer[n-4]&&e.buffer[n-1]>-1){if(t==i)return;if(e.buffer[n-2]>=t){e.buffer[n-2]=i;return}}}if(r&&this.pos!=i){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4]){let e=!1;for(let t=r;t>0&&this.buffer[t-2]>i;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;r>0&&this.buffer[r-2]>i;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,n>4&&(n-=4)}this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=i,this.buffer[r+3]=n}else this.buffer.push(e,t,i,n)}shift(e,t,i,n){if(131072&e)this.pushState(65535&e,this.pos);else if((262144&e)==0){let{parser:r}=this.p;(n>this.pos||t<=r.maxNode)&&(this.pos=n,r.stateFlag(e,1)||(this.reducePos=n)),this.pushState(e,i),this.shiftContext(t,i),t<=r.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){65536&e?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new c_(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new cW(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==i)return!1;if((65536&i)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let n=0,r;n1&t&&e==n)||i.push(t[e],n)}t=i}let i=[];for(let e=0;e>19,n=65535&t,r=this.stack.length-3*i;if(r<0||0>e.getGoto(this.stack[r],n,!1)){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,r)=>{if(!t.includes(n))return t.push(n),e.allActions(n,t=>{if(393216&t);else if(65536&t){let i=(t>>19)-r;if(i>1){let n=65535&t,r=this.stack.length-3*i;if(r>=0&&e.getGoto(this.stack[r],n,!1)>=0)return i<<19|65536|n}}else{let e=i(t,r+1);if(null!=e)return e}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class cF{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class cW{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e>>19;0==t?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],65535&e,!0);this.state=i}}class cj{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new cj(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new cj(this.stack,this.pos,this.index)}}function cz(e,t=Uint16Array){if("string"!=typeof e)return e;let i=null;for(let n=0,r=0;n=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,i=!0),s+=r,i)break;s*=46}i?i[r++]=s:i=new t(s)}return i}class cY{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const cI=new cY;class cU{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=cI,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(n==this.ranges.length-1)return null;let e=this.ranges[++n];r+=e.from-i.to,i=e}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t=this.chunk2Pos&&it.to&&(this.chunk2=this.chunk2.slice(0,t.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(null==i||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=cI,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class cN{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;cJ(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}cN.prototype.contextual=cN.prototype.fallback=cN.prototype.extend=!1;class cG{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data="string"==typeof e?cz(e):e}token(e,t){let i=e.pos,n=0;for(;;){let i=e.next<0,r=e.resolveOffset(1,1);if(cJ(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(!i&&n++,null==r)break;e.reset(r,e.token)}n&&(e.reset(i,e.token),e.acceptToken(this.elseToken,n))}}cG.prototype.contextual=cN.prototype.fallback=cN.prototype.extend=!1;class cH{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function cJ(e,t,i,n,r,s){let o=0,a=1<0){let i=e[n];if(l.allows(i)&&(-1==t.token.value||t.token.value==i||function(e,t,i,n){let r=cK(i,n,t);return r<0||cK(i,n,e)h&&65535==e[i+3*u-3]){o=e[i+3*u-1];continue}for(;h>1,s=i+r+(r<<1),a=e[s],l=e[s+1]||65536;if(n=l)h=r+1;else{o=e[s+2],t.advance();continue i}}break}}function cK(e,t,i){for(let n=t,r;65535!=(r=e[n]);n++)if(r==i)return n-t;return -1}const c0=void 0!==cP&&cP.env&&/\bparse\b/.test(void 0);let c1=null;function c2(e,t,i){let n=e.cursor(B.IncludeAnonymous);for(n.moveTo(t);;)if(!(i<0?n.childBefore(t):n.childAfter(t)))for(;;){if((i<0?n.tot)&&!n.type.isError)return i<0?Math.max(0,Math.min(n.to-1,t-25)):Math.min(e.length,Math.max(n.from+1,t+25));if(i<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return i<0?0:e.length}}class c5{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?c2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?c2(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=s,null;if(r instanceof s_){if(s==e){if(s=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+r.length}}}class c3{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new cY)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:r}=n,s=n.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let n=0;nh.end+25&&(a=Math.max(h.lookAhead,a)),0!=h.value)){let n=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!l.extend&&(i=h,t>n))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),i||e.pos!=this.stream.end||((i=new cY).value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new cY,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:t}=i.p;for(let n=0;n=0&&i.p.parser.dialect.allows(r>>1)){(1&r)==0?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let t=0;t4*e.bufferLength?new c5(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,i=this.stacks,n=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[e]=i;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;sn)r.push(o);else{if(this.advanceStack(o,r,i))continue;e||(e=[],t=[]),e.push(o);let n=this.tokens.getMainToken(o);t.push(n.value,n.end)}break}}if(!r.length){let t=e&&function(e){let t=null;for(let i of e){let e=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=e&&i.pos>e)&&i.p.parser.stateFlag(i.state,2)&&(!t||t.scorethis.stoppedAt?e[0]:this.runRecovery(e,t,r);if(i)return c0&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort((e,t)=>t.score-e.score);r.length>e;)r.pop();r.some(e=>e.reducePos>n)&&this.recovering--}else if(r.length>1){r:for(let e=0;e500&&n.buffer.length>500){if((t.score-n.score||t.buffer.length-n.buffer.length)>0)r.splice(i--,1);else{r.splice(e--,1);continue r}}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e ":"";if(null!=this.stoppedAt&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,i=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(n);o;){let n=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(n>-1&&o.length&&(!t||(o.prop(sM.contextHash)||0)==i))return e.useNode(o,n),c0&&console.log(s+this.stackID(e)+` (via reuse of ${r.getName(o.type.id)})`),!0;if(!(o instanceof s_)||0==o.children.length||o.positions[0]>0)break;let a=o.children[0];if(a instanceof s_&&0==o.positions[0])o=a;else break}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),c0&&console.log(s+this.stackID(e)+` (via always-reduce ${r.getName(65535&o)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let o=0;on?t.push(d):i.push(d)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return c7(e,t),!0}}runRecovery(e,t,i){let n=null,r=!1;for(let s=0;s ":"";if(o.deadEnd&&(r||(r=!0,o.restart(),c0&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let u=o.split(),c=h;for(let e=0;u.forceReduce()&&e<10&&(c0&&console.log(c+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));e++)c0&&(c=this.stackID(u)+" -> ");for(let e of o.recoverByInsert(a))c0&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,i);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),c0&&console.log(h+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),c7(o,i)):(!n||n.scoree;class c8{constructor(e){this.start=e.start,this.shift=e.shift||c6,this.reduce=e.reduce||c6,this.reuse=e.reuse||c6,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}class de extends s9{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let i=0;ie.topRules[t][1]),n=[];for(let e=0;e=0)r(n,e,t[i++]);else{let s=t[i+-n];for(let o=-n;o>0;o--)r(t[i++],e,s);i++}}}this.nodeSet=new sq(t.map((t,r)=>sB.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:n[r],top:i.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=cz(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e"number"==typeof e?new cN(s,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new c4(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return -1;for(let r=n[t+1];;){let t=n[r++],s=1&t,o=n[r++];if(s&&i)return o;for(let i=r+(t>>1);r0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let i=this.stateSlot(e,1);null==n;i+=3){if(65535==this.data[i]){if(1==this.data[i+1])i=dt(this.data,i+2);else break}n=t(dt(this.data,i+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1==this.data[i+1])i=dt(this.data,i+2);else break}if((1&this.data[i+2])==0){let e=this.data[i+1];t.some((t,i)=>1&i&&t==e)||t.push(this.data[i],e)}}return t}configure(e){let t=Object.assign(Object.create(de.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let i=e.tokenizers.find(e=>e.from==t);return i?i.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=e.specializers.find(e=>e.from==i.external);if(!r)return i;let s=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[n]=di(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let n of e.split(" ")){let e=t.indexOf(n);e>=0&&(i[e]=!0)}let n=null;for(let e=0;ee.external(i,n)<<1|t}return e.get}const dn=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],dr=new c8({start:!1,shift:(e,t)=>5==t||6==t||318==t?e:319==t,strict:!1}),ds=new cH((e,t)=>{let{next:i}=e;(125==i||-1==i||t.context)&&e.acceptToken(316)},{contextual:!0,fallback:!0}),da=new cH((e,t)=>{let{next:i}=e,n;!(dn.indexOf(i)>-1)&&(47==i&&(47==(n=e.peek(1))||42==n)||125==i||59==i||-1==i||t.context||e.acceptToken(314))},{contextual:!0}),dl=new cH((e,t)=>{91!=e.next||t.context||e.acceptToken(315)},{contextual:!0}),dh=new cH((e,t)=>{let{next:i}=e;if(43==i||45==i){if(e.advance(),i==e.next){e.advance();let i=!t.context&&t.canShift(1);e.acceptToken(i?1:2)}}else 63==i&&46==e.peek(1)&&(e.advance(),e.advance(),(e.next<48||e.next>57)&&e.acceptToken(3))},{contextual:!0});function du(e,t){return e>=65&&e<=90||e>=97&&e<=122||95==e||e>=192||!t&&e>=48&&e<=57}const dc=new cH((e,t)=>{if(60!=e.next||!t.dialectEnabled(0)||(e.advance(),47==e.next))return;let i=0;for(;dn.indexOf(e.next)>-1;)e.advance(),i++;if(du(e.next,!0)){for(e.advance(),i++;du(e.next,!1);)e.advance(),i++;for(;dn.indexOf(e.next)>-1;)e.advance(),i++;if(44==e.next)return;for(let t=0;;t++){if(7==t){if(!du(e.next,!0))return;break}if(e.next!="extends".charCodeAt(t))break;e.advance(),i++}}e.acceptToken(4,-i)}),dd=op({"get set async static":oM.modifier,"for while do if else switch try catch finally return throw break continue default case":oM.controlKeyword,"in of await yield void typeof delete instanceof":oM.operatorKeyword,"let var const using function class extends":oM.definitionKeyword,"import export from":oM.moduleKeyword,"with debugger as new":oM.keyword,TemplateString:oM.special(oM.string),super:oM.atom,BooleanLiteral:oM.bool,this:oM.self,null:oM.null,Star:oM.modifier,VariableName:oM.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":oM.function(oM.variableName),VariableDefinition:oM.definition(oM.variableName),Label:oM.labelName,PropertyName:oM.propertyName,PrivatePropertyName:oM.special(oM.propertyName),"CallExpression/MemberExpression/PropertyName":oM.function(oM.propertyName),"FunctionDeclaration/VariableDefinition":oM.function(oM.definition(oM.variableName)),"ClassDeclaration/VariableDefinition":oM.definition(oM.className),"NewExpression/VariableName":oM.className,PropertyDefinition:oM.definition(oM.propertyName),PrivatePropertyDefinition:oM.definition(oM.special(oM.propertyName)),UpdateOp:oM.updateOperator,"LineComment Hashbang":oM.lineComment,BlockComment:oM.blockComment,Number:oM.number,String:oM.string,Escape:oM.escape,ArithOp:oM.arithmeticOperator,LogicOp:oM.logicOperator,BitOp:oM.bitwiseOperator,CompareOp:oM.compareOperator,RegExp:oM.regexp,Equals:oM.definitionOperator,Arrow:oM.function(oM.punctuation),": Spread":oM.punctuation,"( )":oM.paren,"[ ]":oM.squareBracket,"{ }":oM.brace,"InterpolationStart InterpolationEnd":oM.special(oM.brace),".":oM.derefOperator,", ;":oM.separator,"@":oM.meta,TypeName:oM.typeName,TypeDefinition:oM.definition(oM.typeName),"type enum interface implements namespace module declare":oM.definitionKeyword,"abstract global Privacy readonly override":oM.modifier,"is keyof unique infer asserts":oM.operatorKeyword,JSXAttributeValue:oM.attributeValue,JSXText:oM.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":oM.angleBracket,"JSXIdentifier JSXNameSpacedName":oM.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":oM.attributeName,"JSXBuiltin/JSXIdentifier":oM.standard(oM.tagName)}),df={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,const:52,extends:56,this:60,true:68,false:68,null:80,void:84,typeof:88,super:104,new:138,delete:150,yield:159,await:163,class:168,public:231,private:231,protected:231,readonly:233,instanceof:252,satisfies:255,in:256,import:290,keyof:347,unique:351,infer:357,asserts:393,is:395,abstract:415,implements:417,type:419,let:422,var:424,using:427,interface:433,enum:437,namespace:443,module:445,declare:449,global:453,for:472,of:481,while:484,with:488,do:492,if:496,else:498,switch:502,case:508,try:514,catch:518,finally:522,return:526,throw:530,break:534,continue:538,debugger:542},dp={__proto__:null,async:125,get:127,set:129,declare:191,public:193,private:193,protected:193,static:195,abstract:197,override:199,readonly:205,accessor:207,new:399},dO={__proto__:null,"<":189},dm=de.deserialize({version:14,states:"$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D_O.QQlO'#DeO.bQlO'#DpO%[QlO'#DxO0fQlO'#EQOOQ!0Lf'#EY'#EYO1PQ`O'#EVOOQO'#En'#EnOOQO'#Ij'#IjO1XQ`O'#GrO1dQ`O'#EmO1iQ`O'#EmO3hQ!0MxO'#JpO6[Q!0MxO'#JqO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#F{O9UQ`O'#FzOOQ!0Lf'#Jq'#JqOOQ!0Lb'#Jp'#JpO9ZQ`O'#GvOOQ['#K]'#K]O9fQ`O'#IWO9kQ!0LrO'#IXOOQ['#J^'#J^OOQ['#I]'#I]Q`QlOOQ`QlOOO9sQ!L^O'#DtO9zQlO'#D|O:RQlO'#EOO9aQ`O'#GrO:YQMhO'#CoO:hQ`O'#ElO:sQ`O'#EwO:xQMhO'#FdO;gQ`O'#GrOOQO'#K^'#K^O;lQ`O'#K^O;zQ`O'#GzO;zQ`O'#G{O;zQ`O'#G}O9aQ`O'#HQOYQ`O'#CeO>jQ`O'#HaO>rQ`O'#HgO>rQ`O'#HiO`QlO'#HkO>rQ`O'#HmO>rQ`O'#HpO>wQ`O'#HvO>|Q!0LsO'#H|O%[QlO'#IOO?XQ!0LsO'#IQO?dQ!0LsO'#ISO9kQ!0LrO'#IUO?oQ!0MxO'#CiO@qQpO'#DjQOQ`OOO%[QlO'#EOOAXQ`O'#ERO:YQMhO'#ElOAdQ`O'#ElOAoQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Do'#DoOOQ!0Lb'#Jt'#JtO%[QlO'#JtOOQO'#Jw'#JwOOQO'#If'#IfOBoQpO'#EeOOQ!0Lb'#Ed'#EdOOQ!0Lb'#J{'#J{OCkQ!0MSO'#EeOCuQpO'#EUOOQO'#Jv'#JvODZQpO'#JwOEhQpO'#EUOCuQpO'#EePEuO&2DjO'#CbPOOO)CD{)CD{OOOO'#I^'#I^OFQO#tO,59UOOQ!0Lh,59U,59UOOOO'#I_'#I_OF`O&jO,59UOFnQ!L^O'#DaOOOO'#Ia'#IaOFuO#@ItO,59yOOQ!0Lf,59y,59yOGTQlO'#IbOGhQ`O'#JrOIgQ!fO'#JrO+}QlO'#JrOInQ`O,5:POJUQ`O'#EnOJcQ`O'#KROJnQ`O'#KQOJnQ`O'#KQOJvQ`O,5;[OJ{Q`O'#KPOOQ!0Ln,5:[,5:[OKSQlO,5:[OMQQ!0MxO,5:dOMqQ`O,5:lON[Q!0LrO'#KOONcQ`O'#J}O9ZQ`O'#J}ONwQ`O'#J}O! PQ`O,5;ZO! UQ`O'#J}O!#ZQ!fO'#JqOOQ!0Lh'#Ci'#CiO%[QlO'#EQO!#yQ!fO,5:qOOQS'#Jx'#JxOOQO-ErOOQ['#Jf'#JfOOQ[,5>s,5>sOOQ[-EbQ!0MxO,5:hO%[QlO,5:hO!@xQ!0MxO,5:jOOQO,5@x,5@xO!AiQMhO,5=^O!AwQ!0LrO'#JgO9UQ`O'#JgO!BYQ!0LrO,59ZO!BeQpO,59ZO!BmQMhO,59ZO:YQMhO,59ZO!BxQ`O,5;XO!CQQ`O'#H`O!CfQ`O'#KbO%[QlO,5;|O!9lQpO,5wQ`O'#HVO9aQ`O'#HXO!D}Q`O'#HXO:YQMhO'#HZO!ESQ`O'#HZOOQ[,5=o,5=oO!EXQ`O'#H[O!EjQ`O'#CoO!EoQ`O,59PO!EyQ`O,59PO!HOQlO,59POOQ[,59P,59PO!H`Q!0LrO,59PO%[QlO,59PO!JkQlO'#HcOOQ['#Hd'#HdOOQ['#He'#HeO`QlO,5={O!KRQ`O,5={O`QlO,5>RO`QlO,5>TO!KWQ`O,5>VO`QlO,5>XO!K]Q`O,5>[O!KbQlO,5>bOOQ[,5>h,5>hO%[QlO,5>hO9kQ!0LrO,5>jOOQ[,5>l,5>lO# lQ`O,5>lOOQ[,5>n,5>nO# lQ`O,5>nOOQ[,5>p,5>pO#!YQpO'#D]O%[QlO'#JtO#!{QpO'#JtO##VQpO'#DkO##hQpO'#DkO#%yQlO'#DkO#&QQ`O'#JsO#&YQ`O,5:UO#&_Q`O'#ErO#&mQ`O'#KSO#&uQ`O,5;]O#&zQpO'#DkO#'XQpO'#ETOOQ!0Lf,5:m,5:mO%[QlO,5:mO#'`Q`O,5:mO>wQ`O,5;WO!BeQpO,5;WO!BmQMhO,5;WO:YQMhO,5;WO#'hQ`O,5@`O#'mQ07dO,5:qOOQO-E|O+}QlO,5>|OOQO,5?S,5?SO#*uQlO'#IbOOQO-E<`-E<`O#+SQ`O,5@^O#+[Q!fO,5@^O#+cQ`O,5@lOOQ!0Lf1G/k1G/kO%[QlO,5@mO#+kQ`O'#IhOOQO-ErQ`O1G3qO$4rQlO1G3sO$8vQlO'#HrOOQ[1G3v1G3vO$9TQ`O'#HxO>wQ`O'#HzOOQ[1G3|1G3|O$9]QlO1G3|O9kQ!0LrO1G4SOOQ[1G4U1G4UOOQ!0Lb'#G^'#G^O9kQ!0LrO1G4WO9kQ!0LrO1G4YO$=dQ`O,5@`O!(yQlO,5;^O9ZQ`O,5;^O>wQ`O,5:VO!(yQlO,5:VO!BeQpO,5:VO$=iQ?MtO,5:VOOQO,5;^,5;^O$=sQpO'#IcO$>ZQ`O,5@_OOQ!0Lf1G/p1G/pO$>cQpO'#IiO$>mQ`O,5@nOOQ!0Lb1G0w1G0wO##hQpO,5:VOOQO'#Ie'#IeO$>uQpO,5:oOOQ!0Ln,5:o,5:oO#'cQ`O1G0XOOQ!0Lf1G0X1G0XO%[QlO1G0XOOQ!0Lf1G0r1G0rO>wQ`O1G0rO!BeQpO1G0rO!BmQMhO1G0rOOQ!0Lb1G5z1G5zO!BYQ!0LrO1G0[OOQO1G0k1G0kO%[QlO1G0kO$>|Q!0LrO1G0kO$?XQ!0LrO1G0kO!BeQpO1G0[OCuQpO1G0[O$?gQ!0LrO1G0kOOQO1G0[1G0[O$?{Q!0MxO1G0kPOOO-E|O$@iQ`O1G5xO$@qQ`O1G6WO$@yQ!fO1G6XO9ZQ`O,5?SO$ATQ!0MxO1G6UO%[QlO1G6UO$AeQ!0LrO1G6UO$AvQ`O1G6TO$AvQ`O1G6TO9ZQ`O1G6TO$BOQ`O,5?VO9ZQ`O,5?VOOQO,5?V,5?VO$BdQ`O,5?VO$)iQ`O,5?VOOQO-E^OOQ[,5>^,5>^O%[QlO'#HsO%=zQ`O'#HuOOQ[,5>d,5>dO9ZQ`O,5>dOOQ[,5>f,5>fOOQ[7+)h7+)hOOQ[7+)n7+)nOOQ[7+)r7+)rOOQ[7+)t7+)tO%>PQpO1G5zO%>kQ?MtO1G0xO%>uQ`O1G0xOOQO1G/q1G/qO%?QQ?MtO1G/qO>wQ`O1G/qO!(yQlO'#DkOOQO,5>},5>}OOQO-EwQ`O7+&^O!BeQpO7+&^OOQO7+%v7+%vO$?{Q!0MxO7+&VOOQO7+&V7+&VO%[QlO7+&VO%?[Q!0LrO7+&VO!BYQ!0LrO7+%vO!BeQpO7+%vO%?gQ!0LrO7+&VO%?uQ!0MxO7++pO%[QlO7++pO%@VQ`O7++oO%@VQ`O7++oOOQO1G4q1G4qO9ZQ`O1G4qO%@_Q`O1G4qOOQS7+%{7+%{O#'cQ`O<_OOQ[,5>a,5>aO&=aQ`O1G4OO9ZQ`O7+&dO!(yQlO7+&dOOQO7+%]7+%]O&=fQ?MtO1G6XO>wQ`O7+%]OOQ!0Lf<wQ`O<]Q`O<= ZOOQO7+*]7+*]O9ZQ`O7+*]OOQ[ANAjANAjO&>eQ!fOANAjO!&iQMhOANAjO#'cQ`OANAjO4UQ!fOANAjO&>lQ`OANAjO%[QlOANAjO&>tQ!0MzO7+'yO&AVQ!0MzO,5?_O&CbQ!0MzO,5?aO&EmQ!0MzO7+'{O&HOQ!fO1G4jO&HYQ?MtO7+&_O&J^Q?MvO,5=WO&LeQ?MvO,5=YO&LuQ?MvO,5=WO&MVQ?MvO,5=YO&MgQ?MvO,59sO' mQ?MvO,5wQ`O7+)jO'-]Q`O<|AN>|O%[QlOAN?]OOQO<PPPP!>XHwPPPPPPPPPP!AhP!BuPPHw!DWPHwPHwHwHwHwHwPHw!EjP!HtP!KzP!LO!LY!L^!L^P!HqP!Lb!LbP# hP# lHwPHw# r#$wCV@yP@yP@y@yP#&U@y@y#(h@y#+`@y#-l@y@y#.[#0p#0p#0u#1O#0p#1ZPP#0pP@y#1s@y#5r@y@y6aPPP#9wPPP#:b#:bP#:bP#:x#:bPP#;OP#:uP#:u#;c#:u#;}#R#>X#>c#>i#>s#>y#?Z#?a#@R#@e#@k#@q#AP#Af#CZ#Ci#Cp#E[#Ej#G[#Gj#Gp#Gv#G|#HW#H^#Hd#Hn#IQ#IWPPPPPPPPPPP#I^PPPPPPP#JR#MY#Nr#Ny$ RPPP$&mP$&v$)o$0Y$0]$0`$1_$1b$1i$1qP$1w$1zP$2h$2l$3d$4r$4w$5_PP$5d$5j$5n$5q$5u$5y$6u$7^$7u$7y$7|$8P$8V$8Y$8^$8bR!|RoqOXst!Z#d%l&p&r&s&u,n,s2S2VY!vQ'^-`1g5qQ%svQ%{yQ&S|Q&h!VS'U!e-WQ'd!iS'j!r!yU*h$|*X*lQ+l%|Q+y&UQ,_&bQ-^']Q-h'eQ-p'kQ0U*nQ1q,`R < TypeParamList const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:378,context:dr,nodeProps:[["isolate",-8,5,6,14,35,37,49,51,53,""],["group",-26,9,17,19,66,206,210,214,215,217,220,223,233,235,241,243,245,247,250,256,262,264,266,268,270,272,273,"Statement",-34,13,14,30,33,34,40,49,52,53,55,60,68,70,74,78,80,82,83,108,109,118,119,135,138,140,141,142,143,144,146,147,166,168,170,"Expression",-23,29,31,35,39,41,43,172,174,176,177,179,180,181,183,184,185,187,188,189,200,202,204,205,"Type",-3,86,101,107,"ClassItem"],["openedBy",23,"<",36,"InterpolationStart",54,"[",58,"{",71,"(",159,"JSXStartCloseTag"],["closedBy",-2,24,167,">",38,"InterpolationEnd",48,"]",59,"}",72,")",164,"JSXEndTag"]],propSources:[dd],skippedNodes:[0,5,6,276],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Up(X!b'z0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(V#S$h&j'{0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Up(X!b'{0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!n),Q(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(T':f$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(X!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Up(X!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(X!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(UpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(UpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Up(X!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$h&j!V7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!V7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!V7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$h&j(X!b!V7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(X!b!V7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(X!b!V7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(X!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(X!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!e$b$h&j#})Lv(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#P-v$?V_![(CdtBr$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!o7`$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$h&j(Up(X!b'z0/l$[#t(R,2j(c$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$h&j(Up(X!b'{0/l$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[da,dl,dh,dc,2,3,4,5,6,7,8,9,10,11,12,13,14,ds,new cG("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOv~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!S~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(a~~",141,338),new cG("j~RQYZXz{^~^O(O~~aP!P!Qd~iO(P~~",25,321)],topRules:{Script:[0,7],SingleExpression:[1,274],SingleClassItem:[2,275]},dialects:{jsx:0,ts:15091},dynamicPrecedences:{78:1,80:1,92:1,168:1,198:1},specialized:[{term:325,get:e=>df[e]||-1},{term:341,get:e=>dp[e]||-1},{term:93,get:e=>dO[e]||-1}],tokenPrec:15116}),dg=[uY("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),uY("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),uY("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),uY("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),uY("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),uY("try {\n ${}\n} catch (${error}) {\n ${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),uY("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),uY("if (${}) {\n ${}\n} else {\n ${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),uY("class ${name} {\n constructor(${params}) {\n ${}\n }\n}",{label:"class",detail:"definition",type:"keyword"}),uY('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),uY('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],db=dg.concat([uY("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),uY("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),uY("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),dx=new s4,dv=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function dy(e){return(t,i)=>{let n=t.node.getChild("VariableDefinition");return n&&i(n,e),!0}}const dw=["FunctionDeclaration"],dk={FunctionDeclaration:dy("function"),ClassDeclaration:dy("class"),ClassExpression:()=>!0,EnumDeclaration:dy("constant"),TypeAliasDeclaration:dy("type"),NamespaceDeclaration:dy("namespace"),VariableDefinition(e,t){e.matchContext(dw)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null},dS=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,dQ=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function dA(e){let t=o_(e.state).resolveInner(e.pos,-1);if(dQ.indexOf(t.name)>-1)return null;let i="VariableName"==t.name||t.to-t.from<20&&dS.test(e.state.sliceDoc(t.from,t.to));if(!i&&!e.explicit)return null;let n=[];for(let i=t;i;i=i.parent)dv.has(i.name)&&(n=n.concat(function e(t,i){let n=dx.get(i);if(n)return n;let r=[],s=!0;function o(e,i){let n=t.sliceString(e.from,e.to);r.push({label:n,type:i})}return i.cursor(B.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let e=dk[i.name];if(e&&e(i,o)||dv.has(i.name))return!1}else if(i.to-i.from>8192){for(let n of e(t,i.node))r.push(n);return!1}}),dx.set(i,r),r}(e.state.doc,i)));return{options:n,from:i?t.from:e.pos,validFor:dS}}const d$=oV.define({name:"javascript",parser:dm.configure({props:[o4.add({IfStatement:ae({except:/^\s*({|else\b)/}),TryStatement:ae({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:e=>e.baseIndent,SwitchBody:e=>{let t=e.textAfter,i=/^\s*\}/.test(t),n=/^\s*(case|default)\b/.test(t);return e.baseIndent+(i?0:n?1:2)*e.unit},Block:function({closing:e,align:t=!0,units:i=1}){return n=>o8(n,t,i,e)}({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":ae({except:/^{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag":e=>e.column(e.node.from)+e.unit}),ai.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":an,BlockComment:e=>({from:e.from+2,to:e.to-2})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),dC={test:e=>/^JSX/.test(e.name),facet:oD({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dP=d$.configure({dialect:"ts"},"typescript"),dZ=d$.configure({dialect:"jsx",props:[oB.add(e=>e.isTop?[dC]:void 0)]}),dE=d$.configure({dialect:"jsx ts",props:[oB.add(e=>e.isTop?[dC]:void 0)]},"typescript");let dT=e=>({label:e,type:"keyword"});const dR="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(dT),dM=dR.concat(["declare","implements","private","protected","public"].map(dT));function dX(e={}){var t;let i=e.jsx?e.typescript?dE:dZ:e.typescript?dP:d$,n=e.typescript?db.concat(dM):dg.concat(dR);return new oH(i,[d$.data.of({autocomplete:(t=h3(n),e=>{for(let t=o_(e.state).resolveInner(e.pos,-1);t;t=t.parent){if(dQ.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(e)})}),d$.data.of({autocomplete:dA}),e.jsx?dq:[]])}function dD(e,t,i=e.length){for(let n=null==t?void 0:t.firstChild;n;n=n.nextSibling)if("JSXIdentifier"==n.name||"JSXBuiltin"==n.name||"JSXNamespacedName"==n.name||"JSXMemberExpression"==n.name)return e.sliceString(n.from,Math.min(n.to,i));return""}const dB="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),dq=ro.inputHandler.of((e,t,i,n,r)=>{if((dB?e.composing:e.compositionStarted)||e.state.readOnly||t!=i||">"!=n&&"/"!=n||!d$.isActiveAt(e.state,t,-1))return!1;let s=r(),{state:o}=s,a=o.changeByRange(e=>{var t;let{head:i}=e,r=o_(o).resolveInner(i-1,-1),s;if("JSXStartTag"==r.name&&(r=r.parent),o.doc.sliceString(i-1,i)!=n||"JSXAttributeValue"==r.name&&r.to>i);else if(">"==n&&"JSXFragmentTag"==r.name)return{range:e,changes:{from:i,insert:">"}};else if("/"==n&&"JSXStartCloseTag"==r.name){let e=r.parent,n=e.parent;if(n&&e.from==i-2&&((s=dD(o.doc,n.firstChild,i))||(null===(t=n.firstChild)||void 0===t?void 0:t.name)=="JSXFragmentTag")){let e=`${s}>`;return{range:K.cursor(i+e.length,-1),changes:{from:i,insert:e}}}}else if(">"==n){let t=function(e){for(;;){if("JSXOpenTag"==e.name||"JSXSelfClosingTag"==e.name||"JSXFragmentTag"==e.name)return e;if("JSXEscape"==e.name||!e.parent)return null;e=e.parent}}(r);if(t&&"JSXOpenTag"==t.name&&!/^\/?>|^<\//.test(o.doc.sliceString(i,i+2))&&(s=dD(o.doc,t,i)))return{range:e,changes:{from:i,insert:`${s}>`}}}return{range:e}});return!a.changes.empty&&(e.dispatch([s,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});class dL{static create(e,t,i,n,r){return new dL(e,t,i,n+(n<<8)+e+(t<<4)|0,r,[],[])}constructor(e,t,i,n,r,s,o){this.type=e,this.value=t,this.from=i,this.hash=n,this.end=r,this.children=s,this.positions=o,this.hashProp=[[sM.contextHash,n]]}addChild(e,t){e.prop(sM.contextHash)!=this.hash&&(e=new s_(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let i=this.children.length-1;return i>=0&&(t=Math.max(t,this.positions[i]+this.children[i].length+this.from)),new s_(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,i)=>new s_(sB.none,e,t,i,this.hashProp)})}}(X=F||(F={}))[X.Document=1]="Document",X[X.CodeBlock=2]="CodeBlock",X[X.FencedCode=3]="FencedCode",X[X.Blockquote=4]="Blockquote",X[X.HorizontalRule=5]="HorizontalRule",X[X.BulletList=6]="BulletList",X[X.OrderedList=7]="OrderedList",X[X.ListItem=8]="ListItem",X[X.ATXHeading1=9]="ATXHeading1",X[X.ATXHeading2=10]="ATXHeading2",X[X.ATXHeading3=11]="ATXHeading3",X[X.ATXHeading4=12]="ATXHeading4",X[X.ATXHeading5=13]="ATXHeading5",X[X.ATXHeading6=14]="ATXHeading6",X[X.SetextHeading1=15]="SetextHeading1",X[X.SetextHeading2=16]="SetextHeading2",X[X.HTMLBlock=17]="HTMLBlock",X[X.LinkReference=18]="LinkReference",X[X.Paragraph=19]="Paragraph",X[X.CommentBlock=20]="CommentBlock",X[X.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",X[X.Escape=22]="Escape",X[X.Entity=23]="Entity",X[X.HardBreak=24]="HardBreak",X[X.Emphasis=25]="Emphasis",X[X.StrongEmphasis=26]="StrongEmphasis",X[X.Link=27]="Link",X[X.Image=28]="Image",X[X.InlineCode=29]="InlineCode",X[X.HTMLTag=30]="HTMLTag",X[X.Comment=31]="Comment",X[X.ProcessingInstruction=32]="ProcessingInstruction",X[X.Autolink=33]="Autolink",X[X.HeaderMark=34]="HeaderMark",X[X.QuoteMark=35]="QuoteMark",X[X.ListMark=36]="ListMark",X[X.LinkMark=37]="LinkMark",X[X.EmphasisMark=38]="EmphasisMark",X[X.CodeMark=39]="CodeMark",X[X.CodeText=40]="CodeText",X[X.CodeInfo=41]="CodeInfo",X[X.LinkTitle=42]="LinkTitle",X[X.LinkLabel=43]="LinkLabel",X[X.URL=44]="URL";class dV{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class d_{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return dz(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,i=0){for(let n=t;n=t.stack[i.depth+1].value+i.baseIndent)return!0;if(i.indent>=i.baseIndent+4)return!1;let n=(e.type==F.OrderedList?dJ:dH)(i,t,!1);return n>0&&(e.type!=F.BulletList||0>dN(i,t,!1))&&i.text.charCodeAt(i.pos+n-1)==e.value}const dW={[F.Blockquote]:(e,t,i)=>62==i.next&&(i.markers.push(ff(F.QuoteMark,t.lineStart+i.pos,t.lineStart+i.pos+1)),i.moveBase(i.pos+(dj(i.text.charCodeAt(i.pos+1))?2:1)),e.end=t.lineStart+i.text.length,!0),[F.ListItem]:(e,t,i)=>(!(i.indent-1))&&(i.moveBaseColumn(i.baseIndent+e.value),!0),[F.OrderedList]:dF,[F.BulletList]:dF,[F.Document]:()=>!0};function dj(e){return 32==e||9==e||10==e||13==e}function dz(e,t=0){for(;ti&&dj(e.charCodeAt(t-1));)t--;return t}function dI(e){if(96!=e.next&&126!=e.next)return -1;let t=e.pos+1;for(;t-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(fi.SetextHeading)>-1?-1:n<3?-1:1}function dG(e,t){for(let i=e.stack.length-1;i>=0;i--)if(e.stack[i].type==t)return!0;return!1}function dH(e,t,i){return(45==e.next||43==e.next||42==e.next)&&(e.pos==e.text.length-1||dj(e.text.charCodeAt(e.pos+1)))&&(!i||dG(t,F.BulletList)||e.skipSpace(e.pos+2)=48&&r<=57;){if(++n==e.text.length)return -1;r=e.text.charCodeAt(n)}return n==e.pos||n>e.pos+9||46!=r&&41!=r||ne.pos+1||49!=e.next)?-1:n+1-e.pos}function dK(e){if(35!=e.next)return -1;let t=e.pos+1;for(;t6?-1:i}function d0(e){if(45!=e.next&&61!=e.next||e.indent>=e.baseIndent+4)return -1;let t=e.pos+1;for(;t/,d5=/\?>/,d3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<\!--/,d2],[/^\s*<\?/,d5],[/^\s*/],[/^\s*/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,d1],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,d1]];function d4(e,t,i){if(60!=e.next)return -1;let n=e.text.slice(e.pos);for(let e=0,t=d3.length-+!!i;e=i+5?i+1:n}function d9(e,t,i){let n=e.length-1;n>=0&&e[n].to==t&&e[n].type==F.CodeText?e[n].to=i:e.push(ff(F.CodeText,t,i))}const d6={LinkReference:void 0,IndentedCode(e,t){let i=t.baseIndent+4;if(t.indent=e.stack.length;)if(t.pos==t.text.length)for(let i of(d9(a,e.lineStart-1,e.lineStart),t.markers))a.push(i);else if(t.indente.type!=F.CodeText)).length&&(t.markers=a.concat(t.markers)),e.addNode(e.buffer.writeElements(o,-r).finish(F.CodeBlock,s-r),r),!0},FencedCode(e,t){let i=dI(t);if(i<0)return!1;let n=e.lineStart+t.pos,r=t.next,s=i-t.pos,o=t.skipSpace(i),a=dY(t.text,t.text.length,o),l=[ff(F.CodeMark,n,n+s)];o=e.stack.length;i=!1){let n=t.pos;if(t.indent-t.baseIndent<4)for(;n=s&&t.skipSpace(n)==t.text.length){for(let e of t.markers)l.push(e);l.push(ff(F.CodeMark,e.lineStart+t.pos,e.lineStart+n)),e.nextLine();break}{for(let n of(i||d9(l,e.lineStart-1,e.lineStart),t.markers))l.push(n);let n=e.lineStart+t.basePos,r=e.lineStart+t.text.length;ndN(t,e,!1))return!1;let i=e.lineStart+t.pos;return e.nextLine(),e.addNode(F.HorizontalRule,i),!0},BulletList(e,t){let i=dH(t,e,!1);if(i<0)return!1;e.block.type!=F.BulletList&&e.startContext(F.BulletList,t.basePos,t.next);let n=d7(t,t.pos+1);return e.startContext(F.ListItem,t.basePos,n-t.baseIndent),e.addNode(F.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+i),t.moveBaseColumn(n),null},OrderedList(e,t){let i=dJ(t,e,!1);if(i<0)return!1;e.block.type!=F.OrderedList&&e.startContext(F.OrderedList,t.basePos,t.text.charCodeAt(t.pos+i-1));let n=d7(t,t.pos+i);return e.startContext(F.ListItem,t.basePos,n-t.baseIndent),e.addNode(F.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+i),t.moveBaseColumn(n),null},ATXHeading(e,t){let i=dK(t);if(i<0)return!1;let n=t.pos,r=e.lineStart+n,s=dY(t.text,t.text.length,n),o=s;for(;o>n&&t.text.charCodeAt(o-1)==t.next;)o--;o!=s&&o!=n&&dj(t.text.charCodeAt(o-1))||(o=t.text.length);let a=e.buffer.write(F.HeaderMark,0,i).writeElements(e.parser.parseInline(t.text.slice(n+i+1,o),r+i+1),-r);o-1&&rthis.pos){let n=fk(e,t,this.start);if(n){let t=fe(e,n.to-this.start);t>0&&(this.nextStage(n),i=t)}}return i||(i=fe(e,this.pos)),i>0&&i91==t.content.charCodeAt(0)?new d8(t):null,SetextHeading:()=>new ft},fn={text:"",end:0};class fr{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.line=new d_,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=n[n.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=n[0].from,this.block=dL.create(F.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=i.length?new fC(i,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(null!=this.stoppedAt&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let i=e.depth=this.to)?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){if(fn.end=e,e>=this.to)fn.text="";else if(fn.text=this.lineChunkAt(e),fn.end+=fn.text.length,this.ranges.length>1){let e=this.absoluteLineStart,t=this.rangeI;for(;this.ranges[t].tothis.to?i.slice(0,this.to-e):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,i=0){this.block=dL.create(e,i,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,i=0){this.startContext(this.parser.getNodeType(e),t,i)}addNode(e,t,i){"number"==typeof e&&(e=new s_(this.parser.nodeSet.types[e],fh,fh,(null!=i?i:this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(fA(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?function e(t,i,n,r,s){let o=t[i].to,a=[],l=[],h=n.from+r;function u(e,n){for(;n?e>=o:e>o;){let n=t[i+1].from-o;r+=n,e+=n,o=t[++i].to}}for(let c=n.firstChild;c;c=c.nextSibling){u(c.from+r,!0);let n=c.from+r,d,f=s.get(c.tree);f?d=f:c.to+r>o?(d=e(t,i,c,r,s),u(c.to+r,!1)):d=c.toTree(),a.push(d),l.push(n-h)}return u(n.to+r,!1),new s_(n.type,a,l,n.to+r-h,n.tree?n.tree.propValues:void 0)}(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let t of e.parsers)if(t.finish(this,e))return;let t=fA(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(F.Paragraph,e.content.length),e.start)}elt(e,t,i,n){return"string"==typeof e?ff(this.parser.getNodeType(e),t,i,n):new fd(e,t)}get buffer(){return new fu(this.parser.nodeSet)}}class fs extends s9{constructor(e,t,i,n,r,s,o,a,l){for(let h of(super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,this.blockNames=n,this.endLeafBlock=r,this.skipContextMarkup=s,this.inlineParsers=o,this.inlineNames=a,this.wrappers=l,this.nodeTypes=Object.create(null),e.types))this.nodeTypes[h.name]=h.id}createParse(e,t,i){let n=new fr(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}configure(e){let t=function e(t){if(!Array.isArray(t))return t;if(0==t.length)return null;let i=e(t[0]);if(1==t.length)return i;let n=e(t.slice(1));if(!n||!i)return i||n;let r=(e,t)=>(e||fh).concat(t||fh),s=i.wrap,o=n.wrap;return{props:r(i.props,n.props),defineNodes:r(i.defineNodes,n.defineNodes),parseBlock:r(i.parseBlock,n.parseBlock),parseInline:r(i.parseInline,n.parseInline),remove:r(i.remove,n.remove),wrap:s?o?(e,t,i,n)=>s(o(e,t,i,n),t,i,n):s:o}}(e);if(!t)return this;let{nodeSet:i,skipContextMarkup:n}=this,r=this.blockParsers.slice(),s=this.leafBlockParsers.slice(),o=this.blockNames.slice(),a=this.inlineParsers.slice(),l=this.inlineNames.slice(),h=this.endLeafBlock.slice(),u=this.wrappers;if(fo(t.defineNodes)){n=Object.assign({},n);let e=i.types.slice(),r;for(let i of t.defineNodes){let{name:t,block:s,composite:o,style:a}="string"==typeof i?{name:i}:i;if(e.some(e=>e.name==t))continue;o&&(n[e.length]=(e,t,i)=>o(t,i,e.value));let l=e.length,h=o?["Block","BlockContext"]:s?l>=F.ATXHeading1&&l<=F.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;e.push(sB.define({id:l,name:t,props:h&&[[sM.group,h]]})),a&&(r||(r={}),Array.isArray(a)||a instanceof oc?r[t]=a:Object.assign(r,a))}i=new sq(e),r&&(i=i.extend(op(r)))}if(fo(t.props)&&(i=i.extend(...t.props)),fo(t.remove))for(let e of t.remove){let t=this.blockNames.indexOf(e),i=this.inlineNames.indexOf(e);t>-1&&(r[t]=s[t]=void 0),i>-1&&(a[i]=void 0)}if(fo(t.parseBlock))for(let e of t.parseBlock){let t=o.indexOf(e.name);if(t>-1)r[t]=e.parse,s[t]=e.leaf;else{let t=e.before?fa(o,e.before):e.after?fa(o,e.after)+1:o.length-1;r.splice(t,0,e.parse),s.splice(t,0,e.leaf),o.splice(t,0,e.name)}e.endLeaf&&h.push(e.endLeaf)}if(fo(t.parseInline))for(let e of t.parseInline){let t=l.indexOf(e.name);if(t>-1)a[t]=e.parse;else{let t=e.before?fa(l,e.before):e.after?fa(l,e.after)+1:l.length-1;a.splice(t,0,e.parse),l.splice(t,0,e.name)}}return t.wrap&&(u=u.concat(t.wrap)),new fs(i,r,s,o,h,n,a,l,u)}getNodeType(e){let t=this.nodeTypes[e];if(null==t)throw RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let i=new fQ(this,e,t);r:for(let e=t;e=0){e=r;continue r}}e++}return i.resolveMarkers(0)}}function fo(e){return null!=e&&e.length>0}function fa(e,t){let i=e.indexOf(t);if(i<0)throw RangeError(`Position specified relative to unknown parser ${t}`);return i}let fl=[sB.none];for(let e=1,t;t=F[e];e++)fl[e]=sB.define({id:e,name:t,props:e>=F.Escape?[]:[[sM.group,e in dW?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==t});const fh=[];class fu{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,i,n=0){return this.content.push(e,t,i,4+4*n),this}writeElements(e,t=0){for(let i of e)i.writeTo(this,t);return this}finish(e,t){return s_.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}class fc{constructor(e,t,i,n=fh){this.type=e,this.from=t,this.to=i,this.children=n}writeTo(e,t){let i=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-i)}toTree(e){return new fu(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}}class fd{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return fh}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function ff(e,t,i,n){return new fc(e,t,i,n)}const fp={resolve:"Emphasis",mark:"EmphasisMark"},fO={resolve:"Emphasis",mark:"EmphasisMark"},fm={},fg={};class fb{constructor(e,t,i,n){this.type=e,this.from=t,this.to=i,this.side=n}}const fx="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let fv=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{fv=RegExp("[\\p{S}|\\p{P}]","u")}catch(e){}const fy={Escape(e,t,i){if(92!=t||i==e.end-1)return -1;let n=e.char(i+1);for(let t=0;t]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(n);if(r)return e.append(ff(F.Autolink,i,i+1+r[0].length,[ff(F.LinkMark,i,i+1),ff(F.URL,i+1,i+r[0].length),ff(F.LinkMark,i+r[0].length,i+1+r[0].length)]));let s=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);if(s)return e.append(ff(F.Comment,i,i+1+s[0].length));let o=/^\?[^]*?\?>/.exec(n);if(o)return e.append(ff(F.ProcessingInstruction,i,i+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(n);return a?e.append(ff(F.HTMLTag,i,i+1+a[0].length)):-1},Emphasis(e,t,i){if(95!=t&&42!=t)return -1;let n=i+1;for(;e.char(n)==t;)n++;let r=e.slice(i-1,i),s=e.slice(n,n+1),o=fv.test(r),a=fv.test(s),l=/\s|^$/.test(r),h=/\s|^$/.test(s),u=!h&&(!a||l||o),c=!l&&(!o||h||a);return e.append(new fb(95==t?fp:fO,i,n,+!!(u&&(42==t||!c||o))|2*!!(c&&(42==t||!u||a))))},HardBreak(e,t,i){if(92==t&&10==e.char(i+1))return e.append(ff(F.HardBreak,i,i+2));if(32==t){let t=i+1;for(;32==e.char(t);)t++;if(10==e.char(t)&&t>=i+2)return e.append(ff(F.HardBreak,i,t+1))}return -1},Link:(e,t,i)=>91==t?e.append(new fb(fm,i,i+1,1)):-1,Image:(e,t,i)=>33==t&&91==e.char(i+1)?e.append(new fb(fg,i,i+2,1)):-1,LinkEnd(e,t,i){if(93!=t)return -1;for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n instanceof fb&&(n.type==fm||n.type==fg)){if(!n.side||e.skipSpace(n.to)==i&&!/[(\[]/.test(e.slice(i+1,i+2)))return e.parts[t]=null,-1;let r=e.takeContent(t),s=e.parts[t]=function(e,t,i,n,r){let{text:s}=e,o=e.char(r),a=r;if(t.unshift(ff(F.LinkMark,n,n+(i==F.Image?2:1))),t.push(ff(F.LinkMark,r-1,r)),40==o){let i=e.skipSpace(r+1),n=fw(s,i-e.offset,e.offset),o;n&&(i=e.skipSpace(n.to))!=n.to&&(o=fk(s,i-e.offset,e.offset))&&(i=e.skipSpace(o.to)),41==e.char(i)&&(t.push(ff(F.LinkMark,r,r+1)),a=i+1,n&&t.push(n),o&&t.push(o),t.push(ff(F.LinkMark,i,a)))}else if(91==o){let i=fS(s,r-e.offset,e.offset,!1);i&&(t.push(i),a=i.to)}return ff(i,n,a,t)}(e,r,n.type==fm?F.Link:F.Image,n.from,i+1);if(n.type==fm)for(let i=0;it?ff(F.URL,t+i,r+i):r==e.length&&null}}function fk(e,t,i){let n=e.charCodeAt(t);if(39!=n&&34!=n&&40!=n)return!1;let r=40==n?41:n;for(let n=t+1,s=!1;n=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,i,n,r){return this.append(new fb(e,t,i,+!!n|2*!!r))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof fb&&(t.type==fm||t.type==fg))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let t=e;t=e;o--){let e=this.parts[o];if(e instanceof fb&&1&e.side&&e.type==i.type&&!(n&&(1&i.side||2&e.side)&&(e.to-e.from+r)%3==0&&((e.to-e.from)%3||r%3))){s=e;break}}if(!s)continue;let a=i.type.resolve,l=[],h=s.from,u=i.to;if(n){let e=Math.min(2,s.to-s.from,r);h=s.to-e,u=i.from+e,a=1==e?"Emphasis":"StrongEmphasis"}s.type.mark&&l.push(this.elt(s.type.mark,h,s.to));for(let e=o+1;e=0;t--){let i=this.parts[t];if(i instanceof fb&&i.type==e)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}skipSpace(e){return dz(this.text,e-this.offset)+this.offset}elt(e,t,i,n){return"string"==typeof e?ff(this.parser.getNodeType(e),t,i,n):new fd(e,t)}}function fA(e,t){if(!t.length)return e;if(!e.length)return t;let i=e.slice(),n=0;for(let e of t){for(;n(e?e-1:0))return!1;if(this.fragmentEnd<0){let e=this.fragment.to;for(;e>0&&"\n"!=this.input.read(e-1,e);)e--;this.fragmentEnd=e?e-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor()).firstChild();let n=e+this.fragment.offset;for(;i.to<=n;)if(!i.parent())return!1;for(;;){if(i.from>=n)return this.fragment.from<=t;if(!i.childAfter(n))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(sM.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,n=this.fragmentEnd-+!!this.fragment.openEnd,r=e.absoluteLineStart,s=r,o=e.block.children.length,a=s,l=o;for(;;){if(t.to-i>n){if(t.type.isAnonymous&&t.firstChild())continue;break}let r=fP(t.from-i,e.ranges);if(t.to-i<=e.ranges[e.rangeI].to)e.addNode(t.tree,r);else{let i=new s_(e.parser.nodeSet.types[F.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(i,t.tree),e.addNode(i,r)}if(t.type.is("Block")&&(0>f$.indexOf(t.type.id)?(s=t.to-i,o=e.block.children.length):(s=a,o=l,a=t.to-i,l=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return s-r}}function fP(e,t){let i=e;for(let n=1;nd6[e]),Object.keys(d6).map(e=>fi[e]),Object.keys(d6),[(e,t)=>dK(t)>=0,(e,t)=>dI(t)>=0,(e,t)=>dU(t)>=0,(e,t)=>dH(t,e,!0)>=0,(e,t)=>dJ(t,e,!0)>=0,(e,t)=>dN(t,e,!0)>=0,(e,t)=>d4(t,e,!0)>=0],dW,Object.keys(fy).map(e=>fy[e]),Object.keys(fy),[]),fT={resolve:"Strikethrough",mark:"StrikethroughMark"},fR={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":oM.strikethrough}},{name:"StrikethroughMark",style:oM.processingInstruction}],parseInline:[{name:"Strikethrough",parse(e,t,i){if(126!=t||126!=e.char(i+1)||126==e.char(i+2))return -1;let n=e.slice(i-1,i),r=e.slice(i+2,i+3),s=/\s|^$/.test(n),o=/\s|^$/.test(r),a=fv.test(n),l=fv.test(r);return e.addDelimiter(fT,i,i+2,!o&&(!l||s||a),!s&&(!a||o||l))},after:"Emphasis"}]};function fM(e,t,i=0,n,r=0){let s=0,o=!0,a=-1,l=-1,h=!1,u=()=>{n.push(e.elt("TableCell",r+a,r+l,e.parser.parseInline(t.slice(a,l),r+a)))};for(let c=i;c-1)&&s++,o=!1,n&&(a>-1&&u(),n.push(e.elt("TableDelimiter",c+r,c+r+1))),a=l=-1),h=!h&&92==i}return a>-1&&(s++,n&&u()),s}function fX(e,t){for(let i=t;i