\')',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),se={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},st=tz.ie&&tz.ie_version<=11;class si{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);(tz.ie&&tz.ie_version<=11||tz.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&&!(tz.chrome&&tz.chrome_version<126)&&(this.editContext=new sr(e),e.state.facet(iq)&&(e.contentDOM.editContext=this.editContext.editContext)),st&&(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(iq)?i.root.activeElement!=this.dom:!to(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(tz.ie&&tz.ie_version<=11||tz.android&&tz.chrome)&&!i.state.selection.main.empty&&n.focusNode&&ta(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ts(e.root);if(!t)return!1;let i=tz.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 ss(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?ss(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 s of e){let e=this.readMutation(s);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 s=new nn(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}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=ns(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=sn(t,e.previousSibling||e.target.previousSibling,-1),n=sn(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(iq)!=e.state.facet(iq)&&(e.view.contentDOM.editContext=e.state.facet(iq)?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 sn(e,t,i){for(;t;){let n=t$.get(t);if(n&&n.parent==e)return n;let s=t.parentNode;t=s!=e.dom?s:i>0?t.nextSibling:t.previousSibling}return null}function ss(e,t){let i=t.startContainer,n=t.startOffset,s=t.endContainer,r=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return ta(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}class sr{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:s}=i,r=this.toEditorPos(t.updateRangeStart),o=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:r,drifted:!1});let l={from:r,to:o,insert:O.of(t.text.split("\n"))};if(l.from==this.from&&nthis.to&&(l.to=n),l.from==l.to&&!l.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((tz.mac||tz.android)&&l.from==s-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(l={from:r,to:o,insert:O.of([t.text.replace("."," ")])}),this.pendingContextChange=l,!e.state.readOnly){let i=this.to-this.from+(l.to-l.from+l.insert.length);nr(e,l,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=[],s=null;for(let t=this.toEditorPos(i.rangeStart),r=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 s=this.toEditorPos(e.rangeStart),r=this.toEditorPos(e.rangeEnd);if(s{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=ts(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((s,r,o,l,a)=>{if(i)return;let h=a.length-(r-s);if(n&&r>=n.to){if(n.from==s&&n.to==r&&n.insert.eq(a)){n=this.pendingContextChange=null,t+=h,this.to+=h;return}n=null,this.revertPending(e.state)}if(s+=t,(r+=t)<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),a.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 so{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 nG(e.state||eE.create(e)),e.scrollTo&&e.scrollTo.is(iR)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(iL).map(e=>new i_(e)),this.plugins))t.update(this);this.observer=new si(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 eT?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,s=this.state;for(let t of e){if(t.startState!=s)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=t.state}if(this.destroyed){this.viewState.state=s;return}let r=this.hasFocus,o=0,l=null;e.some(e=>e.annotation(nZ))?(this.inputState.notifiedFocused=r,o=1):r==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=r,(l=nT(s,r))||(o=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(eE.phrases)!=this.state.facet(eE.phrases))return this.setState(s);n=iF.create(this,s,e),n.flags|=o;let c=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new iA(e.empty?e:K.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(iR)&&(c=e.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=sh.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(iG)!=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||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let e of this.state.facet(iS))try{e(n)}catch(e){iX(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!ns(this,h)&&a.force&&tx(this.contentDOM,a.key,a.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 nG(e),this.plugins=e.facet(iL).map(e=>new i_(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(iL),i=e.state.facet(iL);if(t!=i){let n=[];for(let s of i){let i=t.indexOf(s);if(i<0)n.push(new i_(s));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:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0){if(tk(i))s=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(n);s=e.from,r=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 l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(e=>{try{return e.read(this)}catch(e){return iX(this.state,e),sa}}),h=iF.create(this,this.state,[]),c=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e1||e<-1){n+=e,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(iS))e(t)}get themeClasses(){return n3+" "+(this.state.facet(n5)?n7:n4)+" "+this.state.facet(n2)}updateAttrs(){let e=sc(this,iD,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(iq)?"true":"false",class:"cm-content",style:`${tz.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),sc(this,iW,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(so.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(iG);let e=this.state.facet(so.cspNonce);e4.mount(this.root,this.styleModules.concat(n6).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,i8(this,e,t,i))}moveByGroup(e,t){return ne(this,e,i8(this,e,t,t=>{var i;let n,s;return i=e.head,s=(n=this.state.charCategorizer(i))(t),e=>{let t=n(e);return s==eX.Space&&(s=t),s==t}}))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return K.cursor(s.side(t,n)+e.from,s.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let s=i9(e,t.head),r=n&&s.type==t0.Text&&(e.lineWrapping||s.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head):null;if(r){let t=e.dom.getBoundingClientRect(),n=e.textDirectionAt(s.from),o=e.posAtCoords({x:i==(n==is.LTR)?t.right-1:t.left+1,y:(r.top+r.bottom)/2});if(null!=o)return K.cursor(o,i?-1:1)}return K.cursor(i?s.to:s.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return ne(this,e,function(e,t,i,n){let s=t.head,r=i?1:-1;if(s==(i?e.state.doc.length:0))return K.cursor(s,t.assoc);let o=t.goalColumn,l,a=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(s,t.assoc||-1),c=e.documentTop;if(h)null==o&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(s);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(s-t.from))),l=(r<0?t.top:t.bottom)+c}let u=a.left+o,d=null!=n?n:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let i=l+(d+t)*r,n=i4(e,{x:u,y:i},!1,r);if(ia.bottom||(r<0?ns)){let t=e.docView.coordsForChar(n),s=!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(iZ)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>sl)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=[],s=+(t!=ir);return function e(t,i,n,s,r,o,l){let a=i%2?2:1;!function(e,t,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:t,l=r=0;e-=3)if(iu[e+1]==-n){let i=iu[e+2],n=2&i?s:4&i?1&i?r:s:0;n&&(im[t]=im[iu[e]]=n),l=e;break}}else if(189==iu.length)break;else iu[l++]=t,iu[l++]=i,iu[l++]=a}else if(2==(o=im[t])||1==o){let e=o==s;a=+!e;for(let t=l-3;t>=0;t-=3){let i=iu[t+2];if(2&i)break;if(e)iu[t+2]|=2;else{if(4&i)break;iu[t+2]|=4}}}}}(t,r,o,s,a),function(e,t,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:e,l=sa;)t==r&&(t=i[--n].from,r=n?i[n-1].to:e),im[--t]=c;a=o}else r=o,a++}}}(r,o,s,a),function t(i,n,s,r,o,l,a){let h=r%2?2:1;if(r%2==o%2)for(let c=n,u=0;cc&&a.push(new iO(c,t.from,p)),e(i,t.direction==ir!=!(p%2)?r+1:r,o,t.inner,t.from,t.to,a),c=t.to),O=t.to}else if(O==s||(n?im[O]!=h:im[O]==h))break;else O++;f?t(i,c,O,r+1,o,f,a):cn;){let s=!0,d=!1;if(!u||c>l[u-1].to){let e=im[c-1];e!=h&&(s=!1,d=16==e)}let f=s||1!=h?null:[],p=s?r:r+1,O=c;t:for(;;)if(u&&O==l[u-1].to){if(d)break;let t=l[--u];if(!s)for(let e=t.from,i=u;;){if(e==n)break t;if(i&&l[i-1].to==e)e=l[--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 iR.of(new iA("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 iR.of(new iA(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 iV.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return iV.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=e4.newName(),n=[n2.of(i),iG.of(n8(`.${i}`,e))];return t&&t.dark&&n.push(n5.of(!0)),n}static baseTheme(e){return eu.lowest(iG.of(n8("."+n3,e,n9)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&t$.get(i)||t$.get(e);return(null===(t=null==n?void 0:n.rootView)||void 0===t?void 0:t.view)||null}}so.styleModule=iG,so.inputHandler=iv,so.clipboardInputFilter=i$,so.clipboardOutputFilter=iP,so.scrollHandler=iC,so.focusChangeEffect=iQ,so.perLineTextDirection=iZ,so.exceptionSink=iy,so.updateListener=iS,so.editable=iq,so.mouseSelectionStyle=ik,so.dragMovesSelection=iw,so.clickAddsSelectionRange=ix,so.decorations=iz,so.outerDecorations=ij,so.atomicRanges=iB,so.bidiIsolatedRanges=iY,so.scrollMargins=iU,so.darkTheme=n5,so.cspNonce=ei.define({combine:e=>e.length?e[0]:""}),so.contentAttributes=iW,so.editorAttributes=iD,so.lineWrapping=so.contentAttributes.of({class:"cm-lineWrapping"}),so.announce=eZ.define();const sl=4096,sa={};class sh{constructor(e,t,i,n,s,r){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:is.LTR;for(let s=Math.max(0,e.length-10);s=0;s--){let t=n[s],r="function"==typeof t?t(e):t;r&&tG(r,i)}return i}const su=tz.mac?"mac":tz.windows?"win":tz.linux?"linux":"key";function sd(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 sf=eu.default(so.domEventHandlers({keydown:(e,t)=>sx(sm(t.state),e,t,"editor")})),sp=ei.define({enables:sf}),sO=new WeakMap;function sm(e){let t=e.facet(sp),i=sO.get(t);return i||sO.set(t,i=function(e,t=su){let i=Object.create(null),n=Object.create(null),s=(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")},r=(e,n,r,o,l)=>{var a,h;let c=i[e]||(i[e]=Object.create(null)),u=n.split(/ (?!$)/).map(e=>(function(e,t){let i,n,s,r;let o=e.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let e=0;e{let n=sg={view:t,prefix:i,scope:e};return setTimeout(()=>{sg==n&&(sg=null)},4e3),!0}]})}let d=u.join(" ");s(d,!1);let f=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});r&&f.run.push(r),o&&(f.preventDefault=!0),l&&(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:s}=n;for(let t in e)e[t].run.push(e=>s(e,sb))}let s=n[t]||n.key;if(s)for(let t of e)r(t,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(t,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(t.reduce((e,t)=>e.concat(t),[]))),i}let sg=null,sb=null;function sx(e,t,i,n){var s;sb=t;let r=("Esc"==(s=!(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?e6:e8)[t.keyCode]||t.key||"Unidentified")&&(s="Escape"),"Del"==s&&(s="Delete"),"Left"==s&&(s="ArrowLeft"),"Up"==s&&(s="ArrowUp"),"Right"==s&&(s="ArrowRight"),"Down"==s&&(s="ArrowDown"),s),o=P(Q(r,0))==r.length&&" "!=r,l="",a=!1,h=!1,c=!1;sg&&sg.view==i&&sg.scope==n&&(l=sg.prefix+" ",0>nc.indexOf(t.keyCode)&&(h=!0,sg=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(i)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),h=!0)}return!1},f=e[n],p,O;return f&&(d(f[l+sd(r,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(tz.windows&&t.ctrlKey&&t.altKey)&&(p=e8[t.keyCode])&&p!=r?d(f[l+sd(p,t,!0)])?a=!0:t.shiftKey&&(O=e6[t.keyCode])!=r&&O!=p&&d(f[l+sd(O,t,!1)])&&(a=!0):o&&t.shiftKey&&d(f[l+sd(r,t,!0)])&&(a=!0),!a&&d(f._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),sb=null,a}class sw{constructor(e,t,i,n,s){this.className=e,this.left=t,this.top=i,this.width=n,this.height=s}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),s=Math.min(i.to,e.viewport.to),r=e.textDirection==is.LTR,o=e.contentDOM,l=o.getBoundingClientRect(),a=sk(e),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=l.right-(c?parseInt(c.paddingRight):0),f=i9(e,n),p=i9(e,s),O=f.type==t0.Text?f:null,m=p.type==t0.Text?p:null;if(O&&(e.lineWrapping||f.widgetLineBreaks)&&(O=sy(e,n,1,O)),m&&(e.lineWrapping||p.widgetLineBreaks)&&(m=sy(e,s,-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):w(f,!1),n=m?x(null,i.to,m):w(p,!0),s=[];return(O||f).to<(m||p).from-(O&&m?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2h&&n.from=r)break;l>s&&a(Math.max(e,s),null==t&&e<=h,Math.min(l,r),null==i&&l>=c,o.dir)}if((s=n.to+1)>=r)break}return 0==l.length&&a(h,null==t,c,null==i,e.textDirection),{top:s,bottom:o,horizontal:l}}function w(e,t){let i=l.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 s=sk(e);return[new sw(t,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}}}function sk(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==is.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function sy(e,t,i,n){let s=e.coordsAtPos(t,2*i);if(!s)return n;let r=e.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=e.posAtCoords({x:r.left+1,y:o}),a=e.posAtCoords({x:r.right-1,y:o});return null==l||null==a?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}class sS{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(sv)!=e.state.facet(sv)&&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(sv);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 sv=ei.define();function sQ(e){return[iV.define(t=>new sS(t,e)),sv.of(e)]}const s$=!(tz.ios&&tz.webkit&&tz.webkit_version<534),sP=ei.define({combine:e=>eL(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function sZ(e){return e.startState.facet(sP)!=e.state.facet(sP)}const sT=sQ({above:!0,markers(e){let{state:t}=e,i=t.facet(sP),n=[];for(let s of t.selection.ranges){let r=s==t.selection.main;if(s.empty?!r||s$:i.drawRangeCursor){let t=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:K.cursor(s.head,s.head>s.anchor?-1:1);for(let s of sw.forRange(e,t,i))n.push(s)}}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=sZ(e);return i&&sC(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){sC(t.state,e)},class:"cm-cursorLayer"});function sC(e,t){t.style.animationDuration=e.facet(sP).cursorBlinkRate+"ms"}const sA=sQ({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:sw.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||sZ(e),class:"cm-selectionLayer"}),sR={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};s$&&(sR[".cm-line"].caretColor=sR[".cm-content"].caretColor="transparent !important");const sM=eu.highest(so.theme(sR)),sX=eZ.define({map:(e,t)=>null==e?null:t.mapPos(e)}),sq=ea.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(sX)?t.value:e,e))}),sE=iV.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(sq);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(sq)!=i||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(sq),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(sq)!=e&&this.view.dispatch({effects:sX.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 sL(e,t,i,n,s){t.lastIndex=0;for(let r=e.iterRange(i,n),o=i,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=t.exec(r.value);)s(o+l.index,l)}class sV{constructor(e){let{regexp:t,decoration:i,decorate:n,boundary:s,maxLength:r=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,s)=>n(s,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,n,s)=>{let r=i(e,t,n);r&&s(n,n+e[0].length,r)};else if(i)this.addMatch=(e,t,n,s)=>s(n,n+e[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=r}createDeco(e){let t=new ej,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:s,to:r}of i)s=Math.max(e.state.doc.lineAt(s).from,s-t),r=Math.min(e.state.doc.lineAt(r).to,r+t),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}(e,this.maxLength))sL(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,s,r,o)=>{o>=e.view.viewport.from&&r<=e.view.viewport.to&&(i=Math.min(r,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 s of e.visibleRanges){let r=Math.max(s.from,i),o=Math.min(s.to,n);if(o>r){let i=e.state.doc.lineAt(r),n=i.toi.from;r--)if(this.boundary.test(i.text[r-1-i.from])){l=r;break}for(;oh.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.indexthis.addMatch(i,e,t,u));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>ea,add:h})}}return t}}const s_=null!=/x/.unicode?"gu":"g",sD=RegExp("[\0-\b\n-\x1f-\u2028\u2029\uFEFF-]",s_),sW={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 sz=null;const sj=ei.define({combine(e){let t=eL(e,{render:null,specialChars:sD,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==sz&&"undefined"!=typeof document&&document.body){let t=document.body.style;sz=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)!=null}return sz||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,s_)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,s_)),t}});let sB=null;class sY 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")+" "+(sW[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,i);if(s)return s;let r=document.createElement("span");return r.textContent=i,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class sI 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 sU=t1.line({class:"cm-activeLine"}),sN=iV.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 s=e.lineBlockAt(n.head);s.from>t&&(i.push(sU.range(s.from)),t=s.from)}return t1.set(i)}},{decorations:e=>e.decorations});function sG(e,t){var i;let n,s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(s),o=s-r.from,l=o>2e3?-1:o==r.length?(i=t.clientX,(n=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((n.left-i)/e.defaultCharacterWidth)):-1):e0(r.text,e.state.tabSize,s-r.from);return{line:r.number,col:l,off:o}}const sH={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},sF={style:"cursor: crosshair"},sJ="-10000px";class sK{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 s=null;this.tooltipViews=this.tooltips.map(e=>s=i(e,s))}update(e,t){var i;let n=e.state.facet(this.facet),s=n.filter(e=>e);if(n===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],o=t?[]:null;for(let i=0;ir.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=s,this.tooltipViews=r,!0}}function s0(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const s1=ei.define({combine:e=>{var t,i,n;return{position:tz.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)||s0}}}),s2=new WeakMap,s5=iV.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(s1);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 sK(e,s9,(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(s1);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=sJ,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(tz.gecko)i=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==sJ&&"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(),s=iN(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.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(s1).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:s,scaleY:r}=e,o=[];for(let l=0;l=Math.min(i.bottom,n.bottom)||u.rightMath.min(i.right,n.right)+.1)){c.style.top=sJ;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!f,O=d.right-d.left,m=null!==(t=s2.get(h))&&void 0!==t?t:d.bottom-d.top,g=h.offset||s7,b=this.view.textDirection==is.LTR,x=d.width>n.right-n.left?b?n.left:n.right-d.width:b?Math.max(n.left,Math.min(u.left-14*!!f+g.x,n.right-O)):Math.min(Math.max(n.left,u.left-O+14*!!f-g.x),n.right-O),w=this.above[l];!a.strictSide&&(w?u.top-m-p-g.yn.bottom)&&w==n.bottom-u.bottom>u.top-n.top&&(w=this.above[l]=!w);let k=(w?u.top-n.top:n.bottom-u.bottom)-p;if(kx&&e.topy&&(y=w?e.top-m-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(y-e.parent.top)/r+"px",s3(c,(x-e.parent.left)/s)):(c.style.top=y/r+"px",s3(c,x/s)),f){let e=u.left+(b?g.x:-g.x)-(x+14-7);f.style.left=e/s+"px"}!0!==h.overlap&&o.push({left:x,top:y,right:S,bottom:y+m}),c.classList.toggle("cm-tooltip-above",w),c.classList.toggle("cm-tooltip-below",!w),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=sJ}},{eventObservers:{scroll(){this.maybeMeasure()}}});function s3(e,t){let i=parseInt(e.style.left,10);(isNaN(i)||Math.abs(t-i)>1)&&(e.style.left=t+"px")}const s4=so.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"}}}),s7={x:0,y:0},s9=ei.define({enables:[s5,s4]}),s8=ei.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class s6{static create(e){return new s6(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new sK(e,s8,(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 re=s9.compute([s8],e=>{let t=e.facet(s8);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:s6.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class rt{constructor(e,t,i,n,s){this.view=e,this.source=t,this.field=i,this.setHover=n,this.hoverTime=s,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 r=e.bidiSpans(e.state.doc.lineAt(n)).find(e=>e.from<=n&&e.to>=n),o=r&&r.dir==is.RTL?-1:1;s=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=>iX(e.state,t,"hover tooltip"))}else r&&!(Array.isArray(r)&&!r.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(s5),t=e?e.manager.tooltips.findIndex(e=>e.create==s6.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:s}=this;if(n.length&&s&&!function(e,t){let{left:i,right:n,top:s,bottom:r}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let e=o.getBoundingClientRect();s=Math.min(e.top,s),r=Math.max(e.bottom,r)}return t.clientX>=i-4&&t.clientX<=n+4&&t.clientY>=s-4&&t.clientY<=r+4}(s.dom,e)||this.pending){let{pos:s}=n[0]||this.pending,r=null!==(i=null===(t=n[0])||void 0===t?void 0:t.end)&&void 0!==i?i:s;(s==r?this.view.posAtCoords(this.lastMove)!=s:!function(e,t,i,n,s,r){let o=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>n||o.rights||Math.min(o.bottom,l)=t&&a<=i}(this.view,s,r,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 ri(e,t){let i=e.plugin(s5);if(!i)return null;let n=i.manager.tooltips.indexOf(t);return n<0?null:i.manager.tooltipViews[n]}const rn=eZ.define(),rs=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 rr(e,t){let i=e.plugin(ro),n=i?i.specs.indexOf(t):-1;return n>-1?i.panels[n]:null}const ro=iV.fromClass(class{constructor(e){this.input=e.state.facet(rh),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(rs);for(let i of(this.top=new rl(e,!0,t.topContainer),this.bottom=new rl(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(rs);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new rl(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new rl(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(rh);if(i!=this.input){let t=i.filter(e=>e),n=[],s=[],r=[],o=[];for(let i of t){let t=this.specs.indexOf(i),l;t<0?(l=i(e.view),o.push(l)):(l=this.panels[t]).update&&l.update(e),n.push(l),(l.top?s:r).push(l)}for(let e of(this.specs=t,this.panels=n,this.top.sync(s),this.bottom.sync(r),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=>so.scrollMargins.of(t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class rl{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=ra(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ra(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 ra(e){let t=e.nextSibling;return e.remove(),t}const rh=ei.define({enables:ro});class rc extends eV{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}rc.prototype.elementClass="",rc.prototype.toDOM=void 0,rc.prototype.mapMode=j.TrackBefore,rc.prototype.startSide=rc.prototype.endSide=-1,rc.prototype.point=!0;const ru=ei.define(),rd=ei.define(),rf={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ez.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},rp=ei.define(),rO=ei.define({combine:e=>e.some(e=>e)});function rm(e){let t=[rg];return e&&!1===e.fixed&&t.push(rO.of(!0)),t}const rg=iV.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(rp).map(t=>new rk(e,t)),this.gutters))this.dom.appendChild(t.dom);this.fixed=!e.state.facet(rO),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(rO)!=!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=ez.iter(this.view.state.facet(ru),this.view.viewport.from),n=[],s=this.gutters.map(e=>new rw(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 r of e.type)if(r.type==t0.Text&&t){for(let e of(rx(i,n,r.from),s))e.line(this.view,r,n);t=!1}else if(r.widget)for(let e of s)e.widget(this.view,r)}else if(e.type==t0.Text)for(let t of(rx(i,n,e.from),s))t.line(this.view,e,n);else if(e.widget)for(let t of s)t.widget(this.view,e);for(let e of s)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(rp),i=e.state.facet(rp),n=e.docChanged||e.heightChanged||e.viewportChanged||!ez.eq(e.startState.facet(ru),e.state.facet(ru),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 s=[];for(let n of i){let i=t.indexOf(n);i<0?s.push(new rk(this.view,n)):(this.gutters[i].update(e),s.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),0>s.indexOf(e)&&e.destroy();for(let e of s)this.dom.appendChild(e.dom);this.gutters=s}return n}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>so.scrollMargins.of(t=>{let i=t.plugin(e);return i&&0!=i.gutters.length&&i.fixed?t.textDirection==is.LTR?{left:i.dom.offsetWidth*t.scaleX}:{right:i.dom.offsetWidth*t.scaleX}:null})});function rb(e){return Array.isArray(e)?e:[e]}function rx(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class rw{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ez.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,s=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==n.elements.length){let t=new ry(e,r,s,i);n.elements.push(t),n.dom.appendChild(t.dom)}else n.elements[this.i].update(e,r,s,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];rx(this.cursor,n,t.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(e,t,n);s&&n.unshift(s);let r=this.gutter;(0!=n.length||r.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(rd)){let s=i(e,t.widget,t);s&&(n||(n=[])).push(s)}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 rk{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 s=n.target,r;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let e=s.getBoundingClientRect();r=(e.top+e.bottom)/2}else r=n.clientY;let o=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[i](e,o,n)&&n.preventDefault()});this.markers=rb(t.markers(e)),t.initialSpacer&&(this.spacer=new ry(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=rb(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!ez.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 ry{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;ieL(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],s=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||s(e,t,i):s}return i}})});class r$ extends rc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function rP(e,t){return e.state.facet(rQ).formatNumber(t,e.state)}const rZ=rp.compute([rQ],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(rS),lineMarker:(e,t,i)=>i.some(e=>e.toDOM)?null:new r$(rP(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,i)=>{for(let n of e.state.facet(rv)){let s=n(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(rQ)!=e.state.facet(rQ),initialSpacer:e=>new r$(rP(e,rT(e.state.doc.lines))),updateSpacer(e,t){let i=rP(t.view,rT(t.view.state.doc.lines));return i==e.number?e:new r$(i)},domEventHandlers:e.facet(rQ).domEventHandlers}));function rT(e){let t=9;for(;t{let t=[],i=-1;for(let n of e.selection.ranges){let s=e.doc.lineAt(n.head).from;s>i&&(i=s,t.push(rC.range(s)))}return ez.of(t)});let rR=0;class rM{constructor(e,t){this.from=e,this.to=t}}class rX{constructor(e={}){this.id=rR++,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=rL.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}rX.closedBy=new rX({deserialize:e=>e.split(" ")}),rX.openedBy=new rX({deserialize:e=>e.split(" ")}),rX.group=new rX({deserialize:e=>e.split(" ")}),rX.isolate=new rX({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),rX.contextHash=new rX({perNode:!0}),rX.lookAhead=new rX({perNode:!0}),rX.mounted=new rX({perNode:!0});class rq{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[rX.mounted.id]}}const rE=Object.create(null);class rL{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):rE,i=+!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),n=new rL(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(rX.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(rX.group),n=-1;n<(i?i.length:0);n++){let s=t[n<0?e.name:i[n]];if(s)return s}}}}rL.none=new rL("",Object.create(null),0,8);class rV{constructor(e){this.types=e;for(let t=0;t=t){let o=new rU(r.tree,r.overlay[0].from+e.from,-1,e);(s||(s=[n])).push(rY(o,t,i,!1))}}return s?rJ(s):n}(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:s=this.length}=e,r=e.mode||0,o=(r&L.IncludeAnonymous)>0;for(let e=this.cursor(r|L.IncludeAnonymous);;){let r=!1;if(e.from<=s&&e.to>=n&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;r=!0}for(;r&&i&&(o||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;r=!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:r3(rL.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new rW(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new rW(rL.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:s=1024,reused:r=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(i)?new rz(i,i.length):i,a=n.types,h=0,c=0;function u(e,t,i,s,r,o,l,a,h){let c=[],u=[];for(;e.length>s;)c.push(e.pop()),u.push(t.pop()+i-r);e.push(d(n.types[l],c,u,o-r,a-o,h)),t.push(r-i)}function d(e,t,i,n,s,r,o){if(r){let e=[rX.contextHash,r];o=o?[e].concat(o):[e]}if(s>25){let e=[rX.lookAhead,s];o=o?[e].concat(o):[e]}return new rW(e,t,i,n,o)}let f=[],p=[];for(;l.pos>0;)!function e(t,i,f,p,O,m){let{id:g,start:b,end:x,size:w}=l,k=c,y=h;for(;w<0;){if(l.next(),-1==w){let e=r[g];f.push(e),p.push(b-t);return}if(-3==w){h=g;return}if(-4==w){c=g;return}else throw RangeError(`Unrecognized record size: ${w}`)}let S=a[g],v,Q,$=b-t;if(x-b<=s&&(Q=function(e,t){let i=l.fork(),n=0,r=0,a=0,h=i.end-s,c={size:0,start:0,skip:0};i:for(let s=i.pos-e;i.pos>s;){let e=i.size;if(i.id==t&&e>=0){c.size=n,c.start=r,c.skip=a,a+=4,n+=4,i.next();continue}let l=i.pos-e;if(e<0||l=o),d=i.start;for(i.next();i.pos>l;){if(i.size<0){if(-3==i.size)u+=4;else break i}else i.id>=o&&(u+=4);i.next()}r=d,n+=e,a+=u}return(t<0||n==e)&&(c.size=n,c.start=r,c.skip=a),c.size>4?c:void 0}(l.pos-i,O))){let e=new Uint16Array(Q.size-Q.skip),i=l.pos-Q.size,s=e.length;for(;l.pos>i;)s=function e(t,i,n){let{id:s,start:r,end:a,size:u}=l;if(l.next(),u>=0&&s4){let s=l.pos-(u-4);for(;l.pos>s;)n=e(t,i,n)}i[--n]=o,i[--n]=a-t,i[--n]=r-t,i[--n]=s}else -3==u?h=s:-4==u&&(c=s);return n}(Q.start,e,s);v=new rj(e,x-Q.start,n),$=Q.start-t}else{let t=l.pos-w;l.next();let i=[],r=[],a=g>=o?g:-1,h=0,c=x;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-s&&(u(i,r,b,h,l.end,c,a,k,y),h=i.length,c=l.end),l.next()):m>2500?function(e,t,i,r){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:i,size:n}=l;if(n>4)l.next();else if(h>-1&&t=0;e-=3)t[i++]=o[e],t[i++]=o[e+1]-s,t[i++]=o[e+2]-s,t[i++]=i;i.push(new rj(t,o[2]-s,n)),r.push(s-e)}}(b,t,i,r):e(b,t,i,r,a,m+1);if(a>=0&&h>0&&h-1&&h>0){let e=function(e,t){return(i,n,s)=>{let r=0,o=i.length-1,l,a;if(o>=0&&(l=i[o])instanceof rW){if(!o&&l.type==e&&l.length==s)return l;(a=l.prop(rX.lookAhead))&&(r=n[o]+l.length+a)}return d(e,i,n,s,r,t)}}(S,y);v=r3(S,i,r,0,i.length,0,x-b,e,e)}else v=d(S,i,r,x-b,k-x,y)}f.push(v),p.push($)}(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 rW(a[e.topID],f.reverse(),p.reverse(),O)}(e)}}rW.empty=new rW(rL.none,[],[],0);class rz{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 rz(this.buffer,this.index)}}class rj{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return rL.none}toString(){let e=[];for(let t=0;t0)));l=r[l+3]);return o}slice(e,t,i){let n=this.buffer,s=new Uint16Array(t-e),r=0;for(let o=e,l=0;o=t&⁢case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function rY(e,t,i,n){for(var s;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to0?o.length:-1;e!=a;e+=t){let a=o[e],h=l[e]+r.from;if(rB(n,i,h,h+a.length)){if(a instanceof rj){if(s&L.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,t,i-h,n);if(o>-1)return new rF(new rH(r,a,e,h),null,o)}else if(s&L.IncludeAnonymous||!a.type.isAnonymous||r1(a)){let o;if(!(s&L.IgnoreMounts)&&(o=rq.get(a))&&!o.overlay)return new rU(o.tree,h,e,r);let l=new rU(a,h,e,r);return s&L.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,i,n)}}}if(s&L.IncludeAnonymous||!r.type.isAnonymous||(e=r.index>=0?r.index+t:t<0?-1:r._parent._tree.children.length,!(r=r._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&L.IgnoreOverlays)&&(n=rq.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:e,to:s}of n.overlay)if((t>0?e<=i:e=i:s>i))return new rU(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 rN(e,t,i,n){let s=e.cursor(),r=[];if(!s.firstChild())return r;if(null!=i){for(let e=!1;!e;)if(e=s.type.is(i),!s.nextSibling())return r}for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function rG(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 rH{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class rF extends rI{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,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new rF(this.context,this,s)}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&L.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new rF(this.context,this,s)}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 rF(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 rF(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,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];e.push(i.slice(n,s,r)),t.push(0)}return new rW(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function rJ(e){if(!e.length)return null;let t=0,i=e[0];for(let n=1;ni.from||s.to0){if(this.index-1)for(let n=t+e,s=e<0?-1:i._tree.children.length;n!=s;n+=e){let e=i._tree.children[n];if(this.mode&L.IncludeAnonymous||e instanceof rj||!e.type.isAnonymous||r1(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 r=e;r;r=r._parent)if(r.index==n){if(n==this.index)return r;t=r,i=s+1;break i}n=this.stack[--s]}for(let e=i;e=0;s--){if(s<0)return rG(this._tree,e,n);let r=i[t.buffer[this.stack[s]]];if(!r.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}}function r1(e){return e.children.some(e=>e instanceof rj||!e.type.isAnonymous||r1(e))}const r2=new WeakMap;function r5(e,t){if(!e.isAnonymous||t instanceof rj||t.type!=e)return 1;let i=r2.get(t);if(null==i){for(let n of(i=1,t.children)){if(n.type!=e||!(n instanceof rW)){i=1;break}i+=r5(e,n)}r2.set(t,i)}return i}function r3(e,t,i,n,s,r,o,l,a){let h=0;for(let i=n;i=c)break;p+=t}if(h==s+1){if(p>c){let e=i[s];t(e.children,e.positions,0,e.children.length,n[s]+l);continue}u.push(i[s])}else{let t=n[h-1]+i[h-1].length-f;u.push(r3(e,i,n,s,h,f,t,null,a))}d.push(f+l-r)}}(t,i,n,s,0),(l||a)(u,d,o)}class r4{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 rF?this.setBuffer(e.context.buffer,e.index,t):e instanceof rU&&this.map.set(e.tree,t)}get(e){return e instanceof rF?this.getBuffer(e.context.buffer,e.index):e instanceof rU?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 r7{constructor(e,t,i,n,s=!1,r=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=+!!s|2*!!r}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new r7(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=[],s=1,r=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o=i)for(;r&&r.from=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,i=Math.min(t.to,c)-a;t=e>=i?null:new r7(e,i,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),r.to>c)break;r=snew rM(e.from,e.to)):[new rM(0,0)]:[new rM(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 r8{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 r6(e){return(t,i,n,s)=>new os(t,e,i,n,s)}class oe{constructor(e,t,i,n,s){this.parser=e,this.parse=t,this.overlay=i,this.target=n,this.from=s}}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,s,r,o){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=s,this.target=r,this.prev=o,this.depth=0,this.ranges=[]}}const on=new rX({perNode:!0});class os{constructor(e,t,i,n,s){this.nest=t,this.input=i,this.fragments=n,this.ranges=s,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 rW(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[rX.mounted.id]=new rq(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 s=i.from+e.pos,r=i.to+e.pos;s>=n.from&&r<=n.to&&!t.ranges.some(e=>e.froms)&&t.ranges.push({from:s,to:r})}}o=!1}else if(i&&(r=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!=r;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.fromnew rM(e.from-n.from,e.to-n.from)):null,n.tree,e.length?e[0].from:n.from)),s.overlay?e.length&&(i={ranges:e,depth:0,prev:i}):o=!1}}else if(t&&(l=t.predicate(n))&&(!0===l&&(l=new rM(n.from,n.to)),l.from=0&&t.ranges[e].to==l.from?t.ranges[e]={from:t.ranges[e].from,to:l.to}:t.ranges.push(l)}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=oa(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 rM(e.from-t.start,e.to-t.start)),t.target,e[0].from))),t=t.prev}!i||--i.depth||(i=i.prev)}}}}function or(e,t,i,n,s,r){if(t=e&&t.enter(i,1,L.IgnoreOverlays|L.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 rW)t=t.children[0];else break}return!1}}class ol{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 s=null===(i=e.tree)||void 0===i?void 0:i.prop(rX.mounted);if(s&&s.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:s})}}}return n}}function oa(e,t){let i=null,n=t;for(let s=1,r=0;s=l)break;!(e.to<=o)&&(i||(n=i=t.slice()),e.froml&&i.splice(r+1,0,new rM(l,e.to))):e.to>l?i[r--]=new rM(l,e.to):i.splice(r--,1))}}return n}function oh(e,t){let i=[];for(let{pos:n,mount:s,frag:r}of e){let e=n+(s.overlay?s.overlay[0].from:0),o=e+s.tree.length,l=Math.max(r.from,e),a=Math.min(r.to,o);if(s.overlay){let o=function(e,t,i,n){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=s==e.length?1e9:o?e[s].to:e[s].from,u=r==t.length?1e9:l?t[r].to:t[r].from;if(o!=l){let e=Math.max(a,i),t=Math.min(c,u,n);enew rM(e.from+n,e.to+n)),l,a);for(let t=0,n=l;;t++){let l=t==o.length,h=l?a:o[t].from;if(h>n&&i.push(new r7(n,h,s.tree,-e,r.from>=n||r.openStart,r.to<=h||r.openEnd)),l)break;n=o[t].to}}else i.push(new r7(l,a,s.tree,-e,r.from>=e||r.openStart,r.to<=o||r.openEnd))}return i}let oc=0;class ou{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=oc++}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 ou&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let i=new ou("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,s;return i.base==e&&(n=t,s=i.modified,n.length==s.length&&n.every((e,t)=>e==s[t]))});if(i)return i;let n=[],s=new ou(e.name,n,e,t);for(let e of t)e.instances.push(s);let r=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 r)n.push(of.get(t,e));return s}}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=[],s=2,r=e;for(let t=0;;){if("..."==r&&t>0&&t+3==e.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);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){s=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);r=e.slice(t)}let o=i.length-1,l=i[o];if(!l)throw RangeError("Invalid path: "+e);let a=new om(n,s,o>0?i.slice(0,o):null);t[l]=a.sort(t[l])}}return oO.add(t)}const oO=new rX;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=s;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,s){let{type:r,from:o,to:l}=e;if(o>=i||l<=t)return;r.isTop&&(s=this.highlighters.filter(e=>!e.scope||e.scope(r)));let a=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,c=function(e,t){let i=null;for(let n of e){let e=n.style(t);e&&(i=i?i+" "+e:e)}return i}(s,h.tags);if(c&&(a&&(a+=" "),a+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,o),a),h.opaque)return;let u=e.tree&&e.tree.prop(rX.mounted);if(u&&u.overlay){let r=e.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),c=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(r.cursor(),Math.max(t,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),a))}c&&e.parent()}else if(e.firstChild()){u&&(n="");do{if(e.to<=t)continue;if(e.from>=i)break;this.highlightRange(e,t,i,n,s),this.startSpan(Math.min(i,e.to),a)}while(e.nextSibling())e.parent()}}}const ox=ou.define,ow=ox(),ok=ox(),oy=ox(ok),oS=ox(ok),ov=ox(),oQ=ox(ov),o$=ox(ov),oP=ox(),oZ=ox(oP),oT=ox(),oC=ox(),oA=ox(),oR=ox(oA),oM=ox(),oX={comment:ow,lineComment:ox(ow),blockComment:ox(ow),docComment:ox(ow),name:ok,variableName:ox(ok),typeName:oy,tagName:ox(oy),propertyName:oS,attributeName:ox(oS),className:ox(ok),labelName:ox(ok),namespace:ox(ok),macroName:ox(ok),literal:ov,string:oQ,docString:ox(oQ),character:ox(oQ),attributeValue:ox(oQ),number:o$,integer:ox(o$),float:ox(o$),bool:ox(ov),regexp:ox(ov),escape:ox(ov),color:ox(ov),url:ox(ov),keyword:oT,self:ox(oT),null:ox(oT),atom:ox(oT),unit:ox(oT),modifier:ox(oT),operatorKeyword:ox(oT),controlKeyword:ox(oT),definitionKeyword:ox(oT),moduleKeyword:ox(oT),operator:oC,derefOperator:ox(oC),arithmeticOperator:ox(oC),logicOperator:ox(oC),bitwiseOperator:ox(oC),compareOperator:ox(oC),updateOperator:ox(oC),definitionOperator:ox(oC),typeOperator:ox(oC),controlOperator:ox(oC),punctuation:oA,separator:ox(oA),bracket:oR,angleBracket:ox(oR),squareBracket:ox(oR),paren:ox(oR),brace:ox(oR),content:oP,heading:oZ,heading1:ox(oZ),heading2:ox(oZ),heading3:ox(oZ),heading4:ox(oZ),heading5:ox(oZ),heading6:ox(oZ),contentSeparator:ox(oP),list:ox(oP),quote:ox(oP),emphasis:ox(oP),strong:ox(oP),link:ox(oP),monospace:ox(oP),strikethrough:ox(oP),inserted:ox(),deleted:ox(),changed:ox(),invalid:ox(),meta:oM,documentMeta:ox(oM),annotation:ox(oM),processingInstruction:ox(oM),definition:ou.defineModifier("definition"),constant:ou.defineModifier("constant"),function:ou.defineModifier("function"),standard:ou.defineModifier("standard"),local:ou.defineModifier("local"),special:ou.defineModifier("special")};for(let e in oX){let t=oX[e];t instanceof ou&&(t.name=e)}og([{tag:oX.link,class:"tok-link"},{tag:oX.heading,class:"tok-heading"},{tag:oX.emphasis,class:"tok-emphasis"},{tag:oX.strong,class:"tok-strong"},{tag:oX.keyword,class:"tok-keyword"},{tag:oX.atom,class:"tok-atom"},{tag:oX.bool,class:"tok-bool"},{tag:oX.url,class:"tok-url"},{tag:oX.labelName,class:"tok-labelName"},{tag:oX.inserted,class:"tok-inserted"},{tag:oX.deleted,class:"tok-deleted"},{tag:oX.literal,class:"tok-literal"},{tag:oX.string,class:"tok-string"},{tag:oX.number,class:"tok-number"},{tag:[oX.regexp,oX.escape,oX.special(oX.string)],class:"tok-string2"},{tag:oX.variableName,class:"tok-variableName"},{tag:oX.local(oX.variableName),class:"tok-variableName tok-local"},{tag:oX.definition(oX.variableName),class:"tok-variableName tok-definition"},{tag:oX.special(oX.variableName),class:"tok-variableName2"},{tag:oX.definition(oX.propertyName),class:"tok-propertyName tok-definition"},{tag:oX.typeName,class:"tok-typeName"},{tag:oX.namespace,class:"tok-namespace"},{tag:oX.className,class:"tok-className"},{tag:oX.macroName,class:"tok-macroName"},{tag:oX.propertyName,class:"tok-propertyName"},{tag:oX.operator,class:"tok-operator"},{tag:oX.comment,class:"tok-comment"},{tag:oX.meta,class:"tok-meta"},{tag:oX.invalid,class:"tok-invalid"},{tag:oX.punctuation,class:"tok-punctuation"}]);const oq=new rX;function oE(e){return ei.define({combine:e?t=>t.concat(e):void 0})}const oL=new rX;class oV{constructor(e,t,i=[],n=""){this.data=e,this.name=n,eE.prototype.hasOwnProperty("tree")||Object.defineProperty(eE.prototype,"tree",{get(){return oW(this)}}),this.parser=t,this.extension=[oH.of(this),eE.languageData.of((e,t,i)=>{let n=o_(e,t,i),s=n.type.prop(oq);if(!s)return[];let r=e.facet(s),o=n.type.prop(oL);if(o){let s=n.resolve(t-n.from,i);for(let t of o)if(t.test(s,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(r)}}return r})].concat(i)}isActiveAt(e,t,i=-1){return o_(e,t,i).type.prop(oq)==this.data}findRegions(e){let t=e.facet(oH);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(oq)==this.data){i.push({from:t,to:t+e.length});return}let s=e.prop(rX.mounted);if(s){if(s.tree.prop(oq)==this.data){if(s.overlay)for(let e of s.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(s.overlay){let e=i.length;if(n(s.tree,s.overlay[0].from+t),i.length>e)return}}for(let i=0;ie.isTop?t:void 0)]}),e.name)}configure(e,t){return new oD(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function oW(e){let t=e.field(oV.state,!1);return t?t.tree:rW.empty}class oz{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 oj=null;class oB{constructor(e,t,i=[],n,s,r,o,l){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new oB(e,t,[],rW.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oz(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=rW.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(r7.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=oj;oj=this;try{return e()}finally{oj=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=oY(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,i,n,s)=>t.push({fromA:e,toA:i,fromB:n,toB:s})),i=r7.applyChanges(i,t),n=rW.empty,s=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.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=oY(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 r9{createParse(t,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let t=oj;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=r,new rW(rL.none,[],[],r-s)},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 oj}}function oY(e,t,i){return r7.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class oI{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 oI(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=oB.create(e.facet(oH).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new oI(i)}}oV.state=ea.define({create:oI.init,update(e,t){for(let e of t.effects)if(e.is(oV.setState))return e.value;return t.startState.facet(oH)!=t.state.facet(oH)?oI.init(t.state):e.apply(t)}});let oU=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(oU=e=>{let t=-1,i=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const oN="undefined"!=typeof navigator&&(null===(V=navigator.scheduling)||void 0===V?void 0:V.isInputPending)?()=>navigator.scheduling.isInputPending():null,oG=iV.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(oV.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(oV.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=oU(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,l=s.context.work(()=>oN&&oN()||Date.now()>r,n+1e5*!o);this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:oV.setState.of(new oI(s.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>iX(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()}}}),oH=ei.define({combine:e=>e.length?e[0]:null,enables:e=>[oV.state,oG,so.contentAttributes.compute([e],t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}})]});class oF{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class oJ{constructor(e,t,i,n,s,r){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=r,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,s=e.facet(o0)[0];if(" "==s){for(;t>=n;)i+=" ",t-=n;s=" "}for(let e=0;e=t?function(e,t,i){let n=t.resolveStack(i),s=t.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let e=[];for(let t=s;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:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==e?{text:"",from:e}:(t<0?n-1&&(s+=r-this.countColumn(i,i.search(/\S|$/))),s}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),s=this.options.overrideIndentation;if(s){let e=s(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const o4=new rX;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(rX.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>o6(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(o8.create(t,i,n))}return 0}function o9(){return 0}class o8 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 o8(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 o6(e,t,i,n,s){let r=e.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==e.pos+o,a=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let s=e.options.simulateBreak,r=e.state.doc.lineAt(i.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let e=i.to;;){let s=t.childAfter(e);if(!s||s==n)return null;if(!s.type.isSkipped){if(s.from>=o)return null;let e=/^ */.exec(r.text.slice(i.to-r.from))[0].length;return{from:i.from,to:i.to+e}}e=s.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*i)}function le({except:e,units:t=1}={}){return i=>{let n=e&&e.test(i.textAfter);return i.baseIndent+(n?0:t*i.unit)}}const lt=ei.define(),li=new rX;function ln(e){let t=e.firstChild,i=e.lastChild;return t&&t.toi)continue;if(r&&s.from=t&&n.to>i&&(r=n)}}return r}(e,t,i)}function lr(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 lo=eZ.define({map:lr}),ll=eZ.define({map:lr});function la(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 lh=ea.define({create:()=>t1.none,update(e,t){for(let i of(e=e.map(t.changes),t.effects))if(i.is(lo)&&!function(e,t,i){let n=!1;return e.between(t,t,(e,s)=>{e==t&&s==i&&(n=!0)}),n}(e,i.value.from,i.value.to)){let{preparePlaceholder:n}=t.state.facet(lO),s=n?t1.replace({widget:new lx(n(t.state,i.value))}):lb;e=e.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(ll)&&(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=>so.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{(!s||s.from>e)&&(s={from:e,to:t})}),s}function lu(e,t){return e.field(lh,!1)?t:t.concat(eZ.appendConfig.of(lm()))}function ld(e,t,i=!0){let n=e.state.doc.lineAt(t.from).number,s=e.state.doc.lineAt(t.to).number;return so.announce.of(`${e.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${e.state.phrase("to")} ${s}.`)}const lf=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of la(e)){let i=ls(e.state,t.from,t.to);if(i)return e.dispatch({effects:lu(e.state,[lo.of(i),ld(e,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(lh,!1))return!1;let t=[];for(let i of la(e)){let n=lc(e.state,i.from,i.to);n&&t.push(ll.of(n),ld(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(lh,!1);if(!t||!t.size)return!1;let i=[];return t.between(0,e.state.doc.length,(e,t)=>{i.push(ll.of({from:e,to:t}))}),e.dispatch({effects:i}),!0}}],lp={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lO=ei.define({combine:e=>eL(e,lp)});function lm(e){let t=[lh,ly];return e&&t.push(lO.of(e)),t}function lg(e,t){let{state:i}=e,n=i.facet(lO),s=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),n=lc(e.state,i.from,i.to);n&&e.dispatch({effects:ll.of(n)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,s,t);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const lb=t1.replace({widget:new class extends tK{toDOM(e){return lg(e,null)}}});class lx extends tK{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return lg(e,this.value)}}const lw={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class lk extends rc{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 ly=so.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 lS{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 s="string"==typeof t.all?t.all:t.all?n(t.all):void 0,r=t.scope;this.scope=r instanceof oV?e=>e.prop(oq)==r.data:r?e=>e==r:void 0,this.style=og(e.map(e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))})),{all:s}).style,this.module=i?new e4(i):null,this.themeType=t.themeType}static define(e,t){return new lS(e,t||{})}}const lv=ei.define(),lQ=ei.define({combine:e=>e.length?[e[0]]:null});function l$(e){let t=e.facet(lv);return t.length?t:e.facet(lQ)}const lP=eu.high(iV.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=oW(e.state),this.decorations=this.buildDeco(e,l$(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=oW(e.state),i=l$(e.state),n=i!=l$(e.startState),{viewport:s}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return t1.none;let i=new ej;for(let{from:n,to:s}of e.visibleRanges)!function(e,t,i,n=0,s=e.length){let r=new ob(n,Array.isArray(t)?t:[t],i);r.highlightRange(e.cursor(),n,s,"",r.highlighters),r.flush(s)}(this.tree,t,(e,t,n)=>{i.add(e,t,this.markCache[n]||(this.markCache[n]=t1.mark({class:n})))},n,s);return i.finish()}},{decorations:e=>e.decorations})),lZ=lS.define([{tag:oX.meta,color:"#404740"},{tag:oX.link,textDecoration:"underline"},{tag:oX.heading,textDecoration:"underline",fontWeight:"bold"},{tag:oX.emphasis,fontStyle:"italic"},{tag:oX.strong,fontWeight:"bold"},{tag:oX.strikethrough,textDecoration:"line-through"},{tag:oX.keyword,color:"#708"},{tag:[oX.atom,oX.bool,oX.url,oX.contentSeparator,oX.labelName],color:"#219"},{tag:[oX.literal,oX.inserted],color:"#164"},{tag:[oX.string,oX.deleted],color:"#a11"},{tag:[oX.regexp,oX.escape,oX.special(oX.string)],color:"#e40"},{tag:oX.definition(oX.variableName),color:"#00f"},{tag:oX.local(oX.variableName),color:"#30a"},{tag:[oX.typeName,oX.namespace],color:"#085"},{tag:oX.className,color:"#167"},{tag:[oX.special(oX.variableName),oX.macroName],color:"#256"},{tag:oX.definition(oX.propertyName),color:"#00c"},{tag:oX.comment,color:"#940"},{tag:oX.invalid,color:"#f00"}]),lT=so.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),lC="()[]{}",lA=ei.define({combine:e=>eL(e,{afterCursor:!0,brackets:lC,maxScanDistance:1e4,renderMatch:lX})}),lR=t1.mark({class:"cm-matchingBracket"}),lM=t1.mark({class:"cm-nonmatchingBracket"});function lX(e){let t=[],i=e.matched?lR:lM;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 lq=[ea.define({create:()=>t1.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(lA);for(let e of t.state.selection.ranges){if(!e.empty)continue;let s=l_(t.state,e.head,-1,n)||e.head>0&&l_(t.state,e.head-1,1,n)||n.afterCursor&&(l_(t.state,e.head,1,n)||e.headso.decorations.from(e)}),lT],lE=new rX;function lL(e,t,i){let n=e.prop(t<0?rX.openedBy:rX.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 lV(e){let t=e.type.prop(lE);return t?t(e.node):e}function l_(e,t,i,n={}){let s=n.maxScanDistance||1e4,r=n.brackets||lC,o=oW(e),l=o.resolveInner(t,i);for(let e=l;e;e=e.parent){let n=lL(e.type,i,r);if(n&&e.from0?t>=s.from&&ts.from&&t<=s.to))return function(e,t,i,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&r.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},c=e.doc.iterRange(t,i>0?e.doc.length:0),u=0;for(let e=0;!c.next().done&&e<=r;){let r=c.value;i<0&&(e+=r.length);let l=t+e*i;for(let e=i>0?0:r.length-1,t=i>0?r.length:-1;e!=t;e+=i){let t=o.indexOf(r[e]);if(!(t<0)&&n.resolveInner(l+e,1).type==s){if(t%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};u--}}}i>0&&(e+=r.length)}return c.done?{start:h,matched:!1}:null}(e,t,i,o,l.type,s,r)}const lD=Object.create(null),lW=[rL.none],lz=[],lj=Object.create(null),lB=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"]])lB[e]=function(e,t){let i=[];for(let n of t.split(" ")){let t=[];for(let i of n.split(".")){let n=e[i]||oX[i];n?"function"==typeof n?t.length?t=t.map(n):lY(i,`Modifier ${i} used at start of tag`):t.length?lY(i,`Tag ${i} used as modifier`):t=Array.isArray(n)?n:[n]:lY(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let n=t.replace(/ /g,"_"),s=n+" "+i.map(e=>e.id),r=lj[s];if(r)return r.id;let o=lj[s]=rL.define({id:lW.length,name:n,props:[op({[n]:i})]});return lW.push(o),o.id}(lD,t);function lY(e,t){lz.indexOf(e)>-1||(lz.push(e),console.warn(t))}function lI(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function lU(e){for(let t=e.iter();!t.next().done;)if(lI(t.value))return!0;return!1}const lN=ei.define({combine:e=>e.some(e=>e)});function lG(e,t,i){let n=new ej,s=e.visibleRanges;for(let{from:r,to:o}of(i||(s=function(e,t){let i=t.iter(),n=0,s=[],r=null;for(let{from:t,to:o}of e)if(!r||!(r.to>t)||!((t=r.to)>=o))for(n+i.value.lengthe-10?r.to=Math.min(o,t):s.push(r={from:e,to:Math.min(o,t)})),t>=o)break;n=t,i.next()}return s}(s,e.state.doc)),s))t.iterate({enter:e=>{let t=e.type.prop(rX.isolate);t&&n.add(e.from,e.to,lH[t])},from:r,to:o});return n.finish()}iV.fromClass(class{constructor(e){this.always=e.state.facet(lN)||e.textDirection!=is.LTR||e.state.facet(so.perLineTextDirection),this.hasRTL=!this.always&&lU(e.state.doc),this.tree=oW(e.state),this.decorations=this.always||this.hasRTL?lG(e,this.tree,this.always):t1.none}update(e){var t;let i,n=e.state.facet(lN)||e.view.textDirection!=is.LTR||e.state.facet(so.perLineTextDirection);if(!n&&!this.hasRTL&&(t=e.changes,i=!1,t.iterChanges((e,t,n,s,r)=>{!i&&lU(r)&&(i=!0)}),i)&&(this.hasRTL=!0),!n&&!this.hasRTL)return;let s=oW(e.state);(n!=this.always||s!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=s,this.always=n,this.decorations=lG(e.view,s,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[so.outerDecorations.of(t),eu.lowest(so.bidiIsolatedRanges.of(t))]}});const lH={rtl:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:is.RTL}),ltr:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:is.LTR}),auto:t1.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function lF(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=e(t,i);return!!s&&(n(i.update(s)),!0)}}const lJ=lF(function(e,t,i=t.selection.ranges){let n=[],s=-1;for(let{from:e,to:r}of i){let i=n.length,o=1e9,l=l1(t,e).line;if(l){for(let i=e;i<=r;){let a=t.doc.lineAt(i);if(a.from>s&&(e==r||r>a.from)){s=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,i=a.text.slice(e,e+l.length)==l?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:i,indent:s,empty:r,single:o}of n)(o||!r)&&e.push({from:t.from+s,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:s}of n)if(i>=0){let n=t.from+i,r=n+s.length;" "==t.text[r-t.from]&&r++,e.push({from:n,to:r})}return{changes:e}}return null},0),lK=lF(l2,0),l0=lF((e,t)=>l2(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),s=i.to<=n.to?n:e.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:e.doc.lineAt(i.to-1));let r=t.length-1;r>=0&&t[r].to>n.from?t[r].to=s.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return t}(t)),0);function l1(e,t){let i=e.languageDataAt("commentTokens",t);return i.length?i[0]:{}}function l2(e,t,i=t.selection.ranges){let n=i.map(e=>l1(t,e.from).block);if(!n.every(e=>e))return null;let s=i.map((e,i)=>(function(e,{open:t,close:i},n,s){let r,o,l=e.sliceDoc(n-50,n),a=e.sliceDoc(s,s+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,u=l.length-h;if(l.slice(u-t.length,u)==t&&a.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:s+c,margin:c&&1}};s-n<=100?r=o=e.sliceDoc(n,s):(r=e.sliceDoc(n,n+50),o=e.sliceDoc(s-50,s));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return r.slice(d,d+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:n+d+t.length,margin:+!!/\s/.test(r.charAt(d+t.length))},close:{pos:s-f-i.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(t,n[i],e.from,e.to));if(2!=e&&!s.every(e=>e))return{changes:t.changes(i.map((e,t)=>s[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}]))};if(1!=e&&s.some(e=>e)){let e=[];for(let t=0,i;teL(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)})}),l9=ea.define({create:()=>ac.empty,update(e,t){let i=t.state.facet(l7),n=t.annotation(l5);if(n){let s=an.fromTransaction(t,n.selection),r=n.side,o=0==r?e.undone:e.done;return o=s?as(o,o.length,i.minDepth,s):al(o,t.startState.selection),new ac(0==r?n.rest:o,0==r?o:n.rest)}let s=t.annotation(l3);if(("full"==s||"before"==s)&&(e=e.isolate()),!1===t.annotation(eT.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let r=an.fromTransaction(t),o=t.annotation(eT.time),l=t.annotation(eT.userEvent);return r?e=e.addChanges(r,o,l,i,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,i.newGroupDelay)),("full"==s||"after"==s)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new ac(e.done.map(an.fromJSON),e.undone.map(an.fromJSON))});function l8(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let s=i.field(l9,!1);if(!s)return!1;let r=s.pop(e,i,t);return!!r&&(n(r),!0)}}const l6=l8(0,!1),ae=l8(1,!1),at=l8(0,!0),ai=l8(1,!0);class an{constructor(e,t,i,n,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(e){return new an(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 an(e.changes&&Y.fromJSON(e.changes),[],e.mapped&&B.fromJSON(e.mapped),e.startSelection&&K.fromJSON(e.startSelection),e.selectionsAfter.map(K.fromJSON))}static fromTransaction(e,t){let i=ao;for(let t of e.startState.facet(l4)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new an(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ao)}static selection(e){return new an(void 0,ao,void 0,void 0,e)}}function as(e,t,i,n){let s=e.slice(t+1>i+20?t-i-1:0,t);return s.push(n),s}function ar(e,t){return e.length?t.length?e.concat(t):e:t}const ao=[];function al(e,t){if(!e.length)return[an.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),as(e,e.length-1,1e9,i.setSelAfter(n)))}}function aa(e,t){if(!e.length)return e;let i=e.length,n=ao;for(;i;){let s=function(e,t,i){let n=ar(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):ao,i);if(!e.changes)return an.selection(n);let s=e.changes.map(t),r=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(r):r;return new an(s,eZ.mapEffects(e.effects,t),o,e.startSelection.map(r),n)}(e[i-1],t,n);if(s.changes&&!s.changes.empty||s.effects.length){let t=e.slice(0,i);return t[i-1]=s,t}t=s.mapped,i--,n=s.selectionsAfter}return n.length?[an.selection(n)]:ao}const ah=/^(input\.type|delete)($|\.)/;class ac{constructor(e,t,i=0,n){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new ac(this.done,this.undone):this}addChanges(e,t,i,n,s){var r,o;let l,a,h=this.done,c=h[h.length-1];return new ac(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!i||ah.test(i))&&(!c.selectionsAfter.length&&t-this.prevTimel.push(e,t)),o.iterChangedRanges((e,t,i,n)=>{for(let e=0;e=t&&i<=s&&(a=!0)}}),a))||"input.type.compose"==i)?as(h,h.length-1,n.minDepth,new an(e.changes.compose(c.changes),ar(eZ.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,ao)):as(h,h.length,n.minDepth,e),ao,t,i)}addSelection(e,t,i,n){var s;let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ao;return r.length>0&&t-this.prevTimet.empty!=e.ranges[i].empty).length?this:new ac(al(this.done,e),this.undone,t,i)}addMapping(e){return new ac(aa(this.done,e),aa(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 s=n[n.length-1],r=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length){let i,o;return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:l5.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:r}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!s.changes)return null;let i=1==n.length?ao:n.slice(0,n.length-1);return s.mapped&&(i=aa(i,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:l5.of({side:e,rest:i,selection:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}ac.empty=new ac(ao,ao);function au(e,t){return K.create(e.ranges.map(t),e.mainIndex)}function ad(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function af({state:e,dispatch:t},i){let n=au(e.selection,i);return!n.eq(e.selection,!0)&&(t(ad(e,n)),!0)}function ap(e,t){return K.cursor(t?e.to:e.from)}function aO(e,t){return af(e,i=>i.empty?e.moveByChar(i,t):ap(i,t))}function am(e){return e.textDirectionAt(e.state.selection.main.head)==is.LTR}const ag=e=>aO(e,!am(e)),ab=e=>aO(e,am(e));function ax(e,t){return af(e,i=>i.empty?e.moveByGroup(i,t):ap(i,t))}function aw(e,t,i){let n,s,r=oW(e).resolveInner(t.head),o=i?rX.closedBy:rX.openedBy;for(let n=t.head;;){let t=i?r.childAfter(n):r.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:r=t}return s=r.type.prop(o)&&(n=i?l_(e,r.from,1):l_(e,r.to,-1))&&n.matched?i?n.end.to:n.end.from:i?r.to:r.from,K.cursor(s,i?-1:1)}function ak(e,t){return af(e,i=>{if(!i.empty)return ap(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;const ay=e=>ak(e,!1),aS=e=>ak(e,!0);function av(e){let t=e.scrollDOM.clientHeighti.empty?e.moveVertically(i,t,n.height):ap(i,t));if(r.eq(s.selection))return!1;if(n.selfScroll){let t=e.coordsAtPos(s.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+n.marginTop,a=o.bottom-n.marginBottom;t&&t.top>l&&t.bottomaQ(e,!1),aP=e=>aQ(e,!0);function aZ(e,t,i){let n=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,i);if(s.head==t.head&&s.head!=(i?n.to:n.from)&&(s=e.moveToLineBoundary(t,i,!1)),!i&&s.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&&(s=K.cursor(n.from+i))}return s}function aT(e,t){let i=au(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(ad(e.state,i)),!0)}function aC(e,t){return aT(e,i=>e.moveByChar(i,t))}const aA=e=>aC(e,!am(e)),aR=e=>aC(e,am(e));function aM(e,t){return aT(e,i=>e.moveByGroup(i,t))}function aX(e,t){return aT(e,i=>e.moveVertically(i,t))}const aq=e=>aX(e,!1),aE=e=>aX(e,!0);function aL(e,t){return aT(e,i=>e.moveVertically(i,t,av(e).height))}const aV=e=>aL(e,!1),a_=e=>aL(e,!0),aD=({state:e,dispatch:t})=>(t(ad(e,{anchor:0})),!0),aW=({state:e,dispatch:t})=>(t(ad(e,{anchor:e.doc.length})),!0),az=({state:e,dispatch:t})=>(t(ad(e,{anchor:e.selection.main.anchor,head:0})),!0),aj=({state:e,dispatch:t})=>(t(ad(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function aB(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:n}=e,s=n.changeByRange(n=>{let{from:s,to:r}=n;if(s==r){let o=t(n);os&&(i="delete.forward",o=aY(e,o,!0)),s=Math.min(s,o),r=Math.max(r,o)}else s=aY(e,s,!1),r=aY(e,r,!0);return s==r?{range:n}:{changes:{from:s,to:r},range:K.cursor(s,st(e)))n.between(t,t,(e,n)=>{et&&(t=i?n:e)});return t}const aI=(e,t,i)=>aB(e,n=>{let s=n.from,{state:r}=e,o=r.doc.lineAt(s),l,a;if(i&&!t&&s>o.from&&saI(e,!1,!0),aN=e=>aI(e,!0,!1),aG=(e,t)=>aB(e,i=>{let n=i.head,{state:s}=e,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let e=null;;){if(n==(t?r.to:r.from)){n==i.head&&r.number!=(t?s.doc.lines:1)&&(n+=t?1:-1);break}let l=v(r.text,n-r.from,t)+r.from,a=r.text.slice(Math.min(n,l)-r.from,Math.max(n,l)-r.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||n!=i.head)&&(e=h),n=l}return n}),aH=e=>aG(e,!1);function aF(e){let t=[],i=-1;for(let n of e.selection.ranges){let s=e.doc.lineAt(n.from),r=e.doc.lineAt(n.to);if(n.empty||n.to!=r.from||(r=e.doc.lineAt(n.to-1)),i>=s.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(n)}else t.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return t}function aJ(e,t,i){if(e.readOnly)return!1;let n=[],s=[];for(let t of aF(e)){if(i?t.to==e.doc.length:0==t.from)continue;let r=e.doc.lineAt(i?t.to+1:t.from-1),o=r.length+1;if(i)for(let i of(n.push({from:t.to,to:r.to},{from:t.from,insert:r.text+e.lineBreak}),t.ranges))s.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:r.from,to:t.from},{from:t.to,insert:e.lineBreak+r.text}),t.ranges))s.push(K.range(i.anchor-o,i.head-o))}return!!n.length&&(t(e.update({changes:n,scrollIntoView:!0,selection:K.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0)}function aK(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of aF(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 a0=a2(!1),a1=a2(!0);function a2(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{let{from:n,to:s}=i,r=t.doc.lineAt(n),o=!e&&n==s&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i=oW(e).resolveInner(t),n=i.childBefore(t),s=i.childAfter(t),r;return n&&s&&n.to<=t&&s.from>=t&&(r=n.type.prop(rX.closedBy))&&r.indexOf(s.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}(t,n);e&&(n=s=(s<=r.to?r:t.doc.lineAt(s)).to);let l=new o3(t,{simulateBreak:n,simulateDoubleBreak:!!o}),a=o5(l,n);for(null==a&&(a=e0(/^\s*/.exec(t.doc.lineAt(n).text)[0],t.tabSize));sr.from&&n{let s=[];for(let r=n.from;r<=n.to;){let o=e.doc.lineAt(r);o.number>i&&(n.empty||n.to>o.from)&&(t(o,s,n),i=o.number),r=o.to+1}let r=e.changes(s);return{changes:s,range:K.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const a3=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(a5(e,(t,i)=>{i.push({from:t.from,insert:e.facet(o0)})}),{userEvent:"input.indent"})),!0),a4=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(a5(e,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let s=e0(n,e.tabSize),r=0,o=o2(e,Math.max(0,s-o1(e)));for(;raf(e,t=>K.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>aT(e,t=>K.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>af(e,t=>K.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>aT(e,t=>K.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:aN},{key:"Ctrl-h",run:aU},{key:"Ctrl-k",run:e=>aB(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),s=i==n.from?i-1:v(n.text,i-n.from,!1)+n.from,r=i==n.to?i+1:v(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:r,insert:e.doc.slice(i,r).append(e.doc.slice(s,i))},range:K.cursor(r)}});return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:aP}],a9=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>af(e,t=>aw(e.state,t,!am(e))),shift:e=>aT(e,t=>aw(e.state,t,!am(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>af(e,t=>aw(e.state,t,am(e))),shift:e=>aT(e,t=>aw(e.state,t,am(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>aJ(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>aK(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>aJ(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>aK(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(ad(e,n)),!0)}},{key:"Mod-Enter",run:a1},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=aF(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=au(e.selection,t=>{let i=oW(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(ad(e,i)),!0)},preventDefault:!0},{key:"Mod-[",run:a4},{key:"Mod-]",run:a3},{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}}),s=a5(e,(t,s,r)=>{let o=o5(n,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],a=o2(e,o);(l!=a||r.from{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(aF(t).map(({from:e,to:i})=>(e>0?e--:i{let i;if(e.lineWrapping){let n=e.lineBlockAt(t.head),s=e.coordsAtPos(t.head,t.assoc||1);s&&(i=n.bottom+e.documentTop-s.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=au(e.selection,t=>{let n=l_(e,t.head,-1)||l_(e,t.head,1)||t.head>0&&l_(e,t.head-1,1)||t.head{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),n=l1(e.state,i.from);return n.line?lJ(e):!!n.block&&l0(e)}},{key:"Alt-A",run:lK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:ag,shift:aA,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>ax(e,!am(e)),shift:e=>aM(e,!am(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>af(e,t=>aZ(e,t,!am(e))),shift:e=>aT(e,t=>aZ(e,t,!am(e))),preventDefault:!0},{key:"ArrowRight",run:ab,shift:aR,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>ax(e,am(e)),shift:e=>aM(e,am(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>af(e,t=>aZ(e,t,am(e))),shift:e=>aT(e,t=>aZ(e,t,am(e))),preventDefault:!0},{key:"ArrowUp",run:ay,shift:aq,preventDefault:!0},{mac:"Cmd-ArrowUp",run:aD,shift:az},{mac:"Ctrl-ArrowUp",run:a$,shift:aV},{key:"ArrowDown",run:aS,shift:aE,preventDefault:!0},{mac:"Cmd-ArrowDown",run:aW,shift:aj},{mac:"Ctrl-ArrowDown",run:aP,shift:a_},{key:"PageUp",run:a$,shift:aV},{key:"PageDown",run:aP,shift:a_},{key:"Home",run:e=>af(e,t=>aZ(e,t,!1)),shift:e=>aT(e,t=>aZ(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:aD,shift:az},{key:"End",run:e=>af(e,t=>aZ(e,t,!0)),shift:e=>aT(e,t=>aZ(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:aW,shift:aj},{key:"Enter",run:a0,shift:a0},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:aU,shift:aU},{key:"Delete",run:aN},{key:"Mod-Backspace",mac:"Alt-Backspace",run:aH},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>aG(e,!0)},{mac:"Mod-Backspace",run:e=>aB(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=>aB(e,t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head({mac:e.key,run:e.run,shift:e.shift})))),a8={key:"Tab",run:a3,shift:a4};function a6(){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 s=i[n];"string"==typeof s?e.setAttribute(n,s):null!=s&&(e[n]=s)}t++}for(;te.normalize("NFKD"):e=>e;class ht{constructor(e,t,i=0,n=e.length,s,r){this.test=r,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=s?e=>s(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=$(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=P(e);let n=this.normalize(t);if(n.length)for(let e=0,s=i;;e++){let r=n.charCodeAt(e),o=this.match(r,s,this.bufferPos+this.bufferStart);if(e==n.length-1){if(o)return this.value=o,this;break}s==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=ha(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 hr.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:s,from:r}=n;return r>t&&(s=e.sliceString(t,r)+s,r=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=ha(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 ha(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=a6("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,s=n.doc.lineAt(n.selection.main.head),[,r,o,l,a]=i,h=l?+l.slice(1):0,c=o?+o:s.number;if(o&&a){let e=c/100;r&&(e=e*("-"==r?-1:1)+s.number/n.doc.lines),c=Math.round(n.doc.lines*e)}else o&&r&&(c=c*("-"==r?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),d=K.cursor(u.from+Math.max(0,Math.min(h,u.length)));e.dispatch({effects:[hc.of(!1),so.scrollIntoView(d.from,{y:"center"})],selection:d}),e.focus()}return{dom:a6("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:hc.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:e=>{e.preventDefault(),i()}},a6("label",e.state.phrase("Go to line"),": ",t)," ",a6("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),a6("button",{name:"close",onclick:()=>{e.dispatch({effects:hc.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(hs.prototype[Symbol.iterator]=hl.prototype[Symbol.iterator]=function(){return this});const hc=eZ.define(),hu=ea.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(hc)&&(e=i.value);return e},provide:e=>rh.from(e,e=>e?hh:null)}),hd=so.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=>eL(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))!=eX.Word)&&(n==t.doc.length||e(t.sliceDoc(n,n+1))!=eX.Word)}const hb=iV.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 s=n.main,r,o=null;if(s.empty){if(!t.highlightWordAroundCursor)return t1.none;let e=i.wordAt(s.head);if(!e)return t1.none;o=i.charCategorizer(s.head),r=i.sliceDoc(e.from,e.to)}else{let e=s.to-s.from;if(e200)return t1.none;if(t.wholeWords){var l,a,h;if(r=i.sliceDoc(s.from,s.to),!(hg(o=i.charCategorizer(s.head),i,s.from,s.to)&&(l=o,a=s.from,h=s.to,l(i.sliceDoc(a,a+1))==eX.Word&&l(i.sliceDoc(h-1,h))==eX.Word)))return t1.none}else if(!(r=i.sliceDoc(s.from,s.to)))return t1.none}let c=[];for(let n of e.visibleRanges){let e=new ht(i.doc,r,n.from,n.to);for(;!e.next().done;){let{from:n,to:r}=e.value;if((!o||hg(o,i,n,r))&&(s.empty&&n<=s.from&&r>=s.to?c.push(hm.range(n,r)):(n>=s.to||r<=s.from)&&c.push(hO.range(n,r)),c.length>t.maxMatches))return t1.none}}return t1.set(c)}},{decorations:e=>e.decorations}),hx=so.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),hw=({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)},hk=ei.define({combine:e=>eL(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new hH(e),scrollToMatch:e=>so.scrollIntoView(e)})});class hy{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 hT(this):new hQ(this)}getCursor(e,t=0,i){let n=e.doc?e:eE.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?h$(this,n,t,i):hv(this,n,t,i)}}class hS{constructor(e){this.spec=e}}function hv(e,t,i,n){var s,r;return new ht(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(s=t.doc,r=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 s=hv(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function h$(e,t,i,n){var s;return new hs(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(s=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(s(hP(i.input,i.index))!=eX.Word||s(hZ(i.input,i.index))!=eX.Word)&&(s(hZ(i.input,i.index+i[0].length))!=eX.Word||s(hP(i.input,i.index+i[0].length))!=eX.Word)):void 0},i,n)}function hP(e,t){return e.slice(v(e,t,!1),t)}function hZ(e,t){return e.slice(t,v(e,t))}class hT extends hS{nextMatch(e,t,i){let n=h$(this.spec,e,i,e.doc.length).next();return n.done&&(n=h$(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let s=Math.max(t,i-1e4*n),r=h$(this.spec,e,s,i),o=null;for(;!r.next().done;)o=r.value;if(o&&(s==t||o.from>s+10))return o;if(s==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 s=h$(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const hC=eZ.define(),hA=eZ.define(),hR=ea.define({create:e=>new hM(hB(e).create(),null),update(e,t){for(let i of t.effects)i.is(hC)?e=new hM(i.value.create(),e.panel):i.is(hA)&&(e=new hM(e.query,i.value?hj:null));return e},provide:e=>rh.from(e,e=>e.panel)});class hM{constructor(e,t){this.query=e,this.panel=t}}const hX=t1.mark({class:"cm-searchMatch"}),hq=t1.mark({class:"cm-searchMatch cm-searchMatch-selected"}),hE=iV.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hR))}update(e){let t=e.state.field(hR);(t!=e.startState.field(hR)||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 ej;for(let t=0,s=i.visibleRanges,r=s.length;ts[t+1].from-500;)l=s[++t].to;e.highlight(i.state,o,l,(e,t)=>{let s=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);n.add(e,t,s?hq:hX)})}return n.finish()}},{decorations:e=>e.decorations});function hL(e){return t=>{let i=t.state.field(hR,!1);return i&&i.query.spec.valid?e(t,i):hU(t)}}const hV=hL((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let s=K.single(n.from,n.to),r=e.state.facet(hk);return e.dispatch({selection:s,effects:[hK(e,n),r.scrollToMatch(s.main,e)],userEvent:"select.search"}),hI(e),!0}),h_=hL((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,s=t.prevMatch(i,n,n);if(!s)return!1;let r=K.single(s.from,s.to),o=e.state.facet(hk);return e.dispatch({selection:r,effects:[hK(e,s),o.scrollToMatch(r.main,e)],userEvent:"select.search"}),hI(e),!0}),hD=hL((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)}),hW=hL((e,{query:t})=>{let{state:i}=e,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=t.nextMatch(i,n,n);if(!r)return!1;let o=r,l=[],a,h,c=[];if(o.from==n&&o.to==s&&(h=i.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=t.nextMatch(i,o.from,o.to),c.push(so.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),o){let t=0==l.length||l[0].from>=r.to?0:r.to-r.from-h.length;a=K.single(o.from-t,o.to-t),c.push(hK(e,o)),c.push(i.facet(hk).scrollToMatch(a.main,e))}return e.dispatch({changes:l,selection:a,effects:c,userEvent:"input.replace"}),!0}),hz=hL((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:so.announce.of(n),userEvent:"input.replace.all"}),!0});function hj(e){return e.state.facet(hk).createPanel(e)}function hB(e,t){var i,n,s,r,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(hk);return new hy({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(s=null==t?void 0:t.literal)&&void 0!==s?s:h.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function hY(e){let t=rr(e,hj);return t&&t.dom.querySelector("[main-field]")}function hI(e){let t=hY(e);t&&t==e.root.activeElement&&t.select()}const hU=e=>{let t=e.state.field(hR,!1);if(t&&t.panel){let i=hY(e);if(i&&i!=e.root.activeElement){let n=hB(e.state,t.query.spec);n.valid&&e.dispatch({effects:hC.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[hA.of(!0),t?hC.of(hB(e.state,t.query.spec)):eZ.appendConfig.of(h1)]});return!0},hN=e=>{let t=e.state.field(hR,!1);if(!t||!t.panel)return!1;let i=rr(e,hj);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:hA.of(!1)}),!0},hG=[{key:"Mod-f",run:hU,scope:"editor search-panel"},{key:"F3",run:hV,shift:h_,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hV,shift:h_,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hN,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:s}=i.main,r=[],o=0;for(let t=new ht(e.doc,e.sliceDoc(n,s));!t.next().done;){if(r.length>1e3)return!1;t.value.from==n&&(o=r.length),r.push(K.range(t.value.from,t.value.to))}return t(e.update({selection:K.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=rr(e,hh);if(!t){let i=[hc.of(!0)];null==e.state.field(hu,!1)&&i.push(eZ.appendConfig.of([hu,hd])),e.dispatch({effects:i}),t=rr(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 hw({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 s=function(e,t){let{main:i,ranges:n}=e.selection,s=e.wordAt(i.head),r=s&&s.from==i.from&&s.to==i.to;for(let i=!1,s=new ht(e.doc,t,n[n.length-1].to);;)if(s.next(),s.done){if(i)return null;s=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==s.value.from))continue;if(r){let t=e.wordAt(s.value.from);if(!t||t.from!=s.value.from||t.to!=s.value.to)continue}return s.value}}(e,n);return!!s&&(t(e.update({selection:e.selection.addRange(K.range(s.from,s.to),!1),effects:so.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class hH{constructor(e){this.view=e;let t=this.query=e.state.field(hR).query.spec;function i(e,t,i){return a6("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=a6("input",{value:t.search,placeholder:hF(e,"Find"),"aria-label":hF(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=a6("input",{value:t.replace,placeholder:hF(e,"Replace"),"aria-label":hF(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=a6("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=a6("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=a6("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=a6("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>hV(e),[hF(e,"next")]),i("prev",()=>h_(e),[hF(e,"previous")]),i("select",()=>hD(e),[hF(e,"all")]),a6("label",null,[this.caseField,hF(e,"match case")]),a6("label",null,[this.reField,hF(e,"regexp")]),a6("label",null,[this.wordField,hF(e,"by word")]),...e.state.readOnly?[]:[a6("br"),this.replaceField,i("replace",()=>hW(e),[hF(e,"replace")]),i("replaceAll",()=>hz(e),[hF(e,"replace all")])],a6("button",{name:"close",onclick:()=>hN(e),"aria-label":hF(e,"close"),type:"button"},["×"])])}commit(){let e=new hy({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:hC.of(e)}))}keydown(e){var t,i;(t=this.view,i="search-panel",sx(sm(t.state),e,t,i))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?h_:hV)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),hW(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(hC)&&!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(hk).top}}function hF(e,t){return e.state.phrase(t)}const hJ=/[\s\.,:;?!]/;function hK(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),s=e.state.doc.lineAt(i).to,r=Math.max(n.from,t-30),o=Math.min(s,i+30),l=e.state.sliceDoc(r,o);if(r!=n.from){for(let e=0;e<30;e++)if(!hJ.test(l[e+1])&&hJ.test(l[e])){l=l.slice(e);break}}if(o!=s){for(let e=l.length-1;e>l.length-30;e--)if(!hJ.test(l[e-1])&&hJ.test(l[e])){l=l.slice(0,e);break}}return so.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${n.number}.`)}const h0=so.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=[hR,eu.low(hE),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=oW(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),s=n.search(h9(e,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}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 s=e.matchBefore(n);return s||e.explicit?{from:s?s.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,s=t&&"^"!=n[0],r="$"!=n[n.length-1];return s||r?RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,null!==(i=e.flags)&&void 0!==i?i:e.ignoreCase?"i":""):e}const h8=eQ.define(),h6=new WeakMap;function ce(e){if(!Array.isArray(e))return e;let t=h6.get(e);return t||h6.set(e,t=h3(e)),t}const ct=eZ.define(),ci=eZ.define();class cn{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&&a<=57||a>=97&&a<=122?2:+(a>=65&&a<=90):(b=$(a))!=b.toLowerCase()?1:2*(b!=b.toUpperCase());(!n||1==x&&O||0==g&&0!=x)&&(t[c]==a||i[c]==a&&(u=!0)?r[c++]=n:r.length&&(m=!1)),g=x,n+=P(a)}return c==l&&0==r[0]&&m?this.result(-100+(u?-200:0),r,e):d==l&&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==l?this.ret(-900-e.length,[f,p]):c==l?this.result(-100+(u?-200:0)+-700+(m?0:-1100),r,e):2==t.length?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,i){let n=[],s=0;for(let e of t){let t=e+(this.astral?P(Q(i,e)):1);s&&n[s-1]==e?n[s-1]=t:(n[s++]=e,n[s++]=t)}return this.ret(e-i.length,n)}}class cs{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.lengtheL(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:cl,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=>co(e(i),t(i)),optionClass:(e,t)=>i=>co(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function co(e,t){return e?t?e+" "+t:e:t}function cl(e,t,i,n,s,r){let o=e.textDirection==is.RTL,l=o,a=!1,h="top",c,u,d=t.left-s.left,f=s.right-t.right,p=n.right-n.left,O=n.bottom-n.top;if(l&&d=O||e>t.top?c=i.bottom-t.top:(h="bottom",c=t.bottom-i.top)}let m=(t.bottom-t.top)/r.offsetHeight,g=(t.right-t.left)/r.offsetWidth;return{style:`${h}: ${c/m}px; max-width: ${u/g}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function ca(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 ch{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 s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(cr);this.optionContent=(n=l.addToOptions.slice(),l.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 s=document.createElement("span");s.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;eo&&s.appendChild(document.createTextNode(r.slice(o,t)));let l=s.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(t,i))),l.className="cm-completionMatchedText",o=i}return oe.position-t.position).map(e=>e.render)),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=ca(r.length,o,l.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,s;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(s=/-(\d+)$/.exec(t.id))&&+s[1]{let i=e.state.field(this.stateField,!1);i&&i.tooltip&&e.state.facet(cr).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:ci.of(null)})}),this.showOptions(r,s.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:s,selected:r,disabled:o}=i.open;n.open&&n.open.options==s||(this.range=ca(s.length,r,e.state.facet(cr).maxRenderedOptions),this.showOptions(s,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=ca(t.options.length,t.selected,this.view.state.facet(cr).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 s="string"==typeof n?document.createTextNode(n):n(i);if(!s)return;"then"in s?s.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>iX(this.view.state,e,"completion info")):this.addInfoPane(s,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,s,r,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(),s=i.getBoundingClientRect(),r=n.height/t.offsetHeight,s.topn.bottom&&(t.scrollTop+=(s.bottom-n.bottom)/r)),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(),s=this.space;if(!s){let e=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return n.top>Math.min(s.bottom,t.bottom)-10||n.bottom{e.target==n&&e.preventDefault()});let s=null;for(let r=i.from;ri.from||0==i.from)&&(s=e,"string"!=typeof a&&a.header?n.appendChild(a.header(a)):n.appendChild(document.createElement("completion-section")).textContent=e)}let h=n.appendChild(document.createElement("li"));h.id=t+"-"+r,h.setAttribute("role","option");let c=this.optionClass(o);for(let e of(c&&(h.className=c),this.optionContent)){let t=e(o,this.view.state,this.view,l);t&&h.appendChild(t)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to=this.options.length?this:new cu(this.options,cO(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,n,s,r){if(n&&!r&&e.some(e=>e.isPending))return n.setDisabled();let o=function(e,t){let i=[],n=null,s=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)}},r=t.facet(cr);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)s(new h4(t,n.source,e?e(t):[],1e9-i.length));else{let i=t.sliceDoc(n.from,n.to),o,l=r.filterStrict?new cs(i):new cn(i);for(let t of n.result.options)if(o=l.match(t.label)){let i=t.displayLabel?e?e(t,o.matched):[]:o.matched;s(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||a(e.completion,t.completion))){let t=e.completion;l&&l.label==t.label&&l.detail==t.detail&&(null==l.type||null==t.type||l.type==t.type)&&l.apply==t.apply&&l.boost==t.boost?cc(e.completion)>cc(l)&&(o[o.length-1]=e):o.push(e),l=e.completion}return o}(e,t);if(!o.length)return n&&e.some(e=>e.isPending)?n.setDisabled():null;let l=t.facet(cr).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let e=n.options[n.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e,1e8),create:cv,above:s.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(e){return new cu(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 cu(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class cd{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new cd(cm,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,i=t.facet(cr),n=(i.override||t.languageDataAt("autocomplete",h7(t)).map(ce)).map(t=>(this.active.find(e=>e.source==t)||new cb(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 s=this.open,r=e.effects.some(e=>e.is(cw));for(let o of(s&&e.docChanged&&(s=s.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)&&(s=null),!s&&n.every(e=>!e.isPending)&&n.some(e=>e.hasResult())&&(n=n.map(e=>e.hasResult()?new cb(e.source,0):e)),e.effects))o.is(ck)&&(s=s&&s.setSelected(o.value,this.id));return n==this.active&&s==this.open?this:new cd(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?cf:cp}}const cf={"aria-autocomplete":"list"},cp={};function cO(e,t){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(i["aria-activedescendant"]=e+"-"+t),i}const cm=[];function cg(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(h8);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 cb{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=cg(e,t),n=this;for(let t of((8&i||16&i&&this.touches(e))&&(n=new cb(n.source,0)),4&i&&0==n.state&&(n=new cb(this.source,1)),n=n.updateFor(e,i),e.effects))if(t.is(ct))n=new cb(n.source,1,t.value);else if(t.is(ci))n=new cb(n.source,0);else if(t.is(cw))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 cx extends cb{constructor(e,t,i,n,s,r){super(e,3,t),this.limit=i,this.result=n,this.from=s,this.to=r}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 s=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=h7(e.state);if(o>r||!n||2&t&&(h7(e.startState)==this.from||oe.map(e=>e.map(t))}),ck=eZ.define(),cy=ea.define({create:()=>cd.start(),update:(e,t)=>e.update(t),provide:e=>[s9.from(e,e=>e.tooltip),so.contentAttributes.from(e,e=>e.attrs)]});function cS(e,t){let i=t.completion.apply||t.completion.label,n=e.state.field(cy).active.find(e=>e.source==t.source);return n instanceof cx&&("string"==typeof i?e.dispatch(Object.assign(Object.assign({},function(e,t,i,n){let{main:s}=e.selection,r=i-s.from,o=n-s.from;return Object.assign(Object.assign({},e.changeByRange(l=>{if(l!=s&&i!=n&&e.sliceDoc(l.from+r,l.from+o)!=e.sliceDoc(i,n))return{range:l};let a=e.toText(t);return{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:a},range:K.cursor(l.from+r+a.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,i,n.from,n.to)),{annotations:h8.of(t.completion)})):i(e,t.completion,n.from,n.to),!0)}const cv=e=>new ch(e,cy,cS);function cQ(e,t="option"){return i=>{let n=i.state.field(cy,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+s*(e?1:-1):e?0:o-1;return l<0?l="page"==t?0:o-1:l>=o&&(l="page"==t?o-1:0),i.dispatch({effects:ck.of(l)}),!0}}const c$=e=>!!e.state.field(cy,!1)&&(e.dispatch({effects:ct.of(!0)}),!0);class cP{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const cZ=iV.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(cy).active))t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(cy),i=e.state.facet(cr);if(!e.selectionSet&&!e.docChanged&&e.startState.field(cy)==t)return;let n=e.transactions.some(e=>{let t=cg(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){iX(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(ct)))&&(this.pendingStart=!0);let s=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(),s):-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(cy);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(cr).updateSyncTime))}startQuery(e){let{state:t}=this.view,i=h7(t),n=new h2(t,i,e.explicit,this.view),s=new cP(e,n);this.running.push(s),Promise.resolve(e.source(n)).then(e=>{s.context.aborted||(s.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:ci.of(null)}),iX(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(cr).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],i=this.view.state.facet(cr),n=this.view.state.field(cy);for(let s=0;se.source==r.active.source);if(o&&o.isPending){if(null==r.done){let e=new cb(r.active.source,0);for(let t of r.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:cw.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(cy,!1);if(t&&t.tooltip&&this.view.state.facet(cr).closeOnBlur){let i=t.open&&ri(this.view,t.open.tooltip);i&&i.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:ci.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:ct.of(!1)}),20),this.composing=0}}}),cT="object"==typeof navigator&&/Win/.test(navigator.platform),cC=eu.highest(so.domEventHandlers({keydown(e,t){let i=t.state.field(cy,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||e.key.length>1||e.ctrlKey&&!(cT&&e.altKey)||e.metaKey)return!1;let n=i.open.options[i.open.selected],s=i.active.find(e=>e.source==n.source),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(e.key)>-1&&cS(t,n),!1}})),cA=so.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 cR{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class cM{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,j.TrackDel),i=e.mapPos(this.to,1,j.TrackDel);return null==t||null==i?null:new cM(this.field,t,i)}}class cX{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],s=e.doc.lineAt(t),r=/^\s*/.exec(s.text)[0];for(let s of this.lines){if(i.length){let i=r,o=/^\t*/.exec(s)[0].length;for(let t=0;tnew cM(e.field,n[e.line]+e.from,n[e.line]+e.to))}}static parse(e){let t=[],i=[],n=[],s;for(let r of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(r);){let e=s[1]?+s[1]:null,o=s[2]||s[3]||"",l=-1,a=o.replace(/\\[{}]/g,e=>e[1]);for(let i=0;i=l&&s.field++}n.push(new cR(l,i.length,s.index,s.index+a.length)),r=r.slice(0,s.index)+o+r.slice(s.index+s[0].length)}r=r.replace(/\\([{}])/g,(e,t,s)=>{for(let e of n)e.line==i.length&&e.from>s&&(e.from--,e.to--);return t}),i.push(r)}return new cX(i,n)}}let cq=t1.widget({widget:new class extends tK{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),cE=t1.mark({class:"cm-snippetField"});class cL{constructor(e,t){this.ranges=e,this.active=t,this.deco=t1.set(e.map(e=>(e.from==e.to?cq:cE).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 cL(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 cV=eZ.define({map:(e,t)=>e&&e.map(t)}),c_=eZ.define(),cD=ea.define({create:()=>null,update(e,t){for(let i of t.effects){if(i.is(cV))return i.value;if(i.is(c_)&&e)return new cL(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=>so.decorations.from(e,e=>e?e.deco:t1.none)});function cW(e,t){return K.create(e.filter(e=>e.field==t).map(e=>K.range(e.from,e.to)))}function cz(e){return({state:t,dispatch:i})=>{let n=t.field(cD,!1);if(!n||e<0&&0==n.active)return!1;let s=n.active+e,r=e>0&&!n.ranges.some(t=>t.field==s+e);return i(t.update({selection:cW(n.ranges,s),effects:cV.of(r?null:new cL(n.ranges,s)),scrollIntoView:!0})),!0}}const cj=[{key:"Tab",run:cz(1),shift:cz(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(cD,!1)&&(t(e.update({effects:cV.of(null)})),!0)}],cB=ei.define({combine:e=>e.length?e[0]:cj}),cY=eu.highest(sp.compute([cB],e=>e.facet(cB)));function cI(e,t){let i;return Object.assign(Object.assign({},t),{apply:(i=cX.parse(e),(e,t,n,s)=>{let{text:r,ranges:o}=i.instantiate(e.state,n),{main:l}=e.state.selection,a={changes:{from:n,to:s==l.from?l.to:s,insert:O.of(r)},scrollIntoView:!0,annotations:t?[h8.of(t),eT.userEvent.of("input.complete")]:void 0};if(o.length&&(a.selection=cW(o,0)),o.some(e=>e.field>0)){let t=new cL(o,0),i=a.effects=[cV.of(t)];void 0===e.state.field(cD,!1)&&i.push(eZ.appendConfig.of([cD,cY,cU,cA]))}e.dispatch(e.state.update(a))})})}const cU=so.domEventHandlers({mousedown(e,t){let i=t.state.field(cD,!1),n;if(!i||null==(n=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let s=i.ranges.find(e=>e.from<=n&&e.to>=n);return!!s&&s.field!=i.active&&(t.dispatch({selection:cW(i.ranges,s.field),effects:cV.of(i.ranges.some(e=>e.field>s.field)?new cL(i.ranges,s.field):null),scrollIntoView:!0}),!0)}}),cN={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},cG=eZ.define({map(e,t){let i=t.mapPos(e,-1,j.TrackAfter);return null==i?void 0:i}}),cH=new class extends eV{};cH.startSide=1,cH.endSide=-1;const cF=ea.define({create:()=>ez.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(cG)&&(e=e.update({add:[cH.range(i.value,i.value+1)]}));return e}}),cJ="()[]{}<>«»»«[]{}";function cK(e){for(let t=0;t{if((c1?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let s=e.state.selection.main;if(n.length>2||2==n.length&&1==P(Q(n,0))||t!=s.from||i!=s.to)return!1;let r=function(e,t){let i=c0(e,e.selection.main.head),n=i.brackets||cN.brackets;for(let s of n){let r=cK(Q(s,0));if(t==s)return r==s?function(e,t,i,n){let s=n.stringPrefixes||cN.stringPrefixes,r=null,o=e.changeByRange(n=>{if(!n.empty)return{changes:[{insert:t,from:n.from},{insert:t,from:n.to}],effects:cG.of(n.to+t.length),range:K.range(n.anchor+t.length,n.head+t.length)};let o=n.head,l=c4(e.doc,o),a;if(l==t){if(c7(e,o))return{changes:{insert:t+t,from:o},effects:cG.of(o+t.length),range:K.cursor(o+t.length)};if(c3(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&&(a=c9(e,o-2*t.length,s))>-1&&c7(e,a))return{changes:{insert:t+t+t+t,from:o},effects:cG.of(o+t.length),range:K.cursor(o+t.length)};else if(e.charCategorizer(o)(l)!=eX.Word&&c9(e,o,s)>-1&&!function(e,t,i,n){let s=oW(e).resolveInner(t,-1),r=n.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(s.from,Math.min(s.to,s.from+i.length+r)),l=o.indexOf(i);if(!l||l>-1&&n.indexOf(o.slice(0,l))>-1){let t=s.firstChild;for(;t&&t.from==s.from&&t.to-t.from>i.length+l;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let a=s.to==t&&s.parent;if(!a)break;s=a}return!1}(e,o,t,s))return{changes:{insert:t+t,from:o},effects:cG.of(o+t.length),range:K.cursor(o+t.length)};return{range:r=n}});return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(e,s,n.indexOf(s+s+s)>-1,i):function(e,t,i,n){let s=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:i,from:r.to}],effects:cG.of(r.to+t.length),range:K.range(r.anchor+t.length,r.head+t.length)};let o=c4(e.doc,r.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:t+i,from:r.head},effects:cG.of(r.head+t.length),range:K.cursor(r.head+t.length)}:{range:s=r}});return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(e,s,r,i.before||cN.before);if(t==r&&c3(e,e.selection.main.from))return function(e,t,i){let n=null,s=e.changeByRange(t=>t.empty&&c4(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(s,{scrollIntoView:!0,userEvent:"input.type"})}(e,0,r)}return null}(e.state,n);return!!r&&(e.dispatch(r),!0)}),c5=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=c0(e,e.selection.main.head).brackets||cN.brackets,n=null,s=e.changeByRange(t=>{if(t.empty){var s,r;let n;let o=(s=e.doc,r=t.head,P(Q(n=s.sliceString(r-2,r),0))==n.length?n:n.slice(1));for(let n of i)if(n==o&&c4(e.doc,t.head)==cK(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(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function c3(e,t){let i=!1;return e.field(cF).between(0,e.doc.length,e=>{e==t&&(i=!0)}),i}function c4(e,t){let i=e.sliceString(t,t+2);return i.slice(0,P(Q(i,0)))}function c7(e,t){let i=oW(e).resolveInner(t+1);return i.parent&&i.from==t}function c9(e,t,i){let n=e.charCategorizer(t);if(n(e.sliceDoc(t-1,t))!=eX.Word)return t;for(let s of i){let i=t-s.length;if(e.sliceDoc(i,t)==s&&n(e.sliceDoc(i-1,i))!=eX.Word)return i}return -1}const c8=[{key:"Ctrl-Space",run:c$},{mac:"Alt-`",run:c$},{key:"Escape",run:e=>{let t=e.state.field(cy,!1);return!!(t&&t.active.some(e=>0!=e.state))&&(e.dispatch({effects:ci.of(null)}),!0)}},{key:"ArrowDown",run:cQ(!0)},{key:"ArrowUp",run:cQ(!1)},{key:"PageDown",run:cQ(!0,"page")},{key:"PageUp",run:cQ(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(cy,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.facet(cr).defaultKeymap?[c8]:[]));class ue{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class ut{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=e,s=i.facet(uf).markerFilter;s&&(n=s(n,i));let r=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new ej,l=[],a=0;for(let e=0;;){let t,n,s=e==r.length?null:r[e];if(!s&&!l.length)break;for(l.length?(t=a,n=l.reduce((e,t)=>Math.min(e,t.to),s&&s.from>t?s.from:1e8)):(t=s.from,n=s.to,l.push(s),e++);ei.from||i.to==t))l.push(i),e++,n=Math.min(i.to,n);else{n=Math.min(i.from,n);break}}let h=uy(l);if(l.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 um(h),diagnostics:l.slice()}));else{let e=l.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,t1.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:l.slice(),inclusiveEnd:l.some(e=>e.to>n)}))}a=n;for(let e=0;e{if(!(t&&0>s.diagnostics.indexOf(t))){if(n){if(0>s.diagnostics.indexOf(n.diagnostic))return!1;n=new ue(n.from,i,n.diagnostic)}else n=new ue(e,i,t||s.diagnostics[0])}}),n}function un(e,t){let i=t.pos,n=t.end||i,s=e.state.facet(uf).hideOn(e,i,n);if(null!=s)return s;let r=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(ur))||e.changes.touchesRange(r.from,Math.max(r.to,n)))}function us(e,t){return e.field(ua,!1)?t:t.concat(eZ.appendConfig.of(u$))}const ur=eZ.define(),uo=eZ.define(),ul=eZ.define(),ua=ea.define({create:()=>new ut(t1.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),n=null,s=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);n=ui(i,e.selected.diagnostic,s)||ui(i,null,s)}!i.size&&s&&t.state.facet(uf).autoPanel&&(s=null),e=new ut(i,s,n)}for(let i of t.effects)if(i.is(ur)){let n=t.state.facet(uf).autoPanel?i.value.length?ub.open:null:e.panel;e=ut.init(i.value,n,t.state)}else i.is(uo)?e=new ut(e.diagnostics,i.value?ub.open:null,e.selected):i.is(ul)&&(e=new ut(e.diagnostics,e.panel,i.value));return e},provide:e=>[rh.from(e,e=>e.panel),so.decorations.from(e,e=>e.diagnostics)]}),uh=t1.mark({class:"cm-lintRange cm-lintRange-active"});function uc(e,t){return a6("ul",{class:"cm-tooltip-lint"},t.map(t=>uO(e,t,!1)))}const uu=e=>{let t=e.state.field(ua,!1);return!!t&&!!t.panel&&(e.dispatch({effects:uo.of(!1)}),!0)},ud=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(ua,!1);t&&t.panel||e.dispatch({effects:us(e.state,[uo.of(!0)])});let i=rr(e,ub.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(ua,!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)}}];iV.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(uf);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(s),n.length==e.length?t(n):s=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:us(i,[ur.of(n)])}))}},e=>{iX(this.view.state,e)})}}update(e){let t=e.state.facet(uf);(e.docChanged||t!=e.startState.facet(uf)||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 uf=ei.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},eL(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 up(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 uO(e,t,i){var n;let s=i?up(t.actions):[];return a6("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},a6("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 r=!1,o=n=>{if(n.preventDefault(),r)return;r=!0;let s=ui(e.state.field(ua).diagnostics,t);s&&i.apply(e,s.from,s.to)},{name:l}=i,a=s[n]?l.indexOf(s[n]):-1,h=a<0?l:[l.slice(0,a),a6("u",l.slice(a,a+1)),l.slice(a+1)];return a6("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${l}${a<0?"":` (access key "${s[n]})"`}.`},h)}),t.source&&a6("div",{class:"cm-diagnosticSource"},t.source))}class um extends tK{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return a6("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ug{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=uO(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ub{constructor(e){this.view=e,this.items=[],this.list=a6("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)uu(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=up(i.actions);for(let s=0;s{for(let t=0;tuu(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ua).selected;if(!e)return -1;for(let t=0;t{for(let e of l.diagnostics){if(r.has(e))continue;r.add(e);let o=-1,l;for(let t=i;ti&&(this.items.splice(i,o-i),n=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),s=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),i++}});i({sel:s.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=ui(this.view.state.field(ua).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:ul.of(t)})}static open(e){return new ub(e)}}function ux(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,')`}function uw(e){return ux(``,'width="6" height="3"')}const uk=so.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:uw("#d11")},".cm-lintRange-warning":{backgroundImage:uw("orange")},".cm-lintRange-info":{backgroundImage:uw("#999")},".cm-lintRange-hint":{backgroundImage:uw("#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 uy(e){let t="hint",i=1;for(let s of e){var n;let e="error"==(n=s.severity)?4:"warning"==n?3:"info"==n?2:1;e>i&&(i=e,t=s.severity)}return t}class uS extends rc{constructor(e){super(),this.diagnostics=e,this.severity=uy(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(uP).tooltipFilter;return n&&(i=n(i,e.state)),i.length&&(t.onmouseover=()=>(function(e,t,i){function n(){let n,s=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(s.from)&&e.dispatch({effects:uv.of({pos:s.from,above:!1,clip:!1,create:()=>({dom:uc(e,i),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,n=i=>{let s=t.getBoundingClientRect();if(!(i.clientX>s.left-10)||!(i.clientXs.top-10)||!(i.clientY{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(n,s)}})(e,t,i)),t}}ea.define({create:()=>ez.empty,update(e,t){e=e.map(t.changes);let i=t.state.facet(uP).markerFilter;for(let n of t.effects)if(n.is(ur)){let s=n.value;i&&(s=i(s||[],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 uS(i[e]).range(+e));return ez.of(n,!0)}(t.state.doc,s.slice(0))}return e}});const uv=eZ.define(),uQ=ea.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=un(t,e)?null:Object.assign(Object.assign({},e),{pos:t.changes.mapPos(e.pos)})),t.effects.reduce((e,t)=>t.is(uv)?t.value:e,e)),provide:e=>s9.from(e)});so.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:ux('')},".cm-lint-marker-warning":{content:ux('')},".cm-lint-marker-error":{content:ux('')}});const u$=[ua,so.decorations.compute([ua],e=>{let{selected:t,panel:i}=e.field(ua);return t&&i&&t.from!=t.to?t1.set([uh.range(t.from,t.to)]):t1.none}),function(e,t={}){let i=eZ.define(),n=ea.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,j.TrackDel);if(null!=e){let s=Object.assign(Object.create(null),i);s.pos=e,null!=s.end&&(s.end=n.changes.mapPos(s.end)),t.push(s)}}e=t}for(let t of n.effects)t.is(i)&&(e=t.value),t.is(rn)&&(e=[]);return e},provide:e=>s8.from(e)});return{active:n,extension:[n,iV.define(s=>new rt(s,e,n,i,t.hoverTime||300)),re]}}(function(e,t,i){let{diagnostics:n}=e.state.field(ua),s,r=-1,o=-1;n.between(t-+(i<0),t+ +(i>0),(e,n,{spec:l})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t({dom:uc(e,s)})}:null},{hideOn:un}),uk],uP=ei.define({combine:e=>eL(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}),uZ=[function(e={}){return[rQ.of(e),rm(),rZ]}(),rA,function(e={}){return[sj.of(e),sB||(sB=iV.fromClass(class{constructor(e){this.view=e,this.decorations=t1.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(sj)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new sV({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:s}=i.state,r=Q(t[0],0);if(9==r){let e=s.lineAt(n),t=i.state.tabSize,r=e0(e.text,t,n-e.from);return t1.replace({widget:new sI((t-r%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=t1.replace({widget:new sY(e,r)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(sj);e.startState.facet(sj)!=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[l9,l7.of(e),so.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?l6:"historyRedo"==e.inputType?ae:null;return!!i&&(e.preventDefault(),i(t))}})]}(),function(e={}){var t;let i=Object.assign(Object.assign({},lw),e),n=new lk(i,!0),s=new lk(i,!1),r=iV.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(oH)!=e.state.facet(oH)||e.startState.field(lh,!1)!=e.state.field(lh,!1)||oW(e.startState)!=oW(e.state)||i.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new ej;for(let i of e.viewportLineBlocks){let r=lc(e.state,i.from,i.to)?s:ls(e.state,i.from,i.to)?n:null;r&&t.add(i.from,i.from,r)}return t.finish()}}),{domEventHandlers:o}=i;return[r,(t={class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||ez.empty},initialSpacer:()=>new lk(i,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,i)=>{if(o.click&&o.click(e,t,i))return!0;let n=lc(e.state,t.from,t.to);if(n)return e.dispatch({effects:ll.of(n)}),!0;let s=ls(e.state,t.from,t.to);return!!s&&(e.dispatch({effects:lo.of(s)}),!0)}})},[rm(),rp.of(Object.assign(Object.assign({},rf),t))]),lm()]}(),function(e={}){return[sP.of(e),sT,sA,sM,iT.of(!0)]}(),[sq,sE],eE.allowMultipleSelections.of(!0),eE.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,s=i.lineAt(n);if(n>s.from+200)return e;let r=i.sliceString(s.from,n);if(!t.some(e=>e.test(r)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let i=o5(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],s=o2(o,i);n!=s&&a.push({from:t.from,to:t.from+n.length,insert:s})}return a.length?[e,{changes:a,sequential:!0}]:e}),(X={fallback:!0},e=[lP],lZ instanceof lS&&(lZ.module&&e.push(so.styleModule.of(lZ.module)),t=lZ.themeType),(null==X?void 0:X.fallback)?e.push(lQ.of(lZ)):t?e.push(lv.computeN([so.darkTheme],e=>e.facet(so.darkTheme)==("dark"==t)?[lZ]:[])):e.push(lv.of(lZ)),e),function(e={}){return[lA.of(e),lq]}(),[c2,cF],function(e={}){return[cC,cy,cr.of(e),cZ,c6,cA]}(),(i=e=>e.altKey&&0==e.button,so.mouseSelectionStyle.of((e,t)=>{let n,s;return i(t)?(n=sG(e,t),s=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)},s=s.map(e.changes)}},get(t,i,r){let o=sG(e,t);if(!o)return s;let l=function(e,t,i){let n=Math.min(t.line,i.line),s=Math.max(t.line,i.line),r=[];if(t.off>2e3||i.off>2e3||t.col<0||i.col<0){let o=Math.min(t.off,i.off),l=Math.max(t.off,i.off);for(let t=n;t<=s;t++){let i=e.doc.line(t);i.length<=l&&r.push(K.range(i.from+o,i.to+l))}}else{let o=Math.min(t.col,i.col),l=Math.max(t.col,i.col);for(let t=n;t<=s;t++){let i=e.doc.line(t),n=e1(i.text,o,e.tabSize,!0);if(n<0)r.push(K.cursor(i.to));else{let t=e1(i.text,l,e.tabSize);r.push(K.range(i.from+n,i.from+t))}}}return r}(e.state,n,o);return l.length?r?K.create(l.concat(s.ranges)):K.create(l):s}}:null):null})),function(e={}){let[t,i]=sH[e.key||"Alt"],n=iV.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,so.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(n))||void 0===t?void 0:t.isDown)?sF:null})]}(),sN,n=[hx,hb],sp.of([...c5,...a9,...hG,{key:"Mod-z",run:l6,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ae,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ae,preventDefault:!0},{key:"Mod-u",run:at,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ai,preventDefault:!0},...lf,...c8,...ud])];var uT={},uC=uT={};function uA(){throw Error("setTimeout has not been defined")}function uR(){throw Error("clearTimeout has not been defined")}function uM(e){if(_===setTimeout)return setTimeout(e,0);if((_===uA||!_)&&setTimeout)return _=setTimeout,setTimeout(e,0);try{return _(e,0)}catch(t){try{return _.call(null,e,0)}catch(t){return _.call(this,e,0)}}}!function(){try{_="function"==typeof setTimeout?setTimeout:uA}catch(e){_=uA}try{D="function"==typeof clearTimeout?clearTimeout:uR}catch(e){D=uR}}();var uX=[],uq=!1,uE=-1;function uL(){uq&&W&&(uq=!1,W.length?uX=W.concat(uX):uE=-1,uX.length&&uV())}function uV(){if(!uq){var e=uM(uL);uq=!0;for(var t=uX.length;t;){for(W=uX,uX=[];++uE1)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 uW(e,[],t,i,i,0,[],0,n?new uz(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:s}=this.p,r=this.reducePos=2e3&&!(null===(t=this.p.parser.nodeSet.types[n])||void 0===t?void 0:t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(n,a)}storeNode(e,t,i,n=4,s=!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(s&&this.pos!=i){let s=this.buffer.length;if(s>0&&0!=this.buffer[s-4]){let e=!1;for(let t=s;t>0&&this.buffer[t-2]>i;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,n>4&&(n-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=i,this.buffer[s+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:s}=this.p;(n>this.pos||t<=s.maxNode)&&(this.pos=n,s.stateFlag(e,1)||(this.reducePos=n)),this.pushState(e,i),this.shiftContext(t,i),t<=s.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 uW(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 uj(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,s;n1&t&&e==n)||i.push(t[e],n)}t=i}let i=[];for(let e=0;e>19,n=65535&t,s=this.stack.length-3*i;if(s<0||0>e.getGoto(this.stack[s],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,s)=>{if(!t.includes(n))return t.push(n),e.allActions(n,t=>{if(393216&t);else if(65536&t){let i=(t>>19)-s;if(i>1){let n=65535&t,s=this.stack.length-3*i;if(s>=0&&e.getGoto(this.stack[s],n,!1)>=0)return i<<19|65536|n}}else{let e=i(t,s+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 uz{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class uj{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 uB{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 uB(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 uB(this.stack,this.pos,this.index)}}function uY(e,t=Uint16Array){if("string"!=typeof e)return e;let i=null;for(let n=0,s=0;n=92&&t--,t>=34&&t--;let s=t-32;if(s>=46&&(s-=46,i=!0),r+=s,i)break;r*=46}i?i[s++]=r:i=new t(r)}return i}class uI{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const uU=new uI;class uN{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=uU,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,s=this.pos+e;for(;si.to:s>=i.to;){if(n==this.ranges.length-1)return null;let e=this.ranges[++n];s+=e.from-i.to,i=e}return s}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=uU,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 uG{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;uJ(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}uG.prototype.contextual=uG.prototype.fallback=uG.prototype.extend=!1;class uH{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data="string"==typeof e?uY(e):e}token(e,t){let i=e.pos,n=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(uJ(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(!i&&n++,null==s)break;e.reset(s,e.token)}n&&(e.reset(i,e.token),e.acceptToken(this.elseToken,n))}}uH.prototype.contextual=uG.prototype.fallback=uG.prototype.extend=!1;class uF{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function uJ(e,t,i,n,s,r){let o=0,l=1<0){let i=e[n];if(a.allows(i)&&(-1==t.token.value||t.token.value==i||function(e,t,i,n){let s=uK(i,n,t);return s<0||uK(i,n,e)h&&65535==e[i+3*c-3]){o=e[i+3*c-1];continue}for(;h>1,r=i+s+(s<<1),l=e[r],a=e[r+1]||65536;if(n=a)h=s+1;else{o=e[r+2],t.advance();continue i}}break}}function uK(e,t,i){for(let n=t,s;65535!=(s=e[n]);n++)if(s==i)return n-t;return -1}const u0=void 0!==uT&&uT.env&&/\bparse\b/.test(void 0);let u1=null;function u2(e,t,i){let n=e.cursor(L.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 u5{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?u2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?u2(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=r,null;if(s instanceof rW){if(r==e){if(r=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(r),this.index.push(0))}else this.index[t]++,this.nextStart=r+s.length}}}class u3{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new uI)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:s}=n,r=n.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,l=0;for(let n=0;nh.end+25&&(l=Math.max(h.lookAhead,l)),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),!a.extend&&(i=h,t>n))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),i||e.pos!=this.stream.end||((i=new uI).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 uI,{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(s>>1)){(1&s)==0?e.value=s>>1:e.extended=s>>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 u5(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,i=this.stacks,n=this.minStackPos,s=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 r=0;rn)s.push(o);else{if(this.advanceStack(o,s,i))continue;e||(e=[],t=[]),e.push(o);let n=this.tokens.getMainToken(o);t.push(n.value,n.end)}break}}if(!s.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,s);if(i)return u0&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(s.length>e)for(s.sort((e,t)=>t.score-e.score);s.length>e;)s.pop();s.some(e=>e.reducePos>n)&&this.recovering--}else if(s.length>1){s:for(let e=0;e500&&n.buffer.length>500){if((t.score-n.score||t.buffer.length-n.buffer.length)>0)s.splice(i--,1);else{s.splice(e--,1);continue s}}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[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?s.getGoto(e.state,o.type.id):-1;if(n>-1&&o.length&&(!t||(o.prop(rX.contextHash)||0)==i))return e.useNode(o,n),u0&&console.log(r+this.stackID(e)+` (via reuse of ${s.getName(o.type.id)})`),!0;if(!(o instanceof rW)||0==o.children.length||o.positions[0]>0)break;let l=o.children[0];if(l instanceof rW&&0==o.positions[0])o=l;else break}}let o=s.stateSlot(e.state,4);if(o>0)return e.reduce(o),u0&&console.log(r+this.stackID(e)+` (via always-reduce ${s.getName(65535&o)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=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 u7(e,t),!0}}runRecovery(e,t,i){let n=null,s=!1;for(let r=0;r ":"";if(o.deadEnd&&(s||(s=!0,o.restart(),u0&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let c=o.split(),u=h;for(let e=0;c.forceReduce()&&e<10&&(u0&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));e++)u0&&(u=this.stackID(c)+" -> ");for(let e of o.recoverByInsert(l))u0&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,i);this.stream.end>o.pos?(a==o.pos&&(a++,l=0),o.recoverByDelete(l,a),u0&&console.log(h+this.stackID(o)+` (via recover-delete ${this.parser.getName(l)})`),u7(o,i)):(!n||n.scoree;class u6{constructor(e){this.start=e.start,this.shift=e.shift||u8,this.reduce=e.reduce||u8,this.reuse=e.reuse||u8,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}class de extends r9{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)s(n,e,t[i++]);else{let r=t[i+-n];for(let o=-n;o>0;o--)s(t[i++],e,r);i++}}}this.nodeSet=new rV(t.map((t,s)=>rL.define({name:s>=this.minRepeatTerm?void 0:t,id:s,props:n[s],top:i.indexOf(s)>-1,error:0==s,skipped:e.skippedNodes&&e.skippedNodes.indexOf(s)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let r=uY(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 uG(r,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 u4(this,e,t,i);for(let s of this.wrappers)n=s(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return -1;for(let s=n[t+1];;){let t=n[s++],r=1&t,o=n[s++];if(r&&i)return o;for(let i=s+(t>>1);s0}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 s=e.specializers.find(e=>e.from==i.external);if(!s)return i;let r=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[n]=di(r),r})),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],ds=new u6({start:!1,shift:(e,t)=>5==t||6==t||318==t?e:319==t,strict:!1}),dr=new uF((e,t)=>{let{next:i}=e;(125==i||-1==i||t.context)&&e.acceptToken(316)},{contextual:!0,fallback:!0}),dl=new uF((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}),da=new uF((e,t)=>{91!=e.next||t.context||e.acceptToken(315)},{contextual:!0}),dh=new uF((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 dc(e,t){return e>=65&&e<=90||e>=97&&e<=122||95==e||e>=192||!t&&e>=48&&e<=57}const du=new uF((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(dc(e.next,!0)){for(e.advance(),i++;dc(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(!dc(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":oX.modifier,"for while do if else switch try catch finally return throw break continue default case":oX.controlKeyword,"in of await yield void typeof delete instanceof":oX.operatorKeyword,"let var const using function class extends":oX.definitionKeyword,"import export from":oX.moduleKeyword,"with debugger as new":oX.keyword,TemplateString:oX.special(oX.string),super:oX.atom,BooleanLiteral:oX.bool,this:oX.self,null:oX.null,Star:oX.modifier,VariableName:oX.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":oX.function(oX.variableName),VariableDefinition:oX.definition(oX.variableName),Label:oX.labelName,PropertyName:oX.propertyName,PrivatePropertyName:oX.special(oX.propertyName),"CallExpression/MemberExpression/PropertyName":oX.function(oX.propertyName),"FunctionDeclaration/VariableDefinition":oX.function(oX.definition(oX.variableName)),"ClassDeclaration/VariableDefinition":oX.definition(oX.className),"NewExpression/VariableName":oX.className,PropertyDefinition:oX.definition(oX.propertyName),PrivatePropertyDefinition:oX.definition(oX.special(oX.propertyName)),UpdateOp:oX.updateOperator,"LineComment Hashbang":oX.lineComment,BlockComment:oX.blockComment,Number:oX.number,String:oX.string,Escape:oX.escape,ArithOp:oX.arithmeticOperator,LogicOp:oX.logicOperator,BitOp:oX.bitwiseOperator,CompareOp:oX.compareOperator,RegExp:oX.regexp,Equals:oX.definitionOperator,Arrow:oX.function(oX.punctuation),": Spread":oX.punctuation,"( )":oX.paren,"[ ]":oX.squareBracket,"{ }":oX.brace,"InterpolationStart InterpolationEnd":oX.special(oX.brace),".":oX.derefOperator,", ;":oX.separator,"@":oX.meta,TypeName:oX.typeName,TypeDefinition:oX.definition(oX.typeName),"type enum interface implements namespace module declare":oX.definitionKeyword,"abstract global Privacy readonly override":oX.modifier,"is keyof unique infer asserts":oX.operatorKeyword,JSXAttributeValue:oX.attributeValue,JSXText:oX.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":oX.angleBracket,"JSXIdentifier JSXNameSpacedName":oX.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":oX.attributeName,"JSXBuiltin/JSXIdentifier":oX.standard(oX.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:ds,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:[dl,da,dh,du,2,3,4,5,6,7,8,9,10,11,12,13,14,dr,new uH("$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 uH("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=[cI("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),cI("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),cI("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),cI("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),cI("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),cI("try {\n ${}\n} catch (${error}) {\n ${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),cI("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),cI("if (${}) {\n ${}\n} else {\n ${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),cI("class ${name} {\n constructor(${params}) {\n ${}\n }\n}",{label:"class",detail:"definition",type:"keyword"}),cI('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),cI('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],db=dg.concat([cI("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),cI("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),cI("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),dx=new r4,dw=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function dk(e){return(t,i)=>{let n=t.node.getChild("VariableDefinition");return n&&i(n,e),!0}}const dy=["FunctionDeclaration"],dS={FunctionDeclaration:dk("function"),ClassDeclaration:dk("class"),ClassExpression:()=>!0,EnumDeclaration:dk("constant"),TypeAliasDeclaration:dk("type"),NamespaceDeclaration:dk("namespace"),VariableDefinition(e,t){e.matchContext(dy)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null},dv=/^[\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 d$(e){let t=oW(e.state).resolveInner(e.pos,-1);if(dQ.indexOf(t.name)>-1)return null;let i="VariableName"==t.name||t.to-t.from<20&&dv.test(e.state.sliceDoc(t.from,t.to));if(!i&&!e.explicit)return null;let n=[];for(let i=t;i;i=i.parent)dw.has(i.name)&&(n=n.concat(function e(t,i){let n=dx.get(i);if(n)return n;let s=[],r=!0;function o(e,i){let n=t.sliceString(e.from,e.to);s.push({label:n,type:i})}return i.cursor(L.IncludeAnonymous).iterate(i=>{if(r)r=!1;else if(i.name){let e=dS[i.name];if(e&&e(i,o)||dw.has(i.name))return!1}else if(i.to-i.from>8192){for(let n of e(t,i.node))s.push(n);return!1}}),dx.set(i,s),s}(e.state.doc,i)));return{options:n,from:i?t.from:e.pos,validFor:dv}}const dP=oD.define({name:"javascript",parser:dm.configure({props:[o4.add({IfStatement:le({except:/^\s*({|else\b)/}),TryStatement:le({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=>o6(n,t,i,e)}({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":le({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}),li.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ln,BlockComment:e=>({from:e.from+2,to:e.to-2})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),dZ={test:e=>/^JSX/.test(e.name),facet:oE({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dT=dP.configure({dialect:"ts"},"typescript"),dC=dP.configure({dialect:"jsx",props:[oL.add(e=>e.isTop?[dZ]:void 0)]}),dA=dP.configure({dialect:"jsx ts",props:[oL.add(e=>e.isTop?[dZ]:void 0)]},"typescript");let dR=e=>({label:e,type:"keyword"});const dM="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(dR),dX=dM.concat(["declare","implements","private","protected","public"].map(dR));function dq(e={}){var t;let i=e.jsx?e.typescript?dA:dC:e.typescript?dT:dP,n=e.typescript?db.concat(dX):dg.concat(dM);return new oF(i,[dP.data.of({autocomplete:(t=h3(n),e=>{for(let t=oW(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)})}),dP.data.of({autocomplete:d$}),e.jsx?dV:[]])}function dE(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 dL="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),dV=so.inputHandler.of((e,t,i,n,s)=>{if((dL?e.composing:e.compositionStarted)||e.state.readOnly||t!=i||">"!=n&&"/"!=n||!dP.isActiveAt(e.state,t,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(e=>{var t;let{head:i}=e,s=oW(o).resolveInner(i-1,-1),r;if("JSXStartTag"==s.name&&(s=s.parent),o.doc.sliceString(i-1,i)!=n||"JSXAttributeValue"==s.name&&s.to>i);else if(">"==n&&"JSXFragmentTag"==s.name)return{range:e,changes:{from:i,insert:">"}};else if("/"==n&&"JSXStartCloseTag"==s.name){let e=s.parent,n=e.parent;if(n&&e.from==i-2&&((r=dE(o.doc,n.firstChild,i))||(null===(t=n.firstChild)||void 0===t?void 0:t.name)=="JSXFragmentTag")){let e=`${r}>`;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}}(s);if(t&&"JSXOpenTag"==t.name&&!/^\/?>|^<\//.test(o.doc.sliceString(i,i+2))&&(r=dE(o.doc,t,i)))return{range:e,changes:{from:i,insert:`${r}>`}}}return{range:e}});return!l.changes.empty&&(e.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});class d_{static create(e,t,i,n,s){return new d_(e,t,i,n+(n<<8)+e+(t<<4)|0,s,[],[])}constructor(e,t,i,n,s,r,o){this.type=e,this.value=t,this.from=i,this.hash=n,this.end=s,this.children=r,this.positions=o,this.hashProp=[[rX.contextHash,n]]}addChild(e,t){e.prop(rX.contextHash)!=this.hash&&(e=new rW(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 rW(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,i)=>new rW(rL.none,e,t,i,this.hashProp)})}}(q=z||(z={}))[q.Document=1]="Document",q[q.CodeBlock=2]="CodeBlock",q[q.FencedCode=3]="FencedCode",q[q.Blockquote=4]="Blockquote",q[q.HorizontalRule=5]="HorizontalRule",q[q.BulletList=6]="BulletList",q[q.OrderedList=7]="OrderedList",q[q.ListItem=8]="ListItem",q[q.ATXHeading1=9]="ATXHeading1",q[q.ATXHeading2=10]="ATXHeading2",q[q.ATXHeading3=11]="ATXHeading3",q[q.ATXHeading4=12]="ATXHeading4",q[q.ATXHeading5=13]="ATXHeading5",q[q.ATXHeading6=14]="ATXHeading6",q[q.SetextHeading1=15]="SetextHeading1",q[q.SetextHeading2=16]="SetextHeading2",q[q.HTMLBlock=17]="HTMLBlock",q[q.LinkReference=18]="LinkReference",q[q.Paragraph=19]="Paragraph",q[q.CommentBlock=20]="CommentBlock",q[q.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",q[q.Escape=22]="Escape",q[q.Entity=23]="Entity",q[q.HardBreak=24]="HardBreak",q[q.Emphasis=25]="Emphasis",q[q.StrongEmphasis=26]="StrongEmphasis",q[q.Link=27]="Link",q[q.Image=28]="Image",q[q.InlineCode=29]="InlineCode",q[q.HTMLTag=30]="HTMLTag",q[q.Comment=31]="Comment",q[q.ProcessingInstruction=32]="ProcessingInstruction",q[q.Autolink=33]="Autolink",q[q.HeaderMark=34]="HeaderMark",q[q.QuoteMark=35]="QuoteMark",q[q.ListMark=36]="ListMark",q[q.LinkMark=37]="LinkMark",q[q.EmphasisMark=38]="EmphasisMark",q[q.CodeMark=39]="CodeMark",q[q.CodeText=40]="CodeText",q[q.CodeInfo=41]="CodeInfo",q[q.LinkTitle=42]="LinkTitle",q[q.LinkLabel=43]="LinkLabel",q[q.URL=44]="URL";class dD{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class dW{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 dY(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==z.OrderedList?dJ:dF)(i,t,!1);return n>0&&(e.type!=z.BulletList||0>dG(i,t,!1))&&i.text.charCodeAt(i.pos+n-1)==e.value}const dj={[z.Blockquote]:(e,t,i)=>62==i.next&&(i.markers.push(ff(z.QuoteMark,t.lineStart+i.pos,t.lineStart+i.pos+1)),i.moveBase(i.pos+(dB(i.text.charCodeAt(i.pos+1))?2:1)),e.end=t.lineStart+i.text.length,!0),[z.ListItem]:(e,t,i)=>(!(i.indent-1))&&(i.moveBaseColumn(i.baseIndent+e.value),!0),[z.OrderedList]:dz,[z.BulletList]:dz,[z.Document]:()=>!0};function dB(e){return 32==e||9==e||10==e||13==e}function dY(e,t=0){for(;ti&&dB(e.charCodeAt(t-1));)t--;return t}function dU(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 dH(e,t){for(let i=e.stack.length-1;i>=0;i--)if(e.stack[i].type==t)return!0;return!1}function dF(e,t,i){return(45==e.next||43==e.next||42==e.next)&&(e.pos==e.text.length-1||dB(e.text.charCodeAt(e.pos+1)))&&(!i||dH(t,z.BulletList)||e.skipSpace(e.pos+2)=48&&s<=57;){if(++n==e.text.length)return -1;s=e.text.charCodeAt(n)}return n==e.pos||n>e.pos+9||46!=s&&41!=s||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==z.CodeText?e[n].to=i:e.push(ff(z.CodeText,t,i))}const d8={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(l,e.lineStart-1,e.lineStart),t.markers))l.push(i);else if(t.indente.type!=z.CodeText)).length&&(t.markers=l.concat(t.markers)),e.addNode(e.buffer.writeElements(o,-s).finish(z.CodeBlock,r-s),s),!0},FencedCode(e,t){let i=dU(t);if(i<0)return!1;let n=e.lineStart+t.pos,s=t.next,r=i-t.pos,o=t.skipSpace(i),l=dI(t.text,t.text.length,o),a=[ff(z.CodeMark,n,n+r)];o=e.stack.length;i=!1){let n=t.pos;if(t.indent-t.baseIndent<4)for(;n=r&&t.skipSpace(n)==t.text.length){for(let e of t.markers)a.push(e);a.push(ff(z.CodeMark,e.lineStart+t.pos,e.lineStart+n)),e.nextLine();break}{for(let n of(i||d9(a,e.lineStart-1,e.lineStart),t.markers))a.push(n);let n=e.lineStart+t.basePos,s=e.lineStart+t.text.length;ndG(t,e,!1))return!1;let i=e.lineStart+t.pos;return e.nextLine(),e.addNode(z.HorizontalRule,i),!0},BulletList(e,t){let i=dF(t,e,!1);if(i<0)return!1;e.block.type!=z.BulletList&&e.startContext(z.BulletList,t.basePos,t.next);let n=d7(t,t.pos+1);return e.startContext(z.ListItem,t.basePos,n-t.baseIndent),e.addNode(z.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!=z.OrderedList&&e.startContext(z.OrderedList,t.basePos,t.text.charCodeAt(t.pos+i-1));let n=d7(t,t.pos+i);return e.startContext(z.ListItem,t.basePos,n-t.baseIndent),e.addNode(z.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,s=e.lineStart+n,r=dI(t.text,t.text.length,n),o=r;for(;o>n&&t.text.charCodeAt(o-1)==t.next;)o--;o!=r&&o!=n&&dB(t.text.charCodeAt(o-1))||(o=t.text.length);let l=e.buffer.write(z.HeaderMark,0,i).writeElements(e.parser.parseInline(t.text.slice(n+i+1,o),s+i+1),-s);o-1&&sthis.pos){let n=fS(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 d6(t):null,SetextHeading:()=>new ft},fn={text:"",end:0};class fs{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.line=new dW,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=d_.create(z.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=i.length?new fZ(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=d_.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 rW(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(f$(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,s,r){let o=t[i].to,l=[],a=[],h=n.from+s;function c(e,n){for(;n?e>=o:e>o;){let n=t[i+1].from-o;s+=n,e+=n,o=t[++i].to}}for(let u=n.firstChild;u;u=u.nextSibling){c(u.from+s,!0);let n=u.from+s,d,f=r.get(u.tree);f?d=f:u.to+s>o?(d=e(t,i,u,s,r),c(u.to+s,!1)):d=u.toTree(),l.push(d),a.push(n-h)}return c(n.to+s,!1),new rW(n.type,l,a,n.to+s-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=f$(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(z.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 fc(this.parser.nodeSet)}}class fr extends r9{constructor(e,t,i,n,s,r,o,l,a){for(let h of(super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,this.blockNames=n,this.endLeafBlock=s,this.skipContextMarkup=r,this.inlineParsers=o,this.inlineNames=l,this.wrappers=a,this.nodeTypes=Object.create(null),e.types))this.nodeTypes[h.name]=h.id}createParse(e,t,i){let n=new fs(this,e,t,i);for(let s of this.wrappers)n=s(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 s=(e,t)=>(e||fh).concat(t||fh),r=i.wrap,o=n.wrap;return{props:s(i.props,n.props),defineNodes:s(i.defineNodes,n.defineNodes),parseBlock:s(i.parseBlock,n.parseBlock),parseInline:s(i.parseInline,n.parseInline),remove:s(i.remove,n.remove),wrap:r?o?(e,t,i,n)=>r(o(e,t,i,n),t,i,n):r:o}}(e);if(!t)return this;let{nodeSet:i,skipContextMarkup:n}=this,s=this.blockParsers.slice(),r=this.leafBlockParsers.slice(),o=this.blockNames.slice(),l=this.inlineParsers.slice(),a=this.inlineNames.slice(),h=this.endLeafBlock.slice(),c=this.wrappers;if(fo(t.defineNodes)){n=Object.assign({},n);let e=i.types.slice(),s;for(let i of t.defineNodes){let{name:t,block:r,composite:o,style:l}="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 a=e.length,h=o?["Block","BlockContext"]:r?a>=z.ATXHeading1&&a<=z.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;e.push(rL.define({id:a,name:t,props:h&&[[rX.group,h]]})),l&&(s||(s={}),Array.isArray(l)||l instanceof ou?s[t]=l:Object.assign(s,l))}i=new rV(e),s&&(i=i.extend(op(s)))}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&&(s[t]=r[t]=void 0),i>-1&&(l[i]=void 0)}if(fo(t.parseBlock))for(let e of t.parseBlock){let t=o.indexOf(e.name);if(t>-1)s[t]=e.parse,r[t]=e.leaf;else{let t=e.before?fl(o,e.before):e.after?fl(o,e.after)+1:o.length-1;s.splice(t,0,e.parse),r.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=a.indexOf(e.name);if(t>-1)l[t]=e.parse;else{let t=e.before?fl(a,e.before):e.after?fl(a,e.after)+1:a.length-1;l.splice(t,0,e.parse),a.splice(t,0,e.name)}}return t.wrap&&(c=c.concat(t.wrap)),new fr(i,s,r,o,h,n,l,a,c)}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);s:for(let e=t;e=0){e=s;continue s}}e++}return i.resolveMarkers(0)}}function fo(e){return null!=e&&e.length>0}function fl(e,t){let i=e.indexOf(t);if(i<0)throw RangeError(`Position specified relative to unknown parser ${t}`);return i}let fa=[rL.none];for(let e=1,t;t=z[e];e++)fa[e]=rL.define({id:e,name:t,props:e>=z.Escape?[]:[[rX.group,e in dj?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==t});const fh=[];class fc{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 rW.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}class fu{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 fc(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 fu(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 fw=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{fw=RegExp("[\\p{S}|\\p{P}]","u")}catch(e){}const fk={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(s)return e.append(ff(z.Autolink,i,i+1+s[0].length,[ff(z.LinkMark,i,i+1),ff(z.URL,i+1,i+s[0].length),ff(z.LinkMark,i+s[0].length,i+1+s[0].length)]));let r=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);if(r)return e.append(ff(z.Comment,i,i+1+r[0].length));let o=/^\?[^]*?\?>/.exec(n);if(o)return e.append(ff(z.ProcessingInstruction,i,i+1+o[0].length));let l=/^(?:![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 l?e.append(ff(z.HTMLTag,i,i+1+l[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 s=e.slice(i-1,i),r=e.slice(n,n+1),o=fw.test(s),l=fw.test(r),a=/\s|^$/.test(s),h=/\s|^$/.test(r),c=!h&&(!l||a||o),u=!a&&(!o||h||l);return e.append(new fb(95==t?fp:fO,i,n,+!!(c&&(42==t||!u||o))|2*!!(u&&(42==t||!c||l))))},HardBreak(e,t,i){if(92==t&&10==e.char(i+1))return e.append(ff(z.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(z.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 s=e.takeContent(t),r=e.parts[t]=function(e,t,i,n,s){let{text:r}=e,o=e.char(s),l=s;if(t.unshift(ff(z.LinkMark,n,n+(i==z.Image?2:1))),t.push(ff(z.LinkMark,s-1,s)),40==o){let i=e.skipSpace(s+1),n=fy(r,i-e.offset,e.offset),o;n&&(i=e.skipSpace(n.to))!=n.to&&(o=fS(r,i-e.offset,e.offset))&&(i=e.skipSpace(o.to)),41==e.char(i)&&(t.push(ff(z.LinkMark,s,s+1)),l=i+1,n&&t.push(n),o&&t.push(o),t.push(ff(z.LinkMark,i,l)))}else if(91==o){let i=fv(r,s-e.offset,e.offset,!1);i&&(t.push(i),l=i.to)}return ff(i,n,l,t)}(e,s,n.type==fm?z.Link:z.Image,n.from,i+1);if(n.type==fm)for(let i=0;it?ff(z.URL,t+i,s+i):s==e.length&&null}}function fS(e,t,i){let n=e.charCodeAt(t);if(39!=n&&34!=n&&40!=n)return!1;let s=40==n?41:n;for(let n=t+1,r=!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,s){return this.append(new fb(e,t,i,+!!n|2*!!s))}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+s)%3==0&&((e.to-e.from)%3||s%3))){r=e;break}}if(!r)continue;let l=i.type.resolve,a=[],h=r.from,c=i.to;if(n){let e=Math.min(2,r.to-r.from,s);h=r.to-e,c=i.from+e,l=1==e?"Emphasis":"StrongEmphasis"}r.type.mark&&a.push(this.elt(r.type.mark,h,r.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 dY(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 f$(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(rX.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,n=this.fragmentEnd-+!!this.fragment.openEnd,s=e.absoluteLineStart,r=s,o=e.block.children.length,l=r,a=o;for(;;){if(t.to-i>n){if(t.type.isAnonymous&&t.firstChild())continue;break}let s=fT(t.from-i,e.ranges);if(t.to-i<=e.ranges[e.rangeI].to)e.addNode(t.tree,s);else{let i=new rW(e.parser.nodeSet.types[z.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(i,t.tree),e.addNode(i,s)}if(t.type.is("Block")&&(0>fP.indexOf(t.type.id)?(r=t.to-i,o=e.block.children.length):(r=l,o=a,l=t.to-i,a=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return r-s}}function fT(e,t){let i=e;for(let n=1;nd8[e]),Object.keys(d8).map(e=>fi[e]),Object.keys(d8),[(e,t)=>dK(t)>=0,(e,t)=>dU(t)>=0,(e,t)=>dN(t)>=0,(e,t)=>dF(t,e,!0)>=0,(e,t)=>dJ(t,e,!0)>=0,(e,t)=>dG(t,e,!0)>=0,(e,t)=>d4(t,e,!0)>=0],dj,Object.keys(fk).map(e=>fk[e]),Object.keys(fk),[]),fR={resolve:"Strikethrough",mark:"StrikethroughMark"},fM={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":oX.strikethrough}},{name:"StrikethroughMark",style:oX.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),s=e.slice(i+2,i+3),r=/\s|^$/.test(n),o=/\s|^$/.test(s),l=fw.test(n),a=fw.test(s);return e.addDelimiter(fR,i,i+2,!o&&(!a||r||l),!r&&(!l||o||a))},after:"Emphasis"}]};function fX(e,t,i=0,n,s=0){let r=0,o=!0,l=-1,a=-1,h=!1,c=()=>{n.push(e.elt("TableCell",s+l,s+a,e.parser.parseInline(t.slice(l,a),s+l)))};for(let u=i;u-1)&&r++,o=!1,n&&(l>-1&&c(),n.push(e.elt("TableDelimiter",u+s,u+s+1))),l=a=-1),h=!h&&92==i}return l>-1&&(r++,n&&c()),r}function fq(e,t){for(let i=t;i