-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
1 lines (1 loc) · 755 KB
/
index.js
File metadata and controls
1 lines (1 loc) · 755 KB
1
(()=>{var e,t,i,s,r,n,o,a={616(e){var t;self,t=()=>(()=>{"use strict";var e,t={};return e=t,Object.defineProperty(e,"__esModule",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const i=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),h=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-i;return{cols:Math.max(2,Math.floor(h/t.css.cell.width)),rows:Math.max(1,Math.floor(a/t.css.cell.height))}}},t})(),e.exports=t()},856(e){var t;globalThis,t=()=>(()=>{"use strict";var e={4567:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;const n=i(9042),o=i(9924),a=i(844),h=i(4725),l=i(2585),c=i(3656);let u=t.AccessibilityManager=class extends a.Disposable{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar("\n")))),this.register(this._terminal.onA11yTab((e=>this._handleTab(e)))),this.register(this._terminal.onKey((e=>this._handleKey(e.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,c.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,a.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=n.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){const i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){const e=i.lines.get(i.ydisp+r),t=[],n=e?.translateToString(!0,void 0,void 0,t)||"",o=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(0===n.length?(a.innerText=" ",this._rowColumns.set(a,[0,1])):(a.textContent=n,this._rowColumns.set(a,t)),a.setAttribute("aria-posinset",o),a.setAttribute("aria-setsize",s))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){const i=e.target,s=this._rowElements[0===t?1:this._rowElements.length-2];if(i.getAttribute("aria-posinset")===(0===t?"1":`${this._terminal.buffer.lines.length}`))return;if(e.relatedTarget!==s)return;let r,n;if(0===t?(r=i,n=this._rowElements.pop(),this._rowContainer.removeChild(n)):(r=this._rowElements.shift(),n=i,this._rowContainer.removeChild(r)),r.removeEventListener("focus",this._topBoundaryFocusListener),n.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){const e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{const e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(0===this._rowElements.length)return;const e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;const s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;const r=({node:e,offset:t})=>{const i=e instanceof Text?e.parentNode:e;let s=parseInt(i?.getAttribute("aria-posinset"),10)-1;if(isNaN(s))return console.warn("row is invalid. Race condition?"),null;const r=this._rowColumns.get(i);if(!r)return console.warn("columns is null. Race condition?"),null;let n=t<r.length?r[t]:r.slice(-1)[0]+1;return n>=this._terminal.cols&&(++s,n=0),{row:s,column:n}},n=r(t),o=r(i);if(n&&o){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};t.AccessibilityManager=u=s([r(1,l.IInstantiationService),r(2,h.ICoreBrowserService),r(3,h.IRenderService)],u)},3614:(e,t)=>{function i(e){return e.replace(/\r?\n/g,"\r")}function s(e,t){return t?"[200~"+e+"[201~":e}function r(e,t,r,n){e=s(e=i(e),r.decPrivateModes.bracketedPasteMode&&!0!==n.rawOptions.ignoreBracketedPasteMode),r.triggerDataEvent(e,!0),t.value=""}function n(e,t,i){const s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}Object.defineProperty(t,"__esModule",{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=i,t.bracketTextForPaste=s,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,i,s){e.stopPropagation(),e.clipboardData&&r(e.clipboardData.getData("text/plain"),t,i,s)},t.paste=r,t.moveTextAreaUnderMouseCursor=n,t.rightClickHandler=function(e,t,i,s,r){n(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}},7239:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;const s=i(1505);t.ColorContrastCache=class{constructor(){this._color=new s.TwoKeyMap,this._css=new s.TwoKeyMap}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},3656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,i,s){e.addEventListener(t,i,s);let r=!1;return{dispose:()=>{r||(r=!0,e.removeEventListener(t,i,s))}}}},3551:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier=void 0;const n=i(3656),o=i(8460),a=i(844),h=i(2585),l=i(4725);let c=t.Linkifier=class extends a.Disposable{get currentLink(){return this._currentLink}constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new o.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new o.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,a.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,a.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,n.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,n.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,n.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,n.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(e){this._lastMouseEvent=e;const t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;const i=e.composedPath();for(let e=0;e<i.length;e++){const t=i[e];if(t.classList.contains("xterm"))break;if(t.classList.contains("xterm-hover"))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach((e=>{e?.forEach((e=>{e.link.dispose&&e.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(const[s,r]of this._linkProviderService.linkProviders.entries())if(t){const t=this._activeProviderReplies?.get(s);t&&(i=this._checkLinkProviderResult(s,e,i))}else r.provideLinks(e.y,(t=>{if(this._isMouseOut)return;const r=t?.map((e=>({link:e})));this._activeProviderReplies?.set(s,r),i=this._checkLinkProviderResult(s,e,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)}))}_removeIntersectingLinks(e,t){const i=new Set;for(let s=0;s<t.size;s++){const r=t.get(s);if(r)for(let t=0;t<r.length;t++){const s=r[t],n=s.link.range.start.y<e?0:s.link.range.start.x,o=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let e=n;e<=o;e++){if(i.has(e)){r.splice(t--,1);break}i.add(e)}}}}_checkLinkProviderResult(e,t,i){if(!this._activeProviderReplies)return i;const s=this._activeProviderReplies.get(e);let r=!1;for(let t=0;t<e;t++)this._activeProviderReplies.has(t)&&!this._activeProviderReplies.get(t)||(r=!0);if(!r&&s){const e=s.find((e=>this._linkAtPosition(e.link,t)));e&&(i=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let e=0;e<this._activeProviderReplies.size;e++){const s=this._activeProviderReplies.get(e)?.find((e=>this._linkAtPosition(e.link,t)));if(s){i=!0,this._handleNewLink(s);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;const t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,a.disposeArray)(this._linkCacheDisposables))}_handleNewLink(e){if(!this._lastMouseEvent)return;const t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((e=>{if(!this._currentLink)return;const t=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(t,i),this._lastMouseEvent)){const e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}}))))}_linkHover(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){const i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){const i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){const s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};t.Linkifier=c=s([r(1,l.IMouseService),r(2,l.IRenderService),r(3,h.IBufferService),r(4,l.ILinkProviderService)],c)},9042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel="Terminal input",t.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkProvider=void 0;const n=i(511),o=i(2585);let a=t.OscLinkProvider=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){const i=this._bufferService.buffer.lines.get(e-1);if(!i)return void t(void 0);const s=[],r=this._optionsService.rawOptions.linkHandler,o=new n.CellData,a=i.getTrimmedLength();let l=-1,c=-1,u=!1;for(let t=0;t<a;t++)if(-1!==c||i.hasContent(t)){if(i.loadCell(t,o),o.hasExtendedAttrs()&&o.extended.urlId){if(-1===c){c=t,l=o.extended.urlId;continue}u=o.extended.urlId!==l}else-1!==c&&(u=!0);if(u||-1!==c&&t===a-1){const i=this._oscLinkService.getLinkData(l)?.uri;if(i){const n={start:{x:c+1,y:e},end:{x:t+(u||t!==a-1?0:1),y:e}};let o=!1;if(!r?.allowNonHttpProtocols)try{const e=new URL(i);["http:","https:"].includes(e.protocol)||(o=!0)}catch(e){o=!0}o||s.push({text:i,range:n,activate:(e,t)=>r?r.activate(e,t,n):h(0,t),hover:(e,t)=>r?.hover?.(e,t,n),leave:(e,t)=>r?.leave?.(e,t,n)})}u=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=t,l=o.extended.urlId):(c=-1,l=-1)}}t(s)}};function h(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){const e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}t.OscLinkProvider=a=s([r(0,o.IBufferService),r(1,o.IOptionsService),r(2,o.IOscLinkService)],a)},6193:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();const e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},3236:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;const s=i(3614),r=i(3656),n=i(3551),o=i(9042),a=i(3730),h=i(1680),l=i(3107),c=i(5744),u=i(2950),d=i(1296),f=i(428),p=i(4269),g=i(5114),m=i(8934),v=i(3230),_=i(9312),O=i(4725),S=i(6731),w=i(8055),b=i(8969),y=i(8460),D=i(844),C=i(6114),k=i(8437),x=i(2584),E=i(7399),T=i(5941),A=i(9074),R=i(2585),P=i(5435),M=i(4567),B=i(779);class L extends b.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(e={}){super(e),this.browser=C,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new D.MutableDisposable),this._onCursorMove=this.register(new y.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new y.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new y.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new y.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new y.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new y.EventEmitter),this._onBlur=this.register(new y.EventEmitter),this._onA11yCharEmitter=this.register(new y.EventEmitter),this._onA11yTabEmitter=this.register(new y.EventEmitter),this._onWillOpen=this.register(new y.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(R.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(B.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(a.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((e,t)=>this.refresh(e,t)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((e=>this._reportWindowsOptions(e)))),this.register(this._inputHandler.onColor((e=>this._handleColorEvent(e)))),this.register((0,y.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,y.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,y.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,y.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((e=>this._afterResize(e.cols,e.rows)))),this.register((0,D.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(e){if(this._themeService)for(const t of e){let e,i="";switch(t.index){case 256:e="foreground",i="10";break;case 257:e="background",i="11";break;case 258:e="cursor",i="12";break;default:e="ansi",i="4;"+t.index}switch(t.type){case 0:const s=w.color.toColorRGB("ansi"===e?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${x.C0.ESC}]${i};${(0,T.toRgbString)(s)}${x.C1_ESCAPED.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors((e=>e.ansi[t.index]=w.channels.toColor(...t.color)));else{const i=e;this._themeService.modifyColors((e=>e[i]=w.channels.toColor(...t.color)))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(M.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;const i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,r.addDisposableDomListener)(this.element,"copy",(e=>{this.hasSelection()&&(0,s.copyHandler)(e,this._selectionService)})));const e=e=>(0,s.handlePasteEvent)(e,this.textarea,this.coreService,this.optionsService);this.register((0,r.addDisposableDomListener)(this.textarea,"paste",e)),this.register((0,r.addDisposableDomListener)(this.element,"paste",e)),C.isFirefox?this.register((0,r.addDisposableDomListener)(this.element,"mousedown",(e=>{2===e.button&&(0,s.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,r.addDisposableDomListener)(this.element,"contextmenu",(e=>{(0,s.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),C.isLinux&&this.register((0,r.addDisposableDomListener)(this.element,"auxclick",(e=>{1===e.button&&(0,s.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,r.addDisposableDomListener)(this.textarea,"keyup",(e=>this._keyUp(e)),!0)),this.register((0,r.addDisposableDomListener)(this.textarea,"keydown",(e=>this._keyDown(e)),!0)),this.register((0,r.addDisposableDomListener)(this.textarea,"keypress",(e=>this._keyPress(e)),!0)),this.register((0,r.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,r.addDisposableDomListener)(this.textarea,"compositionupdate",(e=>this._compositionHelper.compositionupdate(e)))),this.register((0,r.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,r.addDisposableDomListener)(this.textarea,"input",(e=>this._inputEvent(e)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);const t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,r.addDisposableDomListener)(this.screenElement,"mousemove",(e=>this.updateCursorStyle(e)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",o.promptLabel),C.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(g.CoreBrowserService,this.textarea,e.ownerDocument.defaultView??window,this._document??"undefined"!=typeof window?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,r.addDisposableDomListener)(this.textarea,"focus",(e=>this._handleTextAreaFocus(e)))),this.register((0,r.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(S.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(p.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(v.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((e=>this._onRender.fire(e)))),this.onResize((e=>this._renderService.resize(e.cols,e.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(u.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(m.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(n.Linkifier,this.screenElement)),this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(h.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(_.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(O.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,r.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,r.addDisposableDomListener)(this.element,"mousedown",(e=>this._selectionService.handleMouseDown(e)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(M.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(e=>this._handleScreenReaderModeOptionChange(e)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(c.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(c.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const e=this,t=this.element;function i(t){const i=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!i)return!1;let s,r;switch(t.overrideType||t.type){case"mousemove":r=32,void 0===t.buttons?(s=3,void 0!==t.button&&(s=t.button<3?t.button:3)):s=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case"mouseup":r=0,s=t.button<3?t.button:3;break;case"mousedown":r=1,s=t.button<3?t.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t))return!1;if(0===e.viewport.getLinesScrolled(t))return!1;r=t.deltaY<0?0:1,s=4;break;default:return!1}return!(void 0===r||void 0===s||s>4)&&e.coreMouseService.triggerMouseEvent({col:i.col,row:i.row,x:i.x,y:i.y,button:s,action:r,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}const s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:e=>(i(e),e.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(e)),wheel:e=>(i(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&i(e)},mousemove:e=>{e.buttons||i(e)}};this.register(this.coreMouseService.onProtocolChange((e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?s.mousemove||(t.addEventListener("mousemove",n.mousemove),s.mousemove=n.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),16&e?s.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),s.wheel=n.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),2&e?s.mouseup||(s.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),4&e?s.mousedrag||(s.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,r.addDisposableDomListener)(t,"mousedown",(e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return i(e),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(e)}))),this.register((0,r.addDisposableDomListener)(t,"wheel",(e=>{if(!s.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(e))return!1;if(!this.buffer.hasScrollback){const t=this.viewport.getLinesScrolled(e);if(0===t)return;const i=x.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(e.deltaY<0?"A":"B");let s="";for(let e=0;e<Math.abs(t);e++)s+=i;return this.coreService.triggerDataEvent(s,!0),this.cancel(e,!0)}return this.viewport.handleWheel(e)?this.cancel(e):void 0}}),{passive:!1})),this.register((0,r.addDisposableDomListener)(t,"touchstart",(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(e),this.cancel(e)}),{passive:!0})),this.register((0,r.addDisposableDomListener)(t,"touchmove",(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(e)?void 0:this.cancel(e)}),{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t,i=0){1===i?(super.scrollLines(e,t,i),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(e)}paste(e){(0,s.paste)(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;const t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;t||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);const i=(0,E.evaluateKeyboardEvent)(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===i.type||2===i.type){const t=this.rows-1;return this.scrollLines(2===i.type?-t:t),this.cancel(e,!0)}return 1===i.type&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key||!!(e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(i.key!==x.C0.ETX&&i.key!==x.C0.CR||(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(e,t){const i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return"keypress"===t.type?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return 16===e.keyCode||17===e.keyCode||18===e.keyCode}(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled)return!1;if(this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null===e.which||void 0===e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(k.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;const e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(x.C0.ESC+"[I"):this.coreService.triggerDataEvent(x.C0.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case P.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${x.C0.ESC}[4;${t};${e}t`);break;case P.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const i=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${x.C0.ESC}[6;${s};${i}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}}t.Terminal=L},9924:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeBasedDebouncer=void 0,t.TimeBasedDebouncer=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t;const s=Date.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){const e=s-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;const e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}}},1680:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;const n=i(3656),o=i(4725),a=i(8460),h=i(844),l=i(2585);let c=t.Viewport=class extends h.Disposable{constructor(e,t,i,s,r,o,h,l){super(),this._viewportElement=e,this._scrollArea=t,this._bufferService=i,this._optionsService=s,this._charSizeService=r,this._renderService=o,this._coreBrowserService=h,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new a.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,n.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((e=>this._renderDimensions=e))),this._handleThemeChange(l.colors),this.register(l.onChangeColors((e=>this._handleThemeChange(e)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(e){this._viewportElement.style.backgroundColor=e.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(e){if(e)return this._innerRefresh(),void(null!==this._refreshAnimationFrame&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));null===this._refreshAnimationFrame&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const e=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==e&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=e),this._refreshAnimationFrame=null}syncScrollArea(e=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(e)}_handleScroll(e){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||-1===this._smoothScrollState.origin||-1===this._smoothScrollState.target)return;const e=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(e*(this._smoothScrollState.target-this._smoothScrollState.origin)),e<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(e,t){const i=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&0!==this._viewportElement.scrollTop||t>0&&i<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)}handleWheel(e){const t=this._getPixelsScrolled(e);return 0!==t&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,-1===this._smoothScrollState.target?this._smoothScrollState.target=this._viewportElement.scrollTop+t:this._smoothScrollState.target+=t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}scrollLines(e){if(0!==e)if(this._optionsService.rawOptions.smoothScrollDuration){const t=e*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!1})}_getPixelsScrolled(e){if(0===e.deltaY||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t}getBufferElements(e,t){let i,s="";const r=[],n=t??this._bufferService.buffer.lines.length,o=this._bufferService.buffer.lines;for(let t=e;t<n;t++){const e=o.get(t);if(!e)continue;const n=o.get(t+1)?.isWrapped;if(s+=e.translateToString(!n),!n||t===o.length-1){const e=document.createElement("div");e.textContent=s,r.push(e),s.length>0&&(i=e),s=""}}return{bufferElements:r,cursorElement:i}}getLinesScrolled(e){if(0===e.deltaY||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t}_applyScrollModifier(e,t){const i=this._optionsService.rawOptions.fastScrollModifier;return"alt"===i&&t.altKey||"ctrl"===i&&t.ctrlKey||"shift"===i&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(e){this._lastTouchY=e.touches[0].pageY}handleTouchMove(e){const t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}};t.Viewport=c=s([r(2,l.IBufferService),r(3,l.IOptionsService),r(4,o.ICharSizeService),r(5,o.IRenderService),r(6,o.ICoreBrowserService),r(7,o.IThemeService)],c)},3107:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferDecorationRenderer=void 0;const n=i(4725),o=i(844),a=i(2585);let h=t.BufferDecorationRenderer=class extends o.Disposable{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((e=>this._removeDecoration(e)))),this.register((0,o.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){const t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer","top"===e?.options?.layer),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+"px",t.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){const t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose((()=>{this._decorationElements.delete(e),i.remove()}))),i.style.top=t*this._renderService.dimensions.css.cell.height+"px",i.style.display=this._altBufferIsActive?"none":"block",e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;const i=e.options.x??0;"right"===(e.options.anchor||"left")?t.style.right=i?i*this._renderService.dimensions.css.cell.width+"px":"":t.style.left=i?i*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};t.BufferDecorationRenderer=h=s([r(1,a.IBufferService),r(2,n.ICoreBrowserService),r(3,a.IDecorationService),r(4,n.IRenderService)],h)},5871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorZoneStore=void 0,t.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(const t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}}},5744:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OverviewRulerRenderer=void 0;const n=i(5871),o=i(4725),a=i(844),h=i(2585),l={full:0,left:0,center:0,right:0},c={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let d=t.OverviewRulerRenderer=class extends a.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(e,t,i,s,r,o,h){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=o,this._coreBrowserService=h,this._colorZoneStore=new n.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);const l=this._canvas.getContext("2d");if(!l)throw new Error("Ctx cannot be null");this._ctx=l,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,a.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const e=Math.floor(this._canvas.width/3),t=Math.ceil(this._canvas.width/3);c.full=this._canvas.width,c.left=e,c.center=t,c.right=e,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=c.left,u.right=c.left+c.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);const e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);l.left=t,l.center=t,l.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1;const e=this._colorZoneStore.zones;for(const t of e)"full"!==t.position&&this._renderColorZone(t);for(const t of e)"full"===t.position&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(u[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-l[e.position||"full"]/2),c[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};t.OverviewRulerRenderer=d=s([r(2,h.IBufferService),r(3,h.IDecorationService),r(4,o.IRenderService),r(5,h.IOptionsService),r(6,o.ICoreBrowserService)],d)},2950:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompositionHelper=void 0;const n=i(4725),o=i(2585),a=i(2584);let h=t.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(229===e.keyCode)return!1;if(16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){const e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,e.end):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;const e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){const e=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${a.C0.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}}),0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const r=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(r.width,1)+"px",this._textarea.style.height=Math.max(r.height,1)+"px",this._textarea.style.lineHeight=r.height+"px"}e||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};t.CompositionHelper=h=s([r(2,o.IBufferService),r(3,o.IOptionsService),r(4,o.ICoreService),r(5,n.IRenderService)],h)},9806:(e,t)=>{function i(e,t,i){const s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}Object.defineProperty(t,"__esModule",{value:!0}),t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=i,t.getCoords=function(e,t,s,r,n,o,a,h,l){if(!o)return;const c=i(e,t,s);return c?(c[0]=Math.ceil((c[0]+(l?a/2:0))/a),c[1]=Math.ceil(c[1]/h),c[0]=Math.min(Math.max(c[0],1),r+(l?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c):void 0}},9504:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.moveToCellSequence=void 0;const s=i(2584);function r(e,t,i,s){const r=e-n(e,i),a=t-n(t,i),c=Math.abs(r-a)-function(e,t,i){let s=0;const r=e-n(e,i),a=t-n(t,i);for(let n=0;n<Math.abs(r-a);n++){const a="A"===o(e,t)?-1:1,h=i.buffer.lines.get(r+a*n);h?.isWrapped&&s++}return s}(e,t,i);return l(c,h(o(e,t),s))}function n(e,t){let i=0,s=t.buffer.lines.get(e),r=s?.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s?.isWrapped;return i}function o(e,t){return e>t?"A":"B"}function a(e,t,i,s,r,n){let o=e,a=t,h="";for(;o!==i||a!==s;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function h(e,t){const i=t?"O":"[";return s.C0.ESC+i+e}function l(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}t.moveToCellSequence=function(e,t,i,s){const o=i.buffer.x,c=i.buffer.y;if(!i.buffer.hasScrollback)return function(e,t,i,s,o,c){return 0===r(t,s,o,c).length?"":l(a(e,t,e,t-n(t,o),!1,o).length,h("D",c))}(o,c,0,t,i,s)+r(c,t,i,s)+function(e,t,i,s,o,c){let u;u=r(t,s,o,c).length>0?s-n(s,o):t;const d=s,f=function(e,t,i,s,o,a){let h;return h=r(i,s,o,a).length>0?s-n(s,o):t,e<i&&h<=s||e>=i&&h<s?"C":"D"}(e,t,i,s,o,c);return l(a(e,u,i,d,"C"===f,o).length,h(f,c))}(o,c,e,t,i,s);let u;if(c===t)return u=o>e?"D":"C",l(Math.abs(o-e),h(u,s));u=c>t?"D":"C";const d=Math.abs(c-t);return l(function(e,t){return t.cols-e}(c>t?e:o,i)+(d-1)*i.cols+1+((c>t?o:e)-1),h(u,s))}},1296:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRenderer=void 0;const n=i(3787),o=i(2550),a=i(2223),h=i(6171),l=i(6052),c=i(4725),u=i(8055),d=i(8460),f=i(844),p=i(2585),g="xterm-dom-renderer-owner-",m="xterm-rows",v="xterm-fg-",_="xterm-bg-",O="xterm-focus",S="xterm-selection";let w=1,b=t.DomRenderer=class extends f.Disposable{constructor(e,t,i,s,r,a,c,u,p,v,_,O,b){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=a,this._linkifier2=c,this._charSizeService=p,this._optionsService=v,this._bufferService=_,this._coreBrowserService=O,this._themeService=b,this._terminalClass=w++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new d.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(m),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(S),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,h.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((e=>this._injectCss(e)))),this._injectCss(this._themeService.colors),this._rowFactory=u.createInstance(n.DomRendererRowFactory,document),this._element.classList.add(g+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((e=>this._handleLinkHover(e)))),this.register(this._linkifier2.onHideLinkUnderline((e=>this._handleLinkLeave(e)))),this.register((0,f.toDisposable)((()=>{this._element.classList.remove(g+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new o.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const t=`${this._terminalSelector} .${m} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${m} { color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${m} .xterm-dim { color: ${u.color.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${m}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${m}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${m}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${m} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${m} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${m} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${m} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${m} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${S} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${S} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${S} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(const[i,s]of e.ansi.entries())t+=`${this._terminalSelector} .${v}${i} { color: ${s.css}; }${this._terminalSelector} .${v}${i}.xterm-dim { color: ${u.color.multiplyOpacity(s,.5).css}; }${this._terminalSelector} .${_}${i} { background-color: ${s.css}; }`;t+=`${this._terminalSelector} .${v}${a.INVERTED_DEFAULT_COLOR} { color: ${u.color.opaque(e.background).css}; }${this._terminalSelector} .${v}${a.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${u.color.multiplyOpacity(u.color.opaque(e.background),.5).css}; }${this._terminalSelector} .${_}${a.INVERTED_DEFAULT_COLOR} { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){const e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){const e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t)return;this._selectionRenderModel.update(this._terminal,e,t,i);const s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow;if(n>=this._bufferService.rows||o<0)return;const a=this._document.createDocumentFragment();if(i){const i=e[0]>t[0];a.appendChild(this._createSelectionElement(n,i?t[0]:e[0],i?e[0]:t[0],o-n+1))}else{const i=s===n?e[0]:0,h=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,i,h));const l=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,l)),n!==o){const e=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){const r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width;let o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=s*this.dimensions.css.cell.height+"px",r.style.top=e*this.dimensions.css.cell.height+"px",r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const e of this._rowElements)e.replaceChildren()}renderRows(e,t){const i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._optionsService.rawOptions.cursorBlink,o=this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){const e=h+i.ydisp,t=this._rowElements[h],l=i.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${g}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);const o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);const a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=i;o<=s;++o){const f=o+a.ydisp,p=this._rowElements[o],g=a.lines.get(f);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,f,f===h,u,d,l,c,this.dimensions.css.cell.width,this._widthCache,n?o===i?e:0:-1,n?(o===s?t:r)-1:-1))}}};t.DomRenderer=b=s([r(7,p.IInstantiationService),r(8,c.ICharSizeService),r(9,p.IOptionsService),r(10,p.IBufferService),r(11,c.ICoreBrowserService),r(12,c.IThemeService)],b)},3787:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRendererRowFactory=void 0;const n=i(2223),o=i(643),a=i(511),h=i(2585),l=i(8055),c=i(4725),u=i(4269),d=i(6171),f=i(3734);let p=t.DomRendererRowFactory=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new a.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,a,h,c,d,p,m){const v=[],_=this._characterJoinerService.getJoinedCharacters(t),O=this._themeService.colors;let S,w=e.getNoBgTrimmedLength();i&&w<a+1&&(w=a+1);let b=0,y="",D=0,C=0,k=0,x=!1,E=0,T=!1,A=0;const R=[],P=-1!==p&&-1!==m;for(let M=0;M<w;M++){e.loadCell(M,this._workCell);let w=this._workCell.getWidth();if(0===w)continue;let B=!1,L=M,F=this._workCell;if(_.length>0&&M===_[0][0]){B=!0;const t=_.shift();F=new u.JoinedCellData(this._workCell,e.translateToString(!0,t[0],t[1]),t[1]-t[0]),L=t[1]-1,w=F.getWidth()}const I=this._isCellInSelection(M,t),Q=i&&M===a,W=P&&M>=p&&M<=m;let H=!1;this._decorationService.forEachDecorationAtCell(M,t,void 0,(e=>{H=!0}));let q=F.getChars()||o.WHITESPACE_CELL_CHAR;if(" "===q&&(F.isUnderline()||F.isOverline())&&(q=" "),A=w*c-d.get(q,F.isBold(),F.isItalic()),S){if(b&&(I&&T||!I&&!T&&F.bg===D)&&(I&&T&&O.selectionForeground||F.fg===C)&&F.extended.ext===k&&W===x&&A===E&&!Q&&!B&&!H){F.isInvisible()?y+=o.WHITESPACE_CELL_CHAR:y+=q,b++;continue}b&&(S.textContent=y),S=this._document.createElement("span"),b=0,y=""}else S=this._document.createElement("span");if(D=F.bg,C=F.fg,k=F.extended.ext,x=W,E=A,T=I,B&&a>=M&&a<=L&&(a=M),!this._coreService.isCursorHidden&&Q&&this._coreService.isCursorInitialized)if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&R.push("xterm-cursor-blink"),R.push("bar"===s?"xterm-cursor-bar":"underline"===s?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline")}if(F.isBold()&&R.push("xterm-bold"),F.isItalic()&&R.push("xterm-italic"),F.isDim()&&R.push("xterm-dim"),y=F.isInvisible()?o.WHITESPACE_CELL_CHAR:F.getChars()||o.WHITESPACE_CELL_CHAR,F.isUnderline()&&(R.push(`xterm-underline-${F.extended.underlineStyle}`)," "===y&&(y=" "),!F.isUnderlineColorDefault()))if(F.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(F.getUnderlineColor()).join(",")})`;else{let e=F.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&F.isBold()&&e<8&&(e+=8),S.style.textDecorationColor=O.ansi[e].css}F.isOverline()&&(R.push("xterm-overline")," "===y&&(y=" ")),F.isStrikethrough()&&R.push("xterm-strikethrough"),W&&(S.style.textDecoration="underline");let $=F.getFgColor(),z=F.getFgColorMode(),N=F.getBgColor(),U=F.getBgColorMode();const V=!!F.isInverse();if(V){const e=$;$=N,N=e;const t=z;z=U,U=t}let j,X,G,K=!1;switch(this._decorationService.forEachDecorationAtCell(M,t,void 0,(e=>{"top"!==e.options.layer&&K||(e.backgroundColorRGB&&(U=50331648,N=e.backgroundColorRGB.rgba>>8&16777215,j=e.backgroundColorRGB),e.foregroundColorRGB&&(z=50331648,$=e.foregroundColorRGB.rgba>>8&16777215,X=e.foregroundColorRGB),K="top"===e.options.layer)})),!K&&I&&(j=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,N=j.rgba>>8&16777215,U=50331648,K=!0,O.selectionForeground&&(z=50331648,$=O.selectionForeground.rgba>>8&16777215,X=O.selectionForeground)),K&&R.push("xterm-decoration-top"),U){case 16777216:case 33554432:G=O.ansi[N],R.push(`xterm-bg-${N}`);break;case 50331648:G=l.channels.toColor(N>>16,N>>8&255,255&N),this._addStyle(S,`background-color:#${g((N>>>0).toString(16),"0",6)}`);break;default:V?(G=O.foreground,R.push(`xterm-bg-${n.INVERTED_DEFAULT_COLOR}`)):G=O.background}switch(j||F.isDim()&&(j=l.color.multiplyOpacity(G,.5)),z){case 16777216:case 33554432:F.isBold()&&$<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&($+=8),this._applyMinimumContrast(S,G,O.ansi[$],F,j,void 0)||R.push(`xterm-fg-${$}`);break;case 50331648:const e=l.channels.toColor($>>16&255,$>>8&255,255&$);this._applyMinimumContrast(S,G,e,F,j,X)||this._addStyle(S,`color:#${g($.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(S,G,O.foreground,F,j,X)||V&&R.push(`xterm-fg-${n.INVERTED_DEFAULT_COLOR}`)}R.length&&(S.className=R.join(" "),R.length=0),Q||B||H?S.textContent=y:b++,A!==this.defaultSpacing&&(S.style.letterSpacing=`${A}px`),v.push(S),M=L}return S&&b&&(S.textContent=y),v}_applyMinimumContrast(e,t,i,s,r,n){if(1===this._optionsService.rawOptions.minimumContrastRatio||(0,d.treatGlyphAsBackgroundColor)(s.getCode()))return!1;const o=this._getContrastCache(s);let a;if(r||n||(a=o.getColor(t.rgba,i.rgba)),void 0===a){const e=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=l.color.ensureContrastRatio(r||t,n||i,e),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return!!a&&(this._addStyle(e,`color:${a.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){const i=this._selectionStart,s=this._selectionEnd;return!(!i||!s)&&(this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0])}};function g(e,t,i){for(;e.length<i;)e=t+e;return e}t.DomRendererRowFactory=p=s([r(1,c.ICharacterJoinerService),r(2,h.IOptionsService),r(3,c.ICoreBrowserService),r(4,h.ICoreService),r(5,h.IDecorationService),r(6,c.IThemeService)],p)},2550:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WidthCache=void 0,t.WidthCache=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const i=e.createElement("span");i.classList.add("xterm-char-measure-element");const s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";const r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";const n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&1===e.length&&(s=e.charCodeAt(0))<256){if(-9999!==this._flat[s])return this._flat[s];const t=this._measure(e,0);return t>0&&(this._flat[s]=t),t}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(void 0===n){let s=0;t&&(s|=1),i&&(s|=2),n=this._measure(e,s),n>0&&this._holey.set(r,n)}return n}_measure(e,t){const i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}}},2223:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;const s=i(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=s.isFirefox||s.isLegacyEdge?"bottom":"ideographic"},6171:(e,t)=>{function i(e){return 57508<=e&&e<=57558}function s(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,"__esModule",{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw new Error("value must not be falsy");return e},t.isPowerlineGlyph=i,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=s,t.allowRescaling=function(e,t,r,n){return 1===t&&r>Math.ceil(1.5*n)&&void 0!==e&&e>255&&!s(e)&&!i(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return i(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,i=0){return(e-(2*Math.round(t)-i))%(2*Math.round(t))}},6052:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSelectionRenderModel=void 0;class i{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1])return void this.clear();const r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);a>=e.rows||h<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0])}isCellSelected(e,t,i){return!!this.hasSelection&&(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new i}},456:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionModel=void 0,t.SelectionModel=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharSizeService=void 0;const n=i(2585),o=i(8460),a=i(844);let h=t.CharSizeService=class extends a.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this.register(new o.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new u(this._optionsService))}catch{this._measureStrategy=this.register(new c(e,t,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};t.CharSizeService=h=s([r(2,n.IOptionsService)],h);class l extends a.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){void 0!==e&&e>0&&void 0!==t&&t>0&&(this._result.width=e,this._result.height=t)}}class c extends l{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class u extends l{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}}},4269:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;const n=i(3734),o=i(643),a=i(511),h=i(2585);class l extends n.AttributeData{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.JoinedCellData=l;let c=t.CharacterJoinerService=class e{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new a.CellData}register(e){const t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];const t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];const i=[],s=t.translateToString(!0);let r=0,n=0,a=0,h=t.getFg(0),l=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==h||this._workCell.bg!==l){if(e-r>1){const e=this._getJoinedRanges(s,a,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}r=e,a=n,h=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||o.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-r>1){const e=this._getJoinedRanges(s,a,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}return i}_getJoinedRanges(t,i,s,r,n){const o=t.substring(i,s);let a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let t=1;t<this._characterJoiners.length;t++)try{const i=this._characterJoiners[t].handler(o);for(let t=0;t<i.length;t++)e._mergeRanges(a,i[t])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,r,n),a}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,a=e[s];if(a){for(let h=i;h<this._bufferService.cols;h++){const i=t.getWidth(h),l=t.getString(h).length||o.WHITESPACE_CELL_CHAR.length;if(0!==i){if(!r&&a[0]<=n&&(a[0]=h,r=!0),a[1]<=n){if(a[1]=h,a=e[++s],!a)break;a[0]<=n?(a[0]=h,r=!0):r=!1}n+=l}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){const r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0)}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};t.CharacterJoinerService=c=s([r(0,h.IBufferService)],c)},5114:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreBrowserService=void 0;const s=i(844),r=i(8460),n=i(3656);class o extends s.Disposable{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new a(this._window),this._onDprChange=this.register(new r.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new r.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,r.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}t.CoreBrowserService=o;class a extends s.Disposable{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this.register(new s.MutableDisposable),this._onDprChange=this.register(new r.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,s.toDisposable)((()=>this.clearListener())))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,n.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkProviderService=void 0;const s=i(844);class r extends s.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,s.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{const t=this.linkProviders.indexOf(e);-1!==t&&this.linkProviders.splice(t,1)}}}}t.LinkProviderService=r},8934:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseService=void 0;const n=i(4725),o=i(9806);let a=t.MouseService=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return(0,o.getCoords)(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){const i=(0,o.getCoordsRelativeToElement)(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};t.MouseService=a=s([r(0,n.IRenderService),r(1,n.ICharSizeService)],a)},3230:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.RenderService=void 0;const n=i(6193),o=i(4725),a=i(8460),h=i(844),l=i(7226),c=i(2585);let u=t.RenderService=class extends h.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,t,i,s,r,o,c,u){super(),this._rowCount=e,this._charSizeService=s,this._renderer=this.register(new h.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new h.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new a.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new a.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new a.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new a.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new n.RenderDebouncer(((e,t)=>this._renderRows(e,t)),c),this.register(this._renderDebouncer),this.register(c.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(o.onResize((()=>this._fullRefresh()))),this.register(o.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(i.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(r.onDecorationRegistered((()=>this._fullRefresh()))),this.register(r.onDecorationRemoved((()=>this._fullRefresh()))),this.register(i.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()}))),this.register(i.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(o.buffer.y,o.buffer.y,!0)))),this.register(u.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(c.window,t),this.register(c.onWindowChange((e=>this._registerIntersectionObserver(e,t))))}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){const i=new e.IntersectionObserver((e=>this._handleIntersectionChange(e[e.length-1])),{threshold:0});i.observe(t),this._observerDisposable.value=(0,h.toDisposable)((()=>i.disconnect()))}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){this._isPaused?this._needsFullRefresh=!0:(i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))}_renderRows(e,t){this._renderer.value&&(e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0)}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw((e=>this.refreshRows(e.start,e.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,t))):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,i){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,this._renderer.value?.handleSelectionChanged(e,t,i)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};t.RenderService=u=s([r(2,c.IOptionsService),r(3,o.ICharSizeService),r(4,c.IDecorationService),r(5,c.IBufferService),r(6,o.ICoreBrowserService),r(7,o.IThemeService)],u)},9312:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionService=void 0;const n=i(9806),o=i(9504),a=i(456),h=i(4725),l=i(8460),c=i(844),u=i(6114),d=i(4841),f=i(511),p=i(2585),g=String.fromCharCode(160),m=new RegExp(g,"g");let v=t.SelectionService=class extends c.Disposable{constructor(e,t,i,s,r,n,o,h,u){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=h,this._coreBrowserService=u,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((e=>this._handleTrim(e))),this.register(this._bufferService.buffers.onBufferActivate((e=>this._handleBufferActivate(e)))),this.enable(),this._model=new a.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,c.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t||e[0]===t[0]&&e[1]===t[1])}get selectionText(){const e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";const i=this._bufferService.buffer,s=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";const r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){const e=i.translateBufferLineToString(o,!0,r,n);s.push(e)}}else{const r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let r=e[1]+1;r<=t[1]-1;r++){const e=i.lines.get(r),t=i.translateBufferLineToString(r,!0);e?.isWrapped?s[s.length-1]+=t:s.push(t)}if(e[1]!==t[1]){const e=i.lines.get(t[1]),r=i.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?s[s.length-1]+=r:s.push(r)}}return s.map((e=>e.replace(m," "))).join(u.isWindows?"\r\n":"\n")}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),u.isLinux&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){const t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!(i&&s&&t)&&this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){const i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!(!i||!s)&&this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){const i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const s=this._getMouseBufferCoords(e);return!!s&&(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){const t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=(0,n.getCoordsRelativeToElement)(this._coreBrowserService.window,e,this._screenElement)[1];const i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return u.isMac?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&0===t.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){const t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(u.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;const t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){const e=i.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){const t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&void 0!==t[0]&&void 0!==t[1]){const e=(0,o.moveToCellSequence)(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);i?e&&t&&(this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,i)):this._oldHasSelection&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((e=>this._handleTrim(e)))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){const r=e.loadCell(s,this._workCell).getChars().length;0===this._workCell.getWidth()?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;const r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;const o=r.translateBufferLineToString(e[1],!1);let a=this._convertViewportColToCharacterIndex(n,e[0]),h=a;const l=e[0]-a;let c=0,u=0,d=0,f=0;if(" "===o.charAt(a)){for(;a>0&&" "===o.charAt(a-1);)a--;for(;h<o.length&&" "===o.charAt(h+1);)h++}else{let t=e[0],i=e[0];0===n.getWidth(t)&&(c++,t--),2===n.getWidth(i)&&(u++,i++);const s=n.getString(i).length;for(s>1&&(f+=s-1,h+=s-1);t>0&&a>0&&!this._isCharWordSeparator(n.loadCell(t-1,this._workCell));){n.loadCell(t-1,this._workCell);const e=this._workCell.getChars().length;0===this._workCell.getWidth()?(c++,t--):e>1&&(d+=e-1,a-=e-1),a--,t--}for(;i<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(i+1,this._workCell));){n.loadCell(i+1,this._workCell);const e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,i++):e>1&&(f+=e-1,h+=e-1),h++,i++}}h++;let p=a+l-c+d,g=Math.min(this._bufferService.cols,h-a+c+u-d-f);if(t||""!==o.slice(a,h).trim()){if(i&&0===p&&32!==n.getCodePoint(0)){const t=r.lines.get(e[1]-1);if(t&&n.isWrapped&&32!==t.getCodePoint(this._bufferService.cols-1)){const t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){const e=this._bufferService.cols-t.start;p-=e,g+=e}}}if(s&&p+g===this._bufferService.cols&&32!==n.getCodePoint(this._bufferService.cols-1)){const t=r.lines.get(e[1]+1);if(t?.isWrapped&&32!==t.getCodePoint(0)){const t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(g+=t.length)}}return{start:p,length:g}}}_selectWordAt(e,t){const i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){const t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){const t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(i,this._bufferService.cols)}};t.SelectionService=v=s([r(3,p.IBufferService),r(4,p.ICoreService),r(5,h.IMouseService),r(6,p.IOptionsService),r(7,h.IRenderService),r(8,h.ICoreBrowserService)],v)},4725:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ILinkProviderService=t.IThemeService=t.ICharacterJoinerService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;const s=i(8343);t.ICharSizeService=(0,s.createDecorator)("CharSizeService"),t.ICoreBrowserService=(0,s.createDecorator)("CoreBrowserService"),t.IMouseService=(0,s.createDecorator)("MouseService"),t.IRenderService=(0,s.createDecorator)("RenderService"),t.ISelectionService=(0,s.createDecorator)("SelectionService"),t.ICharacterJoinerService=(0,s.createDecorator)("CharacterJoinerService"),t.IThemeService=(0,s.createDecorator)("ThemeService"),t.ILinkProviderService=(0,s.createDecorator)("LinkProviderService")},6731:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;const n=i(7239),o=i(8055),a=i(8460),h=i(844),l=i(2585),c=o.css.toColor("#ffffff"),u=o.css.toColor("#000000"),d=o.css.toColor("#ffffff"),f=o.css.toColor("#000000"),p={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const e=[o.css.toColor("#2e3436"),o.css.toColor("#cc0000"),o.css.toColor("#4e9a06"),o.css.toColor("#c4a000"),o.css.toColor("#3465a4"),o.css.toColor("#75507b"),o.css.toColor("#06989a"),o.css.toColor("#d3d7cf"),o.css.toColor("#555753"),o.css.toColor("#ef2929"),o.css.toColor("#8ae234"),o.css.toColor("#fce94f"),o.css.toColor("#729fcf"),o.css.toColor("#ad7fa8"),o.css.toColor("#34e2e2"),o.css.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){const s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:o.channels.toCss(s,r,n),rgba:o.channels.toRgba(s,r,n)})}for(let t=0;t<24;t++){const i=8+10*t;e.push({css:o.channels.toCss(i,i,i),rgba:o.channels.toRgba(i,i,i)})}return e})());let g=t.ThemeService=class extends h.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new n.ColorContrastCache,this._halfContrastCache=new n.ColorContrastCache,this._onChangeColors=this.register(new a.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:c,background:u,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:p,selectionBackgroundOpaque:o.color.blend(u,p),selectionInactiveBackgroundTransparent:p,selectionInactiveBackgroundOpaque:o.color.blend(u,p),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(e={}){const i=this._colors;if(i.foreground=m(e.foreground,c),i.background=m(e.background,u),i.cursor=m(e.cursor,d),i.cursorAccent=m(e.cursorAccent,f),i.selectionBackgroundTransparent=m(e.selectionBackground,p),i.selectionBackgroundOpaque=o.color.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=m(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=o.color.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?m(e.selectionForeground,o.NULL_COLOR):void 0,i.selectionForeground===o.NULL_COLOR&&(i.selectionForeground=void 0),o.color.isOpaque(i.selectionBackgroundTransparent)){const e=.3;i.selectionBackgroundTransparent=o.color.opacity(i.selectionBackgroundTransparent,e)}if(o.color.isOpaque(i.selectionInactiveBackgroundTransparent)){const e=.3;i.selectionInactiveBackgroundTransparent=o.color.opacity(i.selectionInactiveBackgroundTransparent,e)}if(i.ansi=t.DEFAULT_ANSI_COLORS.slice(),i.ansi[0]=m(e.black,t.DEFAULT_ANSI_COLORS[0]),i.ansi[1]=m(e.red,t.DEFAULT_ANSI_COLORS[1]),i.ansi[2]=m(e.green,t.DEFAULT_ANSI_COLORS[2]),i.ansi[3]=m(e.yellow,t.DEFAULT_ANSI_COLORS[3]),i.ansi[4]=m(e.blue,t.DEFAULT_ANSI_COLORS[4]),i.ansi[5]=m(e.magenta,t.DEFAULT_ANSI_COLORS[5]),i.ansi[6]=m(e.cyan,t.DEFAULT_ANSI_COLORS[6]),i.ansi[7]=m(e.white,t.DEFAULT_ANSI_COLORS[7]),i.ansi[8]=m(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),i.ansi[9]=m(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),i.ansi[10]=m(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),i.ansi[11]=m(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),i.ansi[12]=m(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),i.ansi[13]=m(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),i.ansi[14]=m(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),i.ansi[15]=m(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){const s=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)i.ansi[r+16]=m(e.extendedAnsi[r],t.DEFAULT_ANSI_COLORS[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0!==e)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function m(e,t){if(void 0!==e)try{return o.css.toColor(e)}catch{}return t}t.ThemeService=g=s([r(0,l.IOptionsService)],g)},6349:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;const s=i(8460),r=i(844);class n extends r.Disposable{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this.register(new s.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new s.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new s.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;const t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+i.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<i.length;t++)this._array[this._getCyclicIndex(e+t)]=i[t];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){const e=this._length+i.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let s=t-1;s>=0;s--)this.set(e+s+i,this.get(e+s));const s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}}t.CircularList=n},1439:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0,t.clone=function e(t,i=5){if("object"!=typeof t)return t;const s=Array.isArray(t)?[]:{};for(const r in t)s[r]=i<=1?t[r]:t[r]&&e(t[r],i-1);return s}},8055:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let i=0,s=0,r=0,n=0;var o,a,h,l,c;function u(e){const t=e.toString(16);return t.length<2?"0"+t:t}function d(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:"#00000000",rgba:0},function(e){e.toCss=function(e,t,i,s){return void 0!==s?`#${u(e)}${u(t)}${u(i)}${u(s)}`:`#${u(e)}${u(t)}${u(i)}`},e.toRgba=function(e,t,i,s=255){return(e<<24|t<<16|i<<8|s)>>>0},e.toColor=function(t,i,s,r){return{css:e.toCss(t,i,s,r),rgba:e.toRgba(t,i,s,r)}}}(o||(t.channels=o={})),function(e){function t(e,t){return n=Math.round(255*t),[i,s,r]=c.toChannels(e.rgba),{css:o.toCss(i,s,r,n),rgba:o.toRgba(i,s,r,n)}}e.blend=function(e,t){if(n=(255&t.rgba)/255,1===n)return{css:t.css,rgba:t.rgba};const a=t.rgba>>24&255,h=t.rgba>>16&255,l=t.rgba>>8&255,c=e.rgba>>24&255,u=e.rgba>>16&255,d=e.rgba>>8&255;return i=c+Math.round((a-c)*n),s=u+Math.round((h-u)*n),r=d+Math.round((l-d)*n),{css:o.toCss(i,s,r),rgba:o.toRgba(i,s,r)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){const s=c.ensureContrastRatio(e.rgba,t.rgba,i);if(s)return o.toColor(s>>24&255,s>>16&255,s>>8&255)},e.opaque=function(e){const t=(255|e.rgba)>>>0;return[i,s,r]=c.toChannels(t),{css:o.toCss(i,s,r),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return n=255&e.rgba,t(e,n*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(a||(t.color=a={})),function(e){let t,a;try{const e=document.createElement("canvas");e.width=1,e.height=1;const i=e.getContext("2d",{willReadFrequently:!0});i&&(t=i,t.globalCompositeOperation="copy",a=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return i=parseInt(e.slice(1,2).repeat(2),16),s=parseInt(e.slice(2,3).repeat(2),16),r=parseInt(e.slice(3,4).repeat(2),16),o.toColor(i,s,r);case 5:return i=parseInt(e.slice(1,2).repeat(2),16),s=parseInt(e.slice(2,3).repeat(2),16),r=parseInt(e.slice(3,4).repeat(2),16),n=parseInt(e.slice(4,5).repeat(2),16),o.toColor(i,s,r,n);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}const h=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(h)return i=parseInt(h[1]),s=parseInt(h[2]),r=parseInt(h[3]),n=Math.round(255*(void 0===h[5]?1:parseFloat(h[5]))),o.toColor(i,s,r,n);if(!t||!a)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=a,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[i,s,r,n]=t.getImageData(0,0,1,1).data,255!==n)throw new Error("css.toColor: Unsupported css format");return{rgba:o.toRgba(i,s,r,n),css:e}}}(h||(t.css=h={})),function(e){function t(e,t,i){const s=e/255,r=t/255,n=i/255;return.2126*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(l||(t.rgb=l={})),function(e){function t(e,t,i){const s=e>>24&255,r=e>>16&255,n=e>>8&255;let o=t>>24&255,a=t>>16&255,h=t>>8&255,c=d(l.relativeLuminance2(o,a,h),l.relativeLuminance2(s,r,n));for(;c<i&&(o>0||a>0||h>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),h-=Math.max(0,Math.ceil(.1*h)),c=d(l.relativeLuminance2(o,a,h),l.relativeLuminance2(s,r,n));return(o<<24|a<<16|h<<8|255)>>>0}function a(e,t,i){const s=e>>24&255,r=e>>16&255,n=e>>8&255;let o=t>>24&255,a=t>>16&255,h=t>>8&255,c=d(l.relativeLuminance2(o,a,h),l.relativeLuminance2(s,r,n));for(;c<i&&(o<255||a<255||h<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),h=Math.min(255,h+Math.ceil(.1*(255-h))),c=d(l.relativeLuminance2(o,a,h),l.relativeLuminance2(s,r,n));return(o<<24|a<<16|h<<8|255)>>>0}e.blend=function(e,t){if(n=(255&t)/255,1===n)return t;const a=t>>24&255,h=t>>16&255,l=t>>8&255,c=e>>24&255,u=e>>16&255,d=e>>8&255;return i=c+Math.round((a-c)*n),s=u+Math.round((h-u)*n),r=d+Math.round((l-d)*n),o.toRgba(i,s,r)},e.ensureContrastRatio=function(e,i,s){const r=l.relativeLuminance(e>>8),n=l.relativeLuminance(i>>8);if(d(r,n)<s){if(n<r){const n=t(e,i,s),o=d(r,l.relativeLuminance(n>>8));if(o<s){const t=a(e,i,s);return o>d(r,l.relativeLuminance(t>>8))?n:t}return n}const o=a(e,i,s),h=d(r,l.relativeLuminance(o>>8));if(h<s){const n=t(e,i,s);return h>d(r,l.relativeLuminance(n>>8))?o:n}return o}},e.reduceLuminance=t,e.increaseLuminance=a,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(c||(t.rgba=c={})),t.toPaddedHex=u,t.contrastRatio=d},8969:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;const s=i(844),r=i(2585),n=i(4348),o=i(7866),a=i(744),h=i(7302),l=i(6975),c=i(8460),u=i(1753),d=i(1480),f=i(7994),p=i(9282),g=i(5435),m=i(5981),v=i(2660);let _=!1;class O extends s.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new c.EventEmitter),this._onScroll.event((e=>{this._onScrollApi?.fire(e.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(const t in e)this.optionsService.options[t]=e[t]}constructor(e){super(),this._windowsWrappingHeuristics=this.register(new s.MutableDisposable),this._onBinary=this.register(new c.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new c.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new c.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new c.EventEmitter),this._instantiationService=new n.InstantiationService,this.optionsService=this.register(new h.OptionsService(e)),this._instantiationService.setService(r.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(a.BufferService)),this._instantiationService.setService(r.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(o.LogService)),this._instantiationService.setService(r.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(r.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(u.CoreMouseService)),this._instantiationService.setService(r.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(r.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(r.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(v.OscLinkService),this._instantiationService.setService(r.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new g.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,c.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,c.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,c.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,c.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new m.WriteBuffer(((e,t)=>this._inputHandler.parse(e,t)))),this.register((0,c.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=r.LogLevelEnum.WARN&&!_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,a.MINIMUM_COLS),t=Math.max(t,a.MINIMUM_ROWS),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t,i){this._bufferService.scrollLines(e,t,i)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){const t=e-this._bufferService.buffer.ydisp;0!==t&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1;const t=this.optionsService.rawOptions.windowsPty;t&&void 0!==t.buildNumber&&void 0!==t.buildNumber?e=!!("conpty"===t.backend&&t.buildNumber<21376):this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const e=[];e.push(this.onLineFeed(p.updateWindowsModeWrappedState.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},(()=>((0,p.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,s.toDisposable)((()=>{for(const t of e)t.dispose()}))}}}t.CoreTerminal=O},8460:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed)for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}})),this._event}fire(e,t){const i=[];for(let e=0;e<this._listeners.length;e++)i.push(this._listeners[e]);for(let s=0;s<i.length;s++)i[s].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},5435:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0;const n=i(2584),o=i(7116),a=i(2015),h=i(844),l=i(482),c=i(8437),u=i(8460),d=i(643),f=i(511),p=i(3734),g=i(2585),m=i(1480),v=i(6242),_=i(6351),O=i(5941),S={"(":0,")":1,"*":2,"+":3,"-":1,".":2},w=131072;function b(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var y;!function(e){e[e.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",e[e.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"}(y||(t.WindowsOptionsReportType=y={}));let D=0;class C extends h.Disposable{getAttrData(){return this._curAttrData}constructor(e,t,i,s,r,h,d,p,g=new a.EscapeSequenceParser){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=h,this._coreMouseService=d,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=c.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=c.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new u.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new u.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new u.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new u.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new u.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new u.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new u.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new u.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new u.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new u.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new u.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new k(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._parser.setCsiHandlerFallback(((e,t)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:t.toArray()})})),this._parser.setEscHandlerFallback((e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})})),this._parser.setExecuteHandlerFallback((e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})})),this._parser.setOscHandlerFallback(((e,t,i)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:i})})),this._parser.setDcsHandlerFallback(((e,t,i)=>{"HOOK"===t&&(i=i.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:t,payload:i})})),this._parser.setPrintHandler(((e,t,i)=>this.print(e,t,i))),this._parser.registerCsiHandler({final:"@"},(e=>this.insertChars(e))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(e=>this.scrollLeft(e))),this._parser.registerCsiHandler({final:"A"},(e=>this.cursorUp(e))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(e=>this.scrollRight(e))),this._parser.registerCsiHandler({final:"B"},(e=>this.cursorDown(e))),this._parser.registerCsiHandler({final:"C"},(e=>this.cursorForward(e))),this._parser.registerCsiHandler({final:"D"},(e=>this.cursorBackward(e))),this._parser.registerCsiHandler({final:"E"},(e=>this.cursorNextLine(e))),this._parser.registerCsiHandler({final:"F"},(e=>this.cursorPrecedingLine(e))),this._parser.registerCsiHandler({final:"G"},(e=>this.cursorCharAbsolute(e))),this._parser.registerCsiHandler({final:"H"},(e=>this.cursorPosition(e))),this._parser.registerCsiHandler({final:"I"},(e=>this.cursorForwardTab(e))),this._parser.registerCsiHandler({final:"J"},(e=>this.eraseInDisplay(e,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(e=>this.eraseInDisplay(e,!0))),this._parser.registerCsiHandler({final:"K"},(e=>this.eraseInLine(e,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(e=>this.eraseInLine(e,!0))),this._parser.registerCsiHandler({final:"L"},(e=>this.insertLines(e))),this._parser.registerCsiHandler({final:"M"},(e=>this.deleteLines(e))),this._parser.registerCsiHandler({final:"P"},(e=>this.deleteChars(e))),this._parser.registerCsiHandler({final:"S"},(e=>this.scrollUp(e))),this._parser.registerCsiHandler({final:"T"},(e=>this.scrollDown(e))),this._parser.registerCsiHandler({final:"X"},(e=>this.eraseChars(e))),this._parser.registerCsiHandler({final:"Z"},(e=>this.cursorBackwardTab(e))),this._parser.registerCsiHandler({final:"`"},(e=>this.charPosAbsolute(e))),this._parser.registerCsiHandler({final:"a"},(e=>this.hPositionRelative(e))),this._parser.registerCsiHandler({final:"b"},(e=>this.repeatPrecedingCharacter(e))),this._parser.registerCsiHandler({final:"c"},(e=>this.sendDeviceAttributesPrimary(e))),this._parser.registerCsiHandler({prefix:">",final:"c"},(e=>this.sendDeviceAttributesSecondary(e))),this._parser.registerCsiHandler({final:"d"},(e=>this.linePosAbsolute(e))),this._parser.registerCsiHandler({final:"e"},(e=>this.vPositionRelative(e))),this._parser.registerCsiHandler({final:"f"},(e=>this.hVPosition(e))),this._parser.registerCsiHandler({final:"g"},(e=>this.tabClear(e))),this._parser.registerCsiHandler({final:"h"},(e=>this.setMode(e))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(e=>this.setModePrivate(e))),this._parser.registerCsiHandler({final:"l"},(e=>this.resetMode(e))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(e=>this.resetModePrivate(e))),this._parser.registerCsiHandler({final:"m"},(e=>this.charAttributes(e))),this._parser.registerCsiHandler({final:"n"},(e=>this.deviceStatus(e))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(e=>this.deviceStatusPrivate(e))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(e=>this.softReset(e))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(e=>this.setCursorStyle(e))),this._parser.registerCsiHandler({final:"r"},(e=>this.setScrollRegion(e))),this._parser.registerCsiHandler({final:"s"},(e=>this.saveCursor(e))),this._parser.registerCsiHandler({final:"t"},(e=>this.windowOptions(e))),this._parser.registerCsiHandler({final:"u"},(e=>this.restoreCursor(e))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(e=>this.insertColumns(e))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(e=>this.deleteColumns(e))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(e=>this.selectProtected(e))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(e=>this.requestMode(e,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(e=>this.requestMode(e,!1))),this._parser.setExecuteHandler(n.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(n.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(n.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(n.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(n.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(n.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(n.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(n.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(n.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(n.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new v.OscHandler((e=>(this.setTitle(e),this.setIconName(e),!0)))),this._parser.registerOscHandler(1,new v.OscHandler((e=>this.setIconName(e)))),this._parser.registerOscHandler(2,new v.OscHandler((e=>this.setTitle(e)))),this._parser.registerOscHandler(4,new v.OscHandler((e=>this.setOrReportIndexedColor(e)))),this._parser.registerOscHandler(8,new v.OscHandler((e=>this.setHyperlink(e)))),this._parser.registerOscHandler(10,new v.OscHandler((e=>this.setOrReportFgColor(e)))),this._parser.registerOscHandler(11,new v.OscHandler((e=>this.setOrReportBgColor(e)))),this._parser.registerOscHandler(12,new v.OscHandler((e=>this.setOrReportCursorColor(e)))),this._parser.registerOscHandler(104,new v.OscHandler((e=>this.restoreIndexedColor(e)))),this._parser.registerOscHandler(110,new v.OscHandler((e=>this.restoreFgColor(e)))),this._parser.registerOscHandler(111,new v.OscHandler((e=>this.restoreBgColor(e)))),this._parser.registerOscHandler(112,new v.OscHandler((e=>this.restoreCursorColor(e)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const e in o.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:e},(()=>this.selectCharset("("+e))),this._parser.registerEscHandler({intermediates:")",final:e},(()=>this.selectCharset(")"+e))),this._parser.registerEscHandler({intermediates:"*",final:e},(()=>this.selectCharset("*"+e))),this._parser.registerEscHandler({intermediates:"+",final:e},(()=>this.selectCharset("+"+e))),this._parser.registerEscHandler({intermediates:"-",final:e},(()=>this.selectCharset("-"+e))),this._parser.registerEscHandler({intermediates:".",final:e},(()=>this.selectCharset("."+e))),this._parser.registerEscHandler({intermediates:"/",final:e},(()=>this.selectCharset("/"+e)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((e=>(this._logService.error("Parsing error: ",e),e))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new _.DcsHandler(((e,t)=>this.requestStatusString(e,t))))}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=g.LogLevelEnum.WARN&&Promise.race([e,new Promise(((e,t)=>setTimeout((()=>t("#SLOW_TIMEOUT")),5e3)))]).catch((e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0;const o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>w&&(n=this._parseStack.position+w)}if(this._logService.logLevel<=g.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+("string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,(e=>String.fromCharCode(e))).join("")}"`),"string"==typeof e?e.split("").map((e=>e.charCodeAt(0))):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<w&&(this._parseBuffer=new Uint32Array(Math.min(e.length,w))),o||this._dirtyRowTracker.clearRange(),e.length>w)for(let t=n;t<e.length;t+=w){const n=t+w<e.length?t+w:e.length,o="string"==typeof e?this._stringDecoder.decode(e.substring(t,n),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,n),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,o))return this._preserveStack(s,r,o,t),this._logSlowResolvingAsync(i),i}else if(!o){const t="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,t))return this._preserveStack(s,r,t,0),this._logSlowResolvingAsync(i),i}this._activeBuffer.x===s&&this._activeBuffer.y===r||this._onCursorMove.fire();const a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(h,this._bufferService.rows-1),Math.min(a,this._bufferService.rows-1))}print(e,t,i){let s,r;const n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,f=this._curAttrData;let p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&2===p.getWidth(this._activeBuffer.x-1)&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,f);let g=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&n){const e=n[String.fromCharCode(s)];e&&(s=e.charCodeAt(0))}const t=this._unicodeService.charProperties(s,g);r=m.UnicodeService.extractWidth(t);const i=m.UnicodeService.extractShouldJoin(t),_=i?m.UnicodeService.extractWidth(g):0;if(g=t,o&&this._onA11yChar.fire((0,l.stringFromCodePoint)(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-_>a)if(h){const e=p;let t=this._activeBuffer.x-_;for(this._activeBuffer.x=_,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&p instanceof c.BufferLine&&p.copyCellsFrom(e,t,0,_,!1);t<a;)e.setCellFromCodepoint(t++,0,1,f)}else if(this._activeBuffer.x=a-1,2===r)continue;if(i&&this._activeBuffer.x){const e=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-e,s,r);for(let e=r-_;--e>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f)}else if(u&&(p.insertCells(this._activeBuffer.x,r-_,this._activeBuffer.getNullCell(f)),2===p.getWidth(a-1)&&p.setCellFromCodepoint(a-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,f)),p.setCellFromCodepoint(this._activeBuffer.x++,s,r,f),r>0)for(;--r;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f)}this._parser.precedingJoinState=g,this._activeBuffer.x<a&&i-t>0&&0===p.getWidth(this._activeBuffer.x)&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,f),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(e=>!b(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new _.DcsHandler(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new v.OscHandler(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){const t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){const t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){const t=e.params[0];return 0===t?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===t&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){const t=e.params[0];return 1===t&&(this._curAttrData.bg|=536870912),2!==t&&0!==t||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){const n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){const i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){let i;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 3:const e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const i=this._activeBuffer.ybase+this._activeBuffer.y;let s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();const t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();const t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(c.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){const i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){const i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){const i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){const i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();const t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){const t=this._parser.precedingJoinState;if(!t)return!0;const i=e.params[0]||1,s=m.UnicodeService.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i);let a=0;for(let e=0;e<n.length;){const t=n.codePointAt(e)||0;o[a++]=t,e+=t>65535?2:1}let h=a;for(let e=1;e<i;++e)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(n.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(n.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(n.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(n.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(n.C0.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[t]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(e,t){const i=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:r}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:c}=a,u=this._optionsService.rawOptions,d=e=>e?1:2,f=e.params[0];return p=f,g=t?2===f?4:4===f?d(o.modes.insertMode):12===f?3:20===f?d(u.convertEol):0:1===f?d(i.applicationCursorKeys):3===f?u.windowOptions.setWinLines?80===h?2:132===h?1:0:0:6===f?d(i.origin):7===f?d(i.wraparound):8===f?3:9===f?d("X10"===s):12===f?d(u.cursorBlink):25===f?d(!o.isCursorHidden):45===f?d(i.reverseWraparound):66===f?d(i.applicationKeypad):67===f?4:1e3===f?d("VT200"===s):1002===f?d("DRAG"===s):1003===f?d("ANY"===s):1004===f?d(i.sendFocus):1005===f?4:1006===f?d("SGR"===r):1015===f?4:1016===f?d("SGR_PIXELS"===r):1048===f?1:47===f||1047===f||1049===f?d(l===c):2004===f?d(i.bracketedPasteMode):0,o.triggerDataEvent(`${n.C0.ESC}[${t?"":"?"}${p};${g}$y`),!0;var p,g}_updateAttrColor(e,t,i,s,r){return 2===t?(e|=50331648,e&=-16777216,e|=p.AttributeData.fromColorRGB([i,s,r])):5===t&&(e&=-50331904,e|=33554432|255&i),e}_extractColor(e,t,i){const s=[0,0,-1,0,0,0];let r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){const i=e.getSubParams(t+n);let o=0;do{5===s[1]&&(r=1),s[n+o+1+r]=i[o]}while(++o<i.length&&o+n+1+r<s.length);break}if(5===s[1]&&n+r>=2||2===s[1]&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let e=2;e<s.length;++e)-1===s[e]&&(s[e]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,0===e&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=c.DEFAULT_ATTR_DATA.fg,e.bg=c.DEFAULT_ATTR_DATA.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;const t=e.length;let i;const s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777224|i-90):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777224|i-100):0===i?this._processSGR0(s):1===i?s.fg|=134217728:3===i?s.bg|=67108864:4===i?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):5===i?s.fg|=536870912:7===i?s.fg|=67108864:8===i?s.fg|=1073741824:9===i?s.fg|=2147483648:2===i?s.bg|=134217728:21===i?this._processUnderline(2,s):22===i?(s.fg&=-134217729,s.bg&=-134217729):23===i?s.bg&=-67108865:24===i?(s.fg&=-268435457,this._processUnderline(0,s)):25===i?s.fg&=-536870913:27===i?s.fg&=-67108865:28===i?s.fg&=-1073741825:29===i?s.fg&=2147483647:39===i?(s.fg&=-67108864,s.fg|=16777215&c.DEFAULT_ATTR_DATA.fg):49===i?(s.bg&=-67108864,s.bg|=16777215&c.DEFAULT_ATTR_DATA.bg):38===i||48===i||58===i?r+=this._extractColor(e,r,s):53===i?s.bg|=1073741824:55===i?s.bg&=-1073741825:59===i?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):100===i?(s.fg&=-67108864,s.fg|=16777215&c.DEFAULT_ATTR_DATA.fg,s.bg&=-67108864,s.bg|=16777215&c.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${n.C0.ESC}[0n`);break;case 6:const e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n.C0.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){const e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${n.C0.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=c.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){const t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const i=t%2==1;return this._optionsService.options.cursorBlink=i,!0}setScrollRegion(e){const t=e.params[0]||1;let i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||0===i)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!b(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;const t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==t&&this._onRequestWindowsOptionsReport.fire(y.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(y.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${n.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:0!==t&&2!==t||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),0!==t&&1!==t||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:0!==t&&2!==t||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),0!==t&&1!==t||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){const t=[],i=e.split(";");for(;i.length>1;){const e=i.shift(),s=i.shift();if(/^\d+$/.exec(e)){const i=parseInt(e);if(x(i))if("?"===s)t.push({type:0,index:i});else{const e=(0,O.parseColor)(s);e&&t.push({type:1,index:i,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){const t=e.split(";");return!(t.length<2)&&(t[1]?this._createHyperlink(t[0],t[1]):!t[0]&&this._finishHyperlink())}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();const i=e.split(":");let s;const r=i.findIndex((e=>e.startsWith("id=")));return-1!==r&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){const i=e.split(";");for(let e=0;e<i.length&&!(t>=this._specialColors.length);++e,++t)if("?"===i[e])this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{const s=(0,O.parseColor)(i[e]);s&&this._onColor.fire([{type:1,index:this._specialColors[t],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;const t=[],i=e.split(";");for(let e=0;e<i.length;++e)if(/^\d+$/.exec(i[e])){const s=parseInt(i[e]);x(s)&&t.push({type:2,index:s})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),!0}selectCharset(e){return 2!==e.length?(this.selectDefaultCharset(),!0):("/"===e[0]||this._charsetService.setgCharset(S[e[0]],o.CHARSETS[e[1]]||o.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=c.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=c.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){const e=new f.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){const i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){const i=this._bufferService.buffer,s=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${n.C0.ESC}${e}${n.C0.ESC}\\`),!0))('"q'===e?`P1$r${this._curAttrData.isProtected()?1:0}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}}t.InputHandler=C;let k=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(D=e,e=t,t=D),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function x(e){return 0<=e&&e<256}k=s([r(0,g.IBufferService)],k)},844:(e,t)=>{function i(e){for(const t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){const t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=i,t.getDisposeArrayDisposable=function(e){return{dispose:()=>i(e)}}},1505:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=i,t.FourKeyMap=class{constructor(){this._data=new i}set(e,t,s,r,n){this._data.get(e,t)||this._data.set(e,t,new i),this._data.get(e,t).set(s,r,n)}get(e,t,i,s){return this._data.get(e,t)?.get(i,s)}clear(){this._data.clear()}}},6114:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.getSafariVersion=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.isNode="undefined"!=typeof process&&"title"in process;const i=t.isNode?"node":navigator.userAgent,s=t.isNode?"node":navigator.platform;t.isFirefox=i.includes("Firefox"),t.isLegacyEdge=i.includes("Edge"),t.isSafari=/^((?!chrome|android).)*safari/i.test(i),t.getSafariVersion=function(){if(!t.isSafari)return 0;const e=i.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])},t.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(s),t.isIpad="iPad"===s,t.isIphone="iPhone"===s,t.isWindows=["Windows","Win16","Win32","WinCE"].includes(s),t.isLinux=s.indexOf("Linux")>=0,t.isChromeOS=/\bCrOS\b/.test(i)},6106:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SortedList=void 0;let i=0;t.SortedList=class{constructor(e){this._getKey=e,this._array=[]}clear(){this._array.length=0}insert(e){0!==this._array.length?(i=this._search(this._getKey(e)),this._array.splice(i,0,e)):this._array.push(e)}delete(e){if(0===this._array.length)return!1;const t=this._getKey(e);if(void 0===t)return!1;if(i=this._search(t),-1===i)return!1;if(this._getKey(this._array[i])!==t)return!1;do{if(this._array[i]===e)return this._array.splice(i,1),!0}while(++i<this._array.length&&this._getKey(this._array[i])===t);return!1}*getKeyIterator(e){if(0!==this._array.length&&(i=this._search(e),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===e))do{yield this._array[i]}while(++i<this._array.length&&this._getKey(this._array[i])===e)}forEachByKey(e,t){if(0!==this._array.length&&(i=this._search(e),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===e))do{t(this._array[i])}while(++i<this._array.length&&this._getKey(this._array[i])===e)}values(){return[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1;const r=this._getKey(this._array[s]);if(r>e)i=s-1;else{if(!(r<e)){for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}t=s+1}}return t}}},7226:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;const s=i(6114);class r{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=Date.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,Date.now()-t),i=Math.max(t,i),r=e.timeRemaining(),1.5*i>r)return s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),void this._start();s=r}this.clear()}}class n extends r{_requestCallback(e){return setTimeout((()=>e(this._createDeadline(16))))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){const t=Date.now()+e;return{timeRemaining:()=>Math.max(0,t-Date.now())}}}t.PriorityTaskQueue=n,t.IdleTaskQueue=!s.isNode&&"requestIdleCallback"in window?class extends r{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:n,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}}},9282:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;const s=i(643);t.updateWindowsModeWrappedState=function(e){const t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1),i=t?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&i&&(r.isWrapped=i[s.CHAR_DATA_CODE_INDEX]!==s.NULL_CELL_CODE&&i[s.CHAR_DATA_CODE_INDEX]!==s.WHITESPACE_CELL_CODE)}},3734:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new s}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){const e=new i;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t.AttributeData=i;class s{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){const e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}clone(){return new s(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}}t.ExtendedAttrs=s},9092:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;const s=i(6349),r=i(7226),n=i(3734),o=i(8437),a=i(4634),h=i(511),l=i(643),c=i(4863),u=i(7116);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=o.DEFAULT_ATTR_DATA.clone(),this.savedCharset=u.DEFAULT_CHARSET,this.markers=[],this._nullCell=h.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=h.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new r.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new s.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new n.ExtendedAttrs),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new n.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,t){return new o.BufferLine(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;const i=e+this._optionsService.rawOptions.scrollback;return i>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:i}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=o.DEFAULT_ATTR_DATA);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new s.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){const i=this.getNullCell(o.DEFAULT_ATTR_DATA);let s=0;const r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)s+=+this.lines.get(t).resize(e,i);let n=0;if(this._rows<t)for(let s=this._rows;s<t;s++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new o.BufferLine(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new o.BufferLine(e,i)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){const e=this.lines.length-r;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)s+=+this.lines.get(t).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){const e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){const i=(0,a.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(o.DEFAULT_ATTR_DATA));if(i.length>0){const s=(0,a.reflowLargerCreateNewLayout)(this.lines,i);(0,a.reflowLargerApplyNewLayout)(this.lines,s.layout),this._reflowLargerAdjustViewport(e,t,s.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){const s=this.getNullCell(o.DEFAULT_ATTR_DATA);let r=i;for(;r-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new o.BufferLine(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){const i=this.getNullCell(o.DEFAULT_ATTR_DATA),s=[];let r=0;for(let n=this.lines.length-1;n>=0;n--){let h=this.lines.get(n);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;const l=[h];for(;h.isWrapped&&n>0;)h=this.lines.get(--n),l.unshift(h);const c=this.ybase+this.y;if(c>=n&&c<n+l.length)continue;const u=l[l.length-1].getTrimmedLength(),d=(0,a.reflowSmallerGetNewLineLengths)(l,this._cols,e),f=d.length-l.length;let p;p=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+f):Math.max(0,this.lines.length-this.lines.maxLength+f);const g=[];for(let e=0;e<f;e++){const e=this.getBlankLine(o.DEFAULT_ATTR_DATA,!0);g.push(e)}g.length>0&&(s.push({start:n+l.length+r,newLines:g}),r+=g.length),l.push(...g);let m=d.length-1,v=d[m];0===v&&(m--,v=d[m]);let _=l.length-f-1,O=u;for(;_>=0;){const e=Math.min(O,v);if(void 0===l[m])break;if(l[m].copyCellsFrom(l[_],O-e,v-e,e,!0),v-=e,0===v&&(m--,v=d[m]),O-=e,0===O){_--;const e=Math.max(_,0);O=(0,a.getWrappedLineTrimmedLength)(l,e,this._cols)}}for(let t=0;t<l.length;t++)d[t]<e&&l[t].setCell(d[t],i);let S=f-p;for(;S-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f,this.ybase+t-1)}if(s.length>0){const e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));const i=this.lines.length;let n=i-1,o=0,a=s[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let h=0;for(let l=Math.min(this.lines.maxLength-1,i+r-1);l>=0;l--)if(a&&a.start>n+h){for(let e=a.newLines.length-1;e>=0;e--)this.lines.set(l--,a.newLines[e]);l++,e.push({index:n+1,amount:a.newLines.length}),h+=a.newLines.length,a=s[++o]}else this.lines.set(l,t[n--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;const c=Math.max(0,i+r-this.lines.maxLength);c>0&&this.lines.onTrimEmitter.fire(c)}}translateBufferLineToString(e,t,i=0,s){const r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose(),this.markers.splice(e--,1);this._isClearing=!1}addMarker(e){const t=new c.Marker(e);return this.markers.push(t),t.register(this.lines.onTrim((e=>{t.line-=e,t.line<0&&t.dispose()}))),t.register(this.lines.onInsert((e=>{t.line>=e.index&&(t.line+=e.amount)}))),t.register(this.lines.onDelete((e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)}))),t.register(t.onDispose((()=>this._removeMarker(t)))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}}},8437:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;const s=i(3734),r=i(511),n=i(643),o=i(482);t.DEFAULT_ATTR_DATA=Object.freeze(new s.AttributeData);let a=0;class h{constructor(e,t,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);const s=t||r.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]);for(let t=0;t<e;++t)this.setCell(t,s);this.length=e}get(e){const t=this._data[3*e+0],i=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:i?(0,o.stringFromCodePoint)(i):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,t){this._data[3*e+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){const t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){const t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?(0,o.stringFromCodePoint)(2097151&t):""}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return a=3*e,t.content=this._data[a+0],t.fg=this._data[a+1],t.bg=this._data[a+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,i,s){268435456&s.bg&&(this._extendedAttrs[e]=s.extended),this._data[3*e+0]=t|i<<22,this._data[3*e+1]=s.fg,this._data[3*e+2]=s.bg}addCodepointToCell(e,t,i){let s=this._data[3*e+0];2097152&s?this._combined[e]+=(0,o.stringFromCodePoint)(t):2097151&s?(this._combined[e]=(0,o.stringFromCodePoint)(2097151&s)+(0,o.stringFromCodePoint)(t),s&=-2097152,s|=2097152):s=t|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[3*e+0]=s}insertCells(e,t,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length-e){const s=new r.CellData;for(let i=this.length-e-t-1;i>=0;--i)this.setCell(e+t+i,this.loadCell(e+i,s));for(let s=0;s<t;++s)this.setCell(e+s,i)}else for(let t=e;t<this.length;++t)this.setCell(t,i);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,t,i){if(e%=this.length,t<this.length-e){const s=new r.CellData;for(let i=0;i<this.length-e-t;++i)this.setCell(e+i,this.loadCell(e+t+i,s));for(let e=this.length-t;e<this.length;++e)this.setCell(e,i)}else for(let t=e;t<this.length;++t)this.setCell(t,i);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,t,i,s=!1){if(s)for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;else for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.setCell(e++,i)}resize(e,t){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const i=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*i)this._data=new Uint32Array(this._data.buffer,0,i);else{const e=new Uint32Array(i);e.set(this._data),this._data=e}for(let i=this.length;i<e;++i)this.setCell(i,t)}else{this._data=this._data.subarray(0,i);const t=Object.keys(this._combined);for(let i=0;i<t.length;i++){const s=parseInt(t[i],10);s>=e&&delete this._combined[s]}const s=Object.keys(this._extendedAttrs);for(let t=0;t<s.length;t++){const i=parseInt(s[t],10);i>=e&&delete this._extendedAttrs[i]}}return this.length=e,4*i*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(const t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(const t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){const e=new h(0);e._data=new Uint32Array(this._data),e.length=this.length;for(const t in this._combined)e._combined[t]=this._combined[t];for(const t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,t,i,s,r){const n=e._data;if(r)for(let r=s-1;r>=0;r--){for(let e=0;e<3;e++)this._data[3*(i+r)+e]=n[3*(t+r)+e];268435456&n[3*(t+r)+2]&&(this._extendedAttrs[i+r]=e._extendedAttrs[t+r])}else for(let r=0;r<s;r++){for(let e=0;e<3;e++)this._data[3*(i+r)+e]=n[3*(t+r)+e];268435456&n[3*(t+r)+2]&&(this._extendedAttrs[i+r]=e._extendedAttrs[t+r])}const o=Object.keys(e._combined);for(let s=0;s<o.length;s++){const r=parseInt(o[s],10);r>=t&&(this._combined[r-t+i]=e._combined[r])}}translateToString(e,t,i,s){t=t??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let r="";for(;t<i;){const e=this._data[3*t+0],i=2097151&e,a=2097152&e?this._combined[t]:i?(0,o.stringFromCodePoint)(i):n.WHITESPACE_CELL_CHAR;if(r+=a,s)for(let e=0;e<a.length;++e)s.push(t);t+=e>>22||1}return s&&s.push(t),r}}t.BufferLine=h},4841:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRangeLength=void 0,t.getRangeLength=function(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}},4634:(e,t)=>{function i(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();const s=!e[t].hasContent(i-1)&&1===e[t].getWidth(i-1),r=2===e[t+1].getWidth(0);return s&&r?i-1:i}Object.defineProperty(t,"__esModule",{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,s,r,n){const o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;const c=[e.get(a)];for(;h<e.length&&l.isWrapped;)c.push(l),l=e.get(++h);if(r>=a&&r<h){a+=c.length-1;continue}let u=0,d=i(c,u,t),f=1,p=0;for(;f<c.length;){const e=i(c,f,t),r=e-p,o=s-d,a=Math.min(r,o);c[u].copyCellsFrom(c[f],p,d,a,!1),d+=a,d===s&&(u++,d=0),p+=a,p===e&&(f++,p=0),0===d&&0!==u&&2===c[u-1].getWidth(s-1)&&(c[u].copyCellsFrom(c[u-1],s-1,d++,1,!1),c[u-1].setCell(s-1,n))}c[u].replaceCells(d,s,n);let g=0;for(let e=c.length-1;e>0&&(e>u||0===c[e].getTrimmedLength());e--)g++;g>0&&(o.push(a+c.length-g),o.push(g)),a+=c.length-1}return o},t.reflowLargerCreateNewLayout=function(e,t){const i=[];let s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){const i=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:i}),o+=i-1,n+=i,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}},t.reflowLargerApplyNewLayout=function(e,t){const i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let t=0;t<i.length;t++)e.set(t,i[t]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,s){const r=[],n=e.map(((s,r)=>i(e,r,t))).reduce(((e,t)=>e+t));let o=0,a=0,h=0;for(;h<n;){if(n-h<s){r.push(n-h);break}o+=s;const l=i(e,a,t);o>l&&(o-=l,a++);const c=2===e[a].getWidth(o-1);c&&o--;const u=c?s-1:s;r.push(u),h+=u}return r},t.getWrappedLineTrimmedLength=i},5295:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;const s=i(8460),r=i(844),n=i(9092);class o extends r.Disposable{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this.register(new s.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new n.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new n.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}}t.BufferSet=o},511:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;const s=i(482),r=i(643),n=i(3734);class o extends n.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new n.ExtendedAttrs,this.combinedData=""}static fromCharData(e){const t=new o;return t.setFromCharData(e),t}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,s.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[r.CHAR_DATA_ATTR_INDEX],this.bg=0;let t=!1;if(e[r.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[r.CHAR_DATA_CHAR_INDEX].length){const i=e[r.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){const s=e[r.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=s&&s<=57343?this.content=1024*(i-55296)+s-56320+65536|e[r.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[r.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[r.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[r.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[r.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=o},643:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},4863:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;const s=i(8460),r=i(844);class n{get id(){return this._id}constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=n._nextId++,this._onDispose=this.register(new s.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,r.disposeArray)(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}}t.Marker=n,n._nextId=1},7116:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.CHARSETS.A={"#":"£"},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},t.CHARSETS.C=t.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},t.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},t.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},t.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},t.CHARSETS.E=t.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},t.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},t.CHARSETS.H=t.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(e,t)=>{var i,s,r;Object.defineProperty(t,"__esModule",{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(e){e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="",e.BS="\b",e.HT="\t",e.LF="\n",e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""}(i||(t.C0=i={})),function(e){e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""}(s||(t.C1=s={})),function(e){e.ST=`${i.ESC}\\`}(r||(t.C1_ESCAPED=r={}))},7399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateKeyboardEvent=void 0;const s=i(2584),r={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};t.evaluateKeyboardEvent=function(e,t,i,n){const o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?o.key=t?s.C0.ESC+"OA":s.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?o.key=t?s.C0.ESC+"OD":s.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?o.key=t?s.C0.ESC+"OC":s.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(o.key=t?s.C0.ESC+"OB":s.C0.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":s.C0.DEL,e.altKey&&(o.key=s.C0.ESC+o.key);break;case 9:if(e.shiftKey){o.key=s.C0.ESC+"[Z";break}o.key=s.C0.HT,o.cancel=!0;break;case 13:o.key=e.altKey?s.C0.ESC+s.C0.CR:s.C0.CR,o.cancel=!0;break;case 27:o.key=s.C0.ESC,e.altKey&&(o.key=s.C0.ESC+s.C0.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?(o.key=s.C0.ESC+"[1;"+(a+1)+"D",o.key===s.C0.ESC+"[1;3D"&&(o.key=s.C0.ESC+(i?"b":"[1;5D"))):o.key=t?s.C0.ESC+"OD":s.C0.ESC+"[D";break;case 39:if(e.metaKey)break;a?(o.key=s.C0.ESC+"[1;"+(a+1)+"C",o.key===s.C0.ESC+"[1;3C"&&(o.key=s.C0.ESC+(i?"f":"[1;5C"))):o.key=t?s.C0.ESC+"OC":s.C0.ESC+"[C";break;case 38:if(e.metaKey)break;a?(o.key=s.C0.ESC+"[1;"+(a+1)+"A",i||o.key!==s.C0.ESC+"[1;3A"||(o.key=s.C0.ESC+"[1;5A")):o.key=t?s.C0.ESC+"OA":s.C0.ESC+"[A";break;case 40:if(e.metaKey)break;a?(o.key=s.C0.ESC+"[1;"+(a+1)+"B",i||o.key!==s.C0.ESC+"[1;3B"||(o.key=s.C0.ESC+"[1;5B")):o.key=t?s.C0.ESC+"OB":s.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(o.key=s.C0.ESC+"[2~");break;case 46:o.key=a?s.C0.ESC+"[3;"+(a+1)+"~":s.C0.ESC+"[3~";break;case 36:o.key=a?s.C0.ESC+"[1;"+(a+1)+"H":t?s.C0.ESC+"OH":s.C0.ESC+"[H";break;case 35:o.key=a?s.C0.ESC+"[1;"+(a+1)+"F":t?s.C0.ESC+"OF":s.C0.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=s.C0.ESC+"[5;"+(a+1)+"~":o.key=s.C0.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=s.C0.ESC+"[6;"+(a+1)+"~":o.key=s.C0.ESC+"[6~";break;case 112:o.key=a?s.C0.ESC+"[1;"+(a+1)+"P":s.C0.ESC+"OP";break;case 113:o.key=a?s.C0.ESC+"[1;"+(a+1)+"Q":s.C0.ESC+"OQ";break;case 114:o.key=a?s.C0.ESC+"[1;"+(a+1)+"R":s.C0.ESC+"OR";break;case 115:o.key=a?s.C0.ESC+"[1;"+(a+1)+"S":s.C0.ESC+"OS";break;case 116:o.key=a?s.C0.ESC+"[15;"+(a+1)+"~":s.C0.ESC+"[15~";break;case 117:o.key=a?s.C0.ESC+"[17;"+(a+1)+"~":s.C0.ESC+"[17~";break;case 118:o.key=a?s.C0.ESC+"[18;"+(a+1)+"~":s.C0.ESC+"[18~";break;case 119:o.key=a?s.C0.ESC+"[19;"+(a+1)+"~":s.C0.ESC+"[19~";break;case 120:o.key=a?s.C0.ESC+"[20;"+(a+1)+"~":s.C0.ESC+"[20~";break;case 121:o.key=a?s.C0.ESC+"[21;"+(a+1)+"~":s.C0.ESC+"[21~";break;case 122:o.key=a?s.C0.ESC+"[23;"+(a+1)+"~":s.C0.ESC+"[23~";break;case 123:o.key=a?s.C0.ESC+"[24;"+(a+1)+"~":s.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(i&&!n||!e.altKey||e.metaKey)!i||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?o.key=e.key:e.key&&e.ctrlKey&&("_"===e.key&&(o.key=s.C0.US),"@"===e.key&&(o.key=s.C0.NUL)):65===e.keyCode&&(o.type=1);else{const t=r[e.keyCode],i=t?.[e.shiftKey?1:0];if(i)o.key=s.C0.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){const t=e.ctrlKey?e.keyCode-64:e.keyCode+32;let i=String.fromCharCode(t);e.shiftKey&&(i=i.toUpperCase()),o.key=s.C0.ESC+i}else if(32===e.keyCode)o.key=s.C0.ESC+(e.ctrlKey?s.C0.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),o.key=s.C0.ESC+t,o.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?o.key=s.C0.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?o.key=s.C0.DEL:219===e.keyCode?o.key=s.C0.ESC:220===e.keyCode?o.key=s.C0.FS:221===e.keyCode&&(o.key=s.C0.GS)}return o}},482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let t=e[r];t>65535?(t-=65536,s+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):s+=String.fromCharCode(t)}return s},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){const i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){const i=e.charCodeAt(r++);56320<=i&&i<=57343?t[s++]=1024*(this._interim-55296)+i-56320+65536:(t[s++]=this._interim,t[s++]=i),this._interim=0}for(let n=r;n<i;++n){const r=e.charCodeAt(n);if(55296<=r&&r<=56319){if(++n>=i)return this._interim=r,s;const o=e.charCodeAt(n);56320<=o&&o<=57343?t[s++]=1024*(r-55296)+o-56320+65536:(t[s++]=r,t[s++]=o)}else 65279!==r&&(t[s++]=r)}return s}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){const i=e.length;if(!i)return 0;let s,r,n,o,a=0,h=0,l=0;if(this.interim[0]){let s=!1,r=this.interim[0];r&=192==(224&r)?31:224==(240&r)?15:7;let n,o=0;for(;(n=63&this.interim[++o])&&o<4;)r<<=6,r|=n;const h=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,c=h-o;for(;l<c;){if(l>=i)return 0;if(n=e[l++],128!=(192&n)){l--,s=!0;break}this.interim[o++]=n,r<<=6,r|=63&n}s||(2===h?r<128?l--:t[a++]=r:3===h?r<2048||r>=55296&&r<=57343||65279===r||(t[a++]=r):r<65536||r>1114111||(t[a++]=r)),this.interim.fill(0)}const c=i-4;let u=l;for(;u<i;){for(;!(!(u<c)||128&(s=e[u])||128&(r=e[u+1])||128&(n=e[u+2])||128&(o=e[u+3]));)t[a++]=s,t[a++]=r,t[a++]=n,t[a++]=o,u+=4;if(s=e[u++],s<128)t[a++]=s;else if(192==(224&s)){if(u>=i)return this.interim[0]=s,a;if(r=e[u++],128!=(192&r)){u--;continue}if(h=(31&s)<<6|63&r,h<128){u--;continue}t[a++]=h}else if(224==(240&s)){if(u>=i)return this.interim[0]=s,a;if(r=e[u++],128!=(192&r)){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[u++],128!=(192&n)){u--;continue}if(h=(15&s)<<12|(63&r)<<6|63&n,h<2048||h>=55296&&h<=57343||65279===h)continue;t[a++]=h}else if(240==(248&s)){if(u>=i)return this.interim[0]=s,a;if(r=e[u++],128!=(192&r)){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[u++],128!=(192&n)){u--;continue}if(u>=i)return this.interim[0]=s,this.interim[1]=r,this.interim[2]=n,a;if(o=e[u++],128!=(192&o)){u--;continue}if(h=(7&s)<<18|(63&r)<<12|(63&n)<<6|63&o,h<65536||h>1114111)continue;t[a++]=h}}return a}}},225:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;const s=i(1480),r=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],n=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let o;t.UnicodeV6=class{constructor(){if(this.version="6",!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<r.length;++e)o.fill(0,r[e][0],r[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let i,s=0,r=t.length-1;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else{if(!(e<t[i][0]))return!0;r=i-1}return!1}(e,n)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),r=0===i&&0!==t;if(r){const e=s.UnicodeService.extractWidth(t);0===e?r=!1:e>i&&(i=e)}return s.UnicodeService.createPropertyValue(0,i,r)}}},5981:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;const s=i(8460),r=i(844);class n extends r.Disposable{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new s.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(void 0!==t&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let i;for(this._isSyncWriting=!0;i=this._writeBuffer.shift();){this._action(i);const e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){const i=e||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const e=this._writeBuffer[this._bufferOffset],s=this._action(e,t);if(s){const e=e=>Date.now()-i>=12?setTimeout((()=>this._innerWrite(0,e))):this._innerWrite(i,e);return void s.catch((e=>(queueMicrotask((()=>{throw e})),Promise.resolve(!1)))).then(e)}const r=this._callbacks[this._bufferOffset];if(r&&r(),this._bufferOffset++,this._pendingData-=e.length,Date.now()-i>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=n},5941:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toRgbString=t.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,s=/^[\da-f]+$/;function r(e,t){const i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}t.parseColor=function(e){if(!e)return;let t=e.toLowerCase();if(0===t.indexOf("rgb:")){t=t.slice(4);const e=i.exec(t);if(e){const t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(0===t.indexOf("#")&&(t=t.slice(1),s.exec(t)&&[3,6,9,12].includes(t.length))){const e=t.length/3,i=[0,0,0];for(let s=0;s<3;++s){const r=parseInt(t.slice(e*s,e*s+e),16);i[s]=1===e?r<<4:2===e?r:3===e?r>>4:r>>8}return i}},t.toRgbString=function(e,t=16){const[i,s,n]=e;return`rgb:${r(i,t)}/${r(s,t)}/${r(n,t)}`}},5770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;const s=i(482),r=i(8742),n=i(5770),o=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);const i=this._handlers[e];return i.push(t),{dispose:()=>{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=o,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t);else this._handlerFb(this._ident,"HOOK",t)}put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._ident,"PUT",(0,s.utf32ToString)(e,t,i))}unhook(e,t=!0){if(this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].unhook(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",e);this._active=o,this._ident=0}};const a=new r.Params;a.addParam(0),t.DcsHandler=class{constructor(e){this._handler=e,this._data="",this._params=a,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():a,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=(0,s.utf32ToString)(e,t,i),this._data.length>n.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then((e=>(this._params=a,this._data="",this._hitLimit=!1,e)));return this._params=a,this._data="",this._hitLimit=!1,t}}},2015:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;const s=i(844),r=i(8742),n=i(6242),o=i(6351);class a{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}}t.TransitionTable=a;const h=160;t.VT500_TRANSITION_TABLE=function(){const e=new a(4095),t=Array.apply(null,Array(256)).map(((e,t)=>t)),i=(e,i)=>t.slice(e,i),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));const n=i(0,14);let o;for(o in e.setDefault(1,0),e.addMany(s,0,2,0),n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(h,0,2,0),e.add(h,8,5,8),e.add(h,6,0,6),e.add(h,11,0,11),e.add(h,13,13,13),e}();class l extends s.Disposable{constructor(e=t.VT500_TRANSITION_TABLE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new r.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,s.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new n.OscParser),this._dcsParser=this.register(new o.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let t=0;t<e.intermediates.length;++t){const s=e.intermediates.charCodeAt(t);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=s}}if(1!==e.final.length)throw new Error("final must be a single byte");const s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){const t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){const i=this._identifier(e,[48,126]);void 0===this._escHandlers[i]&&(this._escHandlers[i]=[]);const s=this._escHandlers[i];return s.push(t),{dispose:()=>{const e=s.indexOf(t);-1!==e&&s.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){const i=this._identifier(e);void 0===this._csiHandlers[i]&&(this._csiHandlers[i]=[]);const s=this._csiHandlers[i];return s.push(t),{dispose:()=>{const e=s.indexOf(t);-1!==e&&s.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s,r=0,n=0,o=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===i||1===this._parseStack.state)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const t=this._parseStack.handlers;let n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](this._params),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 4:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],s=this._dcsParser.unhook(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],s=this._oscParser.end(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let i=o;i<t;++i){switch(r=e[i],n=this._transitions.table[this.currentState<<8|(r<160?r:h)],n>>4){case 2:for(let s=i+1;;++s){if(s>=t||(r=e[s])<32||r>126&&r<h){this._printHandler(e,i,s),i=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<h){this._printHandler(e,i,s),i=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<h){this._printHandler(e,i,s),i=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<h){this._printHandler(e,i,s),i=s-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:i,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const o=this._csiHandlers[this._collect<<8|r];let a=o?o.length-1:-1;for(;a>=0&&(s=o[a](this._params),!0!==s);a--)if(s instanceof Promise)return this._preserveStack(3,o,a,n,i),s;a<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do{switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}}while(++i<t&&(r=e[i])>47&&r<60);i--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:const l=this._escHandlers[this._collect<<8|r];let c=l?l.length-1:-1;for(;c>=0&&(s=l[c](),!0!==s);c--)if(s instanceof Promise)return this._preserveStack(4,l,c,n,i),s;c<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let s=i+1;;++s)if(s>=t||24===(r=e[s])||26===r||27===r||r>127&&r<h){this._dcsParser.put(e,i,s),i=s-1;break}break;case 14:if(s=this._dcsParser.unhook(24!==r&&26!==r),s)return this._preserveStack(6,[],0,n,i),s;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let s=i+1;;s++)if(s>=t||(r=e[s])<32||r>127&&r<h){this._oscParser.put(e,i,s),i=s-1;break}break;case 6:if(s=this._oscParser.end(24!==r&&26!==r),s)return this._preserveStack(5,[],0,n,i),s;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}}t.EscapeSequenceParser=l},6242:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;const s=i(5770),r=i(482),n=[];t.OscParser=class{constructor(){this._state=0,this._active=n,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);const i=this._handlers[e];return i.push(t),{dispose:()=>{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=n}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=n,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||n,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._id,"PUT",(0,r.utf32ToString)(e,t,i))}start(){this.reset(),this._state=1}put(e,t,i){if(3!==this._state){if(1===this._state)for(;t<i;){const i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].end(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._id,"END",e);this._active=n,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=(0,r.utf32ToString)(e,t,i),this._data.length>s.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then((e=>(this._data="",this._hitLimit=!1,e)));return this._data="",this._hitLimit=!1,t}}},8742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;const i=2147483647;class s{static fromArray(e){const t=new s;if(!e.length)return t;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){const s=e[i];if(Array.isArray(s))for(let e=0;e<s.length;++e)t.addSubParam(s[e]);else t.addParam(s)}return t}constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const e=new s(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){const e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);const i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>i?i:e}}addSubParam(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>i?i:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){const t=this._subParamsIdx[e]>>8,i=255&this._subParamsIdx[e];return i-t>0?this._subParams.subarray(t,i):null}getSubParamsAll(){const e={};for(let t=0;t<this.length;++t){const i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&(e[t]=this._subParams.slice(i,s))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const s=this._digitIsSub?this._subParams:this.params,r=s[t-1];s[t-1]=~r?Math.min(10*r+e,i):e}}t.Params=s},5741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){const i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(-1===t)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}}},8771:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;const s=i(3785),r=i(511);t.BufferApiView=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){const t=this._buffer.lines.get(e);if(t)return new s.BufferLineApiView(t)}getNullCell(){return new r.CellData}}},3785:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;const s=i(511);t.BufferLineApiView=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new s.CellData)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}}},8285:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;const s=i(8771),r=i(8460),n=i(844);class o extends n.Disposable{constructor(e){super(),this._core=e,this._onBufferChange=this.register(new r.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new s.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new s.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,(e=>t(e.toArray())))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,((e,i)=>t(e,i.toArray())))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}}},7090:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}}},744:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;const n=i(8460),o=i(844),a=i(5295),h=i(2585);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let l=t.BufferService=class extends o.Disposable{get buffer(){return this.buffers.active}constructor(e){super(),this.isUserScrolling=!1,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new n.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(e.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this.register(new a.BufferSet(e,this))}resize(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){const i=this.buffer;let s;s=this._cachedBlankLine,s&&s.length===this.cols&&s.getFg(0)===e.fg&&s.getBg(0)===e.bg||(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;const r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(0===i.scrollTop){const e=i.lines.isFull;n===i.lines.length-1?e?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),e?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{const e=n-r+1;i.lines.shiftElements(r+1,e-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t,i){const s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);const r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};t.BufferService=l=s([r(0,h.IOptionsService)],l)},7994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}}},1753:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;const n=i(2585),o=i(8460),a=i(844),h={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function l(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(i|=64,i|=e.action):(i|=3&e.button,4&e.button&&(i|=64),8&e.button&&(i|=128),32===e.action?i|=32:0!==e.action||t||(i|=3)),i}const c=String.fromCharCode,u={DEFAULT:e=>{const t=[l(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`[M${c(t[0])}${c(t[1])}${c(t[2])}`},SGR:e=>{const t=0===e.action&&4!==e.button?"m":"M";return`[<${l(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{const t=0===e.action&&4!==e.button?"m":"M";return`[<${l(e,!0)};${e.x};${e.y}${t}`}};let d=t.CoreMouseService=class extends a.Disposable{constructor(e,t){super(),this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new o.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const e of Object.keys(h))this.addProtocol(e,h[e]);for(const e of Object.keys(u))this.addEncoding(e,u[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows)return!1;if(4===e.button&&32===e.action)return!1;if(3===e.button&&32!==e.action)return!1;if(4!==e.button&&(2===e.action||3===e.action))return!1;if(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))return!1;if(!this._protocols[this._activeProtocol].restrict(e))return!1;const t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x)return!1;if(e.y!==t.y)return!1}else{if(e.col!==t.col)return!1;if(e.row!==t.row)return!1}return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};t.CoreMouseService=d=s([r(0,n.IBufferService),r(1,n.ICoreService)],d)},6975:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;const n=i(1439),o=i(8460),a=i(844),h=i(2585),l=Object.freeze({insertMode:!1}),c=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let u=t.CoreService=class extends a.Disposable{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new o.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new o.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,n.clone)(l),this.decPrivateModes=(0,n.clone)(c)}reset(){this.modes=(0,n.clone)(l),this.decPrivateModes=(0,n.clone)(c)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;const i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split("").map((e=>e.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split("").map((e=>e.charCodeAt(0))))),this._onBinary.fire(e))}};t.CoreService=u=s([r(0,h.IBufferService),r(1,h.ILogService),r(2,h.IOptionsService)],u)},9074:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DecorationService=void 0;const s=i(8055),r=i(8460),n=i(844),o=i(6106);let a=0,h=0;class l extends n.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new o.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new r.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new r.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,n.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;const t=new c(e);if(t){const e=t.marker.onDispose((()=>t.dispose()));t.onDispose((()=>{t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())})),this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(const e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(const n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,(t=>{a=t.options.x??0,h=a+(t.options.width??1),e>=a&&e<h&&(!i||(t.options.layer??"bottom")===i)&&s(t)}))}}t.DecorationService=l;class c extends n.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=s.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=s.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new r.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new r.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;const s=i(2585),r=i(8343);class n{constructor(...e){this._entries=new Map;for(const[t,i]of e)this.set(t,i)}set(e,t){const i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(const[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}}t.ServiceCollection=n,t.InstantiationService=class{constructor(){this._services=new n,this._services.set(s.IInstantiationService,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){const i=(0,r.getServiceDependencies)(e).sort(((e,t)=>e.index-t.index)),s=[];for(const t of i){const i=this._services.get(t.id);if(!i)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id}.`);s.push(i)}const n=i.length>0?i[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...[...t,...s])}}},7866:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;const n=i(844),o=i(2585),a={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF};let h,l=t.LogService=class extends n.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),h=this}_updateLogLevel(){this._logLevel=a[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=s([r(0,o.IOptionsService)],l),t.setTraceLogger=function(e){h=e},t.traceCall=function(e,t,i){if("function"!=typeof i.value)throw new Error("not supported");const s=i.value;i.value=function(...e){if(h.logLevel!==o.LogLevelEnum.TRACE)return s.apply(this,e);h.trace(`GlyphRenderer#${s.name}(${e.map((e=>JSON.stringify(e))).join(", ")})`);const t=s.apply(this,e);return h.trace(`GlyphRenderer#${s.name} return`,t),t}}},7302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;const s=i(8460),r=i(844),n=i(6114);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const o=["normal","bold","100","200","300","400","500","600","700","800","900"];class a extends r.Disposable{constructor(e){super(),this._onOptionChange=this.register(new s.EventEmitter),this.onOptionChange=this._onOptionChange.event;const i={...t.DEFAULT_OPTIONS};for(const t in e)if(t in i)try{const s=e[t];i[t]=this._sanitizeAndValidateOption(t,s)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this.register((0,r.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(e,t){return this.onOptionChange((i=>{i===e&&t(this.rawOptions[e])}))}onMultipleOptionChange(e,t){return this.onOptionChange((i=>{-1!==e.indexOf(i)&&t()}))}_setupOptions(){const e=e=>{if(!(e in t.DEFAULT_OPTIONS))throw new Error(`No option with key "${e}"`);return this.rawOptions[e]},i=(e,i)=>{if(!(e in t.DEFAULT_OPTIONS))throw new Error(`No option with key "${e}"`);i=this._sanitizeAndValidateOption(e,i),this.rawOptions[e]!==i&&(this.rawOptions[e]=i,this._onOptionChange.fire(e))};for(const t in this.rawOptions){const s={get:e.bind(this,t),set:i.bind(this,t)};Object.defineProperty(this.options,t,s)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":if(i||(i=t.DEFAULT_OPTIONS[e]),!function(e){return"block"===e||"underline"===e||"bar"===e}(i))throw new Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=t.DEFAULT_OPTIONS[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=o.includes(i)?i:t.DEFAULT_OPTIONS[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw new Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw new Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}}t.OptionsService=a},2660:function(e,t,i){var s=this&&this.__decorate||function(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},r=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkService=void 0;const n=i(2585);let o=t.OscLinkService=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){const t=this._bufferService.buffer;if(void 0===e.id){const i=t.addMarker(t.ybase+t.y),s={data:e,id:this._nextId++,lines:[i]};return i.onDispose((()=>this._removeMarkerFromLink(s,i))),this._dataByLinkId.set(s.id,s),s.id}const i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;const n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose((()=>this._removeMarkerFromLink(o,n))),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){const i=this._dataByLinkId.get(e);if(i&&i.lines.every((e=>e.line!==t))){const e=this._bufferService.buffer.addMarker(t);i.lines.push(e),e.onDispose((()=>this._removeMarkerFromLink(i,e)))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){const i=e.lines.indexOf(t);-1!==i&&(e.lines.splice(i,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};t.OscLinkService=o=s([r(0,n.IBufferService)],o)},8343:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;const i="di$target",s="di$dependencies";t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[s]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);const r=function(e,t,n){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,r){t[i]===t?t[s].push({id:e,index:r}):(t[s]=[{id:e,index:r}],t[i]=t)}(r,e,n)};return r.toString=()=>e,t.serviceRegistry.set(e,r),r}},2585:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;const s=i(8343);var r;t.IBufferService=(0,s.createDecorator)("BufferService"),t.ICoreMouseService=(0,s.createDecorator)("CoreMouseService"),t.ICoreService=(0,s.createDecorator)("CoreService"),t.ICharsetService=(0,s.createDecorator)("CharsetService"),t.IInstantiationService=(0,s.createDecorator)("InstantiationService"),function(e){e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.OFF=5]="OFF"}(r||(t.LogLevelEnum=r={})),t.ILogService=(0,s.createDecorator)("LogService"),t.IOptionsService=(0,s.createDecorator)("OptionsService"),t.IOscLinkService=(0,s.createDecorator)("OscLinkService"),t.IUnicodeService=(0,s.createDecorator)("UnicodeService"),t.IDecorationService=(0,s.createDecorator)("DecorationService")},1480:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;const s=i(8460),r=i(225);class n{static extractShouldJoin(e){return!!(1&e)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,i=!1){return(16777215&e)<<3|(3&t)<<1|(i?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new s.EventEmitter,this.onChange=this._onChange.event;const e=new r.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,i=0;const s=e.length;for(let r=0;r<s;++r){let o=e.charCodeAt(r);if(55296<=o&&o<=56319){if(++r>=s)return t+this.wcwidth(o);const i=e.charCodeAt(r);56320<=i&&i<=57343?o=1024*(o-55296)+i-56320+65536:t+=this.wcwidth(i)}const a=this.charProperties(o,i);let h=n.extractWidth(a);n.extractShouldJoin(a)&&(h-=n.extractWidth(i)),t+=h,i=a}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=n}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var n=t[s]={exports:{}};return e[s].call(n.exports,n,n.exports,i),n.exports}var s={};return(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.Terminal=void 0;const t=i(9042),r=i(3236),n=i(844),o=i(5741),a=i(8285),h=i(7975),l=i(7090),c=["cols","rows"];class u extends n.Disposable{constructor(e){super(),this._core=this.register(new r.Terminal(e)),this._addonManager=this.register(new o.AddonManager),this._publicOptions={...this._core.options};const t=e=>this._core.options[e],i=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(const e in this._core.options){const s={get:t.bind(this,e),set:i.bind(this,e)};Object.defineProperty(this._publicOptions,e,s)}}_checkReadonlyOptions(e){if(c.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new h.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new a.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const e=this._core.coreService.decPrivateModes;let t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(const t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write("\r\n",t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return t}_verifyIntegers(...e){for(const t of e)if(t===1/0||isNaN(t)||t%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(const t of e)if(t&&(t===1/0||isNaN(t)||t%1!=0||t<0))throw new Error("This API only accepts positive integers")}}e.Terminal=u})(),s})(),e.exports=t()},880(e){"use strict";e.exports=({onlyFirst:e=!1}={})=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}},108(e){"use strict";const t=e=>!Number.isNaN(e)&&e>=4352&&(e<=4447||9001===e||9002===e||11904<=e&&e<=12871&&12351!==e||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);e.exports=t,e.exports.default=t},231(e,t,i){"use strict";const s=i(880);e.exports=e=>"string"==typeof e?e.replace(s(),""):e},942(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IdentityHighlighter=void 0,t.IdentityHighlighter=class{highlight(e,t){return e}highlightPrompt(e){return e}highlightChar(e,t){return!1}}},818(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.History=void 0,t.History=class{constructor(e){this.entries=[],this.cursor=-1,this.maxEntries=e}saveToLocalStorage(){const e=null===window||void 0===window?void 0:window.localStorage;void 0!==e&&e.setItem("history",JSON.stringify(this.entries))}restoreFromLocalStorage(){const e=null===window||void 0===window?void 0:window.localStorage;if(void 0!==e){const t=e.getItem("history");if(null==t)return;try{const i=JSON.parse(t);Array.isArray(i)&&void 0===i.find((e=>"string"!=typeof e))?this.entries=i:(this.entries=[],e.setItem("history","[]"))}catch(t){this.entries=[],e.setItem("history","[]")}}}append(e){this.resetCursor(),this.entries.includes(e)?(this.entries.splice(this.entries.indexOf(e),1),this.entries.unshift(e)):this.entries.unshift(e),this.entries.length>this.maxEntries&&this.entries.pop(),this.saveToLocalStorage()}resetCursor(){this.cursor=-1}next(){if(-1!==this.cursor)return this.cursor-=1,this.entries[this.cursor]}prev(){if(!(this.cursor+1>=this.entries.length))return this.cursor+=1,this.entries[this.cursor]}}},63(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.InputType=void 0,t.parseInput=function(e){return Array.from(function*(e){let t=[];const s=e[Symbol.iterator]();for(let e=s.next();!e.done;e=s.next()){const r=e.value;if(r.length>1){t.push(r);continue}const n=r.charCodeAt(0);if(t.length>0&&(n<32||127===n)&&(yield{inputType:i.Text,data:t},t=[]),27!==n)if(n<32||127===n){let e=i.UnsupportedControlChar;switch(n){case 1:e=i.CtrlA;break;case 3:e=i.CtrlC;break;case 4:e=i.CtrlD;break;case 5:e=i.CtrlE;break;case 11:e=i.CtrlK;break;case 17:e=i.CtrlQ;break;case 19:e=i.CtrlS;break;case 21:e=i.CtrlU;break;case 13:e=i.Enter;break;case 127:e=i.Backspace;break;case 12:e=i.CtrlL}yield{inputType:e,data:[r]}}else t.push(r);else{const e=s.next();if(e.done){t.push("");continue}let r=i.UnsupportedEscape;if("["!==e.value){"\r"===e.value&&(r=i.AltEnter),yield{inputType:r,data:["",e.value]};continue}const n=s.next();if(n.done)continue;if(n.value>="0"&&n.value<="9"){let e=n.value;const t=s.next();if(t.done)return;if(t.value>="0"&&t.value<="9")e+=t.value;else if("~"!==t.value)continue;"3"===e&&(r=i.Delete),yield{inputType:r,data:["","[",e,"~"]};continue}switch(n.value){case"A":r=i.ArrowUp;break;case"B":r=i.ArrowDown;break;case"C":r=i.ArrowRight;break;case"D":r=i.ArrowLeft;break;case"F":r=i.End;break;case"H":r=i.Home;break;case"\r":r=i.AltEnter}yield{inputType:r,data:["","[",n.value]}}}t.length>0&&(yield{inputType:i.Text,data:t})}(e))},function(e){e[e.Text=0]="Text",e[e.AltEnter=1]="AltEnter",e[e.ArrowUp=2]="ArrowUp",e[e.ArrowDown=3]="ArrowDown",e[e.ArrowLeft=4]="ArrowLeft",e[e.ArrowRight=5]="ArrowRight",e[e.Delete=6]="Delete",e[e.Backspace=7]="Backspace",e[e.CtrlA=8]="CtrlA",e[e.CtrlC=9]="CtrlC",e[e.CtrlD=10]="CtrlD",e[e.CtrlE=11]="CtrlE",e[e.CtrlK=12]="CtrlK",e[e.CtrlL=13]="CtrlL",e[e.CtrlQ=14]="CtrlQ",e[e.CtrlS=15]="CtrlS",e[e.CtrlU=16]="CtrlU",e[e.End=17]="End",e[e.Enter=18]="Enter",e[e.Home=19]="Home",e[e.ShiftEnter=20]="ShiftEnter",e[e.UnsupportedControlChar=21]="UnsupportedControlChar",e[e.UnsupportedEscape=22]="UnsupportedEscape"}(i||(t.InputType=i={}))},478(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineBuffer=void 0,t.LineBuffer=class{constructor(){this.buf="",this.pos=0}buffer(){return this.buf}pos_buffer(){return this.buf.slice(0,this.pos)}length(){return this.buf.length}char_length(){return[...this.buf].length}update(e,t){this.buf=e,this.pos=t}insert(e){const t=e.length,i=this.pos===this.buf.length;return this.buf=i?this.buf+e:this.buf.slice(0,this.pos)+e+this.buf.slice(this.pos),this.pos+=t,i}moveBack(e){const t=this.prevPos(e);return void 0!==t&&(this.pos=t,!0)}moveForward(e){const t=this.nextPos(e);return void 0!==t&&(this.pos=t,!0)}moveHome(){const e=this.startOfLine();return this.pos>e&&(this.pos=e,!0)}moveEnd(){const e=this.endOfLine();return this.pos!==e&&(this.pos=e,!0)}startOfLine(){const e=this.buf.slice(0,this.pos).lastIndexOf("\n");return-1!==e?e+1:0}endOfLine(){const e=this.buf.slice(this.pos).indexOf("\n");return-1!==e?this.pos+e:this.buf.length}moveLineUp(e){const t=this.buf.slice(0,this.pos).lastIndexOf("\n");if(-1===t)return!1;const i=[...this.buf.slice(t+1,this.pos)].length;let s=this.buf.slice(0,t).lastIndexOf("\n");-1===s?s=0:s+=1;let r=t;for(let t=1;t<e&&0!==s;t++)r=s-1,s=this.buf.slice(0,r).lastIndexOf("\n"),-1===s?s=0:s+=1;const n=[...this.buf.slice(s,r)].slice(0,i);let o=t;return n.length>0&&(o=n.map((e=>e.length)).reduce(((e,t)=>e+t),0),o=s+o),this.pos=o,!0}moveLineDown(e){const t=this.buf.slice(this.pos).indexOf("\n");if(-1===t)return!1;let i=this.buf.slice(0,this.pos).lastIndexOf("\n");-1===i?i=0:i+=1;const s=[...this.buf.slice(i,this.pos)].length;let r=this.pos+t+1,n=this.buf.slice(r).indexOf("\n");n=-1===n?this.buf.length:r+n;for(let t=1;t<e&&n!==this.buf.length;t++)r=n+1,n=this.buf.slice(r).indexOf("\n"),n=-1===n?this.buf.length:r+n;const o=[...this.buf.slice(r,n)];return s<o.length?this.pos=o.slice(0,s).map((e=>e.length)).reduce(((e,t)=>e+t),0)+r:this.pos=n,!0}set_pos(e){this.pos=e}prevPos(e){if(0===this.pos)return;const t=this.buf.slice(0,this.pos);return this.pos-[...t].slice(-e).map((e=>e.length)).reduce(((e,t)=>e+t),0)}nextPos(e){if(this.pos===this.buf.length)return;const t=this.buf.slice(this.pos);return this.pos+[...t].slice(0,e).map((e=>e.length)).reduce(((e,t)=>e+t),0)}backspace(e){const t=this.prevPos(e);return void 0!==t&&(this.buf=this.buf.slice(0,t)+this.buf.slice(this.pos),this.pos=t,!0)}delete(e){const t=this.nextPos(e);return void 0!==t&&(this.buf=this.buf.slice(0,this.pos)+this.buf.slice(t),!0)}deleteEndOfLine(){if(0==this.buf.length||this.pos==this.buf.length)return!1;const e=this.pos,t=this.endOfLine();return e==t?this.delete(1):this.buf=this.buf.slice(0,e)+this.buf.slice(t),!0}}},530(e,t,i){"use strict";t.b=void 0;const s=i(63),r=i(927),n=i(818),o=i(973),a=i(942);t.b=class{constructor(){this.highlighter=new a.IdentityHighlighter,this.history=new n.History(50),this.disposables=[],this.watermark=0,this.highWatermark=1e4,this.lowWatermark=1e3,this.highWater=!1,this.state=new r.State(">",this.tty(),this.highlighter,this.history),this.checkHandler=()=>!0,this.ctrlCHandler=()=>{},this.pauseHandler=e=>{},this.history.restoreFromLocalStorage()}activate(e){this.term=e,this.term.onData(this.readData.bind(this)),this.term.attachCustomKeyEventHandler(this.handleKeyEvent.bind(this))}dispose(){this.disposables.forEach((e=>e.dispose()))}appendHistory(e){this.history.append(e)}setHighlighter(e){this.highlighter=e}setCheckHandler(e){this.checkHandler=e}setCtrlCHandler(e){this.ctrlCHandler=e}setPauseHandler(e){this.pauseHandler=e}writeReady(){return!this.highWater}write(e){const t=(e="\n"===e?"\r\n":(e=e.replace(/^\n/,"\r\n")).replace(/([^\r])\n/g,"$1\r\n")).length;this.watermark+=t,this.watermark>this.highWatermark&&(this.highWater=!0),this.term&&this.term.write(e,(()=>{this.watermark=Math.max(this.watermark-t,0),this.highWater&&this.watermark<this.lowWatermark&&(this.highWater=!1)}))}print(e){return this.write(e)}println(e){return this.write(e+"\r\n")}output(){return this}tty(){var e,t;return void 0!==(null===(t=null===(e=this.term)||void 0===e?void 0:e.options)||void 0===t?void 0:t.tabStopWidth)?new o.Tty(this.term.cols,this.term.rows,this.term.options.tabStopWidth,this.output()):new o.Tty(0,0,8,this.output())}read(e){return new Promise(((t,i)=>{void 0!==this.term?(this.state=new r.State(e,this.tty(),this.highlighter,this.history),this.state.refresh(),this.activeRead={prompt:e,resolve:t,reject:i}):i("addon is not active")}))}handleKeyEvent(e){return"Enter"!==e.key||!e.shiftKey||("keydown"===e.type&&this.readKey({inputType:s.InputType.ShiftEnter,data:["\r"]}),!1)}readData(e){const t=(0,s.parseInput)(e);t.length>1||t[0].inputType===s.InputType.Text&&t[0].data.length>1?this.readPaste(t):this.readKey(t[0])}readPaste(e){const t=e.map((e=>e.inputType===s.InputType.Enter?{inputType:s.InputType.Text,data:["\n"]}:e));for(const e of t)e.inputType===s.InputType.Text?this.state.editInsert(e.data.join("")):this.readKey(e)}readKey(e){var t,i,n;if(void 0!==this.activeRead)switch(e.inputType){case s.InputType.Text:this.state.editInsert(e.data.join(""));break;case s.InputType.AltEnter:case s.InputType.ShiftEnter:this.state.editInsert("\n");break;case s.InputType.Enter:this.checkHandler(this.state.buffer())?(this.state.moveCursorToEnd(),null===(t=this.term)||void 0===t||t.write("\r\n"),this.history.append(this.state.buffer()),null===(i=this.activeRead)||void 0===i||i.resolve(this.state.buffer()),this.activeRead=void 0):this.state.editInsert("\n");break;case s.InputType.CtrlC:this.state.moveCursorToEnd(),null===(n=this.term)||void 0===n||n.write("^C\r\n"),this.state=new r.State(this.activeRead.prompt,this.tty(),this.highlighter,this.history),this.state.refresh();break;case s.InputType.CtrlS:this.pauseHandler(!1);break;case s.InputType.CtrlU:this.state.update("");break;case s.InputType.CtrlK:this.state.editDeleteEndOfLine();break;case s.InputType.CtrlQ:this.pauseHandler(!0);break;case s.InputType.CtrlL:this.state.clearScreen();break;case s.InputType.Home:case s.InputType.CtrlA:this.state.moveCursorHome();break;case s.InputType.End:case s.InputType.CtrlE:this.state.moveCursorEnd();break;case s.InputType.Backspace:this.state.editBackspace(1);break;case s.InputType.Delete:case s.InputType.CtrlD:this.state.editDelete(1);break;case s.InputType.ArrowLeft:this.state.moveCursorBack(1);break;case s.InputType.ArrowRight:this.state.moveCursorForward(1);break;case s.InputType.ArrowUp:this.state.moveCursorUp(1);break;case s.InputType.ArrowDown:this.state.moveCursorDown(1);case s.InputType.UnsupportedControlChar:case s.InputType.UnsupportedEscape:}else switch(e.inputType){case s.InputType.CtrlC:this.ctrlCHandler();break;case s.InputType.CtrlL:this.write("[H[2J")}}}},927(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.State=t.Layout=t.Position=void 0;const r=i(478),n=s(i(718));class o{constructor(e,t){this.row=void 0!==e?e:0,this.col=void 0!==t?t:0}}t.Position=o;class a{constructor(e){this.promptSize=e,this.cursor=new o,this.end=new o}}t.Layout=a,t.State=class{constructor(e,t,i,s){this.line=new r.LineBuffer,this.highlighting=!1,this.prompt=e,this.tty=t,this.highlighter=i,this.history=s,this.promptSize=t.calculatePosition(e,new o),this.layout=new a(this.promptSize)}buffer(){return this.line.buffer()}shouldHighlight(){return this.highlighter.highlightChar(this.line.buf,this.line.pos)?(this.highlighting=!0,!0):!!this.highlighting&&(this.highlighting=!1,!0)}clearScreen(){this.tty.clearScreen(),this.layout.cursor=new o,this.layout.end=new o,this.refresh()}editInsert(e){const t=this.line.insert(e),i=e.includes("\n");if(t&&!i){const t=(0,n.default)(e);t>0&&this.layout.cursor.col+t<this.tty.col&&!this.shouldHighlight()?(this.layout.cursor.col+=t,this.layout.end.col+=t,this.tty.write(e)):this.refresh()}else this.refresh()}update(e){this.line.update(e,e.length),this.refresh()}editBackspace(e){this.line.backspace(e)&&this.refresh()}editDelete(e){this.line.delete(e)&&this.refresh()}editDeleteEndOfLine(){this.line.deleteEndOfLine()&&this.refresh()}refresh(){const e=this.tty.computeLayout(this.promptSize,this.line);this.tty.refreshLine(this.prompt,this.line,this.layout,e,this.highlighter),this.layout=e}moveCursorBack(e){this.line.moveBack(e)&&this.moveCursor()}moveCursorForward(e){this.line.moveForward(e)&&this.moveCursor()}moveCursorUp(e){this.line.moveLineUp(e)?this.moveCursor():this.previousHistory()}moveCursorDown(e){this.line.moveLineDown(e)?this.moveCursor():this.nextHistory()}moveCursorHome(){this.line.moveHome()&&this.moveCursor()}moveCursorEnd(){this.line.moveEnd()&&this.moveCursor()}moveCursorToEnd(){this.layout.cursor!==this.layout.end&&(this.tty.moveCursor(this.layout.cursor,this.layout.end),this.layout.cursor=Object.assign({},this.layout.end))}previousHistory(){if(-1===this.history.cursor&&this.line.length()>0)return;const e=this.history.prev();void 0!==e&&this.update(e)}nextHistory(){if(-1===this.history.cursor)return;const e=this.history.next();void 0!==e?this.update(e):this.update("")}moveCursor(){const e=this.tty.calculatePosition(this.line.pos_buffer(),this.promptSize);e!==this.layout.cursor&&(this.shouldHighlight()?this.refresh():(this.tty.moveCursor(this.layout.cursor,e),this.layout.promptSize=Object.assign({},this.promptSize),this.layout.cursor=Object.assign({},e)))}}},973(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Tty=void 0;const r=s(i(718));t.Tty=class{constructor(e,t,i,s){this.tabWidth=i,this.col=e,this.row=t,this.out=s}write(e){return this.out.write(e)}print(e){return this.out.print(e)}println(e){return this.out.println(e)}clearScreen(){this.out.write("[H[2J")}calculatePosition(e,t){const i=Object.assign({},t);let s=0;return[...e].forEach((e=>{if("\n"===e)return i.row+=1,void(i.col=0);let t=0;if("\t"===e)t=this.tabWidth-i.col%this.tabWidth;else{let i;[i,s]=function(e,t){return 1===t?"["===e?[0,2]:[0,0]:2===t?";"===e||e[0]>="0"&&e[0]<="9"?[0,t]:[0,0]:""===e?[0,1]:"\n"===e?[0,t]:[(0,r.default)(e),t]}(e,s),t=i}i.col+=t,i.col>this.col&&(i.row+=1,i.col=t)})),i.col===this.col&&(i.col=0,i.row+=1),i}computeLayout(e,t){const i=Object.assign({},e),s=t.pos,r=this.calculatePosition(t.buf.slice(0,t.pos),e);return{promptSize:i,cursor:r,end:s===t.buf.length?Object.assign({},r):this.calculatePosition(t.buf.slice(s),r)}}refreshLine(e,t,i,s,r){const n=s.cursor,o=s.end;this.clearOldRows(i),this.write(r.highlightPrompt(e)),this.write(r.highlight(t.buf,t.pos)),0===o.col&&o.row>0&&"\n"!==t.buf[t.buf.length-1]&&this.write("\n");const a=o.row-n.row;a>0&&this.write(`[${a}A`),n.col>0?this.write(`\r[${n.col}C`):this.write("\r")}clearOldRows(e){const t=e.cursor.row,i=e.end.row,s=Math.max(i-t,0);s>0&&this.write(`[${s}B`);for(let e=0;e<i;e++)this.write("\r[0K[A");this.write("\r[0K")}moveCursor(e,t){if(t.row>e.row){const i=t.row-e.row;1===i?this.write("[B"):this.write(`[${i}B`)}else if(t.row<e.row){const i=e.row-t.row;1===i?this.write("[A"):this.write(`[${i}A`)}if(t.col>e.col){const i=t.col-e.col;1===i?this.write("[C"):this.write(`[${i}C`)}else if(t.col<e.col){const i=e.col-t.col;1===i?this.write("[D"):this.write(`[${i}D`)}}}},522(e){"use strict";e.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}},718(e,t,i){"use strict";const s=i(231),r=i(108),n=i(522),o=e=>{if("string"!=typeof e||0===e.length)return 0;if(0===(e=s(e)).length)return 0;e=e.replace(n()," ");let t=0;for(let i=0;i<e.length;i++){const s=e.codePointAt(i);s<=31||s>=127&&s<=159||s>=768&&s<=879||(s>65535&&i++,t+=r(s)?2:1)}return t};e.exports=o,e.exports.default=o},514(e,t,i){var s={"./asyncbrowser.py":259,"./fetch.py":777,"./fibonacci.py":449,"./fizzbuzz.py":367,"./import_pypi.py":675,"./mandelbrot.py":809};function r(e){var t=n(e);return i(t)}function n(e){if(!i.o(s,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return s[e]}r.keys=function(){return Object.keys(s)},r.resolve=n,e.exports=r,r.id=514},259(e){"use strict";e.exports='import asyncweb\nimport browser\n\n\nasync def main(delay):\n url = f"https://httpbin.org/delay/{delay}"\n print(f"fetching {url}...")\n res = await browser.fetch(\n url, response_format="json", headers={"X-Header-Thing": "rustpython is neat!"}\n )\n print(f"got res from {res[\'url\']}:")\n print(res, end="\\n\\n")\n\n\nfor delay in range(3):\n asyncweb.run(main(delay))\nprint()\n'},777(e){"use strict";e.exports='from browser import fetch\n\n\ndef fetch_handler(res):\n print(f"headers: {res[\'headers\']}")\n\n\nfetch(\n "https://httpbin.org/get",\n response_format="json",\n headers={"X-Header-Thing": "rustpython is neat!"},\n).then(fetch_handler, lambda err: print(f"error: {err}"))\n'},449(e){"use strict";e.exports='n1 = 0\nn2 = 1\ncount = 0\nuntil = 10\n\nprint(f"These are the first {until} numbers in the Fibonacci sequence:")\n\nwhile count < until:\n print(n1)\n n1, n2 = n2, n1 + n2\n count += 1\n'},367(e){"use strict";e.exports='for i in range(1, 100):\n print(f"{i} ", end="")\n if not i % 3:\n print("fizz", end="")\n if not i % 5:\n print("buzz", end="")\n print()\n'},675(e){"use strict";e.exports='# make sys.modules[\'os\'] a dumb version of the os module, which has posixpath\n# available as os.path as well as a few other utilities, but will raise an\n# OSError for anything that actually requires an OS\nimport _dummy_os\nimport asyncweb\nimport whlimport\n\nwhlimport.setup()\n\n\n@asyncweb.main\nasync def main():\n await whlimport.load_package("pygments")\n import pygments\n import pygments.formatters.html\n import pygments.lexers\n\n lexer = pygments.lexers.get_lexer_by_name("python")\n fmter = pygments.formatters.html.HtmlFormatter(noclasses=True, style="default")\n print(pygments.highlight("print(\'hi, mom!\')", lexer, fmter))\n'},809(e){"use strict";e.exports='w = 50.0\nh = 50.0\n\n\ndef mandel():\n """Print a mandelbrot fractal to the console, yielding after each character is printed"""\n y = 0.0\n while y < h:\n x = 0.0\n while x < w:\n Zr, Zi, Tr, Ti = 0.0, 0.0, 0.0, 0.0\n Cr = 2 * x / w - 1.5\n Ci = 2 * y / h - 1.0\n\n i = 0\n while i < 50 and Tr + Ti <= 4:\n Zi = 2 * Zr * Zi + Ci\n Zr = Tr - Ti + Cr\n Tr = Zr * Zr\n Ti = Zi * Zi\n i += 1\n\n if Tr + Ti <= 4:\n print("*", end="")\n else:\n print("·", end="")\n\n x += 1\n yield\n\n print()\n y += 1\n yield\n\n\n# run the mandelbrot\n\ntry:\n from browser import request_animation_frame\nexcept:\n request_animation_frame = None\n\ngen = mandel()\n\n\ndef gen_cb(_time=None):\n for _ in range(4):\n gen.__next__()\n request_animation_frame(gen_cb)\n\n\nif request_animation_frame:\n gen_cb()\nelse:\n any(gen)\n'}},h={};function l(e){var t=h[e];if(void 0!==t)return t.exports;var i=h[e]={id:e,exports:{}};return a[e].call(i.exports,i,i.exports,l),i.exports}l.m=a,e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",i=e?Symbol("webpack exports"):"__webpack_exports__",s=e?Symbol("webpack error"):"__webpack_error__",r=e=>{e&&e.d<1&&(e.d=1,e.forEach((e=>e.r--)),e.forEach((e=>e.r--?e.r++:e())))},l.a=(e,n,o)=>{var a;o&&((a=[]).d=-1);var h,l,c,u=new Set,d=e.exports,f=new Promise(((e,t)=>{c=t,l=e}));f[i]=d,f[t]=e=>(a&&e(a),u.forEach(e),f.catch((e=>{}))),e.exports=f,n((e=>{var n;h=(e=>e.map((e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var n=[];n.d=0,e.then((e=>{o[i]=e,r(n)}),(e=>{o[s]=e,r(n)}));var o={};return o[t]=e=>e(n),o}}var a={};return a[t]=e=>{},a[i]=e,a})))(e);var o=()=>h.map((e=>{if(e[s])throw e[s];return e[i]})),l=new Promise((e=>{(n=()=>e(o)).r=0;var i=e=>e!==a&&!u.has(e)&&(u.add(e),e&&!e.d&&(n.r++,e.push(n)));h.map((e=>e[t](i)))}));return n.r?l:o()}),(e=>(e?c(f[s]=e):l(d),r(a)))),a&&a.d<0&&(a.d=0)},l.d=(e,t)=>{for(var i in t)l.o(t,i)&&!l.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce(((t,i)=>(l.f[i](e,t),t)),[])),l.u=e=>e+".index.js",l.miniCssF=e=>{},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},o="app:",l.l=(e,t,i,s)=>{if(n[e])n[e].push(t);else{var r,a;if(void 0!==i)for(var h=document.getElementsByTagName("script"),c=0;c<h.length;c++){var u=h[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==o+i){r=u;break}}r||(a=!0,(r=document.createElement("script")).charset="utf-8",l.nc&&r.setAttribute("nonce",l.nc),r.setAttribute("data-webpack",o+i),r.src=e),n[e]=[t];var d=(t,i)=>{r.onerror=r.onload=null,clearTimeout(f);var s=n[e];if(delete n[e],r.parentNode&&r.parentNode.removeChild(r),s&&s.forEach((e=>e(i))),t)return t(i)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=d.bind(null,r.onerror),r.onload=d.bind(null,r.onload),a&&document.head.appendChild(r)}},l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.v=(e,t,i,s)=>{var r=fetch(l.p+""+i+".module.wasm"),n=()=>r.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,s))).then((t=>Object.assign(e,t.instance.exports)));return r.then((t=>"function"==typeof WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,s).then((t=>Object.assign(e,t.instance.exports)),(e=>{if("application/wasm"!==t.headers.get("Content-Type"))return console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",e),n();throw e})):n()))},(()=>{var e;l.g.importScripts&&(e=l.g.location+"");var t=l.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=i[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),l.p=e})(),(()=>{var e={792:0};l.f.j=(t,i)=>{var s=l.o(e,t)?e[t]:void 0;if(0!==s)if(s)i.push(s[2]);else{var r=new Promise(((i,r)=>s=e[t]=[i,r]));i.push(s[2]=r);var n=l.p+l.u(t),o=new Error;l.l(n,(i=>{if(l.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var r=i&&("load"===i.type?"missing":i.type),n=i&&i.target&&i.target.src;o.message="Loading chunk "+t+" failed.\n("+r+": "+n+")",o.name="ChunkLoadError",o.type=r,o.request=n,s[1](o)}}),"chunk-"+t,t)}};var t=(t,i)=>{var s,r,[n,o,a]=i,h=0;if(n.some((t=>0!==e[t]))){for(s in o)l.o(o,s)&&(l.m[s]=o[s]);a&&a(l)}for(t&&t(i);h<n.length;h++)r=n[h],l.o(e,r)&&e[r]&&e[r][0](),e[r]=0},i=self.webpackChunkapp=self.webpackChunkapp||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),(()=>{"use strict";let e=[],t=[];function i(i){if(i<768)return!1;for(let s=0,r=e.length;;){let n=s+r>>1;if(i<e[n])r=n;else{if(!(i>=t[n]))return!0;s=n+1}if(s==r)return!1}}function s(e){return e>=127462&&e<=127487}function r(e,t,i=!0,s=!0){return(i?n:o)(e,t,s)}function n(e,t,r){if(t==e.length)return t;t&&h(e.charCodeAt(t))&&c(e.charCodeAt(t-1))&&t--;let n=a(e,t);for(t+=u(n);t<e.length;){let o=a(e,t);if(8205==n||8205==o||r&&i(o))t+=u(o),n=o;else{if(!s(o))break;{let i=0,r=t-2;for(;r>=0&&s(a(e,r));)i++,r-=2;if(i%2==0)break;t+=2}}}return t}function o(e,t,i){for(;t>0;){let s=n(e,t-2,i);if(s<t)return s;t--}return 0}function a(e,t){let i=e.charCodeAt(t);if(!c(i)||t+1==e.length)return i;let s=e.charCodeAt(t+1);return h(s)?s-56320+(i-55296<<10)+65536:i}function h(e){return e>=56320&&e<57344}function c(e){return e>=55296&&e<56320}function u(e){return e<65536?1:2}(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let s=0,r=0;s<i.length;s++)(s%2?t:e).push(r+=i[s])})();class d{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=w(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),p.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=w(this,e,t);let i=[];return this.decompose(e,t,i,0),p.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new v(this),r=new v(e);for(let e=t,n=t;;){if(s.next(e),r.next(e),e=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(n+=s.value.length,s.done||n>=i)return!0}}iter(e=1){return new v(this,e)}iterRange(e,t=this.length){return new _(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new O(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new f(e):p.from(f.split(e,[])):d.empty}}class f extends d{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let n=this.text[r],o=s+n.length;if((t?i:o)>=e)return new S(s,o,i,n);s=o+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new f(m(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&s){let e=i.pop(),t=g(r.text,e.text.slice(),0,r.length);if(t.length<=32)i.push(new f(t,e.length+r.length));else{let e=t.length>>1;i.push(new f(t.slice(0,e)),new f(t.slice(e)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof f))return super.replace(e,t,i);[e,t]=w(this,e,t);let s=g(this.text,g(i.text,m(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new f(s,r):p.from(f.split(s,[]),r)}sliceString(e,t=this.length,i="\n"){[e,t]=w(this,e,t);let s="";for(let r=0,n=0;r<=t&&n<this.text.length;n++){let o=this.text[n],a=r+o.length;r>e&&n&&(s+=i),e<a&&t>r&&(s+=o.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,32==i.length&&(t.push(new f(i,s)),i=[],s=-1);return s>-1&&t.push(new f(i,s)),t}}class p extends d{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,i,s){for(let r=0;;r++){let n=this.children[r],o=s+n.length,a=i+n.lines-1;if((t?a:o)>=e)return n.lineInner(e,t,i,s);s=o+1,i=a+1}}decompose(e,t,i,s){for(let r=0,n=0;n<=t&&r<this.children.length;r++){let o=this.children[r],a=n+o.length;if(e<=a&&t>=n){let r=s&((n<=e?1:0)|(a>=t?2:0));n>=e&&a<=t&&!r?i.push(o):o.decompose(e-n,t-n,i,r)}n=a+1}}replace(e,t,i){if([e,t]=w(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let n=this.children[s],o=r+n.length;if(e>=r&&t<=o){let a=n.replace(e-r,t-r,i),h=this.lines-n.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let r=this.children.slice();return r[s]=a,new p(r,this.length-(t-e)+i.length)}return super.replace(r,o,a)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){[e,t]=w(this,e,t);let s="";for(let r=0,n=0;r<this.children.length&&n<=t;r++){let o=this.children[r],a=n+o.length;n>e&&r&&(s+=i),e<a&&t>n&&(s+=o.sliceString(e-n,t-n,i)),n=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof p))return 0;let i=0,[s,r,n,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==n||r==o)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new f(i,t)}let s=Math.max(32,i>>5),r=s<<1,n=s>>1,o=[],a=0,h=-1,l=[];function c(e){let t;if(e.lines>r&&e instanceof p)for(let t of e.children)c(t);else e.lines>n&&(a>n||!a)?(u(),o.push(e)):e instanceof f&&a&&(t=l[l.length-1])instanceof f&&e.lines+t.lines<=32?(a+=e.lines,h+=e.length+1,l[l.length-1]=new f(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>s&&u(),a+=e.lines,h+=e.length+1,l.push(e))}function u(){0!=a&&(o.push(1==l.length?l[0]:p.from(l,h)),h=-1,a=l.length=0)}for(let t of e)c(t);return u(),1==o.length?o[0]:new p(o,t)}}function g(e,t,i=0,s=1e9){for(let r=0,n=0,o=!0;n<e.length&&r<=s;n++){let a=e[n],h=r+a.length;h>=i&&(h>s&&(a=a.slice(0,s-r)),r<i&&(a=a.slice(i-r)),o?(t[t.length-1]+=a,o=!1):t.push(a)),r=h+1}return t}function m(e,t,i){return g(e,[""],t,i)}d.empty=new f([""],0);class v{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof f?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],n=r>>1,o=s instanceof f?s.text.length:s.children.length;if(n==(t>0?o:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(s instanceof f){let r=s.text[n+(t<0?-1:0)];if(this.offsets[i]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=s.children[n+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof f?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class _{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new v(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class O{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(d.prototype[Symbol.iterator]=function(){return this.iter()},v.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=O.prototype[Symbol.iterator]=function(){return this});class S{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function w(e,t,i){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,i))]}function b(e,t,i=!0,s=!0){return r(e,t,i,s)}function y(e,t){let i=e.charCodeAt(t);if(!((s=i)>=55296&&s<56320&&t+1!=e.length))return i;var s;let r=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(r)?r-56320+(i-55296<<10)+65536:i}function D(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function C(e){return e<65536?1:2}const k=/\r\n?|\n/;var x=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(x||(x={}));class E{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],n=this.sections[t++];n<0?(e(i,s,r),s+=r):s+=n,i+=r}}iterChangedRanges(e,t=!1){P(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new E(e)}composeDesc(e){return this.empty?e:e.empty?this:B(this,e)}mapDesc(e,t=!1){return e.empty?this:M(this,e,t)}mapPos(e,t=-1,i=x.Simple){let s=0,r=0;for(let n=0;n<this.sections.length;){let o=this.sections[n++],a=this.sections[n++],h=s+o;if(a<0){if(h>e)return r+(e-s);r+=o}else{if(i!=x.Simple&&h>=e&&(i==x.TrackDel&&s<e&&h>e||i==x.TrackBefore&&s<e||i==x.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!o)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=s+this.sections[i++];if(this.sections[i++]>=0&&s<=t&&r>=e)return!(s<e&&r>t)||"cover";s=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new E(e)}static create(e){return new E(e)}}class T extends E{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return P(this,((t,i,s,r,n)=>e=e.replace(s,s+(i-t),n)),!1),e}mapDesc(e,t=!1){return M(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let n=t[s],o=t[s+1];if(o>=0){t[s]=o,t[s+1]=n;let a=s>>1;for(;i.length<a;)i.push(d.empty);i.push(n?e.slice(r,r+n):d.empty)}r+=n}return new T(t,i)}compose(e){return this.empty?e:e.empty?this:B(this,e,!0)}map(e,t=!1){return e.empty?this:M(this,e,t,!0)}iterChanges(e,t=!1){P(this,e,t)}get desc(){return E.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new L(this);e:for(let n=0,o=0;;){let a=n==e.length?1e9:e[n++];for(;o<a||o==a&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,a-o);A(s,e,-1);let n=-1==r.ins?-1:0==r.off?r.ins:0;A(t,e,n),n>0&&R(i,t,r.text),r.forward(e),o+=e}let h=e[n++];for(;o<h;){if(r.done)break e;let e=Math.min(r.len,h-o);A(t,e,-1),A(s,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),o+=e}}return{changes:new T(t,i),filtered:E.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):0==s?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],n=0,o=null;function a(e=!1){if(!e&&!s.length)return;n<t&&A(s,t-n,-1);let i=new T(s,r);o=o?o.compose(i.map(o)):i,s=[],r=[],n=0}return function e(h){if(Array.isArray(h))for(let t of h)e(t);else if(h instanceof T){if(h.length!=t)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${t})`);a(),o=o?o.compose(h.map(o)):h}else{let{from:e,to:o=e,insert:l}=h;if(e>o||e<0||o>t)throw new RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let c=l?"string"==typeof l?d.of(l.split(i||k)):l:d.empty,u=c.length;if(e==o&&0==u)return;e<n&&a(),e>n&&A(s,e-n,-1),A(s,o-e,u),R(r,s,c),n=o}}(e),a(!o),o}static empty(e){return new T(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if("number"==typeof r)t.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((e,t)=>t&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;i.length<s;)i.push(d.empty);i[s]=d.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new T(t,i)}static createSet(e,t){return new T(e,t)}}function A(e,t,i,s=!1){if(0==t&&i<=0)return;let r=e.length-2;r>=0&&i<=0&&i==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=i:s?(e[r]+=t,e[r+1]+=i):e.push(t,i)}function R(e,t,i){if(0==i.length)return;let s=t.length-2>>1;if(s<e.length)e[e.length-1]=e[e.length-1].append(i);else{for(;e.length<s;)e.push(d.empty);e.push(i)}}function P(e,t,i){let s=e.inserted;for(let r=0,n=0,o=0;o<e.sections.length;){let a=e.sections[o++],h=e.sections[o++];if(h<0)r+=a,n+=a;else{let l=r,c=n,u=d.empty;for(;l+=a,c+=h,h&&s&&(u=u.append(s[o-2>>1])),!(i||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],h=e.sections[o++];t(r,l,n,c,u),r=l,n=c}}}function M(e,t,i,s=!1){let r=[],n=s?[]:null,o=new L(e),a=new L(t);for(let e=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==a.ins){let e=Math.min(o.len,a.len);A(r,e,-1),o.forward(e),a.forward(e)}else if(a.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!i))){let t=a.len;for(A(r,a.ins,-1);t;){let i=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=i&&(A(r,0,o.ins),n&&R(n,r,o.text),e=o.i),o.forward(i),t-=i}a.next()}else{if(!(o.ins>=0)){if(o.done&&a.done)return n?T.createSet(r,n):E.create(r);throw new Error("Mismatched change set lengths")}{let t=0,i=o.len;for(;i;)if(-1==a.ins){let e=Math.min(i,a.len);t+=e,i-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}A(r,t,e<o.i?o.ins:0),n&&e<o.i&&R(n,r,o.text),e=o.i,o.forward(o.len-i)}}}}function B(e,t,i=!1){let s=[],r=i?[]:null,n=new L(e),o=new L(t);for(let e=!1;;){if(n.done&&o.done)return r?T.createSet(s,r):E.create(s);if(0==n.ins)A(s,n.len,0,e),n.next();else if(0!=o.len||o.done){if(n.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(n.len2,o.len),i=s.length;if(-1==n.ins){let i=-1==o.ins?-1:o.off?0:o.ins;A(s,t,i,e),r&&i&&R(r,s,o.text)}else-1==o.ins?(A(s,n.off?0:n.len,t,e),r&&R(r,s,n.textBit(t))):(A(s,n.off?0:n.len,o.off?0:o.ins,e),r&&!o.off&&R(r,s,o.text));e=(n.ins>t||o.ins>=0&&o.len>t)&&(e||s.length>i),n.forward2(t),o.forward(t)}}else A(s,0,o.ins,e),r&&R(r,s,o.text),o.next()}}class L{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?d.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?d.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class F{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new F(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return I.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return I.range(this.anchor,i)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return I.range(e.anchor,e.head)}static create(e,t,i){return new F(e,t,i)}}class I{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:I.create(this.ranges.map((i=>i.map(e,t))),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new I([this.main],0)}addRange(e,t=!0){return I.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,I.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new I(e.ranges.map((e=>F.fromJSON(e))),e.main)}static single(e,t=e){return new I([I.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return I.normalized(e.slice(),t);i=r.to}return new I(e,t)}static cursor(e,t=0,i,s){return F.create(e,e,(0==t?0:t<0?8:16)|(null==i?7:Math.min(6,i))|(null!=s?s:16777215)<<6)}static range(e,t,i,s){let r=(null!=i?i:16777215)<<6|(null==s?7:Math.min(6,s));return t<e?F.create(t,e,48|r):F.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(i);for(let i=1;i<e.length;i++){let s=e[i],r=e[i-1];if(s.empty?s.from<=r.to:s.from<r.to){let n=r.from,o=Math.max(s.to,r.to);i<=t&&t--,e.splice(--i,2,s.anchor>s.head?I.range(o,n):I.range(n,o))}}return new I(e,t)}}function Q(e,t){for(let i of e.ranges)if(i.to>t)throw new RangeError("Selection points outside of document")}let W=0;class H{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=W++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new H(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:q),!!e.static,e.enables)}of(e){return new $([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new $(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(i=>t(i.field(e))))}}function q(e,t){return e==t||e.length==t.length&&e.every(((e,i)=>e===t[i]))}class ${constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=W++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,n=e[r]>>1,o=2==this.type,a=!1,h=!1,l=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?h=!0:1&(null!==(t=e[i.id])&&void 0!==t?t:1)||l.push(e[i.id]);return{create:e=>(e.values[n]=i(e),1),update(e,t){if(a&&t.docChanged||h&&(t.docChanged||t.selection)||N(e,l)){let t=i(e);if(o?!z(t,e.values[n],s):!s(t,e.values[n]))return e.values[n]=t,1}return 0},reconfigure:(e,t)=>{let a,h=t.config.address[r];if(null!=h){let r=te(t,h);if(this.dependencies.every((i=>i instanceof H?t.facet(i)===e.facet(i):!(i instanceof j)||t.field(i,!1)==e.field(i,!1)))||(o?z(a=i(e),r,s):s(a=i(e),r)))return e.values[n]=r,0}else a=i(e);return e.values[n]=a,1}}}}function z(e,t,i){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!i(e[s],t[s]))return!1;return!0}function N(e,t){let i=!1;for(let s of t)1&ee(e,s)&&(i=!0);return i}function U(e,t,i){let s=i.map((t=>e[t.id])),r=i.map((e=>e.type)),n=s.filter((e=>!(1&e))),o=e[t.id]>>1;function a(e){let i=[];for(let t=0;t<s.length;t++){let n=te(e,s[t]);if(2==r[t])for(let e of n)i.push(e);else i.push(n)}return t.combine(i)}return{create(e){for(let t of s)ee(e,t);return e.values[o]=a(e),1},update(e,i){if(!N(e,n))return 0;let s=a(e);return t.compare(s,e.values[o])?0:(e.values[o]=s,1)},reconfigure(e,r){let n=N(e,s),h=r.config.facets[t.id],l=r.facet(t);if(h&&!n&&q(i,h))return e.values[o]=l,0;let c=a(e);return t.compare(c,l)?(e.values[o]=l,0):(e.values[o]=c,1)}}}const V=H.define({static:!0});class j{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new j(W++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(V).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let s=e.values[t],r=this.updateF(s,i);return this.compareF(s,r)?0:(e.values[t]=r,1)},reconfigure:(e,i)=>{let s,r=e.facet(V),n=i.facet(V);return(s=r.find((e=>e.field==this)))&&s!=n.find((e=>e.field==this))?(e.values[t]=s.create(e),1):null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,V.of({field:this,create:e})]}get extension(){return this}}function X(e){return t=>new K(t,e)}const G={highest:X(0),high:X(1),default:X(2),low:X(3),lowest:X(4)};class K{constructor(e,t){this.inner=e,this.prec=t}}class Z{of(e){return new Y(this,e)}reconfigure(e){return Z.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Y{constructor(e,t){this.compartment=e,this.inner=t}}class J{constructor(e,t,i,s,r,n){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=n,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),n=new Map;for(let i of function(e,t,i){let s=[[],[],[],[],[]],r=new Map;return function e(n,o){let a=r.get(n);if(null!=a){if(a<=o)return;let e=s[a].indexOf(n);e>-1&&s[a].splice(e,1),n instanceof Y&&i.delete(n.compartment)}if(r.set(n,o),Array.isArray(n))for(let t of n)e(t,o);else if(n instanceof Y){if(i.has(n.compartment))throw new RangeError("Duplicate use of compartment in extensions");let s=t.get(n.compartment)||n.inner;i.set(n.compartment,s),e(s,o)}else if(n instanceof K)e(n.inner,n.prec);else if(n instanceof j)s[o].push(n),n.provides&&e(n.provides,o);else if(n instanceof $)s[o].push(n),n.facet.extensions&&e(n.facet.extensions,2);else{let t=n.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${n}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,o)}}(e,2),s.reduce(((e,t)=>e.concat(t)))}(e,t,n))i instanceof j?s.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let o=Object.create(null),a=[],h=[];for(let e of s)o[e.id]=h.length<<1,h.push((t=>e.slot(t)));let l=null==i?void 0:i.config.facets;for(let e in r){let t=r[e],s=t[0].facet,n=l&&l[e]||[];if(t.every((e=>0==e.type)))if(o[s.id]=a.length<<1|1,q(n,t))a.push(i.facet(s));else{let e=s.combine(t.map((e=>e.value)));a.push(i&&s.compare(e,i.facet(s))?i.facet(s):e)}else{for(let e of t)0==e.type?(o[e.id]=a.length<<1|1,a.push(e.value)):(o[e.id]=h.length<<1,h.push((t=>e.dynamicSlot(t))));o[s.id]=h.length<<1,h.push((e=>U(e,s,t)))}}let c=h.map((e=>e(o)));return new J(e,n,c,o,a,r)}}function ee(e,t){if(1&t)return 2;let i=t>>1,s=e.status[i];if(4==s)throw new Error("Cyclic dependency between fields and/or facets");if(2&s)return s;e.status[i]=4;let r=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|r}function te(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const ie=H.define(),se=H.define({combine:e=>e.some((e=>e)),static:!0}),re=H.define({combine:e=>e.length?e[0]:void 0,static:!0}),ne=H.define(),oe=H.define(),ae=H.define(),he=H.define({combine:e=>!!e.length&&e[0]});class le{constructor(e,t){this.type=e,this.value=t}static define(){return new ce}}class ce{of(e){return new le(this,e)}}class ue{constructor(e){this.map=e}of(e){return new de(this,e)}}class de{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new de(this.type,t)}is(e){return this.type==e}static define(e={}){return new ue(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let e=s.map(t);e&&i.push(e)}return i}}de.reconfigure=de.define(),de.appendConfig=de.define();class fe{constructor(e,t,i,s,r,n){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=n,this._doc=null,this._state=null,i&&Q(i,t.newLength),r.some((e=>e.type==fe.time))||(this.annotations=r.concat(fe.time.of(Date.now())))}static create(e,t,i,s,r,n){return new fe(e,t,i,s,r,n)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(fe.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function pe(e,t){let i=[];for(let s=0,r=0;;){let n,o;if(s<e.length&&(r==t.length||t[r]>=e[s]))n=e[s++],o=e[s++];else{if(!(r<t.length))return i;n=t[r++],o=t[r++]}!i.length||i[i.length-1]<n?i.push(n,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function ge(e,t,i){var s;let r,n,o;return i?(r=t.changes,n=T.empty(t.changes.length),o=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),n=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(n):null===(s=e.selection)||void 0===s?void 0:s.map(r),effects:de.mapEffects(e.effects,r).concat(de.mapEffects(t.effects,n)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function me(e,t,i){let s=t.selection,r=Oe(t.annotations);return t.userEvent&&(r=r.concat(fe.userEvent.of(t.userEvent))),{changes:t.changes instanceof T?t.changes:T.of(t.changes||[],i,e.facet(re)),selection:s&&(s instanceof I?s:I.single(s.anchor,s.head)),effects:Oe(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function ve(e,t,i){let s=me(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(i=!1);for(let r=1;r<t.length;r++){!1===t[r].filter&&(i=!1);let n=!!t[r].sequential;s=ge(s,me(e,t[r],n?s.changes.newLength:e.doc.length),n)}let r=fe.create(e,s.changes,s.selection,s.effects,s.annotations,s.scrollIntoView);return function(e){let t=e.startState,i=t.facet(ae),s=e;for(let r=i.length-1;r>=0;r--){let n=i[r](e);n&&Object.keys(n).length&&(s=ge(s,me(t,n,e.changes.newLength),!0))}return s==e?e:fe.create(t,e.changes,e.selection,s.effects,s.annotations,s.scrollIntoView)}(i?function(e){let t=e.startState,i=!0;for(let s of t.facet(ne)){let t=s(e);if(!1===t){i=!1;break}Array.isArray(t)&&(i=!0===i?t:pe(i,t))}if(!0!==i){let s,r;if(!1===i)r=e.changes.invertedDesc,s=T.empty(t.doc.length);else{let t=e.changes.filter(i);s=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=fe.create(t,s,e.selection&&e.selection.map(r),de.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let s=t.facet(oe);for(let i=s.length-1;i>=0;i--){let r=s[i](e);e=r instanceof fe?r:Array.isArray(r)&&1==r.length&&r[0]instanceof fe?r[0]:ve(t,Oe(r),!1)}return e}(r):r)}fe.time=le.define(),fe.userEvent=le.define(),fe.addToHistory=le.define(),fe.remote=le.define();const _e=[];function Oe(e){return null==e?_e:Array.isArray(e)?e:[e]}var Se=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Se||(Se={}));const we=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let be;try{be=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class ye{constructor(e,t,i,s,r,n){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,n&&(n._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)ee(this,e<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(null!=i)return ee(this,i),te(this,i);if(t)throw new RangeError("Field is not present in this state")}update(...e){return ve(this,e,!0)}applyTransaction(e){let t,i=this.config,{base:s,compartments:r}=i;for(let t of e.effects)t.is(Z.reconfigure)?(i&&(r=new Map,i.compartments.forEach(((e,t)=>r.set(t,e))),i=null),r.set(t.value.compartment,t.value.extension)):t.is(de.reconfigure)?(i=null,s=t.value):t.is(de.appendConfig)&&(i=null,s=Oe(s).concat(t.value));i?t=e.startState.values.slice():(i=J.resolve(s,r,this),t=new ye(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values);let n=e.startState.facet(se)?e.newSelection:e.newSelection.asSingle();new ye(i,e.newDoc,n,t,((t,i)=>i.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:I.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],n=Oe(i.effects);for(let i=1;i<t.ranges.length;i++){let o=e(t.ranges[i]),a=this.changes(o.changes),h=a.map(s);for(let e=0;e<i;e++)r[e]=r[e].map(h);let l=s.mapDesc(a,!0);r.push(o.range.map(l)),s=s.compose(h),n=de.mapEffects(n,h).concat(de.mapEffects(Oe(o.effects),l))}return{changes:s,selection:I.create(r,t.mainIndex),effects:n}}changes(e=[]){return e instanceof T?e:T.of(e,this.doc.length,this.facet(ye.lineSeparator))}toText(e){return d.of(e.split(this.facet(ye.lineSeparator)||k))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(ee(this,t),te(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof j&&null!=this.config.address[s.id]&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i)for(let t in i)if(Object.prototype.hasOwnProperty.call(e,t)){let r=i[t],n=e[t];s.push(r.init((e=>r.spec.fromJSON(n,e))))}return ye.create({doc:e.doc,selection:I.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=J.resolve(e.extensions||[],new Map),i=e.doc instanceof d?e.doc:d.of((e.doc||"").split(t.staticFacet(ye.lineSeparator)||k)),s=e.selection?e.selection instanceof I?e.selection:I.single(e.selection.anchor,e.selection.head):I.single(0);return Q(s,i.length),t.staticFacet(se)||(s=s.asSingle()),new ye(t,i,s,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(ye.tabSize)}get lineBreak(){return this.facet(ye.lineSeparator)||"\n"}get readOnly(){return this.facet(he)}phrase(e,...t){for(let t of this.facet(ye.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,((e,i)=>{if("$"==i)return"$";let s=+(i||1);return!s||s>t.length?e:t[s-1]}))),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(ie))for(let n of r(this,t,i))Object.prototype.hasOwnProperty.call(n,e)&&s.push(n[e]);return s}charCategorizer(e){return t=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return Se.Space;if(function(e){if(be)return be.test(e);for(let t=0;t<e.length;t++){let i=e[t];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||we.test(i)))return!0}return!1}(e))return Se.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Se.Word;return Se.Other};var t}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),n=e-i,o=e-i;for(;n>0;){let e=b(t,n,!1);if(r(t.slice(e,n))!=Se.Word)break;n=e}for(;o<s;){let e=b(t,o);if(r(t.slice(o,e))!=Se.Word)break;o=e}return n==o?null:I.range(n+i,o+i)}}function De(e,t,i={}){let s={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],n=s[e];if(void 0===n)s[e]=r;else if(n===r||void 0===r);else{if(!Object.hasOwnProperty.call(i,e))throw new Error("Config merge conflict for field "+e);s[e]=i[e](n,r)}}for(let e in t)void 0===s[e]&&(s[e]=t[e]);return s}ye.allowMultipleSelections=se,ye.tabSize=H.define({combine:e=>e.length?e[0]:4}),ye.lineSeparator=re,ye.readOnly=he,ye.phrases=H.define({compare(e,t){let i=Object.keys(e),s=Object.keys(t);return i.length==s.length&&i.every((i=>e[i]==t[i]))}}),ye.languageData=ie,ye.changeFilter=ne,ye.transactionFilter=oe,ye.transactionExtender=ae,Z.reconfigure=de.define();class Ce{eq(e){return this==e}range(e,t=e){return ke.create(e,t,this)}}Ce.prototype.startSide=Ce.prototype.endSide=0,Ce.prototype.point=!1,Ce.prototype.mapMode=x.TrackDel;class ke{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new ke(e,t,i)}}function xe(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class Ee{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let n=s,o=r.length;;){if(n==o)return n;let s=n+o>>1,a=r[s]-e||(i?this.value[s].endSide:this.value[s].startSide)-t;if(s==n)return a>=0?n:o;a>=0?o=s:n=s+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),n=this.findIndex(i,1e9,!1,r);r<n;r++)if(!1===s(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let i=[],s=[],r=[],n=-1,o=-1;for(let a=0;a<this.value.length;a++){let h,l,c=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,c.startSide,c.mapMode);if(null==e)continue;if(h=l=e,c.startSide!=c.endSide&&(l=t.mapPos(u,c.endSide),l<h))continue}else if(h=t.mapPos(u,c.startSide),l=t.mapPos(d,c.endSide),h>l||h==l&&c.startSide>0&&c.endSide<=0)continue;(l-h||c.endSide-c.startSide)<0||(n<0&&(n=h),c.point&&(o=Math.max(o,l-h)),i.push(c),s.push(h-n),r.push(l-n))}return{mapped:i.length?new Ee(s,r,i,o):null,pos:n}}}class Te{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new Te(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,n=e.filter;if(0==t.length&&!n)return this;if(i&&(t=t.slice().sort(xe)),this.isEmpty)return t.length?Te.of(t):this;let o=new Pe(this,null,-1).goto(0),a=0,h=[],l=new Ae;for(;o.value||a<t.length;)if(a<t.length&&(o.from-t[a].from||o.startSide-t[a].value.startSide)>=0){let e=t[a++];l.addInner(e.from,e.to,e.value)||h.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(o.chunkIndex)<t[a].from)&&(!n||s>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&l.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!n||s>o.to||r<o.from||n(o.from,o.to,o.value))&&(l.addInner(o.from,o.to,o.value)||h.push(ke.create(o.from,o.to,o.value))),o.next());return l.finishInner(this.nextLayer.isEmpty&&!h.length?Te.empty:this.nextLayer.update({add:h,filter:n,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],s=-1;for(let r=0;r<this.chunk.length;r++){let n=this.chunkPos[r],o=this.chunk[r],a=e.touchesRange(n,n+o.length);if(!1===a)s=Math.max(s,o.maxPoint),t.push(o),i.push(e.mapPos(n));else if(!0===a){let{mapped:r,pos:a}=o.map(n,e);r&&(s=Math.max(s,r.maxPoint),t.push(r),i.push(a))}}let r=this.nextLayer.map(e);return 0==t.length?r:new Te(i,t,r||Te.empty,s)}between(e,t,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],n=this.chunk[s];if(t>=r&&e<=r+n.length&&!1===n.between(r,e-r,t-r,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return Me.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Me.from(e).goto(t)}static compare(e,t,i,s,r=-1){let n=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),o=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),a=Re(n,o,i),h=new Le(n,a,r),l=new Le(o,a,r);i.iterGaps(((e,t,i)=>Fe(h,e,l,t,i,s))),i.empty&&0==i.length&&Fe(h,0,l,0,0,s)}static eq(e,t,i=0,s){null==s&&(s=999999999);let r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),n=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(r.length!=n.length)return!1;if(!r.length)return!0;let o=Re(r,n),a=new Le(r,o,0).goto(i),h=new Le(n,o,0).goto(i);for(;;){if(a.to!=h.to||!Ie(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let n=new Le(e,null,r).goto(t),o=t,a=n.openStart;for(;;){let e=Math.min(n.to,i);if(n.point){let i=n.activeForPoint(n.to),r=n.pointFrom<t?i.length+1:n.point.startSide<0?i.length:Math.min(i.length,a);s.point(o,e,n.point,i,r,n.pointRank),a=Math.min(n.openEnd(e),i.length)}else e>o&&(s.span(o,e,n.active,a),a=n.openEnd(e));if(n.to>i)return a+(n.point&&n.to>i?1:0);o=n.to,n.next()}}static of(e,t=!1){let i=new Ae;for(let s of e instanceof ke?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i<e.length;i++){let s=e[i];if(xe(t,s)>0)return e.slice().sort(xe);t=s}return e}(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return Te.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=Te.empty;s=s.nextLayer)t=new Te(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}Te.empty=new Te([],[],null,-1),Te.empty.nextLayer=Te.empty;class Ae{finishChunk(e){this.chunks.push(new Ee(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Ae)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(s<0||(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),0))}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Te.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=Te.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Re(e,t,i){let s=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&s.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let n=s.get(e.chunk[t]);null==n||(i?i.mapPos(n):n)!=e.chunkPos[t]||(null==i?void 0:i.touchesRange(n,n+e.chunk[t].length))||r.add(e.chunk[t])}return r}class Pe{constructor(e,t,i,s=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Me{constructor(e){this.heap=e}static from(e,t=null,i=-1){let s=[];for(let r=0;r<e.length;r++)for(let n=e[r];!n.isEmpty;n=n.nextLayer)n.maxPoint>=i&&s.push(new Pe(n,t,i,r));return 1==s.length?s[0]:new Me(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Be(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Be(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Be(this.heap,0)}}}function Be(e,t){for(let i=e[t];;){let s=1+(t<<1);if(s>=e.length)break;let r=e[s];if(s+1<e.length&&r.compare(e[s+1])>=0&&(r=e[s+1],s++),i.compare(r)<0)break;e[s]=i,e[t]=r,t=s}}class Le{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Me.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Qe(this.active,e),Qe(this.activeTo,e),Qe(this.activeRank,e),this.minActive=He(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;We(this.active,t,i),We(this.activeTo,t,s),We(this.activeRank,t,r),e&&We(e,t,this.cursor.from),this.minActive=He(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&Qe(i,s)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let t=i.length-1;t>=0&&i[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Fe(e,t,i,s,r,n){e.goto(t),i.goto(s);let o=s+r,a=s,h=s-t;for(;;){let t=e.to+h-i.to,s=t||e.endSide-i.endSide,r=s<0?e.to+h:i.to,l=Math.min(r,o);if(e.point||i.point?e.point&&i.point&&(e.point==i.point||e.point.eq(i.point))&&Ie(e.activeForPoint(e.to),i.activeForPoint(i.to))||n.comparePoint(a,l,e.point,i.point):l>a&&!Ie(e.active,i.active)&&n.compareRange(a,l,e.active,i.active),r>o)break;(t||e.openEnd!=i.openEnd)&&n.boundChange&&n.boundChange(r),a=r,s<=0&&e.next(),s>=0&&i.next()}}function Ie(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i]&&!e[i].eq(t[i]))return!1;return!0}function Qe(e,t){for(let i=t,s=e.length-1;i<s;i++)e[i]=e[i+1];e.pop()}function We(e,t,i){for(let i=e.length-1;i>=t;i--)e[i+1]=e[i];e[t]=i}function He(e,t){let i=-1,s=1e9;for(let r=0;r<t.length;r++)(t[r]-s||e[r].endSide-e[i].endSide)<0&&(i=r,s=t[r]);return i}function qe(e,t,i=e.length){let s=0;for(let r=0;r<i&&r<e.length;)9==e.charCodeAt(r)?(s+=t-s%t,r++):(s++,r=b(e,r));return s}function $e(e,t,i,s){for(let s=0,r=0;;){if(r>=t)return s;if(s==e.length)break;r+=9==e.charCodeAt(s)?i-r%i:1,s=b(e,s)}return!0===s?-1:e.length}const ze="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Ne="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Ve{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,n,o){let a=[],h=/^@(\w+)\b/.exec(e[0]),l=h&&"keyframes"==h[1];if(h&&null==t)return n.push(e[0]+";");for(let i in t){let o=t[i];if(/&/.test(i))r(i.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),o,n);else if(o&&"object"==typeof o){if(!h)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(s(i),o,a,l)}else null!=o&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+o+";")}(a.length||l)&&n.push((!i||h||o?e:e.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)r(s(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Ue[ze]||1;return Ue[ze]=e+1,"ͼ"+e.toString(36)}static mount(e,t,i){let s=e[Ne],r=i&&i.nonce;s?r&&s.setNonce(r):s=new Xe(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let je=new Map;class Xe{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let t=je.get(i);if(t)return e[Ne]=t;this.sheet=new s.CSSStyleSheet,je.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ne]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let t=0;t<e.length;t++){let n=e[t],o=this.modules.indexOf(n);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,n),i)for(let e=0;e<n.rules.length;e++)i.insertRule(n.rules[e],s++)}else{for(;r<o;)s+=this.modules[r++].rules.length;s+=n.rules.length,r++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let i=t.head||t;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Ge={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ke={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ze="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ye="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Je=0;Je<10;Je++)Ge[48+Je]=Ge[96+Je]=String(Je);for(Je=1;Je<=24;Je++)Ge[Je+111]="F"+Je;for(Je=65;Je<=90;Je++)Ge[Je]=String.fromCharCode(Je+32),Ke[Je]=String.fromCharCode(Je);for(var et in Ge)Ke.hasOwnProperty(et)||(Ke[et]=Ge[et]);function tt(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function it(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function st(e,t){if(!t.anchorNode)return!1;try{return it(e,t.anchorNode)}catch(e){return!1}}function rt(e){return 3==e.nodeType?vt(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function nt(e,t,i,s){return!!i&&(ht(e,t,i,s,-1)||ht(e,t,i,s,1))}function ot(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function at(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function ht(e,t,i,s,r){for(;;){if(e==i&&t==s)return!0;if(t==(r<0?0:lt(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=ot(e)+(r<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?lt(e):0}}}function lt(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ct(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function ut(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function dt(e,t){let i=t.width/e.offsetWidth,s=t.height/e.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.width-e.offsetWidth)<1)&&(i=1),(s>.995&&s<1.005||!isFinite(s)||Math.abs(t.height-e.offsetHeight)<1)&&(s=1),{scaleX:i,scaleY:s}}class ft{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?lt(t):0),i,Math.min(e.focusOffset,i?lt(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let pt,gt=null;function mt(e){if(e.setActive)return e.setActive();if(gt)return e.focus(gt);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==gt?{get preventScroll(){return gt={preventScroll:!0},!0}}:void 0),!gt){gt=!1;for(let e=0;e<t.length;){let i=t[e++],s=t[e++],r=t[e++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=r&&(i.scrollLeft=r)}}}function vt(e,t,i=t){let s=pt||(pt=document.createRange());return s.setEnd(e,i),s.setStart(e,t),s}function _t(e,t,i,s){let r={key:t,code:t,keyCode:i,which:i,cancelable:!0};s&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=s);let n=new KeyboardEvent("keydown",r);n.synthetic=!0,e.dispatchEvent(n);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),n.defaultPrevented||o.defaultPrevented}function Ot(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function St(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function wt(e,t){for(let i=e,s=t;;){if(3==i.nodeType&&s>0)return{node:i,offset:s};if(1==i.nodeType&&s>0){if("false"==i.contentEditable)return null;i=i.childNodes[s-1],s=lt(i)}else{if(!i.parentNode||at(i))return null;s=ot(i),i=i.parentNode}}}function bt(e,t){for(let i=e,s=t;;){if(3==i.nodeType&&s<i.nodeValue.length)return{node:i,offset:s};if(1==i.nodeType&&s<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[s],s=0}else{if(!i.parentNode||at(i))return null;s=ot(i)+1,i=i.parentNode}}}class yt{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new yt(e.parentNode,ot(e),t)}static after(e,t){return new yt(e.parentNode,ot(e)+1,t)}}const Dt=[];class Ct{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let i,s=this.dom,r=null;for(let n of this.children){if(7&n.flags){if(!n.dom&&(i=r?r.nextSibling:s.firstChild)){let e=Ct.get(i);(!e||!e.parent&&e.canReuseDOM(n))&&n.reuseDOM(i)}n.sync(e,t),n.flags&=-8}if(i=r?r.nextSibling:s.firstChild,t&&!t.written&&t.node==s&&i!=n.dom&&(t.written=!0),n.dom.parentNode==s)for(;i&&i!=n.dom;)i=kt(i);else s.insertBefore(n.dom,i);r=n.dom}for(i=r?r.nextSibling:s.firstChild,i&&t&&t.node==s&&(t.written=!0);i;)i=kt(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let s=0==lt(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==s&&t.firstChild!=t.lastChild&&(s=e==t.firstChild?-1:1),e=t}i=s<0?e:e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Ct.get(i);)i=i.nextSibling;if(!i)return this.length;for(let e=0,t=0;;e++){let s=this.children[e];if(s.dom==i)return t;t+=s.length+s.breakAfter}}domBoundsAround(e,t,i=0){let s=-1,r=-1,n=-1,o=-1;for(let a=0,h=i,l=i;a<this.children.length;a++){let i=this.children[a],c=h+i.length;if(h<e&&c>t)return i.domBoundsAround(e,t,h);if(c>=e&&-1==s&&(s=a,r=h),h>t&&i.dom.parentNode==this.dom){n=a,o=l;break}l=c,h=c+i.breakAfter}return{from:r,to:o<0?i+this.length:o,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Dt){this.markDirty();for(let s=e;s<t;s++){let e=this.children[s];e.parent==this&&i.indexOf(e)<0&&e.destroy()}i.length<250?this.children.splice(e,t-e,...i):this.children=[].concat(this.children.slice(0,e),i,this.children.slice(t));for(let e=0;e<i.length;e++)i[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new xt(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,s,r,n){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!(8&(this.flags|e.flags))}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}function kt(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}Ct.prototype.breakAfter=0;class xt{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Et(e,t,i,s,r,n,o,a,h){let{children:l}=e,c=l.length?l[t]:null,u=n.length?n[n.length-1]:null,d=u?u.breakAfter:o;if(!(t==s&&c&&!o&&!d&&n.length<2&&c.merge(i,r,n.length?u:null,0==i,a,h))){if(s<l.length){let e=l[s];e&&(r<e.length||e.breakAfter&&(null==u?void 0:u.breakAfter))?(t==s&&(e=e.split(r),r=0),!d&&u&&e.merge(0,r,u,!0,0,h)?n[n.length-1]=e:((r||e.children.length&&!e.children[0].length)&&e.merge(0,r,null,!1,0,h),n.push(e))):(null==e?void 0:e.breakAfter)&&(u?u.breakAfter=1:o=1),s++}for(c&&(c.breakAfter=o,i>0&&(!o&&n.length&&c.merge(i,c.length,n[0],!1,a,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,a,0),t++));t<s&&n.length;)if(l[s-1].become(n[n.length-1]))s--,n.pop(),h=n.length?0:a;else{if(!l[t].become(n[0]))break;t++,n.shift(),a=n.length?0:h}!n.length&&t&&s<l.length&&!l[t-1].breakAfter&&l[s].merge(0,0,l[t-1],!1,a,h)&&t--,(t<s||n.length)&&e.replaceChildren(t,s,n)}}function Tt(e,t,i,s,r,n){let o=e.childCursor(),{i:a,off:h}=o.findPos(i,1),{i:l,off:c}=o.findPos(t,-1),u=t-i;for(let e of s)u+=e.length;e.length+=u,Et(e,l,c,a,h,s,0,r,n)}let At="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Rt="undefined"!=typeof document?document:{documentElement:{style:{}}};const Pt=/Edge\/(\d+)/.exec(At.userAgent),Mt=/MSIE \d/.test(At.userAgent),Bt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At.userAgent),Lt=!!(Mt||Bt||Pt),Ft=!Lt&&/gecko\/(\d+)/i.test(At.userAgent),It=!Lt&&/Chrome\/(\d+)/.exec(At.userAgent),Qt="webkitFontSmoothing"in Rt.documentElement.style,Wt=!Lt&&/Apple Computer/.test(At.vendor),Ht=Wt&&(/Mobile\/\w+/.test(At.userAgent)||At.maxTouchPoints>2);var qt={mac:Ht||/Mac/.test(At.platform),windows:/Win/.test(At.platform),linux:/Linux|X11/.test(At.platform),ie:Lt,ie_version:Mt?Rt.documentMode||6:Bt?+Bt[1]:Pt?+Pt[1]:0,gecko:Ft,gecko_version:Ft?+(/Firefox\/(\d+)/.exec(At.userAgent)||[0,0])[1]:0,chrome:!!It,chrome_version:It?+It[1]:0,ios:Ht,android:/Android\b/.test(At.userAgent),webkit:Qt,safari:Wt,webkit_version:Qt?+(/\bAppleWebKit\/(\d+)/.exec(At.userAgent)||[0,0])[1]:0,tabSize:null!=Rt.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class $t extends Ct{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,i){return!(8&this.flags||i&&(!(i instanceof $t)||this.length-(t-e)+i.length>256||8&i.flags)||(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),0))}split(e){let t=new $t(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new yt(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,i){let s=e.nodeValue.length;t>s&&(t=s);let r=t,n=t,o=0;0==t&&i<0||t==s&&i>=0?qt.chrome||qt.gecko||(t?(r--,o=1):n<s&&(n++,o=-1)):i<0?r--:n<s&&n++;let a=vt(e,r,n).getClientRects();if(!a.length)return null;let h=a[(o?o<0:i>=0)?0:a.length-1];return qt.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(a,(e=>e.width))||h),o?ct(h,o<0):h||null}(this.dom,e,t)}}class zt extends Ct{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let e of t)e.setParent(this)}setAttrs(e){if(Ot(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!(8&(this.flags|e.flags))}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,s,r,n){return!(i&&(!(i instanceof zt&&i.mark.eq(this.mark))||e&&r<=0||t<this.length&&n<=0)||(Tt(this,e,t,i?i.children.slice():[],r-1,n-1),this.markDirty(),0))}split(e){let t=[],i=0,s=-1,r=0;for(let n of this.children){let o=i+n.length;o>e&&t.push(i<e?n.split(e-i):n),s<0&&i>=e&&(s=r),i=o,r++}let n=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new zt(this.mark,t,n)}domAtPos(e){return Vt(this,e)}coordsAt(e,t){return Xt(this,e,t)}}class Nt extends Ct{static create(e,t,i){return new Nt(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=Nt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,s,r,n){return!(i&&(!(i instanceof Nt&&this.widget.compare(i.widget))||e>0&&r<=0||t<this.length&&n<=0)||(this.length=e+(i?i.length:0)+(this.length-t),0))}become(e){return e instanceof Nt&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return d.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):d.empty}domAtPos(e){return(this.length?0==e:this.side>0)?yt.before(this.dom):yt.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let n=this.side?this.side<0:e>0;for(let t=n?s.length-1:0;r=s[t],!(e>0?0==t:t==s.length-1||r.top<r.bottom);t+=n?-1:1);return ct(r,!n)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ut extends Ct{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Ut&&e.side==this.side}split(){return new Ut(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?yt.before(this.dom):yt.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return d.empty}get isHidden(){return!0}}function Vt(e,t){let i=e.dom,{children:s}=e,r=0;for(let e=0;r<s.length;r++){let n=s[r],o=e+n.length;if(!(o==e&&n.getSide()<=0)){if(t>e&&t<o&&n.dom.parentNode==i)return n.domAtPos(t-e);if(t<=e)break;e=o}}for(let e=r;e>0;e--){let t=s[e-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let e=r;e<s.length;e++){let t=s[e];if(t.dom.parentNode==i)return t.domAtPos(0)}return new yt(i,0)}function jt(e,t,i){let s,{children:r}=e;i>0&&t instanceof zt&&r.length&&(s=r[r.length-1])instanceof zt&&s.mark.eq(t.mark)?jt(s,t.children[0],i-1):(r.push(t),t.setParent(e)),e.length+=t.length}function Xt(e,t,i){let s=null,r=-1,n=null,o=-1;!function e(t,a){for(let h=0,l=0;h<t.children.length&&l<=a;h++){let c=t.children[h],u=l+c.length;u>=a&&(c.children.length?e(c,a-l):(!n||n.isHidden&&i>0)&&(u>a||l==u&&c.getSide()>0)?(n=c,o=a-l):(l<a||l==u&&c.getSide()<0&&!c.isHidden)&&(s=c,r=a-l)),l=u}}(e,t);let a=(i<0?s:n)||s||n;return a?a.coordsAt(Math.max(0,a==s?r:o),i):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let i=rt(t);return i[i.length-1]||null}(e)}function Gt(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}$t.prototype.children=Nt.prototype.children=Ut.prototype.children=Dt;const Kt=Object.create(null);function Zt(e,t,i){if(e==t)return!0;e||(e=Kt),t||(t=Kt);let s=Object.keys(e),r=Object.keys(t);if(s.length-(i&&s.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let n of s)if(n!=i&&(-1==r.indexOf(n)||e[n]!==t[n]))return!1;return!0}function Yt(e,t,i){let s=!1;if(t)for(let r in t)i&&r in i||(s=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(i)for(let r in i)t&&t[r]==i[r]||(s=!0,"style"==r?e.style.cssText=i[r]:e.setAttribute(r,i[r]));return s}function Jt(e){let t=Object.create(null);for(let i=0;i<e.attributes.length;i++){let s=e.attributes[i];t[s.name]=s.value}return t}class ei{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ti=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(ti||(ti={}));class ii extends Ce{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new si(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new ni(e,t,t,i,e.widget||null,!1)}static replace(e){let t,i,s=!!e.block;if(e.isBlockGap)t=-5e8,i=4e8;else{let{start:r,end:n}=oi(e,s);t=(r?s?-3e8:-1:5e8)-1,i=1+(n?s?2e8:1:-6e8)}return new ni(e,t,i,s,e.widget||null,!0)}static line(e){return new ri(e)}static set(e,t=!1){return Te.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ii.none=Te.empty;class si extends ii{constructor(e){let{start:t,end:i}=oi(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof si&&this.tagName==e.tagName&&(this.class||(null===(t=this.attrs)||void 0===t?void 0:t.class))==(e.class||(null===(i=e.attrs)||void 0===i?void 0:i.class))&&Zt(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}si.prototype.point=!1;class ri extends ii{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ri&&this.spec.class==e.spec.class&&Zt(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ri.prototype.mapMode=x.TrackBefore,ri.prototype.point=!0;class ni extends ii{constructor(e,t,i,s,r,n){super(t,i,r,e),this.block=s,this.isReplace=n,this.mapMode=s?t<=0?x.TrackBefore:x.TrackAfter:x.TrackDel}get type(){return this.startSide!=this.endSide?ti.WidgetRange:this.startSide<=0?ti.WidgetBefore:ti.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ni&&((t=this.widget)==(i=e.widget)||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,i}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function oi(e,t=!1){let{inclusiveStart:i,inclusiveEnd:s}=e;return null==i&&(i=e.inclusive),null==s&&(s=e.inclusive),{start:null!=i?i:t,end:null!=s?s:t}}function ai(e,t,i,s=0){let r=i.length-1;r>=0&&i[r]+s>=e?i[r]=Math.max(i[r],t):i.push(e,t)}ni.prototype.point=!0;class hi extends Ct{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,s,r,n){if(i){if(!(i instanceof hi))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),Tt(this,e,t,i?i.children.slice():[],r,n),!0}split(e){let t=new hi;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i,off:s}=this.childPos(e);s&&(t.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let e=i;e<this.children.length;e++)t.append(this.children[e],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Zt(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){jt(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Gt(t,this.attrs||{})),i&&(this.attrs=Gt({class:i},this.attrs||{}))}domAtPos(e){return Vt(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?4&this.flags&&(Ot(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Yt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&Ct.get(s)instanceof zt;)s=s.lastChild;if(!(s&&this.length&&("BR"==s.nodeName||0!=(null===(i=Ct.get(s))||void 0===i?void 0:i.isEditable)||qt.ios&&this.children.some((e=>e instanceof $t))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let i of this.children){if(!(i instanceof $t)||/[^ -~]/.test(i.text))return null;let s=rt(i.dom);if(1!=s.length)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let i=Xt(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=i.bottom-i.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight<t){let s=(t-e.textHeight)/2;return{top:i.top+s,bottom:i.bottom-s,left:i.left,right:i.left}}}return i}become(e){return e instanceof hi&&0==this.children.length&&0==e.children.length&&Zt(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let i=0,s=0;i<e.children.length;i++){let r=e.children[i],n=s+r.length;if(n>=t){if(r instanceof hi)return r;if(n>t)break}s=n+r.breakAfter}return null}}class li extends Ct{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,r,n){return!(i&&(!(i instanceof li&&this.widget.compare(i.widget))||e>0&&r<=0||t<this.length&&n<=0)||(this.length=e+(i?i.length:0)+(this.length-t),0))}domAtPos(e){return 0==e?yt.before(this.dom):yt.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new li(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Dt}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):d.empty}domBoundsAround(){return null}become(e){return e instanceof li&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)||(this.widget instanceof ci?null:ct(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t!=i&&(e<0?t<0:i>0)}}class ci extends ei{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class ui{constructor(e,t,i,s){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof li&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new hi),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(di(new Ut(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof li||this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:s}=this.cursor.next(this.skip);if(this.skip=0,s)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(di(new $t(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,r,n){if(this.disallowBlockEffectsFor[n]&&i instanceof ni){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=t-e;if(i instanceof ni)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new li(i.widget||fi.block,o,i));else{let n=Nt.create(i.widget||fi.inline,o,o?0:i.startSide),a=this.atCursorPos&&!n.isEditable&&r<=s.length&&(e<t||i.startSide>0),h=!n.isEditable&&(e<t||r>s.length||i.startSide<=0),l=this.getLine();2!=this.pendingBuffer||a||n.isEditable||(this.pendingBuffer=0),this.flushBuffer(s),a&&(l.append(di(new Ut(1),s),r),r=s.length+Math.max(0,r-s.length)),l.append(di(n,s),r),this.atCursorPos=h,this.pendingBuffer=h?e<t||r>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,s,r){let n=new ui(e,t,i,r);return n.openEnd=Te.spans(s,t,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}}function di(e,t){for(let i of t)e=new zt(i,[e],e.length);return e}class fi extends ei{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}fi.inline=new fi("span"),fi.block=new fi("div");var pi=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(pi||(pi={}));const gi=pi.LTR,mi=pi.RTL;function vi(e){let t=[];for(let i=0;i<e.length;i++)t.push(1<<+e[i]);return t}const _i=vi("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Oi=vi("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Si=Object.create(null),wi=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),i=e.charCodeAt(1);Si[t]=i,Si[i]=-t}function bi(e){return e<=247?_i[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Oi[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const yi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Di{get dir(){return this.level%2?mi:gi}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,s){let r=-1;for(let n=0;n<e.length;n++){let o=e[n];if(o.from<=t&&o.to>=t){if(o.level==i)return n;(r<0||(0!=s?s<0?o.from<t:o.to>t:e[r].level>o.level))&&(r=n)}}if(r<0)throw new RangeError("Index out of range");return r}}function Ci(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],r=t[i];if(s.from!=r.from||s.to!=r.to||s.direction!=r.direction||!Ci(s.inner,r.inner))return!1}return!0}const ki=[];function xi(e,t,i,s,r,n,o){let a=s%2?2:1;if(s%2==r%2)for(let h=t,l=0;h<i;){let t=!0,c=!1;if(l==n.length||h<n[l].from){let e=ki[h];e!=a&&(t=!1,c=16==e)}let u=t||1!=a?null:[],d=t?s:s+1,f=h;e:for(;;)if(l<n.length&&f==n[l].from){if(c)break e;let p=n[l];if(!t)for(let e=p.to,t=l+1;;){if(e==i)break e;if(!(t<n.length&&n[t].from==e)){if(ki[e]==a)break e;break}e=n[t++].to}l++,u?u.push(p):(p.from>h&&o.push(new Di(h,p.from,d)),Ei(e,p.direction==gi!=!(d%2)?s+1:s,r,p.inner,p.from,p.to,o),h=p.to),f=p.to}else{if(f==i||(t?ki[f]!=a:ki[f]==a))break;f++}u?xi(e,h,f,s+1,r,u,o):h<f&&o.push(new Di(h,f,d)),h=f}else for(let h=i,l=n.length;h>t;){let i=!0,c=!1;if(!l||h>n[l-1].to){let e=ki[h-1];e!=a&&(i=!1,c=16==e)}let u=i||1!=a?null:[],d=i?s:s+1,f=h;e:for(;;)if(l&&f==n[l-1].to){if(c)break e;let p=n[--l];if(!i)for(let e=p.from,i=l;;){if(e==t)break e;if(!i||n[i-1].to!=e){if(ki[e-1]==a)break e;break}e=n[--i].from}u?u.push(p):(p.to<h&&o.push(new Di(p.to,h,d)),Ei(e,p.direction==gi!=!(d%2)?s+1:s,r,p.inner,p.from,p.to,o),h=p.from),f=p.from}else{if(f==t||(i?ki[f-1]!=a:ki[f-1]==a))break;f--}u?xi(e,f,h,s+1,r,u,o):f<h&&o.push(new Di(f,h,d)),h=f}}function Ei(e,t,i,s,r,n,o){let a=t%2?2:1;!function(e,t,i,s,r){for(let n=0;n<=s.length;n++){let o=n?s[n-1].to:t,a=n<s.length?s[n].from:i,h=n?256:r;for(let t=o,i=h,s=h;t<a;t++){let r=bi(e.charCodeAt(t));512==r?r=i:8==r&&4==s&&(r=16),ki[t]=4==r?2:r,7&r&&(s=r),i=r}for(let e=o,t=h,s=h;e<a;e++){let r=ki[e];if(128==r)e<a-1&&t==ki[e+1]&&24&t?r=ki[e]=t:ki[e]=256;else if(64==r){let r=e+1;for(;r<a&&64==ki[r];)r++;let n=e&&8==t||r<i&&8==ki[r]?1==s?1:8:256;for(let t=e;t<r;t++)ki[t]=n;e=r-1}else 8==r&&1==s&&(ki[e]=1);t=r,7&r&&(s=r)}}}(e,r,n,s,a),function(e,t,i,s,r){let n=1==r?2:1;for(let o=0,a=0,h=0;o<=s.length;o++){let l=o?s[o-1].to:t,c=o<s.length?s[o].from:i;for(let t,i,s,o=l;o<c;o++)if(i=Si[t=e.charCodeAt(o)])if(i<0){for(let e=a-3;e>=0;e-=3)if(wi[e+1]==-i){let t=wi[e+2],i=2&t?r:4&t?1&t?n:r:0;i&&(ki[o]=ki[wi[e]]=i),a=e;break}}else{if(189==wi.length)break;wi[a++]=o,wi[a++]=t,wi[a++]=h}else if(2==(s=ki[o])||1==s){let e=s==r;h=e?0:1;for(let t=a-3;t>=0;t-=3){let i=wi[t+2];if(2&i)break;if(e)wi[t+2]|=2;else{if(4&i)break;wi[t+2]|=4}}}}}(e,r,n,s,a),function(e,t,i,s){for(let r=0,n=s;r<=i.length;r++){let o=r?i[r-1].to:e,a=r<i.length?i[r].from:t;for(let h=o;h<a;){let o=ki[h];if(256==o){let o=h+1;for(;;)if(o==a){if(r==i.length)break;o=i[r++].to,a=r<i.length?i[r].from:t}else{if(256!=ki[o])break;o++}let l=1==n,c=l==(1==(o<t?ki[o]:s))?l?1:2:s;for(let t=o,s=r,n=s?i[s-1].to:e;t>h;)t==n&&(t=i[--s].from,n=s?i[s-1].to:e),ki[--t]=c;h=o}else n=o,h++}}}(r,n,s,a),xi(e,r,n,t,i,s,o)}function Ti(e){return[new Di(0,e,0)]}let Ai="";function Ri(e,t,i,s,r){var n;let o=s.head-e.from,a=Di.find(t,o,null!==(n=s.bidiLevel)&&void 0!==n?n:-1,s.assoc),h=t[a],l=h.side(r,i);if(o==l){let e=a+=r?1:-1;if(e<0||e>=t.length)return null;h=t[a=e],o=h.side(!r,i),l=h.side(r,i)}let c=b(e.text,o,h.forward(r,i));(c<h.from||c>h.to)&&(c=l),Ai=e.text.slice(Math.min(o,c),Math.max(o,c));let u=a==(r?t.length-1:0)?null:t[a+(r?1:-1)];return u&&c==l&&u.level+(r?0:1)<h.level?I.cursor(u.side(!r,i)+e.from,u.forward(r,i)?1:-1,u.level):I.cursor(c+e.from,h.forward(r,i)?-1:1,h.level)}function Pi(e,t,i){for(let s=t;s<i;s++){let t=bi(e.charCodeAt(s));if(1==t)return gi;if(2==t||4==t)return mi}return gi}const Mi=H.define(),Bi=H.define(),Li=H.define(),Fi=H.define(),Ii=H.define(),Qi=H.define(),Wi=H.define(),Hi=H.define(),qi=H.define(),$i=H.define({combine:e=>e.some((e=>e))}),zi=H.define({combine:e=>e.some((e=>e))}),Ni=H.define();class Ui{constructor(e,t="nearest",i="nearest",s=5,r=5,n=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=n}map(e){return e.empty?this:new Ui(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ui(I.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Vi=de.define({map:(e,t)=>e.map(t)}),ji=de.define();function Xi(e,t,i){let s=e.facet(Fi);s.length?s[0](t):window.onerror?window.onerror(String(t),i,void 0,void 0,t):i?console.error(i+":",t):console.error(t)}const Gi=H.define({combine:e=>!e.length||e[0]});let Ki=0;const Zi=H.define();class Yi{constructor(e,t,i,s,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=s,this.extension=r(this)}static define(e,t){const{eventHandlers:i,eventObservers:s,provide:r,decorations:n}=t||{};return new Yi(Ki++,e,i,s,(e=>{let t=[Zi.of(e)];return n&&t.push(is.of((t=>{let i=t.plugin(e);return i?n(i):ii.none}))),r&&t.push(r(e)),t}))}static fromClass(e,t){return Yi.define((t=>new e(t)),t)}}class Ji{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Xi(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Xi(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Xi(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const es=H.define(),ts=H.define(),is=H.define(),ss=H.define(),rs=H.define(),ns=H.define();function os(e,t){let i=e.state.facet(ns);if(!i.length)return i;let s=i.map((t=>t instanceof Function?t(e):t)),r=[];return Te.spans(s,t.from,t.to,{point(){},span(e,i,s,n){let o=e-t.from,a=i-t.from,h=r;for(let e=s.length-1;e>=0;e--,n--){let i,r=s[e].spec.bidiIsolate;if(null==r&&(r=Pi(t.text,o,a)),n>0&&h.length&&(i=h[h.length-1]).to==o&&i.direction==r)i.to=a,h=i.inner;else{let e={from:o,to:a,direction:r,inner:[]};h.push(e),h=e.inner}}}}),r}const as=H.define();function hs(e){let t=0,i=0,s=0,r=0;for(let n of e.state.facet(as)){let o=n(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(s=Math.max(s,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:t,right:i,top:s,bottom:r}}const ls=H.define();class cs{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new cs(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(0==t.length)return e;let i=[];for(let s=0,r=0,n=0,o=0;;s++){let a=s==e.length?null:e[s],h=n-o,l=a?a.fromB:1e9;for(;r<t.length&&t[r]<l;){let e=t[r],s=t[r+1],n=Math.max(o,e),a=Math.min(l,s);if(n<=a&&new cs(n+h,a+h,n,a).addToSet(i),s>l)break;r+=2}if(!a)return i;new cs(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),n=a.toA,o=a.toB}}}class us{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=T.empty(this.startState.doc.length);for(let e of i)this.changes=this.changes.compose(e.changes);let s=[];this.changes.iterChangedRanges(((e,t,i,r)=>s.push(new cs(e,t,i,r)))),this.changedRanges=s}static create(e,t,i){return new us(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class ds extends Ct{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=ii.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new hi],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new cs(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?s=this.domChanged.newSel.head:function(e,t){let i=!1;return t&&e.iterChangedRanges(((e,s)=>{e<t.to&&s>t.from&&(i=!0)})),i}(e.changes,this.hasComposition)||e.selectionSet||(s=e.state.selection.main.head));let r=s>-1?function(e,t,i){let s=fs(e,i);if(!s)return null;let{node:r,from:n,to:o}=s,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(s.from,s.to)!=a)return null;let h=t.invertedDesc,l=new cs(h.mapPos(n),h.mapPos(o),n,o),c=[];for(let t=r.parentNode;;t=t.parentNode){let i=Ct.get(t);if(i instanceof zt)c.push({node:t,deco:i.mark});else{if(i instanceof hi||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:l,text:r,marks:c,line:t};if(t==e.contentDOM)return null;c.push({node:t,deco:new si({inclusive:!0,attributes:Jt(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:s}=this.hasComposition;i=new cs(t,s,e.changes.mapPos(t,-1),e.changes.mapPos(s,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(qt.ie||qt.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let n=function(e,t,i){let s=new ps;return Te.compare(e,t,i,s),s.changes}(this.decorations,this.updateDeco(),e.changes);return i=cs.extendWithRanges(i,n),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:s}=this.view;s.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=qt.chrome||qt.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||s.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((e=>e.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof li&&e.widget instanceof ci&&r.push(e.dom);s.updateGaps(r)}updateChildren(e,t,i){let s=i?i.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let e=s.length-1;;e--){let t=e>=0?s[e]:null;if(!t)break;let n,o,a,h,{fromA:l,toA:c,fromB:u,toB:d}=t;if(i&&i.range.fromB<d&&i.range.toB>u){let e=ui.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),t=ui.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);o=e.breakAtStart,a=e.openStart,h=t.openEnd;let s=this.compositionView(i);t.breakAtStart?s.breakAfter=1:t.content.length&&s.merge(s.length,s.length,t.content[0],!1,t.openStart,0)&&(s.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&s.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),n=e.content.concat(s).concat(t.content)}else({content:n,breakAtStart:o,openStart:a,openEnd:h}=ui.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=r.findPos(c,1),{i:g,off:m}=r.findPos(l,-1);Et(this,g,m,f,p,n,o,a,h)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(ji)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new $t(e.text.nodeValue);t.flags|=8;for(let{deco:i}of e.marks)t=new zt(i,[t],t.length);let i=new hi;return i.append(t,0),i}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|(t.children.some((e=>7&e.flags))?1:0),this.markedForComposition.add(t);let i=Ct.get(e);i&&i!=t&&(i.dom=null),t.setDOM(e)},i=this.childPos(e.range.fromB,1),s=this.children[i.i];t(e.line,s);for(let r=e.marks.length-1;r>=-1;r--)i=s.childPos(i.off,1),s=s.children[i.i],t(r>=0?e.marks[r].node:e.text,s)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom,r=!s&&!(this.view.state.facet(Gi)||this.dom.tabIndex>-1)&&st(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||t||r))return;let n=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(o.anchor)),h=o.empty?a:this.moveToLine(this.domAtPos(o.head));if(qt.gecko&&o.empty&&!this.hasComposition&&1==(l=a).node.nodeType&&l.node.firstChild&&(0==l.offset||"false"==l.node.childNodes[l.offset-1].contentEditable)&&(l.offset==l.node.childNodes.length||"false"==l.node.childNodes[l.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null))),a=h=new yt(e,0),n=!0}var l;let c=this.view.observer.selectionRange;!n&&c.focusNode&&(nt(a.node,a.offset,c.anchorNode,c.anchorOffset)&&nt(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{qt.android&&qt.chrome&&this.dom.contains(c.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=tt(this.view.root);if(e)if(o.empty){if(qt.gecko){let e=(t=a.node,s=a.offset,1!=t.nodeType?0:(s&&"false"==t.childNodes[s-1].contentEditable?1:0)|(s<t.childNodes.length&&"false"==t.childNodes[s].contentEditable?2:0));if(e&&3!=e){let t=(1==e?wt:bt)(a.node,a.offset);t&&(a=new yt(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=o.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=o.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(h.node,h.offset)}catch(e){}}else{let t=document.createRange();o.anchor>o.head&&([a,h]=[h,a]),t.setEnd(h.node,h.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}var t,s;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new yt(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new yt(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&nt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=tt(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!(i&&t.empty&&t.assoc&&i.modify))return;let n=hi.find(this,t.head);if(!n)return;let o=n.posAtStart;if(t.head==o||t.head==o+n.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let l=this.domAtPos(t.head+t.assoc);i.collapse(l.node,l.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(s,r)}moveToLine(e){let t,i=this.dom;if(e.node!=i)return e;for(let s=e.offset;!t&&s<i.childNodes.length;s++){let e=Ct.get(i.childNodes[s]);e instanceof hi&&(t=e.domAtPos(0))}for(let s=e.offset-1;!t&&s>=0;s--){let e=Ct.get(i.childNodes[s]);e instanceof hi&&(t=e.domAtPos(e.length))}return t?new yt(t.node,t.offset,!0):e}nearest(e){for(let t=e;t;){let e=Ct.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(i<e.length||e instanceof hi)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,s=0;for(let r=this.length,n=this.children.length-1;n>=0;n--){let o=this.children[n],a=r-o.breakAfter,h=a-o.length;if(a<e)break;if(h<=e&&(h<e||o.covers(-1))&&(a>e||o.covers(1))&&(!i||o instanceof hi&&!(i instanceof hi&&t>=0)))i=o,s=h;else if(i&&h==e&&a==e&&o instanceof li&&Math.abs(t)<2){if(o.deco.startSide<0)break;n&&(i=null)}r=h}return i?i.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),s=this.children[t];if(!(s instanceof hi))return null;for(;s.children.length;){let{i:e,off:t}=s.childPos(i,1);for(;;e++){if(e==s.children.length)return null;if((s=s.children[e]).length)break}i=t}if(!(s instanceof $t))return null;let r=b(s.text,i);if(r==i)return null;let n=vt(s.dom,i,r).getClientRects();for(let e=0;e<n.length;e++){let t=n[e];if(e==n.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,n=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==pi.LTR;for(let e=0,h=0;h<this.children.length;h++){let l=this.children[h],c=e+l.length;if(c>s)break;if(e>=i){let i=l.dom.getBoundingClientRect();if(t.push(i.height),n){let t=l.dom.lastChild,s=t?rt(t):[];if(s.length){let t=s[s.length-1],n=a?t.right-i.left:i.right-t.left;n>o&&(o=n,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=c)}}}e=c+l.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?pi.RTL:pi.LTR}measureTextSize(){for(let e of this.children)if(e instanceof hi){let t=e.measureTextSize();if(t)return t}let e,t,i,s=document.createElement("div");return s.className="cm-line",s.style.width="99999px",s.style.position="absolute",s.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(s);let r=rt(s.firstChild)[0];e=s.getBoundingClientRect().height,t=r?r.width/27:7,i=r?r.height:e,s.remove()})),{lineHeight:e,charWidth:t,textHeight:i}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new xt(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],n=r?r.from-1:this.length;if(n>i){let s=(t.lineBlockAt(n).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(ii.replace({widget:new ci(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!r)break;i=r.to+1}return ii.set(e)}updateDeco(){let e=1,t=this.view.state.facet(is).map((t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t)),i=!1,s=this.view.state.facet(ss).map(((e,t)=>{let s="function"==typeof e;return s&&(i=!0),s?e(this.view):e}));for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(Te.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Ni))try{if(t(this.view,e.range,e))return!0}catch(e){Xi(this.view.state,e,"scroll handler")}let t,{range:i}=e,s=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!s)return;!i.empty&&(t=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(s={left:Math.min(s.left,t.left),top:Math.min(s.top,t.top),right:Math.max(s.right,t.right),bottom:Math.max(s.bottom,t.bottom)});let r=hs(this.view),n={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:o,offsetHeight:a}=this.view.scrollDOM;!function(e,t,i,s,r,n,o,a){let h=e.ownerDocument,l=h.defaultView||window;for(let c=e,u=!1;c&&!u;)if(1==c.nodeType){let e,d=c==h.body,f=1,p=1;if(d)e=ut(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=dt(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==r)t.top<e.top?(m=-(e.top-t.top+o),i>0&&t.bottom>e.bottom+m&&(m=t.bottom-e.bottom+m+o)):t.bottom>e.bottom&&(m=t.bottom-e.bottom+o,i<0&&t.top-m<e.top&&(m=-(e.top+m-t.top+o)));else{let s=t.bottom-t.top,n=e.bottom-e.top;m=("center"==r&&s<=n?t.top+s/2-n/2:"start"==r||"center"==r&&i<0?t.top-o:t.bottom-n+o)-e.top}if("nearest"==s?t.left<e.left?(g=-(e.left-t.left+n),i>0&&t.right>e.right+g&&(g=t.right-e.right+g+n)):t.right>e.right&&(g=t.right-e.right+n,i<0&&t.left<e.left+g&&(g=-(e.left+g-t.left+n))):g=("center"==s?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==s==a?t.left-n:t.right-(e.right-e.left)+n)-e.left,g||m)if(d)l.scrollBy(g,m);else{let e=0,i=0;if(m){let e=c.scrollTop;c.scrollTop+=m/p,i=(c.scrollTop-e)*p}if(g){let t=c.scrollLeft;c.scrollLeft+=g/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-i,right:t.right-e,bottom:t.bottom-i},e&&Math.abs(e-g)<1&&(s="nearest"),i&&Math.abs(i-m)<1&&(r="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,n,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==pi.LTR)}}function fs(e,t){let i=e.observer.selectionRange;if(!i.focusNode)return null;let s=wt(i.focusNode,i.focusOffset),r=bt(i.focusNode,i.focusOffset),n=s||r;if(r&&s&&r.node!=s.node){let t=Ct.get(r.node);if(!t||t instanceof $t&&t.text!=r.node.nodeValue)n=r;else if(e.docView.lastCompositionAfterCursor){let e=Ct.get(s.node);!e||e instanceof $t&&e.text!=s.node.nodeValue||(n=r)}}if(e.docView.lastCompositionAfterCursor=n!=s,!n)return null;let o=t-n.offset;return{from:o,to:o+n.node.nodeValue.length,node:n.node}}let ps=class{constructor(){this.changes=[]}compareRange(e,t){ai(e,t,this.changes)}comparePoint(e,t){ai(e,t,this.changes)}boundChange(e){ai(e,e,this.changes)}};function gs(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function ms(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function vs(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function _s(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function Os(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function Ss(e,t,i){let s,r,n,o,a,h,l,c,u=!1;for(let d=e.firstChild;d;d=d.nextSibling){let e=rt(d);for(let f=0;f<e.length;f++){let p=e[f];r&&vs(r,p)&&(p=_s(Os(p,r.bottom),r.top));let g=gs(t,p),m=ms(i,p);if(0==g&&0==m)return 3==d.nodeType?ws(d,t,i):Ss(d,t,i);if(!s||o>m||o==m&&n>g){s=d,r=p,n=g,o=m;let a=m?i<p.top?-1:1:g?t<p.left?-1:1:0;u=!a||(a>0?f<e.length-1:f>0)}0==g?i>p.bottom&&(!l||l.bottom<p.bottom)?(a=d,l=p):i<p.top&&(!c||c.top>p.top)&&(h=d,c=p):l&&vs(l,p)?l=Os(l,p.bottom):c&&vs(c,p)&&(c=_s(c,p.top))}}if(l&&l.bottom>=i?(s=a,r=l):c&&c.top<=i&&(s=h,r=c),!s)return{node:e,offset:0};let d=Math.max(r.left,Math.min(r.right,t));return 3==s.nodeType?ws(s,d,i):u&&"false"!=s.contentEditable?Ss(s,d,i):{node:e,offset:Array.prototype.indexOf.call(e.childNodes,s)+(t>=(r.left+r.right)/2?1:0)}}function ws(e,t,i){let s=e.nodeValue.length,r=-1,n=1e9,o=0;for(let a=0;a<s;a++){let s=vt(e,a,a+1).getClientRects();for(let h=0;h<s.length;h++){let l=s[h];if(l.top==l.bottom)continue;o||(o=t-l.left);let c=(l.top>i?l.top-i:i-l.bottom)-1;if(l.left-1<=t&&l.right+1>=t&&c<n){let i=t>=(l.left+l.right)/2,s=i;if((qt.chrome||qt.gecko)&&vt(e,a).getBoundingClientRect().left==l.right&&(s=!i),c<=0)return{node:e,offset:a+(s?1:0)};r=a+(s?1:0),n=c}}}return{node:e,offset:r>-1?r:o>0?e.nodeValue.length:0}}function bs(e,t,i,s=-1){var r,n;let o,a=e.contentDOM.getBoundingClientRect(),h=a.top+e.viewState.paddingTop,{docHeight:l}=e.viewState,{x:c,y:u}=t,d=u-h;if(d<0)return 0;if(d>l)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,r=!1;o=e.elementAtHeight(d),o.type!=ti.Text;)for(;d=s>0?o.bottom+t:o.top-t,!(d>=0&&d<=l);){if(r)return i?null:0;r=!0,s=-s}u=h+d;let f=o.from;if(f<e.viewport.from)return 0==e.viewport.from?0:i?null:ys(e,a,o,c,u);if(f>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:i?null:ys(e,a,o,c,u);let p=e.dom.ownerDocument,g=e.root.elementFromPoint?e.root:p,m=g.elementFromPoint(c,u);m&&!e.contentDOM.contains(m)&&(m=null),m||(c=Math.max(a.left+1,Math.min(a.right-1,c)),m=g.elementFromPoint(c,u),m&&!e.contentDOM.contains(m)&&(m=null));let v,_=-1;if(m&&0!=(null===(r=e.docView.nearest(m))||void 0===r?void 0:r.isEditable)){if(p.caretPositionFromPoint){let e=p.caretPositionFromPoint(c,u);e&&({offsetNode:v,offset:_}=e)}else if(p.caretRangeFromPoint){let t=p.caretRangeFromPoint(c,u);t&&(({startContainer:v,startOffset:_}=t),(!e.contentDOM.contains(v)||qt.safari&&function(e,t,i){let s;if(3!=e.nodeType||t!=(s=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return vt(e,s-1,s).getBoundingClientRect().left>i}(v,_,c)||qt.chrome&&function(e,t,i){if(0!=t)return!1;for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}return i-(1==e.nodeType?e.getBoundingClientRect():vt(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,_,c))&&(v=void 0))}v&&(_=Math.min(lt(v),_))}if(!v||!e.docView.dom.contains(v)){let t=hi.find(e.docView,f);if(!t)return d>o.top+o.height/2?o.to:o.from;({node:v,offset:_}=Ss(t.dom,c,u))}let O=e.docView.nearest(v);if(!O)return null;if(O.isWidget&&1==(null===(n=O.dom)||void 0===n?void 0:n.nodeType)){let e=O.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?O.posAtStart:O.posAtEnd}return O.localPosFromDOM(v,_)+O.posAtStart}function ys(e,t,i,s,r){let n=Math.round((s-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&i.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;n+=Math.floor((r-i.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(i.from,i.to);return i.from+$e(o,n,e.state.tabSize)}function Ds(e,t){let i=e.lineBlockAt(t);if(Array.isArray(i.type))for(let e of i.type)if(e.to>t||e.to==t&&(e.to==i.to||e.type==ti.Text))return e;return i}function Cs(e,t,i,s){let r=e.state.doc.lineAt(t.head),n=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let a=t,h=null;;){let t=Ri(r,n,o,a,i),l=Ai;if(!t){if(r.number==(i?e.state.doc.lines:1))return a;l="\n",r=e.state.doc.line(r.number+(i?1:-1)),n=e.bidiSpans(r),t=e.visualLineSide(r,!i)}if(h){if(!h(l))return a}else{if(!s)return t;h=s(l)}a=t}}function ks(e,t,i){for(;;){let s=0;for(let r of e)r.between(t-1,t+1,((e,r,n)=>{if(t>e&&t<r){let n=s||i||(t-e<r-t?-1:1);t=n<0?e:r,s=n}}));if(!s)return t}}function xs(e,t,i){let s=ks(e.state.facet(rs).map((t=>t(e))),i.from,t.head>i.from?-1:1);return s==i.from?i:I.cursor(s,s<i.from?1:-1)}const Es="";class Ts{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(ye.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Es}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let e=this.text.length;this.readNode(s);let r=s.nextSibling;if(r==t)break;let n=Ct.get(s),o=Ct.get(r);(n&&o?n.breakAfter:(n?n.breakAfter:at(s))||at(r)&&("BR"!=s.nodeName||s.cmIgnore)&&this.text.length>e)&&this.lineBreak(),s=r}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r,n=-1,o=1;if(this.lineSeparator?(n=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(r=s.exec(t))&&(n=r.index,o=r[0].length),this.append(t.slice(i,n<0?t.length:n)),n<0)break;if(this.lineBreak(),o>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=o-1);i=n+o}}readNode(e){if(e.cmIgnore)return;let t=Ct.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(As(e,i.node,i.offset)?t:0))}}function As(e,t,i){for(;;){if(!t||i<lt(t))return!1;if(t==e)return!0;i=ot(t)+1,t=t.parentNode}}class Rs{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Ps{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:n}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let t=r||n?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:n}=e.observer.selectionRange;return i&&(t.push(new Rs(i,s)),r==i&&n==s||t.push(new Rs(r,n))),t}(e),i=new Ts(t,e.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(e,t){if(0==e.length)return null;let i=e[0].pos,s=2==e.length?e[1].pos:i;return i>-1&&s>-1?I.single(i+t,s+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,i=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!it(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),s=n&&n.node==t.anchorNode&&n.offset==t.anchorOffset||!it(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),o=e.viewport;if((qt.ios||qt.chrome)&&e.state.selection.main.empty&&i!=s&&(o.from>0||o.to<e.state.doc.length)){let t=Math.min(i,s),r=Math.max(i,s),n=o.from-t,a=o.to-r;0!=n&&1!=n&&0!=t||0!=a&&-1!=a&&r!=e.state.doc.length||(i=0,s=e.state.doc.length)}this.newSel=I.single(s,i)}}}function Ms(e,t){let i,{newSel:s}=t,r=e.state.selection.main,n=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:s,to:o}=t.bounds,a=r.from,h=null;(8===n||qt.android&&t.text.length<o-s)&&(a=r.to,h="end");let l=function(e,t,i,s){let r=Math.min(e.length,t.length),n=0;for(;n<r&&e.charCodeAt(n)==t.charCodeAt(n);)n++;if(n==r&&e.length==t.length)return null;let o=e.length,a=t.length;for(;o>0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;return"end"==s&&(i-=o+Math.max(0,n-Math.min(o,a))-n),o<n&&e.length<t.length?(n-=i<=n&&i>=o?n-i:0,a=n+(a-o),o=n):a<n&&(n-=i<=n&&i>=a?n-i:0,o=n+(o-a),a=n),{from:n,toA:o,toB:a}}(e.state.doc.sliceString(s,o,Es),t.text,a-s,h);l&&(qt.chrome&&13==n&&l.toB==l.from+2&&t.text.slice(l.from,l.toB)==Es+Es&&l.toB--,i={from:s+l.from,to:s+l.toA,insert:d.of(t.text.slice(l.from,l.toB).split(Es))})}else s&&(!e.hasFocus&&e.state.facet(Gi)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&t.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(qt.mac||qt.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=I.single(s.main.anchor-1,s.main.head-1)),i={from:i.from,to:i.to,insert:d.of([i.insert.toString().replace("."," ")])}):i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,i.from).append(i.insert).append(e.state.doc.slice(i.to,r.to))}:qt.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&e.lineWrapping&&(s&&(s=I.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:d.of([" "])}),i)return Bs(e,i,s,n);if(s&&!s.main.eq(r)){let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin),e.dispatch({selection:s,scrollIntoView:t,userEvent:i}),!0}return!1}function Bs(e,t,i,s=-1){if(qt.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(qt.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&" "==e.state.sliceDoc(t.from,r.from))&&1==t.insert.length&&2==t.insert.lines&&_t(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&0==t.insert.length||8==s&&t.insert.length<t.to-t.from&&t.to>r.head)&&_t(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&0==t.insert.length&&_t(e.contentDOM,"Delete",46)))return!0;let n,o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>n||(n=function(e,t,i){let s,r=e.state,n=r.selection.main;if(t.from>=n.from&&t.to<=n.to&&t.to-t.from>=(n.to-n.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let i=n.from<t.from?r.sliceDoc(n.from,t.from):"",o=n.to>t.to?r.sliceDoc(t.to,n.to):"";s=r.replaceSelection(e.state.toText(i+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=r.changes(t),a=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=n.to&&t.to>=n.to-10){let h,l=e.state.sliceDoc(t.from,t.to),c=i&&fs(e,i.main.head);if(c){let e=t.insert.length-(t.to-t.from);h={from:c.from,to:c.to-e}}else h=e.state.doc.lineAt(n.head);let u=n.to-t.to,d=n.to-n.from;s=r.changeByRange((i=>{if(i.from==n.from&&i.to==n.to)return{changes:o,range:a||i.map(o)};let s=i.to-u,c=s-l.length;if(i.to-i.from!=d||e.state.sliceDoc(c,s)!=l||i.to>=h.from&&i.from<=h.to)return{range:i};let f=r.changes({from:c,to:s,insert:t.insert}),p=i.to-n.to;return{changes:f,range:a?I.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}}))}else s={changes:o,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,o+=".compose",e.inputState.compositionFirstChange&&(o+=".start",e.inputState.compositionFirstChange=!1)),r.update(s,{userEvent:o,scrollIntoView:!0})}(e,t,i));return e.state.facet(Qi).some((i=>i(e,t.from,t.to,o,a)))||e.dispatch(a()),!0}class Ls{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,qt.safari&&e.contentDOM.addEventListener("input",(()=>null)),qt.gecko&&function(e){hr.has(e)||(hr.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{})))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i,s=t.target;s!=e.contentDOM;s=s.parentNode)if(!s||11==s.nodeType||(i=Ct.get(s))&&i.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then((()=>this.runHandlers(e.type,e))):this.runHandlers(e.type,e)))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let e of i.observers)e(this.view,t);for(let e of i.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Is(e),i=this.handlers,s=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,n=i[e];n&&r!=!n.handlers.length&&(s.removeEventListener(e,this.handleEvent),n=null),n||s.addEventListener(e,this.handleEvent,{passive:r})}for(let e in i)"scroll"==e||t[e]||s.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&Hs.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),qt.android&&qt.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!qt.ios||e.synthetic||e.altKey||e.metaKey||!((t=Qs.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Ws.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,_t(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(qt.safari&&!qt.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Fs(e,t){return(i,s)=>{try{return t.call(e,s,i)}catch(e){Xi(i.state,e)}}}function Is(e){let t=Object.create(null);function i(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec;if(e&&e.domEventHandlers)for(let s in e.domEventHandlers){let r=e.domEventHandlers[s];r&&i(s).handlers.push(Fs(t.value,r))}if(e&&e.domEventObservers)for(let s in e.domEventObservers){let r=e.domEventObservers[s];r&&i(s).observers.push(Fs(t.value,r))}}for(let e in zs)i(e).handlers.push(zs[e]);for(let e in Ns)i(e).observers.push(Ns[e]);return t}const Qs=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ws="dthko",Hs=[16,17,18,20,91,92,224,225];function qs(e){return.7*Math.max(0,e)+8}class $s{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,i,s=e.ownerDocument;for(let r=e.parentNode;r&&!(r==s.body||t&&i);)if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:t,y:i}}(e.contentDOM),this.atoms=e.state.facet(rs).map((t=>t(e)));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ye.allowMultipleSelections)&&function(e,t){let i=e.state.facet(Mi);return i.length?i[0](t):qt.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let s=tt(e.root);if(!s||0==s.rangeCount)return!0;let r=s.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let i=r[e];if(i.left<=t.clientX&&i.right>=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)||1!=ir(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,i=e,Math.max(Math.abs(t.clientX-i.clientX),Math.abs(t.clientY-i.clientY))<10))return;var t,i;this.select(this.lastEvent=e);let s=0,r=0,n=0,o=0,a=this.view.win.innerWidth,h=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:h}=this.scrollParents.y.getBoundingClientRect());let l=hs(this.view);e.clientX-l.left<=n+6?s=-qs(n-e.clientX):e.clientX+l.right>=a-6&&(s=qs(e.clientX-a)),e.clientY-l.top<=o+6?r=-qs(o-e.clientY):e.clientY+l.bottom>=h-6&&(r=qs(e.clientY-h)),this.setScrollSpeed(s,r)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let s=e.ranges[i],r=null;if(s.empty){let e=ks(this.atoms,s.from,0);e!=s.from&&(r=I.cursor(e,-1))}else{let e=ks(this.atoms,s.from,-1),t=ks(this.atoms,s.to,1);e==s.from&&t==s.to||(r=I.range(s.from==s.anchor?e:t,s.from==s.head?e:t))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?I.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));!this.mustSelect&&i.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some((e=>e.isUserEvent("input.type")))?this.destroy():this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const zs=Object.create(null),Ns=Object.create(null),Us=qt.ie&&qt.ie_version<15||qt.ios&&qt.webkit_version<604;function Vs(e,t,i){for(let s of e.facet(t))i=s(i,e);return i}function js(e,t){t=Vs(e.state,Hi,t);let i,{state:s}=e,r=1,n=s.toText(t),o=n.lines==s.selection.ranges.length;if(null!=rr&&s.selection.ranges.every((e=>e.empty))&&rr==n.toString()){let e=-1;i=s.changeByRange((i=>{let a=s.doc.lineAt(i.from);if(a.from==e)return{range:i};e=a.from;let h=s.toText((o?n.line(r++).text:t)+s.lineBreak);return{changes:{from:a.from,insert:h},range:I.cursor(i.from+h.length)}}))}else i=o?s.changeByRange((e=>{let t=n.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:I.cursor(e.from+t.length)}})):s.replaceSelection(n);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Xs(e,t,i,s){if(1==s)return I.cursor(t,i);if(2==s)return function(e,t,i=1){let s=e.charCategorizer(t),r=e.doc.lineAt(t),n=t-r.from;if(0==r.length)return I.cursor(t);0==n?i=1:n==r.length&&(i=-1);let o=n,a=n;i<0?o=b(r.text,n,!1):a=b(r.text,n);let h=s(r.text.slice(o,a));for(;o>0;){let e=b(r.text,o,!1);if(s(r.text.slice(e,o))!=h)break;o=e}for(;a<r.length;){let e=b(r.text,a);if(s(r.text.slice(a,e))!=h)break;a=e}return I.range(o+r.from,a+r.from)}(e.state,t,i);{let i=hi.find(e.docView,t),s=e.state.doc.lineAt(i?i.posAtEnd:t),r=i?i.posAtStart:s.from,n=i?i.posAtEnd:s.to;return n<e.state.doc.length&&n==s.to&&n++,I.range(r,n)}}Ns.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},zs.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Ns.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Ns.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},zs.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let s of e.state.facet(Li))if(i=s(e,t),i)break;if(i||0!=t.button||(i=function(e,t){let i=Zs(e,t),s=ir(t),r=e.state.selection;return{update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),r=r.map(e.changes))},get(t,n,o){let a,h=Zs(e,t),l=Xs(e,h.pos,h.bias,s);if(i.pos!=h.pos&&!n){let t=Xs(e,i.pos,i.bias,s),r=Math.min(t.from,l.from),n=Math.max(t.to,l.to);l=r<l.from?I.range(r,n):I.range(n,r)}return n?r.replaceRange(r.main.extend(l.from,l.to)):o&&1==s&&r.ranges.length>1&&(a=function(e,t){for(let i=0;i<e.ranges.length;i++){let{from:s,to:r}=e.ranges[i];if(s<=t&&r>=t)return I.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}return null}(r,h.pos))?a:o?r.addRange(l):I.create([l])}}}(e,t)),i){let s=!e.hasFocus;e.inputState.startMouseSelection(new $s(e,t,i,s)),s&&e.observer.ignore((()=>{mt(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()}));let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}return!1};let Gs=(e,t,i)=>t>=i.top&&t<=i.bottom&&e>=i.left&&e<=i.right;function Ks(e,t,i,s){let r=hi.find(e.docView,t);if(!r)return 1;let n=t-r.posAtStart;if(0==n)return 1;if(n==r.length)return-1;let o=r.coordsAt(n,-1);if(o&&Gs(i,s,o))return-1;let a=r.coordsAt(n,1);return a&&Gs(i,s,a)?1:o&&o.bottom>=s?-1:1}function Zs(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:i,bias:Ks(e,i,t.clientX,t.clientY)}}const Ys=qt.ie&&qt.ie_version<=11;let Js=null,er=0,tr=0;function ir(e){if(!Ys)return e.detail;let t=Js,i=tr;return Js=e,tr=Date.now(),er=!t||i>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(er+1)%3:1}function sr(e,t,i,s){if(!(i=Vs(e.state,Hi,i)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:n}=e.inputState,o=s&&n&&function(e,t){let i=e.state.facet(Bi);return i.length?i[0](t):qt.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:n.from,to:n.to}:null,a={from:r,insert:i},h=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:h,selection:{anchor:h.mapPos(r,-1),head:h.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),e.inputState.draggedContent=null}zs.dragstart=(e,t)=>{let{selection:{main:i}}=e.state;if(t.target.draggable){let s=e.docView.nearest(t.target);if(s&&s.isWidget){let e=s.posAtStart,t=e+s.length;(e>=i.to||t<=i.from)&&(i=I.range(e,t))}}let{inputState:s}=e;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=i,t.dataTransfer&&(t.dataTransfer.setData("Text",Vs(e.state,qi,e.state.sliceDoc(i.from,i.to))),t.dataTransfer.effectAllowed="copyMove"),!1},zs.dragend=e=>(e.inputState.draggedContent=null,!1),zs.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let i=t.dataTransfer.files;if(i&&i.length){let s=Array(i.length),r=0,n=()=>{++r==i.length&&sr(e,t,s.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e<i.length;e++){let t=new FileReader;t.onerror=n,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(s[e]=t.result),n()},t.readAsText(i[e])}return!0}{let i=t.dataTransfer.getData("Text");if(i)return sr(e,t,i,!0),!0}return!1},zs.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let i=Us?null:t.clipboardData;return i?(js(e,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{e.focus(),i.remove(),js(e,i.value)}),50)}(e),!1)};let rr=null;zs.copy=zs.cut=(e,t)=>{let{text:i,ranges:s,linewise:r}=function(e){let t=[],i=[],s=!1;for(let s of e.selection.ranges)s.empty||(t.push(e.sliceDoc(s.from,s.to)),i.push(s));if(!t.length){let r=-1;for(let{from:s}of e.selection.ranges){let n=e.doc.lineAt(s);n.number>r&&(t.push(n.text),i.push({from:n.from,to:Math.min(e.doc.length,n.to+1)})),r=n.number}s=!0}return{text:Vs(e,qi,t.join(e.lineBreak)),ranges:i,linewise:s}}(e.state);if(!i&&!r)return!1;rr=r?i:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let n=Us?null:t.clipboardData;return n?(n.clearData(),n.setData("text/plain",i),!0):(function(e,t){let i=e.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=t,s.focus(),s.selectionEnd=t.length,s.selectionStart=0,setTimeout((()=>{s.remove(),e.focus()}),50)}(e,i),!1)};const nr=le.define();function or(e,t){let i=[];for(let s of e.facet(Wi)){let r=s(e,t);r&&i.push(r)}return i?e.update({effects:i,annotations:nr.of(!0)}):null}function ar(e){setTimeout((()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let i=or(e.state,t);i?e.dispatch(i):e.update([])}}),10)}Ns.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),ar(e)},Ns.blur=e=>{e.observer.clearSelectionRange(),ar(e)},Ns.compositionstart=Ns.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Ns.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,qt.chrome&&qt.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then((()=>e.observer.flush())):setTimeout((()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])}),50))},Ns.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},zs.beforeinput=(e,t)=>{var i,s;if("insertReplacementText"==t.inputType&&e.observer.editContext){let s=null===(i=t.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),r=t.getTargetRanges();if(s&&r.length){let t=r[0],i=e.posAtDOM(t.startContainer,t.startOffset),n=e.posAtDOM(t.endContainer,t.endOffset);return Bs(e,{from:i,to:n,insert:e.state.toText(s)},null),!0}}let r;if(qt.chrome&&qt.android&&(r=Qs.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(s=window.visualViewport)||void 0===s?void 0:s.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}return qt.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),qt.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout((()=>Ns.compositionend(e,t)),20),!1};const hr=new Set,lr=["pre-wrap","normal","pre-line","break-spaces"];let cr=!1;function ur(){cr=!1}class dr{constructor(e){this.lineWrapping=e,this.doc=d.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lr.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let s=e[i];s<0?i++:this.heightSamples[Math.floor(10*s)]||(t=!0,this.heightSamples[Math.floor(10*s)]=!0)}return t}refresh(e,t,i,s,r,n){let o=lr.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let e=0;e<n.length;e++){let t=n[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class fr{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class pr{constructor(e,t,i,s,r){this.from=e,this.length=t,this.top=i,this.height=s,this._content=r}get type(){return"number"==typeof this._content?ti.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ni?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new pr(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var gr=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(gr||(gr={}));const mr=.001;class vr{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>mr&&(cr=!0),this.height=e)}replace(e,t,i){return vr.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,n=i.doc;for(let o=s.length-1;o>=0;o--){let{fromA:a,toA:h,fromB:l,toB:c}=s[o],u=r.lineAt(a,gr.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,gr.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;o>0&&u.from<=s[o-1].toA;)a=s[o-1].fromA,l=s[o-1].fromB,o--,a<u.from&&(u=r.lineAt(a,gr.ByPosNoHeight,i,0,0));l+=u.from-a,a=u.from;let f=Dr.build(i.setDoc(n),e,l,c);r=_r(r,r.replace(a,h,f))}return r.updateHeight(i,0)}static empty(){return new Sr(0,0)}static of(e){if(1==e.length)return e[0];let t=0,i=e.length,s=0,r=0;for(;;)if(t==i)if(s>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),i+=1+r.break,s-=r.size}else{if(!(r>2*s))break;{let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,r-=t.size}}else if(s<r){let i=e[t++];i&&(s+=i.size)}else{let t=e[--i];t&&(r+=t.size)}let n=0;return null==e[t-1]?(n=1,t--):null==e[t]&&(n=1,i++),new br(vr.of(e.slice(0,t)),n,vr.of(e.slice(i)))}}function _r(e,t){return e==t?e:(e.constructor!=t.constructor&&(cr=!0),t)}vr.prototype.size=1;class Or extends vr{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,s){return new pr(s,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,s,r){return this.blockAt(0,i,s,r)}forEachLine(e,t,i,s,r,n){e<=r+this.length&&t>=r&&n(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Sr extends Or{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,s){return new pr(s,this.length,i,this.height,this.breaks)}replace(e,t,i){let s=i[0];return 1==i.length&&(s instanceof Sr||s instanceof wr&&4&s.flags)&&Math.abs(this.length-s.length)<10?(s instanceof wr?s=new Sr(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):vr.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class wr extends vr{constructor(e){super(e,0)}heightMetrics(e,t){let i,s=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,n=r-s+1,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*n);i=t/n,this.length>n+1&&(o=(this.height-t)/(this.length-n-1))}else i=this.height/n;return{firstLine:s,lastLine:r,perLine:i,perChar:o}}blockAt(e,t,i,s){let{firstLine:r,lastLine:n,perLine:o,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let r=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),n=t.doc.lineAt(r),h=o+n.length*a,l=Math.max(i,e-h/2);return new pr(n.from,n.length,l,h,0)}{let s=Math.max(0,Math.min(n-r,Math.floor((e-i)/o))),{from:a,length:h}=t.doc.line(r+s);return new pr(a,h,i+o*s,o,0)}}lineAt(e,t,i,s,r){if(t==gr.ByHeight)return this.blockAt(e,i,s,r);if(t==gr.ByPosNoHeight){let{from:t,to:s}=i.doc.lineAt(e);return new pr(t,s-t,0,0,0)}let{firstLine:n,perLine:o,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(e),l=o+h.length*a,c=h.number-n,u=s+o*c+a*(h.from-r-c);return new pr(h.from,h.length,Math.max(s,Math.min(u,s+this.height-l)),l,0)}forEachLine(e,t,i,s,r,n){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:o,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let l=e,c=s;l<=t;){let t=i.doc.lineAt(l);if(l==e){let i=t.number-o;c+=a*i+h*(e-r-i)}let s=a+h*t.length;n(new pr(t.from,t.length,c,s,0)),c+=s,l=t.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let e=i[i.length-1];e instanceof wr?i[i.length-1]=new wr(e.length+s):i.push(null,new wr(s-1))}if(e>0){let t=i[0];t instanceof wr?i[0]=new wr(e+t.length):i.unshift(new wr(e-1),null)}return vr.of(i)}decomposeLeft(e,t){t.push(new wr(e-1),null)}decomposeRight(e,t){t.push(null,new wr(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let i=[],n=Math.max(t,s.from),o=-1;for(s.from>t&&i.push(new wr(s.from-t-1).updateHeight(e,t));n<=r&&s.more;){let t=e.doc.lineAt(n).length;i.length&&i.push(null);let r=s.heights[s.index++];-1==o?o=r:Math.abs(r-o)>=mr&&(o=-2);let a=new Sr(t,r);a.outdated=!1,i.push(a),n+=t+1}n<=r&&i.push(null,new wr(r-n).updateHeight(e,n));let a=vr.of(i);return(o<0||Math.abs(a.height-this.height)>=mr||Math.abs(o-this.heightMetrics(e,t).perLine)>=mr)&&(cr=!0),_r(this,a)}return(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class br extends vr{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,s){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,i,s,r){let n=s+this.left.height,o=r+this.left.length+this.break,a=t==gr.ByHeight?e<n:e<o,h=a?this.left.lineAt(e,t,i,s,r):this.right.lineAt(e,t,i,n,o);if(this.break||(a?h.to<o:h.from>o))return h;let l=t==gr.ByPosNoHeight?gr.ByPosNoHeight:gr.ByPos;return a?h.join(this.right.lineAt(o,l,i,n,o)):this.left.lineAt(o,l,i,s,r).join(h)}forEachLine(e,t,i,s,r,n){let o=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,s,r,n),t>=a&&this.right.forEachLine(e,t,i,o,a,n);else{let h=this.lineAt(a,gr.ByPos,i,s,r);e<h.from&&this.left.forEachLine(e,h.from-1,i,s,r,n),h.to>=e&&h.from<=t&&n(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,o,a,n)}}replace(e,t,i){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let n=r.length;for(let e of i)r.push(e);if(e>0&&yr(r,n-1),t<this.length){let e=r.length;this.decomposeRight(t,r),yr(r,e)}return vr.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?vr.of(this.break?[e,null,t]:[e,t]):(this.left=_r(this.left,e),this.right=_r(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:n}=this,o=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=o+n.length&&s.more?a=n=n.updateHeight(e,o,i,s):n.updateHeight(e,o,i),a?this.balanced(r,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function yr(e,t){let i,s;null==e[t]&&(i=e[t-1])instanceof wr&&(s=e[t+1])instanceof wr&&e.splice(t-1,3,new wr(i.length+1+s.length))}class Dr{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Sr?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Sr(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let n=t-e;i.block?this.addBlock(new Or(n,s,i)):(n||r||s>=5)&&this.addLineDeco(s,r,n)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Sr(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new wr(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Sr)return e;let t=new Sr(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Sr||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Sr(0,-1));let i=e;for(let e of this.nodes)e instanceof Sr&&e.updateHeight(this.oracle,i),i+=e?e.length:1;return this.nodes}static build(e,t,i,s){let r=new Dr(i,e);return Te.spans(t,i,s,r,0),r.finish(i)}}class Cr{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,s){(e<t||i&&i.heightRelevant||s&&s.heightRelevant)&&ai(e,t,this.changes,5)}}function kr(e,t){let i=e.getBoundingClientRect(),s=e.ownerDocument,r=s.defaultView||window,n=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),a=Math.max(0,i.top),h=Math.min(r.innerHeight,i.bottom);for(let t=e.parentNode;t&&t!=s.body;)if(1==t.nodeType){let i=t,s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=s.overflow){let s=i.getBoundingClientRect();n=Math.max(n,s.left),o=Math.min(o,s.right),a=Math.max(a,s.top),h=Math.min(t==e.parentNode?r.innerHeight:h,s.bottom)}t="absolute"==s.position||"fixed"==s.position?i.offsetParent:i.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:n-i.left,right:Math.max(n,o)-i.left,top:a-(i.top+t),bottom:Math.max(a,h)-(i.top+t)}}function xr(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}class Er{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],r=t[i];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return ii.replace({widget:new Tr(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Tr extends ei{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Ar{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Br,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(ts).some((e=>"function"!=typeof e&&"cm-lineWrapping"==e.class));this.heightOracle=new dr(t),this.stateDeco=e.facet(is).filter((e=>"function"!=typeof e)),this.heightMap=vr.empty().applyChanges(this.stateDeco,d.empty,this.heightOracle.setDoc(e.doc),[new cs(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ii.set(this.lineGaps.map((e=>e.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some((({from:e,to:t})=>s>=e&&s<=t))){let{from:t,to:i}=this.lineBlockAt(s);e.push(new Rr(t,i))}}return this.viewports=e.sort(((e,t)=>e.from-t.from)),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Br:new Lr(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(e=>{this.viewportLines.push(Fr(e,this.scaler))}))}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(is).filter((e=>"function"!=typeof e));let s=e.changedRanges,r=cs.extendWithRanges(s,function(e,t,i){let s=new Cr;return Te.compare(e,t,i,s,0),s.changes}(i,this.stateDeco,e?e.changes:T.empty(this.state.doc.length))),n=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ur(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=n||cr)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(zi)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?pi.RTL:pi.LTR;let n=this.heightOracle.mustRefreshForWrapping(r),o=t.getBoundingClientRect(),a=n||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let h=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:i}=dt(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=e,this.scaleY=i,h|=16,n=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==c&&this.paddingBottom==u||(this.paddingTop=c,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let f=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=St(e.scrollDOM);let p=(this.printing?xr:kr)(t,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),i=e.ownerDocument.defaultView||window;return t.left<i.innerWidth&&t.right>0&&t.top<i.innerHeight&&t.bottom>0}(e.dom))return 0;let _=o.width;if(this.contentDOMWidth==_&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(t)&&(n=!0),n||s.lineWrapping&&Math.abs(_-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:o,textHeight:a}=e.docView.measureTextSize();n=i>0&&s.refresh(r,i,o,a,_/o,t),n&&(e.docView.minWidth=0,h|=16)}g>0&&m>0?l=Math.max(g,m):g<0&&m<0&&(l=Math.min(g,m)),ur();for(let i of this.viewports){let r=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=(n?vr.empty().applyChanges(this.stateDeco,d.empty,this.heightOracle,[new cs(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,n,new fr(i.from,r))}cr&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(2&h&&(h|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),h|=this.updateForViewport()),(2&h||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:n,visibleBottom:o}=this,a=new Rr(s.lineAt(n-1e3*i,gr.ByHeight,r,0,0).from,s.lineAt(o+1e3*(1-i),gr.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let i,n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=s.lineAt(e,gr.ByPos,r,0,0);i="center"==t.y?(o.top+o.bottom)/2-n/2:"start"==t.y||"nearest"==t.y&&e<a.from?o.top:o.bottom-n,a=new Rr(s.lineAt(i-500,gr.ByHeight,r,0,0).from,s.lineAt(i+n+500,gr.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Rr(this.heightMap.lineAt(i,gr.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,gr.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,gr.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,gr.ByPos,this.heightOracle,0,0),{visibleTop:n,visibleBottom:o}=this;return(0==e||s<=n-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&s>n-2e3&&r<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let s of e)t.touchesRange(s.from,s.to)||i.push(new Er(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,r=s>>1,n=s<<1;if(this.defaultTextDirection!=pi.LTR&&!i)return[];let o=[],a=(s,n,h,l)=>{if(n-s<r)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let e of u)if(e>s&&e<n)return a(s,e-10,h,l),void a(e+10,n,h,l);let d=function(e,t){for(let i of e)if(t(i))return i}(e,(e=>e.from>=h.from&&e.to<=h.to&&Math.abs(e.from-s)<r&&Math.abs(e.to-n)<r&&!u.some((t=>e.from<t&&e.to>t))));if(!d){if(n<h.to&&t&&i&&t.visibleRanges.some((e=>e.from<=n&&e.to>=n))){let e=t.moveToLineBoundary(I.cursor(n),!1,!0).head;e>s&&(n=e)}let e=this.gapSize(h,s,n,l);d=new Er(s,n,e,i||e<2e6?e:2e6)}o.push(d)},h=t=>{if(t.length<n||t.type!=ti.Text)return;let r=function(e,t,i){let s=[],r=e,n=0;return Te.spans(i,e,t,{span(){},point(e,t){e>r&&(s.push({from:r,to:e}),n+=e-r),r=t}},20),r<t&&(s.push({from:r,to:t}),n+=t-r),{total:n,ranges:s}}(t.from,t.to,this.stateDeco);if(r.total<n)return;let o,h,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let e,i,n=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let s=Mr(r,l),o=((this.visibleBottom-this.visibleTop)/2+n)/t.height;e=s-o,i=s+o}else e=(this.visibleTop-t.top-n)/t.height,i=(this.visibleBottom-t.top+n)/t.height;o=Pr(r,e),h=Pr(r,i)}else{let i=r.total*this.heightOracle.charWidth,n=s*this.heightOracle.charWidth,a=0;if(i>2e6)for(let i of e)i.from>=t.from&&i.from<t.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=i.size-i.displaySize);let c,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=l){let e=Mr(r,l),t=((f-d)/2+n)/i;c=e-t,u=e+t}else c=(d-n)/i,u=(f+n)/i;o=Pr(r,c),h=Pr(r,u)}o>t.from&&a(t.from,o,t,r),h<t.to&&a(h,t.to,t,r)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(h):h(e);return o}gapSize(e,t,i,s){let r=Mr(s,i)-Mr(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Er.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ii.set(e.map((e=>e.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Te.spans(t,this.viewport.from,this.viewport.to,{span(e,t){i.push({from:e,to:t})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let t=0;t<i.length&&!(8&s);t++){let r=this.visibleRanges[t],n=i[t];r.from==n.from&&r.to==n.to||(s|=4,e&&e.mapPos(r.from,-1)==n.from&&e.mapPos(r.to,1)==n.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||Fr(this.heightMap.lineAt(e,gr.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((t=>t.top<=e&&t.bottom>=e))||Fr(this.heightMap.lineAt(this.scaler.fromDOM(e),gr.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Fr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Rr{constructor(e,t){this.from=e,this.to=t}}function Pr({total:e,ranges:t},i){if(i<=0)return t[0].from;if(i>=1)return t[t.length-1].to;let s=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:r}=t[e],n=r-i;if(s<=n)return i+s;s-=n}}function Mr(e,t){let i=0;for(let{from:s,to:r}of e.ranges){if(t<=r){i+=t-s;break}i+=r-s}return i/e.total}const Br={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class Lr{constructor(e,t,i){let s=0,r=0,n=0;this.viewports=i.map((({from:i,to:r})=>{let n=t.lineAt(i,gr.ByPos,e,0,0).top,o=t.lineAt(r,gr.ByPos,e,0,0).bottom;return s+=o-n,{from:i,to:r,top:n,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-s)/(t.height-s);for(let e of this.viewports)e.domTop=n+(e.top-r)*this.scale,n=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,s=r.domBottom}}eq(e){return e instanceof Lr&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every(((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to))}}function Fr(e,t){if(1==t.scale)return e;let i=t.toDOM(e.top),s=t.toDOM(e.bottom);return new pr(e.from,e.length,i,s-i,Array.isArray(e._content)?e._content.map((e=>Fr(e,t))):e._content)}const Ir=H.define({combine:e=>e.join(" ")}),Qr=H.define({combine:e=>e.indexOf(!0)>-1}),Wr=Ve.newName(),Hr=Ve.newName(),qr=Ve.newName(),$r={"&light":"."+Hr,"&dark":"."+qr};function zr(e,t,i){return new Ve(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]})):e+" "+t})}const Nr=zr("."+Wr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',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"}},$r),Ur={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Vr=qt.ie&&qt.ie_version<=11;class jr{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new ft,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);(qt.ie&&qt.ie_version<=11||qt.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||qt.chrome&&qt.chrome_version<126||(this.editContext=new Kr(e),e.state.facet(Gi)&&(e.contentDOM.editContext=this.editContext.editContext)),Vr&&(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)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((e=>{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])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Gi)?i.root.activeElement!=this.dom:!st(this.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);r&&r.ignoreEvent(e)?t||(this.selectionChanged=!1):(qt.ie&&qt.ie_version<=11||qt.android&&qt.chrome)&&!i.state.selection.main.empty&&s.focusNode&&nt(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=tt(e.root);if(!t)return!1;let i=qt.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 Gr(e,i)}let i=null;function s(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",s,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",s,!0),i?Gr(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=st(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let i=t.focusNode,s=t.focusOffset;if(!i||t.anchorNode!=i||t.anchorOffset!=s)return!1;for(s=Math.min(s,lt(i));;)if(s){if(1!=i.nodeType)return!1;let e=i.childNodes[s-1];"false"==e.contentEditable?s--:(i=e,s=lt(i))}else{if(i==e)return!0;s=ot(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(1==i.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ur),Vr&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Vr&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&_t(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(s=!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:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&st(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Ps(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,s=Ms(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}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=Xr(t,e.previousSibling||e.target.previousSibling,-1),s=Xr(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):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(Gi)!=e.state.facet(Gi)&&(e.view.contentDOM.editContext=e.state.facet(Gi)?this.editContext.editContext:null))}destroy(){var e,t,i;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();for(let e of this.scrollTargets)e.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 Xr(e,t,i){for(;t;){let s=Ct.get(t);if(s&&s.parent==e)return s;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}function Gr(e,t){let i=t.startContainer,s=t.startOffset,r=t.endContainer,n=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return nt(o.node,o.offset,r,n)&&([i,s,r,n]=[r,n,i,s]),{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:n}}class Kr{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)});this.handlers.textupdate=t=>{let i=e.state.selection.main,{anchor:s,head:r}=i,n=this.toEditorPos(t.updateRangeStart),o=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:n,drifted:!1});let a={from:n,to:o,insert:d.of(t.text.split("\n"))};if(a.from==this.from&&s<this.from?a.from=s:a.to==this.to&&s>this.to&&(a.to=s),a.from!=a.to||a.insert.length){if((qt.mac||qt.android)&&a.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(a={from:n,to:o,insert:d.of([t.text.replace("."," ")])}),this.pendingContextChange=a,!e.state.readOnly){let i=this.to-this.from+(a.to-a.from+a.insert.length);Bs(e,a,I.single(this.toEditorPos(t.selectionStart,i),this.toEditorPos(t.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))}else{let s=I.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));s.main.eq(i)||e.dispatch({selection:s,userEvent:"select"})}},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let t=this.toEditorPos(i.rangeStart),n=this.toEditorPos(i.rangeEnd);t<n;t++){let i=e.coordsForChar(t);r=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=t=>{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,s=e.underlineThickness;if("None"!=t&&"None"!=s){let r=this.toEditorPos(e.rangeStart),n=this.toEditorPos(e.rangeEnd);if(r<n){let e=`text-decoration: underline ${"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${"Thin"==s?1:2}px`;i.push(ii.mark({attributes:{style:e}}).range(r,n))}}}e.dispatch({effects:ji.of(ii.set(i))})},this.handlers.compositionstart=()=>{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)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=tt(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges(((r,n,o,a,h)=>{if(i)return;let l=h.length-(n-r);if(s&&n>=s.to){if(s.from==r&&s.to==n&&s.insert.eq(h))return s=this.pendingContextChange=null,t+=l,void(this.to+=l);s=null,this.revertPending(e.state)}if(r+=t,(n+=t)<=this.from)this.from+=l,this.to+=l;else if(r<this.to){if(r<this.from||n>this.to||this.to-this.from+h.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(r),this.toContextPos(n),h.toString()),this.to+=l}t+=l})),s&&!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))),s=this.toContextPos(t.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==s||this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}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 Zr{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(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 Ar(e.state||ye.create(e)),e.scrollTo&&e.scrollTo.is(Vi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zi).map((e=>new Ji(e)));for(let e of this.plugins)e.update(this);this.observer=new jr(this),this.inputState=new Ls(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ds(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 fe?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 new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,i=!1,s=!1,r=this.state;for(let t of e){if(t.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed)return void(this.viewState.state=r);let n=this.hasFocus,o=0,a=null;e.some((e=>e.annotation(nr)))?(this.inputState.notifiedFocused=n,o=1):n!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=n,a=or(r,n),a||(o=1));let h=this.observer.delayedAndroidKey,l=null;if(h?(this.observer.clearDelayedAndroidKey(),l=this.observer.readChange(),(l&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(l=null)):this.observer.clear(),r.facet(ye.phrases)!=this.state.facet(ye.phrases))return this.setState(r);t=us.create(this,r,e),t.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new Ui(e.empty?e:I.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Vi)&&(c=e.value.clip(this.state))}this.viewState.update(t,c),this.bidiCache=en.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),i=this.docView.update(t),this.state.facet(ls)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(Ir)!=t.state.facet(Ir)&&(this.viewState.mustMeasureContent=!0),(i||s||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(Ii))try{e(t)}catch(e){Xi(this.state,e,"update listener")}(a||l)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),l&&!Ms(this,l)&&h.force&&_t(this.contentDOM,h.key,h.keyCode)}))}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Ar(e),this.plugins=e.facet(Zi).map((e=>new Ji(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new ds(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(Zi),i=e.state.facet(Zi);if(t!=i){let s=[];for(let r of i){let i=t.indexOf(r);if(i<0)s.push(new Ji(r));else{let t=this.plugins[i];t.mustUpdate=e,s.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Xi(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:n}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(n=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(n<0)if(St(i))r=-1,n=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(s);r=e.from,n=e.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let h=a.map((e=>{try{return e.read(this)}catch(e){return Xi(this.state,e),Jr}})),l=us.create(this,this.state,[]),c=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),c=this.docView.update(l),c&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(h[e]!=Jr)try{let t=a[e];t.write&&t.write(h[e],this)}catch(e){Xi(this.state,e)}if(c&&this.docView.updateSelection(!0),!l.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,n=-1;continue}{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-n;if(e>1||e<-1){s+=e,i.scrollTop=s/this.scaleY,n=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Ii))e(t)}get themeClasses(){return Wr+" "+(this.state.facet(Qr)?qr:Hr)+" "+this.state.facet(Ir)}updateAttrs(){let e=tn(this,es,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Gi)?"true":"false",class:"cm-content",style:`${qt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),tn(this,ts,t);let i=this.observer.ignore((()=>{let i=Yt(this.contentDOM,this.contentAttrs,t),s=Yt(this.dom,this.editorAttrs,e);return i||s}));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(Zr.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(ls);let e=this.state.facet(Zr.cspNonce);Ve.mount(this.root,this.styleModules.concat(Nr).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new 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){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find((t=>t.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 xs(this,e,Cs(this,e,t,i))}moveByGroup(e,t){return xs(this,e,Cs(this,e,t,(t=>function(e,t,i){let s=e.state.charCategorizer(t),r=s(i);return e=>{let t=s(e);return r==Se.Space&&(r=t),r==t}}(this,e.head,t))))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return I.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return function(e,t,i,s){let r=Ds(e,t.head),n=s&&r.type==ti.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(n){let t=e.dom.getBoundingClientRect(),s=e.textDirectionAt(r.from),o=e.posAtCoords({x:i==(s==pi.LTR)?t.right-1:t.left+1,y:(n.top+n.bottom)/2});if(null!=o)return I.cursor(o,i?-1:1)}return I.cursor(i?r.to:r.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return xs(this,e,function(e,t,i,s){let r=t.head,n=i?1:-1;if(r==(i?e.state.doc.length:0))return I.cursor(r,t.assoc);let o,a=t.goalColumn,h=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(r,t.assoc||-1),c=e.documentTop;if(l)null==a&&(a=l.left-h.left),o=n<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(r);null==a&&(a=Math.min(h.right-h.left,e.defaultCharacterWidth*(r-t.from))),o=(n<0?t.top:t.bottom)+c}let u=h.left+a,d=null!=s?s:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let i=o+(d+t)*n,s=bs(e,{x:u,y:i},!1,n);if(i<h.top||i>h.bottom||(n<0?s<r:s>r)){let t=e.docView.coordsForChar(s),r=!t||i<t.top?-1:1;return I.cursor(s,r,void 0,a)}}}(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),bs(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s);return ct(i,r[Di.find(r,e-s.from,-1,t)].dir==pi.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet($i)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Yr)return Ti(e.length);let t,i=this.textDirectionAt(e.from);for(let s of this.bidiCache)if(s.from==e.from&&s.dir==i&&(s.fresh||Ci(s.isolates,t=os(this,e))))return s.order;t||(t=os(this,e));let s=function(e,t,i){if(!e)return[new Di(0,0,t==mi?1:0)];if(t==gi&&!i.length&&!yi.test(e))return Ti(e.length);if(i.length)for(;e.length>ki.length;)ki[ki.length]=256;let s=[],r=t==gi?0:1;return Ei(e,r,r,i,0,e.length,s),s}(e.text,i,t);return this.bidiCache.push(new en(e.from,e.to,i,t,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||qt.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{mt(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(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Vi.of(new Ui("number"==typeof e?I.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 Vi.of(new Ui(I.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 Yi.define((()=>({})),{eventHandlers:e})}static domEventObservers(e){return Yi.define((()=>({})),{eventObservers:e})}static theme(e,t){let i=Ve.newName(),s=[Ir.of(i),ls.of(zr(`.${i}`,e))];return t&&t.dark&&s.push(Qr.of(!0)),s}static baseTheme(e){return G.lowest(ls.of(zr("."+Wr,e,$r)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&Ct.get(i)||Ct.get(e);return(null===(t=null==s?void 0:s.rootView)||void 0===t?void 0:t.view)||null}}Zr.styleModule=ls,Zr.inputHandler=Qi,Zr.clipboardInputFilter=Hi,Zr.clipboardOutputFilter=qi,Zr.scrollHandler=Ni,Zr.focusChangeEffect=Wi,Zr.perLineTextDirection=$i,Zr.exceptionSink=Fi,Zr.updateListener=Ii,Zr.editable=Gi,Zr.mouseSelectionStyle=Li,Zr.dragMovesSelection=Bi,Zr.clickAddsSelectionRange=Mi,Zr.decorations=is,Zr.outerDecorations=ss,Zr.atomicRanges=rs,Zr.bidiIsolatedRanges=ns,Zr.scrollMargins=as,Zr.darkTheme=Qr,Zr.cspNonce=H.define({combine:e=>e.length?e[0]:""}),Zr.contentAttributes=ts,Zr.editorAttributes=es,Zr.lineWrapping=Zr.contentAttributes.of({class:"cm-lineWrapping"}),Zr.announce=de.define();const Yr=4096,Jr={};class en{constructor(e,t,i,s,r,n){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=n}static update(e,t){if(t.empty&&!e.some((e=>e.fresh)))return e;let i=[],s=e.length?e[e.length-1].dir:pi.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let n=e[r];n.dir!=s||t.touchesRange(n.from,n.to)||i.push(new en(t.mapPos(n.from,1),t.mapPos(n.to,-1),n.dir,n.isolates,!1,n.order))}return i}}function tn(e,t,i){for(let s=e.state.facet(t),r=s.length-1;r>=0;r--){let t=s[r],n="function"==typeof t?t(e):t;n&&Gt(n,i)}return i}const sn=qt.mac?"mac":qt.windows?"win":qt.linux?"linux":"key";function rn(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 nn=G.default(Zr.domEventHandlers({keydown:(e,t)=>dn(hn(t.state),e,t,"editor")})),on=H.define({enables:nn}),an=new WeakMap;function hn(e){let t=e.facet(on),i=an.get(t);return i||an.set(t,i=function(e,t=sn){let i=Object.create(null),s=Object.create(null),r=(e,t)=>{let i=s[e];if(null==i)s[e]=t;else if(i!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},n=(e,s,n,o,a)=>{var h,l;let c=i[e]||(i[e]=Object.create(null)),u=s.split(/ (?!$)/).map((e=>function(e,t){const i=e.split(/-(?!$)/);let s,r,n,o,a=i[i.length-1];"Space"==a&&(a=" ");for(let e=0;e<i.length-1;++e){const a=i[e];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))s=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))n=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?o=!0:r=!0}}return s&&(a="Alt-"+a),r&&(a="Ctrl-"+a),o&&(a="Meta-"+a),n&&(a="Shift-"+a),a}(e,t)));for(let t=1;t<u.length;t++){let i=u.slice(0,t).join(" ");r(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[t=>{let s=ln={view:t,prefix:i,scope:e};return setTimeout((()=>{ln==s&&(ln=null)}),cn),!0}]})}let d=u.join(" ");r(d,!1);let f=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(l=null===(h=c._any)||void 0===h?void 0:h.run)||void 0===l?void 0:l.slice())||[]});n&&f.run.push(n),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let s of e){let e=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let t of e){let e=i[t]||(i[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=s;for(let t in e)e[t].run.push((e=>r(e,un)))}let r=s[t]||s.key;if(r)for(let t of e)n(t,r,s.run,s.preventDefault,s.stopPropagation),s.shift&&n(t,"Shift-"+r,s.shift,s.preventDefault,s.stopPropagation)}return i}(t.reduce(((e,t)=>e.concat(t)),[]))),i}let ln=null;const cn=4e3;let un=null;function dn(e,t,i,s){un=t;let r=function(e){var t=!(Ze&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ye&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Ke:Ge)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),n=C(y(r,0))==r.length&&" "!=r,o="",a=!1,h=!1,l=!1;ln&&ln.view==i&&ln.scope==s&&(o=ln.prefix+" ",Hs.indexOf(t.keyCode)<0&&(h=!0,ln=null));let c,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(i)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),h=!0)}return!1},p=e[s];return p&&(f(p[o+rn(r,t,!n)])?a=!0:n&&(t.altKey||t.metaKey||t.ctrlKey)&&!(qt.windows&&t.ctrlKey&&t.altKey)&&(c=Ge[t.keyCode])&&c!=r?(f(p[o+rn(c,t,!0)])||t.shiftKey&&(u=Ke[t.keyCode])!=r&&u!=c&&f(p[o+rn(u,t,!1)]))&&(a=!0):n&&t.shiftKey&&f(p[o+rn(r,t,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),h&&(a=!0),a&&l&&t.stopPropagation(),un=null,a}class fn{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=pn(e);return[new fn(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}return function(e,t,i){if(i.to<=e.viewport.from||i.from>=e.viewport.to)return[];let s=Math.max(i.from,e.viewport.from),r=Math.min(i.to,e.viewport.to),n=e.textDirection==pi.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),h=pn(e),l=o.querySelector(".cm-line"),c=l&&window.getComputedStyle(l),u=a.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=a.right-(c?parseInt(c.paddingRight):0),f=Ds(e,s),p=Ds(e,r),g=f.type==ti.Text?f:null,m=p.type==ti.Text?p:null;if(g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=gn(e,s,1,g)),m&&(e.lineWrapping||p.widgetLineBreaks)&&(m=gn(e,r,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return _(O(i.from,i.to,g));{let t=g?O(i.from,null,g):S(f,!1),s=m?O(null,i.to,m):S(p,!0),r=[];return(g||f).to<(m||p).from-(g&&m?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<s.top?r.push(v(u,t.bottom,d,s.top)):t.bottom<s.top&&e.elementAtHeight((t.bottom+s.top)/2).type==ti.Text&&(t.bottom=s.top=(t.bottom+s.top)/2),_(t).concat(r).concat(_(s))}function v(e,i,s,r){return new fn(t,e-h.left,i-h.top,s-e,r-i)}function _({top:e,bottom:t,horizontal:i}){let s=[];for(let r=0;r<i.length;r+=2)s.push(v(i[r],e,i[r+1],t));return s}function O(t,i,s){let r=1e9,o=-1e9,a=[];function h(t,i,h,l,c){let f=e.coordsAtPos(t,t==s.to?-2:2),p=e.coordsAtPos(h,h==s.from?2:-2);f&&p&&(r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),c==pi.LTR?a.push(n&&i?u:f.left,n&&l?d:p.right):a.push(!n&&l?u:p.left,!n&&i?d:f.right))}let l=null!=t?t:s.from,c=null!=i?i:s.to;for(let s of e.visibleRanges)if(s.to>l&&s.from<c)for(let r=Math.max(s.from,l),n=Math.min(s.to,c);;){let s=e.state.doc.lineAt(r);for(let o of e.bidiSpans(s)){let e=o.from+s.from,a=o.to+s.from;if(e>=n)break;a>r&&h(Math.max(e,r),null==t&&e<=l,Math.min(a,n),null==i&&a>=c,o.dir)}if(r=s.to+1,r>=n)break}return 0==a.length&&h(l,null==t,c,null==i,e.textDirection),{top:r,bottom:o,horizontal:a}}function S(e,t){let i=a.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(e,t,i)}}function pn(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==pi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function gn(e,t,i,s){let r=e.coordsAtPos(t,2*i);if(!r)return s;let n=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,a=e.posAtCoords({x:n.left+1,y:o}),h=e.posAtCoords({x:n.right-1,y:o});return null==a||null==h?s:{from:Math.max(s.from,Math.min(a,h)),to:Math.min(s.to,Math.max(a,h))}}class mn{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(vn)!=e.state.facet(vn)&&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(vn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some(((e,t)=>{return i=e,s=this.drawn[t],!(i.constructor==s.constructor&&i.eq(s));var i,s}))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.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 vn=H.define();function _n(e){return[Yi.define((t=>new mn(t,e))),vn.of(e)]}const On=!(qt.ios&&qt.webkit&&qt.webkit_version<534),Sn=H.define({combine:e=>De(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function wn(e={}){return[Sn.of(e),yn,Cn,xn,zi.of(!0)]}function bn(e){return e.startState.facet(Sn)!=e.state.facet(Sn)}const yn=_n({above:!0,markers(e){let{state:t}=e,i=t.facet(Sn),s=[];for(let r of t.selection.ranges){let n=r==t.selection.main;if(r.empty?!n||On:i.drawRangeCursor){let t=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:I.cursor(r.head,r.head>r.anchor?-1:1);for(let r of fn.forRange(e,t,i))s.push(r)}}return s},update(e,t){e.transactions.some((e=>e.selection))&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let i=bn(e);return i&&Dn(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){Dn(t.state,e)},class:"cm-cursorLayer"});function Dn(e,t){t.style.animationDuration=e.facet(Sn).cursorBlinkRate+"ms"}const Cn=_n({above:!1,markers:e=>e.state.selection.ranges.map((t=>t.empty?[]:fn.forRange(e,"cm-selectionBackground",t))).reduce(((e,t)=>e.concat(t))),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||bn(e),class:"cm-selectionLayer"}),kn={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};On&&(kn[".cm-line"].caretColor=kn[".cm-content"].caretColor="transparent !important");const xn=G.highest(Zr.theme(kn)),En=de.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Tn=j.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce(((e,t)=>t.is(En)?t.value:e),e))}),An=Yi.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(Tn);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(Tn)!=i||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Tn),i=null!=t&&e.coordsAtPos(t);if(!i)return null;let s=e.scrollDOM.getBoundingClientRect();return{left:i.left-s.left+e.scrollDOM.scrollLeft*e.scaleX,top:i.top-s.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(Tn)!=e&&this.view.dispatch({effects:En.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 Rn(e,t,i,s,r){t.lastIndex=0;for(let n,o=e.iterRange(i,s),a=i;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;n=t.exec(o.value);)r(a+n.index,n)}class Pn{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:n=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(e,t,i,r)=>s(r,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,s,r)=>{let n=i(e,t,s);n&&r(s,s+e[0].length,n)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,s,r)=>r(s,s+e[0].length,i)}this.boundary=r,this.maxLength=n}createDeco(e){let t=new Ae,i=t.add.bind(t);for(let{from:t,to:s}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 s=[];for(let{from:r,to:n}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),n=Math.min(e.state.doc.lineAt(n).to,n+t),s.length&&s[s.length-1].to>=r?s[s.length-1].to=n:s.push({from:r,to:n});return s}(e,this.maxLength))Rn(e.state.doc,this.regexp,t,s,((t,s)=>this.addMatch(s,e,t,i)));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges(((t,r,n,o)=>{o>=e.view.viewport.from&&n<=e.view.viewport.to&&(i=Math.min(n,i),s=Math.max(o,s))})),e.viewportMoved||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let n=Math.max(r.from,i),o=Math.min(r.to,s);if(o>n){let i=e.state.doc.lineAt(n),s=i.to<o?e.state.doc.lineAt(o):i,a=Math.max(r.from,i.from),h=Math.min(r.to,s.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){a=n;break}for(;o<s.to;o++)if(this.boundary.test(s.text[o-s.from])){h=o;break}}let l,c=[],u=(e,t,i)=>c.push(i.range(e,t));if(i==s)for(this.regexp.lastIndex=a-i.from;(l=this.regexp.exec(i.text))&&l.index<h-i.from;)this.addMatch(l,e,l.index+i.from,u);else Rn(e.state.doc,this.regexp,a,h,((t,i)=>this.addMatch(i,e,t,u)));t=t.update({filterFrom:a,filterTo:h,filter:(e,t)=>e<a||t>h,add:c})}}return t}}const Mn=null!=/x/.unicode?"gu":"g",Bn=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",Mn),Ln={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 Fn=null;const In=H.define({combine(e){let t=De(e,{render:null,specialChars:Bn,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Fn&&"undefined"!=typeof document&&document.body){let t=document.body.style;Fn=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Fn||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Mn)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Mn)),t}});function Qn(e={}){return[In.of(e),Wn||(Wn=Yi.fromClass(class{constructor(e){this.view=e,this.decorations=ii.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(In)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Pn({regexp:e.specialChars,decoration:(t,i,s)=>{let{doc:r}=i.state,n=y(t[0],0);if(9==n){let e=r.lineAt(s),t=i.state.tabSize,n=qe(e.text,t,s-e.from);return ii.replace({widget:new qn((t-n%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[n]||(this.decorationCache[n]=ii.replace({widget:new Hn(e,n)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(In);e.startState.facet(In)!=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}))]}let Wn=null;class Hn extends ei{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),i=e.state.phrase("Control character")+" "+(Ln[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class qn extends ei{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const $n=ii.line({class:"cm-activeLine"}),zn=Yi.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 s of e.state.selection.ranges){let r=e.lineBlockAt(s.head);r.from>t&&(i.push($n.range(r.from)),t=r.from)}return ii.set(i)}},{decorations:e=>e.decorations}),Nn=2e3;function Un(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(i),r=i-s.from,n=r>Nn?-1:r==s.length?function(e,t){let i=e.coordsAtPos(e.viewport.from);return i?Math.round(Math.abs((i.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):qe(s.text,e.state.tabSize,i-s.from);return{line:s.number,col:n,off:r}}function Vn(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return Zr.mouseSelectionStyle.of(((e,i)=>t(i)?function(e,t){let i=Un(e,t),s=e.state.selection;return i?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(i.line).from),r=e.state.doc.lineAt(t);i={line:r.number,col:i.col,off:Math.min(i.off,r.length)},s=s.map(e.changes)}},get(t,r,n){let o=Un(e,t);if(!o)return s;let a=function(e,t,i){let s=Math.min(t.line,i.line),r=Math.max(t.line,i.line),n=[];if(t.off>Nn||i.off>Nn||t.col<0||i.col<0){let o=Math.min(t.off,i.off),a=Math.max(t.off,i.off);for(let t=s;t<=r;t++){let i=e.doc.line(t);i.length<=a&&n.push(I.range(i.from+o,i.to+a))}}else{let o=Math.min(t.col,i.col),a=Math.max(t.col,i.col);for(let t=s;t<=r;t++){let i=e.doc.line(t),s=$e(i.text,o,e.tabSize,!0);if(s<0)n.push(I.cursor(i.to));else{let t=$e(i.text,a,e.tabSize);n.push(I.range(i.from+s,i.from+t))}}}return n}(e.state,i,o);return a.length?n?I.create(a.concat(s.ranges)):I.create(a):s}}:null}(e,i):null))}const jn={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Xn={style:"cursor: crosshair"};function Gn(e={}){let[t,i]=jn[e.key||"Alt"],s=Yi.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[s,Zr.contentAttributes.of((e=>{var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.isDown)?Xn:null}))]}const Kn="-10000px";class Zn{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter((e=>e));let r=null;this.tooltipViews=this.tooltips.map((e=>r=i(e,r)))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter((e=>e));if(s===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let n=[],o=t?[]:null;for(let i=0;i<r.length;i++){let s=r[i],a=-1;if(s){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==s.create&&(a=e)}if(a<0)n[i]=this.createTooltipView(s,i?n[i-1]:null),o&&(o[i]=!!s.above);else{let s=n[i]=this.tooltipViews[a];o&&(o[i]=t[a]),s.update&&s.update(e)}}}for(let e of this.tooltipViews)n.indexOf(e)<0&&(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=s,this.tooltips=r,this.tooltipViews=n,!0}}function Yn(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Jn=H.define({combine:e=>{var t,i,s;return{position:qt.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===(s=e.find((e=>e.tooltipSpace)))||void 0===s?void 0:s.tooltipSpace)||Yn}}}),eo=new WeakMap,to=Yi.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(Jn);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 Zn(e,no,((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){this.intersectionObserver.disconnect();for(let e of 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,s=e.state.facet(Jn);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let e of 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),s=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=Kn,i.dom.style.left="0px",this.container.insertBefore(i.dom,s),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var e,t,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of 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(qt.gecko)i=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==Kn&&"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 s=this.view.scrollDOM.getBoundingClientRect(),r=hs(this.view);return{visible:{left:s.left+r.left,top:s.top+r.top,right:s.right-r.right,bottom:s.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map(((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)})),size:this.manager.tooltipViews.map((({dom:e})=>e.getBoundingClientRect())),space:this.view.state.facet(Jn).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:i,space:s,scaleX:r,scaleY:n}=e,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let h=this.manager.tooltips[a],l=this.manager.tooltipViews[a],{dom:c}=l,u=e.pos[a],d=e.size[a];if(!u||!1!==h.clip&&(u.bottom<=Math.max(i.top,s.top)||u.top>=Math.min(i.bottom,s.bottom)||u.right<Math.max(i.left,s.left)-.1||u.left>Math.min(i.right,s.right)+.1)){c.style.top=Kn;continue}let f=h.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,g=d.right-d.left,m=null!==(t=eo.get(l))&&void 0!==t?t:d.bottom-d.top,v=l.offset||ro,_=this.view.textDirection==pi.LTR,O=d.width>s.right-s.left?_?s.left:s.right-d.width:_?Math.max(s.left,Math.min(u.left-(f?14:0)+v.x,s.right-g)):Math.min(Math.max(s.left,u.left-g+(f?14:0)-v.x),s.right-g),S=this.above[a];!h.strictSide&&(S?u.top-m-p-v.y<s.top:u.bottom+m+p+v.y>s.bottom)&&S==s.bottom-u.bottom>u.top-s.top&&(S=this.above[a]=!S);let w=(S?u.top-s.top:s.bottom-u.bottom)-p;if(w<m&&!1!==l.resize){if(w<this.view.defaultLineHeight){c.style.top=Kn;continue}eo.set(l,m),c.style.height=(m=w)/n+"px"}else c.style.height&&(c.style.height="");let b=S?u.top-m-p-v.y:u.bottom+p+v.y,y=O+g;if(!0!==l.overlap)for(let e of o)e.left<y&&e.right>O&&e.top<b+m&&e.bottom>b&&(b=S?e.top-m-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(b-e.parent.top)/n+"px",io(c,(O-e.parent.left)/r)):(c.style.top=b/n+"px",io(c,O/r)),f){let e=u.left+(_?v.x:-v.x)-(O+14-7);f.style.left=e/r+"px"}!0!==l.overlap&&o.push({left:O,top:b,right:y,bottom:b+m}),c.classList.toggle("cm-tooltip-above",S),c.classList.toggle("cm-tooltip-below",!S),l.positioned&&l.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=Kn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function io(e,t){let i=parseInt(e.style.left,10);(isNaN(i)||Math.abs(t-i)>1)&&(e.style.left=t+"px")}const so=Zr.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"}}}),ro={x:0,y:0},no=H.define({enables:[to,so]}),oo=H.define({combine:e=>e.reduce(((e,t)=>e.concat(t)),[])});class ao{static create(e){return new ao(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Zn(e,oo,((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 s=i[e];if(void 0!==s)if(void 0===t)t=s;else if(t!==s)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 ho=no.compute([oo],(e=>{let t=e.facet(oo);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:ao.create,above:t[0].above,arrow:t.some((e=>e.arrow))}}));class lo{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let s,r=1;if(i instanceof Nt)s=i.posAtStart;else{if(s=e.posAtCoords(t),null==s)return;let i=e.coordsAtPos(s);if(!i||t.y<i.top||t.y>i.bottom||t.x<i.left-e.defaultCharacterWidth||t.x>i.right+e.defaultCharacterWidth)return;let n=e.bidiSpans(e.state.doc.lineAt(s)).find((e=>e.from<=s&&e.to>=s)),o=n&&n.dir==pi.RTL?-1:1;r=t.x<i.left?-o:o}let n=this.source(e,s,r);if(null==n?void 0:n.then){let t=this.pending={pos:s};n.then((i=>{this.pending==t&&(this.pending=null,!i||Array.isArray(i)&&!i.length||e.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))}),(t=>Xi(e.state,t,"hover tooltip")))}else!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])})}get tooltip(){let e=this.view.plugin(to),t=e?e.manager.tooltips.findIndex((e=>e.create==ao.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:s,tooltip:r}=this;if(s.length&&r&&!function(e,t){let i,{left:s,right:r,top:n,bottom:o}=e.getBoundingClientRect();if(i=e.querySelector(".cm-tooltip-arrow")){let e=i.getBoundingClientRect();n=Math.min(e.top,n),o=Math.max(e.bottom,o)}return t.clientX>=s-co&&t.clientX<=r+co&&t.clientY>=n-co&&t.clientY<=o+co}(r.dom,e)||this.pending){let{pos:r}=s[0]||this.pending,n=null!==(i=null===(t=s[0])||void 0===t?void 0:t.end)&&void 0!==i?i:r;(r==n?this.view.posAtCoords(this.lastMove)==r:function(e,t,i,s,r){let n=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(n.left>s||n.right<s||n.top>r||Math.min(n.bottom,o)<r)return!1;let a=e.posAtCoords({x:s,y:r},!1);return a>=t&&a<=i}(this.view,r,n,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)}}const co=4;function uo(e,t={}){let i=de.define(),s=j.define({create:()=>[],update(e,s){if(e.length&&(t.hideOnChange&&(s.docChanged||s.selection)?e=[]:t.hideOn&&(e=e.filter((e=>!t.hideOn(s,e)))),s.docChanged)){let t=[];for(let i of e){let e=s.changes.mapPos(i.pos,-1,x.TrackDel);if(null!=e){let r=Object.assign(Object.create(null),i);r.pos=e,null!=r.end&&(r.end=s.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of s.effects)t.is(i)&&(e=t.value),t.is(po)&&(e=[]);return e},provide:e=>oo.from(e)});return{active:s,extension:[s,Yi.define((r=>new lo(r,e,s,i,t.hoverTime||300))),ho]}}function fo(e,t){let i=e.plugin(to);if(!i)return null;let s=i.manager.tooltips.indexOf(t);return s<0?null:i.manager.tooltipViews[s]}const po=de.define(),go=H.define({combine(e){let t,i;for(let s of e)t=t||s.topContainer,i=i||s.bottomContainer;return{topContainer:t,bottomContainer:i}}});function mo(e,t){let i=e.plugin(vo),s=i?i.specs.indexOf(t):-1;return s>-1?i.panels[s]:null}const vo=Yi.fromClass(class{constructor(e){this.input=e.state.facet(So),this.specs=this.input.filter((e=>e)),this.panels=this.specs.map((t=>t(e)));let t=e.state.facet(go);this.top=new _o(e,!0,t.topContainer),this.bottom=new _o(e,!1,t.bottomContainer),this.top.sync(this.panels.filter((e=>e.top))),this.bottom.sync(this.panels.filter((e=>!e.top)));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(go);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new _o(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new _o(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(So);if(i!=this.input){let t=i.filter((e=>e)),s=[],r=[],n=[],o=[];for(let i of t){let t,a=this.specs.indexOf(i);a<0?(t=i(e.view),o.push(t)):(t=this.panels[a],t.update&&t.update(e)),s.push(t),(t.top?r:n).push(t)}this.specs=t,this.panels=s,this.top.sync(r),this.bottom.sync(n);for(let e of 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=>Zr.scrollMargins.of((t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class _o{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&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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=Oo(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Oo(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 Oo(e){let t=e.nextSibling;return e.remove(),t}const So=H.define({enables:vo});class wo extends Ce{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}wo.prototype.elementClass="",wo.prototype.toDOM=void 0,wo.prototype.mapMode=x.TrackBefore,wo.prototype.startSide=wo.prototype.endSide=-1,wo.prototype.point=!0;const bo=H.define(),yo=H.define(),Do={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Te.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Co=H.define();function ko(e){return[Eo(),Co.of(Object.assign(Object.assign({},Do),e))]}const xo=H.define({combine:e=>e.some((e=>e))});function Eo(e){let t=[To];return e&&!1===e.fixed&&t.push(xo.of(!0)),t}const To=Yi.fromClass(class{constructor(e){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(Co).map((t=>new Mo(e,t)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!e.state.facet(xo),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,s=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(s<.8*(i.to-i.from))}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(xo)!=!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=Te.iter(this.view.state.facet(bo),this.view.viewport.from),s=[],r=this.gutters.map((e=>new Po(e,this.view.viewport,-this.view.documentPadding.top)));for(let e of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(e.type)){let t=!0;for(let n of e.type)if(n.type==ti.Text&&t){Ro(i,s,n.from);for(let e of r)e.line(this.view,n,s);t=!1}else if(n.widget)for(let e of r)e.widget(this.view,n)}else if(e.type==ti.Text){Ro(i,s,e.from);for(let t of r)t.line(this.view,e,s)}else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(Co),i=e.state.facet(Co),s=e.docChanged||e.heightChanged||e.viewportChanged||!Te.eq(e.startState.facet(bo),e.state.facet(bo),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(s=!0);else{s=!0;let r=[];for(let s of i){let i=t.indexOf(s);i<0?r.push(new Mo(this.view,s)):(this.gutters[i].update(e),r.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),r.indexOf(e)<0&&e.destroy();for(let e of r)this.dom.appendChild(e.dom);this.gutters=r}return s}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Zr.scrollMargins.of((t=>{let i=t.plugin(e);return i&&0!=i.gutters.length&&i.fixed?t.textDirection==pi.LTR?{left:i.dom.offsetWidth*t.scaleX}:{right:i.dom.offsetWidth*t.scaleX}:null}))});function Ao(e){return Array.isArray(e)?e:[e]}function Ro(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class Po{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Te.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,n=t.height/e.scaleY;if(this.i==s.elements.length){let t=new Bo(e,n,r,i);s.elements.push(t),s.dom.appendChild(t.dom)}else s.elements[this.i].update(e,n,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Ro(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let n=this.gutter;(0!=s.length||n.config.renderEmptyElements)&&this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let i of e.state.facet(yo)){let r=i(e,t.widget,t);r&&(s||(s=[])).push(r)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Mo{constructor(e,t){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:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,(s=>{let r,n=s.target;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let e=n.getBoundingClientRect();r=(e.top+e.bottom)/2}else r=s.clientY;let o=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[i](e,o,s)&&s.preventDefault()}));this.markers=Ao(t.markers(e)),t.initialSpacer&&(this.spacer=new Bo(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=Ao(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!Te.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 Bo{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){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;i<e.length;i++)if(!e[i].compare(t[i]))return!1;return!0}(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,n=0;;){let o=n,a=r<t.length?t[r++]:null,h=!1;if(a){let e=a.elementClass;e&&(i+=" "+e);for(let e=n;e<this.markers.length;e++)if(this.markers[e].compare(a)){o=e,h=!0;break}}else o=this.markers.length;for(;n<o;){let e=this.markers[n++];if(e.toDOM){e.destroy(s);let t=s.nextSibling;s.remove(),s=t}}if(!a)break;a.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),h&&n++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}const Lo=H.define(),Fo=H.define(),Io=H.define({combine:e=>De(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let s=i[e],r=t[e];i[e]=s?(e,t,i)=>s(e,t,i)||r(e,t,i):r}return i}})});class Qo extends wo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Wo(e,t){return e.state.facet(Io).formatNumber(t,e.state)}const Ho=Co.compute([Io],(e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Lo),lineMarker:(e,t,i)=>i.some((e=>e.toDOM))?null:new Qo(Wo(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,i)=>{for(let s of e.state.facet(Fo)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Io)!=e.state.facet(Io),initialSpacer:e=>new Qo(Wo(e,$o(e.state.doc.lines))),updateSpacer(e,t){let i=Wo(t.view,$o(t.view.state.doc.lines));return i==e.number?e:new Qo(i)},domEventHandlers:e.facet(Io).domEventHandlers})));function qo(e={}){return[Io.of(e),Eo(),Ho]}function $o(e){let t=9;for(;t<e;)t=10*t+9;return t}const zo=new class extends wo{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},No=bo.compute(["selection"],(e=>{let t=[],i=-1;for(let s of e.selection.ranges){let r=e.doc.lineAt(s.head).from;r>i&&(i=r,t.push(zo.range(r)))}return Te.of(t)})),Uo=1024;let Vo=0;class jo{constructor(e,t){this.from=e,this.to=t}}class Xo{constructor(e={}){this.id=Vo++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=Zo.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}Xo.closedBy=new Xo({deserialize:e=>e.split(" ")}),Xo.openedBy=new Xo({deserialize:e=>e.split(" ")}),Xo.group=new Xo({deserialize:e=>e.split(" ")}),Xo.isolate=new Xo({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),Xo.contextHash=new Xo({perNode:!0}),Xo.lookAhead=new Xo({perNode:!0}),Xo.mounted=new Xo({perNode:!0});class Go{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Xo.mounted.id]}}const Ko=Object.create(null);class Zo{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Ko,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),s=new Zo(e.name||"",t,e.id,i);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return s}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(Xo.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 s of i.split(" "))t[s]=e[i];return e=>{for(let i=e.prop(Xo.group),s=-1;s<(i?i.length:0);s++){let r=t[s<0?e.name:i[s]];if(r)return r}}}}Zo.none=new Zo("",Object.create(null),0,8);class Yo{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let s=null;for(let t of e){let e=t(i);e&&(s||(s=Object.assign({},i.props)),s[e[0].id]=e[1])}t.push(s?new Zo(i.name,s,i.id,i.flags):i)}return new Yo(t)}}const Jo=new WeakMap,ea=new WeakMap;var ta;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(ta||(ta={}));class ia{constructor(e,t,i,s,r){if(this.type=e,this.children=t,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=Go.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let i=e.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ga(this.topNode,e)}cursorAt(e,t=0,i=0){let s=Jo.get(this)||this.topNode,r=new ga(s);return r.moveTo(e,t),Jo.set(this,r._tree),r}get topNode(){return new ha(this,0,0,null)}resolve(e,t=0){let i=oa(Jo.get(this)||this.topNode,e,t,!1);return Jo.set(this,i),i}resolveInner(e,t=0){let i=oa(ea.get(this)||this.topNode,e,t,!0);return ea.set(this,i),i}resolveStack(e,t=0){return function(e,t,i){let s=e.resolveInner(t,i),r=null;for(let e=s instanceof ha?s:s.context.parent;e;e=e.parent)if(e.index<0){let n=e.parent;(r||(r=[s])).push(n.resolve(t,i)),e=n}else{let n=Go.get(e.tree);if(n&&n.overlay&&n.overlay[0].from<=t&&n.overlay[n.overlay.length-1].to>=t){let o=new ha(n.tree,n.overlay[0].from+e.from,-1,e);(r||(r=[s])).push(oa(o,t,i,!1))}}return r?fa(r):s}(this,e,t)}iterate(e){let{enter:t,leave:i,from:s=0,to:r=this.length}=e,n=e.mode||0,o=(n&ta.IncludeAnonymous)>0;for(let e=this.cursor(n|ta.IncludeAnonymous);;){let n=!1;if(e.from<=r&&e.to>=s&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;n=!0}for(;n&&i&&(o||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;n=!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:Oa(Zo.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,i)=>new ia(this.type,e,t,i,this.propValues)),e.makeTree||((e,t,i)=>new ia(Zo.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:s,maxBufferLength:r=Uo,reused:n=[],minRepeatType:o=s.types.length}=e,a=Array.isArray(i)?new sa(i,i.length):i,h=s.types,l=0,c=0;function u(e,t,i,m,v,_){let{id:O,start:S,end:w,size:b}=a,y=c,D=l;for(;b<0;){if(a.next(),-1==b){let t=n[O];return i.push(t),void m.push(S-e)}if(-3==b)return void(l=O);if(-4==b)return void(c=O);throw new RangeError(`Unrecognized record size: ${b}`)}let C,k,x=h[O],E=S-e;if(w-S<=r&&(k=function(e,t){let i=a.fork(),s=0,n=0,h=0,l=i.end-r,c={size:0,start:0,skip:0};e:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){c.size=s,c.start=n,c.skip=h,h+=4,s+=4,i.next();continue}let a=i.pos-e;if(e<0||a<r||i.start<l)break;let u=i.id>=o?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break e;u+=4}else i.id>=o&&(u+=4);i.next()}n=d,s+=e,h+=u}return(t<0||s==e)&&(c.size=s,c.start=n,c.skip=h),c.size>4?c:void 0}(a.pos-t,v))){let t=new Uint16Array(k.size-k.skip),i=a.pos-k.size,r=t.length;for(;a.pos>i;)r=g(k.start,t,r);C=new ra(t,w-k.start,s),E=k.start-e}else{let e=a.pos-b;a.next();let t=[],i=[],s=O>=o?O:-1,n=0,h=w;for(;a.pos>e;)s>=0&&a.id==s&&a.size>=0?(a.end<=h-r&&(f(t,i,S,n,a.end,h,s,y,D),n=t.length,h=a.end),a.next()):_>2500?d(S,e,t,i):u(S,e,t,i,s,_+1);if(s>=0&&n>0&&n<t.length&&f(t,i,S,n,S,h,s,y,D),t.reverse(),i.reverse(),s>-1&&n>0){let e=function(e,t){return(i,s,r)=>{let n,o,a=0,h=i.length-1;if(h>=0&&(n=i[h])instanceof ia){if(!h&&n.type==e&&n.length==r)return n;(o=n.prop(Xo.lookAhead))&&(a=s[h]+n.length+o)}return p(e,i,s,r,a,t)}}(x,D);C=Oa(x,t,i,0,t.length,0,w-S,e,e)}else C=p(x,t,i,w-S,y-w,D)}i.push(C),m.push(E)}function d(e,t,i,n){let o=[],h=0,l=-1;for(;a.pos>t;){let{id:e,start:t,end:i,size:s}=a;if(s>4)a.next();else{if(l>-1&&t<l)break;l<0&&(l=i-r),o.push(e,t,i),h++,a.next()}}if(h){let t=new Uint16Array(4*h),r=o[o.length-2];for(let e=o.length-3,i=0;e>=0;e-=3)t[i++]=o[e],t[i++]=o[e+1]-r,t[i++]=o[e+2]-r,t[i++]=i;i.push(new ra(t,o[2]-r,s)),n.push(r-e)}}function f(e,t,i,r,n,o,a,h,l){let c=[],u=[];for(;e.length>r;)c.push(e.pop()),u.push(t.pop()+i-n);e.push(p(s.types[a],c,u,o-n,h-o,l)),t.push(n-i)}function p(e,t,i,s,r,n,o){if(n){let e=[Xo.contextHash,n];o=o?[e].concat(o):[e]}if(r>25){let e=[Xo.lookAhead,r];o=o?[e].concat(o):[e]}return new ia(e,t,i,s,o)}function g(e,t,i){let{id:s,start:r,end:n,size:h}=a;if(a.next(),h>=0&&s<o){let o=i;if(h>4){let s=a.pos-(h-4);for(;a.pos>s;)i=g(e,t,i)}t[--i]=o,t[--i]=n-e,t[--i]=r-e,t[--i]=s}else-3==h?l=s:-4==h&&(c=s);return i}let m=[],v=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,m,v,-1,0);let _=null!==(t=e.length)&&void 0!==t?t:m.length?v[0]+m[0].length:0;return new ia(h[e.topID],m.reverse(),v.reverse(),_)}(e)}}ia.empty=new ia(Zo.none,[],[],0);class sa{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 sa(this.buffer,this.index)}}class ra{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Zo.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),i==(e+=4))return r;let n=[];for(;e<i;)n.push(this.childString(e)),e=this.buffer[e+3];return r+"("+n.join(",")+")"}findChild(e,t,i,s,r){let{buffer:n}=this,o=-1;for(let a=e;a!=t&&!(na(r,s,n[a+1],n[a+2])&&(o=a,i>0));a=n[a+3]);return o}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),n=0;for(let o=e,a=0;o<t;){r[a++]=s[o++],r[a++]=s[o++]-i;let t=r[a++]=s[o++]-i;r[a++]=s[o++]-e,n=Math.max(n,t)}return new ra(r,n,this.set)}}function na(e,t,i,s){switch(e){case-2:return i<t;case-1:return s>=t&&i<t;case 0:return i<t&&s>t;case 1:return i<=t&&s>t;case 2:return s>t;case 4:return!0}}function oa(e,t,i,s){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to<t);){let t=!s&&e instanceof ha&&e.index<0?null:e.parent;if(!t)return e;e=t}let n=s?0:ta.IgnoreOverlays;if(s)for(let s=e,o=s.parent;o;s=o,o=s.parent)s instanceof ha&&s.index<0&&(null===(r=o.enter(t,i,n))||void 0===r?void 0:r.from)!=s.from&&(e=o);for(;;){let s=e.enter(t,i,n);if(!s)return e;e=s}}class aa{cursor(e=0){return new ga(this,e)}getChild(e,t=null,i=null){let s=la(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return la(this,e,t,i)}resolve(e,t=0){return oa(this,e,t,!1)}resolveInner(e,t=0){return oa(this,e,t,!0)}matchContext(e){return ca(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(i=t,t=e.prevSibling):t=e}return i}get node(){return this}get next(){return this.parent}}class ha extends aa{constructor(e,t,i,s){super(),this._tree=e,this.from=t,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,s,r=0){for(let n=this;;){for(let{children:o,positions:a}=n._tree,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],l=a[e]+n.from;if(na(s,i,l,l+h.length))if(h instanceof ra){if(r&ta.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,i-l,s);if(o>-1)return new da(new ua(n,h,e,l),null,o)}else if(r&ta.IncludeAnonymous||!h.type.isAnonymous||ma(h)){let o;if(!(r&ta.IgnoreMounts)&&(o=Go.get(h))&&!o.overlay)return new ha(o.tree,l,e,n);let a=new ha(h,l,e,n);return r&ta.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?h.children.length-1:0,t,i,s)}}if(r&ta.IncludeAnonymous||!n.type.isAnonymous)return null;if(e=n.index>=0?n.index+t:t<0?-1:n._parent._tree.children.length,n=n._parent,!n)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 s;if(!(i&ta.IgnoreOverlays)&&(s=Go.get(this._tree))&&s.overlay){let i=e-this.from;for(let{from:e,to:r}of s.overlay)if((t>0?e<=i:e<i)&&(t<0?r>=i:r>i))return new ha(s.tree,s.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 la(e,t,i,s){let r=e.cursor(),n=[];if(!r.firstChild())return n;if(null!=i)for(let e=!1;!e;)if(e=r.type.is(i),!r.nextSibling())return n;for(;;){if(null!=s&&r.type.is(s))return n;if(r.type.is(t)&&n.push(r.node),!r.nextSibling())return null==s?n:[]}}function ca(e,t,i=t.length-1){for(let s=e;i>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}class ua{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class da extends aa{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:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new da(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ta.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new da(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new da(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 da(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let n=i.buffer[this.index+1];e.push(i.slice(s,r,n)),t.push(0)}return new ia(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function fa(e){if(!e.length)return null;let t=0,i=e[0];for(let s=1;s<e.length;s++){let r=e[s];(r.from>i.from||r.to<i.to)&&(i=r,t=s)}let s=i instanceof ha&&i.index<0?null:i.parent,r=e.slice();return s?r[t]=s:r.splice(t,1),new pa(r,i)}class pa{constructor(e,t){this.heads=e,this.node=t}get next(){return fa(this.heads)}}class ga{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ha)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return!!e&&(e instanceof ha?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?!(i&ta.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ta.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ta.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(s.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;({index:t,_parent:i}=i))if(t>-1)for(let s=t+e,r=e<0?-1:i._tree.children.length;s!=r;s+=e){let e=i._tree.children[s];if(this.mode&ta.IncludeAnonymous||e instanceof ra||!e.type.isAnonymous||ma(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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let n=e;n;n=n._parent)if(n.index==s){if(s==this.index)return n;t=n,i=r+1;break e}s=this.stack[--r]}for(let e=i;e<this.stack.length;e++)t=new da(this.buffer,t,this.stack[e]);return this.bufferNode=new da(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let s=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(e){if(!this.buffer)return ca(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return ca(this._tree,e,s);let n=i[t.buffer[this.stack[r]]];if(!n.isAnonymous){if(e[s]&&e[s]!=n.name)return!1;s--}}return!0}}function ma(e){return e.children.some((e=>e instanceof ra||!e.type.isAnonymous||ma(e)))}const va=new WeakMap;function _a(e,t){if(!e.isAnonymous||t instanceof ra||t.type!=e)return 1;let i=va.get(t);if(null==i){i=1;for(let s of t.children){if(s.type!=e||!(s instanceof ia)){i=1;break}i+=_a(e,s)}va.set(t,i)}return i}function Oa(e,t,i,s,r,n,o,a,h){let l=0;for(let i=s;i<r;i++)l+=_a(e,t[i]);let c=Math.ceil(1.5*l/8),u=[],d=[];return function t(i,s,r,o,a){for(let l=r;l<o;){let r=l,f=s[l],p=_a(e,i[l]);for(l++;l<o;l++){let t=_a(e,i[l]);if(p+t>=c)break;p+=t}if(l==r+1){if(p>c){let e=i[r];t(e.children,e.positions,0,e.children.length,s[r]+a);continue}u.push(i[r])}else{let t=s[l-1]+i[l-1].length-f;u.push(Oa(e,i,s,r,l,f,t,null,h))}d.push(f+a-n)}}(t,i,s,r,0),(a||h)(u,d,o)}class Sa{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof da?this.setBuffer(e.context.buffer,e.index,t):e instanceof ha&&this.map.set(e.tree,t)}get(e){return e instanceof da?this.getBuffer(e.context.buffer,e.index):e instanceof ha?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 wa{constructor(e,t,i,s,r=!1,n=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(n?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let s=[new wa(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&s.push(i);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,n=e.length?e[0]:null;for(let o=0,a=0,h=0;;o++){let l=o<t.length?t[o]:null,c=l?l.fromA:1e9;if(c-a>=i)for(;n&&n.from<c;){let t=n;if(a>=t.from||c<=t.to||h){let e=Math.max(t.from,a)-h,i=Math.min(t.to,c)-h;t=e>=i?null:new wa(e,i,t.tree,t.offset+h,o>0,!!l)}if(t&&s.push(t),n.to>c)break;n=r<e.length?e[r++]:null}if(!l)break;a=l.toA,h=l.toA-l.toB}return s}}class ba{startParse(e,t,i){return"string"==typeof e&&(e=new ya(e)),i=i?i.length?i.map((e=>new jo(e.from,e.to))):[new jo(0,0)]:[new jo(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let e=s.advance();if(e)return e}}}class ya{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)}}new Xo({perNode:!0});let Da=0;class Ca{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=Da++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i="string"==typeof e?e:"?";if(e instanceof Ca&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let s=new Ca(i,[],null,[]);if(s.set.push(s),t)for(let e of t.set)s.set.push(e);return s}static defineModifier(e){let t=new xa(e);return e=>e.modified.indexOf(t)>-1?e:xa.get(e.base||e,e.modified.concat(t).sort(((e,t)=>e.id-t.id)))}}let ka=0;class xa{constructor(e){this.name=e,this.instances=[],this.id=ka++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find((i=>{return i.base==e&&(s=t,r=i.modified,s.length==r.length&&s.every(((e,t)=>e==r[t])));var s,r}));if(i)return i;let s=[],r=new Ca(e.name,s,e,t);for(let e of t)e.instances.push(r);let n=function(e){let t=[[]];for(let i=0;i<e.length;i++)for(let s=0,r=t.length;s<r;s++)t.push(t[s].concat(e[i]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of n)s.push(xa.get(t,e));return r}}function Ea(e){let t=Object.create(null);for(let i in e){let s=e[i];Array.isArray(s)||(s=[s]);for(let e of i.split(" "))if(e){let i=[],r=2,n=e;for(let t=0;;){if("..."==n&&t>0&&t+3==e.length){r=1;break}let s=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(n);if(!s)throw new RangeError("Invalid path: "+e);if(i.push("*"==s[0]?"":'"'==s[0][0]?JSON.parse(s[0]):s[0]),t+=s[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);n=e.slice(t)}let o=i.length-1,a=i[o];if(!a)throw new RangeError("Invalid path: "+e);let h=new Aa(s,r,o>0?i.slice(0,o):null);t[a]=h.sort(t[a])}}return Ta.add(t)}const Ta=new Xo;class Aa{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function Ra(e,t){let i=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)i[e.id]=t.class;else i[t.tag.id]=t.class;let{scope:s,all:r=null}=t||{};return{style:e=>{let t=r;for(let s of e)for(let e of s.set){let s=i[e.id];if(s){t=t?t+" "+s:s;break}}return t},scope:s}}function Pa(e,t,i,s=0,r=e.length){let n=new Ma(s,Array.isArray(t)?t:[t],i);n.highlightRange(e.cursor(),s,r,"",n.highlighters),n.flush(r)}Aa.empty=new Aa([],2,null);class Ma{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,s,r){let{type:n,from:o,to:a}=e;if(o>=i||a<=t)return;n.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(n))));let h=s,l=function(e){let t=e.type.prop(Ta);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||Aa.empty,c=function(e,t){let i=null;for(let s of e){let e=s.style(t);e&&(i=i?i+" "+e:e)}return i}(r,l.tags);if(c&&(h&&(h+=" "),h+=c,1==l.mode&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(t,o),h),l.opaque)return;let u=e.tree&&e.tree.prop(Xo.mounted);if(u&&u.overlay){let n=e.node.enter(u.overlay[0].from+o,1),l=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),c=e.firstChild();for(let d=0,f=o;;d++){let p=d<u.overlay.length?u.overlay[d]:null,g=p?p.from+o:a,m=Math.max(t,f),v=Math.min(i,g);if(m<v&&c)for(;e.from<v&&(this.highlightRange(e,m,v,s,r),this.startSpan(Math.min(v,e.to),h),!(e.to>=g)&&e.nextSibling()););if(!p||g>i)break;f=p.to+o,f>t&&(this.highlightRange(n.cursor(),Math.max(t,p.from+o),Math.min(i,f),"",l),this.startSpan(Math.min(i,f),h))}c&&e.parent()}else if(e.firstChild()){u&&(s="");do{if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}}while(e.nextSibling());e.parent()}}}const Ba=Ca.define,La=Ba(),Fa=Ba(),Ia=Ba(Fa),Qa=Ba(Fa),Wa=Ba(),Ha=Ba(Wa),qa=Ba(Wa),$a=Ba(),za=Ba($a),Na=Ba(),Ua=Ba(),Va=Ba(),ja=Ba(Va),Xa=Ba(),Ga={comment:La,lineComment:Ba(La),blockComment:Ba(La),docComment:Ba(La),name:Fa,variableName:Ba(Fa),typeName:Ia,tagName:Ba(Ia),propertyName:Qa,attributeName:Ba(Qa),className:Ba(Fa),labelName:Ba(Fa),namespace:Ba(Fa),macroName:Ba(Fa),literal:Wa,string:Ha,docString:Ba(Ha),character:Ba(Ha),attributeValue:Ba(Ha),number:qa,integer:Ba(qa),float:Ba(qa),bool:Ba(Wa),regexp:Ba(Wa),escape:Ba(Wa),color:Ba(Wa),url:Ba(Wa),keyword:Na,self:Ba(Na),null:Ba(Na),atom:Ba(Na),unit:Ba(Na),modifier:Ba(Na),operatorKeyword:Ba(Na),controlKeyword:Ba(Na),definitionKeyword:Ba(Na),moduleKeyword:Ba(Na),operator:Ua,derefOperator:Ba(Ua),arithmeticOperator:Ba(Ua),logicOperator:Ba(Ua),bitwiseOperator:Ba(Ua),compareOperator:Ba(Ua),updateOperator:Ba(Ua),definitionOperator:Ba(Ua),typeOperator:Ba(Ua),controlOperator:Ba(Ua),punctuation:Va,separator:Ba(Va),bracket:ja,angleBracket:Ba(ja),squareBracket:Ba(ja),paren:Ba(ja),brace:Ba(ja),content:$a,heading:za,heading1:Ba(za),heading2:Ba(za),heading3:Ba(za),heading4:Ba(za),heading5:Ba(za),heading6:Ba(za),contentSeparator:Ba($a),list:Ba($a),quote:Ba($a),emphasis:Ba($a),strong:Ba($a),link:Ba($a),monospace:Ba($a),strikethrough:Ba($a),inserted:Ba(),deleted:Ba(),changed:Ba(),invalid:Ba(),meta:Xa,documentMeta:Ba(Xa),annotation:Ba(Xa),processingInstruction:Ba(Xa),definition:Ca.defineModifier("definition"),constant:Ca.defineModifier("constant"),function:Ca.defineModifier("function"),standard:Ca.defineModifier("standard"),local:Ca.defineModifier("local"),special:Ca.defineModifier("special")};for(let e in Ga){let t=Ga[e];t instanceof Ca&&(t.name=e)}var Ka;Ra([{tag:Ga.link,class:"tok-link"},{tag:Ga.heading,class:"tok-heading"},{tag:Ga.emphasis,class:"tok-emphasis"},{tag:Ga.strong,class:"tok-strong"},{tag:Ga.keyword,class:"tok-keyword"},{tag:Ga.atom,class:"tok-atom"},{tag:Ga.bool,class:"tok-bool"},{tag:Ga.url,class:"tok-url"},{tag:Ga.labelName,class:"tok-labelName"},{tag:Ga.inserted,class:"tok-inserted"},{tag:Ga.deleted,class:"tok-deleted"},{tag:Ga.literal,class:"tok-literal"},{tag:Ga.string,class:"tok-string"},{tag:Ga.number,class:"tok-number"},{tag:[Ga.regexp,Ga.escape,Ga.special(Ga.string)],class:"tok-string2"},{tag:Ga.variableName,class:"tok-variableName"},{tag:Ga.local(Ga.variableName),class:"tok-variableName tok-local"},{tag:Ga.definition(Ga.variableName),class:"tok-variableName tok-definition"},{tag:Ga.special(Ga.variableName),class:"tok-variableName2"},{tag:Ga.definition(Ga.propertyName),class:"tok-propertyName tok-definition"},{tag:Ga.typeName,class:"tok-typeName"},{tag:Ga.namespace,class:"tok-namespace"},{tag:Ga.className,class:"tok-className"},{tag:Ga.macroName,class:"tok-macroName"},{tag:Ga.propertyName,class:"tok-propertyName"},{tag:Ga.operator,class:"tok-operator"},{tag:Ga.comment,class:"tok-comment"},{tag:Ga.meta,class:"tok-meta"},{tag:Ga.invalid,class:"tok-invalid"},{tag:Ga.punctuation,class:"tok-punctuation"}]);const Za=new Xo;const Ya=new Xo;class Ja{constructor(e,t,i=[],s=""){this.data=e,this.name=s,ye.prototype.hasOwnProperty("tree")||Object.defineProperty(ye.prototype,"tree",{get(){return ih(this)}}),this.parser=t,this.extension=[uh.of(this),ye.languageData.of(((e,t,i)=>{let s=eh(e,t,i),r=s.type.prop(Za);if(!r)return[];let n=e.facet(r),o=s.type.prop(Ya);if(o){let r=s.resolve(t-s.from,i);for(let t of o)if(t.test(r,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(n)}}return n}))].concat(i)}isActiveAt(e,t,i=-1){return eh(e,t,i).type.prop(Za)==this.data}findRegions(e){let t=e.facet(uh);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(e,t)=>{if(e.prop(Za)==this.data)return void i.push({from:t,to:t+e.length});let r=e.prop(Xo.mounted);if(r){if(r.tree.prop(Za)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(s(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;i<e.children.length;i++){let r=e.children[i];r instanceof ia&&s(r,e.positions[i]+t)}};return s(ih(e),0),i}get allowsNesting(){return!0}}function eh(e,t,i){let s=e.facet(uh),r=ih(e).topNode;if(!s||s.allowsNesting)for(let e=r;e;e=e.enter(t,i,ta.ExcludeBuffers))e.type.isTop&&(r=e);return r}Ja.setState=de.define();class th extends Ja{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=(i=e.languageData,H.define({combine:i?e=>e.concat(i):void 0}));var i;return new th(t,e.parser.configure({props:[Za.add((e=>e.isTop?t:void 0))]}),e.name)}configure(e,t){return new th(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ih(e){let t=e.field(Ja.state,!1);return t?t.tree:ia.empty}class sh{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<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let rh=null;class nh{constructor(e,t,i=[],s,r,n,o,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=n,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new nh(e,t,[],ia.empty,0,i,[],null)}startParse(){return this.parser.startParse(new sh(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=ia.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.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s){if(this.fragments=this.withoutTempSkipped(wa.addTree(s,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=s,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(wa.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=rh;rh=this;try{return e()}finally{rh=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=oh(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:n,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,i,s,r)=>t.push({fromA:e,toA:i,fromB:s,toB:r}))),i=wa.applyChanges(i,t),s=ia.empty,r=0,n={from:e.mapPos(n.from,-1),to:e.mapPos(n.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let i=e.mapPos(t.from,1),s=e.mapPos(t.to,-1);i<s&&o.push({from:i,to:s})}}}return new nh(this.parser,t,i,s,r,n,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:i,to:s}=this.skipped[t];i<e.to&&s>e.from&&(this.fragments=oh(this.fragments,i,s),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 ba{createParse(t,i,s){let r=s[0].from,n=s[s.length-1].to;return{parsedPos:r,advance(){let t=rh;if(t){for(let e of s)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=n,new ia(Zo.none,[],[],n-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return rh}}function oh(e,t,i){return wa.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class ah{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 ah(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=nh.create(e.facet(uh).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ah(i)}}Ja.state=j.define({create:ah.init,update(e,t){for(let e of t.effects)if(e.is(Ja.setState))return e.value;return t.startState.facet(uh)!=t.state.facet(uh)?ah.init(t.state):e.apply(t)}});let hh=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(hh=e=>{let t=-1,i=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const lh="undefined"!=typeof navigator&&(null===(Ka=navigator.scheduling)||void 0===Ka?void 0:Ka.isInputPending)?()=>navigator.scheduling.isInputPending():null,ch=Yi.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(Ja.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(Ja.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=hh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Ja.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let n=Date.now()+Math.min(this.chunkBudget,100,e&&!lh?Math.max(25,e.timeRemaining()-5):1e9),o=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work((()=>lh&&lh()||Date.now()>n),s+(o?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ja.setState.of(new ah(r.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>Xi(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()}}}),uh=H.define({combine:e=>e.length?e[0]:null,enables:e=>[Ja.state,ch,Zr.contentAttributes.compute([e],(t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}}))]});const dh=H.define(),fh=H.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 new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function ph(e){let t=e.facet(fh);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function gh(e,t){let i="",s=e.tabSize,r=e.facet(fh)[0];if("\t"==r){for(;t>=s;)i+="\t",t-=s;r=" "}for(let e=0;e<t;e++)i+=r;return i}function mh(e,t){e instanceof ye&&(e=new vh(e));for(let i of e.state.facet(dh)){let s=i(e,t);if(void 0!==s)return s}let i=ih(e.state);return i.length>=t?function(e,t,i){let s=t.resolveStack(i),r=t.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=s.node){let e=[];for(let t=r;t&&(t.from!=s.node.from||t.type!=s.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)s={node:e[t],next:s}}return Oh(s,e,i)}(e,i,t):null}class vh{constructor(e,t={}){this.state=e,this.options=t,this.unit=ph(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return null!=s&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),n=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return n>-1&&(r+=n-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return qe(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(s);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const _h=new Xo;function Oh(e,t,i){for(let s=e;s;s=s.next){let e=Sh(s.node);if(e)return e(bh.create(t,i,s))}return 0}function Sh(e){let t=e.type.prop(_h);if(t)return t;let i,s=e.firstChild;if(s&&(i=s.type.prop(Xo.closedBy))){let t=e.lastChild,s=t&&i.indexOf(t.name)>-1;return e=>Ch(e,!0,1,void 0,s&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?wh:null}function wh(){return 0}class bh extends vh{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 bh(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(yh(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Oh(this.context.next,this.base,this.pos)}}function yh(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}function Dh({closing:e,align:t=!0,units:i=1}){return s=>Ch(s,t,i,e)}function Ch(e,t,i,s,r){let n=e.textAfter,o=n.match(/^\s*/)[0].length,a=s&&n.slice(o,o+s.length)==s||r==e.pos+o,h=t?function(e){let t=e.node,i=t.childAfter(t.from),s=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,n=e.state.doc.lineAt(i.from),o=null==r||r<=n.from?n.to:Math.min(n.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==s)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(n.text.slice(i.to-n.from))[0].length;return{from:i.from,to:i.to+e}}e=r.to}}(e):null;return h?a?e.column(h.from):e.column(h.to):e.baseIndent+(a?0:e.unit*i)}const kh=H.define(),xh=new Xo;function Eh(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Th(e,t,i){for(let s of e.facet(kh)){let r=s(e,t,i);if(r)return r}return function(e,t,i){let s=ih(e);if(s.length<i)return null;let r=null;for(let n=s.resolveStack(i,1);n;n=n.next){let o=n.node;if(o.to<=i||o.from>i)continue;if(r&&o.from<t)break;let a=o.type.prop(xh);if(a&&(o.to<s.length-50||s.length==e.doc.length||!Eh(o))){let s=a(o,e);s&&s.from<=i&&s.from>=t&&s.to>i&&(r=s)}}return r}(e,t,i)}function Ah(e,t){let i=t.mapPos(e.from,1),s=t.mapPos(e.to,-1);return i>=s?void 0:{from:i,to:s}}const Rh=de.define({map:Ah}),Ph=de.define({map:Ah});function Mh(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 Bh=j.define({create:()=>ii.none,update(e,t){e=e.map(t.changes);for(let i of t.effects)if(i.is(Rh)&&!Fh(e,i.value.from,i.value.to)){let{preparePlaceholder:s}=t.state.facet(qh),r=s?ii.replace({widget:new Uh(s(t.state,i.value))}):Nh;e=e.update({add:[r.range(i.value.from,i.value.to)]})}else i.is(Ph)&&(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:s}=t.selection.main;e.between(s,s,((e,t)=>{e<s&&t>s&&(i=!0)})),i&&(e=e.update({filterFrom:s,filterTo:s,filter:(e,t)=>t<=s||e>=s}))}return e},provide:e=>Zr.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 new RangeError("Invalid JSON for fold state");let t=[];for(let i=0;i<e.length;){let s=e[i++],r=e[i++];if("number"!=typeof s||"number"!=typeof r)throw new RangeError("Invalid JSON for fold state");t.push(Nh.range(s,r))}return ii.set(t,!0)}});function Lh(e,t,i){var s;let r=null;return null===(s=e.field(Bh,!1))||void 0===s||s.between(t,i,((e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})})),r}function Fh(e,t,i){let s=!1;return e.between(t,t,((e,r)=>{e==t&&r==i&&(s=!0)})),s}function Ih(e,t){return e.field(Bh,!1)?t:t.concat(de.appendConfig.of($h()))}function Qh(e,t,i=!0){let s=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return Zr.announce.of(`${e.state.phrase(i?"Folded lines":"Unfolded lines")} ${s} ${e.state.phrase("to")} ${r}.`)}const Wh=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of Mh(e)){let i=Th(e.state,t.from,t.to);if(i)return e.dispatch({effects:Ih(e.state,[Rh.of(i),Qh(e,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(Bh,!1))return!1;let t=[];for(let i of Mh(e)){let s=Lh(e.state,i.from,i.to);s&&t.push(Ph.of(s),Qh(e,s,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,i=[];for(let s=0;s<t.doc.length;){let r=e.lineBlockAt(s),n=Th(t,r.from,r.to);n&&i.push(Rh.of(n)),s=(n?e.lineBlockAt(n.to):r).to+1}return i.length&&e.dispatch({effects:Ih(e.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(Bh,!1);if(!t||!t.size)return!1;let i=[];return t.between(0,e.state.doc.length,((e,t)=>{i.push(Ph.of({from:e,to:t}))})),e.dispatch({effects:i}),!0}}],Hh={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},qh=H.define({combine:e=>De(e,Hh)});function $h(e){let t=[Bh,Gh];return e&&t.push(qh.of(e)),t}function zh(e,t){let{state:i}=e,s=i.facet(qh),r=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),s=Lh(e.state,i.from,i.to);s&&e.dispatch({effects:Ph.of(s)}),t.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(e,r,t);let n=document.createElement("span");return n.textContent=s.placeholderText,n.setAttribute("aria-label",i.phrase("folded code")),n.title=i.phrase("unfold"),n.className="cm-foldPlaceholder",n.onclick=r,n}const Nh=ii.replace({widget:new class extends ei{toDOM(e){return zh(e,null)}}});class Uh extends ei{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return zh(e,this.value)}}const Vh={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class jh extends wo{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}}function Xh(e={}){let t=Object.assign(Object.assign({},Vh),e),i=new jh(t,!0),s=new jh(t,!1),r=Yi.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(uh)!=e.state.facet(uh)||e.startState.field(Bh,!1)!=e.state.field(Bh,!1)||ih(e.startState)!=ih(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Ae;for(let r of e.viewportLineBlocks){let n=Lh(e.state,r.from,r.to)?s:Th(e.state,r.from,r.to)?i:null;n&&t.add(r.from,r.from,n)}return t.finish()}}),{domEventHandlers:n}=t;return[r,ko({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||Te.empty},initialSpacer:()=>new jh(t,!1),domEventHandlers:Object.assign(Object.assign({},n),{click:(e,t,i)=>{if(n.click&&n.click(e,t,i))return!0;let s=Lh(e.state,t.from,t.to);if(s)return e.dispatch({effects:Ph.of(s)}),!0;let r=Th(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:Rh.of(r)}),!0)}})}),$h()]}const Gh=Zr.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 Kh{constructor(e,t){let i;function s(e){let t=Ve.newName();return(i||(i=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?s(t.all):void 0,n=t.scope;this.scope=n instanceof Ja?e=>e.prop(Za)==n.data:n?e=>e==n:void 0,this.style=Ra(e.map((e=>({tag:e.tag,class:e.class||s(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=i?new Ve(i):null,this.themeType=t.themeType}static define(e,t){return new Kh(e,t||{})}}const Zh=H.define(),Yh=H.define({combine:e=>e.length?[e[0]]:null});function Jh(e){let t=e.facet(Zh);return t.length?t:e.facet(Yh)}function el(e,t){let i,s=[il];return e instanceof Kh&&(e.module&&s.push(Zr.styleModule.of(e.module)),i=e.themeType),(null==t?void 0:t.fallback)?s.push(Yh.of(e)):i?s.push(Zh.computeN([Zr.darkTheme],(t=>t.facet(Zr.darkTheme)==("dark"==i)?[e]:[]))):s.push(Zh.of(e)),s}class tl{constructor(e){this.markCache=Object.create(null),this.tree=ih(e.state),this.decorations=this.buildDeco(e,Jh(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ih(e.state),i=Jh(e.state),s=i!=Jh(e.startState),{viewport:r}=e.view,n=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&n>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=n):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return ii.none;let i=new Ae;for(let{from:s,to:r}of e.visibleRanges)Pa(this.tree,t,((e,t,s)=>{i.add(e,t,this.markCache[s]||(this.markCache[s]=ii.mark({class:s})))}),s,r);return i.finish()}}const il=G.high(Yi.fromClass(tl,{decorations:e=>e.decorations})),sl=Kh.define([{tag:Ga.meta,color:"#404740"},{tag:Ga.link,textDecoration:"underline"},{tag:Ga.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Ga.emphasis,fontStyle:"italic"},{tag:Ga.strong,fontWeight:"bold"},{tag:Ga.strikethrough,textDecoration:"line-through"},{tag:Ga.keyword,color:"#708"},{tag:[Ga.atom,Ga.bool,Ga.url,Ga.contentSeparator,Ga.labelName],color:"#219"},{tag:[Ga.literal,Ga.inserted],color:"#164"},{tag:[Ga.string,Ga.deleted],color:"#a11"},{tag:[Ga.regexp,Ga.escape,Ga.special(Ga.string)],color:"#e40"},{tag:Ga.definition(Ga.variableName),color:"#00f"},{tag:Ga.local(Ga.variableName),color:"#30a"},{tag:[Ga.typeName,Ga.namespace],color:"#085"},{tag:Ga.className,color:"#167"},{tag:[Ga.special(Ga.variableName),Ga.macroName],color:"#256"},{tag:Ga.definition(Ga.propertyName),color:"#00c"},{tag:Ga.comment,color:"#940"},{tag:Ga.invalid,color:"#f00"}]),rl=Zr.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),nl="()[]{}",ol=H.define({combine:e=>De(e,{afterCursor:!0,brackets:nl,maxScanDistance:1e4,renderMatch:ll})}),al=ii.mark({class:"cm-matchingBracket"}),hl=ii.mark({class:"cm-nonmatchingBracket"});function ll(e){let t=[],i=e.matched?al:hl;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 cl=j.define({create:()=>ii.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],s=t.state.facet(ol);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=ml(t.state,e.head,-1,s)||e.head>0&&ml(t.state,e.head-1,1,s)||s.afterCursor&&(ml(t.state,e.head,1,s)||e.head<t.state.doc.length&&ml(t.state,e.head+1,-1,s));r&&(i=i.concat(s.renderMatch(r,t.state)))}return ii.set(i,!0)},provide:e=>Zr.decorations.from(e)}),ul=[cl,rl];function dl(e={}){return[ol.of(e),ul]}const fl=new Xo;function pl(e,t,i){let s=e.prop(t<0?Xo.openedBy:Xo.closedBy);if(s)return s;if(1==e.name.length){let s=i.indexOf(e.name);if(s>-1&&s%2==(t<0?1:0))return[i[s+t]]}return null}function gl(e){let t=e.type.prop(fl);return t?t(e.node):e}function ml(e,t,i,s={}){let r=s.maxScanDistance||1e4,n=s.brackets||nl,o=ih(e),a=o.resolveInner(t,i);for(let e=a;e;e=e.parent){let s=pl(e.type,i,n);if(s&&e.from<e.to){let r=gl(e);if(r&&(i>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return vl(0,0,i,e,r,s,n)}}return function(e,t,i,s,r,n,o){let a=i<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),h=o.indexOf(a);if(h<0||h%2==0!=i>0)return null;let l={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<=n;){let n=c.value;i<0&&(e+=n.length);let a=t+e*i;for(let e=i>0?0:n.length-1,t=i>0?n.length:-1;e!=t;e+=i){let t=o.indexOf(n[e]);if(!(t<0||s.resolveInner(a+e,1).type!=r))if(t%2==0==i>0)u++;else{if(1==u)return{start:l,end:{from:a+e,to:a+e+1},matched:t>>1==h>>1};u--}}i>0&&(e+=n.length)}return c.done?{start:l,matched:!1}:null}(e,t,i,o,a.type,r,n)}function vl(e,t,i,s,r,n,o){let a=s.parent,h={from:r.from,to:r.to},l=0,c=null==a?void 0:a.cursor();if(c&&(i<0?c.childBefore(s.from):c.childAfter(s.to)))do{if(i<0?c.to<=s.from:c.from>=s.to){if(0==l&&n.indexOf(c.type.name)>-1&&c.from<c.to){let e=gl(c);return{start:h,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(pl(c.type,i,o))l++;else if(pl(c.type,-i,o)){if(0==l){let e=gl(c);return{start:h,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:h,matched:!1}}const _l=Object.create(null),Ol=[Zo.none],Sl=[],wl=Object.create(null),bl=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"]])bl[e]=Dl(_l,t);function yl(e,t){Sl.indexOf(e)>-1||(Sl.push(e),console.warn(t))}function Dl(e,t){let i=[];for(let s of t.split(" ")){let t=[];for(let i of s.split(".")){let s=e[i]||Ga[i];s?"function"==typeof s?t.length?t=t.map(s):yl(i,`Modifier ${i} used at start of tag`):t.length?yl(i,`Tag ${i} used as modifier`):t=Array.isArray(s)?s:[s]:yl(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let s=t.replace(/ /g,"_"),r=s+" "+i.map((e=>e.id)),n=wl[r];if(n)return n.id;let o=wl[r]=Zo.define({id:Ol.length,name:s,props:[Ea({[s]:i})]});return Ol.push(o),o.id}function Cl(e,t){return({state:i,dispatch:s})=>{if(i.readOnly)return!1;let r=e(t,i);return!!r&&(s(i.update(r)),!0)}}pi.RTL,pi.LTR;const kl=Cl(Pl,0),xl=Cl(Rl,0),El=Cl(((e,t)=>Rl(e,t,function(e){let t=[];for(let i of e.selection.ranges){let s=e.doc.lineAt(i.from),r=i.to<=s.to?s:e.doc.lineAt(i.to);r.from>s.from&&r.from==i.to&&(r=i.to==s.to+1?s:e.doc.lineAt(i.to-1));let n=t.length-1;n>=0&&t[n].to>s.from?t[n].to=r.to:t.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:r.to})}return t}(t))),0);function Tl(e,t){let i=e.languageDataAt("commentTokens",t);return i.length?i[0]:{}}const Al=50;function Rl(e,t,i=t.selection.ranges){let s=i.map((e=>Tl(t,e.from).block));if(!s.every((e=>e)))return null;let r=i.map(((e,i)=>function(e,{open:t,close:i},s,r){let n,o,a=e.sliceDoc(s-Al,s),h=e.sliceDoc(r,r+Al),l=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(h)[0].length,u=a.length-l;if(a.slice(u-t.length,u)==t&&h.slice(c,c+i.length)==i)return{open:{pos:s-l,margin:l&&1},close:{pos:r+c,margin:c&&1}};r-s<=2*Al?n=o=e.sliceDoc(s,r):(n=e.sliceDoc(s,s+Al),o=e.sliceDoc(r-Al,r));let d=/^\s*/.exec(n)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return n.slice(d,d+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:s+d+t.length,margin:/\s/.test(n.charAt(d+t.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(t,s[i],e.from,e.to)));if(2!=e&&!r.every((e=>e)))return{changes:t.changes(i.map(((e,t)=>r[t]?[]:[{from:e.from,insert:s[t].open+" "},{from:e.to,insert:" "+s[t].close}])))};if(1!=e&&r.some((e=>e))){let e=[];for(let t,i=0;i<r.length;i++)if(t=r[i]){let r=s[i],{open:n,close:o}=t;e.push({from:n.pos-r.open.length,to:n.pos+n.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:e}}return null}function Pl(e,t,i=t.selection.ranges){let s=[],r=-1;for(let{from:e,to:n}of i){let i=s.length,o=1e9,a=Tl(t,e).line;if(a){for(let i=e;i<=n;){let h=t.doc.lineAt(i);if(h.from>r&&(e==n||n>h.from)){r=h.from;let e=/^\s*/.exec(h.text)[0].length,t=e==h.length,i=h.text.slice(e,e+a.length)==a?e:-1;e<h.text.length&&e<o&&(o=e),s.push({line:h,comment:i,token:a,indent:e,empty:t,single:!1})}i=h.to+1}if(o<1e9)for(let e=i;e<s.length;e++)s[e].indent<s[e].line.text.length&&(s[e].indent=o);s.length==i+1&&(s[i].single=!0)}}if(2!=e&&s.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:i,indent:r,empty:n,single:o}of s)!o&&n||e.push({from:t.from+r,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&s.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:i,token:r}of s)if(i>=0){let s=t.from+i,n=s+r.length;" "==t.text[n-t.from]&&n++,e.push({from:s,to:n})}return{changes:e}}return null}const Ml=le.define(),Bl=le.define(),Ll=H.define(),Fl=H.define({combine:e=>De(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}),Il=j.define({create:()=>ec.empty,update(e,t){let i=t.state.facet(Fl),s=t.annotation(Ml);if(s){let r=Nl.fromTransaction(t,s.selection),n=s.side,o=0==n?e.undone:e.done;return o=r?Ul(o,o.length,i.minDepth,r):Gl(o,t.startState.selection),new ec(0==n?s.rest:o,0==n?o:s.rest)}let r=t.annotation(Bl);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(fe.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let n=Nl.fromTransaction(t),o=t.annotation(fe.time),a=t.annotation(fe.userEvent);return n?e=e.addChanges(n,o,a,i,t):t.selection&&(e=e.addSelection(t.startState.selection,o,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new ec(e.done.map(Nl.fromJSON),e.undone.map(Nl.fromJSON))});function Ql(e={}){return[Il,Fl.of(e),Zr.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?Hl:"historyRedo"==e.inputType?ql:null;return!!i&&(e.preventDefault(),i(t))}})]}function Wl(e,t){return function({state:i,dispatch:s}){if(!t&&i.readOnly)return!1;let r=i.field(Il,!1);if(!r)return!1;let n=r.pop(e,i,t);return!!n&&(s(n),!0)}}const Hl=Wl(0,!1),ql=Wl(1,!1),$l=Wl(0,!0),zl=Wl(1,!0);class Nl{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Nl(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 Nl(e.changes&&T.fromJSON(e.changes),[],e.mapped&&E.fromJSON(e.mapped),e.startSelection&&I.fromJSON(e.startSelection),e.selectionsAfter.map(I.fromJSON))}static fromTransaction(e,t){let i=jl;for(let t of e.startState.facet(Ll)){let s=t(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new Nl(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,jl)}static selection(e){return new Nl(void 0,jl,void 0,void 0,e)}}function Ul(e,t,i,s){let r=t+1>i+20?t-i-1:0,n=e.slice(r,t);return n.push(s),n}function Vl(e,t){return e.length?t.length?e.concat(t):e:t}const jl=[],Xl=200;function Gl(e,t){if(e.length){let i=e[e.length-1],s=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-Xl));return s.length&&s[s.length-1].eq(t)?e:(s.push(t),Ul(e,e.length-1,1e9,i.setSelAfter(s)))}return[Nl.selection([t])]}function Kl(e){let t=e[e.length-1],i=e.slice();return i[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),i}function Zl(e,t){if(!e.length)return e;let i=e.length,s=jl;for(;i;){let r=Yl(e[i-1],t,s);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,s=r.selectionsAfter}return s.length?[Nl.selection(s)]:jl}function Yl(e,t,i){let s=Vl(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):jl,i);if(!e.changes)return Nl.selection(s);let r=e.changes.map(t),n=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(n):n;return new Nl(r,de.mapEffects(e.effects,t),o,e.startSelection.map(n),s)}const Jl=/^(input\.type|delete)($|\.)/;class ec{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new ec(this.done,this.undone):this}addChanges(e,t,i,s,r){let n=this.done,o=n[n.length-1];return n=o&&o.changes&&!o.changes.empty&&e.changes&&(!i||Jl.test(i))&&(!o.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,function(e,t){let i=[],s=!1;return e.iterChangedRanges(((e,t)=>i.push(e,t))),t.iterChangedRanges(((e,t,r,n)=>{for(let e=0;e<i.length;){let t=i[e++],o=i[e++];n>=t&&r<=o&&(s=!0)}})),s}(o.changes,e.changes))||"input.type.compose"==i)?Ul(n,n.length-1,s.minDepth,new Nl(e.changes.compose(o.changes),Vl(de.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,jl)):Ul(n,n.length,s.minDepth,e),new ec(n,jl,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:jl;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(n=r[r.length-1],o=e,n.ranges.length==o.ranges.length&&0===n.ranges.filter(((e,t)=>e.empty!=o.ranges[t].empty)).length)?this:new ec(Gl(this.done,e),this.undone,t,i);var n,o}addMapping(e){return new ec(Zl(this.done,e),Zl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=0==e?this.done:this.undone;if(0==s.length)return null;let r=s[s.length-1],n=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Ml.of({side:e,rest:Kl(s),selection:n}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==s.length?jl:s.slice(0,s.length-1);return r.mapped&&(i=Zl(i,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ml.of({side:e,rest:i,selection:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}ec.empty=new ec(jl,jl);const tc=[{key:"Mod-z",run:Hl,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ql,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ql,preventDefault:!0},{key:"Mod-u",run:$l,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:zl,preventDefault:!0}];function ic(e,t){return I.create(e.ranges.map(t),e.mainIndex)}function sc(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function rc({state:e,dispatch:t},i){let s=ic(e.selection,i);return!s.eq(e.selection,!0)&&(t(sc(e,s)),!0)}function nc(e,t){return I.cursor(t?e.to:e.from)}function oc(e,t){return rc(e,(i=>i.empty?e.moveByChar(i,t):nc(i,t)))}function ac(e){return e.textDirectionAt(e.state.selection.main.head)==pi.LTR}const hc=e=>oc(e,!ac(e)),lc=e=>oc(e,ac(e));function cc(e,t){return rc(e,(i=>i.empty?e.moveByGroup(i,t):nc(i,t)))}function uc(e,t,i){if(t.type.prop(i))return!0;let s=t.to-t.from;return s&&(s>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function dc(e,t,i){let s,r,n=ih(e).resolveInner(t.head),o=i?Xo.closedBy:Xo.openedBy;for(let s=t.head;;){let t=i?n.childAfter(s):n.childBefore(s);if(!t)break;uc(e,t,o)?n=t:s=i?t.to:t.from}return r=n.type.prop(o)&&(s=i?ml(e,n.from,1):ml(e,n.to,-1))&&s.matched?i?s.end.to:s.end.from:i?n.to:n.from,I.cursor(r,i?-1:1)}function fc(e,t){return rc(e,(i=>{if(!i.empty)return nc(i,t);let s=e.moveVertically(i,t);return s.head!=i.head?s:e.moveToLineBoundary(i,t)}))}"undefined"!=typeof Intl&&Intl.Segmenter;const pc=e=>fc(e,!1),gc=e=>fc(e,!0);function mc(e){let t,i=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,s=0,r=0;if(i){for(let t of e.state.facet(Zr.scrollMargins)){let i=t(e);(null==i?void 0:i.top)&&(s=Math.max(null==i?void 0:i.top,s)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}t=e.scrollDOM.clientHeight-s-r}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:s,marginBottom:r,selfScroll:i,height:Math.max(e.defaultLineHeight,t-5)}}function vc(e,t){let i,s=mc(e),{state:r}=e,n=ic(r.selection,(i=>i.empty?e.moveVertically(i,t,s.height):nc(i,t)));if(n.eq(r.selection))return!1;if(s.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),a=o.top+s.marginTop,h=o.bottom-s.marginBottom;t&&t.top>a&&t.bottom<h&&(i=Zr.scrollIntoView(n.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(sc(r,n),{effects:i}),!0}const _c=e=>vc(e,!1),Oc=e=>vc(e,!0);function Sc(e,t,i){let s=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?s.to:s.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==s.from&&s.length){let i=/^\s*/.exec(e.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&t.head!=s.from+i&&(r=I.cursor(s.from+i))}return r}function wc(e,t){let i=ic(e.state.selection,(e=>{let i=t(e);return I.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(e.state.selection)&&(e.dispatch(sc(e.state,i)),!0)}function bc(e,t){return wc(e,(i=>e.moveByChar(i,t)))}const yc=e=>bc(e,!ac(e)),Dc=e=>bc(e,ac(e));function Cc(e,t){return wc(e,(i=>e.moveByGroup(i,t)))}function kc(e,t){return wc(e,(i=>e.moveVertically(i,t)))}const xc=e=>kc(e,!1),Ec=e=>kc(e,!0);function Tc(e,t){return wc(e,(i=>e.moveVertically(i,t,mc(e).height)))}const Ac=e=>Tc(e,!1),Rc=e=>Tc(e,!0),Pc=({state:e,dispatch:t})=>(t(sc(e,{anchor:0})),!0),Mc=({state:e,dispatch:t})=>(t(sc(e,{anchor:e.doc.length})),!0),Bc=({state:e,dispatch:t})=>(t(sc(e,{anchor:e.selection.main.anchor,head:0})),!0),Lc=({state:e,dispatch:t})=>(t(sc(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Fc(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:s}=e,r=s.changeByRange((s=>{let{from:r,to:n}=s;if(r==n){let o=t(s);o<r?(i="delete.backward",o=Ic(e,o,!1)):o>r&&(i="delete.forward",o=Ic(e,o,!0)),r=Math.min(r,o),n=Math.max(n,o)}else r=Ic(e,r,!1),n=Ic(e,n,!0);return r==n?{range:s}:{changes:{from:r,to:n},range:I.cursor(r,r<s.head?-1:1)}}));return!r.changes.empty&&(e.dispatch(s.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?Zr.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function Ic(e,t,i){if(e instanceof Zr)for(let s of e.state.facet(Zr.atomicRanges).map((t=>t(e))))s.between(t,t,((e,s)=>{e<t&&s>t&&(t=i?s:e)}));return t}const Qc=(e,t,i)=>Fc(e,(s=>{let r,n,o=s.from,{state:a}=e,h=a.doc.lineAt(o);if(i&&!t&&o>h.from&&o<h.from+200&&!/[^ \t]/.test(r=h.text.slice(0,o-h.from))){if("\t"==r[r.length-1])return o-1;let e=qe(r,a.tabSize)%ph(a)||ph(a);for(let t=0;t<e&&" "==r[r.length-1-t];t++)o--;n=o}else n=b(h.text,o-h.from,t,t)+h.from,n==o&&h.number!=(t?a.doc.lines:1)?n+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(h.text.slice(n-h.from,o-h.from))&&(n=b(h.text,n-h.from,!1,!1)+h.from);return n})),Wc=e=>Qc(e,!1,!0),Hc=e=>Qc(e,!0,!1),qc=(e,t)=>Fc(e,(i=>{let s=i.head,{state:r}=e,n=r.doc.lineAt(s),o=r.charCategorizer(s);for(let e=null;;){if(s==(t?n.to:n.from)){s==i.head&&n.number!=(t?r.doc.lines:1)&&(s+=t?1:-1);break}let a=b(n.text,s-n.from,t)+n.from,h=n.text.slice(Math.min(s,a)-n.from,Math.max(s,a)-n.from),l=o(h);if(null!=e&&l!=e)break;" "==h&&s==i.head||(e=l),s=a}return s})),$c=e=>qc(e,!1);function zc(e){let t=[],i=-1;for(let s of e.selection.ranges){let r=e.doc.lineAt(s.from),n=e.doc.lineAt(s.to);if(s.empty||s.to!=n.from||(n=e.doc.lineAt(s.to-1)),i>=r.number){let e=t[t.length-1];e.to=n.to,e.ranges.push(s)}else t.push({from:r.from,to:n.to,ranges:[s]});i=n.number+1}return t}function Nc(e,t,i){if(e.readOnly)return!1;let s=[],r=[];for(let t of zc(e)){if(i?t.to==e.doc.length:0==t.from)continue;let n=e.doc.lineAt(i?t.to+1:t.from-1),o=n.length+1;if(i){s.push({from:t.to,to:n.to},{from:t.from,insert:n.text+e.lineBreak});for(let i of t.ranges)r.push(I.range(Math.min(e.doc.length,i.anchor+o),Math.min(e.doc.length,i.head+o)))}else{s.push({from:n.from,to:t.from},{from:t.to,insert:e.lineBreak+n.text});for(let e of t.ranges)r.push(I.range(e.anchor-o,e.head-o))}}return!!s.length&&(t(e.update({changes:s,scrollIntoView:!0,selection:I.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Uc(e,t,i){if(e.readOnly)return!1;let s=[];for(let t of zc(e))i?s.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):s.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Vc=jc(!1);function jc(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=t.changeByRange((i=>{let{from:s,to:r}=i,n=t.doc.lineAt(s),o=!e&&s==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i,s=ih(e).resolveInner(t),r=s.childBefore(t),n=s.childAfter(t);return r&&n&&r.to<=t&&n.from>=t&&(i=r.type.prop(Xo.closedBy))&&i.indexOf(n.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(n.from).from&&!/\S/.test(e.sliceDoc(r.to,n.from))?{from:r.to,to:n.from}:null}(t,s);e&&(s=r=(r<=n.to?n:t.doc.lineAt(r)).to);let a=new vh(t,{simulateBreak:s,simulateDoubleBreak:!!o}),h=mh(a,s);for(null==h&&(h=qe(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));r<n.to&&/\s/.test(n.text[r-n.from]);)r++;o?({from:s,to:r}=o):s>n.from&&s<n.from+100&&!/\S/.test(n.text.slice(0,s))&&(s=n.from);let l=["",gh(t,h)];return o&&l.push(gh(t,a.lineIndent(n.from,-1))),{changes:{from:s,to:r,insert:d.of(l)},range:I.cursor(s+1+l[1].length)}}));return i(t.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function Xc(e,t){let i=-1;return e.changeByRange((s=>{let r=[];for(let n=s.from;n<=s.to;){let o=e.doc.lineAt(n);o.number>i&&(s.empty||s.to>o.from)&&(t(o,r,s),i=o.number),n=o.to+1}let n=e.changes(r);return{changes:r,range:I.range(n.mapPos(s.anchor,1),n.mapPos(s.head,1))}}))}const Gc=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Xc(e,((t,i)=>{i.push({from:t.from,insert:e.facet(fh)})})),{userEvent:"input.indent"})),!0),Kc=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Xc(e,((t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=qe(s,e.tabSize),n=0,o=gh(e,Math.max(0,r-ph(e)));for(;n<s.length&&n<o.length&&s.charCodeAt(n)==o.charCodeAt(n);)n++;i.push({from:t.from+n,to:t.from+s.length,insert:o.slice(n)})})),{userEvent:"delete.dedent"})),!0),Zc=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>rc(e,(t=>dc(e.state,t,!ac(e)))),shift:e=>wc(e,(t=>dc(e.state,t,!ac(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>rc(e,(t=>dc(e.state,t,ac(e)))),shift:e=>wc(e,(t=>dc(e.state,t,ac(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Nc(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Uc(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Nc(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Uc(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let i=e.selection,s=null;return i.ranges.length>1?s=I.create([i.main]):i.main.empty||(s=I.create([I.cursor(i.main.head)])),!!s&&(t(sc(e,s)),!0)}},{key:"Mod-Enter",run:jc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=zc(e).map((({from:t,to:i})=>I.range(t,Math.min(i+1,e.doc.length))));return t(e.update({selection:I.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let i=ic(e.selection,(t=>{let i=ih(e),s=i.resolveStack(t.from,1);if(t.empty){let e=i.resolveStack(t.from,-1);e.node.from>=s.node.from&&e.node.to<=s.node.to&&(s=e)}for(let e=s;e;e=e.next){let{node:i}=e;if((i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&e.next)return I.range(i.to,i.from)}return t}));return!i.eq(e.selection)&&(t(sc(e,i)),!0)},preventDefault:!0},{key:"Mod-[",run:Kc},{key:"Mod-]",run:Gc},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),s=new vh(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),r=Xc(e,((t,r,n)=>{let o=mh(s,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],h=gh(e,o);(a!=h||n.from<t.from+a.length)&&(i[t.from]=o,r.push({from:t.from,to:t.from+a.length,insert:h}))}));return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(zc(t).map((({from:e,to:i})=>(e>0?e--:i<t.doc.length&&i++,{from:e,to:i})))),s=ic(t.selection,(t=>{let i;if(e.lineWrapping){let s=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(i=s.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,i)})).map(i);return e.dispatch({changes:i,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,i){let s=!1,r=ic(e.selection,(t=>{let r=ml(e,t.head,-1)||ml(e,t.head,1)||t.head>0&&ml(e,t.head-1,1)||t.head<e.doc.length&&ml(e,t.head+1,-1);if(!r||!r.end)return t;s=!0;let n=r.start.from==t.head?r.end.to:r.end.from;return i?I.range(t.anchor,n):I.cursor(n)}));return!!s&&(t(sc(e,r)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),s=Tl(e.state,i.from);return s.line?kl(e):!!s.block&&El(e)}},{key:"Alt-A",run:xl},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:hc,shift:yc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>cc(e,!ac(e)),shift:e=>Cc(e,!ac(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>rc(e,(t=>Sc(e,t,!ac(e)))),shift:e=>wc(e,(t=>Sc(e,t,!ac(e)))),preventDefault:!0},{key:"ArrowRight",run:lc,shift:Dc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>cc(e,ac(e)),shift:e=>Cc(e,ac(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>rc(e,(t=>Sc(e,t,ac(e)))),shift:e=>wc(e,(t=>Sc(e,t,ac(e)))),preventDefault:!0},{key:"ArrowUp",run:pc,shift:xc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Pc,shift:Bc},{mac:"Ctrl-ArrowUp",run:_c,shift:Ac},{key:"ArrowDown",run:gc,shift:Ec,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Mc,shift:Lc},{mac:"Ctrl-ArrowDown",run:Oc,shift:Rc},{key:"PageUp",run:_c,shift:Ac},{key:"PageDown",run:Oc,shift:Rc},{key:"Home",run:e=>rc(e,(t=>Sc(e,t,!1))),shift:e=>wc(e,(t=>Sc(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:Pc,shift:Bc},{key:"End",run:e=>rc(e,(t=>Sc(e,t,!0))),shift:e=>wc(e,(t=>Sc(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:Mc,shift:Lc},{key:"Enter",run:Vc,shift:Vc},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Wc,shift:Wc},{key:"Delete",run:Hc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:$c},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>qc(e,!0)},{mac:"Mod-Backspace",run:e=>Fc(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=>Fc(e,(t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)}))}].concat([{key:"Ctrl-b",run:hc,shift:yc,preventDefault:!0},{key:"Ctrl-f",run:lc,shift:Dc},{key:"Ctrl-p",run:pc,shift:xc},{key:"Ctrl-n",run:gc,shift:Ec},{key:"Ctrl-a",run:e=>rc(e,(t=>I.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>wc(e,(t=>I.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>rc(e,(t=>I.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>wc(e,(t=>I.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:Hc},{key:"Ctrl-h",run:Wc},{key:"Ctrl-k",run:e=>Fc(e,(t=>{let i=e.lineBlockAt(t.head).to;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)}))},{key:"Ctrl-Alt-h",run:$c},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:d.of(["",""])},range:I.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,s=e.doc.lineAt(i),r=i==s.from?i-1:b(s.text,i-s.from,!1)+s.from,n=i==s.to?i+1:b(s.text,i-s.from,!0)+s.from;return{changes:{from:r,to:n,insert:e.doc.slice(i,n).append(e.doc.slice(r,i))},range:I.cursor(n)}}));return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Oc}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),Yc={key:"Tab",run:Gc,shift:Kc};function Jc(){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 s in i)if(Object.prototype.hasOwnProperty.call(i,s)){var r=i[s];"string"==typeof r?e.setAttribute(s,r):null!=r&&(e[s]=r)}t++}for(;t<arguments.length;t++)eu(e,arguments[t]);return e}function eu(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var i=0;i<t.length;i++)eu(e,t[i])}}const tu="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class iu{constructor(e,t,i=0,s=e.length,r,n){this.test=n,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?e=>r(tu(e)):tu,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 y(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=D(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=C(e);let s=this.normalize(t);if(s.length)for(let e=0,r=i;;e++){let n=s.charCodeAt(e),o=this.match(n,r,this.bufferPos+this.bufferStart);if(e==s.length-1){if(o)return this.value=o,this;break}r==i&&e<t.length&&t.charCodeAt(e)==n&&r++}}}match(e,t,i){let s=null;for(let t=0;t<this.matches.length;t+=2){let r=this.matches[t],n=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?s={from:this.matches[t+1],to:i}:(this.matches[t]++,n=!0)),n||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}"undefined"!=typeof Symbol&&(iu.prototype[Symbol.iterator]=function(){return this});const su={from:-1,to:-1,match:/.*/.exec("")},ru="gm"+(null==/x/.unicode?"":"u");class nu{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=su,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hu(e,t,i,s,r);this.re=new RegExp(t,ru+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let n=e.lineAt(s);this.curLineStart=n.from,this.matchPos=lu(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=lu(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const ou=new WeakMap;class au{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=ou.get(e);if(!s||s.from>=i||s.to<=t){let s=new au(t,e.sliceString(t,i));return ou.set(e,s),s}if(s.from==t&&s.to==i)return s;let{text:r,from:n}=s;return n>t&&(r=e.sliceString(t,n)+r,n=t),s.to<i&&(r+=e.sliceString(s.to,i)),ou.set(e,new au(n,r)),new au(t,r.slice(t-n,i-n))}}class hu{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=su,this.matchPos=lu(e,s),this.re=new RegExp(t,ru+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=au.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,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=lu(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=au.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function lu(e,t){if(t>=e.length)return t;let i,s=e.lineAt(t);for(;t<s.to&&(i=s.text.charCodeAt(t-s.from))>=56320&&i<57344;)t++;return t}function cu(e){let t=Jc("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:s}=e,r=s.doc.lineAt(s.selection.main.head),[,n,o,a,h]=i,l=a?+a.slice(1):0,c=o?+o:r.number;if(o&&h){let e=c/100;n&&(e=e*("-"==n?-1:1)+r.number/s.doc.lines),c=Math.round(s.doc.lines*e)}else o&&n&&(c=c*("-"==n?-1:1)+r.number);let u=s.doc.line(Math.max(1,Math.min(s.doc.lines,c))),d=I.cursor(u.from+Math.max(0,Math.min(l,u.length)));e.dispatch({effects:[uu.of(!1),Zr.scrollIntoView(d.from,{y:"center"})],selection:d}),e.focus()}return{dom:Jc("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:uu.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:e=>{e.preventDefault(),i()}},Jc("label",e.state.phrase("Go to line"),": ",t)," ",Jc("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),Jc("button",{name:"close",onclick:()=>{e.dispatch({effects:uu.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(nu.prototype[Symbol.iterator]=hu.prototype[Symbol.iterator]=function(){return this});const uu=de.define(),du=j.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(uu)&&(e=i.value);return e},provide:e=>So.from(e,(e=>e?cu:null))}),fu=Zr.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"}}}),pu={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},gu=H.define({combine:e=>De(e,pu,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function mu(e){let t=[wu,Su];return e&&t.push(gu.of(e)),t}const vu=ii.mark({class:"cm-selectionMatch"}),_u=ii.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Ou(e,t,i,s){return!(0!=i&&e(t.sliceDoc(i-1,i))==Se.Word||s!=t.doc.length&&e(t.sliceDoc(s,s+1))==Se.Word)}const Su=Yi.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(gu),{state:i}=e,s=i.selection;if(s.ranges.length>1)return ii.none;let r,n=s.main,o=null;if(n.empty){if(!t.highlightWordAroundCursor)return ii.none;let e=i.wordAt(n.head);if(!e)return ii.none;o=i.charCategorizer(n.head),r=i.sliceDoc(e.from,e.to)}else{let e=n.to-n.from;if(e<t.minSelectionLength||e>200)return ii.none;if(t.wholeWords){if(r=i.sliceDoc(n.from,n.to),o=i.charCategorizer(n.head),!Ou(o,i,n.from,n.to)||!function(e,t,i,s){return e(t.sliceDoc(i,i+1))==Se.Word&&e(t.sliceDoc(s-1,s))==Se.Word}(o,i,n.from,n.to))return ii.none}else if(r=i.sliceDoc(n.from,n.to),!r)return ii.none}let a=[];for(let s of e.visibleRanges){let e=new iu(i.doc,r,s.from,s.to);for(;!e.next().done;){let{from:s,to:r}=e.value;if((!o||Ou(o,i,s,r))&&(n.empty&&s<=n.from&&r>=n.to?a.push(_u.range(s,r)):(s>=n.to||r<=n.from)&&a.push(vu.range(s,r)),a.length>t.maxMatches))return ii.none}}return ii.set(a)}},{decorations:e=>e.decorations}),wu=Zr.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),bu=H.define({combine:e=>De(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Zu(e),scrollToMatch:e=>Zr.scrollIntoView(e)})});class yu{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,ru),!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?"\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 Au(this):new ku(this)}getCursor(e,t=0,i){let s=e.doc?e:ye.create({doc:e});return null==i&&(i=s.doc.length),this.regexp?xu(this,s,t,i):Cu(this,s,t,i)}}class Du{constructor(e){this.spec=e}}function Cu(e,t,i,s){return new iu(t.doc,e.unquoted,i,s,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?function(e,t){return(i,s,r,n)=>((n>i||n+r.length<s)&&(n=Math.max(0,i-2),r=e.sliceString(n,Math.min(e.length,s+2))),!(t(Eu(r,i-n))==Se.Word&&t(Tu(r,i-n))==Se.Word||t(Tu(r,s-n))==Se.Word&&t(Eu(r,s-n))==Se.Word))}(t.doc,t.charCategorizer(t.selection.main.head)):void 0)}class ku extends Du{constructor(e){super(e)}nextMatch(e,t,i){let s=Cu(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);s=Cu(this.spec,e,0,i).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let i=Math.max(t,s-1e4-this.spec.unquoted.length),r=Cu(this.spec,e,i,s),n=null;for(;!r.nextOverlapping().done;)n=r.value;if(n)return n;if(i==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!s||s.from==t&&s.to==i?null:s}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Cu(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Cu(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function xu(e,t,i,s){return new nu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(r(Eu(i.input,i.index))!=Se.Word||r(Tu(i.input,i.index))!=Se.Word)&&(r(Tu(i.input,i.index+i[0].length))!=Se.Word||r(Eu(i.input,i.index+i[0].length))!=Se.Word)):void 0},i,s);var r}function Eu(e,t){return e.slice(b(e,t,!1),t)}function Tu(e,t){return e.slice(t,b(e,t))}class Au extends Du{nextMatch(e,t,i){let s=xu(this.spec,e,i,e.doc.length).next();return s.done&&(s=xu(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-1e4*s),n=xu(this.spec,e,r,i),o=null;for(;!n.next().done;)o=n.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,((t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let s=+i.slice(0,t);if(s>0&&s<e.match.length)return e.match[s]+i.slice(t)}return t}))}matchAll(e,t){let i=xu(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=xu(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Ru=de.define(),Pu=de.define(),Mu=j.define({create:e=>new Bu(Uu(e).create(),null),update(e,t){for(let i of t.effects)i.is(Ru)?e=new Bu(i.value.create(),e.panel):i.is(Pu)&&(e=new Bu(e.query,i.value?Nu:null));return e},provide:e=>So.from(e,(e=>e.panel))});class Bu{constructor(e,t){this.query=e,this.panel=t}}const Lu=ii.mark({class:"cm-searchMatch"}),Fu=ii.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Iu=Yi.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Mu))}update(e){let t=e.state.field(Mu);(t!=e.startState.field(Mu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return ii.none;let{view:i}=this,s=new Ae;for(let t=0,r=i.visibleRanges,n=r.length;t<n;t++){let{from:o,to:a}=r[t];for(;t<n-1&&a>r[t+1].from-500;)a=r[++t].to;e.highlight(i.state,o,a,((e,t)=>{let r=i.state.selection.ranges.some((i=>i.from==e&&i.to==t));s.add(e,t,r?Fu:Lu)}))}return s.finish()}},{decorations:e=>e.decorations});function Qu(e){return t=>{let i=t.state.field(Mu,!1);return i&&i.query.spec.valid?e(t,i):Xu(t)}}const Wu=Qu(((e,{query:t})=>{let{to:i}=e.state.selection.main,s=t.nextMatch(e.state,i,i);if(!s)return!1;let r=I.single(s.from,s.to),n=e.state.facet(bu);return e.dispatch({selection:r,effects:[td(e,s),n.scrollToMatch(r.main,e)],userEvent:"select.search"}),ju(e),!0})),Hu=Qu(((e,{query:t})=>{let{state:i}=e,{from:s}=i.selection.main,r=t.prevMatch(i,s,s);if(!r)return!1;let n=I.single(r.from,r.to),o=e.state.facet(bu);return e.dispatch({selection:n,effects:[td(e,r),o.scrollToMatch(n.main,e)],userEvent:"select.search"}),ju(e),!0})),qu=Qu(((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length||(e.dispatch({selection:I.create(i.map((e=>I.range(e.from,e.to)))),userEvent:"select.search.matches"}),0))})),$u=Qu(((e,{query:t})=>{let{state:i}=e,{from:s,to:r}=i.selection.main;if(i.readOnly)return!1;let n=t.nextMatch(i,s,s);if(!n)return!1;let o,a,h=n,l=[],c=[];if(h.from==s&&h.to==r&&(a=i.toText(t.getReplacement(h)),l.push({from:h.from,to:h.to,insert:a}),h=t.nextMatch(i,h.from,h.to),c.push(Zr.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(s).number)+"."))),h){let t=0==l.length||l[0].from>=n.to?0:n.to-n.from-a.length;o=I.single(h.from-t,h.to-t),c.push(td(e,h)),c.push(i.facet(bu).scrollToMatch(o.main,e))}return e.dispatch({changes:l,selection:o,effects:c,userEvent:"input.replace"}),!0})),zu=Qu(((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map((e=>{let{from:i,to:s}=e;return{from:i,to:s,insert:t.getReplacement(e)}}));if(!i.length)return!1;let s=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:Zr.announce.of(s),userEvent:"input.replace.all"}),!0}));function Nu(e){return e.state.facet(bu).createPanel(e)}function Uu(e,t){var i,s,r,n,o;let a=e.selection.main,h=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!h)return t;let l=e.facet(bu);return new yu({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:l.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:null!==(s=null==t?void 0:t.caseSensitive)&&void 0!==s?s:l.caseSensitive,literal:null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:l.literal,regexp:null!==(n=null==t?void 0:t.regexp)&&void 0!==n?n:l.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:l.wholeWord})}function Vu(e){let t=mo(e,Nu);return t&&t.dom.querySelector("[main-field]")}function ju(e){let t=Vu(e);t&&t==e.root.activeElement&&t.select()}const Xu=e=>{let t=e.state.field(Mu,!1);if(t&&t.panel){let i=Vu(e);if(i&&i!=e.root.activeElement){let s=Uu(e.state,t.query.spec);s.valid&&e.dispatch({effects:Ru.of(s)}),i.focus(),i.select()}}else e.dispatch({effects:[Pu.of(!0),t?Ru.of(Uu(e.state,t.query.spec)):de.appendConfig.of(sd)]});return!0},Gu=e=>{let t=e.state.field(Mu,!1);if(!t||!t.panel)return!1;let i=mo(e,Nu);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Pu.of(!1)}),!0},Ku=[{key:"Mod-f",run:Xu,scope:"editor search-panel"},{key:"F3",run:Wu,shift:Hu,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Wu,shift:Hu,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Gu,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:s,to:r}=i.main,n=[],o=0;for(let t=new iu(e.doc,e.sliceDoc(s,r));!t.next().done;){if(n.length>1e3)return!1;t.value.from==s&&(o=n.length),n.push(I.range(t.value.from,t.value.to))}return t(e.update({selection:I.create(n,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=mo(e,cu);if(!t){let i=[uu.of(!0)];null==e.state.field(du,!1)&&i.push(de.appendConfig.of([du,fu])),e.dispatch({effects:i}),t=mo(e,cu)}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(({state:e,dispatch:t})=>{let{selection:i}=e,s=I.create(i.ranges.map((t=>e.wordAt(t.head)||I.cursor(t.head))),i.mainIndex);return!s.eq(i)&&(t(e.update({selection:s})),!0)})({state:e,dispatch:t});let s=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=s)))return!1;let r=function(e,t){let{main:i,ranges:s}=e.selection,r=e.wordAt(i.head),n=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new iu(e.doc,t,s[s.length-1].to);;){if(r.next(),!r.done){if(i&&s.some((e=>e.from==r.value.from)))continue;if(n){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}if(i)return null;r=new iu(e.doc,t,0,Math.max(0,s[s.length-1].from-1)),i=!0}}(e,s);return!!r&&(t(e.update({selection:e.selection.addRange(I.range(r.from,r.to),!1),effects:Zr.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class Zu{constructor(e){this.view=e;let t=this.query=e.state.field(Mu).query.spec;function i(e,t,i){return Jc("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Jc("input",{value:t.search,placeholder:Yu(e,"Find"),"aria-label":Yu(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Jc("input",{value:t.replace,placeholder:Yu(e,"Replace"),"aria-label":Yu(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Jc("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Jc("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Jc("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=Jc("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",(()=>Wu(e)),[Yu(e,"next")]),i("prev",(()=>Hu(e)),[Yu(e,"previous")]),i("select",(()=>qu(e)),[Yu(e,"all")]),Jc("label",null,[this.caseField,Yu(e,"match case")]),Jc("label",null,[this.reField,Yu(e,"regexp")]),Jc("label",null,[this.wordField,Yu(e,"by word")]),...e.state.readOnly?[]:[Jc("br"),this.replaceField,i("replace",(()=>$u(e)),[Yu(e,"replace")]),i("replaceAll",(()=>zu(e)),[Yu(e,"replace all")])],Jc("button",{name:"close",onclick:()=>Gu(e),"aria-label":Yu(e,"close"),type:"button"},["×"])])}commit(){let e=new yu({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:Ru.of(e)}))}keydown(e){var t,i;i=e,dn(hn((t=this.view).state),i,t,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Hu:Wu)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),$u(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Ru)&&!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(bu).top}}function Yu(e,t){return e.state.phrase(t)}const Ju=30,ed=/[\s\.,:;?!]/;function td(e,{from:t,to:i}){let s=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,n=Math.max(s.from,t-Ju),o=Math.min(r,i+Ju),a=e.state.sliceDoc(n,o);if(n!=s.from)for(let e=0;e<Ju;e++)if(!ed.test(a[e+1])&&ed.test(a[e])){a=a.slice(e);break}if(o!=r)for(let e=a.length-1;e>a.length-Ju;e--)if(!ed.test(a[e-1])&&ed.test(a[e])){a=a.slice(0,e);break}return Zr.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${s.number}.`)}const id=Zr.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"}}),sd=[Mu,G.low(Iu),id];class rd{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ih(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)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),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(cd(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,i){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function nd(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 od(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[i,s]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),i=Object.create(null);for(let{label:s}of e){t[s[0]]=!0;for(let e=1;e<s.length;e++)i[s[e]]=!0}let s=nd(t)+nd(i)+"*$";return[new RegExp("^"+s),new RegExp(s)]}(t);return e=>{let r=e.matchBefore(s);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:i}:null}}function ad(e,t){return i=>{for(let t=ih(i.state).resolveInner(i.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(i)}}class hd{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function ld(e){return e.selection.main.from}function cd(e,t){var i;let{source:s}=e,r=t&&"^"!=s[0],n="$"!=s[s.length-1];return r||n?new RegExp(`${r?"^":""}(?:${s})${n?"$":""}`,null!==(i=e.flags)&&void 0!==i?i:e.ignoreCase?"i":""):e}const ud=le.define(),dd=new WeakMap;function fd(e){if(!Array.isArray(e))return e;let t=dd.get(e);return t||dd.set(e,t=od(e)),t}const pd=de.define(),gd=de.define();class md{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<e.length;){let i=y(e,t),s=C(i);this.chars.push(i);let r=e.slice(t,t+s),n=r.toUpperCase();this.folded.push(y(n==r?r.toLowerCase():n,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:n}=this;if(1==t.length){let s=y(e,0),r=C(s),n=r==e.length?0:-100;if(s==t[0]);else{if(s!=i[0])return null;n+=-200}return this.ret(n,[0,r])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(o<0){for(let r=0,n=Math.min(e.length,200);r<n&&h<a;){let n=y(e,r);n!=t[h]&&n!=i[h]||(s[h++]=r),r+=C(n)}if(h<a)return null}let l=0,c=0,u=!1,d=0,f=-1,p=-1,g=/[a-z]/.test(e),m=!0;for(let s=0,h=Math.min(e.length,200),v=0;s<h&&c<a;){let h=y(e,s);o<0&&(l<a&&h==t[l]&&(r[l++]=s),d<a&&(h==t[d]||h==i[d]?(0==d&&(f=s),p=s+1,d++):d=0));let _,O=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(_=D(h))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!s||1==O&&g||0==v&&0!=O)&&(t[c]==h||i[c]==h&&(u=!0)?n[c++]=s:n.length&&(m=!1)),v=O,s+=C(h)}return c==a&&0==n[0]&&m?this.result((u?-200:0)-100,n,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):c==a?this.result((u?-200:0)-100-700+(m?0:-1100),n,e):2==t.length?null:this.result((s[0]?-700:0)-200-1100,s,e)}result(e,t,i){let s=[],r=0;for(let e of t){let t=e+(this.astral?C(y(i,e)):1);r&&s[r-1]==e?s[r-1]=t:(s[r++]=e,s[r++]=t)}return this.ret(e-i.length,s)}}class vd{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const _d=H.define({combine:e=>De(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:Sd,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=>Od(e(i),t(i)),optionClass:(e,t)=>i=>Od(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function Od(e,t){return e?t?e+" "+t:e:t}function Sd(e,t,i,s,r,n){let o,a,h=e.textDirection==pi.RTL,l=h,c=!1,u="top",d=t.left-r.left,f=r.right-t.right,p=s.right-s.left,g=s.bottom-s.top;if(l&&d<Math.min(p,f)?l=!1:!l&&f<Math.min(p,d)&&(l=!0),p<=(l?d:f))o=Math.max(r.top,Math.min(i.top,r.bottom-g))-t.top,a=Math.min(400,l?d:f);else{c=!0,a=Math.min(400,(h?t.right:r.right-t.left)-30);let e=r.bottom-t.bottom;e>=g||e>t.top?o=i.bottom-t.top:(u="bottom",o=t.bottom-i.top)}return{style:`${u}: ${o/((t.bottom-t.top)/n.offsetHeight)}px; max-width: ${a/((t.right-t.left)/n.offsetWidth)}px`,class:"cm-completionInfo-"+(c?h?"left-narrow":"right-narrow":l?"left":"right")}}function wd(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 s=Math.floor((e-t)/i);return{from:e-(s+1)*i,to:e-s*i}}class bd{constructor(e,t,i){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:n}=s.open,o=e.state.facet(_d);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.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}),t.push({render(e,t,i,s){let r=document.createElement("span");r.className="cm-completionLabel";let n=e.displayLabel||e.label,o=0;for(let e=0;e<s.length;){let t=s[e++],i=s[e++];t>o&&r.appendChild(document.createTextNode(n.slice(o,t)));let a=r.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(n.slice(t,i))),a.className="cm-completionMatchedText",o=i}return o<n.length&&r.appendChild(document.createTextNode(n.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=wd(r.length,n,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(i=>{let{options:s}=e.state.field(t).open;for(let t,r=i.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(t=/-(\d+)$/.exec(r.id))&&+t[1]<s.length)return this.applyCompletion(e,s[+t[1]]),void i.preventDefault()})),this.dom.addEventListener("focusout",(t=>{let i=e.state.field(this.stateField,!1);i&&i.tooltip&&e.state.facet(_d).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:gd.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),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:n,disabled:o}=i.open;s.open&&s.open.options==r||(this.range=wd(r.length,n,e.state.facet(_d).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),o!=(null===(t=s.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.from||t.selected>=this.range.to)&&(this.range=wd(t.options.length,t.selected,this.view.state.facet(_d).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r="string"==typeof s?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)})).catch((e=>Xi(this.view.state,e,"completion info"))):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=e.nodeType)i.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:s}=e;i.appendChild(t),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)"LI"==i.nodeName&&i.id?s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):s--;return t&&function(e,t){let i=e.getBoundingClientRect(),s=t.getBoundingClientRect(),r=i.height/e.offsetHeight;s.top<i.top?e.scrollTop-=(i.top-s.top)/r:s.bottom>i.bottom&&(e.scrollTop+=(s.bottom-i.bottom)/r)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(_d).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",(e=>{e.target==s&&e.preventDefault()}));let r=null;for(let n=i.from;n<i.to;n++){let{completion:o,match:a}=e[n],{section:h}=o;if(h){let e="string"==typeof h?h:h.name;e!=r&&(n>i.from||0==i.from)&&(r=e,"string"!=typeof h&&h.header?s.appendChild(h.header(h)):s.appendChild(document.createElement("completion-section")).textContent=e)}const l=s.appendChild(document.createElement("li"));l.id=t+"-"+n,l.setAttribute("role","option");let c=this.optionClass(o);c&&(l.className=c);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,a);t&&l.appendChild(t)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function yd(e,t){return i=>new bd(i,e,t)}function Dd(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Cd{constructor(e,t,i,s,r,n){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=n}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Cd(this.options,Td(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,n){if(s&&!n&&e.some((e=>e.isPending)))return s.setDisabled();let o=function(e,t){let i=[],s=null,r=e=>{i.push(e);let{section:t}=e.completion;if(t){s||(s=[]);let e="string"==typeof t?t:t.name;s.some((t=>t.name==e))||s.push("string"==typeof t?{name:e}:t)}},n=t.facet(_d);for(let s of e)if(s.hasResult()){let e=s.result.getMatch;if(!1===s.result.filter)for(let t of s.result.options)r(new hd(t,s.source,e?e(t):[],1e9-i.length));else{let i,o=t.sliceDoc(s.from,s.to),a=n.filterStrict?new vd(o):new md(o);for(let t of s.result.options)if(i=a.match(t.label)){let n=t.displayLabel?e?e(t,i.matched):[]:i.matched;r(new hd(t,s.source,n,i.score+(t.boost||0)))}}}if(s){let e=Object.create(null),t=0,r=(e,t)=>{var i,s;return(null!==(i=e.rank)&&void 0!==i?i:1e9)-(null!==(s=t.rank)&&void 0!==s?s:1e9)||(e.name<t.name?-1:1)};for(let i of s.sort(r))t-=1e5,e[i.name]=t;for(let t of i){let{section:i}=t.completion;i&&(t.score+=e["string"==typeof i?i:i.name])}}let o=[],a=null,h=n.compareCompletions;for(let e of i.sort(((e,t)=>t.score-e.score||h(e.completion,t.completion)))){let t=e.completion;!a||a.label!=t.label||a.detail!=t.detail||null!=a.type&&null!=t.type&&a.type!=t.type||a.apply!=t.apply||a.boost!=t.boost?o.push(e):Dd(e.completion)>Dd(a)&&(o[o.length-1]=e),a=e.completion}return o}(e,t);if(!o.length)return s&&e.some((e=>e.isPending))?s.setDisabled():null;let a=t.facet(_d).selectOnOpen?0:-1;if(s&&s.selected!=a&&-1!=s.selected){let e=s.options[s.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){a=t;break}}return new Cd(o,Td(i,a),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:Qd,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new Cd(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 Cd(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class kd{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new kd(Ad,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,i=t.facet(_d),s=(i.override||t.languageDataAt("autocomplete",ld(t)).map(fd)).map((t=>(this.active.find((e=>e.source==t))||new Pd(t,this.active.some((e=>0!=e.state))?1:0)).update(e,i)));s.length==this.active.length&&s.every(((e,t)=>e==this.active[t]))&&(s=this.active);let r=this.open,n=e.effects.some((e=>e.is(Bd)));r&&e.docChanged&&(r=r.map(e.changes)),e.selection||s.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let i=0,s=0;;){for(;i<e.length&&!e[i].hasResult();)i++;for(;s<t.length&&!t[s].hasResult();)s++;let r=i==e.length,n=s==t.length;if(r||n)return r==n;if(e[i++].result!=t[s++].result)return!1}}(s,this.active)||n?r=Cd.build(s,t,this.id,r,i,n):r&&r.disabled&&!s.some((e=>e.isPending))&&(r=null),!r&&s.every((e=>!e.isPending))&&s.some((e=>e.hasResult()))&&(s=s.map((e=>e.hasResult()?new Pd(e.source,0):e)));for(let t of e.effects)t.is(Ld)&&(r=r&&r.setSelected(t.value,this.id));return s==this.active&&r==this.open?this:new kd(s,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?xd:Ed}}const xd={"aria-autocomplete":"list"},Ed={};function Td(e,t){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(i["aria-activedescendant"]=e+"-"+t),i}const Ad=[];function Rd(e,t){if(e.isUserEvent("input.complete")){let i=e.annotation(ud);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:e.docChanged?16:0}class Pd{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=Rd(e,t),s=this;(8&i||16&i&&this.touches(e))&&(s=new Pd(s.source,0)),4&i&&0==s.state&&(s=new Pd(this.source,1)),s=s.updateFor(e,i);for(let t of e.effects)if(t.is(pd))s=new Pd(s.source,1,t.value);else if(t.is(gd))s=new Pd(s.source,0);else if(t.is(Bd))for(let e of t.value)e.source==s.source&&(s=e);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ld(e.state))}}class Md extends Pd{constructor(e,t,i,s,r,n){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=n}hasResult(){return!0}updateFor(e,t){var i;if(!(3&t))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),n=e.changes.mapPos(this.to,1),o=ld(e.state);if(o>n||!s||2&t&&(ld(e.startState)==this.from||o<this.limit))return new Pd(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,i,s){if(!e)return!1;let r=t.sliceDoc(i,s);return"function"==typeof e?e(r,i,s,t):cd(e,!0).test(r)}(s.validFor,e.state,r,n)?new Md(this.source,this.explicit,a,s,r,n):s.update&&(s=s.update(s,r,n,new rd(e.state,o,!1)))?new Md(this.source,this.explicit,a,s,s.from,null!==(i=s.to)&&void 0!==i?i:ld(e.state)):new Pd(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Md(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Pd(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const Bd=de.define({map:(e,t)=>e.map((e=>e.map(t)))}),Ld=de.define(),Fd=j.define({create:()=>kd.start(),update:(e,t)=>e.update(t),provide:e=>[no.from(e,(e=>e.tooltip)),Zr.contentAttributes.from(e,(e=>e.attrs))]});function Id(e,t){const i=t.completion.apply||t.completion.label;let s=e.state.field(Fd).active.find((e=>e.source==t.source));return s instanceof Md&&("string"==typeof i?e.dispatch(Object.assign(Object.assign({},function(e,t,i,s){let{main:r}=e.selection,n=i-r.from,o=s-r.from;return Object.assign(Object.assign({},e.changeByRange((a=>{if(a!=r&&i!=s&&e.sliceDoc(a.from+n,a.from+o)!=e.sliceDoc(i,s))return{range:a};let h=e.toText(t);return{changes:{from:a.from+n,to:s==r.from?a.to:a.from+o,insert:h},range:I.cursor(a.from+n+h.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,i,s.from,s.to)),{annotations:ud.of(t.completion)})):i(e,t.completion,s.from,s.to),!0)}const Qd=yd(Fd,Id);function Wd(e,t="option"){return i=>{let s=i.state.field(Fd,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp<i.state.facet(_d).interactionDelay)return!1;let r,n=1;"page"==t&&(r=fo(i,s.open.tooltip))&&(n=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=s.open.options,a=s.open.selected>-1?s.open.selected+n*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),i.dispatch({effects:Ld.of(a)}),!0}}const Hd=e=>!!e.state.field(Fd,!1)&&(e.dispatch({effects:pd.of(!0)}),!0);class qd{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const $d=Yi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Fd).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Fd),i=e.state.facet(_d);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Fd)==t)return;let s=e.transactions.some((e=>{let t=Rd(e,i);return 8&t||(e.selection||e.docChanged)&&!(3&t)}));for(let t=0;t<this.running.length;t++){let i=this.running[t];if(s||i.context.abortOnDocChange&&e.docChanged||i.updates.length+e.transactions.length>50&&Date.now()-i.time>1e3){for(let e of i.context.abortListeners)try{e()}catch(e){Xi(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(pd)))))&&(this.pendingStart=!0);let r=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=t.active.some((e=>e.isPending&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),r):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Fd);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(_d).updateSyncTime))}startQuery(e){let{state:t}=this.view,i=ld(t),s=new rd(t,i,e.explicit,this.view),r=new qd(e,s);this.running.push(r),Promise.resolve(e.source(s)).then((e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:gd.of(null)}),Xi(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(_d).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],i=this.view.state.facet(_d),s=this.view.state.field(Fd);for(let r=0;r<this.running.length;r++){let n=this.running[r];if(void 0===n.done)continue;if(this.running.splice(r--,1),n.done){let s=ld(n.updates.length?n.updates[0].startState:this.view.state),r=Math.min(s,n.done.from+(n.active.explicit?0:1)),o=new Md(n.active.source,n.active.explicit,r,n.done,n.done.from,null!==(e=n.done.to)&&void 0!==e?e:s);for(let e of n.updates)o=o.update(e,i);if(o.hasResult()){t.push(o);continue}}let o=s.active.find((e=>e.source==n.active.source));if(o&&o.isPending)if(null==n.done){let e=new Pd(n.active.source,0);for(let t of n.updates)e=e.update(t,i);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||s.open&&s.open.disabled)&&this.view.dispatch({effects:Bd.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Fd,!1);if(t&&t.tooltip&&this.view.state.facet(_d).closeOnBlur){let i=t.open&&fo(this.view,t.open.tooltip);i&&i.dom.contains(e.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:gd.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:pd.of(!1)})),20),this.composing=0}}}),zd="object"==typeof navigator&&/Win/.test(navigator.platform),Nd=G.highest(Zr.domEventHandlers({keydown(e,t){let i=t.state.field(Fd,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||e.key.length>1||e.ctrlKey&&(!zd||!e.altKey)||e.metaKey)return!1;let s=i.open.options[i.open.selected],r=i.active.find((e=>e.source==s.source)),n=s.completion.commitCharacters||r.result.commitCharacters;return n&&n.indexOf(e.key)>-1&&Id(t,s),!1}})),Ud=Zr.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:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Vd{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class jd{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,x.TrackDel),i=e.mapPos(this.to,1,x.TrackDel);return null==t||null==i?null:new jd(this.field,t,i)}}class Xd{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),n=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(i.length){let i=n,o=/^\t*/.exec(r)[0].length;for(let t=0;t<o;t++)i+=e.facet(fh);s.push(t+i.length-o),r=i+r.slice(o)}i.push(r),t+=r.length+1}let o=this.fieldPositions.map((e=>new jd(e.field,s[e.line]+e.from,s[e.line]+e.to)));return{text:i,ranges:o}}static parse(e){let t,i=[],s=[],r=[];for(let n of e.split(/\r\n?|\n/)){for(;t=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(n);){let e=t[1]?+t[1]:null,o=t[2]||t[3]||"",a=-1,h=o.replace(/\\[{}]/g,(e=>e[1]));for(let t=0;t<i.length;t++)(null!=e?i[t].seq==e:h&&i[t].name==h)&&(a=t);if(a<0){let t=0;for(;t<i.length&&(null==e||null!=i[t].seq&&i[t].seq<e);)t++;i.splice(t,0,{seq:e,name:h}),a=t;for(let e of r)e.field>=a&&e.field++}r.push(new Vd(a,s.length,t.index,t.index+h.length)),n=n.slice(0,t.index)+o+n.slice(t.index+t[0].length)}n=n.replace(/\\([{}])/g,((e,t,i)=>{for(let e of r)e.line==s.length&&e.from>i&&(e.from--,e.to--);return t})),s.push(n)}return new Xd(s,r)}}let Gd=ii.widget({widget:new class extends ei{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Kd=ii.mark({class:"cm-snippetField"});class Zd{constructor(e,t){this.ranges=e,this.active=t,this.deco=ii.set(e.map((e=>(e.from==e.to?Gd:Kd).range(e.from,e.to))))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Zd(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 Yd=de.define({map:(e,t)=>e&&e.map(t)}),Jd=de.define(),ef=j.define({create:()=>null,update(e,t){for(let i of t.effects){if(i.is(Yd))return i.value;if(i.is(Jd)&&e)return new Zd(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=>Zr.decorations.from(e,(e=>e?e.deco:ii.none))});function tf(e,t){return I.create(e.filter((e=>e.field==t)).map((e=>I.range(e.from,e.to))))}function sf(e){let t=Xd.parse(e);return(e,i,s,r)=>{let{text:n,ranges:o}=t.instantiate(e.state,s),{main:a}=e.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:d.of(n)},scrollIntoView:!0,annotations:i?[ud.of(i),fe.userEvent.of("input.complete")]:void 0};if(o.length&&(h.selection=tf(o,0)),o.some((e=>e.field>0))){let t=new Zd(o,0),i=h.effects=[Yd.of(t)];void 0===e.state.field(ef,!1)&&i.push(de.appendConfig.of([ef,af,lf,Ud]))}e.dispatch(e.state.update(h))}}function rf(e){return({state:t,dispatch:i})=>{let s=t.field(ef,!1);if(!s||e<0&&0==s.active)return!1;let r=s.active+e,n=e>0&&!s.ranges.some((t=>t.field==r+e));return i(t.update({selection:tf(s.ranges,r),effects:Yd.of(n?null:new Zd(s.ranges,r)),scrollIntoView:!0})),!0}}const nf=[{key:"Tab",run:rf(1),shift:rf(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(ef,!1)&&(t(e.update({effects:Yd.of(null)})),!0)}],of=H.define({combine:e=>e.length?e[0]:nf}),af=G.highest(on.compute([of],(e=>e.facet(of))));function hf(e,t){return Object.assign(Object.assign({},t),{apply:sf(e)})}const lf=Zr.domEventHandlers({mousedown(e,t){let i,s=t.state.field(ef,!1);if(!s||null==(i=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let r=s.ranges.find((e=>e.from<=i&&e.to>=i));return!(!r||r.field==s.active||(t.dispatch({selection:tf(s.ranges,r.field),effects:Yd.of(s.ranges.some((e=>e.field>r.field))?new Zd(s.ranges,r.field):null),scrollIntoView:!0}),0))}}),cf={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},uf=de.define({map(e,t){let i=t.mapPos(e,-1,x.TrackAfter);return null==i?void 0:i}}),df=new class extends Ce{};df.startSide=1,df.endSide=-1;const ff=j.define({create:()=>Te.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(uf)&&(e=e.update({add:[df.range(i.value,i.value+1)]}));return e}}),pf="()[]{}<>«»»«[]{}";function gf(e){for(let t=0;t<16;t+=2)if(pf.charCodeAt(t)==e)return pf.charAt(t+1);return D(e<128?e:e+1)}function mf(e,t){return e.languageDataAt("closeBrackets",t)[0]||cf}const vf="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),_f=Zr.inputHandler.of(((e,t,i,s)=>{if((vf?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(s.length>2||2==s.length&&1==C(y(s,0))||t!=r.from||i!=r.to)return!1;let n=function(e,t){let i=mf(e,e.selection.main.head),s=i.brackets||cf.brackets;for(let r of s){let n=gf(y(r,0));if(t==r)return n==r?Df(e,r,s.indexOf(r+r+r)>-1,i):bf(e,r,n,i.before||cf.before);if(t==n&&Sf(e,e.selection.main.from))return yf(e,0,n)}return null}(e.state,s);return!!n&&(e.dispatch(n),!0)})),Of=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=mf(e,e.selection.main.head).brackets||cf.brackets,s=null,r=e.changeByRange((t=>{if(t.empty){let s=function(e,t){let i=e.sliceString(t-2,t);return C(y(i,0))==i.length?i:i.slice(1)}(e.doc,t.head);for(let r of i)if(r==s&&wf(e.doc,t.head)==gf(y(r,0)))return{changes:{from:t.head-r.length,to:t.head+r.length},range:I.cursor(t.head-r.length)}}return{range:s=t}}));return s||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s}}];function Sf(e,t){let i=!1;return e.field(ff).between(0,e.doc.length,(e=>{e==t&&(i=!0)})),i}function wf(e,t){let i=e.sliceString(t,t+2);return i.slice(0,C(y(i,0)))}function bf(e,t,i,s){let r=null,n=e.changeByRange((n=>{if(!n.empty)return{changes:[{insert:t,from:n.from},{insert:i,from:n.to}],effects:uf.of(n.to+t.length),range:I.range(n.anchor+t.length,n.head+t.length)};let o=wf(e.doc,n.head);return!o||/\s/.test(o)||s.indexOf(o)>-1?{changes:{insert:t+i,from:n.head},effects:uf.of(n.head+t.length),range:I.cursor(n.head+t.length)}:{range:r=n}}));return r?null:e.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function yf(e,t,i){let s=null,r=e.changeByRange((t=>t.empty&&wf(e.doc,t.head)==i?{changes:{from:t.head,to:t.head+i.length,insert:i},range:I.cursor(t.head+i.length)}:s={range:t}));return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Df(e,t,i,s){let r=s.stringPrefixes||cf.stringPrefixes,n=null,o=e.changeByRange((s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:uf.of(s.to+t.length),range:I.range(s.anchor+t.length,s.head+t.length)};let o,a=s.head,h=wf(e.doc,a);if(h==t){if(Cf(e,a))return{changes:{insert:t+t,from:a},effects:uf.of(a+t.length),range:I.cursor(a+t.length)};if(Sf(e,a)){let s=i&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+s.length,insert:s},range:I.cursor(a+s.length)}}}else{if(i&&e.sliceDoc(a-2*t.length,a)==t+t&&(o=kf(e,a-2*t.length,r))>-1&&Cf(e,o))return{changes:{insert:t+t+t+t,from:a},effects:uf.of(a+t.length),range:I.cursor(a+t.length)};if(e.charCategorizer(a)(h)!=Se.Word&&kf(e,a,r)>-1&&!function(e,t,i,s){let r=ih(e).resolveInner(t,-1),n=s.reduce(((e,t)=>Math.max(e,t.length)),0);for(let o=0;o<5;o++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+i.length+n)),a=o.indexOf(i);if(!a||a>-1&&s.indexOf(o.slice(0,a))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>i.length+a;){if(e.sliceDoc(t.to-i.length,t.to)==i)return!1;t=t.firstChild}return!0}let h=r.to==t&&r.parent;if(!h)break;r=h}return!1}(e,a,t,r))return{changes:{insert:t+t,from:a},effects:uf.of(a+t.length),range:I.cursor(a+t.length)}}return{range:n=s}}));return n?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Cf(e,t){let i=ih(e).resolveInner(t+1);return i.parent&&i.from==t}function kf(e,t,i){let s=e.charCategorizer(t);if(s(e.sliceDoc(t-1,t))!=Se.Word)return t;for(let r of i){let i=t-r.length;if(e.sliceDoc(i,t)==r&&s(e.sliceDoc(i-1,i))!=Se.Word)return i}return-1}function xf(e={}){return[Nd,Fd,_d.of(e),$d,Tf,Ud]}const Ef=[{key:"Ctrl-Space",run:Hd},{mac:"Alt-`",run:Hd},{key:"Escape",run:e=>{let t=e.state.field(Fd,!1);return!(!t||!t.active.some((e=>0!=e.state))||(e.dispatch({effects:gd.of(null)}),0))}},{key:"ArrowDown",run:Wd(!0)},{key:"ArrowUp",run:Wd(!1)},{key:"PageDown",run:Wd(!0,"page")},{key:"PageUp",run:Wd(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(Fd,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(_d).interactionDelay)&&Id(e,t.open.options[t.open.selected])}}],Tf=G.highest(on.computeN([_d],(e=>e.facet(_d).defaultKeymap?[Ef]:[])));class Af{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Rf{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet($f).markerFilter;r&&(s=r(s,i));let n=e.slice().sort(((e,t)=>e.from-t.from||e.to-t.to)),o=new Ae,a=[],h=0;for(let e=0;;){let t,s,r=e==n.length?null:n[e];if(!r&&!a.length)break;for(a.length?(t=h,s=a.reduce(((e,t)=>Math.min(e,t.to)),r&&r.from>t?r.from:1e8)):(t=r.from,s=r.to,a.push(r),e++);e<n.length;){let i=n[e];if(i.from!=t||!(i.to>i.from||i.to==t)){s=Math.min(i.from,s);break}a.push(i),e++,s=Math.min(i.to,s)}let l=Zf(a);if(a.some((e=>e.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from)))o.add(t,t,ii.widget({widget:new Uf(l),diagnostics:a.slice()}));else{let e=a.reduce(((e,t)=>t.markClass?e+" "+t.markClass:e),"");o.add(t,s,ii.mark({class:"cm-lintRange cm-lintRange-"+l+e,diagnostics:a.slice(),inclusiveEnd:a.some((e=>e.to>s))}))}h=s;for(let e=0;e<a.length;e++)a[e].to<=h&&a.splice(e--,1)}let l=o.finish();return new Rf(l,t,Pf(l))}}function Pf(e,t=null,i=0){let s=null;return e.between(i,1e9,((e,i,{spec:r})=>{if(!(t&&r.diagnostics.indexOf(t)<0))if(s){if(r.diagnostics.indexOf(s.diagnostic)<0)return!1;s=new Af(s.from,i,s.diagnostic)}else s=new Af(e,i,t||r.diagnostics[0])})),s}const Mf=de.define(),Bf=de.define(),Lf=de.define(),Ff=j.define({create:()=>new Rf(ii.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),s=null,r=e.panel;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);s=Pf(i,e.selected.diagnostic,r)||Pf(i,null,r)}!i.size&&r&&t.state.facet($f).autoPanel&&(r=null),e=new Rf(i,r,s)}for(let i of t.effects)if(i.is(Mf)){let s=t.state.facet($f).autoPanel?i.value.length?jf.open:null:e.panel;e=Rf.init(i.value,s,t.state)}else i.is(Bf)?e=new Rf(e.diagnostics,i.value?jf.open:null,e.selected):i.is(Lf)&&(e=new Rf(e.diagnostics,e.panel,i.value));return e},provide:e=>[So.from(e,(e=>e.panel)),Zr.decorations.from(e,(e=>e.diagnostics))]}),If=ii.mark({class:"cm-lintRange cm-lintRange-active"});function Qf(e,t,i){let s,{diagnostics:r}=e.state.field(Ff),n=-1,o=-1;r.between(t-(i<0?1:0),t+(i>0?1:0),((e,r,{spec:a})=>{if(t>=e&&t<=r&&(e==r||(t>e||i>0)&&(t<r||i<0)))return s=a.diagnostics,n=e,o=r,!1}));let a=e.state.facet($f).tooltipFilter;return s&&a&&(s=a(s,e.state)),s?{pos:n,end:o,above:e.state.doc.lineAt(n).to<o,create:()=>({dom:Wf(e,s)})}:null}function Wf(e,t){return Jc("ul",{class:"cm-tooltip-lint"},t.map((t=>Nf(e,t,!1))))}const Hf=e=>{let t=e.state.field(Ff,!1);return!(!t||!t.panel||(e.dispatch({effects:Bf.of(!1)}),0))},qf=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(Ff,!1);var i,s;t&&t.panel||e.dispatch({effects:(i=e.state,s=[Bf.of(!0)],i.field(Ff,!1)?s:s.concat(de.appendConfig.of(Yf)))});let r=mo(e,jf.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(Ff,!1);if(!t)return!1;let i=e.state.selection.main,s=t.diagnostics.iter(i.to+1);return!(!s.value&&(s=t.diagnostics.iter(0),!s.value||s.from==i.from&&s.to==i.to)||(e.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0}),0))}}],$f=H.define({combine:e=>Object.assign({sources:e.map((e=>e.source)).filter((e=>null!=e))},De(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 zf(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let s=i[e];if(/[a-zA-Z]/.test(s)&&!t.some((e=>e.toLowerCase()==s.toLowerCase()))){t.push(s);continue e}}t.push("")}return t}function Nf(e,t,i){var s;let r=i?zf(t.actions):[];return Jc("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Jc("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(s=t.actions)||void 0===s?void 0:s.map(((i,s)=>{let n=!1,o=s=>{if(s.preventDefault(),n)return;n=!0;let r=Pf(e.state.field(Ff).diagnostics,t);r&&i.apply(e,r.from,r.to)},{name:a}=i,h=r[s]?a.indexOf(r[s]):-1,l=h<0?a:[a.slice(0,h),Jc("u",a.slice(h,h+1)),a.slice(h+1)];return Jc("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${a}${h<0?"":` (access key "${r[s]})"`}.`},l)})),t.source&&Jc("div",{class:"cm-diagnosticSource"},t.source))}class Uf extends ei{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Jc("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Vf{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Nf(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class jf{constructor(e){this.view=e,this.items=[],this.list=Jc("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)Hf(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],s=zf(i.actions);for(let r=0;r<s.length;r++)if(s[r].toUpperCase().charCodeAt(0)==t.keyCode){let t=Pf(this.view.state.field(Ff).diagnostics,i);t&&i.actions[r].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=Jc("div",{class:"cm-panel-lint"},this.list,Jc("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Hf(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ff).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Ff),i=0,s=!1,r=null,n=new Set;for(e.between(0,this.view.state.doc.length,((e,o,{spec:a})=>{for(let e of a.diagnostics){if(n.has(e))continue;n.add(e);let o,a=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(o=new Vf(this.view,e),this.items.splice(i,0,o),s=!0):(o=this.items[a],a>i&&(this.items.splice(i,a-i),s=!0)),t&&o.diagnostic==t.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),r=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),i++}}));i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();0==this.items.length&&(this.items.push(new Vf(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&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=Pf(this.view.state.field(Ff).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Lf.of(t)})}static open(e){return new jf(e)}}function Xf(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Gf=Zr.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:Xf("#d11")},".cm-lintRange-warning":{backgroundImage:Xf("orange")},".cm-lintRange-info":{backgroundImage:Xf("#999")},".cm-lintRange-hint":{backgroundImage:Xf("#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 Kf(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function Zf(e){let t="hint",i=1;for(let s of e){let e=Kf(s.severity);e>i&&(i=e,t=s.severity)}return t}const Yf=[Ff,Zr.decorations.compute([Ff],(e=>{let{selected:t,panel:i}=e.field(Ff);return t&&i&&t.from!=t.to?ii.set([If.range(t.from,t.to)]):ii.none})),uo(Qf,{hideOn:function(e,t){let i=t.pos,s=t.end||i,r=e.state.facet($f).hideOn(e,i,s);if(null!=r)return r;let n=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(Mf)))&&!e.changes.touchesRange(n.from,Math.max(n.to,s)))}}),Gf],Jf=(()=>[qo(),No,Qn(),Ql(),Xh(),wn(),[Tn,An],ye.allowMultipleSelections.of(!0),ye.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:s}=e.newSelection.main,r=i.lineAt(s);if(s>r.from+200)return e;let n=i.sliceString(r.from,s);if(!t.some((e=>e.test(n))))return e;let{state:o}=e,a=-1,h=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let i=mh(o,t.from);if(null==i)continue;let s=/^\s*/.exec(t.text)[0],r=gh(o,i);s!=r&&h.push({from:t.from,to:t.from+s.length,insert:r})}return h.length?[e,{changes:h,sequential:!0}]:e})),el(sl,{fallback:!0}),dl(),[_f,ff],xf(),Vn(),Gn(),zn,mu(),on.of([...Of,...Zc,...Ku,...tc,...Wh,...Ef,...qf])])();class ep{constructor(e,t,i,s,r,n,o,a,h,l=0,c){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=n,this.buffer=o,this.bufferBase=a,this.curContext=h,this.lookAhead=l,this.parent=c}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new ep(e,[],t,i,i,0,[],0,s?new tp(s,s.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,s=65535&e,{parser:r}=this.p,n=this.reducePos<this.pos-25;n&&this.setLookAhead(this.pos);let o=r.dynamicPrecedence(s);if(o&&(this.score+=o),0==i)return this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,n?8:4,!0),void this.reduceContext(s,this.reducePos);let a=this.stack.length-3*(i-1)-(262144&e?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from,l=this.reducePos-h;l>=2e3&&!(null===(t=this.p.parser.nodeSet.types[s])||void 0===t?void 0:t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSize<l&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=l));let c=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<r.minRepeatTerm||131072&e){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,h,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=r.getGoto(e,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,h)}storeNode(e,t,i,s=4,r=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,s=this.buffer.length;if(0==s&&e.parent&&(s=e.bufferBase-e.parent.bufferBase,e=e.parent),s>0&&0==e.buffer[s-4]&&e.buffer[s-1]>-1){if(t==i)return;if(e.buffer[s-2]>=t)return void(e.buffer[s-2]=i)}}if(r&&this.pos!=i){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4]){let e=!1;for(let t=r;t>0&&this.buffer[t-2]>i;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;r>0&&this.buffer[r-2]>i;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,s>4&&(s-=4)}this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=i,this.buffer[r+3]=s}else this.buffer.push(e,t,i,s)}shift(e,t,i,s){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4);else{let r=e,{parser:n}=this.p;(s>this.pos||t<=n.maxNode)&&(this.pos=s,n.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,i),this.shiftContext(t,i),t<=n.maxNode&&this.buffer.push(t,i,s,4)}}apply(e,t,i,s){65536&e?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new ep(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,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 ip(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))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 s,r=0;r<t.length;r+=2)(s=t[r+1])!=this.state&&this.p.parser.hasAction(s,e)&&i.push(t[r],s);if(this.stack.length<120)for(let e=0;i.length<8&&e<t.length;e+=2){let s=t[e+1];i.some(((e,t)=>1&t&&e==s))||i.push(t[e],s)}t=i}let i=[];for(let e=0;e<t.length&&i.length<4;e+=2){let s=t[e+1];if(s==this.state)continue;let r=this.split();r.pushState(s,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(t[e],this.pos),r.reducePos=this.pos,r.score-=200,i.push(r)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let i=t>>19,s=65535&t,r=this.stack.length-3*i;if(r<0||e.getGoto(this.stack[r],s,!1)<0){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=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,(t=>{if(393216&t);else if(65536&t){let i=(t>>19)-r;if(i>1){let s=65535&t,r=this.stack.length-3*i;if(r>=0&&e.getGoto(this.stack[r],s,!1)>=0)return i<<19|65536|s}}else{let e=i(t,r+1);if(null!=e)return e}}))};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new tp(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class tp{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class ip{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,i=e>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class sp{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 sp(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 sp(this.stack,this.pos,this.index)}}function rp(e,t=Uint16Array){if("string"!=typeof e)return e;let i=null;for(let s=0,r=0;s<e.length;){let n=0;for(;;){let t=e.charCodeAt(s++),i=!1;if(126==t){n=65535;break}t>=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,i=!0),n+=r,i)break;n*=46}i?i[r++]=n:i=new t(n)}return i}class np{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const op=new np;class ap{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=op,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,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let e=this.ranges[--s];r-=i.from-e.to,i=e}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let e=this.ranges[++s];r+=e.from-i.to,i=e}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,i,s=this.chunkOff+e;if(s>=0&&s<this.chunk.length)t=this.pos+e,i=this.chunk.charCodeAt(s);else{let s=this.resolveOffset(e,1);if(null==s)return-1;if(t=s,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,s=this.range;for(;s.to<=t;)s=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-t)),i=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),i}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(null==i||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.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=op,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(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 s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class hp{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;!function(e,t,i,s,r,n){let o=0,a=1<<s,{dialect:h}=i.p.parser;e:for(;a&e[o];){let i=e[o+1];for(let s=o+3;s<i;s+=2)if((e[s+1]&a)>0){let i=e[s];if(h.allows(i)&&(-1==t.token.value||t.token.value==i||up(i,t.token.value,r,n))){t.acceptToken(i);break}}let s=t.next,l=0,c=e[o+2];if(!(t.next<0&&c>l&&65535==e[i+3*c-3])){for(;l<c;){let r=l+c>>1,n=i+r+(r<<1),a=e[n],h=e[n+1]||65536;if(s<a)c=r;else{if(!(s>=h)){o=e[n+2],t.advance();continue e}l=r+1}}break}o=e[i+3*c-1]}}(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}hp.prototype.contextual=hp.prototype.fallback=hp.prototype.extend=!1,hp.prototype.fallback=hp.prototype.extend=!1;class lp{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function cp(e,t,i){for(let s,r=t;65535!=(s=e[r]);r++)if(s==i)return r-t;return-1}function up(e,t,i,s){let r=cp(i,s,t);return r<0||cp(i,s,e)<r}const dp="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let fp=null;function pp(e,t,i){let s=e.cursor(ta.IncludeAnonymous);for(s.moveTo(t);;)if(!(i<0?s.childBefore(t):s.childAfter(t)))for(;;){if((i<0?s.to<t:s.from>t)&&!s.type.isError)return i<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(e.length,Math.max(s.from+1,t+25));if(i<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return i<0?0:e.length}}class gp{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?pp(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pp(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(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],n=this.start[t]+i.positions[s];if(n>e)return this.nextStart=n,null;if(r instanceof ia){if(n==e){if(n<this.safeFrom)return null;let e=n+r.length;if(e<=this.safeTo){let t=r.prop(Xo.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,n+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(n),this.index.push(0))}else this.index[t]++,this.nextStart=n+r.length}}}class mp{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map((e=>new np))}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,n=s.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let s=0;s<r.length;s++){if(!(1<<s&n))continue;let h=r[s],l=this.tokens[s];if((!i||h.fallback)&&((h.contextual||l.start!=e.pos||l.mask!=n||l.context!=o)&&(this.updateCachedToken(l,h,e),l.mask=n,l.context=o),l.lookAhead>l.end+25&&(a=Math.max(l.lookAhead,a)),0!=l.value)){let s=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!h.extend&&(i=l,t>s))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),i||e.pos!=this.stream.end||(i=new np,i.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 np,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:t}=i.p;for(let s=0;s<t.specialized.length;s++)if(t.specialized[s]==e.value){let r=t.specializers[s](this.stream.read(e.start,e.end),i);if(r>=0&&i.p.parser.dialect.allows(r>>1)){1&r?e.extended=r>>1:e.value=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,i,s){for(let t=0;t<s;t+=3)if(this.actions[t]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:n}=e.p,{data:o}=n;for(let e=0;e<2;e++)for(let a=n.stateSlot(r,e?2:1);;a+=3){if(65535==o[a]){if(1!=o[a+1]){0==s&&2==o[a+1]&&(s=this.putAction(bp(o,a+2),t,i,s));break}a=bp(o,a+2)}o[a]==t&&(s=this.putAction(bp(o,a+1),t,i,s))}return s}}class vp{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new ap(t,s),this.tokens=new mp(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[ep.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>4*e.bufferLength?new gp(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,i=this.stacks,s=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[e]=i;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let n=0;n<i.length;n++){let o=i[n];for(;;){if(this.tokens.mainToken=null,o.pos>s)r.push(o);else{if(this.advanceStack(o,r,i))continue;{e||(e=[],t=[]),e.push(o);let i=this.tokens.getMainToken(o);t.push(i.value,i.end)}}break}}if(!r.length){let t=e&&function(e){let t=null;for(let i of e){let e=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=e&&i.pos>e)&&i.p.parser.stateFlag(i.state,2)&&(!t||t.score<i.score)&&(t=i)}return t}(e);if(t)return dp&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw dp&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&e){let i=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,r);if(i)return dp&&console.log("Force-finish "+this.stackID(i)),this.stackToTree(i.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort(((e,t)=>t.score-e.score));r.length>e;)r.pop();r.some((e=>e.reducePos>s))&&this.recovering--}else if(r.length>1){e:for(let e=0;e<r.length-1;e++){let t=r[e];for(let i=e+1;i<r.length;i++){let s=r[i];if(t.sameState(s)||t.buffer.length>500&&s.buffer.length>500){if(!((t.score-s.score||t.buffer.length-s.buffer.length)>0)){r.splice(e--,1);continue e}r.splice(i--,1)}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e<r.length;e++)r[e].pos<this.minStackPos&&(this.minStackPos=r[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let s=e.pos,{parser:r}=this,n=dp?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&s>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(s);o;){let s=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(s>-1&&o.length&&(!t||(o.prop(Xo.contextHash)||0)==i))return e.useNode(o,s),dp&&console.log(n+this.stackID(e)+` (via reuse of ${r.getName(o.type.id)})`),!0;if(!(o instanceof ia)||0==o.children.length||o.positions[0]>0)break;let a=o.children[0];if(!(a instanceof ia&&0==o.positions[0]))break;o=a}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),dp&&console.log(n+this.stackID(e)+` (via always-reduce ${r.getName(65535&o)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let o=0;o<a.length;){let h=a[o++],l=a[o++],c=a[o++],u=o==a.length||!i,d=u?e:e.split(),f=this.tokens.mainToken;if(d.apply(h,l,f?f.start:d.pos,c),dp&&console.log(n+this.stackID(d)+` (via ${65536&h?`reduce of ${r.getName(65535&h)}`:"shift"} for ${r.getName(l)} @ ${s}${d==e?"":", split"})`),u)return!0;d.pos>s?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 _p(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let n=0;n<e.length;n++){let o=e[n],a=t[n<<1],h=t[1+(n<<1)],l=dp?this.stackID(o)+" -> ":"";if(o.deadEnd){if(r)continue;if(r=!0,o.restart(),dp&&console.log(l+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))continue}let c=o.split(),u=l;for(let e=0;c.forceReduce()&&e<10&&(dp&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));e++)dp&&(u=this.stackID(c)+" -> ");for(let e of o.recoverByInsert(a))dp&&console.log(l+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,i);this.stream.end>o.pos?(h==o.pos&&(h++,a=0),o.recoverByDelete(a,h),dp&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),_p(o,i)):(!s||s.score<o.score)&&(s=o)}return s}stackToTree(e){return e.close(),ia.build({buffer:sp.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(fp||(fp=new WeakMap)).get(e);return t||fp.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function _p(e,t){for(let i=0;i<t.length;i++){let s=t[i];if(s.pos==e.pos&&s.sameState(e))return void(t[i].score<e.score&&(t[i]=e))}t.push(e)}class Op{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||0==this.disabled[e]}}const Sp=e=>e;class wp extends ba{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let i=0;i<e.repeatNodeCount;i++)t.push("");let i=Object.keys(e.topRules).map((t=>e.topRules[t][1])),s=[];for(let e=0;e<t.length;e++)s.push([]);function r(e,t,i){s[e].push([t,t.deserialize(String(i))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=Xo[e]);for(let i=1;i<t.length;){let s=t[i++];if(s>=0)r(s,e,t[i++]);else{let n=t[i+-s];for(let o=-s;o>0;o--)r(t[i++],e,n);i++}}}this.nodeSet=new Yo(t.map(((t,r)=>Zo.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:s[r],top:i.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1})))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Uo;let n=rp(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(yp),this.states=rp(e.states,Uint32Array),this.data=rp(e.stateData),this.goto=rp(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map((e=>"number"==typeof e?new hp(n,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 s=new vp(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let t=s[r++],n=1&t,o=s[r++];if(n&&i)return o;for(let i=r+(t>>1);r<i;r++)if(s[r]==e)return o;if(n)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r,n=this.stateSlot(e,s?2:1);;n+=3){if(65535==(r=i[n])){if(1!=i[n+1]){if(2==i[n+1])return bp(i,n+2);break}r=i[n=bp(i,n+2)]}if(r==t||0==r)return bp(i,n+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,(e=>e==t||null))}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let i=this.stateSlot(e,1);null==s;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=bp(this.data,i+2)}s=t(bp(this.data,i+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=bp(this.data,i+2)}if(!(1&this.data[i+2])){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(wp.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new 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,s)=>{let r=e.specializers.find((e=>e.from==i.external));if(!r)return i;let n=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=yp(n),n}))),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 s of e.split(" ")){let e=t.indexOf(s);e>=0&&(i[e]=!0)}let s=null;for(let e=0;e<t.length;e++)if(!i[e])for(let i,r=this.dialects[t[e]];65535!=(i=this.data[r++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[i]=1;return new Op(e,i,s)}static deserialize(e){return new wp(e)}}function bp(e,t){return e[t]|e[t+1]<<16}function yp(e){if(e.external){let t=e.extend?1:0;return(i,s)=>e.external(i,s)<<1|t}return e.get}const Dp=10,Cp=new Set([25,49,50,263,65,130,56,57,238,62,63,72,73,77,60,61,151,152,155,112]);function kp(e){return e==Dp||13==e}function xp(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}const Ep=new lp(((e,t)=>{let i;if(e.next<0)e.acceptToken(199);else if(t.context.flags&Ap)kp(e.next)&&e.acceptToken(198,1);else if(((i=e.peek(-1))<0||kp(i))&&t.canShift(197)){let t=0;for(;32==e.next||9==e.next;)e.advance(),t++;e.next!=Dp&&13!=e.next&&35!=e.next||e.acceptToken(197,-t)}else kp(e.next)&&e.acceptToken(196,1)}),{contextual:!0}),Tp=new lp(((e,t)=>{let i=t.context;if(i.flags)return;let s=e.peek(-1);if(s==Dp||13==s){let t=0,s=0;for(;;){if(32==e.next)t++;else{if(9!=e.next)break;t+=8-t%8}e.advance(),s++}t!=i.indent&&e.next!=Dp&&13!=e.next&&35!=e.next&&(t<i.indent?e.acceptToken(195,-s):e.acceptToken(194))}})),Ap=1,Rp=4,Pp=8,Mp=16,Bp=32;function Lp(e,t,i){this.parent=e,this.indent=t,this.flags=i,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+i+(i<<6)}const Fp=new Lp(null,0,0),Ip=new Map([[241,0],[242,Rp],[243,Pp],[244,Pp|Rp],[245,Mp],[246,Mp|Rp],[247,Mp|Pp],[248,Mp|Pp|Rp],[249,Bp],[250,Bp|Rp],[251,Bp|Pp],[252,Bp|Pp|Rp],[253,Bp|Mp],[254,Bp|Mp|Rp],[255,Bp|Mp|Pp],[256,Bp|Mp|Pp|Rp]].map((([e,t])=>[e,2|t]))),Qp=new class{constructor(e){this.start=e.start,this.shift=e.shift||Sp,this.reduce=e.reduce||Sp,this.reuse=e.reuse||Sp,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}({start:Fp,reduce:(e,t,i,s)=>e.flags&Ap&&Cp.has(t)||(71==t||72==t)&&2&e.flags?e.parent:e,shift:(e,t,i,s)=>194==t?new Lp(e,function(e){let t=0;for(let i=0;i<e.length;i++)t+=9==e.charCodeAt(i)?8-t%8:1;return t}(s.read(s.pos,i.pos)),0):195==t?e.parent:24==t||55==t||59==t||3==t?new Lp(e,0,Ap):Ip.has(t)?new Lp(e,0,Ip.get(t)|e.flags&Ap):e,hash:e=>e.hash}),Wp=new lp((e=>{for(let t=0;t<5;t++){if(e.next!="print".charCodeAt(t))return;e.advance()}if(!/\w/.test(String.fromCharCode(e.next)))for(let t=0;;t++){let i=e.peek(t);if(32!=i&&9!=i)return void(40!=i&&46!=i&&i!=Dp&&13!=i&&35!=i&&e.acceptToken(1))}})),Hp=new lp(((e,t)=>{let{flags:i}=t.context,s=i&Rp?34:39,r=(i&Pp)>0,n=!(i&Mp),o=(i&Bp)>0,a=e.pos;for(;!(e.next<0);)if(o&&123==e.next){if(123!=e.peek(1)){if(e.pos==a)return void e.acceptToken(3,1);break}e.advance(2)}else{if(n&&92==e.next){if(e.pos==a){e.advance();let t=e.next;return t>=0&&(e.advance(),qp(e,t)),void e.acceptToken(2)}break}if(e.next==s&&(!r||e.peek(1)==s&&e.peek(2)==s)){if(e.pos==a)return void e.acceptToken(201,r?3:1);break}if(e.next==Dp){if(r)e.advance();else if(e.pos==a)return void e.acceptToken(201);break}e.advance()}e.pos>a&&e.acceptToken(200)}));function qp(e,t){if(111==t)for(let t=0;t<2&&e.next>=48&&e.next<=55;t++)e.advance();else if(120==t)for(let t=0;t<2&&xp(e.next);t++)e.advance();else if(117==t)for(let t=0;t<4&&xp(e.next);t++)e.advance();else if(85==t)for(let t=0;t<8&&xp(e.next);t++)e.advance();else if(78==t&&123==e.next){for(e.advance();e.next>=0&&125!=e.next&&39!=e.next&&34!=e.next&&e.next!=Dp;)e.advance();125==e.next&&e.advance()}}const $p=Ea({'async "*" "**" FormatConversion FormatSpec':Ga.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":Ga.controlKeyword,"in not and or is del":Ga.operatorKeyword,"from def class global nonlocal lambda":Ga.definitionKeyword,import:Ga.moduleKeyword,"with as print":Ga.keyword,Boolean:Ga.bool,None:Ga.null,VariableName:Ga.variableName,"CallExpression/VariableName":Ga.function(Ga.variableName),"FunctionDefinition/VariableName":Ga.function(Ga.definition(Ga.variableName)),"ClassDefinition/VariableName":Ga.definition(Ga.className),PropertyName:Ga.propertyName,"CallExpression/MemberExpression/PropertyName":Ga.function(Ga.propertyName),Comment:Ga.lineComment,Number:Ga.number,String:Ga.string,FormatString:Ga.special(Ga.string),Escape:Ga.escape,UpdateOp:Ga.updateOperator,"ArithOp!":Ga.arithmeticOperator,BitOp:Ga.bitwiseOperator,CompareOp:Ga.compareOperator,AssignOp:Ga.definitionOperator,Ellipsis:Ga.punctuation,At:Ga.meta,"( )":Ga.paren,"[ ]":Ga.squareBracket,"{ }":Ga.brace,".":Ga.derefOperator,", ;":Ga.separator}),zp={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},Np=wp.deserialize({version:14,states:"##jO`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#EnO0rQdO'#EtO0rQdO'#EwO4VQdO'#EyO4^QdO'#FOO4iQdO'#EzO0rQdO'#FOO1XQdO'#FQO1XQdO'#FVO4nQdO'#F[P4uOdO'#GpPOOO)CBd)CBdOOQS'#Ce'#CeOOQS'#Cf'#CfOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Cl'#ClO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO5TQdO'#DoOOQS,5:Y,5:YO5hQdO'#HdOOQS,5:],5:]O5uQ!fO,5:]O5zQtO,59YO1lQdO,59bO1lQdO,59bO1lQdO,59bO8jQdO,59bO8oQdO,59bO8vQdO,59jO8}QdO'#HTO:TQdO'#HSOOQS'#HS'#HSOOQS'#D['#D[O:lQdO,59aO'vQdO,59aO:zQdO,59aOOQS,59y,59yO;PQdO,5:RO'vQdO,5:ROOQS,5:Q,5:QO;_QdO,5:QO;dQdO,5:XO'vQdO,5:XO'vQdO,5:VOOQS,5:U,5:UO;uQdO,5:UO;zQdO,5:WOOOW'#Fy'#FyO<POWO,5:aOOQS,5:a,5:aO<[QdO'#HwOOOW'#Dw'#DwOOOW'#Fz'#FzO<lOWO,5:bOOQS,5:b,5:bOOQS'#F}'#F}O<zQtO,5:iO?lQtO,5=`O@VQ#xO,5=`O@vQtO,5=`OOQS,5:},5:}OA_QeO'#GWOBqQdO,5;^OOQV,5=^,5=^OB|QtO'#IPOCkQdO,5;tOOQS-E:[-E:[OOQV,5;s,5;sO4dQdO'#FQOOQV-E9o-E9oOCsQtO,59]OEzQtO,59iOFeQdO'#HVOFpQdO'#HVO1XQdO'#HVOF{QdO'#DTOGTQdO,59mOGYQdO'#HZO'vQdO'#HZO0rQdO,5=tOOQS,5=t,5=tO0rQdO'#EROOQS'#ES'#ESOGwQdO'#GPOHXQdO,58|OHXQdO,58|O*xQdO,5:oOHgQtO'#H]OOQS,5:r,5:rOOQS,5:z,5:zOHzQdO,5;OOI]QdO'#IOO1XQdO'#H}OOQS,5;Q,5;QOOQS'#GT'#GTOIqQtO,5;QOJPQdO,5;QOJUQdO'#IQOOQS,5;T,5;TOJdQdO'#H|OOQS,5;W,5;WOJuQdO,5;YO4iQdO,5;`O4iQdO,5;cOJ}QtO'#ITO'vQdO'#ITOKXQdO,5;eO4VQdO,5;eO0rQdO,5;jO1XQdO,5;lOK^QeO'#EuOLjQgO,5;fO!!kQdO'#IUO4iQdO,5;jO!!vQdO,5;lO!#OQdO,5;qO!#ZQtO,5;vO'vQdO,5;vPOOO,5=[,5=[P!#bOSO,5=[P!#jOdO,5=[O!&bQtO1G.jO!&iQtO1G.jO!)YQtO1G.jO!)dQtO1G.jO!+}QtO1G.jO!,bQtO1G.jO!,uQdO'#HcO!-TQtO'#GuO0rQdO'#HcO!-_QdO'#HbOOQS,5:Z,5:ZO!-gQdO,5:ZO!-lQdO'#HeO!-wQdO'#HeO!.[QdO,5>OOOQS'#Ds'#DsOOQS1G/w1G/wOOQS1G.|1G.|O!/[QtO1G.|O!/cQtO1G.|O1lQdO1G.|O!0OQdO1G/UOOQS'#DZ'#DZO0rQdO,59tOOQS1G.{1G.{O!0VQdO1G/eO!0gQdO1G/eO!0oQdO1G/fO'vQdO'#H[O!0tQdO'#H[O!0yQtO1G.{O!1ZQdO,59iO!2aQdO,5=zO!2qQdO,5=zO!2yQdO1G/mO!3OQtO1G/mOOQS1G/l1G/lO!3`QdO,5=uO!4VQdO,5=uO0rQdO1G/qO!4tQdO1G/sO!4yQtO1G/sO!5ZQtO1G/qOOQS1G/p1G/pOOQS1G/r1G/rOOOW-E9w-E9wOOQS1G/{1G/{O!5kQdO'#HxO0rQdO'#HxO!5|QdO,5>cOOOW-E9x-E9xOOQS1G/|1G/|OOQS-E9{-E9{O!6[Q#xO1G2zO!6{QtO1G2zO'vQdO,5<jOOQS,5<j,5<jOOQS-E9|-E9|OOQS,5<r,5<rOOQS-E:U-E:UOOQV1G0x1G0xO1XQdO'#GRO!7dQtO,5>kOOQS1G1`1G1`O!8RQdO1G1`OOQS'#DV'#DVO0rQdO,5=qOOQS,5=q,5=qO!8WQdO'#FrO!8cQdO,59oO!8kQdO1G/XO!8uQtO,5=uOOQS1G3`1G3`OOQS,5:m,5:mO!9fQdO'#GtOOQS,5<k,5<kOOQS-E9}-E9}O!9wQdO1G.hOOQS1G0Z1G0ZO!:VQdO,5=wO!:gQdO,5=wO0rQdO1G0jO0rQdO1G0jO!:xQdO,5>jO!;ZQdO,5>jO1XQdO,5>jO!;lQdO,5>iOOQS-E:R-E:RO!;qQdO1G0lO!;|QdO1G0lO!<RQdO,5>lO!<aQdO,5>lO!<oQdO,5>hO!=VQdO,5>hO!=hQdO'#EpO0rQdO1G0tO!=sQdO1G0tO!=xQgO1G0zO!AvQgO1G0}O!EqQdO,5>oO!E{QdO,5>oO!FTQtO,5>oO0rQdO1G1PO!F_QdO1G1PO4iQdO1G1UO!!vQdO1G1WOOQV,5;a,5;aO!FdQfO,5;aO!FiQgO1G1QO!JjQdO'#GZO4iQdO1G1QO4iQdO1G1QO!JzQdO,5>pO!KXQdO,5>pO1XQdO,5>pOOQV1G1U1G1UO!KaQdO'#FSO!KrQ!fO1G1WO!KzQdO1G1WOOQV1G1]1G1]O4iQdO1G1]O!LPQdO1G1]O!LXQdO'#F^OOQV1G1b1G1bO!#ZQtO1G1bPOOO1G2v1G2vP!L^OSO1G2vOOQS,5=},5=}OOQS'#Dp'#DpO0rQdO,5=}O!LfQdO,5=|O!LyQdO,5=|OOQS1G/u1G/uO!MRQdO,5>PO!McQdO,5>PO!MkQdO,5>PO!NOQdO,5>PO!N`QdO,5>POOQS1G3j1G3jOOQS7+$h7+$hO!8kQdO7+$pO#!RQdO1G.|O#!YQdO1G.|OOQS1G/`1G/`OOQS,5<`,5<`O'vQdO,5<`OOQS7+%P7+%PO#!aQdO7+%POOQS-E9r-E9rOOQS7+%Q7+%QO#!qQdO,5=vO'vQdO,5=vOOQS7+$g7+$gO#!vQdO7+%PO##OQdO7+%QO##TQdO1G3fOOQS7+%X7+%XO##eQdO1G3fO##mQdO7+%XOOQS,5<_,5<_O'vQdO,5<_O##rQdO1G3aOOQS-E9q-E9qO#$iQdO7+%]OOQS7+%_7+%_O#$wQdO1G3aO#%fQdO7+%_O#%kQdO1G3gO#%{QdO1G3gO#&TQdO7+%]O#&YQdO,5>dO#&sQdO,5>dO#&sQdO,5>dOOQS'#Dx'#DxO#'UO&jO'#DzO#'aO`O'#HyOOOW1G3}1G3}O#'fQdO1G3}O#'nQdO1G3}O#'yQ#xO7+(fO#(jQtO1G2UP#)TQdO'#GOOOQS,5<m,5<mOOQS-E:P-E:POOQS7+&z7+&zOOQS1G3]1G3]OOQS,5<^,5<^OOQS-E9p-E9pOOQS7+$s7+$sO#)bQdO,5=`O#){QdO,5=`O#*^QtO,5<aO#*qQdO1G3cOOQS-E9s-E9sOOQS7+&U7+&UO#+RQdO7+&UO#+aQdO,5<nO#+uQdO1G4UOOQS-E:Q-E:QO#,WQdO1G4UOOQS1G4T1G4TOOQS7+&W7+&WO#,iQdO7+&WOOQS,5<p,5<pO#,tQdO1G4WOOQS-E:S-E:SOOQS,5<l,5<lO#-SQdO1G4SOOQS-E:O-E:OO1XQdO'#EqO#-jQdO'#EqO#-uQdO'#IRO#-}QdO,5;[OOQS7+&`7+&`O0rQdO7+&`O#.SQgO7+&fO!JmQdO'#GXO4iQdO7+&fO4iQdO7+&iO#2QQtO,5<tO'vQdO,5<tO#2[QdO1G4ZOOQS-E:W-E:WO#2fQdO1G4ZO4iQdO7+&kO0rQdO7+&kOOQV7+&p7+&pO!KrQ!fO7+&rO!KzQdO7+&rO`QeO1G0{OOQV-E:X-E:XO4iQdO7+&lO4iQdO7+&lOOQV,5<u,5<uO#2nQdO,5<uO!JmQdO,5<uOOQV7+&l7+&lO#2yQgO7+&lO#6tQdO,5<vO#7PQdO1G4[OOQS-E:Y-E:YO#7^QdO1G4[O#7fQdO'#IWO#7tQdO'#IWO1XQdO'#IWOOQS'#IW'#IWO#8PQdO'#IVOOQS,5;n,5;nO#8XQdO,5;nO0rQdO'#FUOOQV7+&r7+&rO4iQdO7+&rOOQV7+&w7+&wO4iQdO7+&wO#8^QfO,5;xOOQV7+&|7+&|POOO7+(b7+(bO#8cQdO1G3iOOQS,5<c,5<cO#8qQdO1G3hOOQS-E9u-E9uO#9UQdO,5<dO#9aQdO,5<dO#9tQdO1G3kOOQS-E9v-E9vO#:UQdO1G3kO#:^QdO1G3kO#:nQdO1G3kO#:UQdO1G3kOOQS<<H[<<H[O#:yQtO1G1zOOQS<<Hk<<HkP#;WQdO'#FtO8vQdO1G3bO#;eQdO1G3bO#;jQdO<<HkOOQS<<Hl<<HlO#;zQdO7+)QOOQS<<Hs<<HsO#<[QtO1G1yP#<{QdO'#FsO#=YQdO7+)RO#=jQdO7+)RO#=rQdO<<HwO#=wQdO7+({OOQS<<Hy<<HyO#>nQdO,5<bO'vQdO,5<bOOQS-E9t-E9tOOQS<<Hw<<HwOOQS,5<g,5<gO0rQdO,5<gO#>sQdO1G4OOOQS-E9y-E9yO#?^QdO1G4OO<[QdO'#H{OOOO'#D{'#D{OOOO'#F|'#F|O#?oO&jO,5:fOOOW,5>e,5>eOOOW7+)i7+)iO#?zQdO7+)iO#@SQdO1G2zO#@mQdO1G2zP'vQdO'#FuO0rQdO<<IpO1XQdO1G2YP1XQdO'#GSO#AOQdO7+)pO#AaQdO7+)pOOQS<<Ir<<IrP1XQdO'#GUP0rQdO'#GQOOQS,5;],5;]O#ArQdO,5>mO#BQQdO,5>mOOQS1G0v1G0vOOQS<<Iz<<IzOOQV-E:V-E:VO4iQdO<<JQOOQV,5<s,5<sO4iQdO,5<sOOQV<<JQ<<JQOOQV<<JT<<JTO#BYQtO1G2`P#BdQdO'#GYO#BkQdO7+)uO#BuQgO<<JVO4iQdO<<JVOOQV<<J^<<J^O4iQdO<<J^O!KrQ!fO<<J^O#FpQgO7+&gOOQV<<JW<<JWO#FzQgO<<JWOOQV1G2a1G2aO1XQdO1G2aO#JuQdO1G2aO4iQdO<<JWO1XQdO1G2bP0rQdO'#G[O#KQQdO7+)vO#K_QdO7+)vOOQS'#FT'#FTO0rQdO,5>rO#KgQdO,5>rOOQS,5>r,5>rO#KrQdO,5>qO#LTQdO,5>qOOQS1G1Y1G1YOOQS,5;p,5;pOOQV<<Jc<<JcO#L]QdO1G1dOOQS7+)T7+)TP#LbQdO'#FwO#LrQdO1G2OO#MVQdO1G2OO#MgQdO1G2OP#MrQdO'#FxO#NPQdO7+)VO#NaQdO7+)VO#NaQdO7+)VO#NiQdO7+)VO#NyQdO7+(|O8vQdO7+(|OOQSAN>VAN>VO$ dQdO<<LmOOQSAN>cAN>cO0rQdO1G1|O$ tQtO1G1|P$!OQdO'#FvOOQS1G2R1G2RP$!]QdO'#F{O$!jQdO7+)jO$#TQdO,5>gOOOO-E9z-E9zOOOW<<MT<<MTO$#cQdO7+(fOOQSAN?[AN?[OOQS7+'t7+'tO$#|QdO<<M[OOQS,5<q,5<qO$$_QdO1G4XOOQS-E:T-E:TOOQVAN?lAN?lOOQV1G2_1G2_O4iQdOAN?qO$$mQgOAN?qOOQVAN?xAN?xO4iQdOAN?xOOQV<<JR<<JRO4iQdOAN?rO4iQdO7+'{OOQV7+'{7+'{O1XQdO7+'{OOQVAN?rAN?rOOQS7+'|7+'|O$(hQdO<<MbOOQS1G4^1G4^O0rQdO1G4^OOQS,5<w,5<wO$(uQdO1G4]OOQS-E:Z-E:ZOOQU'#G_'#G_O$)WQfO7+'OO$)cQdO'#F_O$*jQdO7+'jO$*zQdO7+'jOOQS7+'j7+'jO$+VQdO<<LqO$+gQdO<<LqO$+gQdO<<LqO$+oQdO'#H^OOQS<<Lh<<LhO$+yQdO<<LhOOQS7+'h7+'hOOQS'#D|'#D|OOOO1G4R1G4RO$,dQdO1G4RO$,lQdO1G4RP!=hQdO'#GVOOQVG25]G25]O4iQdOG25]OOQVG25dG25dOOQVG25^G25^OOQV<<Kg<<KgO4iQdO<<KgOOQS7+)x7+)xP$,wQdO'#G]OOQU-E:]-E:]OOQV<<Jj<<JjO$-kQtO'#FaOOQS'#Fc'#FcO$-{QdO'#FbO$.mQdO'#FbOOQS'#Fb'#FbO$.rQdO'#IYO$)cQdO'#FiO$)cQdO'#FiO$/ZQdO'#FjO$)cQdO'#FkO$/bQdO'#IZOOQS'#IZ'#IZO$0PQdO,5;yOOQS<<KU<<KUO$0XQdO<<KUO$0iQdOANB]O$0yQdOANB]O$1RQdO'#H_OOQS'#H_'#H_O1sQdO'#DcO$1lQdO,5=xOOQSANBSANBSOOOO7+)m7+)mO$2TQdO7+)mOOQVLD*wLD*wOOQVANARANARO5uQ!fO'#GaO$2]QtO,5<SO$)cQdO'#FmOOQS,5<W,5<WOOQS'#Fd'#FdO$2}QdO,5;|O$3SQdO,5;|OOQS'#Fg'#FgO$)cQdO'#G`O$3tQdO,5<QO$4`QdO,5>tO$4pQdO,5>tO1XQdO,5<PO$5RQdO,5<TO$5WQdO,5<TO$)cQdO'#I[O$5]QdO'#I[O$5bQdO,5<UOOQS,5<V,5<VO'vQdO'#FpOOQU1G1e1G1eO4iQdO1G1eOOQSAN@pAN@pO$5gQdOG27wO$5wQdO,59}OOQS1G3d1G3dOOOO<<MX<<MXOOQS,5<{,5<{OOQS-E:_-E:_O$5|QtO'#FaO$6TQdO'#I]O$6cQdO'#I]O$6kQdO,5<XOOQS1G1h1G1hO$6pQdO1G1hO$6uQdO,5<zOOQS-E:^-E:^O$7aQdO,5=OO$7xQdO1G4`OOQS-E:b-E:bOOQS1G1k1G1kOOQS1G1o1G1oO$8YQdO,5>vO$)cQdO,5>vOOQS1G1p1G1pO$8hQtO,5<[OOQU7+'P7+'PO$+oQdO1G/iO$)cQdO,5<YO$8oQdO,5>wO$8vQdO,5>wOOQS1G1s1G1sOOQS7+'S7+'SP$)cQdO'#GdO$9OQdO1G4bO$9YQdO1G4bO$9bQdO1G4bOOQS7+%T7+%TO$9pQdO1G1tO$:OQtO'#FaO$:VQdO,5<}OOQS,5<},5<}O$:eQdO1G4cOOQS-E:a-E:aO$)cQdO,5<|O$:lQdO,5<|O$:qQdO7+)|OOQS-E:`-E:`O$:{QdO7+)|O$)cQdO,5<ZP$)cQdO'#GcO$;TQdO1G2hO$)cQdO1G2hP$;cQdO'#GbO$;jQdO<<MhO$;tQdO1G1uO$<SQdO7+(SO8vQdO'#C}O8vQdO,59bO8vQdO,59bO8vQdO,59bO$<bQtO,5=`O8vQdO1G.|O0rQdO1G/XO0rQdO7+$pP$<uQdO'#GOO'vQdO'#GtO$=SQdO,59bO$=XQdO,59bO$=`QdO,59mO$=eQdO1G/UO1sQdO'#DRO8vQdO,59j",stateData:"$>O~O%cOS%^OSSOS%]PQ~OPdOVaOfoOhYOopOs!POvqO!PrO!Q{O!T!SO!U!RO!XZO!][O!h`O!r`O!s`O!t`O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#l!QO#o!TO#s!UO#u!VO#z!WO#}hO$P!XO%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~O%]!YO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%j![O%k!]O%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aO~Ok%xXl%xXm%xXn%xXo%xXp%xXs%xXz%xX{%xX!x%xX#g%xX%[%xX%_%xX%z%xXg%xX!T%xX!U%xX%{%xX!W%xX![%xX!Q%xX#[%xXt%xX!m%xX~P%SOfoOhYO!XZO!][O!h`O!r`O!s`O!t`O%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~Oz%wX{%wX#g%wX%[%wX%_%wX%z%wX~Ok!pOl!qOm!oOn!oOo!rOp!sOs!tO!x%wX~P)pOV!zOg!|Oo0cOv0qO!PrO~P'vOV#OOo0cOv0qO!W#PO~P'vOV#SOa#TOo0cOv0qO![#UO~P'vOQ#XO%`#XO%a#ZO~OQ#^OR#[O%`#^O%a#`O~OV%iX_%iXa%iXh%iXk%iXl%iXm%iXn%iXo%iXp%iXs%iXz%iX!X%iX!f%iX%j%iX%k%iX%l%iX%m%iX%n%iX%o%iX%p%iX%q%iX%r%iX%s%iXg%iX!T%iX!U%iX~O&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O{%iX!x%iX#g%iX%[%iX%_%iX%z%iX%{%iX!W%iX![%iX!Q%iX#[%iXt%iX!m%iX~P,eOz#dO{%hX!x%hX#g%hX%[%hX%_%hX%z%hX~Oo0cOv0qO~P'vO#g#gO%[#iO%_#iO~O%uWO~O!T#nO#u!VO#z!WO#}hO~OopO~P'vOV#sOa#tO%uWO{wP~OV#xOo0cOv0qO!Q#yO~P'vO{#{O!x$QO%z#|O#g!yX%[!yX%_!yX~OV#xOo0cOv0qO#g#SX%[#SX%_#SX~P'vOo0cOv0qO#g#WX%[#WX%_#WX~P'vOh$WO%uWO~O!f$YO!r$YO%uWO~OV$eO~P'vO!U$gO#s$hO#u$iO~O{$jO~OV$qO~P'vOS$sO%[$rO%_$rO%c$tO~OV$}Oa$}Og%POo0cOv0qO~P'vOo0cOv0qO{%SO~P'vO&Y%UO~Oa!bOh!iO!X!kO!f!mOVba_bakbalbambanbaobapbasbazba{ba!xba#gba%[ba%_ba%jba%kba%lba%mba%nba%oba%pba%qba%rba%sba%zbagba!Tba!Uba%{ba!Wba![ba!Qba#[batba!mba~On%ZO~Oo%ZO~P'vOo0cO~P'vOk0eOl0fOm0dOn0dOo0mOp0nOs0rOg%wX!T%wX!U%wX%{%wX!W%wX![%wX!Q%wX#[%wX!m%wX~P)pO%{%]Og%vXz%vX!T%vX!U%vX!W%vX{%vX~Og%_Oz%`O!T%dO!U%cO~Og%_O~Oz%gO!T%dO!U%cO!W&SX~O!W%kO~Oz%lO{%nO!T%dO!U%cO![%}X~O![%rO~O![%sO~OQ#XO%`#XO%a%uO~OV%wOo0cOv0qO!PrO~P'vOQ#^OR#[O%`#^O%a%zO~OV!qa_!qaa!qah!qak!qal!qam!qan!qao!qap!qas!qaz!qa{!qa!X!qa!f!qa!x!qa#g!qa%[!qa%_!qa%j!qa%k!qa%l!qa%m!qa%n!qa%o!qa%p!qa%q!qa%r!qa%s!qa%z!qag!qa!T!qa!U!qa%{!qa!W!qa![!qa!Q!qa#[!qat!qa!m!qa~P#yOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P%SOV&OOopOvqO{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P'vOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#g$zX%[$zX%_$zX~P'vO#g#gO%[&TO%_&TO~O!f&UOh&sX%[&sXz&sX#[&sX#g&sX%_&sX#Z&sXg&sX~Oh!iO%[&WO~Okealeameaneaoeapeaseazea{ea!xea#gea%[ea%_ea%zeagea!Tea!Uea%{ea!Wea![ea!Qea#[eatea!mea~P%SOsqazqa{qa#gqa%[qa%_qa%zqa~Ok!pOl!qOm!oOn!oOo!rOp!sO!xqa~PEcO%z&YOz%yX{%yX~O%uWOz%yX{%yX~Oz&]O{wX~O{&_O~Oz%lO#g%}X%[%}X%_%}Xg%}X{%}X![%}X!m%}X%z%}X~OV0lOo0cOv0qO!PrO~P'vO%z#|O#gUa%[Ua%_Ua~Oz&hO#g&PX%[&PX%_&PXn&PX~P%SOz&kO!Q&jO#g#Wa%[#Wa%_#Wa~Oz&lO#[&nO#g&rX%[&rX%_&rXg&rX~O!f$YO!r$YO#Z&qO%uWO~O#Z&qO~Oz&sO#g&tX%[&tX%_&tX~Oz&uO#g&pX%[&pX%_&pX{&pX~O!X&wO%z&xO~Oz&|On&wX~P%SOn'PO~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO%['UO~P'vOt'YO#p'WO#q'XOP#naV#naf#nah#nao#nas#nav#na!P#na!Q#na!T#na!U#na!X#na!]#na!h#na!r#na!s#na!t#na!{#na!}#na#P#na#R#na#T#na#X#na#Z#na#^#na#_#na#a#na#c#na#l#na#o#na#s#na#u#na#z#na#}#na$P#na%X#na%o#na%p#na%t#na%u#na&Z#na&[#na&]#na&^#na&_#na&`#na&a#na&b#na&c#na&d#na&e#na&f#na&g#na&h#na&i#na&j#na%Z#na%_#na~Oz'ZO#[']O{&xX~Oh'_O!X&wO~Oh!iO{$jO!X&wO~O{'eO~P%SO%['hO%_'hO~OS'iO%['hO%_'hO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%k!]O~P!#uO%kWi~P!#uOV!aO_!aOa!bOh!iO!X!kO!f!mO%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%m!_O%n!_O~P!&pO%mWi%nWi~P!&pOa!bOh!iO!X!kO!f!mOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%mWi%nWi%oWi%pWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~OV!aO_!aO%q!aO%r!aO%s!aO~P!)nOVWi_Wi%qWi%rWi%sWi~P!)nO!T%dO!U%cOg&VXz&VX~O%z'kO%{'kO~P,eOz'mOg&UX~Og'oO~Oz'pO{'rO!W&XX~Oo0cOv0qOz'pO{'sO!W&XX~P'vO!W'uO~Om!oOn!oOo!rOp!sOkjisjizji{ji!xji#gji%[ji%_ji%zji~Ol!qO~P!.aOlji~P!.aOk0eOl0fOm0dOn0dOo0mOp0nO~Ot'wO~P!/jOV'|Og'}Oo0cOv0qO~P'vOg'}Oz(OO~Og(QO~O!U(SO~Og(TOz(OO!T%dO!U%cO~P%SOk0eOl0fOm0dOn0dOo0mOp0nOgqa!Tqa!Uqa%{qa!Wqa![qa!Qqa#[qatqa!mqa~PEcOV'|Oo0cOv0qO!W&Sa~P'vOz(WO!W&Sa~O!W(XO~Oz(WO!T%dO!U%cO!W&Sa~P%SOV(]Oo0cOv0qO![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~P'vOz(^O![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~O![(aO~Oz(^O!T%dO!U%cO![%}a~P%SOz(dO!T%dO!U%cO![&Ta~P%SOz(gO{&lX![&lX!m&lX%z&lX~O{(kO![(mO!m(nO%z(jO~OV&OOopOvqO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~P'vOz(pO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~O!f&UOh&sa%[&saz&sa#[&sa#g&sa%_&sa#Z&sag&sa~O%[(uO~OV#sOa#tO%uWO~Oz&]O{wa~OopOvqO~P'vOz(^O#g%}a%[%}a%_%}ag%}a{%}a![%}a!m%}a%z%}a~P%SOz(zO#g%hX%[%hX%_%hX%z%hX~O%z#|O#gUi%[Ui%_Ui~O#g&Pa%[&Pa%_&Pan&Pa~P'vOz(}O#g&Pa%[&Pa%_&Pan&Pa~O%uWO#g&ra%[&ra%_&rag&ra~Oz)SO#g&ra%[&ra%_&rag&ra~Og)VO~OV)WOh$WO%uWO~O#Z)XO~O%uWO#g&ta%[&ta%_&ta~Oz)ZO#g&ta%[&ta%_&ta~Oo0cOv0qO#g&pa%[&pa%_&pa{&pa~P'vOz)^O#g&pa%[&pa%_&pa{&pa~OV)`Oa)`O%uWO~O%z)eO~Ot)hO#j)gOP#hiV#hif#hih#hio#his#hiv#hi!P#hi!Q#hi!T#hi!U#hi!X#hi!]#hi!h#hi!r#hi!s#hi!t#hi!{#hi!}#hi#P#hi#R#hi#T#hi#X#hi#Z#hi#^#hi#_#hi#a#hi#c#hi#l#hi#o#hi#s#hi#u#hi#z#hi#}#hi$P#hi%X#hi%o#hi%p#hi%t#hi%u#hi&Z#hi&[#hi&]#hi&^#hi&_#hi&`#hi&a#hi&b#hi&c#hi&d#hi&e#hi&f#hi&g#hi&h#hi&i#hi&j#hi%Z#hi%_#hi~Ot)iOP#kiV#kif#kih#kio#kis#kiv#ki!P#ki!Q#ki!T#ki!U#ki!X#ki!]#ki!h#ki!r#ki!s#ki!t#ki!{#ki!}#ki#P#ki#R#ki#T#ki#X#ki#Z#ki#^#ki#_#ki#a#ki#c#ki#l#ki#o#ki#s#ki#u#ki#z#ki#}#ki$P#ki%X#ki%o#ki%p#ki%t#ki%u#ki&Z#ki&[#ki&]#ki&^#ki&_#ki&`#ki&a#ki&b#ki&c#ki&d#ki&e#ki&f#ki&g#ki&h#ki&i#ki&j#ki%Z#ki%_#ki~OV)kOn&wa~P'vOz)lOn&wa~Oz)lOn&wa~P%SOn)pO~O%Y)tO~Ot)wO#p'WO#q)vOP#niV#nif#nih#nio#nis#niv#ni!P#ni!Q#ni!T#ni!U#ni!X#ni!]#ni!h#ni!r#ni!s#ni!t#ni!{#ni!}#ni#P#ni#R#ni#T#ni#X#ni#Z#ni#^#ni#_#ni#a#ni#c#ni#l#ni#o#ni#s#ni#u#ni#z#ni#}#ni$P#ni%X#ni%o#ni%p#ni%t#ni%u#ni&Z#ni&[#ni&]#ni&^#ni&_#ni&`#ni&a#ni&b#ni&c#ni&d#ni&e#ni&f#ni&g#ni&h#ni&i#ni&j#ni%Z#ni%_#ni~OV)zOo0cOv0qO{$jO~P'vOo0cOv0qO{&xa~P'vOz*OO{&xa~OV*SOa*TOg*WO%q*UO%uWO~O{$jO&{*YO~Oh'_O~Oh!iO{$jO~O%[*_O~O%[*aO%_*aO~OV$}Oa$}Oo0cOv0qOg&Ua~P'vOz*dOg&Ua~Oo0cOv0qO{*gO!W&Xa~P'vOz*hO!W&Xa~Oo0cOv0qOz*hO{*kO!W&Xa~P'vOo0cOv0qOz*hO!W&Xa~P'vOz*hO{*kO!W&Xa~Om0dOn0dOo0mOp0nOgjikjisjizji!Tji!Uji%{ji!Wji{ji![ji#gji%[ji%_ji!Qji#[jitji!mji%zji~Ol0fO~P!NkOlji~P!NkOV'|Og*pOo0cOv0qO~P'vOn*rO~Og*pOz*tO~Og*uO~OV'|Oo0cOv0qO!W&Si~P'vOz*vO!W&Si~O!W*wO~OV(]Oo0cOv0qO![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~P'vOz*zO!T%dO!U%cO![&Ti~Oz*}O![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~O![+OO~Oa+QOo0cOv0qO![&Ti~P'vOz*zO![&Ti~O![+SO~OV+UOo0cOv0qO{&la![&la!m&la%z&la~P'vOz+VO{&la![&la!m&la%z&la~O!]+YO&n+[O![!nX~O![+^O~O{(kO![+_O~O{(kO![+_O!m+`O~OV&OOopOvqO{%hq!x%hq#g%hq%[%hq%_%hq%z%hq~P'vOz$ri{$ri!x$ri#g$ri%[$ri%_$ri%z$ri~P%SOV&OOopOvqO~P'vOV&OOo0cOv0qO#g%ha%[%ha%_%ha%z%ha~P'vOz+aO#g%ha%[%ha%_%ha%z%ha~Oz$ia#g$ia%[$ia%_$ian$ia~P%SO#g&Pi%[&Pi%_&Pin&Pi~P'vOz+dO#g#Wq%[#Wq%_#Wq~O#[+eOz$va#g$va%[$va%_$vag$va~O%uWO#g&ri%[&ri%_&rig&ri~Oz+gO#g&ri%[&ri%_&rig&ri~OV+iOh$WO%uWO~O%uWO#g&ti%[&ti%_&ti~Oo0cOv0qO#g&pi%[&pi%_&pi{&pi~P'vO{#{Oz#eX!W#eX~Oz+mO!W&uX~O!W+oO~Ot+rO#j)gOP#hqV#hqf#hqh#hqo#hqs#hqv#hq!P#hq!Q#hq!T#hq!U#hq!X#hq!]#hq!h#hq!r#hq!s#hq!t#hq!{#hq!}#hq#P#hq#R#hq#T#hq#X#hq#Z#hq#^#hq#_#hq#a#hq#c#hq#l#hq#o#hq#s#hq#u#hq#z#hq#}#hq$P#hq%X#hq%o#hq%p#hq%t#hq%u#hq&Z#hq&[#hq&]#hq&^#hq&_#hq&`#hq&a#hq&b#hq&c#hq&d#hq&e#hq&f#hq&g#hq&h#hq&i#hq&j#hq%Z#hq%_#hq~On$|az$|a~P%SOV)kOn&wi~P'vOz+yOn&wi~Oz,TO{$jO#[,TO~O#q,VOP#nqV#nqf#nqh#nqo#nqs#nqv#nq!P#nq!Q#nq!T#nq!U#nq!X#nq!]#nq!h#nq!r#nq!s#nq!t#nq!{#nq!}#nq#P#nq#R#nq#T#nq#X#nq#Z#nq#^#nq#_#nq#a#nq#c#nq#l#nq#o#nq#s#nq#u#nq#z#nq#}#nq$P#nq%X#nq%o#nq%p#nq%t#nq%u#nq&Z#nq&[#nq&]#nq&^#nq&_#nq&`#nq&a#nq&b#nq&c#nq&d#nq&e#nq&f#nq&g#nq&h#nq&i#nq&j#nq%Z#nq%_#nq~O#[,WOz%Oa{%Oa~Oo0cOv0qO{&xi~P'vOz,YO{&xi~O{#{O%z,[Og&zXz&zX~O%uWOg&zXz&zX~Oz,`Og&yX~Og,bO~O%Y,eO~O!T%dO!U%cOg&Viz&Vi~OV$}Oa$}Oo0cOv0qOg&Ui~P'vO{,hOz$la!W$la~Oo0cOv0qO{,iOz$la!W$la~P'vOo0cOv0qO{*gO!W&Xi~P'vOz,lO!W&Xi~Oo0cOv0qOz,lO!W&Xi~P'vOz,lO{,oO!W&Xi~Og$hiz$hi!W$hi~P%SOV'|Oo0cOv0qO~P'vOn,qO~OV'|Og,rOo0cOv0qO~P'vOV'|Oo0cOv0qO!W&Sq~P'vOz$gi![$gi#g$gi%[$gi%_$gig$gi{$gi!m$gi%z$gi~P%SOV(]Oo0cOv0qO~P'vOa+QOo0cOv0qO![&Tq~P'vOz,sO![&Tq~O![,tO~OV(]Oo0cOv0qO![%}q#g%}q%[%}q%_%}qg%}q{%}q!m%}q%z%}q~P'vO{,uO~OV+UOo0cOv0qO{&li![&li!m&li%z&li~P'vOz,zO{&li![&li!m&li%z&li~O!]+YO&n+[O![!na~O{(kO![,}O~OV&OOo0cOv0qO#g%hi%[%hi%_%hi%z%hi~P'vOz-OO#g%hi%[%hi%_%hi%z%hi~O%uWO#g&rq%[&rq%_&rqg&rq~Oz-RO#g&rq%[&rq%_&rqg&rq~OV)`Oa)`O%uWO!W&ua~Oz-TO!W&ua~On$|iz$|i~P%SOV)kO~P'vOV)kOn&wq~P'vOt-XOP#myV#myf#myh#myo#mys#myv#my!P#my!Q#my!T#my!U#my!X#my!]#my!h#my!r#my!s#my!t#my!{#my!}#my#P#my#R#my#T#my#X#my#Z#my#^#my#_#my#a#my#c#my#l#my#o#my#s#my#u#my#z#my#}#my$P#my%X#my%o#my%p#my%t#my%u#my&Z#my&[#my&]#my&^#my&_#my&`#my&a#my&b#my&c#my&d#my&e#my&f#my&g#my&h#my&i#my&j#my%Z#my%_#my~O%Z-]O%_-]O~P`O#q-^OP#nyV#nyf#nyh#nyo#nys#nyv#ny!P#ny!Q#ny!T#ny!U#ny!X#ny!]#ny!h#ny!r#ny!s#ny!t#ny!{#ny!}#ny#P#ny#R#ny#T#ny#X#ny#Z#ny#^#ny#_#ny#a#ny#c#ny#l#ny#o#ny#s#ny#u#ny#z#ny#}#ny$P#ny%X#ny%o#ny%p#ny%t#ny%u#ny&Z#ny&[#ny&]#ny&^#ny&_#ny&`#ny&a#ny&b#ny&c#ny&d#ny&e#ny&f#ny&g#ny&h#ny&i#ny&j#ny%Z#ny%_#ny~Oz-aO{$jO#[-aO~Oo0cOv0qO{&xq~P'vOz-dO{&xq~O%z,[Og&zaz&za~OV*SOa*TO%q*UO%uWOg&ya~Oz-hOg&ya~O$S-lO~OV$}Oa$}Oo0cOv0qO~P'vOo0cOv0qO{-mOz$li!W$li~P'vOo0cOv0qOz$li!W$li~P'vO{-mOz$li!W$li~Oo0cOv0qO{*gO~P'vOo0cOv0qO{*gO!W&Xq~P'vOz-pO!W&Xq~Oo0cOv0qOz-pO!W&Xq~P'vOs-sO!T%dO!U%cOg&Oq!W&Oq![&Oqz&Oq~P!/jOa+QOo0cOv0qO![&Ty~P'vOz$ji![$ji~P%SOa+QOo0cOv0qO~P'vOV+UOo0cOv0qO~P'vOV+UOo0cOv0qO{&lq![&lq!m&lq%z&lq~P'vO{(kO![-xO!m-yO%z-wO~OV&OOo0cOv0qO#g%hq%[%hq%_%hq%z%hq~P'vO%uWO#g&ry%[&ry%_&ryg&ry~OV)`Oa)`O%uWO!W&ui~Ot-}OP#m!RV#m!Rf#m!Rh#m!Ro#m!Rs#m!Rv#m!R!P#m!R!Q#m!R!T#m!R!U#m!R!X#m!R!]#m!R!h#m!R!r#m!R!s#m!R!t#m!R!{#m!R!}#m!R#P#m!R#R#m!R#T#m!R#X#m!R#Z#m!R#^#m!R#_#m!R#a#m!R#c#m!R#l#m!R#o#m!R#s#m!R#u#m!R#z#m!R#}#m!R$P#m!R%X#m!R%o#m!R%p#m!R%t#m!R%u#m!R&Z#m!R&[#m!R&]#m!R&^#m!R&_#m!R&`#m!R&a#m!R&b#m!R&c#m!R&d#m!R&e#m!R&f#m!R&g#m!R&h#m!R&i#m!R&j#m!R%Z#m!R%_#m!R~Oo0cOv0qO{&xy~P'vOV*SOa*TO%q*UO%uWOg&yi~O$S-lO%Z.VO%_.VO~OV.aOh._O!X.^O!].`O!h.YO!s.[O!t.[O%p.XO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O~Oo0cOv0qOz$lq!W$lq~P'vO{.fOz$lq!W$lq~Oo0cOv0qO{*gO!W&Xy~P'vOz.gO!W&Xy~Oo0cOv.kO~P'vOs-sO!T%dO!U%cOg&Oy!W&Oy![&Oyz&Oy~P!/jO{(kO![.nO~O{(kO![.nO!m.oO~OV*SOa*TO%q*UO%uWO~Oh.tO!f.rOz$TX#[$TX%j$TXg$TX~Os$TX{$TX!W$TX![$TX~P$-VO%o.vO%p.vOs$UXz$UX{$UX#[$UX%j$UX!W$UXg$UX![$UX~O!h.xO~Oz.|O#[/OO%j.yOs&|X{&|X!W&|Xg&|X~Oa/RO~P$)oOh.tOs&}Xz&}X{&}X#[&}X%j&}X!W&}Xg&}X![&}X~Os/VO{$jO~Oo0cOv0qOz$ly!W$ly~P'vOo0cOv0qO{*gO!W&X!R~P'vOz/ZO!W&X!R~Og&RXs&RX!T&RX!U&RX!W&RX![&RXz&RX~P!/jOs-sO!T%dO!U%cOg&Qa!W&Qa![&Qaz&Qa~O{(kO![/^O~O!f.rOh$[as$[az$[a{$[a#[$[a%j$[a!W$[ag$[a![$[a~O!h/eO~O%o.vO%p.vOs$Uaz$Ua{$Ua#[$Ua%j$Ua!W$Uag$Ua![$Ua~O%j.yOs$Yaz$Ya{$Ya#[$Ya!W$Yag$Ya![$Ya~Os&|a{&|a!W&|ag&|a~P$)cOz/jOs&|a{&|a!W&|ag&|a~O!W/mO~Og/mO~O{/oO~O![/pO~Oo0cOv0qO{*gO!W&X!Z~P'vO{/sO~O%z/tO~P$-VOz/uO#[/OO%j.yOg'PX~Oz/uOg'PX~Og/wO~O!h/xO~O#[/OOs%Saz%Sa{%Sa%j%Sa!W%Sag%Sa![%Sa~O#[/OO%j.yOs%Waz%Wa{%Wa!W%Wag%Wa~Os&|i{&|i!W&|ig&|i~P$)cOz/zO#[/OO%j.yO!['Oa~O{$da~P%SOg'Pa~P$)cOz0SOg'Pa~Oa0UO!['Oi~P$)oOz0WO!['Oi~Oz0WO#[/OO%j.yO!['Oi~O#[/OO%j.yOg$biz$bi~O%z0ZO~P$-VO#[/OO%j.yOg%Vaz%Va~Og'Pi~P$)cO{0^O~Oa0UO!['Oq~P$)oOz0`O!['Oq~O#[/OO%j.yOz%Ui![%Ui~Oa0UO~P$)oOa0UO!['Oy~P$)oO#[/OO%j.yOg$ciz$ci~O#[/OO%j.yOz%Uq![%Uq~Oz+aO#g%ha%[%ha%_%ha%z%ha~P%SOV&OOo0cOv0qO~P'vOn0hO~Oo0hO~P'vO{0iO~Ot0jO~P!/jO&]&Z&j&h&i&g&f&d&e&c&b&`&a&_&^&[%u~",goto:"!=l'QPPPPPP'RP'Z*s+]+v,b,}-kP.YP'Z.y.y'ZPPP'Z2cPPPPPP2c5VPP5VP7g7p=xPP={>m>pPP'Z'ZPP?PPP'Z'ZPP'Z'Z'Z'Z'Z?T?}'ZP@QP@WD_G{HPPHSH^Hb'ZPPPHeHn'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RP'RPHtIQIYPIaIgPIaPIaIaPPPIaPKuPLOLYL`KuPIaLiPIaPLpLvPLzM`M}NhLzLzNnN{LzLzLzLz! a! g! j! o! r! |!!S!!`!!r!!x!#S!#Y!#v!#|!$S!$^!$d!$j!$|!%W!%^!%d!%n!%t!%z!&Q!&W!&^!&h!&n!&x!'O!'X!'_!'n!'v!(Q!(XPPPPPPPPPPP!(_!(b!(h!(q!({!)WPPPPPPPPPPPP!-z!/`!3`!6pPP!6x!7X!7b!8Z!8Q!8d!8j!8m!8p!8s!8{!9lPPPPPPPPPPPPPPPPP!9o!9s!9yP!:_!:c!:o!:x!;U!;l!;o!;r!;x!<O!<U!<XP!<a!<j!=f!=i]eOn#g$j)t,P'}`OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0r}!cQ#c#p$R$d$p%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!P!dQ#c#p$R$d$p$u%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!R!eQ#c#p$R$d$p$u$v%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!T!fQ#c#p$R$d$p$u$v$w%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!V!gQ#c#p$R$d$p$u$v$w$x%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!X!hQ#c#p$R$d$p$u$v$w$x$y%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g!]!hQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0g'}TOTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0r&cVOYZ[dnprxy}!P!Q!U!i!k!o!p!q!s!t#[#d#g#y#{#}$Q$h$j$}%S%Z%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/Z/s0c0d0e0f0h0i0j0k0n0r%mXOYZ[dnrxy}!P!Q!U!i!k#[#d#g#y#{#}$Q$h$j$}%S%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,s,u,w,y,z-O-d-f-m-p.f.g/Z0i0j0kQ#vqQ/[.kR0o0q't`OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rh#jhz{$W$Z&l&q)S)X+f+g-RW#rq&].k0qQ$]|Q$a!OQ$n!VQ$o!WW$|!i'm*d,gS&[#s#tQ'S$iQ(s&UQ)U&nU)Y&s)Z+jW)a&w+m-T-{Q*Q']W*R'_,`-h.TQ+l)`S,_*S*TQ-Q+eQ-_,TQ-c,WQ.R-al.W-l.^._.a.z.|/R/j/o/t/y0U0Z0^Q/S.`Q/a.tQ/l/OU0P/u0S0[X0V/z0W0_0`R&Z#r!_!wYZ!P!Q!k%S%`%g'p'r's(O(W)g*g*h*k*q*t*v,h,i,k,l,o-m-p.f.g/ZR%^!vQ!{YQ%x#[Q&d#}Q&g$QR,{+YT.j-s/s^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rS#a_#b!P.[-l.^._.`.a.t.z.|/R/j/o/t/u/y/z0S0U0W0Z0[0^0_0`'|_OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rT#a_#bT#^^#_R(o%xa(l%x(n(o+`,{-y-z.oT+[(k+]R-z,{Q$PsQ+l)aR,^*RX#}s$O$P&fQ&y$aQ'a$nQ'd$oR)s'SQ)b&wV-S+m-T-{ZgOn$j)t,PXkOn)t,PQ$k!TQ&z$bQ&{$cQ'^$mQ'b$oQ)q'RQ)x'WQ){'XQ)|'YQ*Z'`S*]'c'dQ+s)gQ+u)hQ+v)iQ+z)oS+|)r*[Q,Q)vQ,R)wS,S)y)zQ,d*^Q-V+rQ-W+tQ-Y+{S-Z+},OQ-`,UQ-b,VQ-|-XQ.O-[Q.P-^Q.Q-_Q.p-}Q.q.RQ/W.dR/r/XWkOn)t,PR#mjQ'`$nS)r'S'aR,O)sQ,]*RR-f,^Q*['`Q+})rR-[,OZiOjn)t,PQ'f$pR*`'gT-j,e-ku.c-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^t.c-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^Q/S.`X0V/z0W0_0`!P.Z-l.^._.`.a.t.z.|/R/j/o/t/u/y/z0S0U0W0Z0[0^0_0`Q.w.YR/f.xg.z.].{/b/i/n/|0O0Q0]0a0bu.b-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^X.u.W.b/a0PR/c.tV0R/u0S0[R/X.dQnOS#on,PR,P)tQ&^#uR(x&^S%m#R#wS(_%m(bT(b%p&`Q%a!yQ%h!}W(P%a%h(U(YQ(U%eR(Y%jQ&i$RR)O&iQ(e%qQ*{(`T+R(e*{Q'n%OR*e'nS'q%R%SY*i'q*j,m-q.hU*j'r's'tU,m*k*l*mS-q,n,oR.h-rQ#Y]R%t#YQ#_^R%y#_Q(h%vS+W(h+XR+X(iQ+](kR,|+]Q#b_R%{#bQ#ebQ%}#cW&Q#e%}({+bQ({&cR+b0gQ$OsS&e$O&fR&f$PQ&v$_R)_&vQ&V#jR(t&VQ&m$VS)T&m+hR+h)UQ$Z{R&p$ZQ&t$]R)[&tQ+n)bR-U+nQ#hfR&S#hQ)f&zR+q)fQ&}$dS)m&})nR)n'OQ'V$kR)u'VQ'[$lS*P'[,ZR,Z*QQ,a*VR-i,aWjOn)t,PR#ljQ-k,eR.U-kd.{.]/b/i/n/|0O0Q0]0a0bR/h.{U.s.W/a0PR/`.sQ/{/nS0X/{0YR0Y/|S/v/b/cR0T/vQ.}.]R/k.}R!ZPXmOn)t,PWlOn)t,PR'T$jYfOn$j)t,PR&R#g[sOn#g$j)t,PR&d#}&bQOYZ[dnprxy}!P!Q!U!i!k!o!p!q!s!t#[#d#g#y#{#}$Q$h$j$}%S%Z%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/Z/s0c0d0e0f0h0i0j0k0n0rQ!nTQ#caQ#poU$Rt%c(SS$d!R$gQ$p!XQ$u!cQ$v!dQ$w!eQ$x!fQ$y!gQ$z!hQ%e!zQ%j#OQ%p#SQ%q#TQ&`#xQ'O$eQ'g$qQ(q&OU(|&h(}+cW)j&|)l+x+yQ*o'|Q*x(]Q+w)kQ,v+QQ/q/VR0g0lQ!yYQ!}ZQ$b!PQ$c!QQ%R!kQ't%S^'{%`%g(O(W*q*t*v^*f'p*h,k,l-p.g/ZQ*l'rQ*m'sQ+t)gQ,j*gQ,n*kQ-n,hQ-o,iQ-r,oQ.e-mR/Y.f[bOn#g$j)t,P!^!vYZ!P!Q!k%S%`%g'p'r's(O(W)g*g*h*k*q*t*v,h,i,k,l,o-m-p.f.g/ZQ#R[Q#fdS#wrxQ$UyW$_}$Q'P)pS$l!U$hW${!i'm*d,gS%v#[+Y`&P#d%|(p(r(z+a-O0kQ&a#yQ&b#{Q&c#}Q'j$}Q'z%^W([%l(^*y*}Q(`%nQ(i%wQ(v&ZS(y&_0iQ)P&jQ)Q&kU)]&u)^+kQ)d&xQ)y'WY)}'Z*O,X,Y-dQ*b'lS*n'w0jW+P(d*z,s,wW+T(g+V,y,zQ+p)eQ,U)zQ,c*YQ,x+UQ-P+dQ-e,]Q-v,uR.S-fhUOn#d#g$j%|&_'w(p(r)t,P%S!uYZ[drxy}!P!Q!U!i!k#[#y#{#}$Q$h$}%S%^%`%g%l%n%w&Z&j&k&u&x'P'W'Z'l'm'p'r's(O(W(^(d(g(z)^)e)g)p)z*O*Y*d*g*h*k*q*t*v*y*z*}+U+V+Y+a+d+k,X,Y,],g,h,i,k,l,o,s,u,w,y,z-O-d-f-m-p.f.g/Z0i0j0kQ#qpW%W!o!s0d0nQ%X!pQ%Y!qQ%[!tQ%f0cS'v%Z0hQ'x0eQ'y0fQ,p*rQ-u,qS.i-s/sR0p0rU#uq.k0qR(w&][cOn#g$j)t,PZ!xY#[#}$Q+YQ#W[Q#zrR$TxQ%b!yQ%i!}Q%o#RQ'j${Q(V%eQ(Z%jQ(c%pQ(f%qQ*|(`Q,f*bQ-t,pQ.m-uR/].lQ$StQ(R%cR*s(SQ.l-sR/}/sR#QZR#V[R%Q!iQ%O!iV*c'm*d,g!]!lQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v/q0gR%T!kT#]^#_Q%x#[R,{+YQ(m%xS+_(n(oQ,}+`Q-x,{S.n-y-zR/^.oT+Z(k+]Q$`}Q&g$QQ)o'PR+{)pQ$XzQ)W&qR+i)XQ$XzQ&o$WQ)W&qR+i)XQ#khW$Vz$W&q)XQ$[{Q&r$ZZ)R&l)S+f+g-RR$^|R)c&wXlOn)t,PQ$f!RR'Q$gQ$m!UR'R$hR*X'_Q*V'_V-g,`-h.TQ.d-lQ/P.^R/Q._U.]-l.^._Q/U.aQ/b.tQ/g.zU/i.|/j/yQ/n/RQ/|/oQ0O/tU0Q/u0S0[Q0]0UQ0a0ZR0b0^R/T.`R/d.t",nodeNames:"⚠ print Escape { Comment Script AssignStatement * BinaryExpression BitOp BitOp BitOp BitOp ArithOp ArithOp @ ArithOp ** UnaryExpression ArithOp BitOp AwaitExpression await ) ( ParenthesizedExpression BinaryExpression or and CompareOp in not is UnaryExpression ConditionalExpression if else LambdaExpression lambda ParamList VariableName AssignOp , : NamedExpression AssignOp YieldExpression yield from TupleExpression ComprehensionExpression async for LambdaExpression ] [ ArrayExpression ArrayComprehensionExpression } { DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression CallExpression ArgList AssignOp MemberExpression . PropertyName Number String FormatString FormatReplacement FormatSelfDoc FormatConversion FormatSpec FormatReplacement FormatSelfDoc ContinuedString Ellipsis None Boolean TypeDef AssignOp UpdateStatement UpdateOp ExpressionStatement DeleteStatement del PassStatement pass BreakStatement break ContinueStatement continue ReturnStatement return YieldStatement PrintStatement RaiseStatement raise ImportStatement import as ScopeStatement global nonlocal AssertStatement assert TypeDefinition type TypeParamList TypeParam StatementGroup ; IfStatement Body elif WhileStatement while ForStatement TryStatement try except finally WithStatement with FunctionDefinition def ParamList AssignOp TypeDef ClassDefinition class DecoratedStatement Decorator At MatchStatement match MatchBody MatchClause case CapturePattern LiteralPattern ArithOp ArithOp AsPattern OrPattern LogicOp AttributePattern SequencePattern MappingPattern StarPattern ClassPattern PatternArgList KeywordPattern KeywordPattern Guard",maxTerm:277,context:Qp,nodeProps:[["isolate",-5,4,71,72,73,77,""],["group",-15,6,85,87,88,90,92,94,96,98,99,100,102,105,108,110,"Statement Statement",-22,8,18,21,25,40,49,50,56,57,60,61,62,63,64,67,70,71,72,79,80,81,82,"Expression",-10,114,116,119,121,122,126,128,133,135,138,"Statement",-9,143,144,147,148,150,151,152,153,154,"Pattern"],["openedBy",23,"(",54,"[",58,"{"],["closedBy",24,")",55,"]",59,"}"]],propSources:[$p],skippedNodes:[0,4],repeatNodeCount:34,tokenData:"!2|~R!`OX%TXY%oY[%T[]%o]p%Tpq%oqr'ars)Yst*xtu%Tuv,dvw-hwx.Uxy/tyz0[z{0r{|2S|}2p}!O3W!O!P4_!P!Q:Z!Q!R;k!R![>_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY%oY[%T[]%o]p%Tpq%oq#O%T#O#P&o#P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To&tX&n`OY%TYZ%oZ]%T]^%o^#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc'f[&n`O!_%T!_!`([!`#T%T#T#U(r#U#f%T#f#g(r#g#h(r#h#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(cTmR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(yT!mR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk)aV&n`&[ZOr%Trs)vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk){V&n`Or%Trs*bs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk*iT&n`&^ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To+PZS_&n`OY*xYZ%TZ]*x]^%T^#o*x#o#p+r#p#q*x#q#r+r#r;'S*x;'S;=`,^<%lO*x_+wTS_OY+rZ]+r^;'S+r;'S;=`,W<%lO+r_,ZP;=`<%l+ro,aP;=`<%l*xj,kV%rQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-XT!xY&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-oV%lQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.]V&n`&ZZOw%Twx.rx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.wV&n`Ow%Twx/^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/eT&n`&]ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/{ThZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc0cTgR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk0yXVZ&n`Oz%Tz{1f{!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk1mVaR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk2ZV%oZ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc2wTzR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To3_W%pZ&n`O!_%T!_!`-Q!`!a3w!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Td4OT&{S&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk4fX!fQ&n`O!O%T!O!P5R!P!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5WV&n`O!O%T!O!P5m!P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5tT!rZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti6[a!hX&n`O!Q%T!Q![6T![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S6T#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti7fZ&n`O{%T{|8X|}%T}!O8X!O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8^V&n`O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8z]!hX&n`O!Q%T!Q![8s![!l%T!l!m9s!m#R%T#R#S8s#S#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti9zT!hX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk:bX%qR&n`O!P%T!P!Q:}!Q!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj;UV%sQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti;ro!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!d%T!d!e?q!e!g%T!g!h7a!h!l%T!l!m9s!m!q%T!q!rA]!r!z%T!z!{Bq!{#R%T#R#S>_#S#U%T#U#V?q#V#X%T#X#Y7a#Y#^%T#^#_9s#_#c%T#c#dA]#d#l%T#l#mBq#m#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti=xV&n`O!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti>fc!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S>_#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti?vY&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti@mY!hX&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiAbX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBUX!hX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBv]&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiCv]!hX&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToDvV{_&n`O!_%T!_!`E]!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TcEdT%{R&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkEzT#gZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkFbXmR&n`O!^%T!^!_F}!_!`([!`!a([!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjGUV%mQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkGrV%zZ&n`O!_%T!_!`([!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkH`WmR&n`O!_%T!_!`([!`!aHx!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjIPV%nQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkIoV_Q#}P&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToJ_]&n`&YS%uZO!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoKZP;=`<%lJUoKge&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!tJU!t!uLx!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#gLx#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoMRa&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUkN_V&n`&`ZOr%TrsNts#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkNyV&n`Or%Trs! `s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! gT&n`&bZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! }V&n`&_ZOw%Twx!!dx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!!iV&n`Ow%Twx!#Ox#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!#VT&n`&aZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!#oe&n`&YS%uZOr%Trs!%Qsw%Twx!&px!Q%T!Q![JU![!c%T!c!tJU!t!u!(`!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#g!(`#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!%XV&n`&dZOr%Trs!%ns#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!%sV&n`Or%Trs!&Ys#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&aT&n`&fZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&wV&n`&cZOw%Twx!'^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!'cV&n`Ow%Twx!'xx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!(PT&n`&eZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!(ia&n`&YS%uZOr%Trs!)nsw%Twx!+^x!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!)uV&n`&hZOr%Trs!*[s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*aV&n`Or%Trs!*vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*}T&n`&jZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!+eV&n`&gZOw%Twx!+zx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,PV&n`Ow%Twx!,fx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,mT&n`&iZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!-Vi&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!dJU!d!eLx!e!hJU!h!i!(`!i!}JU!}#R%T#R#SJU#S#T%T#T#UJU#U#VLx#V#YJU#Y#Z!(`#Z#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUo!.}a&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!0ZT!XZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc!0qT!WR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj!1XV%kQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[Wp,Tp,Ep,Hp,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:e=>zp[e]||-1}],tokenPrec:7664}),Up=new Sa,Vp=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function jp(e){return(t,i,s)=>{if(s)return!1;let r=t.node.getChild("VariableName");return r&&i(r,e),!0}}const Xp={FunctionDefinition:jp("function"),ClassDefinition:jp("class"),ForStatement(e,t,i){if(i)for(let i=e.node.firstChild;i;i=i.nextSibling)if("VariableName"==i.name)t(i,"variable");else if("in"==i.name)break},ImportStatement(e,t){var i,s;let{node:r}=e,n="from"==(null===(i=r.firstChild)||void 0===i?void 0:i.name);for(let e=r.getChild("import");e;e=e.nextSibling)"VariableName"==e.name&&"as"!=(null===(s=e.nextSibling)||void 0===s?void 0:s.name)&&t(e,n?"variable":"namespace")},AssignStatement(e,t){for(let i=e.node.firstChild;i;i=i.nextSibling)if("VariableName"==i.name)t(i,"variable");else if(":"==i.name||"AssignOp"==i.name)break},ParamList(e,t){for(let i=null,s=e.node.firstChild;s;s=s.nextSibling)"VariableName"!=s.name||i&&/\*|AssignOp/.test(i.name)||t(s,"variable"),i=s},CapturePattern:jp("variable"),AsPattern:jp("variable"),__proto__:null};function Gp(e,t){let i=Up.get(t);if(i)return i;let s=[],r=!0;function n(t,i){let r=e.sliceString(t.from,t.to);s.push({label:r,type:i})}return t.cursor(ta.IncludeAnonymous).iterate((t=>{if(t.name){let e=Xp[t.name];if(e&&e(t,n,r)||!r&&Vp.has(t.name))return!1;r=!1}else if(t.to-t.from>8192){for(let i of Gp(e,t.node))s.push(i);return!1}})),Up.set(t,s),s}const Kp=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Zp=["String","FormatString","Comment","PropertyName"];const Yp=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map((e=>({label:e,type:"constant"}))).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map((e=>({label:e,type:"type"})))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map((e=>({label:e,type:"class"})))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map((e=>({label:e,type:"function"})))),Jp=[hf("def ${name}(${params}):\n\t${}",{label:"def",detail:"function",type:"keyword"}),hf("for ${name} in ${collection}:\n\t${}",{label:"for",detail:"loop",type:"keyword"}),hf("while ${}:\n\t${}",{label:"while",detail:"loop",type:"keyword"}),hf("try:\n\t${}\nexcept ${error}:\n\t${}",{label:"try",detail:"/ except block",type:"keyword"}),hf("if ${}:\n\t\n",{label:"if",detail:"block",type:"keyword"}),hf("if ${}:\n\t${}\nelse:\n\t${}",{label:"if",detail:"/ else block",type:"keyword"}),hf("class ${name}:\n\tdef __init__(self, ${params}):\n\t\t\t${}",{label:"class",detail:"definition",type:"keyword"}),hf("import ${module}",{label:"import",detail:"statement",type:"keyword"}),hf("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],eg=ad(Zp,od(Yp.concat(Jp)));function tg(e){let{node:t,pos:i}=e,s=e.lineIndent(i,-1),r=null;for(;;){let n=t.childBefore(i);if(!n)break;if("Comment"==n.name)i=n.from;else if("Body"==n.name||"MatchBody"==n.name)e.baseIndentFor(n)+e.unit<=s&&(r=n),t=n;else if("MatchClause"==n.name)t=n;else{if(!n.type.is("Statement"))break;t=n}}return r}function ig(e,t){let i=e.baseIndentFor(t),s=e.lineAt(e.pos,-1),r=s.from+s.text.length;return/^\s*($|#)/.test(s.text)&&e.node.to<r+100&&!/\S/.test(e.state.sliceDoc(r,e.node.to))&&e.lineIndent(e.pos,-1)<=i||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(e.textAfter)&&e.lineIndent(e.pos,-1)>i?null:i+e.unit}const sg=th.define({name:"python",parser:Np.configure({props:[_h.add({Body:e=>{var t;return null!==(t=ig(e,tg(e)||e.node))&&void 0!==t?t:e.continue()},MatchBody:e=>{var t;return null!==(t=ig(e,tg(e)||e.node))&&void 0!==t?t:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),"ForStatement WhileStatement":e=>/^\s*else:/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except |finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),MatchStatement:e=>/^\s*case /.test(e.textAfter)?e.baseIndent+e.unit:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Dh({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Dh({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Dh({closing:"]"}),"String FormatString":()=>null,Script:e=>{var t;let i=tg(e);return null!==(t=i&&ig(e,i))&&void 0!==t?t:e.continue()}}),xh.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":function(e){let t=e.firstChild,i=e.lastChild;return t&&t.to<i.from?{from:t.to,to:i.type.isError?e.to:i.from}:null},Body:(e,t)=>({from:e.from+1,to:e.to-(e.to==t.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});var rg=l(856),ng=l(616),og=l(530);let ag;l.e(384).then(l.bind(l,384)).then((e=>{ag=e,window.rp=e,function(){fg.addEventListener("change",gg),document.getElementById("run-btn").addEventListener("click",dg),dg(),Og=ag.vmStore.init("term_vm"),Og.setStdout((e=>vg.print(e))),async function(){let e="";for(;;){let i=await vg.read((t=e?"ps2":"ps1",Og.exec(`\ntry:\n import sys as __sys\n __prompt = __sys.${t}\nexcept:\n __prompt = ''\nfinally:\n del __sys\n`),String(Og.eval("__prompt"))));if(i.endsWith("\n")&&(i=i.slice(0,-1)),!e||(i=e+="\n"+i,e.endsWith("\n"))){try{console.log([i]),Og.execSingle(i)}catch(t){if(t.canContinue){e=i;continue}t instanceof WebAssembly.RuntimeError&&(t=window.__RUSTPYTHON_ERROR||t),vg.print(""+t)}e=""}}var t}().catch((e=>console.error(e)));const e=document.createElement("div");e.id="rp_loaded",document.head.appendChild(e)}()})).catch((e=>{console.error("Error importing `rustpython`:",e);let t=e.toString();window.__RUSTPYTHON_ERROR&&(t+="\nRustPython Error: "+window.__RUSTPYTHON_ERROR),window.__RUSTPYTHON_ERROR_STACK&&(t+="\nStack: "+window.__RUSTPYTHON_ERROR_STACK),document.getElementById("error").textContent=t}));const hg=Zr.theme({"&":{height:"100%"},".cm-scroller":{overflow:"auto"}}),lg=new Zr({parent:document.getElementById("code-wrapper"),extensions:[Jf,new class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}(sg,[sg.data.of({autocomplete:function(e){let t=ih(e.state).resolveInner(e.pos,-1);if(Zp.indexOf(t.name)>-1)return null;let i="VariableName"==t.name||t.to-t.from<20&&Kp.test(e.state.sliceDoc(t.from,t.to));if(!i&&!e.explicit)return null;let s=[];for(let i=t;i;i=i.parent)Vp.has(i.name)&&(s=s.concat(Gp(e.state.doc,i)));return{options:s,from:i?t.from:e.pos,validFor:Kp}}}),sg.data.of({autocomplete:eg})]),on.of({key:"Ctrl-Enter",mac:"Cmd-Enter",run:dg},Yc),fh.of(" "),hg]});lg.focus();const cg=document.getElementById("console"),ug=document.getElementById("error");function dg(){cg.value="",ug.textContent="";const e=lg.state.doc.toString();try{ag.pyExec(e,{stdout:e=>{const t=cg.scrollHeight-cg.scrollTop===cg.clientHeight;cg.value+=e,t&&(cg.scrollTop=cg.scrollHeight)}})}catch(e){e instanceof WebAssembly.RuntimeError&&(e=window.__RUSTPYTHON_ERROR||e),ug.textContent=e,console.error(e)}}const fg=document.getElementById("snippets");function pg(){const e=fg.value,t=l(514)(`./${e}.py`);lg.dispatch({changes:{from:0,to:lg.state.doc.length,insert:t}})}function gg(){pg(),requestAnimationFrame(dg)}pg();const mg=new rg.Terminal,vg=new og.b,_g=new ng.FitAddon;let Og;mg.loadAddon(vg),mg.loadAddon(_g),mg.open(document.getElementById("terminal")),_g.fit()})()})();