diff --git a/.gitignore b/.gitignore index f27e7e8..b82b2ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules/ -lib/ +/lib/ *.log +*.map 03_local/ .DS_Store Thumbs.db diff --git a/01_content/lib/client.css b/01_content/lib/client.css new file mode 100644 index 0000000..9d35497 --- /dev/null +++ b/01_content/lib/client.css @@ -0,0 +1,194 @@ +/* node_modules/xterm/css/xterm.css */ +.xterm { + cursor: text; + position: relative; + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; +} +.xterm.focus, +.xterm:focus { + outline: none; +} +.xterm .xterm-helpers { + position: absolute; + top: 0; + z-index: 5; +} +.xterm .xterm-helper-textarea { + padding: 0; + border: 0; + margin: 0; + position: absolute; + opacity: 0; + left: -9999em; + top: 0; + width: 0; + height: 0; + z-index: -5; + white-space: nowrap; + overflow: hidden; + resize: none; +} +.xterm .composition-view { + background: #000; + color: #FFF; + display: none; + position: absolute; + white-space: nowrap; + z-index: 1; +} +.xterm .composition-view.active { + display: block; +} +.xterm .xterm-viewport { + background-color: #000; + overflow-y: scroll; + cursor: default; + position: absolute; + right: 0; + left: 0; + top: 0; + bottom: 0; +} +.xterm .xterm-screen { + position: relative; +} +.xterm .xterm-screen canvas { + position: absolute; + left: 0; + top: 0; +} +.xterm .xterm-scroll-area { + visibility: hidden; +} +.xterm-char-measure-element { + display: inline-block; + visibility: hidden; + position: absolute; + top: 0; + left: -9999em; + line-height: normal; +} +.xterm.enable-mouse-events { + cursor: default; +} +.xterm.xterm-cursor-pointer, +.xterm .xterm-cursor-pointer { + cursor: pointer; +} +.xterm.column-select.focus { + cursor: crosshair; +} +.xterm .xterm-accessibility, +.xterm .xterm-message { + position: absolute; + left: 0; + top: 0; + bottom: 0; + right: 0; + z-index: 10; + color: transparent; + pointer-events: none; +} +.xterm .live-region { + position: absolute; + left: -9999px; + width: 1px; + height: 1px; + overflow: hidden; +} +.xterm-dim { + opacity: 1 !important; +} +.xterm-underline-1 { + text-decoration: underline; +} +.xterm-underline-2 { + text-decoration: double underline; +} +.xterm-underline-3 { + text-decoration: wavy underline; +} +.xterm-underline-4 { + text-decoration: dotted underline; +} +.xterm-underline-5 { + text-decoration: dashed underline; +} +.xterm-overline { + text-decoration: overline; +} +.xterm-overline.xterm-underline-1 { + text-decoration: overline underline; +} +.xterm-overline.xterm-underline-2 { + text-decoration: overline double underline; +} +.xterm-overline.xterm-underline-3 { + text-decoration: overline wavy underline; +} +.xterm-overline.xterm-underline-4 { + text-decoration: overline dotted underline; +} +.xterm-overline.xterm-underline-5 { + text-decoration: overline dashed underline; +} +.xterm-strikethrough { + text-decoration: line-through; +} +.xterm-screen .xterm-decoration-container .xterm-decoration { + z-index: 6; + position: absolute; +} +.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { + z-index: 7; +} +.xterm-decoration-overview-ruler { + z-index: 8; + position: absolute; + top: 0; + right: 0; + pointer-events: none; +} +.xterm-decoration-top { + z-index: 2; + position: relative; +} +/*! Bundled license information: + +xterm/css/xterm.css: + (** + * Copyright (c) 2014 The xterm.js authors. All rights reserved. + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * https://github.com/chjj/term.js + * @license MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + * The original design remains. The terminal itself + * has been extended to include xterm CSI codes, among + * other features. + *) +*/ +/*# sourceMappingURL=client.css.map */ diff --git a/01_content/lib/client.js b/01_content/lib/client.js new file mode 100644 index 0000000..e619af1 --- /dev/null +++ b/01_content/lib/client.js @@ -0,0 +1,21127 @@ +window.__ModuleLoader__.load({ id: 'dsh-worktable', factory: (require) => { var module = { exports: {} }; var exports = module.exports; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// node_modules/xterm/lib/xterm.js +var require_xterm = __commonJS({ + "node_modules/xterm/lib/xterm.js"(exports, module2) { + !(function(e, t) { + if ("object" == typeof exports && "object" == typeof module2) module2.exports = t(); + else if ("function" == typeof define && define.amd) define([], t); + else { + var i = t(); + for (var s in i) ("object" == typeof exports ? exports : e)[s] = i[s]; + } + })(self, (() => (() => { + "use strict"; + var e = { 4567: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.AccessibilityManager = void 0; + const n = i2(9042), o = i2(6114), a = i2(9924), h = i2(844), c = i2(5596), l = i2(4725), d = i2(3656); + let _ = t2.AccessibilityManager = class extends h.Disposable { + constructor(e3, t3) { + super(), this._terminal = e3, this._renderService = t3, this._liveRegionLineCount = 0, this._charsToConsume = [], this._charsToAnnounce = "", this._accessibilityContainer = document.createElement("div"), this._accessibilityContainer.classList.add("xterm-accessibility"), this._rowContainer = document.createElement("div"), this._rowContainer.setAttribute("role", "list"), this._rowContainer.classList.add("xterm-accessibility-tree"), this._rowElements = []; + for (let e4 = 0; e4 < this._terminal.rows; e4++) this._rowElements[e4] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[e4]); + if (this._topBoundaryFocusListener = (e4) => this._handleBoundaryFocus(e4, 0), this._bottomBoundaryFocusListener = (e4) => this._handleBoundaryFocus(e4, 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 = document.createElement("div"), this._liveRegion.classList.add("live-region"), this._liveRegion.setAttribute("aria-live", "assertive"), this._accessibilityContainer.appendChild(this._liveRegion), this._liveRegionDebouncer = this.register(new a.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(((e4) => this._handleResize(e4.rows)))), this.register(this._terminal.onRender(((e4) => this._refreshRows(e4.start, e4.end)))), this.register(this._terminal.onScroll((() => this._refreshRows()))), this.register(this._terminal.onA11yChar(((e4) => this._handleChar(e4)))), this.register(this._terminal.onLineFeed((() => this._handleChar("\n")))), this.register(this._terminal.onA11yTab(((e4) => this._handleTab(e4)))), this.register(this._terminal.onKey(((e4) => this._handleKey(e4.key)))), this.register(this._terminal.onBlur((() => this._clearLiveRegion()))), this.register(this._renderService.onDimensionsChange((() => this._refreshRowsDimensions()))), this._screenDprMonitor = new c.ScreenDprMonitor(window), this.register(this._screenDprMonitor), this._screenDprMonitor.setListener((() => this._refreshRowsDimensions())), this.register((0, d.addDisposableDomListener)(window, "resize", (() => this._refreshRowsDimensions()))), this._refreshRows(), this.register((0, h.toDisposable)((() => { + this._accessibilityContainer.remove(), this._rowElements.length = 0; + }))); + } + _handleTab(e3) { + for (let t3 = 0; t3 < e3; t3++) this._handleChar(" "); + } + _handleChar(e3) { + this._liveRegionLineCount < 21 && (this._charsToConsume.length > 0 ? this._charsToConsume.shift() !== e3 && (this._charsToAnnounce += e3) : this._charsToAnnounce += e3, "\n" === e3 && (this._liveRegionLineCount++, 21 === this._liveRegionLineCount && (this._liveRegion.textContent += n.tooMuchOutput)), o.isMac && this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode && setTimeout((() => { + this._accessibilityContainer.appendChild(this._liveRegion); + }), 0)); + } + _clearLiveRegion() { + this._liveRegion.textContent = "", this._liveRegionLineCount = 0, o.isMac && this._liveRegion.remove(); + } + _handleKey(e3) { + this._clearLiveRegion(), /\p{Control}/u.test(e3) || this._charsToConsume.push(e3); + } + _refreshRows(e3, t3) { + this._liveRegionDebouncer.refresh(e3, t3, this._terminal.rows); + } + _renderRows(e3, t3) { + const i3 = this._terminal.buffer, s3 = i3.lines.length.toString(); + for (let r2 = e3; r2 <= t3; r2++) { + const e4 = i3.translateBufferLineToString(i3.ydisp + r2, true), t4 = (i3.ydisp + r2 + 1).toString(), n2 = this._rowElements[r2]; + n2 && (0 === e4.length ? n2.innerText = "\xA0" : n2.textContent = e4, n2.setAttribute("aria-posinset", t4), n2.setAttribute("aria-setsize", s3)); + } + this._announceCharacters(); + } + _announceCharacters() { + 0 !== this._charsToAnnounce.length && (this._liveRegion.textContent += this._charsToAnnounce, this._charsToAnnounce = ""); + } + _handleBoundaryFocus(e3, t3) { + const i3 = e3.target, s3 = this._rowElements[0 === t3 ? 1 : this._rowElements.length - 2]; + if (i3.getAttribute("aria-posinset") === (0 === t3 ? "1" : `${this._terminal.buffer.lines.length}`)) return; + if (e3.relatedTarget !== s3) return; + let r2, n2; + if (0 === t3 ? (r2 = i3, n2 = this._rowElements.pop(), this._rowContainer.removeChild(n2)) : (r2 = this._rowElements.shift(), n2 = i3, this._rowContainer.removeChild(r2)), r2.removeEventListener("focus", this._topBoundaryFocusListener), n2.removeEventListener("focus", this._bottomBoundaryFocusListener), 0 === t3) { + const e4 = this._createAccessibilityTreeNode(); + this._rowElements.unshift(e4), this._rowContainer.insertAdjacentElement("afterbegin", e4); + } else { + const e4 = this._createAccessibilityTreeNode(); + this._rowElements.push(e4), this._rowContainer.appendChild(e4); + } + this._rowElements[0].addEventListener("focus", this._topBoundaryFocusListener), this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._terminal.scrollLines(0 === t3 ? -1 : 1), this._rowElements[0 === t3 ? 1 : this._rowElements.length - 2].focus(), e3.preventDefault(), e3.stopImmediatePropagation(); + } + _handleResize(e3) { + this._rowElements[this._rowElements.length - 1].removeEventListener("focus", this._bottomBoundaryFocusListener); + for (let e4 = this._rowContainer.children.length; e4 < this._terminal.rows; e4++) this._rowElements[e4] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[e4]); + for (; this._rowElements.length > e3; ) this._rowContainer.removeChild(this._rowElements.pop()); + this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._refreshRowsDimensions(); + } + _createAccessibilityTreeNode() { + const e3 = document.createElement("div"); + return e3.setAttribute("role", "listitem"), e3.tabIndex = -1, this._refreshRowDimensions(e3), e3; + } + _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 e3 = 0; e3 < this._terminal.rows; e3++) this._refreshRowDimensions(this._rowElements[e3]); + } + } + _refreshRowDimensions(e3) { + e3.style.height = `${this._renderService.dimensions.css.cell.height}px`; + } + }; + t2.AccessibilityManager = _ = s2([r(1, l.IRenderService)], _); + }, 3614: (e2, t2) => { + function i2(e3) { + return e3.replace(/\r?\n/g, "\r"); + } + function s2(e3, t3) { + return t3 ? "\x1B[200~" + e3 + "\x1B[201~" : e3; + } + function r(e3, t3, r2, n2) { + e3 = s2(e3 = i2(e3), r2.decPrivateModes.bracketedPasteMode && true !== n2.rawOptions.ignoreBracketedPasteMode), r2.triggerDataEvent(e3, true), t3.value = ""; + } + function n(e3, t3, i3) { + const s3 = i3.getBoundingClientRect(), r2 = e3.clientX - s3.left - 10, n2 = e3.clientY - s3.top - 10; + t3.style.width = "20px", t3.style.height = "20px", t3.style.left = `${r2}px`, t3.style.top = `${n2}px`, t3.style.zIndex = "1000", t3.focus(); + } + Object.defineProperty(t2, "__esModule", { value: true }), t2.rightClickHandler = t2.moveTextAreaUnderMouseCursor = t2.paste = t2.handlePasteEvent = t2.copyHandler = t2.bracketTextForPaste = t2.prepareTextForTerminal = void 0, t2.prepareTextForTerminal = i2, t2.bracketTextForPaste = s2, t2.copyHandler = function(e3, t3) { + e3.clipboardData && e3.clipboardData.setData("text/plain", t3.selectionText), e3.preventDefault(); + }, t2.handlePasteEvent = function(e3, t3, i3, s3) { + e3.stopPropagation(), e3.clipboardData && r(e3.clipboardData.getData("text/plain"), t3, i3, s3); + }, t2.paste = r, t2.moveTextAreaUnderMouseCursor = n, t2.rightClickHandler = function(e3, t3, i3, s3, r2) { + n(e3, t3, i3), r2 && s3.rightClickSelect(e3), t3.value = s3.selectionText, t3.select(); + }; + }, 7239: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.ColorContrastCache = void 0; + const s2 = i2(1505); + t2.ColorContrastCache = class { + constructor() { + this._color = new s2.TwoKeyMap(), this._css = new s2.TwoKeyMap(); + } + setCss(e3, t3, i3) { + this._css.set(e3, t3, i3); + } + getCss(e3, t3) { + return this._css.get(e3, t3); + } + setColor(e3, t3, i3) { + this._color.set(e3, t3, i3); + } + getColor(e3, t3) { + return this._color.get(e3, t3); + } + clear() { + this._color.clear(), this._css.clear(); + } + }; + }, 3656: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.addDisposableDomListener = void 0, t2.addDisposableDomListener = function(e3, t3, i2, s2) { + e3.addEventListener(t3, i2, s2); + let r = false; + return { dispose: () => { + r || (r = true, e3.removeEventListener(t3, i2, s2)); + } }; + }; + }, 6465: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.Linkifier2 = void 0; + const n = i2(3656), o = i2(8460), a = i2(844), h = i2(2585); + let c = t2.Linkifier2 = class extends a.Disposable { + get currentLink() { + return this._currentLink; + } + constructor(e3) { + super(), this._bufferService = e3, this._linkProviders = [], this._linkCacheDisposables = [], this._isMouseOut = true, this._wasResized = false, 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.register(this._bufferService.onResize((() => { + this._clearCurrentLink(), this._wasResized = true; + }))); + } + registerLinkProvider(e3) { + return this._linkProviders.push(e3), { dispose: () => { + const t3 = this._linkProviders.indexOf(e3); + -1 !== t3 && this._linkProviders.splice(t3, 1); + } }; + } + attachToDom(e3, t3, i3) { + this._element = e3, this._mouseService = t3, this._renderService = i3, this.register((0, n.addDisposableDomListener)(this._element, "mouseleave", (() => { + this._isMouseOut = true, 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(e3) { + if (this._lastMouseEvent = e3, !this._element || !this._mouseService) return; + const t3 = this._positionFromMouseEvent(e3, this._element, this._mouseService); + if (!t3) return; + this._isMouseOut = false; + const i3 = e3.composedPath(); + for (let e4 = 0; e4 < i3.length; e4++) { + const t4 = i3[e4]; + if (t4.classList.contains("xterm")) break; + if (t4.classList.contains("xterm-hover")) return; + } + this._lastBufferCell && t3.x === this._lastBufferCell.x && t3.y === this._lastBufferCell.y || (this._handleHover(t3), this._lastBufferCell = t3); + } + _handleHover(e3) { + if (this._activeLine !== e3.y || this._wasResized) return this._clearCurrentLink(), this._askForLink(e3, false), void (this._wasResized = false); + this._currentLink && this._linkAtPosition(this._currentLink.link, e3) || (this._clearCurrentLink(), this._askForLink(e3, true)); + } + _askForLink(e3, t3) { + var i3, s3; + this._activeProviderReplies && t3 || (null === (i3 = this._activeProviderReplies) || void 0 === i3 || i3.forEach(((e4) => { + null == e4 || e4.forEach(((e5) => { + e5.link.dispose && e5.link.dispose(); + })); + })), this._activeProviderReplies = /* @__PURE__ */ new Map(), this._activeLine = e3.y); + let r2 = false; + for (const [i4, n2] of this._linkProviders.entries()) t3 ? (null === (s3 = this._activeProviderReplies) || void 0 === s3 ? void 0 : s3.get(i4)) && (r2 = this._checkLinkProviderResult(i4, e3, r2)) : n2.provideLinks(e3.y, ((t4) => { + var s4, n3; + if (this._isMouseOut) return; + const o2 = null == t4 ? void 0 : t4.map(((e4) => ({ link: e4 }))); + null === (s4 = this._activeProviderReplies) || void 0 === s4 || s4.set(i4, o2), r2 = this._checkLinkProviderResult(i4, e3, r2), (null === (n3 = this._activeProviderReplies) || void 0 === n3 ? void 0 : n3.size) === this._linkProviders.length && this._removeIntersectingLinks(e3.y, this._activeProviderReplies); + })); + } + _removeIntersectingLinks(e3, t3) { + const i3 = /* @__PURE__ */ new Set(); + for (let s3 = 0; s3 < t3.size; s3++) { + const r2 = t3.get(s3); + if (r2) for (let t4 = 0; t4 < r2.length; t4++) { + const s4 = r2[t4], n2 = s4.link.range.start.y < e3 ? 0 : s4.link.range.start.x, o2 = s4.link.range.end.y > e3 ? this._bufferService.cols : s4.link.range.end.x; + for (let e4 = n2; e4 <= o2; e4++) { + if (i3.has(e4)) { + r2.splice(t4--, 1); + break; + } + i3.add(e4); + } + } + } + } + _checkLinkProviderResult(e3, t3, i3) { + var s3; + if (!this._activeProviderReplies) return i3; + const r2 = this._activeProviderReplies.get(e3); + let n2 = false; + for (let t4 = 0; t4 < e3; t4++) this._activeProviderReplies.has(t4) && !this._activeProviderReplies.get(t4) || (n2 = true); + if (!n2 && r2) { + const e4 = r2.find(((e5) => this._linkAtPosition(e5.link, t3))); + e4 && (i3 = true, this._handleNewLink(e4)); + } + if (this._activeProviderReplies.size === this._linkProviders.length && !i3) for (let e4 = 0; e4 < this._activeProviderReplies.size; e4++) { + const r3 = null === (s3 = this._activeProviderReplies.get(e4)) || void 0 === s3 ? void 0 : s3.find(((e5) => this._linkAtPosition(e5.link, t3))); + if (r3) { + i3 = true, this._handleNewLink(r3); + break; + } + } + return i3; + } + _handleMouseDown() { + this._mouseDownLink = this._currentLink; + } + _handleMouseUp(e3) { + if (!this._element || !this._mouseService || !this._currentLink) return; + const t3 = this._positionFromMouseEvent(e3, this._element, this._mouseService); + t3 && this._mouseDownLink === this._currentLink && this._linkAtPosition(this._currentLink.link, t3) && this._currentLink.link.activate(e3, this._currentLink.link.text); + } + _clearCurrentLink(e3, t3) { + this._element && this._currentLink && this._lastMouseEvent && (!e3 || !t3 || this._currentLink.link.range.start.y >= e3 && this._currentLink.link.range.end.y <= t3) && (this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent), this._currentLink = void 0, (0, a.disposeArray)(this._linkCacheDisposables)); + } + _handleNewLink(e3) { + if (!this._element || !this._lastMouseEvent || !this._mouseService) return; + const t3 = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService); + t3 && this._linkAtPosition(e3.link, t3) && (this._currentLink = e3, this._currentLink.state = { decorations: { underline: void 0 === e3.link.decorations || e3.link.decorations.underline, pointerCursor: void 0 === e3.link.decorations || e3.link.decorations.pointerCursor }, isHovered: true }, this._linkHover(this._element, e3.link, this._lastMouseEvent), e3.link.decorations = {}, Object.defineProperties(e3.link.decorations, { pointerCursor: { get: () => { + var e4, t4; + return null === (t4 = null === (e4 = this._currentLink) || void 0 === e4 ? void 0 : e4.state) || void 0 === t4 ? void 0 : t4.decorations.pointerCursor; + }, set: (e4) => { + var t4, i3; + (null === (t4 = this._currentLink) || void 0 === t4 ? void 0 : t4.state) && this._currentLink.state.decorations.pointerCursor !== e4 && (this._currentLink.state.decorations.pointerCursor = e4, this._currentLink.state.isHovered && (null === (i3 = this._element) || void 0 === i3 || i3.classList.toggle("xterm-cursor-pointer", e4))); + } }, underline: { get: () => { + var e4, t4; + return null === (t4 = null === (e4 = this._currentLink) || void 0 === e4 ? void 0 : e4.state) || void 0 === t4 ? void 0 : t4.decorations.underline; + }, set: (t4) => { + var i3, s3, r2; + (null === (i3 = this._currentLink) || void 0 === i3 ? void 0 : i3.state) && (null === (r2 = null === (s3 = this._currentLink) || void 0 === s3 ? void 0 : s3.state) || void 0 === r2 ? void 0 : r2.decorations.underline) !== t4 && (this._currentLink.state.decorations.underline = t4, this._currentLink.state.isHovered && this._fireUnderlineEvent(e3.link, t4)); + } } }), this._renderService && this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(((e4) => { + if (!this._currentLink) return; + const t4 = 0 === e4.start ? 0 : e4.start + 1 + this._bufferService.buffer.ydisp, i3 = this._bufferService.buffer.ydisp + 1 + e4.end; + if (this._currentLink.link.range.start.y >= t4 && this._currentLink.link.range.end.y <= i3 && (this._clearCurrentLink(t4, i3), this._lastMouseEvent && this._element)) { + const e5 = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService); + e5 && this._askForLink(e5, false); + } + })))); + } + _linkHover(e3, t3, i3) { + var s3; + (null === (s3 = this._currentLink) || void 0 === s3 ? void 0 : s3.state) && (this._currentLink.state.isHovered = true, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(t3, true), this._currentLink.state.decorations.pointerCursor && e3.classList.add("xterm-cursor-pointer")), t3.hover && t3.hover(i3, t3.text); + } + _fireUnderlineEvent(e3, t3) { + const i3 = e3.range, s3 = this._bufferService.buffer.ydisp, r2 = this._createLinkUnderlineEvent(i3.start.x - 1, i3.start.y - s3 - 1, i3.end.x, i3.end.y - s3 - 1, void 0); + (t3 ? this._onShowLinkUnderline : this._onHideLinkUnderline).fire(r2); + } + _linkLeave(e3, t3, i3) { + var s3; + (null === (s3 = this._currentLink) || void 0 === s3 ? void 0 : s3.state) && (this._currentLink.state.isHovered = false, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(t3, false), this._currentLink.state.decorations.pointerCursor && e3.classList.remove("xterm-cursor-pointer")), t3.leave && t3.leave(i3, t3.text); + } + _linkAtPosition(e3, t3) { + const i3 = e3.range.start.y * this._bufferService.cols + e3.range.start.x, s3 = e3.range.end.y * this._bufferService.cols + e3.range.end.x, r2 = t3.y * this._bufferService.cols + t3.x; + return i3 <= r2 && r2 <= s3; + } + _positionFromMouseEvent(e3, t3, i3) { + const s3 = i3.getCoords(e3, t3, this._bufferService.cols, this._bufferService.rows); + if (s3) return { x: s3[0], y: s3[1] + this._bufferService.buffer.ydisp }; + } + _createLinkUnderlineEvent(e3, t3, i3, s3, r2) { + return { x1: e3, y1: t3, x2: i3, y2: s3, cols: this._bufferService.cols, fg: r2 }; + } + }; + t2.Linkifier2 = c = s2([r(0, h.IBufferService)], c); + }, 9042: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.tooMuchOutput = t2.promptLabel = void 0, t2.promptLabel = "Terminal input", t2.tooMuchOutput = "Too much output to announce, navigate to rows manually to read"; + }, 3730: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.OscLinkProvider = void 0; + const n = i2(511), o = i2(2585); + let a = t2.OscLinkProvider = class { + constructor(e3, t3, i3) { + this._bufferService = e3, this._optionsService = t3, this._oscLinkService = i3; + } + provideLinks(e3, t3) { + var i3; + const s3 = this._bufferService.buffer.lines.get(e3 - 1); + if (!s3) return void t3(void 0); + const r2 = [], o2 = this._optionsService.rawOptions.linkHandler, a2 = new n.CellData(), c = s3.getTrimmedLength(); + let l = -1, d = -1, _ = false; + for (let t4 = 0; t4 < c; t4++) if (-1 !== d || s3.hasContent(t4)) { + if (s3.loadCell(t4, a2), a2.hasExtendedAttrs() && a2.extended.urlId) { + if (-1 === d) { + d = t4, l = a2.extended.urlId; + continue; + } + _ = a2.extended.urlId !== l; + } else -1 !== d && (_ = true); + if (_ || -1 !== d && t4 === c - 1) { + const s4 = null === (i3 = this._oscLinkService.getLinkData(l)) || void 0 === i3 ? void 0 : i3.uri; + if (s4) { + const i4 = { start: { x: d + 1, y: e3 }, end: { x: t4 + (_ || t4 !== c - 1 ? 0 : 1), y: e3 } }; + let n2 = false; + if (!(null == o2 ? void 0 : o2.allowNonHttpProtocols)) try { + const e4 = new URL(s4); + ["http:", "https:"].includes(e4.protocol) || (n2 = true); + } catch (e4) { + n2 = true; + } + n2 || r2.push({ text: s4, range: i4, activate: (e4, t5) => o2 ? o2.activate(e4, t5, i4) : h(0, t5), hover: (e4, t5) => { + var s5; + return null === (s5 = null == o2 ? void 0 : o2.hover) || void 0 === s5 ? void 0 : s5.call(o2, e4, t5, i4); + }, leave: (e4, t5) => { + var s5; + return null === (s5 = null == o2 ? void 0 : o2.leave) || void 0 === s5 ? void 0 : s5.call(o2, e4, t5, i4); + } }); + } + _ = false, a2.hasExtendedAttrs() && a2.extended.urlId ? (d = t4, l = a2.extended.urlId) : (d = -1, l = -1); + } + } + t3(r2); + } + }; + function h(e3, t3) { + if (confirm(`Do you want to navigate to ${t3}? + +WARNING: This link could potentially be dangerous`)) { + const e4 = window.open(); + if (e4) { + try { + e4.opener = null; + } catch (e5) { + } + e4.location.href = t3; + } else console.warn("Opening link blocked as opener could not be cleared"); + } + } + t2.OscLinkProvider = a = s2([r(0, o.IBufferService), r(1, o.IOptionsService), r(2, o.IOscLinkService)], a); + }, 6193: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.RenderDebouncer = void 0, t2.RenderDebouncer = class { + constructor(e3, t3) { + this._parentWindow = e3, this._renderCallback = t3, this._refreshCallbacks = []; + } + dispose() { + this._animationFrame && (this._parentWindow.cancelAnimationFrame(this._animationFrame), this._animationFrame = void 0); + } + addRefreshCallback(e3) { + return this._refreshCallbacks.push(e3), this._animationFrame || (this._animationFrame = this._parentWindow.requestAnimationFrame((() => this._innerRefresh()))), this._animationFrame; + } + refresh(e3, t3, i2) { + this._rowCount = i2, e3 = void 0 !== e3 ? e3 : 0, t3 = void 0 !== t3 ? t3 : this._rowCount - 1, this._rowStart = void 0 !== this._rowStart ? Math.min(this._rowStart, e3) : e3, this._rowEnd = void 0 !== this._rowEnd ? Math.max(this._rowEnd, t3) : t3, this._animationFrame || (this._animationFrame = this._parentWindow.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 e3 = Math.max(this._rowStart, 0), t3 = Math.min(this._rowEnd, this._rowCount - 1); + this._rowStart = void 0, this._rowEnd = void 0, this._renderCallback(e3, t3), this._runRefreshCallbacks(); + } + _runRefreshCallbacks() { + for (const e3 of this._refreshCallbacks) e3(0); + this._refreshCallbacks = []; + } + }; + }, 5596: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.ScreenDprMonitor = void 0; + const s2 = i2(844); + class r extends s2.Disposable { + constructor(e3) { + super(), this._parentWindow = e3, this._currentDevicePixelRatio = this._parentWindow.devicePixelRatio, this.register((0, s2.toDisposable)((() => { + this.clearListener(); + }))); + } + setListener(e3) { + this._listener && this.clearListener(), this._listener = e3, this._outerListener = () => { + this._listener && (this._listener(this._parentWindow.devicePixelRatio, this._currentDevicePixelRatio), this._updateDpr()); + }, this._updateDpr(); + } + _updateDpr() { + var e3; + this._outerListener && (null === (e3 = this._resolutionMediaMatchList) || void 0 === e3 || e3.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._listener && this._outerListener && (this._resolutionMediaMatchList.removeListener(this._outerListener), this._resolutionMediaMatchList = void 0, this._listener = void 0, this._outerListener = void 0); + } + } + t2.ScreenDprMonitor = r; + }, 3236: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.Terminal = void 0; + const s2 = i2(3614), r = i2(3656), n = i2(6465), o = i2(9042), a = i2(3730), h = i2(1680), c = i2(3107), l = i2(5744), d = i2(2950), _ = i2(1296), u = i2(428), f = i2(4269), v = i2(5114), p = i2(8934), g = i2(3230), m = i2(9312), S2 = i2(4725), C = i2(6731), b = i2(8055), y = i2(8969), w = i2(8460), E = i2(844), k = i2(6114), L = i2(8437), D = i2(2584), R = i2(7399), x = i2(5941), A = i2(9074), B = i2(2585), T2 = i2(5435), M = i2(4567), O = "undefined" != typeof window ? window.document : null; + class P2 extends y.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(e3 = {}) { + super(e3), this.browser = k, this._keyDownHandled = false, this._keyDownSeen = false, this._keyPressHandled = false, this._unprocessedDeadKey = false, this._accessibilityManager = this.register(new E.MutableDisposable()), this._onCursorMove = this.register(new w.EventEmitter()), this.onCursorMove = this._onCursorMove.event, this._onKey = this.register(new w.EventEmitter()), this.onKey = this._onKey.event, this._onRender = this.register(new w.EventEmitter()), this.onRender = this._onRender.event, this._onSelectionChange = this.register(new w.EventEmitter()), this.onSelectionChange = this._onSelectionChange.event, this._onTitleChange = this.register(new w.EventEmitter()), this.onTitleChange = this._onTitleChange.event, this._onBell = this.register(new w.EventEmitter()), this.onBell = this._onBell.event, this._onFocus = this.register(new w.EventEmitter()), this._onBlur = this.register(new w.EventEmitter()), this._onA11yCharEmitter = this.register(new w.EventEmitter()), this._onA11yTabEmitter = this.register(new w.EventEmitter()), this._onWillOpen = this.register(new w.EventEmitter()), this._setup(), this.linkifier2 = this.register(this._instantiationService.createInstance(n.Linkifier2)), this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(a.OscLinkProvider)), this._decorationService = this._instantiationService.createInstance(A.DecorationService), this._instantiationService.setService(B.IDecorationService, this._decorationService), this.register(this._inputHandler.onRequestBell((() => this._onBell.fire()))), this.register(this._inputHandler.onRequestRefreshRows(((e4, t3) => this.refresh(e4, t3)))), this.register(this._inputHandler.onRequestSendFocus((() => this._reportFocus()))), this.register(this._inputHandler.onRequestReset((() => this.reset()))), this.register(this._inputHandler.onRequestWindowsOptionsReport(((e4) => this._reportWindowsOptions(e4)))), this.register(this._inputHandler.onColor(((e4) => this._handleColorEvent(e4)))), this.register((0, w.forwardEvent)(this._inputHandler.onCursorMove, this._onCursorMove)), this.register((0, w.forwardEvent)(this._inputHandler.onTitleChange, this._onTitleChange)), this.register((0, w.forwardEvent)(this._inputHandler.onA11yChar, this._onA11yCharEmitter)), this.register((0, w.forwardEvent)(this._inputHandler.onA11yTab, this._onA11yTabEmitter)), this.register(this._bufferService.onResize(((e4) => this._afterResize(e4.cols, e4.rows)))), this.register((0, E.toDisposable)((() => { + var e4, t3; + this._customKeyEventHandler = void 0, null === (t3 = null === (e4 = this.element) || void 0 === e4 ? void 0 : e4.parentNode) || void 0 === t3 || t3.removeChild(this.element); + }))); + } + _handleColorEvent(e3) { + if (this._themeService) for (const t3 of e3) { + let e4, i3 = ""; + switch (t3.index) { + case 256: + e4 = "foreground", i3 = "10"; + break; + case 257: + e4 = "background", i3 = "11"; + break; + case 258: + e4 = "cursor", i3 = "12"; + break; + default: + e4 = "ansi", i3 = "4;" + t3.index; + } + switch (t3.type) { + case 0: + const s3 = b.color.toColorRGB("ansi" === e4 ? this._themeService.colors.ansi[t3.index] : this._themeService.colors[e4]); + this.coreService.triggerDataEvent(`${D.C0.ESC}]${i3};${(0, x.toRgbString)(s3)}${D.C1_ESCAPED.ST}`); + break; + case 1: + if ("ansi" === e4) this._themeService.modifyColors(((e5) => e5.ansi[t3.index] = b.rgba.toColor(...t3.color))); + else { + const i4 = e4; + this._themeService.modifyColors(((e5) => e5[i4] = b.rgba.toColor(...t3.color))); + } + break; + case 2: + this._themeService.restoreColor(t3.index); + } + } + } + _setup() { + super._setup(), this._customKeyEventHandler = void 0; + } + get buffer() { + return this.buffers.active; + } + focus() { + this.textarea && this.textarea.focus({ preventScroll: true }); + } + _handleScreenReaderModeOptionChange(e3) { + e3 ? !this._accessibilityManager.value && this._renderService && (this._accessibilityManager.value = this._instantiationService.createInstance(M.AccessibilityManager, this)) : this._accessibilityManager.clear(); + } + _handleTextAreaFocus(e3) { + this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(D.C0.ESC + "[I"), this.updateCursorStyle(e3), this.element.classList.add("focus"), this._showCursor(), this._onFocus.fire(); + } + blur() { + var e3; + return null === (e3 = this.textarea) || void 0 === e3 ? void 0 : e3.blur(); + } + _handleTextAreaBlur() { + this.textarea.value = "", this.refresh(this.buffer.y, this.buffer.y), this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(D.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 e3 = this.buffer.ybase + this.buffer.y, t3 = this.buffer.lines.get(e3); + if (!t3) return; + const i3 = Math.min(this.buffer.x, this.cols - 1), s3 = this._renderService.dimensions.css.cell.height, r2 = t3.getWidth(i3), n2 = this._renderService.dimensions.css.cell.width * r2, o2 = this.buffer.y * this._renderService.dimensions.css.cell.height, a2 = i3 * this._renderService.dimensions.css.cell.width; + this.textarea.style.left = a2 + "px", this.textarea.style.top = o2 + "px", this.textarea.style.width = n2 + "px", this.textarea.style.height = s3 + "px", this.textarea.style.lineHeight = s3 + "px", this.textarea.style.zIndex = "-5"; + } + _initGlobal() { + this._bindKeys(), this.register((0, r.addDisposableDomListener)(this.element, "copy", ((e4) => { + this.hasSelection() && (0, s2.copyHandler)(e4, this._selectionService); + }))); + const e3 = (e4) => (0, s2.handlePasteEvent)(e4, this.textarea, this.coreService, this.optionsService); + this.register((0, r.addDisposableDomListener)(this.textarea, "paste", e3)), this.register((0, r.addDisposableDomListener)(this.element, "paste", e3)), k.isFirefox ? this.register((0, r.addDisposableDomListener)(this.element, "mousedown", ((e4) => { + 2 === e4.button && (0, s2.rightClickHandler)(e4, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord); + }))) : this.register((0, r.addDisposableDomListener)(this.element, "contextmenu", ((e4) => { + (0, s2.rightClickHandler)(e4, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord); + }))), k.isLinux && this.register((0, r.addDisposableDomListener)(this.element, "auxclick", ((e4) => { + 1 === e4.button && (0, s2.moveTextAreaUnderMouseCursor)(e4, this.textarea, this.screenElement); + }))); + } + _bindKeys() { + this.register((0, r.addDisposableDomListener)(this.textarea, "keyup", ((e3) => this._keyUp(e3)), true)), this.register((0, r.addDisposableDomListener)(this.textarea, "keydown", ((e3) => this._keyDown(e3)), true)), this.register((0, r.addDisposableDomListener)(this.textarea, "keypress", ((e3) => this._keyPress(e3)), true)), this.register((0, r.addDisposableDomListener)(this.textarea, "compositionstart", (() => this._compositionHelper.compositionstart()))), this.register((0, r.addDisposableDomListener)(this.textarea, "compositionupdate", ((e3) => this._compositionHelper.compositionupdate(e3)))), this.register((0, r.addDisposableDomListener)(this.textarea, "compositionend", (() => this._compositionHelper.compositionend()))), this.register((0, r.addDisposableDomListener)(this.textarea, "input", ((e3) => this._inputEvent(e3)), true)), this.register(this.onRender((() => this._compositionHelper.updateCompositionElements()))); + } + open(e3) { + var t3; + if (!e3) throw new Error("Terminal requires a parent element."); + e3.isConnected || this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"), this._document = e3.ownerDocument, this.element = this._document.createElement("div"), this.element.dir = "ltr", this.element.classList.add("terminal"), this.element.classList.add("xterm"), e3.appendChild(this.element); + const i3 = O.createDocumentFragment(); + this._viewportElement = O.createElement("div"), this._viewportElement.classList.add("xterm-viewport"), i3.appendChild(this._viewportElement), this._viewportScrollArea = O.createElement("div"), this._viewportScrollArea.classList.add("xterm-scroll-area"), this._viewportElement.appendChild(this._viewportScrollArea), this.screenElement = O.createElement("div"), this.screenElement.classList.add("xterm-screen"), this._helperContainer = O.createElement("div"), this._helperContainer.classList.add("xterm-helpers"), this.screenElement.appendChild(this._helperContainer), i3.appendChild(this.screenElement), this.textarea = O.createElement("textarea"), this.textarea.classList.add("xterm-helper-textarea"), this.textarea.setAttribute("aria-label", o.promptLabel), k.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._instantiationService.createInstance(v.CoreBrowserService, this.textarea, null !== (t3 = this._document.defaultView) && void 0 !== t3 ? t3 : window), this._instantiationService.setService(S2.ICoreBrowserService, this._coreBrowserService), this.register((0, r.addDisposableDomListener)(this.textarea, "focus", ((e4) => this._handleTextAreaFocus(e4)))), this.register((0, r.addDisposableDomListener)(this.textarea, "blur", (() => this._handleTextAreaBlur()))), this._helperContainer.appendChild(this.textarea), this._charSizeService = this._instantiationService.createInstance(u.CharSizeService, this._document, this._helperContainer), this._instantiationService.setService(S2.ICharSizeService, this._charSizeService), this._themeService = this._instantiationService.createInstance(C.ThemeService), this._instantiationService.setService(S2.IThemeService, this._themeService), this._characterJoinerService = this._instantiationService.createInstance(f.CharacterJoinerService), this._instantiationService.setService(S2.ICharacterJoinerService, this._characterJoinerService), this._renderService = this.register(this._instantiationService.createInstance(g.RenderService, this.rows, this.screenElement)), this._instantiationService.setService(S2.IRenderService, this._renderService), this.register(this._renderService.onRenderedViewportChange(((e4) => this._onRender.fire(e4)))), this.onResize(((e4) => this._renderService.resize(e4.cols, e4.rows))), this._compositionView = O.createElement("div"), this._compositionView.classList.add("composition-view"), this._compositionHelper = this._instantiationService.createInstance(d.CompositionHelper, this.textarea, this._compositionView), this._helperContainer.appendChild(this._compositionView), this.element.appendChild(i3); + try { + this._onWillOpen.fire(this.element); + } catch (e4) { + } + this._renderService.hasRenderer() || this._renderService.setRenderer(this._createRenderer()), this._mouseService = this._instantiationService.createInstance(p.MouseService), this._instantiationService.setService(S2.IMouseService, this._mouseService), this.viewport = this._instantiationService.createInstance(h.Viewport, this._viewportElement, this._viewportScrollArea), this.viewport.onRequestScrollLines(((e4) => this.scrollLines(e4.amount, e4.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(m.SelectionService, this.element, this.screenElement, this.linkifier2)), this._instantiationService.setService(S2.ISelectionService, this._selectionService), this.register(this._selectionService.onRequestScrollLines(((e4) => this.scrollLines(e4.amount, e4.suppressScrollEvent)))), this.register(this._selectionService.onSelectionChange((() => this._onSelectionChange.fire()))), this.register(this._selectionService.onRequestRedraw(((e4) => this._renderService.handleSelectionChanged(e4.start, e4.end, e4.columnSelectMode)))), this.register(this._selectionService.onLinuxMouseSelection(((e4) => { + this.textarea.value = e4, this.textarea.focus(), this.textarea.select(); + }))), this.register(this._onScroll.event(((e4) => { + this.viewport.syncScrollArea(), this._selectionService.refresh(); + }))), this.register((0, r.addDisposableDomListener)(this._viewportElement, "scroll", (() => this._selectionService.refresh()))), this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService), this.register(this._instantiationService.createInstance(c.BufferDecorationRenderer, this.screenElement)), this.register((0, r.addDisposableDomListener)(this.element, "mousedown", ((e4) => this._selectionService.handleMouseDown(e4)))), 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", ((e4) => this._handleScreenReaderModeOptionChange(e4)))), this.options.overviewRulerWidth && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer, this._viewportElement, this.screenElement))), this.optionsService.onSpecificOptionChange("overviewRulerWidth", ((e4) => { + !this._overviewRulerRenderer && e4 && this._viewportElement && this.screenElement && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer, this._viewportElement, this.screenElement))); + })), this._charSizeService.measure(), this.refresh(0, this.rows - 1), this._initGlobal(), this.bindMouse(); + } + _createRenderer() { + return this._instantiationService.createInstance(_.DomRenderer, this.element, this.screenElement, this._viewportElement, this.linkifier2); + } + bindMouse() { + const e3 = this, t3 = this.element; + function i3(t4) { + const i4 = e3._mouseService.getMouseReportCoords(t4, e3.screenElement); + if (!i4) return false; + let s4, r2; + switch (t4.overrideType || t4.type) { + case "mousemove": + r2 = 32, void 0 === t4.buttons ? (s4 = 3, void 0 !== t4.button && (s4 = t4.button < 3 ? t4.button : 3)) : s4 = 1 & t4.buttons ? 0 : 4 & t4.buttons ? 1 : 2 & t4.buttons ? 2 : 3; + break; + case "mouseup": + r2 = 0, s4 = t4.button < 3 ? t4.button : 3; + break; + case "mousedown": + r2 = 1, s4 = t4.button < 3 ? t4.button : 3; + break; + case "wheel": + if (0 === e3.viewport.getLinesScrolled(t4)) return false; + r2 = t4.deltaY < 0 ? 0 : 1, s4 = 4; + break; + default: + return false; + } + return !(void 0 === r2 || void 0 === s4 || s4 > 4) && e3.coreMouseService.triggerMouseEvent({ col: i4.col, row: i4.row, x: i4.x, y: i4.y, button: s4, action: r2, ctrl: t4.ctrlKey, alt: t4.altKey, shift: t4.shiftKey }); + } + const s3 = { mouseup: null, wheel: null, mousedrag: null, mousemove: null }, n2 = { mouseup: (e4) => (i3(e4), e4.buttons || (this._document.removeEventListener("mouseup", s3.mouseup), s3.mousedrag && this._document.removeEventListener("mousemove", s3.mousedrag)), this.cancel(e4)), wheel: (e4) => (i3(e4), this.cancel(e4, true)), mousedrag: (e4) => { + e4.buttons && i3(e4); + }, mousemove: (e4) => { + e4.buttons || i3(e4); + } }; + this.register(this.coreMouseService.onProtocolChange(((e4) => { + e4 ? ("debug" === this.optionsService.rawOptions.logLevel && this._logService.debug("Binding to mouse events:", this.coreMouseService.explainEvents(e4)), 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 & e4 ? s3.mousemove || (t3.addEventListener("mousemove", n2.mousemove), s3.mousemove = n2.mousemove) : (t3.removeEventListener("mousemove", s3.mousemove), s3.mousemove = null), 16 & e4 ? s3.wheel || (t3.addEventListener("wheel", n2.wheel, { passive: false }), s3.wheel = n2.wheel) : (t3.removeEventListener("wheel", s3.wheel), s3.wheel = null), 2 & e4 ? s3.mouseup || (t3.addEventListener("mouseup", n2.mouseup), s3.mouseup = n2.mouseup) : (this._document.removeEventListener("mouseup", s3.mouseup), t3.removeEventListener("mouseup", s3.mouseup), s3.mouseup = null), 4 & e4 ? s3.mousedrag || (s3.mousedrag = n2.mousedrag) : (this._document.removeEventListener("mousemove", s3.mousedrag), s3.mousedrag = null); + }))), this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol, this.register((0, r.addDisposableDomListener)(t3, "mousedown", ((e4) => { + if (e4.preventDefault(), this.focus(), this.coreMouseService.areMouseEventsActive && !this._selectionService.shouldForceSelection(e4)) return i3(e4), s3.mouseup && this._document.addEventListener("mouseup", s3.mouseup), s3.mousedrag && this._document.addEventListener("mousemove", s3.mousedrag), this.cancel(e4); + }))), this.register((0, r.addDisposableDomListener)(t3, "wheel", ((e4) => { + if (!s3.wheel) { + if (!this.buffer.hasScrollback) { + const t4 = this.viewport.getLinesScrolled(e4); + if (0 === t4) return; + const i4 = D.C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? "O" : "[") + (e4.deltaY < 0 ? "A" : "B"); + let s4 = ""; + for (let e5 = 0; e5 < Math.abs(t4); e5++) s4 += i4; + return this.coreService.triggerDataEvent(s4, true), this.cancel(e4, true); + } + return this.viewport.handleWheel(e4) ? this.cancel(e4) : void 0; + } + }), { passive: false })), this.register((0, r.addDisposableDomListener)(t3, "touchstart", ((e4) => { + if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handleTouchStart(e4), this.cancel(e4); + }), { passive: true })), this.register((0, r.addDisposableDomListener)(t3, "touchmove", ((e4) => { + if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handleTouchMove(e4) ? void 0 : this.cancel(e4); + }), { passive: false })); + } + refresh(e3, t3) { + var i3; + null === (i3 = this._renderService) || void 0 === i3 || i3.refreshRows(e3, t3); + } + updateCursorStyle(e3) { + var t3; + (null === (t3 = this._selectionService) || void 0 === t3 ? void 0 : t3.shouldColumnSelect(e3)) ? this.element.classList.add("column-select") : this.element.classList.remove("column-select"); + } + _showCursor() { + this.coreService.isCursorInitialized || (this.coreService.isCursorInitialized = true, this.refresh(this.buffer.y, this.buffer.y)); + } + scrollLines(e3, t3, i3 = 0) { + var s3; + 1 === i3 ? (super.scrollLines(e3, t3, i3), this.refresh(0, this.rows - 1)) : null === (s3 = this.viewport) || void 0 === s3 || s3.scrollLines(e3); + } + paste(e3) { + (0, s2.paste)(e3, this.textarea, this.coreService, this.optionsService); + } + attachCustomKeyEventHandler(e3) { + this._customKeyEventHandler = e3; + } + registerLinkProvider(e3) { + return this.linkifier2.registerLinkProvider(e3); + } + registerCharacterJoiner(e3) { + if (!this._characterJoinerService) throw new Error("Terminal must be opened first"); + const t3 = this._characterJoinerService.register(e3); + return this.refresh(0, this.rows - 1), t3; + } + deregisterCharacterJoiner(e3) { + if (!this._characterJoinerService) throw new Error("Terminal must be opened first"); + this._characterJoinerService.deregister(e3) && this.refresh(0, this.rows - 1); + } + get markers() { + return this.buffer.markers; + } + registerMarker(e3) { + return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + e3); + } + registerDecoration(e3) { + return this._decorationService.registerDecoration(e3); + } + hasSelection() { + return !!this._selectionService && this._selectionService.hasSelection; + } + select(e3, t3, i3) { + this._selectionService.setSelection(e3, t3, i3); + } + 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() { + var e3; + null === (e3 = this._selectionService) || void 0 === e3 || e3.clearSelection(); + } + selectAll() { + var e3; + null === (e3 = this._selectionService) || void 0 === e3 || e3.selectAll(); + } + selectLines(e3, t3) { + var i3; + null === (i3 = this._selectionService) || void 0 === i3 || i3.selectLines(e3, t3); + } + _keyDown(e3) { + if (this._keyDownHandled = false, this._keyDownSeen = true, this._customKeyEventHandler && false === this._customKeyEventHandler(e3)) return false; + const t3 = this.browser.isMac && this.options.macOptionIsMeta && e3.altKey; + if (!t3 && !this._compositionHelper.keydown(e3)) return this.options.scrollOnUserInput && this.buffer.ybase !== this.buffer.ydisp && this.scrollToBottom(), false; + t3 || "Dead" !== e3.key && "AltGraph" !== e3.key || (this._unprocessedDeadKey = true); + const i3 = (0, R.evaluateKeyboardEvent)(e3, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); + if (this.updateCursorStyle(e3), 3 === i3.type || 2 === i3.type) { + const t4 = this.rows - 1; + return this.scrollLines(2 === i3.type ? -t4 : t4), this.cancel(e3, true); + } + return 1 === i3.type && this.selectAll(), !!this._isThirdLevelShift(this.browser, e3) || (i3.cancel && this.cancel(e3, true), !i3.key || !!(e3.key && !e3.ctrlKey && !e3.altKey && !e3.metaKey && 1 === e3.key.length && e3.key.charCodeAt(0) >= 65 && e3.key.charCodeAt(0) <= 90) || (this._unprocessedDeadKey ? (this._unprocessedDeadKey = false, true) : (i3.key !== D.C0.ETX && i3.key !== D.C0.CR || (this.textarea.value = ""), this._onKey.fire({ key: i3.key, domEvent: e3 }), this._showCursor(), this.coreService.triggerDataEvent(i3.key, true), !this.optionsService.rawOptions.screenReaderMode || e3.altKey || e3.ctrlKey ? this.cancel(e3, true) : void (this._keyDownHandled = true)))); + } + _isThirdLevelShift(e3, t3) { + const i3 = e3.isMac && !this.options.macOptionIsMeta && t3.altKey && !t3.ctrlKey && !t3.metaKey || e3.isWindows && t3.altKey && t3.ctrlKey && !t3.metaKey || e3.isWindows && t3.getModifierState("AltGraph"); + return "keypress" === t3.type ? i3 : i3 && (!t3.keyCode || t3.keyCode > 47); + } + _keyUp(e3) { + this._keyDownSeen = false, this._customKeyEventHandler && false === this._customKeyEventHandler(e3) || ((function(e4) { + return 16 === e4.keyCode || 17 === e4.keyCode || 18 === e4.keyCode; + })(e3) || this.focus(), this.updateCursorStyle(e3), this._keyPressHandled = false); + } + _keyPress(e3) { + let t3; + if (this._keyPressHandled = false, this._keyDownHandled) return false; + if (this._customKeyEventHandler && false === this._customKeyEventHandler(e3)) return false; + if (this.cancel(e3), e3.charCode) t3 = e3.charCode; + else if (null === e3.which || void 0 === e3.which) t3 = e3.keyCode; + else { + if (0 === e3.which || 0 === e3.charCode) return false; + t3 = e3.which; + } + return !(!t3 || (e3.altKey || e3.ctrlKey || e3.metaKey) && !this._isThirdLevelShift(this.browser, e3) || (t3 = String.fromCharCode(t3), this._onKey.fire({ key: t3, domEvent: e3 }), this._showCursor(), this.coreService.triggerDataEvent(t3, true), this._keyPressHandled = true, this._unprocessedDeadKey = false, 0)); + } + _inputEvent(e3) { + if (e3.data && "insertText" === e3.inputType && (!e3.composed || !this._keyDownSeen) && !this.optionsService.rawOptions.screenReaderMode) { + if (this._keyPressHandled) return false; + this._unprocessedDeadKey = false; + const t3 = e3.data; + return this.coreService.triggerDataEvent(t3, true), this.cancel(e3), true; + } + return false; + } + resize(e3, t3) { + e3 !== this.cols || t3 !== this.rows ? super.resize(e3, t3) : this._charSizeService && !this._charSizeService.hasValidSize && this._charSizeService.measure(); + } + _afterResize(e3, t3) { + var i3, s3; + null === (i3 = this._charSizeService) || void 0 === i3 || i3.measure(), null === (s3 = this.viewport) || void 0 === s3 || s3.syncScrollArea(true); + } + clear() { + var e3; + 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 e4 = 1; e4 < this.rows; e4++) this.buffer.lines.push(this.buffer.getBlankLine(L.DEFAULT_ATTR_DATA)); + this._onScroll.fire({ position: this.buffer.ydisp, source: 0 }), null === (e3 = this.viewport) || void 0 === e3 || e3.reset(), this.refresh(0, this.rows - 1); + } + } + reset() { + var e3, t3; + this.options.rows = this.rows, this.options.cols = this.cols; + const i3 = this._customKeyEventHandler; + this._setup(), super.reset(), null === (e3 = this._selectionService) || void 0 === e3 || e3.reset(), this._decorationService.reset(), null === (t3 = this.viewport) || void 0 === t3 || t3.reset(), this._customKeyEventHandler = i3, this.refresh(0, this.rows - 1); + } + clearTextureAtlas() { + var e3; + null === (e3 = this._renderService) || void 0 === e3 || e3.clearTextureAtlas(); + } + _reportFocus() { + var e3; + (null === (e3 = this.element) || void 0 === e3 ? void 0 : e3.classList.contains("focus")) ? this.coreService.triggerDataEvent(D.C0.ESC + "[I") : this.coreService.triggerDataEvent(D.C0.ESC + "[O"); + } + _reportWindowsOptions(e3) { + if (this._renderService) switch (e3) { + case T2.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS: + const e4 = this._renderService.dimensions.css.canvas.width.toFixed(0), t3 = this._renderService.dimensions.css.canvas.height.toFixed(0); + this.coreService.triggerDataEvent(`${D.C0.ESC}[4;${t3};${e4}t`); + break; + case T2.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS: + const i3 = this._renderService.dimensions.css.cell.width.toFixed(0), s3 = this._renderService.dimensions.css.cell.height.toFixed(0); + this.coreService.triggerDataEvent(`${D.C0.ESC}[6;${s3};${i3}t`); + } + } + cancel(e3, t3) { + if (this.options.cancelEvents || t3) return e3.preventDefault(), e3.stopPropagation(), false; + } + } + t2.Terminal = P2; + }, 9924: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.TimeBasedDebouncer = void 0, t2.TimeBasedDebouncer = class { + constructor(e3, t3 = 1e3) { + this._renderCallback = e3, this._debounceThresholdMS = t3, this._lastRefreshMs = 0, this._additionalRefreshRequested = false; + } + dispose() { + this._refreshTimeoutID && clearTimeout(this._refreshTimeoutID); + } + refresh(e3, t3, i2) { + this._rowCount = i2, e3 = void 0 !== e3 ? e3 : 0, t3 = void 0 !== t3 ? t3 : this._rowCount - 1, this._rowStart = void 0 !== this._rowStart ? Math.min(this._rowStart, e3) : e3, this._rowEnd = void 0 !== this._rowEnd ? Math.max(this._rowEnd, t3) : t3; + const s2 = Date.now(); + if (s2 - this._lastRefreshMs >= this._debounceThresholdMS) this._lastRefreshMs = s2, this._innerRefresh(); + else if (!this._additionalRefreshRequested) { + const e4 = s2 - this._lastRefreshMs, t4 = this._debounceThresholdMS - e4; + this._additionalRefreshRequested = true, this._refreshTimeoutID = window.setTimeout((() => { + this._lastRefreshMs = Date.now(), this._innerRefresh(), this._additionalRefreshRequested = false, this._refreshTimeoutID = void 0; + }), t4); + } + } + _innerRefresh() { + if (void 0 === this._rowStart || void 0 === this._rowEnd || void 0 === this._rowCount) return; + const e3 = Math.max(this._rowStart, 0), t3 = Math.min(this._rowEnd, this._rowCount - 1); + this._rowStart = void 0, this._rowEnd = void 0, this._renderCallback(e3, t3); + } + }; + }, 1680: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.Viewport = void 0; + const n = i2(3656), o = i2(4725), a = i2(8460), h = i2(844), c = i2(2585); + let l = t2.Viewport = class extends h.Disposable { + constructor(e3, t3, i3, s3, r2, o2, h2, c2) { + super(), this._viewportElement = e3, this._scrollArea = t3, this._bufferService = i3, this._optionsService = s3, this._charSizeService = r2, this._renderService = o2, this._coreBrowserService = h2, 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 = false, 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(((e4) => this._activeBuffer = e4.activeBuffer))), this._renderDimensions = this._renderService.dimensions, this.register(this._renderService.onDimensionsChange(((e4) => this._renderDimensions = e4))), this._handleThemeChange(c2.colors), this.register(c2.onChangeColors(((e4) => this._handleThemeChange(e4)))), this.register(this._optionsService.onSpecificOptionChange("scrollback", (() => this.syncScrollArea()))), setTimeout((() => this.syncScrollArea())); + } + _handleThemeChange(e3) { + this._viewportElement.style.backgroundColor = e3.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(e3) { + if (e3) 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._renderService.dimensions.device.cell.height / this._coreBrowserService.dpr, this._currentDeviceCellHeight = this._renderService.dimensions.device.cell.height, this._lastRecordedViewportHeight = this._viewportElement.offsetHeight; + const e4 = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.css.canvas.height); + this._lastRecordedBufferHeight !== e4 && (this._lastRecordedBufferHeight = e4, this._scrollArea.style.height = this._lastRecordedBufferHeight + "px"); + } + const e3 = this._bufferService.buffer.ydisp * this._currentRowHeight; + this._viewportElement.scrollTop !== e3 && (this._ignoreNextScrollEvent = true, this._viewportElement.scrollTop = e3), this._refreshAnimationFrame = null; + } + syncScrollArea(e3 = false) { + if (this._lastRecordedBufferLength !== this._bufferService.buffer.lines.length) return this._lastRecordedBufferLength = this._bufferService.buffer.lines.length, void this._refresh(e3); + this._lastRecordedViewportHeight === this._renderService.dimensions.css.canvas.height && this._lastScrollTop === this._activeBuffer.ydisp * this._currentRowHeight && this._renderDimensions.device.cell.height === this._currentDeviceCellHeight || this._refresh(e3); + } + _handleScroll(e3) { + if (this._lastScrollTop = this._viewportElement.scrollTop, !this._viewportElement.offsetParent) return; + if (this._ignoreNextScrollEvent) return this._ignoreNextScrollEvent = false, void this._onRequestScrollLines.fire({ amount: 0, suppressScrollEvent: true }); + const t3 = Math.round(this._lastScrollTop / this._currentRowHeight) - this._bufferService.buffer.ydisp; + this._onRequestScrollLines.fire({ amount: t3, suppressScrollEvent: true }); + } + _smoothScroll() { + if (this._isDisposed || -1 === this._smoothScrollState.origin || -1 === this._smoothScrollState.target) return; + const e3 = this._smoothScrollPercent(); + this._viewportElement.scrollTop = this._smoothScrollState.origin + Math.round(e3 * (this._smoothScrollState.target - this._smoothScrollState.origin)), e3 < 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(e3, t3) { + const i3 = this._viewportElement.scrollTop + this._lastRecordedViewportHeight; + return !(t3 < 0 && 0 !== this._viewportElement.scrollTop || t3 > 0 && i3 < this._lastRecordedBufferHeight) || (e3.cancelable && e3.preventDefault(), false); + } + handleWheel(e3) { + const t3 = this._getPixelsScrolled(e3); + return 0 !== t3 && (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 + t3 : this._smoothScrollState.target += t3, this._smoothScrollState.target = Math.max(Math.min(this._smoothScrollState.target, this._viewportElement.scrollHeight), 0), this._smoothScroll()) : this._clearSmoothScrollState()) : this._viewportElement.scrollTop += t3, this._bubbleScroll(e3, t3)); + } + scrollLines(e3) { + if (0 !== e3) if (this._optionsService.rawOptions.smoothScrollDuration) { + const t3 = e3 * this._currentRowHeight; + this._smoothScrollState.startTime = Date.now(), this._smoothScrollPercent() < 1 ? (this._smoothScrollState.origin = this._viewportElement.scrollTop, this._smoothScrollState.target = this._smoothScrollState.origin + t3, this._smoothScrollState.target = Math.max(Math.min(this._smoothScrollState.target, this._viewportElement.scrollHeight), 0), this._smoothScroll()) : this._clearSmoothScrollState(); + } else this._onRequestScrollLines.fire({ amount: e3, suppressScrollEvent: false }); + } + _getPixelsScrolled(e3) { + if (0 === e3.deltaY || e3.shiftKey) return 0; + let t3 = this._applyScrollModifier(e3.deltaY, e3); + return e3.deltaMode === WheelEvent.DOM_DELTA_LINE ? t3 *= this._currentRowHeight : e3.deltaMode === WheelEvent.DOM_DELTA_PAGE && (t3 *= this._currentRowHeight * this._bufferService.rows), t3; + } + getBufferElements(e3, t3) { + var i3; + let s3, r2 = ""; + const n2 = [], o2 = null != t3 ? t3 : this._bufferService.buffer.lines.length, a2 = this._bufferService.buffer.lines; + for (let t4 = e3; t4 < o2; t4++) { + const e4 = a2.get(t4); + if (!e4) continue; + const o3 = null === (i3 = a2.get(t4 + 1)) || void 0 === i3 ? void 0 : i3.isWrapped; + if (r2 += e4.translateToString(!o3), !o3 || t4 === a2.length - 1) { + const e5 = document.createElement("div"); + e5.textContent = r2, n2.push(e5), r2.length > 0 && (s3 = e5), r2 = ""; + } + } + return { bufferElements: n2, cursorElement: s3 }; + } + getLinesScrolled(e3) { + if (0 === e3.deltaY || e3.shiftKey) return 0; + let t3 = this._applyScrollModifier(e3.deltaY, e3); + return e3.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? (t3 /= this._currentRowHeight + 0, this._wheelPartialScroll += t3, t3 = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1), this._wheelPartialScroll %= 1) : e3.deltaMode === WheelEvent.DOM_DELTA_PAGE && (t3 *= this._bufferService.rows), t3; + } + _applyScrollModifier(e3, t3) { + const i3 = this._optionsService.rawOptions.fastScrollModifier; + return "alt" === i3 && t3.altKey || "ctrl" === i3 && t3.ctrlKey || "shift" === i3 && t3.shiftKey ? e3 * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity : e3 * this._optionsService.rawOptions.scrollSensitivity; + } + handleTouchStart(e3) { + this._lastTouchY = e3.touches[0].pageY; + } + handleTouchMove(e3) { + const t3 = this._lastTouchY - e3.touches[0].pageY; + return this._lastTouchY = e3.touches[0].pageY, 0 !== t3 && (this._viewportElement.scrollTop += t3, this._bubbleScroll(e3, t3)); + } + }; + t2.Viewport = l = s2([r(2, c.IBufferService), r(3, c.IOptionsService), r(4, o.ICharSizeService), r(5, o.IRenderService), r(6, o.ICoreBrowserService), r(7, o.IThemeService)], l); + }, 3107: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferDecorationRenderer = void 0; + const n = i2(3656), o = i2(4725), a = i2(844), h = i2(2585); + let c = t2.BufferDecorationRenderer = class extends a.Disposable { + constructor(e3, t3, i3, s3) { + super(), this._screenElement = e3, this._bufferService = t3, this._decorationService = i3, this._renderService = s3, this._decorationElements = /* @__PURE__ */ new Map(), this._altBufferIsActive = false, this._dimensionsChanged = false, 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 = true, this._queueRefresh(); + }))), this.register((0, n.addDisposableDomListener)(window, "resize", (() => 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(((e4) => this._removeDecoration(e4)))), this.register((0, a.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 e3 of this._decorationService.decorations) this._renderDecoration(e3); + this._dimensionsChanged = false; + } + _renderDecoration(e3) { + this._refreshStyle(e3), this._dimensionsChanged && this._refreshXPosition(e3); + } + _createElement(e3) { + var t3, i3; + const s3 = document.createElement("div"); + s3.classList.add("xterm-decoration"), s3.classList.toggle("xterm-decoration-top-layer", "top" === (null === (t3 = null == e3 ? void 0 : e3.options) || void 0 === t3 ? void 0 : t3.layer)), s3.style.width = `${Math.round((e3.options.width || 1) * this._renderService.dimensions.css.cell.width)}px`, s3.style.height = (e3.options.height || 1) * this._renderService.dimensions.css.cell.height + "px", s3.style.top = (e3.marker.line - this._bufferService.buffers.active.ydisp) * this._renderService.dimensions.css.cell.height + "px", s3.style.lineHeight = `${this._renderService.dimensions.css.cell.height}px`; + const r2 = null !== (i3 = e3.options.x) && void 0 !== i3 ? i3 : 0; + return r2 && r2 > this._bufferService.cols && (s3.style.display = "none"), this._refreshXPosition(e3, s3), s3; + } + _refreshStyle(e3) { + const t3 = e3.marker.line - this._bufferService.buffers.active.ydisp; + if (t3 < 0 || t3 >= this._bufferService.rows) e3.element && (e3.element.style.display = "none", e3.onRenderEmitter.fire(e3.element)); + else { + let i3 = this._decorationElements.get(e3); + i3 || (i3 = this._createElement(e3), e3.element = i3, this._decorationElements.set(e3, i3), this._container.appendChild(i3), e3.onDispose((() => { + this._decorationElements.delete(e3), i3.remove(); + }))), i3.style.top = t3 * this._renderService.dimensions.css.cell.height + "px", i3.style.display = this._altBufferIsActive ? "none" : "block", e3.onRenderEmitter.fire(i3); + } + } + _refreshXPosition(e3, t3 = e3.element) { + var i3; + if (!t3) return; + const s3 = null !== (i3 = e3.options.x) && void 0 !== i3 ? i3 : 0; + "right" === (e3.options.anchor || "left") ? t3.style.right = s3 ? s3 * this._renderService.dimensions.css.cell.width + "px" : "" : t3.style.left = s3 ? s3 * this._renderService.dimensions.css.cell.width + "px" : ""; + } + _removeDecoration(e3) { + var t3; + null === (t3 = this._decorationElements.get(e3)) || void 0 === t3 || t3.remove(), this._decorationElements.delete(e3), e3.dispose(); + } + }; + t2.BufferDecorationRenderer = c = s2([r(1, h.IBufferService), r(2, h.IDecorationService), r(3, o.IRenderService)], c); + }, 5871: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.ColorZoneStore = void 0, t2.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(e3) { + if (e3.options.overviewRulerOptions) { + for (const t3 of this._zones) if (t3.color === e3.options.overviewRulerOptions.color && t3.position === e3.options.overviewRulerOptions.position) { + if (this._lineIntersectsZone(t3, e3.marker.line)) return; + if (this._lineAdjacentToZone(t3, e3.marker.line, e3.options.overviewRulerOptions.position)) return void this._addLineToZone(t3, e3.marker.line); + } + if (this._zonePoolIndex < this._zonePool.length) return this._zonePool[this._zonePoolIndex].color = e3.options.overviewRulerOptions.color, this._zonePool[this._zonePoolIndex].position = e3.options.overviewRulerOptions.position, this._zonePool[this._zonePoolIndex].startBufferLine = e3.marker.line, this._zonePool[this._zonePoolIndex].endBufferLine = e3.marker.line, void this._zones.push(this._zonePool[this._zonePoolIndex++]); + this._zones.push({ color: e3.options.overviewRulerOptions.color, position: e3.options.overviewRulerOptions.position, startBufferLine: e3.marker.line, endBufferLine: e3.marker.line }), this._zonePool.push(this._zones[this._zones.length - 1]), this._zonePoolIndex++; + } + } + setPadding(e3) { + this._linePadding = e3; + } + _lineIntersectsZone(e3, t3) { + return t3 >= e3.startBufferLine && t3 <= e3.endBufferLine; + } + _lineAdjacentToZone(e3, t3, i2) { + return t3 >= e3.startBufferLine - this._linePadding[i2 || "full"] && t3 <= e3.endBufferLine + this._linePadding[i2 || "full"]; + } + _addLineToZone(e3, t3) { + e3.startBufferLine = Math.min(e3.startBufferLine, t3), e3.endBufferLine = Math.max(e3.endBufferLine, t3); + } + }; + }, 5744: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.OverviewRulerRenderer = void 0; + const n = i2(5871), o = i2(3656), a = i2(4725), h = i2(844), c = i2(2585), l = { full: 0, left: 0, center: 0, right: 0 }, d = { full: 0, left: 0, center: 0, right: 0 }, _ = { full: 0, left: 0, center: 0, right: 0 }; + let u = t2.OverviewRulerRenderer = class extends h.Disposable { + get _width() { + return this._optionsService.options.overviewRulerWidth || 0; + } + constructor(e3, t3, i3, s3, r2, o2, a2) { + var c2; + super(), this._viewportElement = e3, this._screenElement = t3, this._bufferService = i3, this._decorationService = s3, this._renderService = r2, this._optionsService = o2, this._coreBrowseService = a2, this._colorZoneStore = new n.ColorZoneStore(), this._shouldUpdateDimensions = true, this._shouldUpdateAnchor = true, this._lastKnownBufferLength = 0, this._canvas = document.createElement("canvas"), this._canvas.classList.add("xterm-decoration-overview-ruler"), this._refreshCanvasDimensions(), null === (c2 = this._viewportElement.parentElement) || void 0 === c2 || c2.insertBefore(this._canvas, this._viewportElement); + const l2 = this._canvas.getContext("2d"); + if (!l2) throw new Error("Ctx cannot be null"); + this._ctx = l2, this._registerDecorationListeners(), this._registerBufferChangeListeners(), this._registerDimensionChangeListeners(), this.register((0, h.toDisposable)((() => { + var e4; + null === (e4 = this._canvas) || void 0 === e4 || e4.remove(); + }))); + } + _registerDecorationListeners() { + this.register(this._decorationService.onDecorationRegistered((() => this._queueRefresh(void 0, true)))), this.register(this._decorationService.onDecorationRemoved((() => this._queueRefresh(void 0, true)))); + } + _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(true), this._containerHeight = this._screenElement.clientHeight); + }))), this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth", (() => this._queueRefresh(true)))), this.register((0, o.addDisposableDomListener)(this._coreBrowseService.window, "resize", (() => this._queueRefresh(true)))), this._queueRefresh(true); + } + _refreshDrawConstants() { + const e3 = Math.floor(this._canvas.width / 3), t3 = Math.ceil(this._canvas.width / 3); + d.full = this._canvas.width, d.left = e3, d.center = t3, d.right = e3, this._refreshDrawHeightConstants(), _.full = 0, _.left = 0, _.center = d.left, _.right = d.left + d.center; + } + _refreshDrawHeightConstants() { + l.full = Math.round(2 * this._coreBrowseService.dpr); + const e3 = this._canvas.height / this._bufferService.buffer.lines.length, t3 = Math.round(Math.max(Math.min(e3, 12), 6) * this._coreBrowseService.dpr); + l.left = t3, l.center = t3, l.right = t3; + } + _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._coreBrowseService.dpr), this._canvas.style.height = `${this._screenElement.clientHeight}px`, this._canvas.height = Math.round(this._screenElement.clientHeight * this._coreBrowseService.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 e4 of this._decorationService.decorations) this._colorZoneStore.addDecoration(e4); + this._ctx.lineWidth = 1; + const e3 = this._colorZoneStore.zones; + for (const t3 of e3) "full" !== t3.position && this._renderColorZone(t3); + for (const t3 of e3) "full" === t3.position && this._renderColorZone(t3); + this._shouldUpdateDimensions = false, this._shouldUpdateAnchor = false; + } + _renderColorZone(e3) { + this._ctx.fillStyle = e3.color, this._ctx.fillRect(_[e3.position || "full"], Math.round((this._canvas.height - 1) * (e3.startBufferLine / this._bufferService.buffers.active.lines.length) - l[e3.position || "full"] / 2), d[e3.position || "full"], Math.round((this._canvas.height - 1) * ((e3.endBufferLine - e3.startBufferLine) / this._bufferService.buffers.active.lines.length) + l[e3.position || "full"])); + } + _queueRefresh(e3, t3) { + this._shouldUpdateDimensions = e3 || this._shouldUpdateDimensions, this._shouldUpdateAnchor = t3 || this._shouldUpdateAnchor, void 0 === this._animationFrame && (this._animationFrame = this._coreBrowseService.window.requestAnimationFrame((() => { + this._refreshDecorations(), this._animationFrame = void 0; + }))); + } + }; + t2.OverviewRulerRenderer = u = s2([r(2, c.IBufferService), r(3, c.IDecorationService), r(4, a.IRenderService), r(5, c.IOptionsService), r(6, a.ICoreBrowserService)], u); + }, 2950: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.CompositionHelper = void 0; + const n = i2(4725), o = i2(2585), a = i2(2584); + let h = t2.CompositionHelper = class { + get isComposing() { + return this._isComposing; + } + constructor(e3, t3, i3, s3, r2, n2) { + this._textarea = e3, this._compositionView = t3, this._bufferService = i3, this._optionsService = s3, this._coreService = r2, this._renderService = n2, this._isComposing = false, this._isSendingComposition = false, this._compositionPosition = { start: 0, end: 0 }, this._dataAlreadySent = ""; + } + compositionstart() { + this._isComposing = true, this._compositionPosition.start = this._textarea.value.length, this._compositionView.textContent = "", this._dataAlreadySent = "", this._compositionView.classList.add("active"); + } + compositionupdate(e3) { + this._compositionView.textContent = e3.data, this.updateCompositionElements(), setTimeout((() => { + this._compositionPosition.end = this._textarea.value.length; + }), 0); + } + compositionend() { + this._finalizeComposition(true); + } + keydown(e3) { + if (this._isComposing || this._isSendingComposition) { + if (229 === e3.keyCode) return false; + if (16 === e3.keyCode || 17 === e3.keyCode || 18 === e3.keyCode) return false; + this._finalizeComposition(false); + } + return 229 !== e3.keyCode || (this._handleAnyTextareaChanges(), false); + } + _finalizeComposition(e3) { + if (this._compositionView.classList.remove("active"), this._isComposing = false, e3) { + const e4 = { start: this._compositionPosition.start, end: this._compositionPosition.end }; + this._isSendingComposition = true, setTimeout((() => { + if (this._isSendingComposition) { + let t3; + this._isSendingComposition = false, e4.start += this._dataAlreadySent.length, t3 = this._isComposing ? this._textarea.value.substring(e4.start, e4.end) : this._textarea.value.substring(e4.start), t3.length > 0 && this._coreService.triggerDataEvent(t3, true); + } + }), 0); + } else { + this._isSendingComposition = false; + const e4 = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end); + this._coreService.triggerDataEvent(e4, true); + } + } + _handleAnyTextareaChanges() { + const e3 = this._textarea.value; + setTimeout((() => { + if (!this._isComposing) { + const t3 = this._textarea.value, i3 = t3.replace(e3, ""); + this._dataAlreadySent = i3, t3.length > e3.length ? this._coreService.triggerDataEvent(i3, true) : t3.length < e3.length ? this._coreService.triggerDataEvent(`${a.C0.DEL}`, true) : t3.length === e3.length && t3 !== e3 && this._coreService.triggerDataEvent(t3, true); + } + }), 0); + } + updateCompositionElements(e3) { + if (this._isComposing) { + if (this._bufferService.buffer.isCursorInViewport) { + const e4 = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1), t3 = this._renderService.dimensions.css.cell.height, i3 = this._bufferService.buffer.y * this._renderService.dimensions.css.cell.height, s3 = e4 * this._renderService.dimensions.css.cell.width; + this._compositionView.style.left = s3 + "px", this._compositionView.style.top = i3 + "px", this._compositionView.style.height = t3 + "px", this._compositionView.style.lineHeight = t3 + "px", this._compositionView.style.fontFamily = this._optionsService.rawOptions.fontFamily, this._compositionView.style.fontSize = this._optionsService.rawOptions.fontSize + "px"; + const r2 = this._compositionView.getBoundingClientRect(); + this._textarea.style.left = s3 + "px", this._textarea.style.top = i3 + "px", this._textarea.style.width = Math.max(r2.width, 1) + "px", this._textarea.style.height = Math.max(r2.height, 1) + "px", this._textarea.style.lineHeight = r2.height + "px"; + } + e3 || setTimeout((() => this.updateCompositionElements(true)), 0); + } + } + }; + t2.CompositionHelper = h = s2([r(2, o.IBufferService), r(3, o.IOptionsService), r(4, o.ICoreService), r(5, n.IRenderService)], h); + }, 9806: (e2, t2) => { + function i2(e3, t3, i3) { + const s2 = i3.getBoundingClientRect(), r = e3.getComputedStyle(i3), n = parseInt(r.getPropertyValue("padding-left")), o = parseInt(r.getPropertyValue("padding-top")); + return [t3.clientX - s2.left - n, t3.clientY - s2.top - o]; + } + Object.defineProperty(t2, "__esModule", { value: true }), t2.getCoords = t2.getCoordsRelativeToElement = void 0, t2.getCoordsRelativeToElement = i2, t2.getCoords = function(e3, t3, s2, r, n, o, a, h, c) { + if (!o) return; + const l = i2(e3, t3, s2); + return l ? (l[0] = Math.ceil((l[0] + (c ? a / 2 : 0)) / a), l[1] = Math.ceil(l[1] / h), l[0] = Math.min(Math.max(l[0], 1), r + (c ? 1 : 0)), l[1] = Math.min(Math.max(l[1], 1), n), l) : void 0; + }; + }, 9504: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.moveToCellSequence = void 0; + const s2 = i2(2584); + function r(e3, t3, i3, s3) { + const r2 = e3 - n(e3, i3), a2 = t3 - n(t3, i3), l = Math.abs(r2 - a2) - (function(e4, t4, i4) { + let s4 = 0; + const r3 = e4 - n(e4, i4), a3 = t4 - n(t4, i4); + for (let n2 = 0; n2 < Math.abs(r3 - a3); n2++) { + const a4 = "A" === o(e4, t4) ? -1 : 1, h2 = i4.buffer.lines.get(r3 + a4 * n2); + (null == h2 ? void 0 : h2.isWrapped) && s4++; + } + return s4; + })(e3, t3, i3); + return c(l, h(o(e3, t3), s3)); + } + function n(e3, t3) { + let i3 = 0, s3 = t3.buffer.lines.get(e3), r2 = null == s3 ? void 0 : s3.isWrapped; + for (; r2 && e3 >= 0 && e3 < t3.rows; ) i3++, s3 = t3.buffer.lines.get(--e3), r2 = null == s3 ? void 0 : s3.isWrapped; + return i3; + } + function o(e3, t3) { + return e3 > t3 ? "A" : "B"; + } + function a(e3, t3, i3, s3, r2, n2) { + let o2 = e3, a2 = t3, h2 = ""; + for (; o2 !== i3 || a2 !== s3; ) o2 += r2 ? 1 : -1, r2 && o2 > n2.cols - 1 ? (h2 += n2.buffer.translateBufferLineToString(a2, false, e3, o2), o2 = 0, e3 = 0, a2++) : !r2 && o2 < 0 && (h2 += n2.buffer.translateBufferLineToString(a2, false, 0, e3 + 1), o2 = n2.cols - 1, e3 = o2, a2--); + return h2 + n2.buffer.translateBufferLineToString(a2, false, e3, o2); + } + function h(e3, t3) { + const i3 = t3 ? "O" : "["; + return s2.C0.ESC + i3 + e3; + } + function c(e3, t3) { + e3 = Math.floor(e3); + let i3 = ""; + for (let s3 = 0; s3 < e3; s3++) i3 += t3; + return i3; + } + t2.moveToCellSequence = function(e3, t3, i3, s3) { + const o2 = i3.buffer.x, l = i3.buffer.y; + if (!i3.buffer.hasScrollback) return (function(e4, t4, i4, s4, o3, l2) { + return 0 === r(t4, s4, o3, l2).length ? "" : c(a(e4, t4, e4, t4 - n(t4, o3), false, o3).length, h("D", l2)); + })(o2, l, 0, t3, i3, s3) + r(l, t3, i3, s3) + (function(e4, t4, i4, s4, o3, l2) { + let d2; + d2 = r(t4, s4, o3, l2).length > 0 ? s4 - n(s4, o3) : t4; + const _2 = s4, u = (function(e5, t5, i5, s5, o4, a2) { + let h2; + return h2 = r(i5, s5, o4, a2).length > 0 ? s5 - n(s5, o4) : t5, e5 < i5 && h2 <= s5 || e5 >= i5 && h2 < s5 ? "C" : "D"; + })(e4, t4, i4, s4, o3, l2); + return c(a(e4, d2, i4, _2, "C" === u, o3).length, h(u, l2)); + })(o2, l, e3, t3, i3, s3); + let d; + if (l === t3) return d = o2 > e3 ? "D" : "C", c(Math.abs(o2 - e3), h(d, s3)); + d = l > t3 ? "D" : "C"; + const _ = Math.abs(l - t3); + return c((function(e4, t4) { + return t4.cols - e4; + })(l > t3 ? e3 : o2, i3) + (_ - 1) * i3.cols + 1 + ((l > t3 ? o2 : e3) - 1), h(d, s3)); + }; + }, 1296: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.DomRenderer = void 0; + const n = i2(3787), o = i2(2550), a = i2(2223), h = i2(6171), c = i2(4725), l = i2(8055), d = i2(8460), _ = i2(844), u = i2(2585), f = "xterm-dom-renderer-owner-", v = "xterm-rows", p = "xterm-fg-", g = "xterm-bg-", m = "xterm-focus", S2 = "xterm-selection"; + let C = 1, b = t2.DomRenderer = class extends _.Disposable { + constructor(e3, t3, i3, s3, r2, a2, c2, l2, u2, p2) { + super(), this._element = e3, this._screenElement = t3, this._viewportElement = i3, this._linkifier2 = s3, this._charSizeService = a2, this._optionsService = c2, this._bufferService = l2, this._coreBrowserService = u2, this._themeService = p2, this._terminalClass = C++, this._rowElements = [], this.onRequestRedraw = this.register(new d.EventEmitter()).event, this._rowContainer = document.createElement("div"), this._rowContainer.classList.add(v), this._rowContainer.style.lineHeight = "normal", this._rowContainer.setAttribute("aria-hidden", "true"), this._refreshRowElements(this._bufferService.cols, this._bufferService.rows), this._selectionContainer = document.createElement("div"), this._selectionContainer.classList.add(S2), 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(((e4) => this._injectCss(e4)))), this._injectCss(this._themeService.colors), this._rowFactory = r2.createInstance(n.DomRendererRowFactory, document), this._element.classList.add(f + this._terminalClass), this._screenElement.appendChild(this._rowContainer), this._screenElement.appendChild(this._selectionContainer), this.register(this._linkifier2.onShowLinkUnderline(((e4) => this._handleLinkHover(e4)))), this.register(this._linkifier2.onHideLinkUnderline(((e4) => this._handleLinkLeave(e4)))), this.register((0, _.toDisposable)((() => { + this._element.classList.remove(f + this._terminalClass), this._rowContainer.remove(), this._selectionContainer.remove(), this._widthCache.dispose(), this._themeStyleElement.remove(), this._dimensionsStyleElement.remove(); + }))), this._widthCache = new o.WidthCache(document), this._widthCache.setFont(this._optionsService.rawOptions.fontFamily, this._optionsService.rawOptions.fontSize, this._optionsService.rawOptions.fontWeight, this._optionsService.rawOptions.fontWeightBold), this._setDefaultSpacing(); + } + _updateDimensions() { + const e3 = this._coreBrowserService.dpr; + this.dimensions.device.char.width = this._charSizeService.width * e3, this.dimensions.device.char.height = Math.ceil(this._charSizeService.height * e3), 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 / e3), this.dimensions.css.canvas.height = Math.round(this.dimensions.device.canvas.height / e3), 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 e4 of this._rowElements) e4.style.width = `${this.dimensions.css.canvas.width}px`, e4.style.height = `${this.dimensions.css.cell.height}px`, e4.style.lineHeight = `${this.dimensions.css.cell.height}px`, e4.style.overflow = "hidden"; + this._dimensionsStyleElement || (this._dimensionsStyleElement = document.createElement("style"), this._screenElement.appendChild(this._dimensionsStyleElement)); + const t3 = `${this._terminalSelector} .${v} span { display: inline-block; height: 100%; vertical-align: top;}`; + this._dimensionsStyleElement.textContent = t3, 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(e3) { + this._themeStyleElement || (this._themeStyleElement = document.createElement("style"), this._screenElement.appendChild(this._themeStyleElement)); + let t3 = `${this._terminalSelector} .${v} { color: ${e3.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`; + t3 += `${this._terminalSelector} .${v} .xterm-dim { color: ${l.color.multiplyOpacity(e3.foreground, 0.5).css};}`, t3 += `${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;}`, t3 += "@keyframes blink_box_shadow_" + this._terminalClass + " { 50% { border-bottom-style: hidden; }}", t3 += "@keyframes blink_block_" + this._terminalClass + ` { 0% { background-color: ${e3.cursor.css}; color: ${e3.cursorAccent.css}; } 50% { background-color: inherit; color: ${e3.cursor.css}; }}`, t3 += `${this._terminalSelector} .${v}.${m} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_` + this._terminalClass + ` 1s step-end infinite;}${this._terminalSelector} .${v}.${m} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_` + this._terminalClass + ` 1s step-end infinite;}${this._terminalSelector} .${v} .xterm-cursor.xterm-cursor-block { background-color: ${e3.cursor.css}; color: ${e3.cursorAccent.css};}${this._terminalSelector} .${v} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e3.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${v} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e3.cursor.css} inset;}${this._terminalSelector} .${v} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e3.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`, t3 += `${this._terminalSelector} .${S2} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${S2} div { position: absolute; background-color: ${e3.selectionBackgroundOpaque.css};}${this._terminalSelector} .${S2} div { position: absolute; background-color: ${e3.selectionInactiveBackgroundOpaque.css};}`; + for (const [i3, s3] of e3.ansi.entries()) t3 += `${this._terminalSelector} .${p}${i3} { color: ${s3.css}; }${this._terminalSelector} .${p}${i3}.xterm-dim { color: ${l.color.multiplyOpacity(s3, 0.5).css}; }${this._terminalSelector} .${g}${i3} { background-color: ${s3.css}; }`; + t3 += `${this._terminalSelector} .${p}${a.INVERTED_DEFAULT_COLOR} { color: ${l.color.opaque(e3.background).css}; }${this._terminalSelector} .${p}${a.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${l.color.multiplyOpacity(l.color.opaque(e3.background), 0.5).css}; }${this._terminalSelector} .${g}${a.INVERTED_DEFAULT_COLOR} { background-color: ${e3.foreground.css}; }`, this._themeStyleElement.textContent = t3; + } + _setDefaultSpacing() { + const e3 = this.dimensions.css.cell.width - this._widthCache.get("W", false, false); + this._rowContainer.style.letterSpacing = `${e3}px`, this._rowFactory.defaultSpacing = e3; + } + handleDevicePixelRatioChange() { + this._updateDimensions(), this._widthCache.clear(), this._setDefaultSpacing(); + } + _refreshRowElements(e3, t3) { + for (let e4 = this._rowElements.length; e4 <= t3; e4++) { + const e5 = document.createElement("div"); + this._rowContainer.appendChild(e5), this._rowElements.push(e5); + } + for (; this._rowElements.length > t3; ) this._rowContainer.removeChild(this._rowElements.pop()); + } + handleResize(e3, t3) { + this._refreshRowElements(e3, t3), this._updateDimensions(); + } + handleCharSizeChanged() { + this._updateDimensions(), this._widthCache.clear(), this._setDefaultSpacing(); + } + handleBlur() { + this._rowContainer.classList.remove(m); + } + handleFocus() { + this._rowContainer.classList.add(m), this.renderRows(this._bufferService.buffer.y, this._bufferService.buffer.y); + } + handleSelectionChanged(e3, t3, i3) { + if (this._selectionContainer.replaceChildren(), this._rowFactory.handleSelectionChanged(e3, t3, i3), this.renderRows(0, this._bufferService.rows - 1), !e3 || !t3) return; + const s3 = e3[1] - this._bufferService.buffer.ydisp, r2 = t3[1] - this._bufferService.buffer.ydisp, n2 = Math.max(s3, 0), o2 = Math.min(r2, this._bufferService.rows - 1); + if (n2 >= this._bufferService.rows || o2 < 0) return; + const a2 = document.createDocumentFragment(); + if (i3) { + const i4 = e3[0] > t3[0]; + a2.appendChild(this._createSelectionElement(n2, i4 ? t3[0] : e3[0], i4 ? e3[0] : t3[0], o2 - n2 + 1)); + } else { + const i4 = s3 === n2 ? e3[0] : 0, h2 = n2 === r2 ? t3[0] : this._bufferService.cols; + a2.appendChild(this._createSelectionElement(n2, i4, h2)); + const c2 = o2 - n2 - 1; + if (a2.appendChild(this._createSelectionElement(n2 + 1, 0, this._bufferService.cols, c2)), n2 !== o2) { + const e4 = r2 === o2 ? t3[0] : this._bufferService.cols; + a2.appendChild(this._createSelectionElement(o2, 0, e4)); + } + } + this._selectionContainer.appendChild(a2); + } + _createSelectionElement(e3, t3, i3, s3 = 1) { + const r2 = document.createElement("div"); + return r2.style.height = s3 * this.dimensions.css.cell.height + "px", r2.style.top = e3 * this.dimensions.css.cell.height + "px", r2.style.left = t3 * this.dimensions.css.cell.width + "px", r2.style.width = this.dimensions.css.cell.width * (i3 - t3) + "px", r2; + } + 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 e3 of this._rowElements) e3.replaceChildren(); + } + renderRows(e3, t3) { + const i3 = this._bufferService.buffer, s3 = i3.ybase + i3.y, r2 = Math.min(i3.x, this._bufferService.cols - 1), n2 = this._optionsService.rawOptions.cursorBlink, o2 = this._optionsService.rawOptions.cursorStyle, a2 = this._optionsService.rawOptions.cursorInactiveStyle; + for (let h2 = e3; h2 <= t3; h2++) { + const e4 = h2 + i3.ydisp, t4 = this._rowElements[h2], c2 = i3.lines.get(e4); + if (!t4 || !c2) break; + t4.replaceChildren(...this._rowFactory.createRow(c2, e4, e4 === s3, o2, a2, r2, n2, this.dimensions.css.cell.width, this._widthCache, -1, -1)); + } + } + get _terminalSelector() { + return `.${f}${this._terminalClass}`; + } + _handleLinkHover(e3) { + this._setCellUnderline(e3.x1, e3.x2, e3.y1, e3.y2, e3.cols, true); + } + _handleLinkLeave(e3) { + this._setCellUnderline(e3.x1, e3.x2, e3.y1, e3.y2, e3.cols, false); + } + _setCellUnderline(e3, t3, i3, s3, r2, n2) { + i3 < 0 && (e3 = 0), s3 < 0 && (t3 = 0); + const o2 = this._bufferService.rows - 1; + i3 = Math.max(Math.min(i3, o2), 0), s3 = Math.max(Math.min(s3, o2), 0), r2 = Math.min(r2, this._bufferService.cols); + const a2 = this._bufferService.buffer, h2 = a2.ybase + a2.y, c2 = Math.min(a2.x, r2 - 1), l2 = this._optionsService.rawOptions.cursorBlink, d2 = this._optionsService.rawOptions.cursorStyle, _2 = this._optionsService.rawOptions.cursorInactiveStyle; + for (let o3 = i3; o3 <= s3; ++o3) { + const u2 = o3 + a2.ydisp, f2 = this._rowElements[o3], v2 = a2.lines.get(u2); + if (!f2 || !v2) break; + f2.replaceChildren(...this._rowFactory.createRow(v2, u2, u2 === h2, d2, _2, c2, l2, this.dimensions.css.cell.width, this._widthCache, n2 ? o3 === i3 ? e3 : 0 : -1, n2 ? (o3 === s3 ? t3 : r2) - 1 : -1)); + } + } + }; + t2.DomRenderer = b = s2([r(4, u.IInstantiationService), r(5, c.ICharSizeService), r(6, u.IOptionsService), r(7, u.IBufferService), r(8, c.ICoreBrowserService), r(9, c.IThemeService)], b); + }, 3787: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.DomRendererRowFactory = void 0; + const n = i2(2223), o = i2(643), a = i2(511), h = i2(2585), c = i2(8055), l = i2(4725), d = i2(4269), _ = i2(6171), u = i2(3734); + let f = t2.DomRendererRowFactory = class { + constructor(e3, t3, i3, s3, r2, n2, o2) { + this._document = e3, this._characterJoinerService = t3, this._optionsService = i3, this._coreBrowserService = s3, this._coreService = r2, this._decorationService = n2, this._themeService = o2, this._workCell = new a.CellData(), this._columnSelectMode = false, this.defaultSpacing = 0; + } + handleSelectionChanged(e3, t3, i3) { + this._selectionStart = e3, this._selectionEnd = t3, this._columnSelectMode = i3; + } + createRow(e3, t3, i3, s3, r2, a2, h2, l2, _2, f2, p) { + const g = [], m = this._characterJoinerService.getJoinedCharacters(t3), S2 = this._themeService.colors; + let C, b = e3.getNoBgTrimmedLength(); + i3 && b < a2 + 1 && (b = a2 + 1); + let y = 0, w = "", E = 0, k = 0, L = 0, D = false, R = 0, x = false, A = 0; + const B = [], T2 = -1 !== f2 && -1 !== p; + for (let M = 0; M < b; M++) { + e3.loadCell(M, this._workCell); + let b2 = this._workCell.getWidth(); + if (0 === b2) continue; + let O = false, P2 = M, I = this._workCell; + if (m.length > 0 && M === m[0][0]) { + O = true; + const t4 = m.shift(); + I = new d.JoinedCellData(this._workCell, e3.translateToString(true, t4[0], t4[1]), t4[1] - t4[0]), P2 = t4[1] - 1, b2 = I.getWidth(); + } + const H = this._isCellInSelection(M, t3), F = i3 && M === a2, W = T2 && M >= f2 && M <= p; + let U = false; + this._decorationService.forEachDecorationAtCell(M, t3, void 0, ((e4) => { + U = true; + })); + let N = I.getChars() || o.WHITESPACE_CELL_CHAR; + if (" " === N && (I.isUnderline() || I.isOverline()) && (N = "\xA0"), A = b2 * l2 - _2.get(N, I.isBold(), I.isItalic()), C) { + if (y && (H && x || !H && !x && I.bg === E) && (H && x && S2.selectionForeground || I.fg === k) && I.extended.ext === L && W === D && A === R && !F && !O && !U) { + w += N, y++; + continue; + } + y && (C.textContent = w), C = this._document.createElement("span"), y = 0, w = ""; + } else C = this._document.createElement("span"); + if (E = I.bg, k = I.fg, L = I.extended.ext, D = W, R = A, x = H, O && a2 >= M && a2 <= P2 && (a2 = M), !this._coreService.isCursorHidden && F) { + if (B.push("xterm-cursor"), this._coreBrowserService.isFocused) h2 && B.push("xterm-cursor-blink"), B.push("bar" === s3 ? "xterm-cursor-bar" : "underline" === s3 ? "xterm-cursor-underline" : "xterm-cursor-block"); + else if (r2) switch (r2) { + case "outline": + B.push("xterm-cursor-outline"); + break; + case "block": + B.push("xterm-cursor-block"); + break; + case "bar": + B.push("xterm-cursor-bar"); + break; + case "underline": + B.push("xterm-cursor-underline"); + } + } + if (I.isBold() && B.push("xterm-bold"), I.isItalic() && B.push("xterm-italic"), I.isDim() && B.push("xterm-dim"), w = I.isInvisible() ? o.WHITESPACE_CELL_CHAR : I.getChars() || o.WHITESPACE_CELL_CHAR, I.isUnderline() && (B.push(`xterm-underline-${I.extended.underlineStyle}`), " " === w && (w = "\xA0"), !I.isUnderlineColorDefault())) if (I.isUnderlineColorRGB()) C.style.textDecorationColor = `rgb(${u.AttributeData.toColorRGB(I.getUnderlineColor()).join(",")})`; + else { + let e4 = I.getUnderlineColor(); + this._optionsService.rawOptions.drawBoldTextInBrightColors && I.isBold() && e4 < 8 && (e4 += 8), C.style.textDecorationColor = S2.ansi[e4].css; + } + I.isOverline() && (B.push("xterm-overline"), " " === w && (w = "\xA0")), I.isStrikethrough() && B.push("xterm-strikethrough"), W && (C.style.textDecoration = "underline"); + let $ = I.getFgColor(), j = I.getFgColorMode(), z = I.getBgColor(), K = I.getBgColorMode(); + const q = !!I.isInverse(); + if (q) { + const e4 = $; + $ = z, z = e4; + const t4 = j; + j = K, K = t4; + } + let V, G, X, J = false; + switch (this._decorationService.forEachDecorationAtCell(M, t3, void 0, ((e4) => { + "top" !== e4.options.layer && J || (e4.backgroundColorRGB && (K = 50331648, z = e4.backgroundColorRGB.rgba >> 8 & 16777215, V = e4.backgroundColorRGB), e4.foregroundColorRGB && (j = 50331648, $ = e4.foregroundColorRGB.rgba >> 8 & 16777215, G = e4.foregroundColorRGB), J = "top" === e4.options.layer); + })), !J && H && (V = this._coreBrowserService.isFocused ? S2.selectionBackgroundOpaque : S2.selectionInactiveBackgroundOpaque, z = V.rgba >> 8 & 16777215, K = 50331648, J = true, S2.selectionForeground && (j = 50331648, $ = S2.selectionForeground.rgba >> 8 & 16777215, G = S2.selectionForeground)), J && B.push("xterm-decoration-top"), K) { + case 16777216: + case 33554432: + X = S2.ansi[z], B.push(`xterm-bg-${z}`); + break; + case 50331648: + X = c.rgba.toColor(z >> 16, z >> 8 & 255, 255 & z), this._addStyle(C, `background-color:#${v((z >>> 0).toString(16), "0", 6)}`); + break; + default: + q ? (X = S2.foreground, B.push(`xterm-bg-${n.INVERTED_DEFAULT_COLOR}`)) : X = S2.background; + } + switch (V || I.isDim() && (V = c.color.multiplyOpacity(X, 0.5)), j) { + case 16777216: + case 33554432: + I.isBold() && $ < 8 && this._optionsService.rawOptions.drawBoldTextInBrightColors && ($ += 8), this._applyMinimumContrast(C, X, S2.ansi[$], I, V, void 0) || B.push(`xterm-fg-${$}`); + break; + case 50331648: + const e4 = c.rgba.toColor($ >> 16 & 255, $ >> 8 & 255, 255 & $); + this._applyMinimumContrast(C, X, e4, I, V, G) || this._addStyle(C, `color:#${v($.toString(16), "0", 6)}`); + break; + default: + this._applyMinimumContrast(C, X, S2.foreground, I, V, void 0) || q && B.push(`xterm-fg-${n.INVERTED_DEFAULT_COLOR}`); + } + B.length && (C.className = B.join(" "), B.length = 0), F || O || U ? C.textContent = w : y++, A !== this.defaultSpacing && (C.style.letterSpacing = `${A}px`), g.push(C), M = P2; + } + return C && y && (C.textContent = w), g; + } + _applyMinimumContrast(e3, t3, i3, s3, r2, n2) { + if (1 === this._optionsService.rawOptions.minimumContrastRatio || (0, _.excludeFromContrastRatioDemands)(s3.getCode())) return false; + const o2 = this._getContrastCache(s3); + let a2; + if (r2 || n2 || (a2 = o2.getColor(t3.rgba, i3.rgba)), void 0 === a2) { + const e4 = this._optionsService.rawOptions.minimumContrastRatio / (s3.isDim() ? 2 : 1); + a2 = c.color.ensureContrastRatio(r2 || t3, n2 || i3, e4), o2.setColor((r2 || t3).rgba, (n2 || i3).rgba, null != a2 ? a2 : null); + } + return !!a2 && (this._addStyle(e3, `color:${a2.css}`), true); + } + _getContrastCache(e3) { + return e3.isDim() ? this._themeService.colors.halfContrastCache : this._themeService.colors.contrastCache; + } + _addStyle(e3, t3) { + e3.setAttribute("style", `${e3.getAttribute("style") || ""}${t3};`); + } + _isCellInSelection(e3, t3) { + const i3 = this._selectionStart, s3 = this._selectionEnd; + return !(!i3 || !s3) && (this._columnSelectMode ? i3[0] <= s3[0] ? e3 >= i3[0] && t3 >= i3[1] && e3 < s3[0] && t3 <= s3[1] : e3 < i3[0] && t3 >= i3[1] && e3 >= s3[0] && t3 <= s3[1] : t3 > i3[1] && t3 < s3[1] || i3[1] === s3[1] && t3 === i3[1] && e3 >= i3[0] && e3 < s3[0] || i3[1] < s3[1] && t3 === s3[1] && e3 < s3[0] || i3[1] < s3[1] && t3 === i3[1] && e3 >= i3[0]); + } + }; + function v(e3, t3, i3) { + for (; e3.length < i3; ) e3 = t3 + e3; + return e3; + } + t2.DomRendererRowFactory = f = s2([r(1, l.ICharacterJoinerService), r(2, h.IOptionsService), r(3, l.ICoreBrowserService), r(4, h.ICoreService), r(5, h.IDecorationService), r(6, l.IThemeService)], f); + }, 2550: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.WidthCache = void 0, t2.WidthCache = class { + constructor(e3) { + this._flat = new Float32Array(256), this._font = "", this._fontSize = 0, this._weight = "normal", this._weightBold = "bold", this._measureElements = [], this._container = e3.createElement("div"), this._container.style.position = "absolute", this._container.style.top = "-50000px", this._container.style.width = "50000px", this._container.style.whiteSpace = "pre", this._container.style.fontKerning = "none"; + const t3 = e3.createElement("span"), i2 = e3.createElement("span"); + i2.style.fontWeight = "bold"; + const s2 = e3.createElement("span"); + s2.style.fontStyle = "italic"; + const r = e3.createElement("span"); + r.style.fontWeight = "bold", r.style.fontStyle = "italic", this._measureElements = [t3, i2, s2, r], this._container.appendChild(t3), this._container.appendChild(i2), this._container.appendChild(s2), this._container.appendChild(r), e3.body.appendChild(this._container), this.clear(); + } + dispose() { + this._container.remove(), this._measureElements.length = 0, this._holey = void 0; + } + clear() { + this._flat.fill(-9999), this._holey = /* @__PURE__ */ new Map(); + } + setFont(e3, t3, i2, s2) { + e3 === this._font && t3 === this._fontSize && i2 === this._weight && s2 === this._weightBold || (this._font = e3, this._fontSize = t3, this._weight = i2, this._weightBold = s2, this._container.style.fontFamily = this._font, this._container.style.fontSize = `${this._fontSize}px`, this._measureElements[0].style.fontWeight = `${i2}`, this._measureElements[1].style.fontWeight = `${s2}`, this._measureElements[2].style.fontWeight = `${i2}`, this._measureElements[3].style.fontWeight = `${s2}`, this.clear()); + } + get(e3, t3, i2) { + let s2 = 0; + if (!t3 && !i2 && 1 === e3.length && (s2 = e3.charCodeAt(0)) < 256) return -9999 !== this._flat[s2] ? this._flat[s2] : this._flat[s2] = this._measure(e3, 0); + let r = e3; + t3 && (r += "B"), i2 && (r += "I"); + let n = this._holey.get(r); + if (void 0 === n) { + let s3 = 0; + t3 && (s3 |= 1), i2 && (s3 |= 2), n = this._measure(e3, s3), this._holey.set(r, n); + } + return n; + } + _measure(e3, t3) { + const i2 = this._measureElements[t3]; + return i2.textContent = e3.repeat(32), i2.offsetWidth / 32; + } + }; + }, 2223: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.TEXT_BASELINE = t2.DIM_OPACITY = t2.INVERTED_DEFAULT_COLOR = void 0; + const s2 = i2(6114); + t2.INVERTED_DEFAULT_COLOR = 257, t2.DIM_OPACITY = 0.5, t2.TEXT_BASELINE = s2.isFirefox || s2.isLegacyEdge ? "bottom" : "ideographic"; + }, 6171: (e2, t2) => { + function i2(e3) { + return 57508 <= e3 && e3 <= 57558; + } + Object.defineProperty(t2, "__esModule", { value: true }), t2.createRenderDimensions = t2.excludeFromContrastRatioDemands = t2.isRestrictedPowerlineGlyph = t2.isPowerlineGlyph = t2.throwIfFalsy = void 0, t2.throwIfFalsy = function(e3) { + if (!e3) throw new Error("value must not be falsy"); + return e3; + }, t2.isPowerlineGlyph = i2, t2.isRestrictedPowerlineGlyph = function(e3) { + return 57520 <= e3 && e3 <= 57527; + }, t2.excludeFromContrastRatioDemands = function(e3) { + return i2(e3) || (function(e4) { + return 9472 <= e4 && e4 <= 9631; + })(e3); + }, t2.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 } } }; + }; + }, 456: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.SelectionModel = void 0, t2.SelectionModel = class { + constructor(e3) { + this._bufferService = e3, this.isSelectAllActive = false, this.selectionStartLength = 0; + } + clearSelection() { + this.selectionStart = void 0, this.selectionEnd = void 0, this.isSelectAllActive = false, 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 e3 = this.selectionStart[0] + this.selectionStartLength; + return e3 > this._bufferService.cols ? e3 % this._bufferService.cols == 0 ? [this._bufferService.cols, this.selectionStart[1] + Math.floor(e3 / this._bufferService.cols) - 1] : [e3 % this._bufferService.cols, this.selectionStart[1] + Math.floor(e3 / this._bufferService.cols)] : [e3, this.selectionStart[1]]; + } + if (this.selectionStartLength && this.selectionEnd[1] === this.selectionStart[1]) { + const e3 = this.selectionStart[0] + this.selectionStartLength; + return e3 > this._bufferService.cols ? [e3 % this._bufferService.cols, this.selectionStart[1] + Math.floor(e3 / this._bufferService.cols)] : [Math.max(e3, this.selectionEnd[0]), this.selectionEnd[1]]; + } + return this.selectionEnd; + } + } + areSelectionValuesReversed() { + const e3 = this.selectionStart, t3 = this.selectionEnd; + return !(!e3 || !t3) && (e3[1] > t3[1] || e3[1] === t3[1] && e3[0] > t3[0]); + } + handleTrim(e3) { + return this.selectionStart && (this.selectionStart[1] -= e3), this.selectionEnd && (this.selectionEnd[1] -= e3), this.selectionEnd && this.selectionEnd[1] < 0 ? (this.clearSelection(), true) : (this.selectionStart && this.selectionStart[1] < 0 && (this.selectionStart[1] = 0), false); + } + }; + }, 428: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.CharSizeService = void 0; + const n = i2(2585), o = i2(8460), a = i2(844); + let h = t2.CharSizeService = class extends a.Disposable { + get hasValidSize() { + return this.width > 0 && this.height > 0; + } + constructor(e3, t3, i3) { + super(), this._optionsService = i3, this.width = 0, this.height = 0, this._onCharSizeChange = this.register(new o.EventEmitter()), this.onCharSizeChange = this._onCharSizeChange.event, this._measureStrategy = new c(e3, t3, this._optionsService), this.register(this._optionsService.onMultipleOptionChange(["fontFamily", "fontSize"], (() => this.measure()))); + } + measure() { + const e3 = this._measureStrategy.measure(); + e3.width === this.width && e3.height === this.height || (this.width = e3.width, this.height = e3.height, this._onCharSizeChange.fire()); + } + }; + t2.CharSizeService = h = s2([r(2, n.IOptionsService)], h); + class c { + constructor(e3, t3, i3) { + this._document = e3, this._parentElement = t3, this._optionsService = i3, this._result = { width: 0, height: 0 }, 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() { + this._measureElement.style.fontFamily = this._optionsService.rawOptions.fontFamily, this._measureElement.style.fontSize = `${this._optionsService.rawOptions.fontSize}px`; + const e3 = { height: Number(this._measureElement.offsetHeight), width: Number(this._measureElement.offsetWidth) }; + return 0 !== e3.width && 0 !== e3.height && (this._result.width = e3.width / 32, this._result.height = Math.ceil(e3.height)), this._result; + } + } + }, 4269: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.CharacterJoinerService = t2.JoinedCellData = void 0; + const n = i2(3734), o = i2(643), a = i2(511), h = i2(2585); + class c extends n.AttributeData { + constructor(e3, t3, i3) { + super(), this.content = 0, this.combinedData = "", this.fg = e3.fg, this.bg = e3.bg, this.combinedData = t3, this._width = i3; + } + isCombined() { + return 2097152; + } + getWidth() { + return this._width; + } + getChars() { + return this.combinedData; + } + getCode() { + return 2097151; + } + setFromCharData(e3) { + throw new Error("not implemented"); + } + getAsCharData() { + return [this.fg, this.getChars(), this.getWidth(), this.getCode()]; + } + } + t2.JoinedCellData = c; + let l = t2.CharacterJoinerService = class e3 { + constructor(e4) { + this._bufferService = e4, this._characterJoiners = [], this._nextCharacterJoinerId = 0, this._workCell = new a.CellData(); + } + register(e4) { + const t3 = { id: this._nextCharacterJoinerId++, handler: e4 }; + return this._characterJoiners.push(t3), t3.id; + } + deregister(e4) { + for (let t3 = 0; t3 < this._characterJoiners.length; t3++) if (this._characterJoiners[t3].id === e4) return this._characterJoiners.splice(t3, 1), true; + return false; + } + getJoinedCharacters(e4) { + if (0 === this._characterJoiners.length) return []; + const t3 = this._bufferService.buffer.lines.get(e4); + if (!t3 || 0 === t3.length) return []; + const i3 = [], s3 = t3.translateToString(true); + let r2 = 0, n2 = 0, a2 = 0, h2 = t3.getFg(0), c2 = t3.getBg(0); + for (let e5 = 0; e5 < t3.getTrimmedLength(); e5++) if (t3.loadCell(e5, this._workCell), 0 !== this._workCell.getWidth()) { + if (this._workCell.fg !== h2 || this._workCell.bg !== c2) { + if (e5 - r2 > 1) { + const e6 = this._getJoinedRanges(s3, a2, n2, t3, r2); + for (let t4 = 0; t4 < e6.length; t4++) i3.push(e6[t4]); + } + r2 = e5, a2 = n2, h2 = this._workCell.fg, c2 = this._workCell.bg; + } + n2 += this._workCell.getChars().length || o.WHITESPACE_CELL_CHAR.length; + } + if (this._bufferService.cols - r2 > 1) { + const e5 = this._getJoinedRanges(s3, a2, n2, t3, r2); + for (let t4 = 0; t4 < e5.length; t4++) i3.push(e5[t4]); + } + return i3; + } + _getJoinedRanges(t3, i3, s3, r2, n2) { + const o2 = t3.substring(i3, s3); + let a2 = []; + try { + a2 = this._characterJoiners[0].handler(o2); + } catch (e4) { + console.error(e4); + } + for (let t4 = 1; t4 < this._characterJoiners.length; t4++) try { + const i4 = this._characterJoiners[t4].handler(o2); + for (let t5 = 0; t5 < i4.length; t5++) e3._mergeRanges(a2, i4[t5]); + } catch (e4) { + console.error(e4); + } + return this._stringRangesToCellRanges(a2, r2, n2), a2; + } + _stringRangesToCellRanges(e4, t3, i3) { + let s3 = 0, r2 = false, n2 = 0, a2 = e4[s3]; + if (a2) { + for (let h2 = i3; h2 < this._bufferService.cols; h2++) { + const i4 = t3.getWidth(h2), c2 = t3.getString(h2).length || o.WHITESPACE_CELL_CHAR.length; + if (0 !== i4) { + if (!r2 && a2[0] <= n2 && (a2[0] = h2, r2 = true), a2[1] <= n2) { + if (a2[1] = h2, a2 = e4[++s3], !a2) break; + a2[0] <= n2 ? (a2[0] = h2, r2 = true) : r2 = false; + } + n2 += c2; + } + } + a2 && (a2[1] = this._bufferService.cols); + } + } + static _mergeRanges(e4, t3) { + let i3 = false; + for (let s3 = 0; s3 < e4.length; s3++) { + const r2 = e4[s3]; + if (i3) { + if (t3[1] <= r2[0]) return e4[s3 - 1][1] = t3[1], e4; + if (t3[1] <= r2[1]) return e4[s3 - 1][1] = Math.max(t3[1], r2[1]), e4.splice(s3, 1), e4; + e4.splice(s3, 1), s3--; + } else { + if (t3[1] <= r2[0]) return e4.splice(s3, 0, t3), e4; + if (t3[1] <= r2[1]) return r2[0] = Math.min(t3[0], r2[0]), e4; + t3[0] < r2[1] && (r2[0] = Math.min(t3[0], r2[0]), i3 = true); + } + } + return i3 ? e4[e4.length - 1][1] = t3[1] : e4.push(t3), e4; + } + }; + t2.CharacterJoinerService = l = s2([r(0, h.IBufferService)], l); + }, 5114: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreBrowserService = void 0, t2.CoreBrowserService = class { + constructor(e3, t3) { + this._textarea = e3, this.window = t3, this._isFocused = false, this._cachedIsFocused = void 0, this._textarea.addEventListener("focus", (() => this._isFocused = true)), this._textarea.addEventListener("blur", (() => this._isFocused = false)); + } + 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; + } + }; + }, 8934: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.MouseService = void 0; + const n = i2(4725), o = i2(9806); + let a = t2.MouseService = class { + constructor(e3, t3) { + this._renderService = e3, this._charSizeService = t3; + } + getCoords(e3, t3, i3, s3, r2) { + return (0, o.getCoords)(window, e3, t3, i3, s3, this._charSizeService.hasValidSize, this._renderService.dimensions.css.cell.width, this._renderService.dimensions.css.cell.height, r2); + } + getMouseReportCoords(e3, t3) { + const i3 = (0, o.getCoordsRelativeToElement)(window, e3, t3); + if (this._charSizeService.hasValidSize) return i3[0] = Math.min(Math.max(i3[0], 0), this._renderService.dimensions.css.canvas.width - 1), i3[1] = Math.min(Math.max(i3[1], 0), this._renderService.dimensions.css.canvas.height - 1), { col: Math.floor(i3[0] / this._renderService.dimensions.css.cell.width), row: Math.floor(i3[1] / this._renderService.dimensions.css.cell.height), x: Math.floor(i3[0]), y: Math.floor(i3[1]) }; + } + }; + t2.MouseService = a = s2([r(0, n.IRenderService), r(1, n.ICharSizeService)], a); + }, 3230: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.RenderService = void 0; + const n = i2(3656), o = i2(6193), a = i2(5596), h = i2(4725), c = i2(8460), l = i2(844), d = i2(7226), _ = i2(2585); + let u = t2.RenderService = class extends l.Disposable { + get dimensions() { + return this._renderer.value.dimensions; + } + constructor(e3, t3, i3, s3, r2, h2, _2, u2) { + if (super(), this._rowCount = e3, this._charSizeService = s3, this._renderer = this.register(new l.MutableDisposable()), this._pausedResizeTask = new d.DebouncedIdleTask(), this._isPaused = false, this._needsFullRefresh = false, this._isNextRenderRedrawOnly = true, this._needsSelectionRefresh = false, this._canvasWidth = 0, this._canvasHeight = 0, this._selectionState = { start: void 0, end: void 0, columnSelectMode: false }, this._onDimensionsChange = this.register(new c.EventEmitter()), this.onDimensionsChange = this._onDimensionsChange.event, this._onRenderedViewportChange = this.register(new c.EventEmitter()), this.onRenderedViewportChange = this._onRenderedViewportChange.event, this._onRender = this.register(new c.EventEmitter()), this.onRender = this._onRender.event, this._onRefreshRequest = this.register(new c.EventEmitter()), this.onRefreshRequest = this._onRefreshRequest.event, this._renderDebouncer = new o.RenderDebouncer(_2.window, ((e4, t4) => this._renderRows(e4, t4))), this.register(this._renderDebouncer), this._screenDprMonitor = new a.ScreenDprMonitor(_2.window), this._screenDprMonitor.setListener((() => this.handleDevicePixelRatioChange())), this.register(this._screenDprMonitor), this.register(h2.onResize((() => this._fullRefresh()))), this.register(h2.buffers.onBufferActivate((() => { + var e4; + return null === (e4 = this._renderer.value) || void 0 === e4 ? void 0 : e4.clear(); + }))), this.register(i3.onOptionChange((() => this._handleOptionsChanged()))), this.register(this._charSizeService.onCharSizeChange((() => this.handleCharSizeChanged()))), this.register(r2.onDecorationRegistered((() => this._fullRefresh()))), this.register(r2.onDecorationRemoved((() => this._fullRefresh()))), this.register(i3.onMultipleOptionChange(["customGlyphs", "drawBoldTextInBrightColors", "letterSpacing", "lineHeight", "fontFamily", "fontSize", "fontWeight", "fontWeightBold", "minimumContrastRatio"], (() => { + this.clear(), this.handleResize(h2.cols, h2.rows), this._fullRefresh(); + }))), this.register(i3.onMultipleOptionChange(["cursorBlink", "cursorStyle"], (() => this.refreshRows(h2.buffer.y, h2.buffer.y, true)))), this.register((0, n.addDisposableDomListener)(_2.window, "resize", (() => this.handleDevicePixelRatioChange()))), this.register(u2.onChangeColors((() => this._fullRefresh()))), "IntersectionObserver" in _2.window) { + const e4 = new _2.window.IntersectionObserver(((e5) => this._handleIntersectionChange(e5[e5.length - 1])), { threshold: 0 }); + e4.observe(t3), this.register({ dispose: () => e4.disconnect() }); + } + } + _handleIntersectionChange(e3) { + this._isPaused = void 0 === e3.isIntersecting ? 0 === e3.intersectionRatio : !e3.isIntersecting, this._isPaused || this._charSizeService.hasValidSize || this._charSizeService.measure(), !this._isPaused && this._needsFullRefresh && (this._pausedResizeTask.flush(), this.refreshRows(0, this._rowCount - 1), this._needsFullRefresh = false); + } + refreshRows(e3, t3, i3 = false) { + this._isPaused ? this._needsFullRefresh = true : (i3 || (this._isNextRenderRedrawOnly = false), this._renderDebouncer.refresh(e3, t3, this._rowCount)); + } + _renderRows(e3, t3) { + this._renderer.value && (e3 = Math.min(e3, this._rowCount - 1), t3 = Math.min(t3, this._rowCount - 1), this._renderer.value.renderRows(e3, t3), this._needsSelectionRefresh && (this._renderer.value.handleSelectionChanged(this._selectionState.start, this._selectionState.end, this._selectionState.columnSelectMode), this._needsSelectionRefresh = false), this._isNextRenderRedrawOnly || this._onRenderedViewportChange.fire({ start: e3, end: t3 }), this._onRender.fire({ start: e3, end: t3 }), this._isNextRenderRedrawOnly = true); + } + resize(e3, t3) { + this._rowCount = t3, 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(e3) { + this._renderer.value = e3, this._renderer.value.onRequestRedraw(((e4) => this.refreshRows(e4.start, e4.end, true))), this._needsSelectionRefresh = true, this._fullRefresh(); + } + addRefreshCallback(e3) { + return this._renderDebouncer.addRefreshCallback(e3); + } + _fullRefresh() { + this._isPaused ? this._needsFullRefresh = true : this.refreshRows(0, this._rowCount - 1); + } + clearTextureAtlas() { + var e3, t3; + this._renderer.value && (null === (t3 = (e3 = this._renderer.value).clearTextureAtlas) || void 0 === t3 || t3.call(e3), this._fullRefresh()); + } + handleDevicePixelRatioChange() { + this._charSizeService.measure(), this._renderer.value && (this._renderer.value.handleDevicePixelRatioChange(), this.refreshRows(0, this._rowCount - 1)); + } + handleResize(e3, t3) { + this._renderer.value && (this._isPaused ? this._pausedResizeTask.set((() => this._renderer.value.handleResize(e3, t3))) : this._renderer.value.handleResize(e3, t3), this._fullRefresh()); + } + handleCharSizeChanged() { + var e3; + null === (e3 = this._renderer.value) || void 0 === e3 || e3.handleCharSizeChanged(); + } + handleBlur() { + var e3; + null === (e3 = this._renderer.value) || void 0 === e3 || e3.handleBlur(); + } + handleFocus() { + var e3; + null === (e3 = this._renderer.value) || void 0 === e3 || e3.handleFocus(); + } + handleSelectionChanged(e3, t3, i3) { + var s3; + this._selectionState.start = e3, this._selectionState.end = t3, this._selectionState.columnSelectMode = i3, null === (s3 = this._renderer.value) || void 0 === s3 || s3.handleSelectionChanged(e3, t3, i3); + } + handleCursorMove() { + var e3; + null === (e3 = this._renderer.value) || void 0 === e3 || e3.handleCursorMove(); + } + clear() { + var e3; + null === (e3 = this._renderer.value) || void 0 === e3 || e3.clear(); + } + }; + t2.RenderService = u = s2([r(2, _.IOptionsService), r(3, h.ICharSizeService), r(4, _.IDecorationService), r(5, _.IBufferService), r(6, h.ICoreBrowserService), r(7, h.IThemeService)], u); + }, 9312: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.SelectionService = void 0; + const n = i2(9806), o = i2(9504), a = i2(456), h = i2(4725), c = i2(8460), l = i2(844), d = i2(6114), _ = i2(4841), u = i2(511), f = i2(2585), v = String.fromCharCode(160), p = new RegExp(v, "g"); + let g = t2.SelectionService = class extends l.Disposable { + constructor(e3, t3, i3, s3, r2, n2, o2, h2, d2) { + super(), this._element = e3, this._screenElement = t3, this._linkifier = i3, this._bufferService = s3, this._coreService = r2, this._mouseService = n2, this._optionsService = o2, this._renderService = h2, this._coreBrowserService = d2, this._dragScrollAmount = 0, this._enabled = true, this._workCell = new u.CellData(), this._mouseDownTimeStamp = 0, this._oldHasSelection = false, this._oldSelectionStart = void 0, this._oldSelectionEnd = void 0, this._onLinuxMouseSelection = this.register(new c.EventEmitter()), this.onLinuxMouseSelection = this._onLinuxMouseSelection.event, this._onRedrawRequest = this.register(new c.EventEmitter()), this.onRequestRedraw = this._onRedrawRequest.event, this._onSelectionChange = this.register(new c.EventEmitter()), this.onSelectionChange = this._onSelectionChange.event, this._onRequestScrollLines = this.register(new c.EventEmitter()), this.onRequestScrollLines = this._onRequestScrollLines.event, this._mouseMoveListener = (e4) => this._handleMouseMove(e4), this._mouseUpListener = (e4) => this._handleMouseUp(e4), this._coreService.onUserInput((() => { + this.hasSelection && this.clearSelection(); + })), this._trimListener = this._bufferService.buffer.lines.onTrim(((e4) => this._handleTrim(e4))), this.register(this._bufferService.buffers.onBufferActivate(((e4) => this._handleBufferActivate(e4)))), this.enable(), this._model = new a.SelectionModel(this._bufferService), this._activeSelectionMode = 0, this.register((0, l.toDisposable)((() => { + this._removeMouseDownListeners(); + }))); + } + reset() { + this.clearSelection(); + } + disable() { + this.clearSelection(), this._enabled = false; + } + enable() { + this._enabled = true; + } + get selectionStart() { + return this._model.finalSelectionStart; + } + get selectionEnd() { + return this._model.finalSelectionEnd; + } + get hasSelection() { + const e3 = this._model.finalSelectionStart, t3 = this._model.finalSelectionEnd; + return !(!e3 || !t3 || e3[0] === t3[0] && e3[1] === t3[1]); + } + get selectionText() { + const e3 = this._model.finalSelectionStart, t3 = this._model.finalSelectionEnd; + if (!e3 || !t3) return ""; + const i3 = this._bufferService.buffer, s3 = []; + if (3 === this._activeSelectionMode) { + if (e3[0] === t3[0]) return ""; + const r2 = e3[0] < t3[0] ? e3[0] : t3[0], n2 = e3[0] < t3[0] ? t3[0] : e3[0]; + for (let o2 = e3[1]; o2 <= t3[1]; o2++) { + const e4 = i3.translateBufferLineToString(o2, true, r2, n2); + s3.push(e4); + } + } else { + const r2 = e3[1] === t3[1] ? t3[0] : void 0; + s3.push(i3.translateBufferLineToString(e3[1], true, e3[0], r2)); + for (let r3 = e3[1] + 1; r3 <= t3[1] - 1; r3++) { + const e4 = i3.lines.get(r3), t4 = i3.translateBufferLineToString(r3, true); + (null == e4 ? void 0 : e4.isWrapped) ? s3[s3.length - 1] += t4 : s3.push(t4); + } + if (e3[1] !== t3[1]) { + const e4 = i3.lines.get(t3[1]), r3 = i3.translateBufferLineToString(t3[1], true, 0, t3[0]); + e4 && e4.isWrapped ? s3[s3.length - 1] += r3 : s3.push(r3); + } + } + return s3.map(((e4) => e4.replace(p, " "))).join(d.isWindows ? "\r\n" : "\n"); + } + clearSelection() { + this._model.clearSelection(), this._removeMouseDownListeners(), this.refresh(), this._onSelectionChange.fire(); + } + refresh(e3) { + this._refreshAnimationFrame || (this._refreshAnimationFrame = this._coreBrowserService.window.requestAnimationFrame((() => this._refresh()))), d.isLinux && e3 && 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(e3) { + const t3 = this._getMouseBufferCoords(e3), i3 = this._model.finalSelectionStart, s3 = this._model.finalSelectionEnd; + return !!(i3 && s3 && t3) && this._areCoordsInSelection(t3, i3, s3); + } + isCellInSelection(e3, t3) { + const i3 = this._model.finalSelectionStart, s3 = this._model.finalSelectionEnd; + return !(!i3 || !s3) && this._areCoordsInSelection([e3, t3], i3, s3); + } + _areCoordsInSelection(e3, t3, i3) { + return e3[1] > t3[1] && e3[1] < i3[1] || t3[1] === i3[1] && e3[1] === t3[1] && e3[0] >= t3[0] && e3[0] < i3[0] || t3[1] < i3[1] && e3[1] === i3[1] && e3[0] < i3[0] || t3[1] < i3[1] && e3[1] === t3[1] && e3[0] >= t3[0]; + } + _selectWordAtCursor(e3, t3) { + var i3, s3; + const r2 = null === (s3 = null === (i3 = this._linkifier.currentLink) || void 0 === i3 ? void 0 : i3.link) || void 0 === s3 ? void 0 : s3.range; + if (r2) return this._model.selectionStart = [r2.start.x - 1, r2.start.y - 1], this._model.selectionStartLength = (0, _.getRangeLength)(r2, this._bufferService.cols), this._model.selectionEnd = void 0, true; + const n2 = this._getMouseBufferCoords(e3); + return !!n2 && (this._selectWordAt(n2, t3), this._model.selectionEnd = void 0, true); + } + selectAll() { + this._model.isSelectAllActive = true, this.refresh(), this._onSelectionChange.fire(); + } + selectLines(e3, t3) { + this._model.clearSelection(), e3 = Math.max(e3, 0), t3 = Math.min(t3, this._bufferService.buffer.lines.length - 1), this._model.selectionStart = [0, e3], this._model.selectionEnd = [this._bufferService.cols, t3], this.refresh(), this._onSelectionChange.fire(); + } + _handleTrim(e3) { + this._model.handleTrim(e3) && this.refresh(); + } + _getMouseBufferCoords(e3) { + const t3 = this._mouseService.getCoords(e3, this._screenElement, this._bufferService.cols, this._bufferService.rows, true); + if (t3) return t3[0]--, t3[1]--, t3[1] += this._bufferService.buffer.ydisp, t3; + } + _getMouseEventScrollAmount(e3) { + let t3 = (0, n.getCoordsRelativeToElement)(this._coreBrowserService.window, e3, this._screenElement)[1]; + const i3 = this._renderService.dimensions.css.canvas.height; + return t3 >= 0 && t3 <= i3 ? 0 : (t3 > i3 && (t3 -= i3), t3 = Math.min(Math.max(t3, -50), 50), t3 /= 50, t3 / Math.abs(t3) + Math.round(14 * t3)); + } + shouldForceSelection(e3) { + return d.isMac ? e3.altKey && this._optionsService.rawOptions.macOptionClickForcesSelection : e3.shiftKey; + } + handleMouseDown(e3) { + if (this._mouseDownTimeStamp = e3.timeStamp, (2 !== e3.button || !this.hasSelection) && 0 === e3.button) { + if (!this._enabled) { + if (!this.shouldForceSelection(e3)) return; + e3.stopPropagation(); + } + e3.preventDefault(), this._dragScrollAmount = 0, this._enabled && e3.shiftKey ? this._handleIncrementalClick(e3) : 1 === e3.detail ? this._handleSingleClick(e3) : 2 === e3.detail ? this._handleDoubleClick(e3) : 3 === e3.detail && this._handleTripleClick(e3), this._addMouseDownListeners(), this.refresh(true); + } + } + _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(e3) { + this._model.selectionStart && (this._model.selectionEnd = this._getMouseBufferCoords(e3)); + } + _handleSingleClick(e3) { + if (this._model.selectionStartLength = 0, this._model.isSelectAllActive = false, this._activeSelectionMode = this.shouldColumnSelect(e3) ? 3 : 0, this._model.selectionStart = this._getMouseBufferCoords(e3), !this._model.selectionStart) return; + this._model.selectionEnd = void 0; + const t3 = this._bufferService.buffer.lines.get(this._model.selectionStart[1]); + t3 && t3.length !== this._model.selectionStart[0] && 0 === t3.hasWidth(this._model.selectionStart[0]) && this._model.selectionStart[0]++; + } + _handleDoubleClick(e3) { + this._selectWordAtCursor(e3, true) && (this._activeSelectionMode = 1); + } + _handleTripleClick(e3) { + const t3 = this._getMouseBufferCoords(e3); + t3 && (this._activeSelectionMode = 2, this._selectLineAt(t3[1])); + } + shouldColumnSelect(e3) { + return e3.altKey && !(d.isMac && this._optionsService.rawOptions.macOptionClickForcesSelection); + } + _handleMouseMove(e3) { + if (e3.stopImmediatePropagation(), !this._model.selectionStart) return; + const t3 = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null; + if (this._model.selectionEnd = this._getMouseBufferCoords(e3), !this._model.selectionEnd) return void this.refresh(true); + 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(e3), 3 !== this._activeSelectionMode && (this._dragScrollAmount > 0 ? this._model.selectionEnd[0] = this._bufferService.cols : this._dragScrollAmount < 0 && (this._model.selectionEnd[0] = 0)); + const i3 = this._bufferService.buffer; + if (this._model.selectionEnd[1] < i3.lines.length) { + const e4 = i3.lines.get(this._model.selectionEnd[1]); + e4 && 0 === e4.hasWidth(this._model.selectionEnd[0]) && this._model.selectionEnd[0]++; + } + t3 && t3[0] === this._model.selectionEnd[0] && t3[1] === this._model.selectionEnd[1] || this.refresh(true); + } + _dragScroll() { + if (this._model.selectionEnd && this._model.selectionStart && this._dragScrollAmount) { + this._onRequestScrollLines.fire({ amount: this._dragScrollAmount, suppressScrollEvent: false }); + const e3 = this._bufferService.buffer; + this._dragScrollAmount > 0 ? (3 !== this._activeSelectionMode && (this._model.selectionEnd[0] = this._bufferService.cols), this._model.selectionEnd[1] = Math.min(e3.ydisp + this._bufferService.rows, e3.lines.length - 1)) : (3 !== this._activeSelectionMode && (this._model.selectionEnd[0] = 0), this._model.selectionEnd[1] = e3.ydisp), this.refresh(); + } + } + _handleMouseUp(e3) { + const t3 = e3.timeStamp - this._mouseDownTimeStamp; + if (this._removeMouseDownListeners(), this.selectionText.length <= 1 && t3 < 500 && e3.altKey && this._optionsService.rawOptions.altClickMovesCursor) { + if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) { + const t4 = this._mouseService.getCoords(e3, this._element, this._bufferService.cols, this._bufferService.rows, false); + if (t4 && void 0 !== t4[0] && void 0 !== t4[1]) { + const e4 = (0, o.moveToCellSequence)(t4[0] - 1, t4[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys); + this._coreService.triggerDataEvent(e4, true); + } + } + } else this._fireEventIfSelectionChanged(); + } + _fireEventIfSelectionChanged() { + const e3 = this._model.finalSelectionStart, t3 = this._model.finalSelectionEnd, i3 = !(!e3 || !t3 || e3[0] === t3[0] && e3[1] === t3[1]); + i3 ? e3 && t3 && (this._oldSelectionStart && this._oldSelectionEnd && e3[0] === this._oldSelectionStart[0] && e3[1] === this._oldSelectionStart[1] && t3[0] === this._oldSelectionEnd[0] && t3[1] === this._oldSelectionEnd[1] || this._fireOnSelectionChange(e3, t3, i3)) : this._oldHasSelection && this._fireOnSelectionChange(e3, t3, i3); + } + _fireOnSelectionChange(e3, t3, i3) { + this._oldSelectionStart = e3, this._oldSelectionEnd = t3, this._oldHasSelection = i3, this._onSelectionChange.fire(); + } + _handleBufferActivate(e3) { + this.clearSelection(), this._trimListener.dispose(), this._trimListener = e3.activeBuffer.lines.onTrim(((e4) => this._handleTrim(e4))); + } + _convertViewportColToCharacterIndex(e3, t3) { + let i3 = t3; + for (let s3 = 0; t3 >= s3; s3++) { + const r2 = e3.loadCell(s3, this._workCell).getChars().length; + 0 === this._workCell.getWidth() ? i3-- : r2 > 1 && t3 !== s3 && (i3 += r2 - 1); + } + return i3; + } + setSelection(e3, t3, i3) { + this._model.clearSelection(), this._removeMouseDownListeners(), this._model.selectionStart = [e3, t3], this._model.selectionStartLength = i3, this.refresh(), this._fireEventIfSelectionChanged(); + } + rightClickSelect(e3) { + this._isClickInSelection(e3) || (this._selectWordAtCursor(e3, false) && this.refresh(true), this._fireEventIfSelectionChanged()); + } + _getWordAt(e3, t3, i3 = true, s3 = true) { + if (e3[0] >= this._bufferService.cols) return; + const r2 = this._bufferService.buffer, n2 = r2.lines.get(e3[1]); + if (!n2) return; + const o2 = r2.translateBufferLineToString(e3[1], false); + let a2 = this._convertViewportColToCharacterIndex(n2, e3[0]), h2 = a2; + const c2 = e3[0] - a2; + let l2 = 0, d2 = 0, _2 = 0, u2 = 0; + if (" " === o2.charAt(a2)) { + for (; a2 > 0 && " " === o2.charAt(a2 - 1); ) a2--; + for (; h2 < o2.length && " " === o2.charAt(h2 + 1); ) h2++; + } else { + let t4 = e3[0], i4 = e3[0]; + 0 === n2.getWidth(t4) && (l2++, t4--), 2 === n2.getWidth(i4) && (d2++, i4++); + const s4 = n2.getString(i4).length; + for (s4 > 1 && (u2 += s4 - 1, h2 += s4 - 1); t4 > 0 && a2 > 0 && !this._isCharWordSeparator(n2.loadCell(t4 - 1, this._workCell)); ) { + n2.loadCell(t4 - 1, this._workCell); + const e4 = this._workCell.getChars().length; + 0 === this._workCell.getWidth() ? (l2++, t4--) : e4 > 1 && (_2 += e4 - 1, a2 -= e4 - 1), a2--, t4--; + } + for (; i4 < n2.length && h2 + 1 < o2.length && !this._isCharWordSeparator(n2.loadCell(i4 + 1, this._workCell)); ) { + n2.loadCell(i4 + 1, this._workCell); + const e4 = this._workCell.getChars().length; + 2 === this._workCell.getWidth() ? (d2++, i4++) : e4 > 1 && (u2 += e4 - 1, h2 += e4 - 1), h2++, i4++; + } + } + h2++; + let f2 = a2 + c2 - l2 + _2, v2 = Math.min(this._bufferService.cols, h2 - a2 + l2 + d2 - _2 - u2); + if (t3 || "" !== o2.slice(a2, h2).trim()) { + if (i3 && 0 === f2 && 32 !== n2.getCodePoint(0)) { + const t4 = r2.lines.get(e3[1] - 1); + if (t4 && n2.isWrapped && 32 !== t4.getCodePoint(this._bufferService.cols - 1)) { + const t5 = this._getWordAt([this._bufferService.cols - 1, e3[1] - 1], false, true, false); + if (t5) { + const e4 = this._bufferService.cols - t5.start; + f2 -= e4, v2 += e4; + } + } + } + if (s3 && f2 + v2 === this._bufferService.cols && 32 !== n2.getCodePoint(this._bufferService.cols - 1)) { + const t4 = r2.lines.get(e3[1] + 1); + if ((null == t4 ? void 0 : t4.isWrapped) && 32 !== t4.getCodePoint(0)) { + const t5 = this._getWordAt([0, e3[1] + 1], false, false, true); + t5 && (v2 += t5.length); + } + } + return { start: f2, length: v2 }; + } + } + _selectWordAt(e3, t3) { + const i3 = this._getWordAt(e3, t3); + if (i3) { + for (; i3.start < 0; ) i3.start += this._bufferService.cols, e3[1]--; + this._model.selectionStart = [i3.start, e3[1]], this._model.selectionStartLength = i3.length; + } + } + _selectToWordAt(e3) { + const t3 = this._getWordAt(e3, true); + if (t3) { + let i3 = e3[1]; + for (; t3.start < 0; ) t3.start += this._bufferService.cols, i3--; + if (!this._model.areSelectionValuesReversed()) for (; t3.start + t3.length > this._bufferService.cols; ) t3.length -= this._bufferService.cols, i3++; + this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? t3.start : t3.start + t3.length, i3]; + } + } + _isCharWordSeparator(e3) { + return 0 !== e3.getWidth() && this._optionsService.rawOptions.wordSeparator.indexOf(e3.getChars()) >= 0; + } + _selectLineAt(e3) { + const t3 = this._bufferService.buffer.getWrappedRangeForLine(e3), i3 = { start: { x: 0, y: t3.first }, end: { x: this._bufferService.cols - 1, y: t3.last } }; + this._model.selectionStart = [0, t3.first], this._model.selectionEnd = void 0, this._model.selectionStartLength = (0, _.getRangeLength)(i3, this._bufferService.cols); + } + }; + t2.SelectionService = g = s2([r(3, f.IBufferService), r(4, f.ICoreService), r(5, h.IMouseService), r(6, f.IOptionsService), r(7, h.IRenderService), r(8, h.ICoreBrowserService)], g); + }, 4725: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.IThemeService = t2.ICharacterJoinerService = t2.ISelectionService = t2.IRenderService = t2.IMouseService = t2.ICoreBrowserService = t2.ICharSizeService = void 0; + const s2 = i2(8343); + t2.ICharSizeService = (0, s2.createDecorator)("CharSizeService"), t2.ICoreBrowserService = (0, s2.createDecorator)("CoreBrowserService"), t2.IMouseService = (0, s2.createDecorator)("MouseService"), t2.IRenderService = (0, s2.createDecorator)("RenderService"), t2.ISelectionService = (0, s2.createDecorator)("SelectionService"), t2.ICharacterJoinerService = (0, s2.createDecorator)("CharacterJoinerService"), t2.IThemeService = (0, s2.createDecorator)("ThemeService"); + }, 6731: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.ThemeService = t2.DEFAULT_ANSI_COLORS = void 0; + const n = i2(7239), o = i2(8055), a = i2(8460), h = i2(844), c = i2(2585), l = o.css.toColor("#ffffff"), d = o.css.toColor("#000000"), _ = o.css.toColor("#ffffff"), u = o.css.toColor("#000000"), f = { css: "rgba(255, 255, 255, 0.3)", rgba: 4294967117 }; + t2.DEFAULT_ANSI_COLORS = Object.freeze((() => { + const e3 = [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")], t3 = [0, 95, 135, 175, 215, 255]; + for (let i3 = 0; i3 < 216; i3++) { + const s3 = t3[i3 / 36 % 6 | 0], r2 = t3[i3 / 6 % 6 | 0], n2 = t3[i3 % 6]; + e3.push({ css: o.channels.toCss(s3, r2, n2), rgba: o.channels.toRgba(s3, r2, n2) }); + } + for (let t4 = 0; t4 < 24; t4++) { + const i3 = 8 + 10 * t4; + e3.push({ css: o.channels.toCss(i3, i3, i3), rgba: o.channels.toRgba(i3, i3, i3) }); + } + return e3; + })()); + let v = t2.ThemeService = class extends h.Disposable { + get colors() { + return this._colors; + } + constructor(e3) { + super(), this._optionsService = e3, 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: l, background: d, cursor: _, cursorAccent: u, selectionForeground: void 0, selectionBackgroundTransparent: f, selectionBackgroundOpaque: o.color.blend(d, f), selectionInactiveBackgroundTransparent: f, selectionInactiveBackgroundOpaque: o.color.blend(d, f), ansi: t2.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(e3 = {}) { + const i3 = this._colors; + if (i3.foreground = p(e3.foreground, l), i3.background = p(e3.background, d), i3.cursor = p(e3.cursor, _), i3.cursorAccent = p(e3.cursorAccent, u), i3.selectionBackgroundTransparent = p(e3.selectionBackground, f), i3.selectionBackgroundOpaque = o.color.blend(i3.background, i3.selectionBackgroundTransparent), i3.selectionInactiveBackgroundTransparent = p(e3.selectionInactiveBackground, i3.selectionBackgroundTransparent), i3.selectionInactiveBackgroundOpaque = o.color.blend(i3.background, i3.selectionInactiveBackgroundTransparent), i3.selectionForeground = e3.selectionForeground ? p(e3.selectionForeground, o.NULL_COLOR) : void 0, i3.selectionForeground === o.NULL_COLOR && (i3.selectionForeground = void 0), o.color.isOpaque(i3.selectionBackgroundTransparent)) { + const e4 = 0.3; + i3.selectionBackgroundTransparent = o.color.opacity(i3.selectionBackgroundTransparent, e4); + } + if (o.color.isOpaque(i3.selectionInactiveBackgroundTransparent)) { + const e4 = 0.3; + i3.selectionInactiveBackgroundTransparent = o.color.opacity(i3.selectionInactiveBackgroundTransparent, e4); + } + if (i3.ansi = t2.DEFAULT_ANSI_COLORS.slice(), i3.ansi[0] = p(e3.black, t2.DEFAULT_ANSI_COLORS[0]), i3.ansi[1] = p(e3.red, t2.DEFAULT_ANSI_COLORS[1]), i3.ansi[2] = p(e3.green, t2.DEFAULT_ANSI_COLORS[2]), i3.ansi[3] = p(e3.yellow, t2.DEFAULT_ANSI_COLORS[3]), i3.ansi[4] = p(e3.blue, t2.DEFAULT_ANSI_COLORS[4]), i3.ansi[5] = p(e3.magenta, t2.DEFAULT_ANSI_COLORS[5]), i3.ansi[6] = p(e3.cyan, t2.DEFAULT_ANSI_COLORS[6]), i3.ansi[7] = p(e3.white, t2.DEFAULT_ANSI_COLORS[7]), i3.ansi[8] = p(e3.brightBlack, t2.DEFAULT_ANSI_COLORS[8]), i3.ansi[9] = p(e3.brightRed, t2.DEFAULT_ANSI_COLORS[9]), i3.ansi[10] = p(e3.brightGreen, t2.DEFAULT_ANSI_COLORS[10]), i3.ansi[11] = p(e3.brightYellow, t2.DEFAULT_ANSI_COLORS[11]), i3.ansi[12] = p(e3.brightBlue, t2.DEFAULT_ANSI_COLORS[12]), i3.ansi[13] = p(e3.brightMagenta, t2.DEFAULT_ANSI_COLORS[13]), i3.ansi[14] = p(e3.brightCyan, t2.DEFAULT_ANSI_COLORS[14]), i3.ansi[15] = p(e3.brightWhite, t2.DEFAULT_ANSI_COLORS[15]), e3.extendedAnsi) { + const s3 = Math.min(i3.ansi.length - 16, e3.extendedAnsi.length); + for (let r2 = 0; r2 < s3; r2++) i3.ansi[r2 + 16] = p(e3.extendedAnsi[r2], t2.DEFAULT_ANSI_COLORS[r2 + 16]); + } + this._contrastCache.clear(), this._halfContrastCache.clear(), this._updateRestoreColors(), this._onChangeColors.fire(this.colors); + } + restoreColor(e3) { + this._restoreColor(e3), this._onChangeColors.fire(this.colors); + } + _restoreColor(e3) { + if (void 0 !== e3) switch (e3) { + 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[e3] = this._restoreColors.ansi[e3]; + } + else for (let e4 = 0; e4 < this._restoreColors.ansi.length; ++e4) this._colors.ansi[e4] = this._restoreColors.ansi[e4]; + } + modifyColors(e3) { + e3(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 p(e3, t3) { + if (void 0 !== e3) try { + return o.css.toColor(e3); + } catch (e4) { + } + return t3; + } + t2.ThemeService = v = s2([r(0, c.IOptionsService)], v); + }, 6349: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.CircularList = void 0; + const s2 = i2(8460), r = i2(844); + class n extends r.Disposable { + constructor(e3) { + super(), this._maxLength = e3, this.onDeleteEmitter = this.register(new s2.EventEmitter()), this.onDelete = this.onDeleteEmitter.event, this.onInsertEmitter = this.register(new s2.EventEmitter()), this.onInsert = this.onInsertEmitter.event, this.onTrimEmitter = this.register(new s2.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(e3) { + if (this._maxLength === e3) return; + const t3 = new Array(e3); + for (let i3 = 0; i3 < Math.min(e3, this.length); i3++) t3[i3] = this._array[this._getCyclicIndex(i3)]; + this._array = t3, this._maxLength = e3, this._startIndex = 0; + } + get length() { + return this._length; + } + set length(e3) { + if (e3 > this._length) for (let t3 = this._length; t3 < e3; t3++) this._array[t3] = void 0; + this._length = e3; + } + get(e3) { + return this._array[this._getCyclicIndex(e3)]; + } + set(e3, t3) { + this._array[this._getCyclicIndex(e3)] = t3; + } + push(e3) { + this._array[this._getCyclicIndex(this._length)] = e3, 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(e3, t3, ...i3) { + if (t3) { + for (let i4 = e3; i4 < this._length - t3; i4++) this._array[this._getCyclicIndex(i4)] = this._array[this._getCyclicIndex(i4 + t3)]; + this._length -= t3, this.onDeleteEmitter.fire({ index: e3, amount: t3 }); + } + for (let t4 = this._length - 1; t4 >= e3; t4--) this._array[this._getCyclicIndex(t4 + i3.length)] = this._array[this._getCyclicIndex(t4)]; + for (let t4 = 0; t4 < i3.length; t4++) this._array[this._getCyclicIndex(e3 + t4)] = i3[t4]; + if (i3.length && this.onInsertEmitter.fire({ index: e3, amount: i3.length }), this._length + i3.length > this._maxLength) { + const e4 = this._length + i3.length - this._maxLength; + this._startIndex += e4, this._length = this._maxLength, this.onTrimEmitter.fire(e4); + } else this._length += i3.length; + } + trimStart(e3) { + e3 > this._length && (e3 = this._length), this._startIndex += e3, this._length -= e3, this.onTrimEmitter.fire(e3); + } + shiftElements(e3, t3, i3) { + if (!(t3 <= 0)) { + if (e3 < 0 || e3 >= this._length) throw new Error("start argument out of range"); + if (e3 + i3 < 0) throw new Error("Cannot shift elements in list beyond index 0"); + if (i3 > 0) { + for (let s4 = t3 - 1; s4 >= 0; s4--) this.set(e3 + s4 + i3, this.get(e3 + s4)); + const s3 = e3 + t3 + i3 - this._length; + if (s3 > 0) for (this._length += s3; this._length > this._maxLength; ) this._length--, this._startIndex++, this.onTrimEmitter.fire(1); + } else for (let s3 = 0; s3 < t3; s3++) this.set(e3 + s3 + i3, this.get(e3 + s3)); + } + } + _getCyclicIndex(e3) { + return (this._startIndex + e3) % this._maxLength; + } + } + t2.CircularList = n; + }, 1439: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.clone = void 0, t2.clone = function e3(t3, i2 = 5) { + if ("object" != typeof t3) return t3; + const s2 = Array.isArray(t3) ? [] : {}; + for (const r in t3) s2[r] = i2 <= 1 ? t3[r] : t3[r] && e3(t3[r], i2 - 1); + return s2; + }; + }, 8055: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.contrastRatio = t2.toPaddedHex = t2.rgba = t2.rgb = t2.css = t2.color = t2.channels = t2.NULL_COLOR = void 0; + const s2 = i2(6114); + let r = 0, n = 0, o = 0, a = 0; + var h, c, l, d, _; + function u(e3) { + const t3 = e3.toString(16); + return t3.length < 2 ? "0" + t3 : t3; + } + function f(e3, t3) { + return e3 < t3 ? (t3 + 0.05) / (e3 + 0.05) : (e3 + 0.05) / (t3 + 0.05); + } + t2.NULL_COLOR = { css: "#00000000", rgba: 0 }, (function(e3) { + e3.toCss = function(e4, t3, i3, s3) { + return void 0 !== s3 ? `#${u(e4)}${u(t3)}${u(i3)}${u(s3)}` : `#${u(e4)}${u(t3)}${u(i3)}`; + }, e3.toRgba = function(e4, t3, i3, s3 = 255) { + return (e4 << 24 | t3 << 16 | i3 << 8 | s3) >>> 0; + }; + })(h || (t2.channels = h = {})), (function(e3) { + function t3(e4, t4) { + return a = Math.round(255 * t4), [r, n, o] = _.toChannels(e4.rgba), { css: h.toCss(r, n, o, a), rgba: h.toRgba(r, n, o, a) }; + } + e3.blend = function(e4, t4) { + if (a = (255 & t4.rgba) / 255, 1 === a) return { css: t4.css, rgba: t4.rgba }; + const i3 = t4.rgba >> 24 & 255, s3 = t4.rgba >> 16 & 255, c2 = t4.rgba >> 8 & 255, l2 = e4.rgba >> 24 & 255, d2 = e4.rgba >> 16 & 255, _2 = e4.rgba >> 8 & 255; + return r = l2 + Math.round((i3 - l2) * a), n = d2 + Math.round((s3 - d2) * a), o = _2 + Math.round((c2 - _2) * a), { css: h.toCss(r, n, o), rgba: h.toRgba(r, n, o) }; + }, e3.isOpaque = function(e4) { + return 255 == (255 & e4.rgba); + }, e3.ensureContrastRatio = function(e4, t4, i3) { + const s3 = _.ensureContrastRatio(e4.rgba, t4.rgba, i3); + if (s3) return _.toColor(s3 >> 24 & 255, s3 >> 16 & 255, s3 >> 8 & 255); + }, e3.opaque = function(e4) { + const t4 = (255 | e4.rgba) >>> 0; + return [r, n, o] = _.toChannels(t4), { css: h.toCss(r, n, o), rgba: t4 }; + }, e3.opacity = t3, e3.multiplyOpacity = function(e4, i3) { + return a = 255 & e4.rgba, t3(e4, a * i3 / 255); + }, e3.toColorRGB = function(e4) { + return [e4.rgba >> 24 & 255, e4.rgba >> 16 & 255, e4.rgba >> 8 & 255]; + }; + })(c || (t2.color = c = {})), (function(e3) { + let t3, i3; + if (!s2.isNode) { + const e4 = document.createElement("canvas"); + e4.width = 1, e4.height = 1; + const s3 = e4.getContext("2d", { willReadFrequently: true }); + s3 && (t3 = s3, t3.globalCompositeOperation = "copy", i3 = t3.createLinearGradient(0, 0, 1, 1)); + } + e3.toColor = function(e4) { + if (e4.match(/#[\da-f]{3,8}/i)) switch (e4.length) { + case 4: + return r = parseInt(e4.slice(1, 2).repeat(2), 16), n = parseInt(e4.slice(2, 3).repeat(2), 16), o = parseInt(e4.slice(3, 4).repeat(2), 16), _.toColor(r, n, o); + case 5: + return r = parseInt(e4.slice(1, 2).repeat(2), 16), n = parseInt(e4.slice(2, 3).repeat(2), 16), o = parseInt(e4.slice(3, 4).repeat(2), 16), a = parseInt(e4.slice(4, 5).repeat(2), 16), _.toColor(r, n, o, a); + case 7: + return { css: e4, rgba: (parseInt(e4.slice(1), 16) << 8 | 255) >>> 0 }; + case 9: + return { css: e4, rgba: parseInt(e4.slice(1), 16) >>> 0 }; + } + const s3 = e4.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/); + if (s3) return r = parseInt(s3[1]), n = parseInt(s3[2]), o = parseInt(s3[3]), a = Math.round(255 * (void 0 === s3[5] ? 1 : parseFloat(s3[5]))), _.toColor(r, n, o, a); + if (!t3 || !i3) throw new Error("css.toColor: Unsupported css format"); + if (t3.fillStyle = i3, t3.fillStyle = e4, "string" != typeof t3.fillStyle) throw new Error("css.toColor: Unsupported css format"); + if (t3.fillRect(0, 0, 1, 1), [r, n, o, a] = t3.getImageData(0, 0, 1, 1).data, 255 !== a) throw new Error("css.toColor: Unsupported css format"); + return { rgba: h.toRgba(r, n, o, a), css: e4 }; + }; + })(l || (t2.css = l = {})), (function(e3) { + function t3(e4, t4, i3) { + const s3 = e4 / 255, r2 = t4 / 255, n2 = i3 / 255; + return 0.2126 * (s3 <= 0.03928 ? s3 / 12.92 : Math.pow((s3 + 0.055) / 1.055, 2.4)) + 0.7152 * (r2 <= 0.03928 ? r2 / 12.92 : Math.pow((r2 + 0.055) / 1.055, 2.4)) + 0.0722 * (n2 <= 0.03928 ? n2 / 12.92 : Math.pow((n2 + 0.055) / 1.055, 2.4)); + } + e3.relativeLuminance = function(e4) { + return t3(e4 >> 16 & 255, e4 >> 8 & 255, 255 & e4); + }, e3.relativeLuminance2 = t3; + })(d || (t2.rgb = d = {})), (function(e3) { + function t3(e4, t4, i4) { + const s3 = e4 >> 24 & 255, r2 = e4 >> 16 & 255, n2 = e4 >> 8 & 255; + let o2 = t4 >> 24 & 255, a2 = t4 >> 16 & 255, h2 = t4 >> 8 & 255, c2 = f(d.relativeLuminance2(o2, a2, h2), d.relativeLuminance2(s3, r2, n2)); + for (; c2 < i4 && (o2 > 0 || a2 > 0 || h2 > 0); ) o2 -= Math.max(0, Math.ceil(0.1 * o2)), a2 -= Math.max(0, Math.ceil(0.1 * a2)), h2 -= Math.max(0, Math.ceil(0.1 * h2)), c2 = f(d.relativeLuminance2(o2, a2, h2), d.relativeLuminance2(s3, r2, n2)); + return (o2 << 24 | a2 << 16 | h2 << 8 | 255) >>> 0; + } + function i3(e4, t4, i4) { + const s3 = e4 >> 24 & 255, r2 = e4 >> 16 & 255, n2 = e4 >> 8 & 255; + let o2 = t4 >> 24 & 255, a2 = t4 >> 16 & 255, h2 = t4 >> 8 & 255, c2 = f(d.relativeLuminance2(o2, a2, h2), d.relativeLuminance2(s3, r2, n2)); + for (; c2 < i4 && (o2 < 255 || a2 < 255 || h2 < 255); ) o2 = Math.min(255, o2 + Math.ceil(0.1 * (255 - o2))), a2 = Math.min(255, a2 + Math.ceil(0.1 * (255 - a2))), h2 = Math.min(255, h2 + Math.ceil(0.1 * (255 - h2))), c2 = f(d.relativeLuminance2(o2, a2, h2), d.relativeLuminance2(s3, r2, n2)); + return (o2 << 24 | a2 << 16 | h2 << 8 | 255) >>> 0; + } + e3.ensureContrastRatio = function(e4, s3, r2) { + const n2 = d.relativeLuminance(e4 >> 8), o2 = d.relativeLuminance(s3 >> 8); + if (f(n2, o2) < r2) { + if (o2 < n2) { + const o3 = t3(e4, s3, r2), a3 = f(n2, d.relativeLuminance(o3 >> 8)); + if (a3 < r2) { + const t4 = i3(e4, s3, r2); + return a3 > f(n2, d.relativeLuminance(t4 >> 8)) ? o3 : t4; + } + return o3; + } + const a2 = i3(e4, s3, r2), h2 = f(n2, d.relativeLuminance(a2 >> 8)); + if (h2 < r2) { + const i4 = t3(e4, s3, r2); + return h2 > f(n2, d.relativeLuminance(i4 >> 8)) ? a2 : i4; + } + return a2; + } + }, e3.reduceLuminance = t3, e3.increaseLuminance = i3, e3.toChannels = function(e4) { + return [e4 >> 24 & 255, e4 >> 16 & 255, e4 >> 8 & 255, 255 & e4]; + }, e3.toColor = function(e4, t4, i4, s3) { + return { css: h.toCss(e4, t4, i4, s3), rgba: h.toRgba(e4, t4, i4, s3) }; + }; + })(_ || (t2.rgba = _ = {})), t2.toPaddedHex = u, t2.contrastRatio = f; + }, 8969: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreTerminal = void 0; + const s2 = i2(844), r = i2(2585), n = i2(4348), o = i2(7866), a = i2(744), h = i2(7302), c = i2(6975), l = i2(8460), d = i2(1753), _ = i2(1480), u = i2(7994), f = i2(9282), v = i2(5435), p = i2(5981), g = i2(2660); + let m = false; + class S2 extends s2.Disposable { + get onScroll() { + return this._onScrollApi || (this._onScrollApi = this.register(new l.EventEmitter()), this._onScroll.event(((e3) => { + var t3; + null === (t3 = this._onScrollApi) || void 0 === t3 || t3.fire(e3.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(e3) { + for (const t3 in e3) this.optionsService.options[t3] = e3[t3]; + } + constructor(e3) { + super(), this._windowsWrappingHeuristics = this.register(new s2.MutableDisposable()), this._onBinary = this.register(new l.EventEmitter()), this.onBinary = this._onBinary.event, this._onData = this.register(new l.EventEmitter()), this.onData = this._onData.event, this._onLineFeed = this.register(new l.EventEmitter()), this.onLineFeed = this._onLineFeed.event, this._onResize = this.register(new l.EventEmitter()), this.onResize = this._onResize.event, this._onWriteParsed = this.register(new l.EventEmitter()), this.onWriteParsed = this._onWriteParsed.event, this._onScroll = this.register(new l.EventEmitter()), this._instantiationService = new n.InstantiationService(), this.optionsService = this.register(new h.OptionsService(e3)), 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(c.CoreService)), this._instantiationService.setService(r.ICoreService, this.coreService), this.coreMouseService = this.register(this._instantiationService.createInstance(d.CoreMouseService)), this._instantiationService.setService(r.ICoreMouseService, this.coreMouseService), this.unicodeService = this.register(this._instantiationService.createInstance(_.UnicodeService)), this._instantiationService.setService(r.IUnicodeService, this.unicodeService), this._charsetService = this._instantiationService.createInstance(u.CharsetService), this._instantiationService.setService(r.ICharsetService, this._charsetService), this._oscLinkService = this._instantiationService.createInstance(g.OscLinkService), this._instantiationService.setService(r.IOscLinkService, this._oscLinkService), this._inputHandler = this.register(new v.InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService)), this.register((0, l.forwardEvent)(this._inputHandler.onLineFeed, this._onLineFeed)), this.register(this._inputHandler), this.register((0, l.forwardEvent)(this._bufferService.onResize, this._onResize)), this.register((0, l.forwardEvent)(this.coreService.onData, this._onData)), this.register((0, l.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(((e4) => { + 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(((e4) => { + 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 p.WriteBuffer(((e4, t3) => this._inputHandler.parse(e4, t3)))), this.register((0, l.forwardEvent)(this._writeBuffer.onWriteParsed, this._onWriteParsed)); + } + write(e3, t3) { + this._writeBuffer.write(e3, t3); + } + writeSync(e3, t3) { + this._logService.logLevel <= r.LogLevelEnum.WARN && !m && (this._logService.warn("writeSync is unreliable and will be removed soon."), m = true), this._writeBuffer.writeSync(e3, t3); + } + resize(e3, t3) { + isNaN(e3) || isNaN(t3) || (e3 = Math.max(e3, a.MINIMUM_COLS), t3 = Math.max(t3, a.MINIMUM_ROWS), this._bufferService.resize(e3, t3)); + } + scroll(e3, t3 = false) { + this._bufferService.scroll(e3, t3); + } + scrollLines(e3, t3, i3) { + this._bufferService.scrollLines(e3, t3, i3); + } + scrollPages(e3) { + this.scrollLines(e3 * (this.rows - 1)); + } + scrollToTop() { + this.scrollLines(-this._bufferService.buffer.ydisp); + } + scrollToBottom() { + this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp); + } + scrollToLine(e3) { + const t3 = e3 - this._bufferService.buffer.ydisp; + 0 !== t3 && this.scrollLines(t3); + } + registerEscHandler(e3, t3) { + return this._inputHandler.registerEscHandler(e3, t3); + } + registerDcsHandler(e3, t3) { + return this._inputHandler.registerDcsHandler(e3, t3); + } + registerCsiHandler(e3, t3) { + return this._inputHandler.registerCsiHandler(e3, t3); + } + registerOscHandler(e3, t3) { + return this._inputHandler.registerOscHandler(e3, t3); + } + _setup() { + this._handleWindowsPtyOptionChange(); + } + reset() { + this._inputHandler.reset(), this._bufferService.reset(), this._charsetService.reset(), this.coreService.reset(), this.coreMouseService.reset(); + } + _handleWindowsPtyOptionChange() { + let e3 = false; + const t3 = this.optionsService.rawOptions.windowsPty; + t3 && void 0 !== t3.buildNumber && void 0 !== t3.buildNumber ? e3 = !!("conpty" === t3.backend && t3.buildNumber < 21376) : this.optionsService.rawOptions.windowsMode && (e3 = true), e3 ? this._enableWindowsWrappingHeuristics() : this._windowsWrappingHeuristics.clear(); + } + _enableWindowsWrappingHeuristics() { + if (!this._windowsWrappingHeuristics.value) { + const e3 = []; + e3.push(this.onLineFeed(f.updateWindowsModeWrappedState.bind(null, this._bufferService))), e3.push(this.registerCsiHandler({ final: "H" }, (() => ((0, f.updateWindowsModeWrappedState)(this._bufferService), false)))), this._windowsWrappingHeuristics.value = (0, s2.toDisposable)((() => { + for (const t3 of e3) t3.dispose(); + })); + } + } + } + t2.CoreTerminal = S2; + }, 8460: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.forwardEvent = t2.EventEmitter = void 0, t2.EventEmitter = class { + constructor() { + this._listeners = [], this._disposed = false; + } + get event() { + return this._event || (this._event = (e3) => (this._listeners.push(e3), { dispose: () => { + if (!this._disposed) { + for (let t3 = 0; t3 < this._listeners.length; t3++) if (this._listeners[t3] === e3) return void this._listeners.splice(t3, 1); + } + } })), this._event; + } + fire(e3, t3) { + const i2 = []; + for (let e4 = 0; e4 < this._listeners.length; e4++) i2.push(this._listeners[e4]); + for (let s2 = 0; s2 < i2.length; s2++) i2[s2].call(void 0, e3, t3); + } + dispose() { + this.clearListeners(), this._disposed = true; + } + clearListeners() { + this._listeners && (this._listeners.length = 0); + } + }, t2.forwardEvent = function(e3, t3) { + return e3(((e4) => t3.fire(e4))); + }; + }, 5435: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.InputHandler = t2.WindowsOptionsReportType = void 0; + const n = i2(2584), o = i2(7116), a = i2(2015), h = i2(844), c = i2(482), l = i2(8437), d = i2(8460), _ = i2(643), u = i2(511), f = i2(3734), v = i2(2585), p = i2(6242), g = i2(6351), m = i2(5941), S2 = { "(": 0, ")": 1, "*": 2, "+": 3, "-": 1, ".": 2 }, C = 131072; + function b(e3, t3) { + if (e3 > 24) return t3.setWinLines || false; + switch (e3) { + case 1: + return !!t3.restoreWin; + case 2: + return !!t3.minimizeWin; + case 3: + return !!t3.setWinPosition; + case 4: + return !!t3.setWinSizePixels; + case 5: + return !!t3.raiseWin; + case 6: + return !!t3.lowerWin; + case 7: + return !!t3.refreshWin; + case 8: + return !!t3.setWinSizeChars; + case 9: + return !!t3.maximizeWin; + case 10: + return !!t3.fullscreenWin; + case 11: + return !!t3.getWinState; + case 13: + return !!t3.getWinPosition; + case 14: + return !!t3.getWinSizePixels; + case 15: + return !!t3.getScreenSizePixels; + case 16: + return !!t3.getCellSizePixels; + case 18: + return !!t3.getWinSizeChars; + case 19: + return !!t3.getScreenSizeChars; + case 20: + return !!t3.getIconTitle; + case 21: + return !!t3.getWinTitle; + case 22: + return !!t3.pushTitle; + case 23: + return !!t3.popTitle; + case 24: + return !!t3.setWinLines; + } + return false; + } + var y; + !(function(e3) { + e3[e3.GET_WIN_SIZE_PIXELS = 0] = "GET_WIN_SIZE_PIXELS", e3[e3.GET_CELL_SIZE_PIXELS = 1] = "GET_CELL_SIZE_PIXELS"; + })(y || (t2.WindowsOptionsReportType = y = {})); + let w = 0; + class E extends h.Disposable { + getAttrData() { + return this._curAttrData; + } + constructor(e3, t3, i3, s3, r2, h2, _2, f2, v2 = new a.EscapeSequenceParser()) { + super(), this._bufferService = e3, this._charsetService = t3, this._coreService = i3, this._logService = s3, this._optionsService = r2, this._oscLinkService = h2, this._coreMouseService = _2, this._unicodeService = f2, this._parser = v2, this._parseBuffer = new Uint32Array(4096), this._stringDecoder = new c.StringToUtf32(), this._utf8Decoder = new c.Utf8ToUtf32(), this._workCell = new u.CellData(), this._windowTitle = "", this._iconName = "", this._windowTitleStack = [], this._iconNameStack = [], this._curAttrData = l.DEFAULT_ATTR_DATA.clone(), this._eraseAttrDataInternal = l.DEFAULT_ATTR_DATA.clone(), this._onRequestBell = this.register(new d.EventEmitter()), this.onRequestBell = this._onRequestBell.event, this._onRequestRefreshRows = this.register(new d.EventEmitter()), this.onRequestRefreshRows = this._onRequestRefreshRows.event, this._onRequestReset = this.register(new d.EventEmitter()), this.onRequestReset = this._onRequestReset.event, this._onRequestSendFocus = this.register(new d.EventEmitter()), this.onRequestSendFocus = this._onRequestSendFocus.event, this._onRequestSyncScrollBar = this.register(new d.EventEmitter()), this.onRequestSyncScrollBar = this._onRequestSyncScrollBar.event, this._onRequestWindowsOptionsReport = this.register(new d.EventEmitter()), this.onRequestWindowsOptionsReport = this._onRequestWindowsOptionsReport.event, this._onA11yChar = this.register(new d.EventEmitter()), this.onA11yChar = this._onA11yChar.event, this._onA11yTab = this.register(new d.EventEmitter()), this.onA11yTab = this._onA11yTab.event, this._onCursorMove = this.register(new d.EventEmitter()), this.onCursorMove = this._onCursorMove.event, this._onLineFeed = this.register(new d.EventEmitter()), this.onLineFeed = this._onLineFeed.event, this._onScroll = this.register(new d.EventEmitter()), this.onScroll = this._onScroll.event, this._onTitleChange = this.register(new d.EventEmitter()), this.onTitleChange = this._onTitleChange.event, this._onColor = this.register(new d.EventEmitter()), this.onColor = this._onColor.event, this._parseStack = { paused: false, 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(((e4) => this._activeBuffer = e4.activeBuffer))), this._parser.setCsiHandlerFallback(((e4, t4) => { + this._logService.debug("Unknown CSI code: ", { identifier: this._parser.identToString(e4), params: t4.toArray() }); + })), this._parser.setEscHandlerFallback(((e4) => { + this._logService.debug("Unknown ESC code: ", { identifier: this._parser.identToString(e4) }); + })), this._parser.setExecuteHandlerFallback(((e4) => { + this._logService.debug("Unknown EXECUTE code: ", { code: e4 }); + })), this._parser.setOscHandlerFallback(((e4, t4, i4) => { + this._logService.debug("Unknown OSC code: ", { identifier: e4, action: t4, data: i4 }); + })), this._parser.setDcsHandlerFallback(((e4, t4, i4) => { + "HOOK" === t4 && (i4 = i4.toArray()), this._logService.debug("Unknown DCS code: ", { identifier: this._parser.identToString(e4), action: t4, payload: i4 }); + })), this._parser.setPrintHandler(((e4, t4, i4) => this.print(e4, t4, i4))), this._parser.registerCsiHandler({ final: "@" }, ((e4) => this.insertChars(e4))), this._parser.registerCsiHandler({ intermediates: " ", final: "@" }, ((e4) => this.scrollLeft(e4))), this._parser.registerCsiHandler({ final: "A" }, ((e4) => this.cursorUp(e4))), this._parser.registerCsiHandler({ intermediates: " ", final: "A" }, ((e4) => this.scrollRight(e4))), this._parser.registerCsiHandler({ final: "B" }, ((e4) => this.cursorDown(e4))), this._parser.registerCsiHandler({ final: "C" }, ((e4) => this.cursorForward(e4))), this._parser.registerCsiHandler({ final: "D" }, ((e4) => this.cursorBackward(e4))), this._parser.registerCsiHandler({ final: "E" }, ((e4) => this.cursorNextLine(e4))), this._parser.registerCsiHandler({ final: "F" }, ((e4) => this.cursorPrecedingLine(e4))), this._parser.registerCsiHandler({ final: "G" }, ((e4) => this.cursorCharAbsolute(e4))), this._parser.registerCsiHandler({ final: "H" }, ((e4) => this.cursorPosition(e4))), this._parser.registerCsiHandler({ final: "I" }, ((e4) => this.cursorForwardTab(e4))), this._parser.registerCsiHandler({ final: "J" }, ((e4) => this.eraseInDisplay(e4, false))), this._parser.registerCsiHandler({ prefix: "?", final: "J" }, ((e4) => this.eraseInDisplay(e4, true))), this._parser.registerCsiHandler({ final: "K" }, ((e4) => this.eraseInLine(e4, false))), this._parser.registerCsiHandler({ prefix: "?", final: "K" }, ((e4) => this.eraseInLine(e4, true))), this._parser.registerCsiHandler({ final: "L" }, ((e4) => this.insertLines(e4))), this._parser.registerCsiHandler({ final: "M" }, ((e4) => this.deleteLines(e4))), this._parser.registerCsiHandler({ final: "P" }, ((e4) => this.deleteChars(e4))), this._parser.registerCsiHandler({ final: "S" }, ((e4) => this.scrollUp(e4))), this._parser.registerCsiHandler({ final: "T" }, ((e4) => this.scrollDown(e4))), this._parser.registerCsiHandler({ final: "X" }, ((e4) => this.eraseChars(e4))), this._parser.registerCsiHandler({ final: "Z" }, ((e4) => this.cursorBackwardTab(e4))), this._parser.registerCsiHandler({ final: "`" }, ((e4) => this.charPosAbsolute(e4))), this._parser.registerCsiHandler({ final: "a" }, ((e4) => this.hPositionRelative(e4))), this._parser.registerCsiHandler({ final: "b" }, ((e4) => this.repeatPrecedingCharacter(e4))), this._parser.registerCsiHandler({ final: "c" }, ((e4) => this.sendDeviceAttributesPrimary(e4))), this._parser.registerCsiHandler({ prefix: ">", final: "c" }, ((e4) => this.sendDeviceAttributesSecondary(e4))), this._parser.registerCsiHandler({ final: "d" }, ((e4) => this.linePosAbsolute(e4))), this._parser.registerCsiHandler({ final: "e" }, ((e4) => this.vPositionRelative(e4))), this._parser.registerCsiHandler({ final: "f" }, ((e4) => this.hVPosition(e4))), this._parser.registerCsiHandler({ final: "g" }, ((e4) => this.tabClear(e4))), this._parser.registerCsiHandler({ final: "h" }, ((e4) => this.setMode(e4))), this._parser.registerCsiHandler({ prefix: "?", final: "h" }, ((e4) => this.setModePrivate(e4))), this._parser.registerCsiHandler({ final: "l" }, ((e4) => this.resetMode(e4))), this._parser.registerCsiHandler({ prefix: "?", final: "l" }, ((e4) => this.resetModePrivate(e4))), this._parser.registerCsiHandler({ final: "m" }, ((e4) => this.charAttributes(e4))), this._parser.registerCsiHandler({ final: "n" }, ((e4) => this.deviceStatus(e4))), this._parser.registerCsiHandler({ prefix: "?", final: "n" }, ((e4) => this.deviceStatusPrivate(e4))), this._parser.registerCsiHandler({ intermediates: "!", final: "p" }, ((e4) => this.softReset(e4))), this._parser.registerCsiHandler({ intermediates: " ", final: "q" }, ((e4) => this.setCursorStyle(e4))), this._parser.registerCsiHandler({ final: "r" }, ((e4) => this.setScrollRegion(e4))), this._parser.registerCsiHandler({ final: "s" }, ((e4) => this.saveCursor(e4))), this._parser.registerCsiHandler({ final: "t" }, ((e4) => this.windowOptions(e4))), this._parser.registerCsiHandler({ final: "u" }, ((e4) => this.restoreCursor(e4))), this._parser.registerCsiHandler({ intermediates: "'", final: "}" }, ((e4) => this.insertColumns(e4))), this._parser.registerCsiHandler({ intermediates: "'", final: "~" }, ((e4) => this.deleteColumns(e4))), this._parser.registerCsiHandler({ intermediates: '"', final: "q" }, ((e4) => this.selectProtected(e4))), this._parser.registerCsiHandler({ intermediates: "$", final: "p" }, ((e4) => this.requestMode(e4, true))), this._parser.registerCsiHandler({ prefix: "?", intermediates: "$", final: "p" }, ((e4) => this.requestMode(e4, false))), 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 p.OscHandler(((e4) => (this.setTitle(e4), this.setIconName(e4), true)))), this._parser.registerOscHandler(1, new p.OscHandler(((e4) => this.setIconName(e4)))), this._parser.registerOscHandler(2, new p.OscHandler(((e4) => this.setTitle(e4)))), this._parser.registerOscHandler(4, new p.OscHandler(((e4) => this.setOrReportIndexedColor(e4)))), this._parser.registerOscHandler(8, new p.OscHandler(((e4) => this.setHyperlink(e4)))), this._parser.registerOscHandler(10, new p.OscHandler(((e4) => this.setOrReportFgColor(e4)))), this._parser.registerOscHandler(11, new p.OscHandler(((e4) => this.setOrReportBgColor(e4)))), this._parser.registerOscHandler(12, new p.OscHandler(((e4) => this.setOrReportCursorColor(e4)))), this._parser.registerOscHandler(104, new p.OscHandler(((e4) => this.restoreIndexedColor(e4)))), this._parser.registerOscHandler(110, new p.OscHandler(((e4) => this.restoreFgColor(e4)))), this._parser.registerOscHandler(111, new p.OscHandler(((e4) => this.restoreBgColor(e4)))), this._parser.registerOscHandler(112, new p.OscHandler(((e4) => this.restoreCursorColor(e4)))), 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 e4 in o.CHARSETS) this._parser.registerEscHandler({ intermediates: "(", final: e4 }, (() => this.selectCharset("(" + e4))), this._parser.registerEscHandler({ intermediates: ")", final: e4 }, (() => this.selectCharset(")" + e4))), this._parser.registerEscHandler({ intermediates: "*", final: e4 }, (() => this.selectCharset("*" + e4))), this._parser.registerEscHandler({ intermediates: "+", final: e4 }, (() => this.selectCharset("+" + e4))), this._parser.registerEscHandler({ intermediates: "-", final: e4 }, (() => this.selectCharset("-" + e4))), this._parser.registerEscHandler({ intermediates: ".", final: e4 }, (() => this.selectCharset("." + e4))), this._parser.registerEscHandler({ intermediates: "/", final: e4 }, (() => this.selectCharset("/" + e4))); + this._parser.registerEscHandler({ intermediates: "#", final: "8" }, (() => this.screenAlignmentPattern())), this._parser.setErrorHandler(((e4) => (this._logService.error("Parsing error: ", e4), e4))), this._parser.registerDcsHandler({ intermediates: "$", final: "q" }, new g.DcsHandler(((e4, t4) => this.requestStatusString(e4, t4)))); + } + _preserveStack(e3, t3, i3, s3) { + this._parseStack.paused = true, this._parseStack.cursorStartX = e3, this._parseStack.cursorStartY = t3, this._parseStack.decodedLength = i3, this._parseStack.position = s3; + } + _logSlowResolvingAsync(e3) { + this._logService.logLevel <= v.LogLevelEnum.WARN && Promise.race([e3, new Promise(((e4, t3) => setTimeout((() => t3("#SLOW_TIMEOUT")), 5e3)))]).catch(((e4) => { + if ("#SLOW_TIMEOUT" !== e4) throw e4; + console.warn("async parser handler taking longer than 5000 ms"); + })); + } + _getCurrentLinkId() { + return this._curAttrData.extended.urlId; + } + parse(e3, t3) { + let i3, s3 = this._activeBuffer.x, r2 = this._activeBuffer.y, n2 = 0; + const o2 = this._parseStack.paused; + if (o2) { + if (i3 = this._parser.parse(this._parseBuffer, this._parseStack.decodedLength, t3)) return this._logSlowResolvingAsync(i3), i3; + s3 = this._parseStack.cursorStartX, r2 = this._parseStack.cursorStartY, this._parseStack.paused = false, e3.length > C && (n2 = this._parseStack.position + C); + } + if (this._logService.logLevel <= v.LogLevelEnum.DEBUG && this._logService.debug("parsing data" + ("string" == typeof e3 ? ` "${e3}"` : ` "${Array.prototype.map.call(e3, ((e4) => String.fromCharCode(e4))).join("")}"`), "string" == typeof e3 ? e3.split("").map(((e4) => e4.charCodeAt(0))) : e3), this._parseBuffer.length < e3.length && this._parseBuffer.length < C && (this._parseBuffer = new Uint32Array(Math.min(e3.length, C))), o2 || this._dirtyRowTracker.clearRange(), e3.length > C) for (let t4 = n2; t4 < e3.length; t4 += C) { + const n3 = t4 + C < e3.length ? t4 + C : e3.length, o3 = "string" == typeof e3 ? this._stringDecoder.decode(e3.substring(t4, n3), this._parseBuffer) : this._utf8Decoder.decode(e3.subarray(t4, n3), this._parseBuffer); + if (i3 = this._parser.parse(this._parseBuffer, o3)) return this._preserveStack(s3, r2, o3, t4), this._logSlowResolvingAsync(i3), i3; + } + else if (!o2) { + const t4 = "string" == typeof e3 ? this._stringDecoder.decode(e3, this._parseBuffer) : this._utf8Decoder.decode(e3, this._parseBuffer); + if (i3 = this._parser.parse(this._parseBuffer, t4)) return this._preserveStack(s3, r2, t4, 0), this._logSlowResolvingAsync(i3), i3; + } + this._activeBuffer.x === s3 && this._activeBuffer.y === r2 || this._onCursorMove.fire(), this._onRequestRefreshRows.fire(this._dirtyRowTracker.start, this._dirtyRowTracker.end); + } + print(e3, t3, i3) { + let s3, r2; + const n2 = this._charsetService.charset, o2 = this._optionsService.rawOptions.screenReaderMode, a2 = this._bufferService.cols, h2 = this._coreService.decPrivateModes.wraparound, l2 = this._coreService.modes.insertMode, d2 = this._curAttrData; + let u2 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + this._dirtyRowTracker.markDirty(this._activeBuffer.y), this._activeBuffer.x && i3 - t3 > 0 && 2 === u2.getWidth(this._activeBuffer.x - 1) && u2.setCellFromCodePoint(this._activeBuffer.x - 1, 0, 1, d2.fg, d2.bg, d2.extended); + for (let f2 = t3; f2 < i3; ++f2) { + if (s3 = e3[f2], r2 = this._unicodeService.wcwidth(s3), s3 < 127 && n2) { + const e4 = n2[String.fromCharCode(s3)]; + e4 && (s3 = e4.charCodeAt(0)); + } + if (o2 && this._onA11yChar.fire((0, c.stringFromCodePoint)(s3)), this._getCurrentLinkId() && this._oscLinkService.addLineToLink(this._getCurrentLinkId(), this._activeBuffer.ybase + this._activeBuffer.y), r2 || !this._activeBuffer.x) { + if (this._activeBuffer.x + r2 - 1 >= a2) { + if (h2) { + for (; this._activeBuffer.x < a2; ) u2.setCellFromCodePoint(this._activeBuffer.x++, 0, 1, d2.fg, d2.bg, d2.extended); + this._activeBuffer.x = 0, this._activeBuffer.y++, this._activeBuffer.y === this._activeBuffer.scrollBottom + 1 ? (this._activeBuffer.y--, this._bufferService.scroll(this._eraseAttrData(), true)) : (this._activeBuffer.y >= this._bufferService.rows && (this._activeBuffer.y = this._bufferService.rows - 1), this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y).isWrapped = true), u2 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + } else if (this._activeBuffer.x = a2 - 1, 2 === r2) continue; + } + if (l2 && (u2.insertCells(this._activeBuffer.x, r2, this._activeBuffer.getNullCell(d2), d2), 2 === u2.getWidth(a2 - 1) && u2.setCellFromCodePoint(a2 - 1, _.NULL_CELL_CODE, _.NULL_CELL_WIDTH, d2.fg, d2.bg, d2.extended)), u2.setCellFromCodePoint(this._activeBuffer.x++, s3, r2, d2.fg, d2.bg, d2.extended), r2 > 0) for (; --r2; ) u2.setCellFromCodePoint(this._activeBuffer.x++, 0, 0, d2.fg, d2.bg, d2.extended); + } else u2.getWidth(this._activeBuffer.x - 1) ? u2.addCodepointToCell(this._activeBuffer.x - 1, s3) : u2.addCodepointToCell(this._activeBuffer.x - 2, s3); + } + i3 - t3 > 0 && (u2.loadCell(this._activeBuffer.x - 1, this._workCell), 2 === this._workCell.getWidth() || this._workCell.getCode() > 65535 ? this._parser.precedingCodepoint = 0 : this._workCell.isCombined() ? this._parser.precedingCodepoint = this._workCell.getChars().charCodeAt(0) : this._parser.precedingCodepoint = this._workCell.content), this._activeBuffer.x < a2 && i3 - t3 > 0 && 0 === u2.getWidth(this._activeBuffer.x) && !u2.hasContent(this._activeBuffer.x) && u2.setCellFromCodePoint(this._activeBuffer.x, 0, 1, d2.fg, d2.bg, d2.extended), this._dirtyRowTracker.markDirty(this._activeBuffer.y); + } + registerCsiHandler(e3, t3) { + return "t" !== e3.final || e3.prefix || e3.intermediates ? this._parser.registerCsiHandler(e3, t3) : this._parser.registerCsiHandler(e3, ((e4) => !b(e4.params[0], this._optionsService.rawOptions.windowOptions) || t3(e4))); + } + registerDcsHandler(e3, t3) { + return this._parser.registerDcsHandler(e3, new g.DcsHandler(t3)); + } + registerEscHandler(e3, t3) { + return this._parser.registerEscHandler(e3, t3); + } + registerOscHandler(e3, t3) { + return this._parser.registerOscHandler(e3, new p.OscHandler(t3)); + } + bell() { + return this._onRequestBell.fire(), true; + } + 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 = false, this._activeBuffer.x >= this._bufferService.cols && this._activeBuffer.x--, this._dirtyRowTracker.markDirty(this._activeBuffer.y), this._onLineFeed.fire(), true; + } + carriageReturn() { + return this._activeBuffer.x = 0, true; + } + backspace() { + var e3; + if (!this._coreService.decPrivateModes.reverseWraparound) return this._restrictCursor(), this._activeBuffer.x > 0 && this._activeBuffer.x--, true; + 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 && (null === (e3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)) || void 0 === e3 ? void 0 : e3.isWrapped)) { + this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y).isWrapped = false, this._activeBuffer.y--, this._activeBuffer.x = this._bufferService.cols - 1; + const e4 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + e4.hasWidth(this._activeBuffer.x) && !e4.hasContent(this._activeBuffer.x) && this._activeBuffer.x--; + } + return this._restrictCursor(), true; + } + tab() { + if (this._activeBuffer.x >= this._bufferService.cols) return true; + const e3 = this._activeBuffer.x; + return this._activeBuffer.x = this._activeBuffer.nextStop(), this._optionsService.rawOptions.screenReaderMode && this._onA11yTab.fire(this._activeBuffer.x - e3), true; + } + shiftOut() { + return this._charsetService.setgLevel(1), true; + } + shiftIn() { + return this._charsetService.setgLevel(0), true; + } + _restrictCursor(e3 = this._bufferService.cols - 1) { + this._activeBuffer.x = Math.min(e3, 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(e3, t3) { + this._dirtyRowTracker.markDirty(this._activeBuffer.y), this._coreService.decPrivateModes.origin ? (this._activeBuffer.x = e3, this._activeBuffer.y = this._activeBuffer.scrollTop + t3) : (this._activeBuffer.x = e3, this._activeBuffer.y = t3), this._restrictCursor(), this._dirtyRowTracker.markDirty(this._activeBuffer.y); + } + _moveCursor(e3, t3) { + this._restrictCursor(), this._setCursor(this._activeBuffer.x + e3, this._activeBuffer.y + t3); + } + cursorUp(e3) { + const t3 = this._activeBuffer.y - this._activeBuffer.scrollTop; + return t3 >= 0 ? this._moveCursor(0, -Math.min(t3, e3.params[0] || 1)) : this._moveCursor(0, -(e3.params[0] || 1)), true; + } + cursorDown(e3) { + const t3 = this._activeBuffer.scrollBottom - this._activeBuffer.y; + return t3 >= 0 ? this._moveCursor(0, Math.min(t3, e3.params[0] || 1)) : this._moveCursor(0, e3.params[0] || 1), true; + } + cursorForward(e3) { + return this._moveCursor(e3.params[0] || 1, 0), true; + } + cursorBackward(e3) { + return this._moveCursor(-(e3.params[0] || 1), 0), true; + } + cursorNextLine(e3) { + return this.cursorDown(e3), this._activeBuffer.x = 0, true; + } + cursorPrecedingLine(e3) { + return this.cursorUp(e3), this._activeBuffer.x = 0, true; + } + cursorCharAbsolute(e3) { + return this._setCursor((e3.params[0] || 1) - 1, this._activeBuffer.y), true; + } + cursorPosition(e3) { + return this._setCursor(e3.length >= 2 ? (e3.params[1] || 1) - 1 : 0, (e3.params[0] || 1) - 1), true; + } + charPosAbsolute(e3) { + return this._setCursor((e3.params[0] || 1) - 1, this._activeBuffer.y), true; + } + hPositionRelative(e3) { + return this._moveCursor(e3.params[0] || 1, 0), true; + } + linePosAbsolute(e3) { + return this._setCursor(this._activeBuffer.x, (e3.params[0] || 1) - 1), true; + } + vPositionRelative(e3) { + return this._moveCursor(0, e3.params[0] || 1), true; + } + hVPosition(e3) { + return this.cursorPosition(e3), true; + } + tabClear(e3) { + const t3 = e3.params[0]; + return 0 === t3 ? delete this._activeBuffer.tabs[this._activeBuffer.x] : 3 === t3 && (this._activeBuffer.tabs = {}), true; + } + cursorForwardTab(e3) { + if (this._activeBuffer.x >= this._bufferService.cols) return true; + let t3 = e3.params[0] || 1; + for (; t3--; ) this._activeBuffer.x = this._activeBuffer.nextStop(); + return true; + } + cursorBackwardTab(e3) { + if (this._activeBuffer.x >= this._bufferService.cols) return true; + let t3 = e3.params[0] || 1; + for (; t3--; ) this._activeBuffer.x = this._activeBuffer.prevStop(); + return true; + } + selectProtected(e3) { + const t3 = e3.params[0]; + return 1 === t3 && (this._curAttrData.bg |= 536870912), 2 !== t3 && 0 !== t3 || (this._curAttrData.bg &= -536870913), true; + } + _eraseInBufferLine(e3, t3, i3, s3 = false, r2 = false) { + const n2 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e3); + n2.replaceCells(t3, i3, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData(), r2), s3 && (n2.isWrapped = false); + } + _resetBufferLine(e3, t3 = false) { + const i3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e3); + i3 && (i3.fill(this._activeBuffer.getNullCell(this._eraseAttrData()), t3), this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase + e3), i3.isWrapped = false); + } + eraseInDisplay(e3, t3 = false) { + let i3; + switch (this._restrictCursor(this._bufferService.cols), e3.params[0]) { + case 0: + for (i3 = this._activeBuffer.y, this._dirtyRowTracker.markDirty(i3), this._eraseInBufferLine(i3++, this._activeBuffer.x, this._bufferService.cols, 0 === this._activeBuffer.x, t3); i3 < this._bufferService.rows; i3++) this._resetBufferLine(i3, t3); + this._dirtyRowTracker.markDirty(i3); + break; + case 1: + for (i3 = this._activeBuffer.y, this._dirtyRowTracker.markDirty(i3), this._eraseInBufferLine(i3, 0, this._activeBuffer.x + 1, true, t3), this._activeBuffer.x + 1 >= this._bufferService.cols && (this._activeBuffer.lines.get(i3 + 1).isWrapped = false); i3--; ) this._resetBufferLine(i3, t3); + this._dirtyRowTracker.markDirty(0); + break; + case 2: + for (i3 = this._bufferService.rows, this._dirtyRowTracker.markDirty(i3 - 1); i3--; ) this._resetBufferLine(i3, t3); + this._dirtyRowTracker.markDirty(0); + break; + case 3: + const e4 = this._activeBuffer.lines.length - this._bufferService.rows; + e4 > 0 && (this._activeBuffer.lines.trimStart(e4), this._activeBuffer.ybase = Math.max(this._activeBuffer.ybase - e4, 0), this._activeBuffer.ydisp = Math.max(this._activeBuffer.ydisp - e4, 0), this._onScroll.fire(0)); + } + return true; + } + eraseInLine(e3, t3 = false) { + switch (this._restrictCursor(this._bufferService.cols), e3.params[0]) { + case 0: + this._eraseInBufferLine(this._activeBuffer.y, this._activeBuffer.x, this._bufferService.cols, 0 === this._activeBuffer.x, t3); + break; + case 1: + this._eraseInBufferLine(this._activeBuffer.y, 0, this._activeBuffer.x + 1, false, t3); + break; + case 2: + this._eraseInBufferLine(this._activeBuffer.y, 0, this._bufferService.cols, true, t3); + } + return this._dirtyRowTracker.markDirty(this._activeBuffer.y), true; + } + insertLines(e3) { + this._restrictCursor(); + let t3 = e3.params[0] || 1; + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const i3 = this._activeBuffer.ybase + this._activeBuffer.y, s3 = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom, r2 = this._bufferService.rows - 1 + this._activeBuffer.ybase - s3 + 1; + for (; t3--; ) this._activeBuffer.lines.splice(r2 - 1, 1), this._activeBuffer.lines.splice(i3, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom), this._activeBuffer.x = 0, true; + } + deleteLines(e3) { + this._restrictCursor(); + let t3 = e3.params[0] || 1; + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const i3 = this._activeBuffer.ybase + this._activeBuffer.y; + let s3; + for (s3 = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom, s3 = this._bufferService.rows - 1 + this._activeBuffer.ybase - s3; t3--; ) this._activeBuffer.lines.splice(i3, 1), this._activeBuffer.lines.splice(s3, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom), this._activeBuffer.x = 0, true; + } + insertChars(e3) { + this._restrictCursor(); + const t3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + return t3 && (t3.insertCells(this._activeBuffer.x, e3.params[0] || 1, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), this._dirtyRowTracker.markDirty(this._activeBuffer.y)), true; + } + deleteChars(e3) { + this._restrictCursor(); + const t3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + return t3 && (t3.deleteCells(this._activeBuffer.x, e3.params[0] || 1, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), this._dirtyRowTracker.markDirty(this._activeBuffer.y)), true; + } + scrollUp(e3) { + let t3 = e3.params[0] || 1; + for (; t3--; ) 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), true; + } + scrollDown(e3) { + let t3 = e3.params[0] || 1; + for (; t3--; ) 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(l.DEFAULT_ATTR_DATA)); + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom), true; + } + scrollLeft(e3) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const t3 = e3.params[0] || 1; + for (let e4 = this._activeBuffer.scrollTop; e4 <= this._activeBuffer.scrollBottom; ++e4) { + const i3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e4); + i3.deleteCells(0, t3, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), i3.isWrapped = false; + } + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom), true; + } + scrollRight(e3) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const t3 = e3.params[0] || 1; + for (let e4 = this._activeBuffer.scrollTop; e4 <= this._activeBuffer.scrollBottom; ++e4) { + const i3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e4); + i3.insertCells(0, t3, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), i3.isWrapped = false; + } + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom), true; + } + insertColumns(e3) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const t3 = e3.params[0] || 1; + for (let e4 = this._activeBuffer.scrollTop; e4 <= this._activeBuffer.scrollBottom; ++e4) { + const i3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e4); + i3.insertCells(this._activeBuffer.x, t3, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), i3.isWrapped = false; + } + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom), true; + } + deleteColumns(e3) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) return true; + const t3 = e3.params[0] || 1; + for (let e4 = this._activeBuffer.scrollTop; e4 <= this._activeBuffer.scrollBottom; ++e4) { + const i3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + e4); + i3.deleteCells(this._activeBuffer.x, t3, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), i3.isWrapped = false; + } + return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom), true; + } + eraseChars(e3) { + this._restrictCursor(); + const t3 = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); + return t3 && (t3.replaceCells(this._activeBuffer.x, this._activeBuffer.x + (e3.params[0] || 1), this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()), this._dirtyRowTracker.markDirty(this._activeBuffer.y)), true; + } + repeatPrecedingCharacter(e3) { + if (!this._parser.precedingCodepoint) return true; + const t3 = e3.params[0] || 1, i3 = new Uint32Array(t3); + for (let e4 = 0; e4 < t3; ++e4) i3[e4] = this._parser.precedingCodepoint; + return this.print(i3, 0, i3.length), true; + } + sendDeviceAttributesPrimary(e3) { + return e3.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")), true; + } + sendDeviceAttributesSecondary(e3) { + return e3.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(e3.params[0] + "c") : this._is("screen") && this._coreService.triggerDataEvent(n.C0.ESC + "[>83;40003;0c")), true; + } + _is(e3) { + return 0 === (this._optionsService.rawOptions.termName + "").indexOf(e3); + } + setMode(e3) { + for (let t3 = 0; t3 < e3.length; t3++) switch (e3.params[t3]) { + case 4: + this._coreService.modes.insertMode = true; + break; + case 20: + this._optionsService.options.convertEol = true; + } + return true; + } + setModePrivate(e3) { + for (let t3 = 0; t3 < e3.length; t3++) switch (e3.params[t3]) { + case 1: + this._coreService.decPrivateModes.applicationCursorKeys = true; + 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 = true, this._setCursor(0, 0); + break; + case 7: + this._coreService.decPrivateModes.wraparound = true; + break; + case 12: + this._optionsService.options.cursorBlink = true; + break; + case 45: + this._coreService.decPrivateModes.reverseWraparound = true; + break; + case 66: + this._logService.debug("Serial port requested application keypad."), this._coreService.decPrivateModes.applicationKeypad = true, 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 = true, 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 = false; + break; + case 1048: + this.saveCursor(); + break; + case 1049: + this.saveCursor(); + case 47: + case 1047: + this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()), this._coreService.isCursorInitialized = true, this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1), this._onRequestSyncScrollBar.fire(); + break; + case 2004: + this._coreService.decPrivateModes.bracketedPasteMode = true; + } + return true; + } + resetMode(e3) { + for (let t3 = 0; t3 < e3.length; t3++) switch (e3.params[t3]) { + case 4: + this._coreService.modes.insertMode = false; + break; + case 20: + this._optionsService.options.convertEol = false; + } + return true; + } + resetModePrivate(e3) { + for (let t3 = 0; t3 < e3.length; t3++) switch (e3.params[t3]) { + case 1: + this._coreService.decPrivateModes.applicationCursorKeys = false; + 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 = false, this._setCursor(0, 0); + break; + case 7: + this._coreService.decPrivateModes.wraparound = false; + break; + case 12: + this._optionsService.options.cursorBlink = false; + break; + case 45: + this._coreService.decPrivateModes.reverseWraparound = false; + break; + case 66: + this._logService.debug("Switching back to normal keypad."), this._coreService.decPrivateModes.applicationKeypad = false, this._onRequestSyncScrollBar.fire(); + break; + case 9: + case 1e3: + case 1002: + case 1003: + this._coreMouseService.activeProtocol = "NONE"; + break; + case 1004: + this._coreService.decPrivateModes.sendFocus = false; + 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 = true; + break; + case 1048: + this.restoreCursor(); + break; + case 1049: + case 47: + case 1047: + this._bufferService.buffers.activateNormalBuffer(), 1049 === e3.params[t3] && this.restoreCursor(), this._coreService.isCursorInitialized = true, this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1), this._onRequestSyncScrollBar.fire(); + break; + case 2004: + this._coreService.decPrivateModes.bracketedPasteMode = false; + } + return true; + } + requestMode(e3, t3) { + const i3 = this._coreService.decPrivateModes, { activeProtocol: s3, activeEncoding: r2 } = this._coreMouseService, o2 = this._coreService, { buffers: a2, cols: h2 } = this._bufferService, { active: c2, alt: l2 } = a2, d2 = this._optionsService.rawOptions, _2 = (e4) => e4 ? 1 : 2, u2 = e3.params[0]; + return f2 = u2, v2 = t3 ? 2 === u2 ? 4 : 4 === u2 ? _2(o2.modes.insertMode) : 12 === u2 ? 3 : 20 === u2 ? _2(d2.convertEol) : 0 : 1 === u2 ? _2(i3.applicationCursorKeys) : 3 === u2 ? d2.windowOptions.setWinLines ? 80 === h2 ? 2 : 132 === h2 ? 1 : 0 : 0 : 6 === u2 ? _2(i3.origin) : 7 === u2 ? _2(i3.wraparound) : 8 === u2 ? 3 : 9 === u2 ? _2("X10" === s3) : 12 === u2 ? _2(d2.cursorBlink) : 25 === u2 ? _2(!o2.isCursorHidden) : 45 === u2 ? _2(i3.reverseWraparound) : 66 === u2 ? _2(i3.applicationKeypad) : 67 === u2 ? 4 : 1e3 === u2 ? _2("VT200" === s3) : 1002 === u2 ? _2("DRAG" === s3) : 1003 === u2 ? _2("ANY" === s3) : 1004 === u2 ? _2(i3.sendFocus) : 1005 === u2 ? 4 : 1006 === u2 ? _2("SGR" === r2) : 1015 === u2 ? 4 : 1016 === u2 ? _2("SGR_PIXELS" === r2) : 1048 === u2 ? 1 : 47 === u2 || 1047 === u2 || 1049 === u2 ? _2(c2 === l2) : 2004 === u2 ? _2(i3.bracketedPasteMode) : 0, o2.triggerDataEvent(`${n.C0.ESC}[${t3 ? "" : "?"}${f2};${v2}$y`), true; + var f2, v2; + } + _updateAttrColor(e3, t3, i3, s3, r2) { + return 2 === t3 ? (e3 |= 50331648, e3 &= -16777216, e3 |= f.AttributeData.fromColorRGB([i3, s3, r2])) : 5 === t3 && (e3 &= -50331904, e3 |= 33554432 | 255 & i3), e3; + } + _extractColor(e3, t3, i3) { + const s3 = [0, 0, -1, 0, 0, 0]; + let r2 = 0, n2 = 0; + do { + if (s3[n2 + r2] = e3.params[t3 + n2], e3.hasSubParams(t3 + n2)) { + const i4 = e3.getSubParams(t3 + n2); + let o2 = 0; + do { + 5 === s3[1] && (r2 = 1), s3[n2 + o2 + 1 + r2] = i4[o2]; + } while (++o2 < i4.length && o2 + n2 + 1 + r2 < s3.length); + break; + } + if (5 === s3[1] && n2 + r2 >= 2 || 2 === s3[1] && n2 + r2 >= 5) break; + s3[1] && (r2 = 1); + } while (++n2 + t3 < e3.length && n2 + r2 < s3.length); + for (let e4 = 2; e4 < s3.length; ++e4) -1 === s3[e4] && (s3[e4] = 0); + switch (s3[0]) { + case 38: + i3.fg = this._updateAttrColor(i3.fg, s3[1], s3[3], s3[4], s3[5]); + break; + case 48: + i3.bg = this._updateAttrColor(i3.bg, s3[1], s3[3], s3[4], s3[5]); + break; + case 58: + i3.extended = i3.extended.clone(), i3.extended.underlineColor = this._updateAttrColor(i3.extended.underlineColor, s3[1], s3[3], s3[4], s3[5]); + } + return n2; + } + _processUnderline(e3, t3) { + t3.extended = t3.extended.clone(), (!~e3 || e3 > 5) && (e3 = 1), t3.extended.underlineStyle = e3, t3.fg |= 268435456, 0 === e3 && (t3.fg &= -268435457), t3.updateExtended(); + } + _processSGR0(e3) { + e3.fg = l.DEFAULT_ATTR_DATA.fg, e3.bg = l.DEFAULT_ATTR_DATA.bg, e3.extended = e3.extended.clone(), e3.extended.underlineStyle = 0, e3.extended.underlineColor &= -67108864, e3.updateExtended(); + } + charAttributes(e3) { + if (1 === e3.length && 0 === e3.params[0]) return this._processSGR0(this._curAttrData), true; + const t3 = e3.length; + let i3; + const s3 = this._curAttrData; + for (let r2 = 0; r2 < t3; r2++) i3 = e3.params[r2], i3 >= 30 && i3 <= 37 ? (s3.fg &= -50331904, s3.fg |= 16777216 | i3 - 30) : i3 >= 40 && i3 <= 47 ? (s3.bg &= -50331904, s3.bg |= 16777216 | i3 - 40) : i3 >= 90 && i3 <= 97 ? (s3.fg &= -50331904, s3.fg |= 16777224 | i3 - 90) : i3 >= 100 && i3 <= 107 ? (s3.bg &= -50331904, s3.bg |= 16777224 | i3 - 100) : 0 === i3 ? this._processSGR0(s3) : 1 === i3 ? s3.fg |= 134217728 : 3 === i3 ? s3.bg |= 67108864 : 4 === i3 ? (s3.fg |= 268435456, this._processUnderline(e3.hasSubParams(r2) ? e3.getSubParams(r2)[0] : 1, s3)) : 5 === i3 ? s3.fg |= 536870912 : 7 === i3 ? s3.fg |= 67108864 : 8 === i3 ? s3.fg |= 1073741824 : 9 === i3 ? s3.fg |= 2147483648 : 2 === i3 ? s3.bg |= 134217728 : 21 === i3 ? this._processUnderline(2, s3) : 22 === i3 ? (s3.fg &= -134217729, s3.bg &= -134217729) : 23 === i3 ? s3.bg &= -67108865 : 24 === i3 ? (s3.fg &= -268435457, this._processUnderline(0, s3)) : 25 === i3 ? s3.fg &= -536870913 : 27 === i3 ? s3.fg &= -67108865 : 28 === i3 ? s3.fg &= -1073741825 : 29 === i3 ? s3.fg &= 2147483647 : 39 === i3 ? (s3.fg &= -67108864, s3.fg |= 16777215 & l.DEFAULT_ATTR_DATA.fg) : 49 === i3 ? (s3.bg &= -67108864, s3.bg |= 16777215 & l.DEFAULT_ATTR_DATA.bg) : 38 === i3 || 48 === i3 || 58 === i3 ? r2 += this._extractColor(e3, r2, s3) : 53 === i3 ? s3.bg |= 1073741824 : 55 === i3 ? s3.bg &= -1073741825 : 59 === i3 ? (s3.extended = s3.extended.clone(), s3.extended.underlineColor = -1, s3.updateExtended()) : 100 === i3 ? (s3.fg &= -67108864, s3.fg |= 16777215 & l.DEFAULT_ATTR_DATA.fg, s3.bg &= -67108864, s3.bg |= 16777215 & l.DEFAULT_ATTR_DATA.bg) : this._logService.debug("Unknown SGR attribute: %d.", i3); + return true; + } + deviceStatus(e3) { + switch (e3.params[0]) { + case 5: + this._coreService.triggerDataEvent(`${n.C0.ESC}[0n`); + break; + case 6: + const e4 = this._activeBuffer.y + 1, t3 = this._activeBuffer.x + 1; + this._coreService.triggerDataEvent(`${n.C0.ESC}[${e4};${t3}R`); + } + return true; + } + deviceStatusPrivate(e3) { + if (6 === e3.params[0]) { + const e4 = this._activeBuffer.y + 1, t3 = this._activeBuffer.x + 1; + this._coreService.triggerDataEvent(`${n.C0.ESC}[?${e4};${t3}R`); + } + return true; + } + softReset(e3) { + return this._coreService.isCursorHidden = false, this._onRequestSyncScrollBar.fire(), this._activeBuffer.scrollTop = 0, this._activeBuffer.scrollBottom = this._bufferService.rows - 1, this._curAttrData = l.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 = false, true; + } + setCursorStyle(e3) { + const t3 = e3.params[0] || 1; + switch (t3) { + 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 i3 = t3 % 2 == 1; + return this._optionsService.options.cursorBlink = i3, true; + } + setScrollRegion(e3) { + const t3 = e3.params[0] || 1; + let i3; + return (e3.length < 2 || (i3 = e3.params[1]) > this._bufferService.rows || 0 === i3) && (i3 = this._bufferService.rows), i3 > t3 && (this._activeBuffer.scrollTop = t3 - 1, this._activeBuffer.scrollBottom = i3 - 1, this._setCursor(0, 0)), true; + } + windowOptions(e3) { + if (!b(e3.params[0], this._optionsService.rawOptions.windowOptions)) return true; + const t3 = e3.length > 1 ? e3.params[1] : 0; + switch (e3.params[0]) { + case 14: + 2 !== t3 && 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 !== t3 && 2 !== t3 || (this._windowTitleStack.push(this._windowTitle), this._windowTitleStack.length > 10 && this._windowTitleStack.shift()), 0 !== t3 && 1 !== t3 || (this._iconNameStack.push(this._iconName), this._iconNameStack.length > 10 && this._iconNameStack.shift()); + break; + case 23: + 0 !== t3 && 2 !== t3 || this._windowTitleStack.length && this.setTitle(this._windowTitleStack.pop()), 0 !== t3 && 1 !== t3 || this._iconNameStack.length && this.setIconName(this._iconNameStack.pop()); + } + return true; + } + saveCursor(e3) { + 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, true; + } + restoreCursor(e3) { + 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(), true; + } + setTitle(e3) { + return this._windowTitle = e3, this._onTitleChange.fire(e3), true; + } + setIconName(e3) { + return this._iconName = e3, true; + } + setOrReportIndexedColor(e3) { + const t3 = [], i3 = e3.split(";"); + for (; i3.length > 1; ) { + const e4 = i3.shift(), s3 = i3.shift(); + if (/^\d+$/.exec(e4)) { + const i4 = parseInt(e4); + if (L(i4)) if ("?" === s3) t3.push({ type: 0, index: i4 }); + else { + const e5 = (0, m.parseColor)(s3); + e5 && t3.push({ type: 1, index: i4, color: e5 }); + } + } + } + return t3.length && this._onColor.fire(t3), true; + } + setHyperlink(e3) { + const t3 = e3.split(";"); + return !(t3.length < 2) && (t3[1] ? this._createHyperlink(t3[0], t3[1]) : !t3[0] && this._finishHyperlink()); + } + _createHyperlink(e3, t3) { + this._getCurrentLinkId() && this._finishHyperlink(); + const i3 = e3.split(":"); + let s3; + const r2 = i3.findIndex(((e4) => e4.startsWith("id="))); + return -1 !== r2 && (s3 = i3[r2].slice(3) || void 0), this._curAttrData.extended = this._curAttrData.extended.clone(), this._curAttrData.extended.urlId = this._oscLinkService.registerLink({ id: s3, uri: t3 }), this._curAttrData.updateExtended(), true; + } + _finishHyperlink() { + return this._curAttrData.extended = this._curAttrData.extended.clone(), this._curAttrData.extended.urlId = 0, this._curAttrData.updateExtended(), true; + } + _setOrReportSpecialColor(e3, t3) { + const i3 = e3.split(";"); + for (let e4 = 0; e4 < i3.length && !(t3 >= this._specialColors.length); ++e4, ++t3) if ("?" === i3[e4]) this._onColor.fire([{ type: 0, index: this._specialColors[t3] }]); + else { + const s3 = (0, m.parseColor)(i3[e4]); + s3 && this._onColor.fire([{ type: 1, index: this._specialColors[t3], color: s3 }]); + } + return true; + } + setOrReportFgColor(e3) { + return this._setOrReportSpecialColor(e3, 0); + } + setOrReportBgColor(e3) { + return this._setOrReportSpecialColor(e3, 1); + } + setOrReportCursorColor(e3) { + return this._setOrReportSpecialColor(e3, 2); + } + restoreIndexedColor(e3) { + if (!e3) return this._onColor.fire([{ type: 2 }]), true; + const t3 = [], i3 = e3.split(";"); + for (let e4 = 0; e4 < i3.length; ++e4) if (/^\d+$/.exec(i3[e4])) { + const s3 = parseInt(i3[e4]); + L(s3) && t3.push({ type: 2, index: s3 }); + } + return t3.length && this._onColor.fire(t3), true; + } + restoreFgColor(e3) { + return this._onColor.fire([{ type: 2, index: 256 }]), true; + } + restoreBgColor(e3) { + return this._onColor.fire([{ type: 2, index: 257 }]), true; + } + restoreCursorColor(e3) { + return this._onColor.fire([{ type: 2, index: 258 }]), true; + } + nextLine() { + return this._activeBuffer.x = 0, this.index(), true; + } + keypadApplicationMode() { + return this._logService.debug("Serial port requested application keypad."), this._coreService.decPrivateModes.applicationKeypad = true, this._onRequestSyncScrollBar.fire(), true; + } + keypadNumericMode() { + return this._logService.debug("Switching back to normal keypad."), this._coreService.decPrivateModes.applicationKeypad = false, this._onRequestSyncScrollBar.fire(), true; + } + selectDefaultCharset() { + return this._charsetService.setgLevel(0), this._charsetService.setgCharset(0, o.DEFAULT_CHARSET), true; + } + selectCharset(e3) { + return 2 !== e3.length ? (this.selectDefaultCharset(), true) : ("/" === e3[0] || this._charsetService.setgCharset(S2[e3[0]], o.CHARSETS[e3[1]] || o.DEFAULT_CHARSET), true); + } + 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(), true; + } + tabSet() { + return this._activeBuffer.tabs[this._activeBuffer.x] = true, true; + } + reverseIndex() { + if (this._restrictCursor(), this._activeBuffer.y === this._activeBuffer.scrollTop) { + const e3 = this._activeBuffer.scrollBottom - this._activeBuffer.scrollTop; + this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase + this._activeBuffer.y, e3, 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 true; + } + fullReset() { + return this._parser.reset(), this._onRequestReset.fire(), true; + } + reset() { + this._curAttrData = l.DEFAULT_ATTR_DATA.clone(), this._eraseAttrDataInternal = l.DEFAULT_ATTR_DATA.clone(); + } + _eraseAttrData() { + return this._eraseAttrDataInternal.bg &= -67108864, this._eraseAttrDataInternal.bg |= 67108863 & this._curAttrData.bg, this._eraseAttrDataInternal; + } + setgLevel(e3) { + return this._charsetService.setgLevel(e3), true; + } + screenAlignmentPattern() { + const e3 = new u.CellData(); + e3.content = 1 << 22 | "E".charCodeAt(0), e3.fg = this._curAttrData.fg, e3.bg = this._curAttrData.bg, this._setCursor(0, 0); + for (let t3 = 0; t3 < this._bufferService.rows; ++t3) { + const i3 = this._activeBuffer.ybase + this._activeBuffer.y + t3, s3 = this._activeBuffer.lines.get(i3); + s3 && (s3.fill(e3), s3.isWrapped = false); + } + return this._dirtyRowTracker.markAllDirty(), this._setCursor(0, 0), true; + } + requestStatusString(e3, t3) { + const i3 = this._bufferService.buffer, s3 = this._optionsService.rawOptions; + return ((e4) => (this._coreService.triggerDataEvent(`${n.C0.ESC}${e4}${n.C0.ESC}\\`), true))('"q' === e3 ? `P1$r${this._curAttrData.isProtected() ? 1 : 0}"q` : '"p' === e3 ? 'P1$r61;1"p' : "r" === e3 ? `P1$r${i3.scrollTop + 1};${i3.scrollBottom + 1}r` : "m" === e3 ? "P1$r0m" : " q" === e3 ? `P1$r${{ block: 2, underline: 4, bar: 6 }[s3.cursorStyle] - (s3.cursorBlink ? 1 : 0)} q` : "P0$r"); + } + markRangeDirty(e3, t3) { + this._dirtyRowTracker.markRangeDirty(e3, t3); + } + } + t2.InputHandler = E; + let k = class { + constructor(e3) { + this._bufferService = e3, this.clearRange(); + } + clearRange() { + this.start = this._bufferService.buffer.y, this.end = this._bufferService.buffer.y; + } + markDirty(e3) { + e3 < this.start ? this.start = e3 : e3 > this.end && (this.end = e3); + } + markRangeDirty(e3, t3) { + e3 > t3 && (w = e3, e3 = t3, t3 = w), e3 < this.start && (this.start = e3), t3 > this.end && (this.end = t3); + } + markAllDirty() { + this.markRangeDirty(0, this._bufferService.rows - 1); + } + }; + function L(e3) { + return 0 <= e3 && e3 < 256; + } + k = s2([r(0, v.IBufferService)], k); + }, 844: (e2, t2) => { + function i2(e3) { + for (const t3 of e3) t3.dispose(); + e3.length = 0; + } + Object.defineProperty(t2, "__esModule", { value: true }), t2.getDisposeArrayDisposable = t2.disposeArray = t2.toDisposable = t2.MutableDisposable = t2.Disposable = void 0, t2.Disposable = class { + constructor() { + this._disposables = [], this._isDisposed = false; + } + dispose() { + this._isDisposed = true; + for (const e3 of this._disposables) e3.dispose(); + this._disposables.length = 0; + } + register(e3) { + return this._disposables.push(e3), e3; + } + unregister(e3) { + const t3 = this._disposables.indexOf(e3); + -1 !== t3 && this._disposables.splice(t3, 1); + } + }, t2.MutableDisposable = class { + constructor() { + this._isDisposed = false; + } + get value() { + return this._isDisposed ? void 0 : this._value; + } + set value(e3) { + var t3; + this._isDisposed || e3 === this._value || (null === (t3 = this._value) || void 0 === t3 || t3.dispose(), this._value = e3); + } + clear() { + this.value = void 0; + } + dispose() { + var e3; + this._isDisposed = true, null === (e3 = this._value) || void 0 === e3 || e3.dispose(), this._value = void 0; + } + }, t2.toDisposable = function(e3) { + return { dispose: e3 }; + }, t2.disposeArray = i2, t2.getDisposeArrayDisposable = function(e3) { + return { dispose: () => i2(e3) }; + }; + }, 1505: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.FourKeyMap = t2.TwoKeyMap = void 0; + class i2 { + constructor() { + this._data = {}; + } + set(e3, t3, i3) { + this._data[e3] || (this._data[e3] = {}), this._data[e3][t3] = i3; + } + get(e3, t3) { + return this._data[e3] ? this._data[e3][t3] : void 0; + } + clear() { + this._data = {}; + } + } + t2.TwoKeyMap = i2, t2.FourKeyMap = class { + constructor() { + this._data = new i2(); + } + set(e3, t3, s2, r, n) { + this._data.get(e3, t3) || this._data.set(e3, t3, new i2()), this._data.get(e3, t3).set(s2, r, n); + } + get(e3, t3, i3, s2) { + var r; + return null === (r = this._data.get(e3, t3)) || void 0 === r ? void 0 : r.get(i3, s2); + } + clear() { + this._data.clear(); + } + }; + }, 6114: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.isChromeOS = t2.isLinux = t2.isWindows = t2.isIphone = t2.isIpad = t2.isMac = t2.getSafariVersion = t2.isSafari = t2.isLegacyEdge = t2.isFirefox = t2.isNode = void 0, t2.isNode = "undefined" == typeof navigator; + const i2 = t2.isNode ? "node" : navigator.userAgent, s2 = t2.isNode ? "node" : navigator.platform; + t2.isFirefox = i2.includes("Firefox"), t2.isLegacyEdge = i2.includes("Edge"), t2.isSafari = /^((?!chrome|android).)*safari/i.test(i2), t2.getSafariVersion = function() { + if (!t2.isSafari) return 0; + const e3 = i2.match(/Version\/(\d+)/); + return null === e3 || e3.length < 2 ? 0 : parseInt(e3[1]); + }, t2.isMac = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"].includes(s2), t2.isIpad = "iPad" === s2, t2.isIphone = "iPhone" === s2, t2.isWindows = ["Windows", "Win16", "Win32", "WinCE"].includes(s2), t2.isLinux = s2.indexOf("Linux") >= 0, t2.isChromeOS = /\bCrOS\b/.test(i2); + }, 6106: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.SortedList = void 0; + let i2 = 0; + t2.SortedList = class { + constructor(e3) { + this._getKey = e3, this._array = []; + } + clear() { + this._array.length = 0; + } + insert(e3) { + 0 !== this._array.length ? (i2 = this._search(this._getKey(e3)), this._array.splice(i2, 0, e3)) : this._array.push(e3); + } + delete(e3) { + if (0 === this._array.length) return false; + const t3 = this._getKey(e3); + if (void 0 === t3) return false; + if (i2 = this._search(t3), -1 === i2) return false; + if (this._getKey(this._array[i2]) !== t3) return false; + do { + if (this._array[i2] === e3) return this._array.splice(i2, 1), true; + } while (++i2 < this._array.length && this._getKey(this._array[i2]) === t3); + return false; + } + *getKeyIterator(e3) { + if (0 !== this._array.length && (i2 = this._search(e3), !(i2 < 0 || i2 >= this._array.length) && this._getKey(this._array[i2]) === e3)) do { + yield this._array[i2]; + } while (++i2 < this._array.length && this._getKey(this._array[i2]) === e3); + } + forEachByKey(e3, t3) { + if (0 !== this._array.length && (i2 = this._search(e3), !(i2 < 0 || i2 >= this._array.length) && this._getKey(this._array[i2]) === e3)) do { + t3(this._array[i2]); + } while (++i2 < this._array.length && this._getKey(this._array[i2]) === e3); + } + values() { + return [...this._array].values(); + } + _search(e3) { + let t3 = 0, i3 = this._array.length - 1; + for (; i3 >= t3; ) { + let s2 = t3 + i3 >> 1; + const r = this._getKey(this._array[s2]); + if (r > e3) i3 = s2 - 1; + else { + if (!(r < e3)) { + for (; s2 > 0 && this._getKey(this._array[s2 - 1]) === e3; ) s2--; + return s2; + } + t3 = s2 + 1; + } + } + return t3; + } + }; + }, 7226: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.DebouncedIdleTask = t2.IdleTaskQueue = t2.PriorityTaskQueue = void 0; + const s2 = i2(6114); + class r { + constructor() { + this._tasks = [], this._i = 0; + } + enqueue(e3) { + this._tasks.push(e3), 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(e3) { + this._idleCallback = void 0; + let t3 = 0, i3 = 0, s3 = e3.timeRemaining(), r2 = 0; + for (; this._i < this._tasks.length; ) { + if (t3 = Date.now(), this._tasks[this._i]() || this._i++, t3 = Math.max(1, Date.now() - t3), i3 = Math.max(t3, i3), r2 = e3.timeRemaining(), 1.5 * i3 > r2) return s3 - t3 < -20 && console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s3 - t3))}ms`), void this._start(); + s3 = r2; + } + this.clear(); + } + } + class n extends r { + _requestCallback(e3) { + return setTimeout((() => e3(this._createDeadline(16)))); + } + _cancelCallback(e3) { + clearTimeout(e3); + } + _createDeadline(e3) { + const t3 = Date.now() + e3; + return { timeRemaining: () => Math.max(0, t3 - Date.now()) }; + } + } + t2.PriorityTaskQueue = n, t2.IdleTaskQueue = !s2.isNode && "requestIdleCallback" in window ? class extends r { + _requestCallback(e3) { + return requestIdleCallback(e3); + } + _cancelCallback(e3) { + cancelIdleCallback(e3); + } + } : n, t2.DebouncedIdleTask = class { + constructor() { + this._queue = new t2.IdleTaskQueue(); + } + set(e3) { + this._queue.clear(), this._queue.enqueue(e3); + } + flush() { + this._queue.flush(); + } + }; + }, 9282: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.updateWindowsModeWrappedState = void 0; + const s2 = i2(643); + t2.updateWindowsModeWrappedState = function(e3) { + const t3 = e3.buffer.lines.get(e3.buffer.ybase + e3.buffer.y - 1), i3 = null == t3 ? void 0 : t3.get(e3.cols - 1), r = e3.buffer.lines.get(e3.buffer.ybase + e3.buffer.y); + r && i3 && (r.isWrapped = i3[s2.CHAR_DATA_CODE_INDEX] !== s2.NULL_CELL_CODE && i3[s2.CHAR_DATA_CODE_INDEX] !== s2.WHITESPACE_CELL_CODE); + }; + }, 3734: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.ExtendedAttrs = t2.AttributeData = void 0; + class i2 { + constructor() { + this.fg = 0, this.bg = 0, this.extended = new s2(); + } + static toColorRGB(e3) { + return [e3 >>> 16 & 255, e3 >>> 8 & 255, 255 & e3]; + } + static fromColorRGB(e3) { + return (255 & e3[0]) << 16 | (255 & e3[1]) << 8 | 255 & e3[2]; + } + clone() { + const e3 = new i2(); + return e3.fg = this.fg, e3.bg = this.bg, e3.extended = this.extended.clone(), e3; + } + 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 == (50331648 & this.fg); + } + isBgRGB() { + return 50331648 == (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 0 == (50331648 & this.fg); + } + isBgDefault() { + return 0 == (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 == (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 ? 0 == (50331648 & this.extended.underlineColor) : this.isFgDefault(); + } + getUnderlineStyle() { + return 268435456 & this.fg ? 268435456 & this.bg ? this.extended.underlineStyle : 1 : 0; + } + } + t2.AttributeData = i2; + class s2 { + get ext() { + return this._urlId ? -469762049 & this._ext | this.underlineStyle << 26 : this._ext; + } + set ext(e3) { + this._ext = e3; + } + get underlineStyle() { + return this._urlId ? 5 : (469762048 & this._ext) >> 26; + } + set underlineStyle(e3) { + this._ext &= -469762049, this._ext |= e3 << 26 & 469762048; + } + get underlineColor() { + return 67108863 & this._ext; + } + set underlineColor(e3) { + this._ext &= -67108864, this._ext |= 67108863 & e3; + } + get urlId() { + return this._urlId; + } + set urlId(e3) { + this._urlId = e3; + } + constructor(e3 = 0, t3 = 0) { + this._ext = 0, this._urlId = 0, this._ext = e3, this._urlId = t3; + } + clone() { + return new s2(this._ext, this._urlId); + } + isEmpty() { + return 0 === this.underlineStyle && 0 === this._urlId; + } + } + t2.ExtendedAttrs = s2; + }, 9092: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.Buffer = t2.MAX_BUFFER_SIZE = void 0; + const s2 = i2(6349), r = i2(7226), n = i2(3734), o = i2(8437), a = i2(4634), h = i2(511), c = i2(643), l = i2(4863), d = i2(7116); + t2.MAX_BUFFER_SIZE = 4294967295, t2.Buffer = class { + constructor(e3, t3, i3) { + this._hasScrollback = e3, this._optionsService = t3, this._bufferService = i3, 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 = d.DEFAULT_CHARSET, this.markers = [], this._nullCell = h.CellData.fromCharData([0, c.NULL_CELL_CHAR, c.NULL_CELL_WIDTH, c.NULL_CELL_CODE]), this._whitespaceCell = h.CellData.fromCharData([0, c.WHITESPACE_CELL_CHAR, c.WHITESPACE_CELL_WIDTH, c.WHITESPACE_CELL_CODE]), this._isClearing = false, this._memoryCleanupQueue = new r.IdleTaskQueue(), this._memoryCleanupPosition = 0, this._cols = this._bufferService.cols, this._rows = this._bufferService.rows, this.lines = new s2.CircularList(this._getCorrectBufferLength(this._rows)), this.scrollTop = 0, this.scrollBottom = this._rows - 1, this.setupTabStops(); + } + getNullCell(e3) { + return e3 ? (this._nullCell.fg = e3.fg, this._nullCell.bg = e3.bg, this._nullCell.extended = e3.extended) : (this._nullCell.fg = 0, this._nullCell.bg = 0, this._nullCell.extended = new n.ExtendedAttrs()), this._nullCell; + } + getWhitespaceCell(e3) { + return e3 ? (this._whitespaceCell.fg = e3.fg, this._whitespaceCell.bg = e3.bg, this._whitespaceCell.extended = e3.extended) : (this._whitespaceCell.fg = 0, this._whitespaceCell.bg = 0, this._whitespaceCell.extended = new n.ExtendedAttrs()), this._whitespaceCell; + } + getBlankLine(e3, t3) { + return new o.BufferLine(this._bufferService.cols, this.getNullCell(e3), t3); + } + get hasScrollback() { + return this._hasScrollback && this.lines.maxLength > this._rows; + } + get isCursorInViewport() { + const e3 = this.ybase + this.y - this.ydisp; + return e3 >= 0 && e3 < this._rows; + } + _getCorrectBufferLength(e3) { + if (!this._hasScrollback) return e3; + const i3 = e3 + this._optionsService.rawOptions.scrollback; + return i3 > t2.MAX_BUFFER_SIZE ? t2.MAX_BUFFER_SIZE : i3; + } + fillViewportRows(e3) { + if (0 === this.lines.length) { + void 0 === e3 && (e3 = o.DEFAULT_ATTR_DATA); + let t3 = this._rows; + for (; t3--; ) this.lines.push(this.getBlankLine(e3)); + } + } + clear() { + this.ydisp = 0, this.ybase = 0, this.y = 0, this.x = 0, this.lines = new s2.CircularList(this._getCorrectBufferLength(this._rows)), this.scrollTop = 0, this.scrollBottom = this._rows - 1, this.setupTabStops(); + } + resize(e3, t3) { + const i3 = this.getNullCell(o.DEFAULT_ATTR_DATA); + let s3 = 0; + const r2 = this._getCorrectBufferLength(t3); + if (r2 > this.lines.maxLength && (this.lines.maxLength = r2), this.lines.length > 0) { + if (this._cols < e3) for (let t4 = 0; t4 < this.lines.length; t4++) s3 += +this.lines.get(t4).resize(e3, i3); + let n2 = 0; + if (this._rows < t3) for (let s4 = this._rows; s4 < t3; s4++) this.lines.length < t3 + 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(e3, i3)) : this.ybase > 0 && this.lines.length <= this.ybase + this.y + n2 + 1 ? (this.ybase--, n2++, this.ydisp > 0 && this.ydisp--) : this.lines.push(new o.BufferLine(e3, i3))); + else for (let e4 = this._rows; e4 > t3; e4--) this.lines.length > t3 + this.ybase && (this.lines.length > this.ybase + this.y + 1 ? this.lines.pop() : (this.ybase++, this.ydisp++)); + if (r2 < this.lines.maxLength) { + const e4 = this.lines.length - r2; + e4 > 0 && (this.lines.trimStart(e4), this.ybase = Math.max(this.ybase - e4, 0), this.ydisp = Math.max(this.ydisp - e4, 0), this.savedY = Math.max(this.savedY - e4, 0)), this.lines.maxLength = r2; + } + this.x = Math.min(this.x, e3 - 1), this.y = Math.min(this.y, t3 - 1), n2 && (this.y += n2), this.savedX = Math.min(this.savedX, e3 - 1), this.scrollTop = 0; + } + if (this.scrollBottom = t3 - 1, this._isReflowEnabled && (this._reflow(e3, t3), this._cols > e3)) for (let t4 = 0; t4 < this.lines.length; t4++) s3 += +this.lines.get(t4).resize(e3, i3); + this._cols = e3, this._rows = t3, this._memoryCleanupQueue.clear(), s3 > 0.1 * this.lines.length && (this._memoryCleanupPosition = 0, this._memoryCleanupQueue.enqueue((() => this._batchedMemoryCleanup()))); + } + _batchedMemoryCleanup() { + let e3 = true; + this._memoryCleanupPosition >= this.lines.length && (this._memoryCleanupPosition = 0, e3 = false); + let t3 = 0; + for (; this._memoryCleanupPosition < this.lines.length; ) if (t3 += this.lines.get(this._memoryCleanupPosition++).cleanupMemory(), t3 > 100) return true; + return e3; + } + get _isReflowEnabled() { + const e3 = this._optionsService.rawOptions.windowsPty; + return e3 && e3.buildNumber ? this._hasScrollback && "conpty" === e3.backend && e3.buildNumber >= 21376 : this._hasScrollback && !this._optionsService.rawOptions.windowsMode; + } + _reflow(e3, t3) { + this._cols !== e3 && (e3 > this._cols ? this._reflowLarger(e3, t3) : this._reflowSmaller(e3, t3)); + } + _reflowLarger(e3, t3) { + const i3 = (0, a.reflowLargerGetLinesToRemove)(this.lines, this._cols, e3, this.ybase + this.y, this.getNullCell(o.DEFAULT_ATTR_DATA)); + if (i3.length > 0) { + const s3 = (0, a.reflowLargerCreateNewLayout)(this.lines, i3); + (0, a.reflowLargerApplyNewLayout)(this.lines, s3.layout), this._reflowLargerAdjustViewport(e3, t3, s3.countRemoved); + } + } + _reflowLargerAdjustViewport(e3, t3, i3) { + const s3 = this.getNullCell(o.DEFAULT_ATTR_DATA); + let r2 = i3; + for (; r2-- > 0; ) 0 === this.ybase ? (this.y > 0 && this.y--, this.lines.length < t3 && this.lines.push(new o.BufferLine(e3, s3))) : (this.ydisp === this.ybase && this.ydisp--, this.ybase--); + this.savedY = Math.max(this.savedY - i3, 0); + } + _reflowSmaller(e3, t3) { + const i3 = this.getNullCell(o.DEFAULT_ATTR_DATA), s3 = []; + let r2 = 0; + for (let n2 = this.lines.length - 1; n2 >= 0; n2--) { + let h2 = this.lines.get(n2); + if (!h2 || !h2.isWrapped && h2.getTrimmedLength() <= e3) continue; + const c2 = [h2]; + for (; h2.isWrapped && n2 > 0; ) h2 = this.lines.get(--n2), c2.unshift(h2); + const l2 = this.ybase + this.y; + if (l2 >= n2 && l2 < n2 + c2.length) continue; + const d2 = c2[c2.length - 1].getTrimmedLength(), _ = (0, a.reflowSmallerGetNewLineLengths)(c2, this._cols, e3), u = _.length - c2.length; + let f; + f = 0 === this.ybase && this.y !== this.lines.length - 1 ? Math.max(0, this.y - this.lines.maxLength + u) : Math.max(0, this.lines.length - this.lines.maxLength + u); + const v = []; + for (let e4 = 0; e4 < u; e4++) { + const e5 = this.getBlankLine(o.DEFAULT_ATTR_DATA, true); + v.push(e5); + } + v.length > 0 && (s3.push({ start: n2 + c2.length + r2, newLines: v }), r2 += v.length), c2.push(...v); + let p = _.length - 1, g = _[p]; + 0 === g && (p--, g = _[p]); + let m = c2.length - u - 1, S2 = d2; + for (; m >= 0; ) { + const e4 = Math.min(S2, g); + if (void 0 === c2[p]) break; + if (c2[p].copyCellsFrom(c2[m], S2 - e4, g - e4, e4, true), g -= e4, 0 === g && (p--, g = _[p]), S2 -= e4, 0 === S2) { + m--; + const e5 = Math.max(m, 0); + S2 = (0, a.getWrappedLineTrimmedLength)(c2, e5, this._cols); + } + } + for (let t4 = 0; t4 < c2.length; t4++) _[t4] < e3 && c2[t4].setCell(_[t4], i3); + let C = u - f; + for (; C-- > 0; ) 0 === this.ybase ? this.y < t3 - 1 ? (this.y++, this.lines.pop()) : (this.ybase++, this.ydisp++) : this.ybase < Math.min(this.lines.maxLength, this.lines.length + r2) - t3 && (this.ybase === this.ydisp && this.ydisp++, this.ybase++); + this.savedY = Math.min(this.savedY + u, this.ybase + t3 - 1); + } + if (s3.length > 0) { + const e4 = [], t4 = []; + for (let e5 = 0; e5 < this.lines.length; e5++) t4.push(this.lines.get(e5)); + const i4 = this.lines.length; + let n2 = i4 - 1, o2 = 0, a2 = s3[o2]; + this.lines.length = Math.min(this.lines.maxLength, this.lines.length + r2); + let h2 = 0; + for (let c3 = Math.min(this.lines.maxLength - 1, i4 + r2 - 1); c3 >= 0; c3--) if (a2 && a2.start > n2 + h2) { + for (let e5 = a2.newLines.length - 1; e5 >= 0; e5--) this.lines.set(c3--, a2.newLines[e5]); + c3++, e4.push({ index: n2 + 1, amount: a2.newLines.length }), h2 += a2.newLines.length, a2 = s3[++o2]; + } else this.lines.set(c3, t4[n2--]); + let c2 = 0; + for (let t5 = e4.length - 1; t5 >= 0; t5--) e4[t5].index += c2, this.lines.onInsertEmitter.fire(e4[t5]), c2 += e4[t5].amount; + const l2 = Math.max(0, i4 + r2 - this.lines.maxLength); + l2 > 0 && this.lines.onTrimEmitter.fire(l2); + } + } + translateBufferLineToString(e3, t3, i3 = 0, s3) { + const r2 = this.lines.get(e3); + return r2 ? r2.translateToString(t3, i3, s3) : ""; + } + getWrappedRangeForLine(e3) { + let t3 = e3, i3 = e3; + for (; t3 > 0 && this.lines.get(t3).isWrapped; ) t3--; + for (; i3 + 1 < this.lines.length && this.lines.get(i3 + 1).isWrapped; ) i3++; + return { first: t3, last: i3 }; + } + setupTabStops(e3) { + for (null != e3 ? this.tabs[e3] || (e3 = this.prevStop(e3)) : (this.tabs = {}, e3 = 0); e3 < this._cols; e3 += this._optionsService.rawOptions.tabStopWidth) this.tabs[e3] = true; + } + prevStop(e3) { + for (null == e3 && (e3 = this.x); !this.tabs[--e3] && e3 > 0; ) ; + return e3 >= this._cols ? this._cols - 1 : e3 < 0 ? 0 : e3; + } + nextStop(e3) { + for (null == e3 && (e3 = this.x); !this.tabs[++e3] && e3 < this._cols; ) ; + return e3 >= this._cols ? this._cols - 1 : e3 < 0 ? 0 : e3; + } + clearMarkers(e3) { + this._isClearing = true; + for (let t3 = 0; t3 < this.markers.length; t3++) this.markers[t3].line === e3 && (this.markers[t3].dispose(), this.markers.splice(t3--, 1)); + this._isClearing = false; + } + clearAllMarkers() { + this._isClearing = true; + for (let e3 = 0; e3 < this.markers.length; e3++) this.markers[e3].dispose(), this.markers.splice(e3--, 1); + this._isClearing = false; + } + addMarker(e3) { + const t3 = new l.Marker(e3); + return this.markers.push(t3), t3.register(this.lines.onTrim(((e4) => { + t3.line -= e4, t3.line < 0 && t3.dispose(); + }))), t3.register(this.lines.onInsert(((e4) => { + t3.line >= e4.index && (t3.line += e4.amount); + }))), t3.register(this.lines.onDelete(((e4) => { + t3.line >= e4.index && t3.line < e4.index + e4.amount && t3.dispose(), t3.line > e4.index && (t3.line -= e4.amount); + }))), t3.register(t3.onDispose((() => this._removeMarker(t3)))), t3; + } + _removeMarker(e3) { + this._isClearing || this.markers.splice(this.markers.indexOf(e3), 1); + } + }; + }, 8437: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferLine = t2.DEFAULT_ATTR_DATA = void 0; + const s2 = i2(3734), r = i2(511), n = i2(643), o = i2(482); + t2.DEFAULT_ATTR_DATA = Object.freeze(new s2.AttributeData()); + let a = 0; + class h { + constructor(e3, t3, i3 = false) { + this.isWrapped = i3, this._combined = {}, this._extendedAttrs = {}, this._data = new Uint32Array(3 * e3); + const s3 = t3 || r.CellData.fromCharData([0, n.NULL_CELL_CHAR, n.NULL_CELL_WIDTH, n.NULL_CELL_CODE]); + for (let t4 = 0; t4 < e3; ++t4) this.setCell(t4, s3); + this.length = e3; + } + get(e3) { + const t3 = this._data[3 * e3 + 0], i3 = 2097151 & t3; + return [this._data[3 * e3 + 1], 2097152 & t3 ? this._combined[e3] : i3 ? (0, o.stringFromCodePoint)(i3) : "", t3 >> 22, 2097152 & t3 ? this._combined[e3].charCodeAt(this._combined[e3].length - 1) : i3]; + } + set(e3, t3) { + this._data[3 * e3 + 1] = t3[n.CHAR_DATA_ATTR_INDEX], t3[n.CHAR_DATA_CHAR_INDEX].length > 1 ? (this._combined[e3] = t3[1], this._data[3 * e3 + 0] = 2097152 | e3 | t3[n.CHAR_DATA_WIDTH_INDEX] << 22) : this._data[3 * e3 + 0] = t3[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | t3[n.CHAR_DATA_WIDTH_INDEX] << 22; + } + getWidth(e3) { + return this._data[3 * e3 + 0] >> 22; + } + hasWidth(e3) { + return 12582912 & this._data[3 * e3 + 0]; + } + getFg(e3) { + return this._data[3 * e3 + 1]; + } + getBg(e3) { + return this._data[3 * e3 + 2]; + } + hasContent(e3) { + return 4194303 & this._data[3 * e3 + 0]; + } + getCodePoint(e3) { + const t3 = this._data[3 * e3 + 0]; + return 2097152 & t3 ? this._combined[e3].charCodeAt(this._combined[e3].length - 1) : 2097151 & t3; + } + isCombined(e3) { + return 2097152 & this._data[3 * e3 + 0]; + } + getString(e3) { + const t3 = this._data[3 * e3 + 0]; + return 2097152 & t3 ? this._combined[e3] : 2097151 & t3 ? (0, o.stringFromCodePoint)(2097151 & t3) : ""; + } + isProtected(e3) { + return 536870912 & this._data[3 * e3 + 2]; + } + loadCell(e3, t3) { + return a = 3 * e3, t3.content = this._data[a + 0], t3.fg = this._data[a + 1], t3.bg = this._data[a + 2], 2097152 & t3.content && (t3.combinedData = this._combined[e3]), 268435456 & t3.bg && (t3.extended = this._extendedAttrs[e3]), t3; + } + setCell(e3, t3) { + 2097152 & t3.content && (this._combined[e3] = t3.combinedData), 268435456 & t3.bg && (this._extendedAttrs[e3] = t3.extended), this._data[3 * e3 + 0] = t3.content, this._data[3 * e3 + 1] = t3.fg, this._data[3 * e3 + 2] = t3.bg; + } + setCellFromCodePoint(e3, t3, i3, s3, r2, n2) { + 268435456 & r2 && (this._extendedAttrs[e3] = n2), this._data[3 * e3 + 0] = t3 | i3 << 22, this._data[3 * e3 + 1] = s3, this._data[3 * e3 + 2] = r2; + } + addCodepointToCell(e3, t3) { + let i3 = this._data[3 * e3 + 0]; + 2097152 & i3 ? this._combined[e3] += (0, o.stringFromCodePoint)(t3) : (2097151 & i3 ? (this._combined[e3] = (0, o.stringFromCodePoint)(2097151 & i3) + (0, o.stringFromCodePoint)(t3), i3 &= -2097152, i3 |= 2097152) : i3 = t3 | 1 << 22, this._data[3 * e3 + 0] = i3); + } + insertCells(e3, t3, i3, n2) { + if ((e3 %= this.length) && 2 === this.getWidth(e3 - 1) && this.setCellFromCodePoint(e3 - 1, 0, 1, (null == n2 ? void 0 : n2.fg) || 0, (null == n2 ? void 0 : n2.bg) || 0, (null == n2 ? void 0 : n2.extended) || new s2.ExtendedAttrs()), t3 < this.length - e3) { + const s3 = new r.CellData(); + for (let i4 = this.length - e3 - t3 - 1; i4 >= 0; --i4) this.setCell(e3 + t3 + i4, this.loadCell(e3 + i4, s3)); + for (let s4 = 0; s4 < t3; ++s4) this.setCell(e3 + s4, i3); + } else for (let t4 = e3; t4 < this.length; ++t4) this.setCell(t4, i3); + 2 === this.getWidth(this.length - 1) && this.setCellFromCodePoint(this.length - 1, 0, 1, (null == n2 ? void 0 : n2.fg) || 0, (null == n2 ? void 0 : n2.bg) || 0, (null == n2 ? void 0 : n2.extended) || new s2.ExtendedAttrs()); + } + deleteCells(e3, t3, i3, n2) { + if (e3 %= this.length, t3 < this.length - e3) { + const s3 = new r.CellData(); + for (let i4 = 0; i4 < this.length - e3 - t3; ++i4) this.setCell(e3 + i4, this.loadCell(e3 + t3 + i4, s3)); + for (let e4 = this.length - t3; e4 < this.length; ++e4) this.setCell(e4, i3); + } else for (let t4 = e3; t4 < this.length; ++t4) this.setCell(t4, i3); + e3 && 2 === this.getWidth(e3 - 1) && this.setCellFromCodePoint(e3 - 1, 0, 1, (null == n2 ? void 0 : n2.fg) || 0, (null == n2 ? void 0 : n2.bg) || 0, (null == n2 ? void 0 : n2.extended) || new s2.ExtendedAttrs()), 0 !== this.getWidth(e3) || this.hasContent(e3) || this.setCellFromCodePoint(e3, 0, 1, (null == n2 ? void 0 : n2.fg) || 0, (null == n2 ? void 0 : n2.bg) || 0, (null == n2 ? void 0 : n2.extended) || new s2.ExtendedAttrs()); + } + replaceCells(e3, t3, i3, r2, n2 = false) { + if (n2) for (e3 && 2 === this.getWidth(e3 - 1) && !this.isProtected(e3 - 1) && this.setCellFromCodePoint(e3 - 1, 0, 1, (null == r2 ? void 0 : r2.fg) || 0, (null == r2 ? void 0 : r2.bg) || 0, (null == r2 ? void 0 : r2.extended) || new s2.ExtendedAttrs()), t3 < this.length && 2 === this.getWidth(t3 - 1) && !this.isProtected(t3) && this.setCellFromCodePoint(t3, 0, 1, (null == r2 ? void 0 : r2.fg) || 0, (null == r2 ? void 0 : r2.bg) || 0, (null == r2 ? void 0 : r2.extended) || new s2.ExtendedAttrs()); e3 < t3 && e3 < this.length; ) this.isProtected(e3) || this.setCell(e3, i3), e3++; + else for (e3 && 2 === this.getWidth(e3 - 1) && this.setCellFromCodePoint(e3 - 1, 0, 1, (null == r2 ? void 0 : r2.fg) || 0, (null == r2 ? void 0 : r2.bg) || 0, (null == r2 ? void 0 : r2.extended) || new s2.ExtendedAttrs()), t3 < this.length && 2 === this.getWidth(t3 - 1) && this.setCellFromCodePoint(t3, 0, 1, (null == r2 ? void 0 : r2.fg) || 0, (null == r2 ? void 0 : r2.bg) || 0, (null == r2 ? void 0 : r2.extended) || new s2.ExtendedAttrs()); e3 < t3 && e3 < this.length; ) this.setCell(e3++, i3); + } + resize(e3, t3) { + if (e3 === this.length) return 4 * this._data.length * 2 < this._data.buffer.byteLength; + const i3 = 3 * e3; + if (e3 > this.length) { + if (this._data.buffer.byteLength >= 4 * i3) this._data = new Uint32Array(this._data.buffer, 0, i3); + else { + const e4 = new Uint32Array(i3); + e4.set(this._data), this._data = e4; + } + for (let i4 = this.length; i4 < e3; ++i4) this.setCell(i4, t3); + } else { + this._data = this._data.subarray(0, i3); + const t4 = Object.keys(this._combined); + for (let i4 = 0; i4 < t4.length; i4++) { + const s4 = parseInt(t4[i4], 10); + s4 >= e3 && delete this._combined[s4]; + } + const s3 = Object.keys(this._extendedAttrs); + for (let t5 = 0; t5 < s3.length; t5++) { + const i4 = parseInt(s3[t5], 10); + i4 >= e3 && delete this._extendedAttrs[i4]; + } + } + return this.length = e3, 4 * i3 * 2 < this._data.buffer.byteLength; + } + cleanupMemory() { + if (4 * this._data.length * 2 < this._data.buffer.byteLength) { + const e3 = new Uint32Array(this._data.length); + return e3.set(this._data), this._data = e3, 1; + } + return 0; + } + fill(e3, t3 = false) { + if (t3) for (let t4 = 0; t4 < this.length; ++t4) this.isProtected(t4) || this.setCell(t4, e3); + else { + this._combined = {}, this._extendedAttrs = {}; + for (let t4 = 0; t4 < this.length; ++t4) this.setCell(t4, e3); + } + } + copyFrom(e3) { + this.length !== e3.length ? this._data = new Uint32Array(e3._data) : this._data.set(e3._data), this.length = e3.length, this._combined = {}; + for (const t3 in e3._combined) this._combined[t3] = e3._combined[t3]; + this._extendedAttrs = {}; + for (const t3 in e3._extendedAttrs) this._extendedAttrs[t3] = e3._extendedAttrs[t3]; + this.isWrapped = e3.isWrapped; + } + clone() { + const e3 = new h(0); + e3._data = new Uint32Array(this._data), e3.length = this.length; + for (const t3 in this._combined) e3._combined[t3] = this._combined[t3]; + for (const t3 in this._extendedAttrs) e3._extendedAttrs[t3] = this._extendedAttrs[t3]; + return e3.isWrapped = this.isWrapped, e3; + } + getTrimmedLength() { + for (let e3 = this.length - 1; e3 >= 0; --e3) if (4194303 & this._data[3 * e3 + 0]) return e3 + (this._data[3 * e3 + 0] >> 22); + return 0; + } + getNoBgTrimmedLength() { + for (let e3 = this.length - 1; e3 >= 0; --e3) if (4194303 & this._data[3 * e3 + 0] || 50331648 & this._data[3 * e3 + 2]) return e3 + (this._data[3 * e3 + 0] >> 22); + return 0; + } + copyCellsFrom(e3, t3, i3, s3, r2) { + const n2 = e3._data; + if (r2) for (let r3 = s3 - 1; r3 >= 0; r3--) { + for (let e4 = 0; e4 < 3; e4++) this._data[3 * (i3 + r3) + e4] = n2[3 * (t3 + r3) + e4]; + 268435456 & n2[3 * (t3 + r3) + 2] && (this._extendedAttrs[i3 + r3] = e3._extendedAttrs[t3 + r3]); + } + else for (let r3 = 0; r3 < s3; r3++) { + for (let e4 = 0; e4 < 3; e4++) this._data[3 * (i3 + r3) + e4] = n2[3 * (t3 + r3) + e4]; + 268435456 & n2[3 * (t3 + r3) + 2] && (this._extendedAttrs[i3 + r3] = e3._extendedAttrs[t3 + r3]); + } + const o2 = Object.keys(e3._combined); + for (let s4 = 0; s4 < o2.length; s4++) { + const r3 = parseInt(o2[s4], 10); + r3 >= t3 && (this._combined[r3 - t3 + i3] = e3._combined[r3]); + } + } + translateToString(e3 = false, t3 = 0, i3 = this.length) { + e3 && (i3 = Math.min(i3, this.getTrimmedLength())); + let s3 = ""; + for (; t3 < i3; ) { + const e4 = this._data[3 * t3 + 0], i4 = 2097151 & e4; + s3 += 2097152 & e4 ? this._combined[t3] : i4 ? (0, o.stringFromCodePoint)(i4) : n.WHITESPACE_CELL_CHAR, t3 += e4 >> 22 || 1; + } + return s3; + } + } + t2.BufferLine = h; + }, 4841: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.getRangeLength = void 0, t2.getRangeLength = function(e3, t3) { + if (e3.start.y > e3.end.y) throw new Error(`Buffer range end (${e3.end.x}, ${e3.end.y}) cannot be before start (${e3.start.x}, ${e3.start.y})`); + return t3 * (e3.end.y - e3.start.y) + (e3.end.x - e3.start.x + 1); + }; + }, 4634: (e2, t2) => { + function i2(e3, t3, i3) { + if (t3 === e3.length - 1) return e3[t3].getTrimmedLength(); + const s2 = !e3[t3].hasContent(i3 - 1) && 1 === e3[t3].getWidth(i3 - 1), r = 2 === e3[t3 + 1].getWidth(0); + return s2 && r ? i3 - 1 : i3; + } + Object.defineProperty(t2, "__esModule", { value: true }), t2.getWrappedLineTrimmedLength = t2.reflowSmallerGetNewLineLengths = t2.reflowLargerApplyNewLayout = t2.reflowLargerCreateNewLayout = t2.reflowLargerGetLinesToRemove = void 0, t2.reflowLargerGetLinesToRemove = function(e3, t3, s2, r, n) { + const o = []; + for (let a = 0; a < e3.length - 1; a++) { + let h = a, c = e3.get(++h); + if (!c.isWrapped) continue; + const l = [e3.get(a)]; + for (; h < e3.length && c.isWrapped; ) l.push(c), c = e3.get(++h); + if (r >= a && r < h) { + a += l.length - 1; + continue; + } + let d = 0, _ = i2(l, d, t3), u = 1, f = 0; + for (; u < l.length; ) { + const e4 = i2(l, u, t3), r2 = e4 - f, o2 = s2 - _, a2 = Math.min(r2, o2); + l[d].copyCellsFrom(l[u], f, _, a2, false), _ += a2, _ === s2 && (d++, _ = 0), f += a2, f === e4 && (u++, f = 0), 0 === _ && 0 !== d && 2 === l[d - 1].getWidth(s2 - 1) && (l[d].copyCellsFrom(l[d - 1], s2 - 1, _++, 1, false), l[d - 1].setCell(s2 - 1, n)); + } + l[d].replaceCells(_, s2, n); + let v = 0; + for (let e4 = l.length - 1; e4 > 0 && (e4 > d || 0 === l[e4].getTrimmedLength()); e4--) v++; + v > 0 && (o.push(a + l.length - v), o.push(v)), a += l.length - 1; + } + return o; + }, t2.reflowLargerCreateNewLayout = function(e3, t3) { + const i3 = []; + let s2 = 0, r = t3[s2], n = 0; + for (let o = 0; o < e3.length; o++) if (r === o) { + const i4 = t3[++s2]; + e3.onDeleteEmitter.fire({ index: o - n, amount: i4 }), o += i4 - 1, n += i4, r = t3[++s2]; + } else i3.push(o); + return { layout: i3, countRemoved: n }; + }, t2.reflowLargerApplyNewLayout = function(e3, t3) { + const i3 = []; + for (let s2 = 0; s2 < t3.length; s2++) i3.push(e3.get(t3[s2])); + for (let t4 = 0; t4 < i3.length; t4++) e3.set(t4, i3[t4]); + e3.length = t3.length; + }, t2.reflowSmallerGetNewLineLengths = function(e3, t3, s2) { + const r = [], n = e3.map(((s3, r2) => i2(e3, r2, t3))).reduce(((e4, t4) => e4 + t4)); + let o = 0, a = 0, h = 0; + for (; h < n; ) { + if (n - h < s2) { + r.push(n - h); + break; + } + o += s2; + const c = i2(e3, a, t3); + o > c && (o -= c, a++); + const l = 2 === e3[a].getWidth(o - 1); + l && o--; + const d = l ? s2 - 1 : s2; + r.push(d), h += d; + } + return r; + }, t2.getWrappedLineTrimmedLength = i2; + }, 5295: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferSet = void 0; + const s2 = i2(8460), r = i2(844), n = i2(9092); + class o extends r.Disposable { + constructor(e3, t3) { + super(), this._optionsService = e3, this._bufferService = t3, this._onBufferActivate = this.register(new s2.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(true, this._optionsService, this._bufferService), this._normal.fillViewportRows(), this._alt = new n.Buffer(false, 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(e3) { + this._activeBuffer !== this._alt && (this._alt.fillViewportRows(e3), 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(e3, t3) { + this._normal.resize(e3, t3), this._alt.resize(e3, t3), this.setupTabStops(e3); + } + setupTabStops(e3) { + this._normal.setupTabStops(e3), this._alt.setupTabStops(e3); + } + } + t2.BufferSet = o; + }, 511: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.CellData = void 0; + const s2 = i2(482), r = i2(643), n = i2(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(e3) { + const t3 = new o(); + return t3.setFromCharData(e3), t3; + } + isCombined() { + return 2097152 & this.content; + } + getWidth() { + return this.content >> 22; + } + getChars() { + return 2097152 & this.content ? this.combinedData : 2097151 & this.content ? (0, s2.stringFromCodePoint)(2097151 & this.content) : ""; + } + getCode() { + return this.isCombined() ? this.combinedData.charCodeAt(this.combinedData.length - 1) : 2097151 & this.content; + } + setFromCharData(e3) { + this.fg = e3[r.CHAR_DATA_ATTR_INDEX], this.bg = 0; + let t3 = false; + if (e3[r.CHAR_DATA_CHAR_INDEX].length > 2) t3 = true; + else if (2 === e3[r.CHAR_DATA_CHAR_INDEX].length) { + const i3 = e3[r.CHAR_DATA_CHAR_INDEX].charCodeAt(0); + if (55296 <= i3 && i3 <= 56319) { + const s3 = e3[r.CHAR_DATA_CHAR_INDEX].charCodeAt(1); + 56320 <= s3 && s3 <= 57343 ? this.content = 1024 * (i3 - 55296) + s3 - 56320 + 65536 | e3[r.CHAR_DATA_WIDTH_INDEX] << 22 : t3 = true; + } else t3 = true; + } else this.content = e3[r.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | e3[r.CHAR_DATA_WIDTH_INDEX] << 22; + t3 && (this.combinedData = e3[r.CHAR_DATA_CHAR_INDEX], this.content = 2097152 | e3[r.CHAR_DATA_WIDTH_INDEX] << 22); + } + getAsCharData() { + return [this.fg, this.getChars(), this.getWidth(), this.getCode()]; + } + } + t2.CellData = o; + }, 643: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.WHITESPACE_CELL_CODE = t2.WHITESPACE_CELL_WIDTH = t2.WHITESPACE_CELL_CHAR = t2.NULL_CELL_CODE = t2.NULL_CELL_WIDTH = t2.NULL_CELL_CHAR = t2.CHAR_DATA_CODE_INDEX = t2.CHAR_DATA_WIDTH_INDEX = t2.CHAR_DATA_CHAR_INDEX = t2.CHAR_DATA_ATTR_INDEX = t2.DEFAULT_EXT = t2.DEFAULT_ATTR = t2.DEFAULT_COLOR = void 0, t2.DEFAULT_COLOR = 0, t2.DEFAULT_ATTR = 256 | t2.DEFAULT_COLOR << 9, t2.DEFAULT_EXT = 0, t2.CHAR_DATA_ATTR_INDEX = 0, t2.CHAR_DATA_CHAR_INDEX = 1, t2.CHAR_DATA_WIDTH_INDEX = 2, t2.CHAR_DATA_CODE_INDEX = 3, t2.NULL_CELL_CHAR = "", t2.NULL_CELL_WIDTH = 1, t2.NULL_CELL_CODE = 0, t2.WHITESPACE_CELL_CHAR = " ", t2.WHITESPACE_CELL_WIDTH = 1, t2.WHITESPACE_CELL_CODE = 32; + }, 4863: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.Marker = void 0; + const s2 = i2(8460), r = i2(844); + class n { + get id() { + return this._id; + } + constructor(e3) { + this.line = e3, this.isDisposed = false, this._disposables = [], this._id = n._nextId++, this._onDispose = this.register(new s2.EventEmitter()), this.onDispose = this._onDispose.event; + } + dispose() { + this.isDisposed || (this.isDisposed = true, this.line = -1, this._onDispose.fire(), (0, r.disposeArray)(this._disposables), this._disposables.length = 0); + } + register(e3) { + return this._disposables.push(e3), e3; + } + } + t2.Marker = n, n._nextId = 1; + }, 7116: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.DEFAULT_CHARSET = t2.CHARSETS = void 0, t2.CHARSETS = {}, t2.DEFAULT_CHARSET = t2.CHARSETS.B, t2.CHARSETS[0] = { "`": "\u25C6", a: "\u2592", b: "\u2409", c: "\u240C", d: "\u240D", e: "\u240A", f: "\xB0", g: "\xB1", h: "\u2424", i: "\u240B", j: "\u2518", k: "\u2510", l: "\u250C", m: "\u2514", n: "\u253C", o: "\u23BA", p: "\u23BB", q: "\u2500", r: "\u23BC", s: "\u23BD", t: "\u251C", u: "\u2524", v: "\u2534", w: "\u252C", x: "\u2502", y: "\u2264", z: "\u2265", "{": "\u03C0", "|": "\u2260", "}": "\xA3", "~": "\xB7" }, t2.CHARSETS.A = { "#": "\xA3" }, t2.CHARSETS.B = void 0, t2.CHARSETS[4] = { "#": "\xA3", "@": "\xBE", "[": "ij", "\\": "\xBD", "]": "|", "{": "\xA8", "|": "f", "}": "\xBC", "~": "\xB4" }, t2.CHARSETS.C = t2.CHARSETS[5] = { "[": "\xC4", "\\": "\xD6", "]": "\xC5", "^": "\xDC", "`": "\xE9", "{": "\xE4", "|": "\xF6", "}": "\xE5", "~": "\xFC" }, t2.CHARSETS.R = { "#": "\xA3", "@": "\xE0", "[": "\xB0", "\\": "\xE7", "]": "\xA7", "{": "\xE9", "|": "\xF9", "}": "\xE8", "~": "\xA8" }, t2.CHARSETS.Q = { "@": "\xE0", "[": "\xE2", "\\": "\xE7", "]": "\xEA", "^": "\xEE", "`": "\xF4", "{": "\xE9", "|": "\xF9", "}": "\xE8", "~": "\xFB" }, t2.CHARSETS.K = { "@": "\xA7", "[": "\xC4", "\\": "\xD6", "]": "\xDC", "{": "\xE4", "|": "\xF6", "}": "\xFC", "~": "\xDF" }, t2.CHARSETS.Y = { "#": "\xA3", "@": "\xA7", "[": "\xB0", "\\": "\xE7", "]": "\xE9", "`": "\xF9", "{": "\xE0", "|": "\xF2", "}": "\xE8", "~": "\xEC" }, t2.CHARSETS.E = t2.CHARSETS[6] = { "@": "\xC4", "[": "\xC6", "\\": "\xD8", "]": "\xC5", "^": "\xDC", "`": "\xE4", "{": "\xE6", "|": "\xF8", "}": "\xE5", "~": "\xFC" }, t2.CHARSETS.Z = { "#": "\xA3", "@": "\xA7", "[": "\xA1", "\\": "\xD1", "]": "\xBF", "{": "\xB0", "|": "\xF1", "}": "\xE7" }, t2.CHARSETS.H = t2.CHARSETS[7] = { "@": "\xC9", "[": "\xC4", "\\": "\xD6", "]": "\xC5", "^": "\xDC", "`": "\xE9", "{": "\xE4", "|": "\xF6", "}": "\xE5", "~": "\xFC" }, t2.CHARSETS["="] = { "#": "\xF9", "@": "\xE0", "[": "\xE9", "\\": "\xE7", "]": "\xEA", "^": "\xEE", _: "\xE8", "`": "\xF4", "{": "\xE4", "|": "\xF6", "}": "\xFC", "~": "\xFB" }; + }, 2584: (e2, t2) => { + var i2, s2, r; + Object.defineProperty(t2, "__esModule", { value: true }), t2.C1_ESCAPED = t2.C1 = t2.C0 = void 0, (function(e3) { + e3.NUL = "\0", e3.SOH = "", e3.STX = "", e3.ETX = "", e3.EOT = "", e3.ENQ = "", e3.ACK = "", e3.BEL = "\x07", e3.BS = "\b", e3.HT = " ", e3.LF = "\n", e3.VT = "\v", e3.FF = "\f", e3.CR = "\r", e3.SO = "", e3.SI = "", e3.DLE = "", e3.DC1 = "", e3.DC2 = "", e3.DC3 = "", e3.DC4 = "", e3.NAK = "", e3.SYN = "", e3.ETB = "", e3.CAN = "", e3.EM = "", e3.SUB = "", e3.ESC = "\x1B", e3.FS = "", e3.GS = "", e3.RS = "", e3.US = "", e3.SP = " ", e3.DEL = "\x7F"; + })(i2 || (t2.C0 = i2 = {})), (function(e3) { + e3.PAD = "\x80", e3.HOP = "\x81", e3.BPH = "\x82", e3.NBH = "\x83", e3.IND = "\x84", e3.NEL = "\x85", e3.SSA = "\x86", e3.ESA = "\x87", e3.HTS = "\x88", e3.HTJ = "\x89", e3.VTS = "\x8A", e3.PLD = "\x8B", e3.PLU = "\x8C", e3.RI = "\x8D", e3.SS2 = "\x8E", e3.SS3 = "\x8F", e3.DCS = "\x90", e3.PU1 = "\x91", e3.PU2 = "\x92", e3.STS = "\x93", e3.CCH = "\x94", e3.MW = "\x95", e3.SPA = "\x96", e3.EPA = "\x97", e3.SOS = "\x98", e3.SGCI = "\x99", e3.SCI = "\x9A", e3.CSI = "\x9B", e3.ST = "\x9C", e3.OSC = "\x9D", e3.PM = "\x9E", e3.APC = "\x9F"; + })(s2 || (t2.C1 = s2 = {})), (function(e3) { + e3.ST = `${i2.ESC}\\`; + })(r || (t2.C1_ESCAPED = r = {})); + }, 7399: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.evaluateKeyboardEvent = void 0; + const s2 = i2(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: ["'", '"'] }; + t2.evaluateKeyboardEvent = function(e3, t3, i3, n) { + const o = { type: 0, cancel: false, key: void 0 }, a = (e3.shiftKey ? 1 : 0) | (e3.altKey ? 2 : 0) | (e3.ctrlKey ? 4 : 0) | (e3.metaKey ? 8 : 0); + switch (e3.keyCode) { + case 0: + "UIKeyInputUpArrow" === e3.key ? o.key = t3 ? s2.C0.ESC + "OA" : s2.C0.ESC + "[A" : "UIKeyInputLeftArrow" === e3.key ? o.key = t3 ? s2.C0.ESC + "OD" : s2.C0.ESC + "[D" : "UIKeyInputRightArrow" === e3.key ? o.key = t3 ? s2.C0.ESC + "OC" : s2.C0.ESC + "[C" : "UIKeyInputDownArrow" === e3.key && (o.key = t3 ? s2.C0.ESC + "OB" : s2.C0.ESC + "[B"); + break; + case 8: + if (e3.altKey) { + o.key = s2.C0.ESC + s2.C0.DEL; + break; + } + o.key = s2.C0.DEL; + break; + case 9: + if (e3.shiftKey) { + o.key = s2.C0.ESC + "[Z"; + break; + } + o.key = s2.C0.HT, o.cancel = true; + break; + case 13: + o.key = e3.altKey ? s2.C0.ESC + s2.C0.CR : s2.C0.CR, o.cancel = true; + break; + case 27: + o.key = s2.C0.ESC, e3.altKey && (o.key = s2.C0.ESC + s2.C0.ESC), o.cancel = true; + break; + case 37: + if (e3.metaKey) break; + a ? (o.key = s2.C0.ESC + "[1;" + (a + 1) + "D", o.key === s2.C0.ESC + "[1;3D" && (o.key = s2.C0.ESC + (i3 ? "b" : "[1;5D"))) : o.key = t3 ? s2.C0.ESC + "OD" : s2.C0.ESC + "[D"; + break; + case 39: + if (e3.metaKey) break; + a ? (o.key = s2.C0.ESC + "[1;" + (a + 1) + "C", o.key === s2.C0.ESC + "[1;3C" && (o.key = s2.C0.ESC + (i3 ? "f" : "[1;5C"))) : o.key = t3 ? s2.C0.ESC + "OC" : s2.C0.ESC + "[C"; + break; + case 38: + if (e3.metaKey) break; + a ? (o.key = s2.C0.ESC + "[1;" + (a + 1) + "A", i3 || o.key !== s2.C0.ESC + "[1;3A" || (o.key = s2.C0.ESC + "[1;5A")) : o.key = t3 ? s2.C0.ESC + "OA" : s2.C0.ESC + "[A"; + break; + case 40: + if (e3.metaKey) break; + a ? (o.key = s2.C0.ESC + "[1;" + (a + 1) + "B", i3 || o.key !== s2.C0.ESC + "[1;3B" || (o.key = s2.C0.ESC + "[1;5B")) : o.key = t3 ? s2.C0.ESC + "OB" : s2.C0.ESC + "[B"; + break; + case 45: + e3.shiftKey || e3.ctrlKey || (o.key = s2.C0.ESC + "[2~"); + break; + case 46: + o.key = a ? s2.C0.ESC + "[3;" + (a + 1) + "~" : s2.C0.ESC + "[3~"; + break; + case 36: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "H" : t3 ? s2.C0.ESC + "OH" : s2.C0.ESC + "[H"; + break; + case 35: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "F" : t3 ? s2.C0.ESC + "OF" : s2.C0.ESC + "[F"; + break; + case 33: + e3.shiftKey ? o.type = 2 : e3.ctrlKey ? o.key = s2.C0.ESC + "[5;" + (a + 1) + "~" : o.key = s2.C0.ESC + "[5~"; + break; + case 34: + e3.shiftKey ? o.type = 3 : e3.ctrlKey ? o.key = s2.C0.ESC + "[6;" + (a + 1) + "~" : o.key = s2.C0.ESC + "[6~"; + break; + case 112: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "P" : s2.C0.ESC + "OP"; + break; + case 113: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "Q" : s2.C0.ESC + "OQ"; + break; + case 114: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "R" : s2.C0.ESC + "OR"; + break; + case 115: + o.key = a ? s2.C0.ESC + "[1;" + (a + 1) + "S" : s2.C0.ESC + "OS"; + break; + case 116: + o.key = a ? s2.C0.ESC + "[15;" + (a + 1) + "~" : s2.C0.ESC + "[15~"; + break; + case 117: + o.key = a ? s2.C0.ESC + "[17;" + (a + 1) + "~" : s2.C0.ESC + "[17~"; + break; + case 118: + o.key = a ? s2.C0.ESC + "[18;" + (a + 1) + "~" : s2.C0.ESC + "[18~"; + break; + case 119: + o.key = a ? s2.C0.ESC + "[19;" + (a + 1) + "~" : s2.C0.ESC + "[19~"; + break; + case 120: + o.key = a ? s2.C0.ESC + "[20;" + (a + 1) + "~" : s2.C0.ESC + "[20~"; + break; + case 121: + o.key = a ? s2.C0.ESC + "[21;" + (a + 1) + "~" : s2.C0.ESC + "[21~"; + break; + case 122: + o.key = a ? s2.C0.ESC + "[23;" + (a + 1) + "~" : s2.C0.ESC + "[23~"; + break; + case 123: + o.key = a ? s2.C0.ESC + "[24;" + (a + 1) + "~" : s2.C0.ESC + "[24~"; + break; + default: + if (!e3.ctrlKey || e3.shiftKey || e3.altKey || e3.metaKey) if (i3 && !n || !e3.altKey || e3.metaKey) !i3 || e3.altKey || e3.ctrlKey || e3.shiftKey || !e3.metaKey ? e3.key && !e3.ctrlKey && !e3.altKey && !e3.metaKey && e3.keyCode >= 48 && 1 === e3.key.length ? o.key = e3.key : e3.key && e3.ctrlKey && ("_" === e3.key && (o.key = s2.C0.US), "@" === e3.key && (o.key = s2.C0.NUL)) : 65 === e3.keyCode && (o.type = 1); + else { + const t4 = r[e3.keyCode], i4 = null == t4 ? void 0 : t4[e3.shiftKey ? 1 : 0]; + if (i4) o.key = s2.C0.ESC + i4; + else if (e3.keyCode >= 65 && e3.keyCode <= 90) { + const t5 = e3.ctrlKey ? e3.keyCode - 64 : e3.keyCode + 32; + let i5 = String.fromCharCode(t5); + e3.shiftKey && (i5 = i5.toUpperCase()), o.key = s2.C0.ESC + i5; + } else if (32 === e3.keyCode) o.key = s2.C0.ESC + (e3.ctrlKey ? s2.C0.NUL : " "); + else if ("Dead" === e3.key && e3.code.startsWith("Key")) { + let t5 = e3.code.slice(3, 4); + e3.shiftKey || (t5 = t5.toLowerCase()), o.key = s2.C0.ESC + t5, o.cancel = true; + } + } + else e3.keyCode >= 65 && e3.keyCode <= 90 ? o.key = String.fromCharCode(e3.keyCode - 64) : 32 === e3.keyCode ? o.key = s2.C0.NUL : e3.keyCode >= 51 && e3.keyCode <= 55 ? o.key = String.fromCharCode(e3.keyCode - 51 + 27) : 56 === e3.keyCode ? o.key = s2.C0.DEL : 219 === e3.keyCode ? o.key = s2.C0.ESC : 220 === e3.keyCode ? o.key = s2.C0.FS : 221 === e3.keyCode && (o.key = s2.C0.GS); + } + return o; + }; + }, 482: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.Utf8ToUtf32 = t2.StringToUtf32 = t2.utf32ToString = t2.stringFromCodePoint = void 0, t2.stringFromCodePoint = function(e3) { + return e3 > 65535 ? (e3 -= 65536, String.fromCharCode(55296 + (e3 >> 10)) + String.fromCharCode(e3 % 1024 + 56320)) : String.fromCharCode(e3); + }, t2.utf32ToString = function(e3, t3 = 0, i2 = e3.length) { + let s2 = ""; + for (let r = t3; r < i2; ++r) { + let t4 = e3[r]; + t4 > 65535 ? (t4 -= 65536, s2 += String.fromCharCode(55296 + (t4 >> 10)) + String.fromCharCode(t4 % 1024 + 56320)) : s2 += String.fromCharCode(t4); + } + return s2; + }, t2.StringToUtf32 = class { + constructor() { + this._interim = 0; + } + clear() { + this._interim = 0; + } + decode(e3, t3) { + const i2 = e3.length; + if (!i2) return 0; + let s2 = 0, r = 0; + if (this._interim) { + const i3 = e3.charCodeAt(r++); + 56320 <= i3 && i3 <= 57343 ? t3[s2++] = 1024 * (this._interim - 55296) + i3 - 56320 + 65536 : (t3[s2++] = this._interim, t3[s2++] = i3), this._interim = 0; + } + for (let n = r; n < i2; ++n) { + const r2 = e3.charCodeAt(n); + if (55296 <= r2 && r2 <= 56319) { + if (++n >= i2) return this._interim = r2, s2; + const o = e3.charCodeAt(n); + 56320 <= o && o <= 57343 ? t3[s2++] = 1024 * (r2 - 55296) + o - 56320 + 65536 : (t3[s2++] = r2, t3[s2++] = o); + } else 65279 !== r2 && (t3[s2++] = r2); + } + return s2; + } + }, t2.Utf8ToUtf32 = class { + constructor() { + this.interim = new Uint8Array(3); + } + clear() { + this.interim.fill(0); + } + decode(e3, t3) { + const i2 = e3.length; + if (!i2) return 0; + let s2, r, n, o, a = 0, h = 0, c = 0; + if (this.interim[0]) { + let s3 = false, r2 = this.interim[0]; + r2 &= 192 == (224 & r2) ? 31 : 224 == (240 & r2) ? 15 : 7; + let n2, o2 = 0; + for (; (n2 = 63 & this.interim[++o2]) && o2 < 4; ) r2 <<= 6, r2 |= n2; + const h2 = 192 == (224 & this.interim[0]) ? 2 : 224 == (240 & this.interim[0]) ? 3 : 4, l2 = h2 - o2; + for (; c < l2; ) { + if (c >= i2) return 0; + if (n2 = e3[c++], 128 != (192 & n2)) { + c--, s3 = true; + break; + } + this.interim[o2++] = n2, r2 <<= 6, r2 |= 63 & n2; + } + s3 || (2 === h2 ? r2 < 128 ? c-- : t3[a++] = r2 : 3 === h2 ? r2 < 2048 || r2 >= 55296 && r2 <= 57343 || 65279 === r2 || (t3[a++] = r2) : r2 < 65536 || r2 > 1114111 || (t3[a++] = r2)), this.interim.fill(0); + } + const l = i2 - 4; + let d = c; + for (; d < i2; ) { + for (; !(!(d < l) || 128 & (s2 = e3[d]) || 128 & (r = e3[d + 1]) || 128 & (n = e3[d + 2]) || 128 & (o = e3[d + 3])); ) t3[a++] = s2, t3[a++] = r, t3[a++] = n, t3[a++] = o, d += 4; + if (s2 = e3[d++], s2 < 128) t3[a++] = s2; + else if (192 == (224 & s2)) { + if (d >= i2) return this.interim[0] = s2, a; + if (r = e3[d++], 128 != (192 & r)) { + d--; + continue; + } + if (h = (31 & s2) << 6 | 63 & r, h < 128) { + d--; + continue; + } + t3[a++] = h; + } else if (224 == (240 & s2)) { + if (d >= i2) return this.interim[0] = s2, a; + if (r = e3[d++], 128 != (192 & r)) { + d--; + continue; + } + if (d >= i2) return this.interim[0] = s2, this.interim[1] = r, a; + if (n = e3[d++], 128 != (192 & n)) { + d--; + continue; + } + if (h = (15 & s2) << 12 | (63 & r) << 6 | 63 & n, h < 2048 || h >= 55296 && h <= 57343 || 65279 === h) continue; + t3[a++] = h; + } else if (240 == (248 & s2)) { + if (d >= i2) return this.interim[0] = s2, a; + if (r = e3[d++], 128 != (192 & r)) { + d--; + continue; + } + if (d >= i2) return this.interim[0] = s2, this.interim[1] = r, a; + if (n = e3[d++], 128 != (192 & n)) { + d--; + continue; + } + if (d >= i2) return this.interim[0] = s2, this.interim[1] = r, this.interim[2] = n, a; + if (o = e3[d++], 128 != (192 & o)) { + d--; + continue; + } + if (h = (7 & s2) << 18 | (63 & r) << 12 | (63 & n) << 6 | 63 & o, h < 65536 || h > 1114111) continue; + t3[a++] = h; + } + } + return a; + } + }; + }, 225: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.UnicodeV6 = void 0; + const i2 = [[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]], s2 = [[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 r; + t2.UnicodeV6 = class { + constructor() { + if (this.version = "6", !r) { + r = new Uint8Array(65536), r.fill(1), r[0] = 0, r.fill(0, 1, 32), r.fill(0, 127, 160), r.fill(2, 4352, 4448), r[9001] = 2, r[9002] = 2, r.fill(2, 11904, 42192), r[12351] = 1, r.fill(2, 44032, 55204), r.fill(2, 63744, 64256), r.fill(2, 65040, 65050), r.fill(2, 65072, 65136), r.fill(2, 65280, 65377), r.fill(2, 65504, 65511); + for (let e3 = 0; e3 < i2.length; ++e3) r.fill(0, i2[e3][0], i2[e3][1] + 1); + } + } + wcwidth(e3) { + return e3 < 32 ? 0 : e3 < 127 ? 1 : e3 < 65536 ? r[e3] : (function(e4, t3) { + let i3, s3 = 0, r2 = t3.length - 1; + if (e4 < t3[0][0] || e4 > t3[r2][1]) return false; + for (; r2 >= s3; ) if (i3 = s3 + r2 >> 1, e4 > t3[i3][1]) s3 = i3 + 1; + else { + if (!(e4 < t3[i3][0])) return true; + r2 = i3 - 1; + } + return false; + })(e3, s2) ? 0 : e3 >= 131072 && e3 <= 196605 || e3 >= 196608 && e3 <= 262141 ? 2 : 1; + } + }; + }, 5981: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.WriteBuffer = void 0; + const s2 = i2(8460), r = i2(844); + class n extends r.Disposable { + constructor(e3) { + super(), this._action = e3, this._writeBuffer = [], this._callbacks = [], this._pendingData = 0, this._bufferOffset = 0, this._isSyncWriting = false, this._syncCalls = 0, this._didUserInput = false, this._onWriteParsed = this.register(new s2.EventEmitter()), this.onWriteParsed = this._onWriteParsed.event; + } + handleUserInput() { + this._didUserInput = true; + } + writeSync(e3, t3) { + if (void 0 !== t3 && this._syncCalls > t3) return void (this._syncCalls = 0); + if (this._pendingData += e3.length, this._writeBuffer.push(e3), this._callbacks.push(void 0), this._syncCalls++, this._isSyncWriting) return; + let i3; + for (this._isSyncWriting = true; i3 = this._writeBuffer.shift(); ) { + this._action(i3); + const e4 = this._callbacks.shift(); + e4 && e4(); + } + this._pendingData = 0, this._bufferOffset = 2147483647, this._isSyncWriting = false, this._syncCalls = 0; + } + write(e3, t3) { + 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 = false, this._pendingData += e3.length, this._writeBuffer.push(e3), this._callbacks.push(t3), void this._innerWrite(); + setTimeout((() => this._innerWrite())); + } + this._pendingData += e3.length, this._writeBuffer.push(e3), this._callbacks.push(t3); + } + _innerWrite(e3 = 0, t3 = true) { + const i3 = e3 || Date.now(); + for (; this._writeBuffer.length > this._bufferOffset; ) { + const e4 = this._writeBuffer[this._bufferOffset], s3 = this._action(e4, t3); + if (s3) { + const e5 = (e6) => Date.now() - i3 >= 12 ? setTimeout((() => this._innerWrite(0, e6))) : this._innerWrite(i3, e6); + return void s3.catch(((e6) => (queueMicrotask((() => { + throw e6; + })), Promise.resolve(false)))).then(e5); + } + const r2 = this._callbacks[this._bufferOffset]; + if (r2 && r2(), this._bufferOffset++, this._pendingData -= e4.length, Date.now() - i3 >= 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(); + } + } + t2.WriteBuffer = n; + }, 5941: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.toRgbString = t2.parseColor = void 0; + const i2 = /^([\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})$/, s2 = /^[\da-f]+$/; + function r(e3, t3) { + const i3 = e3.toString(16), s3 = i3.length < 2 ? "0" + i3 : i3; + switch (t3) { + case 4: + return i3[0]; + case 8: + return s3; + case 12: + return (s3 + s3).slice(0, 3); + default: + return s3 + s3; + } + } + t2.parseColor = function(e3) { + if (!e3) return; + let t3 = e3.toLowerCase(); + if (0 === t3.indexOf("rgb:")) { + t3 = t3.slice(4); + const e4 = i2.exec(t3); + if (e4) { + const t4 = e4[1] ? 15 : e4[4] ? 255 : e4[7] ? 4095 : 65535; + return [Math.round(parseInt(e4[1] || e4[4] || e4[7] || e4[10], 16) / t4 * 255), Math.round(parseInt(e4[2] || e4[5] || e4[8] || e4[11], 16) / t4 * 255), Math.round(parseInt(e4[3] || e4[6] || e4[9] || e4[12], 16) / t4 * 255)]; + } + } else if (0 === t3.indexOf("#") && (t3 = t3.slice(1), s2.exec(t3) && [3, 6, 9, 12].includes(t3.length))) { + const e4 = t3.length / 3, i3 = [0, 0, 0]; + for (let s3 = 0; s3 < 3; ++s3) { + const r2 = parseInt(t3.slice(e4 * s3, e4 * s3 + e4), 16); + i3[s3] = 1 === e4 ? r2 << 4 : 2 === e4 ? r2 : 3 === e4 ? r2 >> 4 : r2 >> 8; + } + return i3; + } + }, t2.toRgbString = function(e3, t3 = 16) { + const [i3, s3, n] = e3; + return `rgb:${r(i3, t3)}/${r(s3, t3)}/${r(n, t3)}`; + }; + }, 5770: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.PAYLOAD_LIMIT = void 0, t2.PAYLOAD_LIMIT = 1e7; + }, 6351: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.DcsHandler = t2.DcsParser = void 0; + const s2 = i2(482), r = i2(8742), n = i2(5770), o = []; + t2.DcsParser = class { + constructor() { + this._handlers = /* @__PURE__ */ Object.create(null), this._active = o, this._ident = 0, this._handlerFb = () => { + }, this._stack = { paused: false, loopPosition: 0, fallThrough: false }; + } + dispose() { + this._handlers = /* @__PURE__ */ Object.create(null), this._handlerFb = () => { + }, this._active = o; + } + registerHandler(e3, t3) { + void 0 === this._handlers[e3] && (this._handlers[e3] = []); + const i3 = this._handlers[e3]; + return i3.push(t3), { dispose: () => { + const e4 = i3.indexOf(t3); + -1 !== e4 && i3.splice(e4, 1); + } }; + } + clearHandler(e3) { + this._handlers[e3] && delete this._handlers[e3]; + } + setHandlerFallback(e3) { + this._handlerFb = e3; + } + reset() { + if (this._active.length) for (let e3 = this._stack.paused ? this._stack.loopPosition - 1 : this._active.length - 1; e3 >= 0; --e3) this._active[e3].unhook(false); + this._stack.paused = false, this._active = o, this._ident = 0; + } + hook(e3, t3) { + if (this.reset(), this._ident = e3, this._active = this._handlers[e3] || o, this._active.length) for (let e4 = this._active.length - 1; e4 >= 0; e4--) this._active[e4].hook(t3); + else this._handlerFb(this._ident, "HOOK", t3); + } + put(e3, t3, i3) { + if (this._active.length) for (let s3 = this._active.length - 1; s3 >= 0; s3--) this._active[s3].put(e3, t3, i3); + else this._handlerFb(this._ident, "PUT", (0, s2.utf32ToString)(e3, t3, i3)); + } + unhook(e3, t3 = true) { + if (this._active.length) { + let i3 = false, s3 = this._active.length - 1, r2 = false; + if (this._stack.paused && (s3 = this._stack.loopPosition - 1, i3 = t3, r2 = this._stack.fallThrough, this._stack.paused = false), !r2 && false === i3) { + for (; s3 >= 0 && (i3 = this._active[s3].unhook(e3), true !== i3); s3--) if (i3 instanceof Promise) return this._stack.paused = true, this._stack.loopPosition = s3, this._stack.fallThrough = false, i3; + s3--; + } + for (; s3 >= 0; s3--) if (i3 = this._active[s3].unhook(false), i3 instanceof Promise) return this._stack.paused = true, this._stack.loopPosition = s3, this._stack.fallThrough = true, i3; + } else this._handlerFb(this._ident, "UNHOOK", e3); + this._active = o, this._ident = 0; + } + }; + const a = new r.Params(); + a.addParam(0), t2.DcsHandler = class { + constructor(e3) { + this._handler = e3, this._data = "", this._params = a, this._hitLimit = false; + } + hook(e3) { + this._params = e3.length > 1 || e3.params[0] ? e3.clone() : a, this._data = "", this._hitLimit = false; + } + put(e3, t3, i3) { + this._hitLimit || (this._data += (0, s2.utf32ToString)(e3, t3, i3), this._data.length > n.PAYLOAD_LIMIT && (this._data = "", this._hitLimit = true)); + } + unhook(e3) { + let t3 = false; + if (this._hitLimit) t3 = false; + else if (e3 && (t3 = this._handler(this._data, this._params), t3 instanceof Promise)) return t3.then(((e4) => (this._params = a, this._data = "", this._hitLimit = false, e4))); + return this._params = a, this._data = "", this._hitLimit = false, t3; + } + }; + }, 2015: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.EscapeSequenceParser = t2.VT500_TRANSITION_TABLE = t2.TransitionTable = void 0; + const s2 = i2(844), r = i2(8742), n = i2(6242), o = i2(6351); + class a { + constructor(e3) { + this.table = new Uint8Array(e3); + } + setDefault(e3, t3) { + this.table.fill(e3 << 4 | t3); + } + add(e3, t3, i3, s3) { + this.table[t3 << 8 | e3] = i3 << 4 | s3; + } + addMany(e3, t3, i3, s3) { + for (let r2 = 0; r2 < e3.length; r2++) this.table[t3 << 8 | e3[r2]] = i3 << 4 | s3; + } + } + t2.TransitionTable = a; + const h = 160; + t2.VT500_TRANSITION_TABLE = (function() { + const e3 = new a(4095), t3 = Array.apply(null, Array(256)).map(((e4, t4) => t4)), i3 = (e4, i4) => t3.slice(e4, i4), s3 = i3(32, 127), r2 = i3(0, 24); + r2.push(25), r2.push.apply(r2, i3(28, 32)); + const n2 = i3(0, 14); + let o2; + for (o2 in e3.setDefault(1, 0), e3.addMany(s3, 0, 2, 0), n2) e3.addMany([24, 26, 153, 154], o2, 3, 0), e3.addMany(i3(128, 144), o2, 3, 0), e3.addMany(i3(144, 152), o2, 3, 0), e3.add(156, o2, 0, 0), e3.add(27, o2, 11, 1), e3.add(157, o2, 4, 8), e3.addMany([152, 158, 159], o2, 0, 7), e3.add(155, o2, 11, 3), e3.add(144, o2, 11, 9); + return e3.addMany(r2, 0, 3, 0), e3.addMany(r2, 1, 3, 1), e3.add(127, 1, 0, 1), e3.addMany(r2, 8, 0, 8), e3.addMany(r2, 3, 3, 3), e3.add(127, 3, 0, 3), e3.addMany(r2, 4, 3, 4), e3.add(127, 4, 0, 4), e3.addMany(r2, 6, 3, 6), e3.addMany(r2, 5, 3, 5), e3.add(127, 5, 0, 5), e3.addMany(r2, 2, 3, 2), e3.add(127, 2, 0, 2), e3.add(93, 1, 4, 8), e3.addMany(s3, 8, 5, 8), e3.add(127, 8, 5, 8), e3.addMany([156, 27, 24, 26, 7], 8, 6, 0), e3.addMany(i3(28, 32), 8, 0, 8), e3.addMany([88, 94, 95], 1, 0, 7), e3.addMany(s3, 7, 0, 7), e3.addMany(r2, 7, 0, 7), e3.add(156, 7, 0, 0), e3.add(127, 7, 0, 7), e3.add(91, 1, 11, 3), e3.addMany(i3(64, 127), 3, 7, 0), e3.addMany(i3(48, 60), 3, 8, 4), e3.addMany([60, 61, 62, 63], 3, 9, 4), e3.addMany(i3(48, 60), 4, 8, 4), e3.addMany(i3(64, 127), 4, 7, 0), e3.addMany([60, 61, 62, 63], 4, 0, 6), e3.addMany(i3(32, 64), 6, 0, 6), e3.add(127, 6, 0, 6), e3.addMany(i3(64, 127), 6, 0, 0), e3.addMany(i3(32, 48), 3, 9, 5), e3.addMany(i3(32, 48), 5, 9, 5), e3.addMany(i3(48, 64), 5, 0, 6), e3.addMany(i3(64, 127), 5, 7, 0), e3.addMany(i3(32, 48), 4, 9, 5), e3.addMany(i3(32, 48), 1, 9, 2), e3.addMany(i3(32, 48), 2, 9, 2), e3.addMany(i3(48, 127), 2, 10, 0), e3.addMany(i3(48, 80), 1, 10, 0), e3.addMany(i3(81, 88), 1, 10, 0), e3.addMany([89, 90, 92], 1, 10, 0), e3.addMany(i3(96, 127), 1, 10, 0), e3.add(80, 1, 11, 9), e3.addMany(r2, 9, 0, 9), e3.add(127, 9, 0, 9), e3.addMany(i3(28, 32), 9, 0, 9), e3.addMany(i3(32, 48), 9, 9, 12), e3.addMany(i3(48, 60), 9, 8, 10), e3.addMany([60, 61, 62, 63], 9, 9, 10), e3.addMany(r2, 11, 0, 11), e3.addMany(i3(32, 128), 11, 0, 11), e3.addMany(i3(28, 32), 11, 0, 11), e3.addMany(r2, 10, 0, 10), e3.add(127, 10, 0, 10), e3.addMany(i3(28, 32), 10, 0, 10), e3.addMany(i3(48, 60), 10, 8, 10), e3.addMany([60, 61, 62, 63], 10, 0, 11), e3.addMany(i3(32, 48), 10, 9, 12), e3.addMany(r2, 12, 0, 12), e3.add(127, 12, 0, 12), e3.addMany(i3(28, 32), 12, 0, 12), e3.addMany(i3(32, 48), 12, 9, 12), e3.addMany(i3(48, 64), 12, 0, 11), e3.addMany(i3(64, 127), 12, 12, 13), e3.addMany(i3(64, 127), 10, 12, 13), e3.addMany(i3(64, 127), 9, 12, 13), e3.addMany(r2, 13, 13, 13), e3.addMany(s3, 13, 13, 13), e3.add(127, 13, 0, 13), e3.addMany([27, 156, 24, 26], 13, 14, 0), e3.add(h, 0, 2, 0), e3.add(h, 8, 5, 8), e3.add(h, 6, 0, 6), e3.add(h, 11, 0, 11), e3.add(h, 13, 13, 13), e3; + })(); + class c extends s2.Disposable { + constructor(e3 = t2.VT500_TRANSITION_TABLE) { + super(), this._transitions = e3, 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.precedingCodepoint = 0, this._printHandlerFb = (e4, t3, i3) => { + }, this._executeHandlerFb = (e4) => { + }, this._csiHandlerFb = (e4, t3) => { + }, this._escHandlerFb = (e4) => { + }, this._errorHandlerFb = (e4) => e4, this._printHandler = this._printHandlerFb, this._executeHandlers = /* @__PURE__ */ Object.create(null), this._csiHandlers = /* @__PURE__ */ Object.create(null), this._escHandlers = /* @__PURE__ */ Object.create(null), this.register((0, s2.toDisposable)((() => { + this._csiHandlers = /* @__PURE__ */ Object.create(null), this._executeHandlers = /* @__PURE__ */ Object.create(null), this._escHandlers = /* @__PURE__ */ Object.create(null); + }))), this._oscParser = this.register(new n.OscParser()), this._dcsParser = this.register(new o.DcsParser()), this._errorHandler = this._errorHandlerFb, this.registerEscHandler({ final: "\\" }, (() => true)); + } + _identifier(e3, t3 = [64, 126]) { + let i3 = 0; + if (e3.prefix) { + if (e3.prefix.length > 1) throw new Error("only one byte as prefix supported"); + if (i3 = e3.prefix.charCodeAt(0), i3 && 60 > i3 || i3 > 63) throw new Error("prefix must be in range 0x3c .. 0x3f"); + } + if (e3.intermediates) { + if (e3.intermediates.length > 2) throw new Error("only two bytes as intermediates are supported"); + for (let t4 = 0; t4 < e3.intermediates.length; ++t4) { + const s4 = e3.intermediates.charCodeAt(t4); + if (32 > s4 || s4 > 47) throw new Error("intermediate must be in range 0x20 .. 0x2f"); + i3 <<= 8, i3 |= s4; + } + } + if (1 !== e3.final.length) throw new Error("final must be a single byte"); + const s3 = e3.final.charCodeAt(0); + if (t3[0] > s3 || s3 > t3[1]) throw new Error(`final must be in range ${t3[0]} .. ${t3[1]}`); + return i3 <<= 8, i3 |= s3, i3; + } + identToString(e3) { + const t3 = []; + for (; e3; ) t3.push(String.fromCharCode(255 & e3)), e3 >>= 8; + return t3.reverse().join(""); + } + setPrintHandler(e3) { + this._printHandler = e3; + } + clearPrintHandler() { + this._printHandler = this._printHandlerFb; + } + registerEscHandler(e3, t3) { + const i3 = this._identifier(e3, [48, 126]); + void 0 === this._escHandlers[i3] && (this._escHandlers[i3] = []); + const s3 = this._escHandlers[i3]; + return s3.push(t3), { dispose: () => { + const e4 = s3.indexOf(t3); + -1 !== e4 && s3.splice(e4, 1); + } }; + } + clearEscHandler(e3) { + this._escHandlers[this._identifier(e3, [48, 126])] && delete this._escHandlers[this._identifier(e3, [48, 126])]; + } + setEscHandlerFallback(e3) { + this._escHandlerFb = e3; + } + setExecuteHandler(e3, t3) { + this._executeHandlers[e3.charCodeAt(0)] = t3; + } + clearExecuteHandler(e3) { + this._executeHandlers[e3.charCodeAt(0)] && delete this._executeHandlers[e3.charCodeAt(0)]; + } + setExecuteHandlerFallback(e3) { + this._executeHandlerFb = e3; + } + registerCsiHandler(e3, t3) { + const i3 = this._identifier(e3); + void 0 === this._csiHandlers[i3] && (this._csiHandlers[i3] = []); + const s3 = this._csiHandlers[i3]; + return s3.push(t3), { dispose: () => { + const e4 = s3.indexOf(t3); + -1 !== e4 && s3.splice(e4, 1); + } }; + } + clearCsiHandler(e3) { + this._csiHandlers[this._identifier(e3)] && delete this._csiHandlers[this._identifier(e3)]; + } + setCsiHandlerFallback(e3) { + this._csiHandlerFb = e3; + } + registerDcsHandler(e3, t3) { + return this._dcsParser.registerHandler(this._identifier(e3), t3); + } + clearDcsHandler(e3) { + this._dcsParser.clearHandler(this._identifier(e3)); + } + setDcsHandlerFallback(e3) { + this._dcsParser.setHandlerFallback(e3); + } + registerOscHandler(e3, t3) { + return this._oscParser.registerHandler(e3, t3); + } + clearOscHandler(e3) { + this._oscParser.clearHandler(e3); + } + setOscHandlerFallback(e3) { + this._oscParser.setHandlerFallback(e3); + } + setErrorHandler(e3) { + this._errorHandler = e3; + } + 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.precedingCodepoint = 0, 0 !== this._parseStack.state && (this._parseStack.state = 2, this._parseStack.handlers = []); + } + _preserveStack(e3, t3, i3, s3, r2) { + this._parseStack.state = e3, this._parseStack.handlers = t3, this._parseStack.handlerPos = i3, this._parseStack.transition = s3, this._parseStack.chunkPos = r2; + } + parse(e3, t3, i3) { + let s3, r2 = 0, n2 = 0, o2 = 0; + if (this._parseStack.state) if (2 === this._parseStack.state) this._parseStack.state = 0, o2 = this._parseStack.chunkPos + 1; + else { + if (void 0 === i3 || 1 === this._parseStack.state) throw this._parseStack.state = 1, new Error("improper continuation due to previous async handler, giving up parsing"); + const t4 = this._parseStack.handlers; + let n3 = this._parseStack.handlerPos - 1; + switch (this._parseStack.state) { + case 3: + if (false === i3 && n3 > -1) { + for (; n3 >= 0 && (s3 = t4[n3](this._params), true !== s3); n3--) if (s3 instanceof Promise) return this._parseStack.handlerPos = n3, s3; + } + this._parseStack.handlers = []; + break; + case 4: + if (false === i3 && n3 > -1) { + for (; n3 >= 0 && (s3 = t4[n3](), true !== s3); n3--) if (s3 instanceof Promise) return this._parseStack.handlerPos = n3, s3; + } + this._parseStack.handlers = []; + break; + case 6: + if (r2 = e3[this._parseStack.chunkPos], s3 = this._dcsParser.unhook(24 !== r2 && 26 !== r2, i3), s3) return s3; + 27 === r2 && (this._parseStack.transition |= 1), this._params.reset(), this._params.addParam(0), this._collect = 0; + break; + case 5: + if (r2 = e3[this._parseStack.chunkPos], s3 = this._oscParser.end(24 !== r2 && 26 !== r2, i3), s3) return s3; + 27 === r2 && (this._parseStack.transition |= 1), this._params.reset(), this._params.addParam(0), this._collect = 0; + } + this._parseStack.state = 0, o2 = this._parseStack.chunkPos + 1, this.precedingCodepoint = 0, this.currentState = 15 & this._parseStack.transition; + } + for (let i4 = o2; i4 < t3; ++i4) { + switch (r2 = e3[i4], n2 = this._transitions.table[this.currentState << 8 | (r2 < 160 ? r2 : h)], n2 >> 4) { + case 2: + for (let s4 = i4 + 1; ; ++s4) { + if (s4 >= t3 || (r2 = e3[s4]) < 32 || r2 > 126 && r2 < h) { + this._printHandler(e3, i4, s4), i4 = s4 - 1; + break; + } + if (++s4 >= t3 || (r2 = e3[s4]) < 32 || r2 > 126 && r2 < h) { + this._printHandler(e3, i4, s4), i4 = s4 - 1; + break; + } + if (++s4 >= t3 || (r2 = e3[s4]) < 32 || r2 > 126 && r2 < h) { + this._printHandler(e3, i4, s4), i4 = s4 - 1; + break; + } + if (++s4 >= t3 || (r2 = e3[s4]) < 32 || r2 > 126 && r2 < h) { + this._printHandler(e3, i4, s4), i4 = s4 - 1; + break; + } + } + break; + case 3: + this._executeHandlers[r2] ? this._executeHandlers[r2]() : this._executeHandlerFb(r2), this.precedingCodepoint = 0; + break; + case 0: + break; + case 1: + if (this._errorHandler({ position: i4, code: r2, currentState: this.currentState, collect: this._collect, params: this._params, abort: false }).abort) return; + break; + case 7: + const o3 = this._csiHandlers[this._collect << 8 | r2]; + let a2 = o3 ? o3.length - 1 : -1; + for (; a2 >= 0 && (s3 = o3[a2](this._params), true !== s3); a2--) if (s3 instanceof Promise) return this._preserveStack(3, o3, a2, n2, i4), s3; + a2 < 0 && this._csiHandlerFb(this._collect << 8 | r2, this._params), this.precedingCodepoint = 0; + break; + case 8: + do { + switch (r2) { + case 59: + this._params.addParam(0); + break; + case 58: + this._params.addSubParam(-1); + break; + default: + this._params.addDigit(r2 - 48); + } + } while (++i4 < t3 && (r2 = e3[i4]) > 47 && r2 < 60); + i4--; + break; + case 9: + this._collect <<= 8, this._collect |= r2; + break; + case 10: + const c2 = this._escHandlers[this._collect << 8 | r2]; + let l = c2 ? c2.length - 1 : -1; + for (; l >= 0 && (s3 = c2[l](), true !== s3); l--) if (s3 instanceof Promise) return this._preserveStack(4, c2, l, n2, i4), s3; + l < 0 && this._escHandlerFb(this._collect << 8 | r2), this.precedingCodepoint = 0; + break; + case 11: + this._params.reset(), this._params.addParam(0), this._collect = 0; + break; + case 12: + this._dcsParser.hook(this._collect << 8 | r2, this._params); + break; + case 13: + for (let s4 = i4 + 1; ; ++s4) if (s4 >= t3 || 24 === (r2 = e3[s4]) || 26 === r2 || 27 === r2 || r2 > 127 && r2 < h) { + this._dcsParser.put(e3, i4, s4), i4 = s4 - 1; + break; + } + break; + case 14: + if (s3 = this._dcsParser.unhook(24 !== r2 && 26 !== r2), s3) return this._preserveStack(6, [], 0, n2, i4), s3; + 27 === r2 && (n2 |= 1), this._params.reset(), this._params.addParam(0), this._collect = 0, this.precedingCodepoint = 0; + break; + case 4: + this._oscParser.start(); + break; + case 5: + for (let s4 = i4 + 1; ; s4++) if (s4 >= t3 || (r2 = e3[s4]) < 32 || r2 > 127 && r2 < h) { + this._oscParser.put(e3, i4, s4), i4 = s4 - 1; + break; + } + break; + case 6: + if (s3 = this._oscParser.end(24 !== r2 && 26 !== r2), s3) return this._preserveStack(5, [], 0, n2, i4), s3; + 27 === r2 && (n2 |= 1), this._params.reset(), this._params.addParam(0), this._collect = 0, this.precedingCodepoint = 0; + } + this.currentState = 15 & n2; + } + } + } + t2.EscapeSequenceParser = c; + }, 6242: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.OscHandler = t2.OscParser = void 0; + const s2 = i2(5770), r = i2(482), n = []; + t2.OscParser = class { + constructor() { + this._state = 0, this._active = n, this._id = -1, this._handlers = /* @__PURE__ */ Object.create(null), this._handlerFb = () => { + }, this._stack = { paused: false, loopPosition: 0, fallThrough: false }; + } + registerHandler(e3, t3) { + void 0 === this._handlers[e3] && (this._handlers[e3] = []); + const i3 = this._handlers[e3]; + return i3.push(t3), { dispose: () => { + const e4 = i3.indexOf(t3); + -1 !== e4 && i3.splice(e4, 1); + } }; + } + clearHandler(e3) { + this._handlers[e3] && delete this._handlers[e3]; + } + setHandlerFallback(e3) { + this._handlerFb = e3; + } + dispose() { + this._handlers = /* @__PURE__ */ Object.create(null), this._handlerFb = () => { + }, this._active = n; + } + reset() { + if (2 === this._state) for (let e3 = this._stack.paused ? this._stack.loopPosition - 1 : this._active.length - 1; e3 >= 0; --e3) this._active[e3].end(false); + this._stack.paused = false, this._active = n, this._id = -1, this._state = 0; + } + _start() { + if (this._active = this._handlers[this._id] || n, this._active.length) for (let e3 = this._active.length - 1; e3 >= 0; e3--) this._active[e3].start(); + else this._handlerFb(this._id, "START"); + } + _put(e3, t3, i3) { + if (this._active.length) for (let s3 = this._active.length - 1; s3 >= 0; s3--) this._active[s3].put(e3, t3, i3); + else this._handlerFb(this._id, "PUT", (0, r.utf32ToString)(e3, t3, i3)); + } + start() { + this.reset(), this._state = 1; + } + put(e3, t3, i3) { + if (3 !== this._state) { + if (1 === this._state) for (; t3 < i3; ) { + const i4 = e3[t3++]; + if (59 === i4) { + this._state = 2, this._start(); + break; + } + if (i4 < 48 || 57 < i4) return void (this._state = 3); + -1 === this._id && (this._id = 0), this._id = 10 * this._id + i4 - 48; + } + 2 === this._state && i3 - t3 > 0 && this._put(e3, t3, i3); + } + } + end(e3, t3 = true) { + if (0 !== this._state) { + if (3 !== this._state) if (1 === this._state && this._start(), this._active.length) { + let i3 = false, s3 = this._active.length - 1, r2 = false; + if (this._stack.paused && (s3 = this._stack.loopPosition - 1, i3 = t3, r2 = this._stack.fallThrough, this._stack.paused = false), !r2 && false === i3) { + for (; s3 >= 0 && (i3 = this._active[s3].end(e3), true !== i3); s3--) if (i3 instanceof Promise) return this._stack.paused = true, this._stack.loopPosition = s3, this._stack.fallThrough = false, i3; + s3--; + } + for (; s3 >= 0; s3--) if (i3 = this._active[s3].end(false), i3 instanceof Promise) return this._stack.paused = true, this._stack.loopPosition = s3, this._stack.fallThrough = true, i3; + } else this._handlerFb(this._id, "END", e3); + this._active = n, this._id = -1, this._state = 0; + } + } + }, t2.OscHandler = class { + constructor(e3) { + this._handler = e3, this._data = "", this._hitLimit = false; + } + start() { + this._data = "", this._hitLimit = false; + } + put(e3, t3, i3) { + this._hitLimit || (this._data += (0, r.utf32ToString)(e3, t3, i3), this._data.length > s2.PAYLOAD_LIMIT && (this._data = "", this._hitLimit = true)); + } + end(e3) { + let t3 = false; + if (this._hitLimit) t3 = false; + else if (e3 && (t3 = this._handler(this._data), t3 instanceof Promise)) return t3.then(((e4) => (this._data = "", this._hitLimit = false, e4))); + return this._data = "", this._hitLimit = false, t3; + } + }; + }, 8742: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.Params = void 0; + const i2 = 2147483647; + class s2 { + static fromArray(e3) { + const t3 = new s2(); + if (!e3.length) return t3; + for (let i3 = Array.isArray(e3[0]) ? 1 : 0; i3 < e3.length; ++i3) { + const s3 = e3[i3]; + if (Array.isArray(s3)) for (let e4 = 0; e4 < s3.length; ++e4) t3.addSubParam(s3[e4]); + else t3.addParam(s3); + } + return t3; + } + constructor(e3 = 32, t3 = 32) { + if (this.maxLength = e3, this.maxSubParamsLength = t3, t3 > 256) throw new Error("maxSubParamsLength must not be greater than 256"); + this.params = new Int32Array(e3), this.length = 0, this._subParams = new Int32Array(t3), this._subParamsLength = 0, this._subParamsIdx = new Uint16Array(e3), this._rejectDigits = false, this._rejectSubDigits = false, this._digitIsSub = false; + } + clone() { + const e3 = new s2(this.maxLength, this.maxSubParamsLength); + return e3.params.set(this.params), e3.length = this.length, e3._subParams.set(this._subParams), e3._subParamsLength = this._subParamsLength, e3._subParamsIdx.set(this._subParamsIdx), e3._rejectDigits = this._rejectDigits, e3._rejectSubDigits = this._rejectSubDigits, e3._digitIsSub = this._digitIsSub, e3; + } + toArray() { + const e3 = []; + for (let t3 = 0; t3 < this.length; ++t3) { + e3.push(this.params[t3]); + const i3 = this._subParamsIdx[t3] >> 8, s3 = 255 & this._subParamsIdx[t3]; + s3 - i3 > 0 && e3.push(Array.prototype.slice.call(this._subParams, i3, s3)); + } + return e3; + } + reset() { + this.length = 0, this._subParamsLength = 0, this._rejectDigits = false, this._rejectSubDigits = false, this._digitIsSub = false; + } + addParam(e3) { + if (this._digitIsSub = false, this.length >= this.maxLength) this._rejectDigits = true; + else { + if (e3 < -1) throw new Error("values lesser than -1 are not allowed"); + this._subParamsIdx[this.length] = this._subParamsLength << 8 | this._subParamsLength, this.params[this.length++] = e3 > i2 ? i2 : e3; + } + } + addSubParam(e3) { + if (this._digitIsSub = true, this.length) if (this._rejectDigits || this._subParamsLength >= this.maxSubParamsLength) this._rejectSubDigits = true; + else { + if (e3 < -1) throw new Error("values lesser than -1 are not allowed"); + this._subParams[this._subParamsLength++] = e3 > i2 ? i2 : e3, this._subParamsIdx[this.length - 1]++; + } + } + hasSubParams(e3) { + return (255 & this._subParamsIdx[e3]) - (this._subParamsIdx[e3] >> 8) > 0; + } + getSubParams(e3) { + const t3 = this._subParamsIdx[e3] >> 8, i3 = 255 & this._subParamsIdx[e3]; + return i3 - t3 > 0 ? this._subParams.subarray(t3, i3) : null; + } + getSubParamsAll() { + const e3 = {}; + for (let t3 = 0; t3 < this.length; ++t3) { + const i3 = this._subParamsIdx[t3] >> 8, s3 = 255 & this._subParamsIdx[t3]; + s3 - i3 > 0 && (e3[t3] = this._subParams.slice(i3, s3)); + } + return e3; + } + addDigit(e3) { + let t3; + if (this._rejectDigits || !(t3 = this._digitIsSub ? this._subParamsLength : this.length) || this._digitIsSub && this._rejectSubDigits) return; + const s3 = this._digitIsSub ? this._subParams : this.params, r = s3[t3 - 1]; + s3[t3 - 1] = ~r ? Math.min(10 * r + e3, i2) : e3; + } + } + t2.Params = s2; + }, 5741: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.AddonManager = void 0, t2.AddonManager = class { + constructor() { + this._addons = []; + } + dispose() { + for (let e3 = this._addons.length - 1; e3 >= 0; e3--) this._addons[e3].instance.dispose(); + } + loadAddon(e3, t3) { + const i2 = { instance: t3, dispose: t3.dispose, isDisposed: false }; + this._addons.push(i2), t3.dispose = () => this._wrappedAddonDispose(i2), t3.activate(e3); + } + _wrappedAddonDispose(e3) { + if (e3.isDisposed) return; + let t3 = -1; + for (let i2 = 0; i2 < this._addons.length; i2++) if (this._addons[i2] === e3) { + t3 = i2; + break; + } + if (-1 === t3) throw new Error("Could not dispose an addon that has not been loaded"); + e3.isDisposed = true, e3.dispose.apply(e3.instance), this._addons.splice(t3, 1); + } + }; + }, 8771: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferApiView = void 0; + const s2 = i2(3785), r = i2(511); + t2.BufferApiView = class { + constructor(e3, t3) { + this._buffer = e3, this.type = t3; + } + init(e3) { + return this._buffer = e3, 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(e3) { + const t3 = this._buffer.lines.get(e3); + if (t3) return new s2.BufferLineApiView(t3); + } + getNullCell() { + return new r.CellData(); + } + }; + }, 3785: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferLineApiView = void 0; + const s2 = i2(511); + t2.BufferLineApiView = class { + constructor(e3) { + this._line = e3; + } + get isWrapped() { + return this._line.isWrapped; + } + get length() { + return this._line.length; + } + getCell(e3, t3) { + if (!(e3 < 0 || e3 >= this._line.length)) return t3 ? (this._line.loadCell(e3, t3), t3) : this._line.loadCell(e3, new s2.CellData()); + } + translateToString(e3, t3, i3) { + return this._line.translateToString(e3, t3, i3); + } + }; + }, 8285: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferNamespaceApi = void 0; + const s2 = i2(8771), r = i2(8460), n = i2(844); + class o extends n.Disposable { + constructor(e3) { + super(), this._core = e3, this._onBufferChange = this.register(new r.EventEmitter()), this.onBufferChange = this._onBufferChange.event, this._normal = new s2.BufferApiView(this._core.buffers.normal, "normal"), this._alternate = new s2.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); + } + } + t2.BufferNamespaceApi = o; + }, 7975: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.ParserApi = void 0, t2.ParserApi = class { + constructor(e3) { + this._core = e3; + } + registerCsiHandler(e3, t3) { + return this._core.registerCsiHandler(e3, ((e4) => t3(e4.toArray()))); + } + addCsiHandler(e3, t3) { + return this.registerCsiHandler(e3, t3); + } + registerDcsHandler(e3, t3) { + return this._core.registerDcsHandler(e3, ((e4, i2) => t3(e4, i2.toArray()))); + } + addDcsHandler(e3, t3) { + return this.registerDcsHandler(e3, t3); + } + registerEscHandler(e3, t3) { + return this._core.registerEscHandler(e3, t3); + } + addEscHandler(e3, t3) { + return this.registerEscHandler(e3, t3); + } + registerOscHandler(e3, t3) { + return this._core.registerOscHandler(e3, t3); + } + addOscHandler(e3, t3) { + return this.registerOscHandler(e3, t3); + } + }; + }, 7090: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.UnicodeApi = void 0, t2.UnicodeApi = class { + constructor(e3) { + this._core = e3; + } + register(e3) { + this._core.unicodeService.register(e3); + } + get versions() { + return this._core.unicodeService.versions; + } + get activeVersion() { + return this._core.unicodeService.activeVersion; + } + set activeVersion(e3) { + this._core.unicodeService.activeVersion = e3; + } + }; + }, 744: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.BufferService = t2.MINIMUM_ROWS = t2.MINIMUM_COLS = void 0; + const n = i2(8460), o = i2(844), a = i2(5295), h = i2(2585); + t2.MINIMUM_COLS = 2, t2.MINIMUM_ROWS = 1; + let c = t2.BufferService = class extends o.Disposable { + get buffer() { + return this.buffers.active; + } + constructor(e3) { + super(), this.isUserScrolling = false, 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(e3.rawOptions.cols || 0, t2.MINIMUM_COLS), this.rows = Math.max(e3.rawOptions.rows || 0, t2.MINIMUM_ROWS), this.buffers = this.register(new a.BufferSet(e3, this)); + } + resize(e3, t3) { + this.cols = e3, this.rows = t3, this.buffers.resize(e3, t3), this._onResize.fire({ cols: e3, rows: t3 }); + } + reset() { + this.buffers.reset(), this.isUserScrolling = false; + } + scroll(e3, t3 = false) { + const i3 = this.buffer; + let s3; + s3 = this._cachedBlankLine, s3 && s3.length === this.cols && s3.getFg(0) === e3.fg && s3.getBg(0) === e3.bg || (s3 = i3.getBlankLine(e3, t3), this._cachedBlankLine = s3), s3.isWrapped = t3; + const r2 = i3.ybase + i3.scrollTop, n2 = i3.ybase + i3.scrollBottom; + if (0 === i3.scrollTop) { + const e4 = i3.lines.isFull; + n2 === i3.lines.length - 1 ? e4 ? i3.lines.recycle().copyFrom(s3) : i3.lines.push(s3.clone()) : i3.lines.splice(n2 + 1, 0, s3.clone()), e4 ? this.isUserScrolling && (i3.ydisp = Math.max(i3.ydisp - 1, 0)) : (i3.ybase++, this.isUserScrolling || i3.ydisp++); + } else { + const e4 = n2 - r2 + 1; + i3.lines.shiftElements(r2 + 1, e4 - 1, -1), i3.lines.set(n2, s3.clone()); + } + this.isUserScrolling || (i3.ydisp = i3.ybase), this._onScroll.fire(i3.ydisp); + } + scrollLines(e3, t3, i3) { + const s3 = this.buffer; + if (e3 < 0) { + if (0 === s3.ydisp) return; + this.isUserScrolling = true; + } else e3 + s3.ydisp >= s3.ybase && (this.isUserScrolling = false); + const r2 = s3.ydisp; + s3.ydisp = Math.max(Math.min(s3.ydisp + e3, s3.ybase), 0), r2 !== s3.ydisp && (t3 || this._onScroll.fire(s3.ydisp)); + } + }; + t2.BufferService = c = s2([r(0, h.IOptionsService)], c); + }, 7994: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.CharsetService = void 0, t2.CharsetService = class { + constructor() { + this.glevel = 0, this._charsets = []; + } + reset() { + this.charset = void 0, this._charsets = [], this.glevel = 0; + } + setgLevel(e3) { + this.glevel = e3, this.charset = this._charsets[e3]; + } + setgCharset(e3, t3) { + this._charsets[e3] = t3, this.glevel === e3 && (this.charset = t3); + } + }; + }, 1753: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreMouseService = void 0; + const n = i2(2585), o = i2(8460), a = i2(844), h = { NONE: { events: 0, restrict: () => false }, X10: { events: 1, restrict: (e3) => 4 !== e3.button && 1 === e3.action && (e3.ctrl = false, e3.alt = false, e3.shift = false, true) }, VT200: { events: 19, restrict: (e3) => 32 !== e3.action }, DRAG: { events: 23, restrict: (e3) => 32 !== e3.action || 3 !== e3.button }, ANY: { events: 31, restrict: (e3) => true } }; + function c(e3, t3) { + let i3 = (e3.ctrl ? 16 : 0) | (e3.shift ? 4 : 0) | (e3.alt ? 8 : 0); + return 4 === e3.button ? (i3 |= 64, i3 |= e3.action) : (i3 |= 3 & e3.button, 4 & e3.button && (i3 |= 64), 8 & e3.button && (i3 |= 128), 32 === e3.action ? i3 |= 32 : 0 !== e3.action || t3 || (i3 |= 3)), i3; + } + const l = String.fromCharCode, d = { DEFAULT: (e3) => { + const t3 = [c(e3, false) + 32, e3.col + 32, e3.row + 32]; + return t3[0] > 255 || t3[1] > 255 || t3[2] > 255 ? "" : `\x1B[M${l(t3[0])}${l(t3[1])}${l(t3[2])}`; + }, SGR: (e3) => { + const t3 = 0 === e3.action && 4 !== e3.button ? "m" : "M"; + return `\x1B[<${c(e3, true)};${e3.col};${e3.row}${t3}`; + }, SGR_PIXELS: (e3) => { + const t3 = 0 === e3.action && 4 !== e3.button ? "m" : "M"; + return `\x1B[<${c(e3, true)};${e3.x};${e3.y}${t3}`; + } }; + let _ = t2.CoreMouseService = class extends a.Disposable { + constructor(e3, t3) { + super(), this._bufferService = e3, this._coreService = t3, 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 e4 of Object.keys(h)) this.addProtocol(e4, h[e4]); + for (const e4 of Object.keys(d)) this.addEncoding(e4, d[e4]); + this.reset(); + } + addProtocol(e3, t3) { + this._protocols[e3] = t3; + } + addEncoding(e3, t3) { + this._encodings[e3] = t3; + } + get activeProtocol() { + return this._activeProtocol; + } + get areMouseEventsActive() { + return 0 !== this._protocols[this._activeProtocol].events; + } + set activeProtocol(e3) { + if (!this._protocols[e3]) throw new Error(`unknown protocol "${e3}"`); + this._activeProtocol = e3, this._onProtocolChange.fire(this._protocols[e3].events); + } + get activeEncoding() { + return this._activeEncoding; + } + set activeEncoding(e3) { + if (!this._encodings[e3]) throw new Error(`unknown encoding "${e3}"`); + this._activeEncoding = e3; + } + reset() { + this.activeProtocol = "NONE", this.activeEncoding = "DEFAULT", this._lastEvent = null; + } + triggerMouseEvent(e3) { + if (e3.col < 0 || e3.col >= this._bufferService.cols || e3.row < 0 || e3.row >= this._bufferService.rows) return false; + if (4 === e3.button && 32 === e3.action) return false; + if (3 === e3.button && 32 !== e3.action) return false; + if (4 !== e3.button && (2 === e3.action || 3 === e3.action)) return false; + if (e3.col++, e3.row++, 32 === e3.action && this._lastEvent && this._equalEvents(this._lastEvent, e3, "SGR_PIXELS" === this._activeEncoding)) return false; + if (!this._protocols[this._activeProtocol].restrict(e3)) return false; + const t3 = this._encodings[this._activeEncoding](e3); + return t3 && ("DEFAULT" === this._activeEncoding ? this._coreService.triggerBinaryEvent(t3) : this._coreService.triggerDataEvent(t3, true)), this._lastEvent = e3, true; + } + explainEvents(e3) { + return { down: !!(1 & e3), up: !!(2 & e3), drag: !!(4 & e3), move: !!(8 & e3), wheel: !!(16 & e3) }; + } + _equalEvents(e3, t3, i3) { + if (i3) { + if (e3.x !== t3.x) return false; + if (e3.y !== t3.y) return false; + } else { + if (e3.col !== t3.col) return false; + if (e3.row !== t3.row) return false; + } + return e3.button === t3.button && e3.action === t3.action && e3.ctrl === t3.ctrl && e3.alt === t3.alt && e3.shift === t3.shift; + } + }; + t2.CoreMouseService = _ = s2([r(0, n.IBufferService), r(1, n.ICoreService)], _); + }, 6975: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.CoreService = void 0; + const n = i2(1439), o = i2(8460), a = i2(844), h = i2(2585), c = Object.freeze({ insertMode: false }), l = Object.freeze({ applicationCursorKeys: false, applicationKeypad: false, bracketedPasteMode: false, origin: false, reverseWraparound: false, sendFocus: false, wraparound: true }); + let d = t2.CoreService = class extends a.Disposable { + constructor(e3, t3, i3) { + super(), this._bufferService = e3, this._logService = t3, this._optionsService = i3, this.isCursorInitialized = false, this.isCursorHidden = false, 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)(c), this.decPrivateModes = (0, n.clone)(l); + } + reset() { + this.modes = (0, n.clone)(c), this.decPrivateModes = (0, n.clone)(l); + } + triggerDataEvent(e3, t3 = false) { + if (this._optionsService.rawOptions.disableStdin) return; + const i3 = this._bufferService.buffer; + t3 && this._optionsService.rawOptions.scrollOnUserInput && i3.ybase !== i3.ydisp && this._onRequestScrollToBottom.fire(), t3 && this._onUserInput.fire(), this._logService.debug(`sending data "${e3}"`, (() => e3.split("").map(((e4) => e4.charCodeAt(0))))), this._onData.fire(e3); + } + triggerBinaryEvent(e3) { + this._optionsService.rawOptions.disableStdin || (this._logService.debug(`sending binary "${e3}"`, (() => e3.split("").map(((e4) => e4.charCodeAt(0))))), this._onBinary.fire(e3)); + } + }; + t2.CoreService = d = s2([r(0, h.IBufferService), r(1, h.ILogService), r(2, h.IOptionsService)], d); + }, 9074: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.DecorationService = void 0; + const s2 = i2(8055), r = i2(8460), n = i2(844), o = i2(6106); + let a = 0, h = 0; + class c extends n.Disposable { + get decorations() { + return this._decorations.values(); + } + constructor() { + super(), this._decorations = new o.SortedList(((e3) => null == e3 ? void 0 : e3.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(e3) { + if (e3.marker.isDisposed) return; + const t3 = new l(e3); + if (t3) { + const e4 = t3.marker.onDispose((() => t3.dispose())); + t3.onDispose((() => { + t3 && (this._decorations.delete(t3) && this._onDecorationRemoved.fire(t3), e4.dispose()); + })), this._decorations.insert(t3), this._onDecorationRegistered.fire(t3); + } + return t3; + } + reset() { + for (const e3 of this._decorations.values()) e3.dispose(); + this._decorations.clear(); + } + *getDecorationsAtCell(e3, t3, i3) { + var s3, r2, n2; + let o2 = 0, a2 = 0; + for (const h2 of this._decorations.getKeyIterator(t3)) o2 = null !== (s3 = h2.options.x) && void 0 !== s3 ? s3 : 0, a2 = o2 + (null !== (r2 = h2.options.width) && void 0 !== r2 ? r2 : 1), e3 >= o2 && e3 < a2 && (!i3 || (null !== (n2 = h2.options.layer) && void 0 !== n2 ? n2 : "bottom") === i3) && (yield h2); + } + forEachDecorationAtCell(e3, t3, i3, s3) { + this._decorations.forEachByKey(t3, ((t4) => { + var r2, n2, o2; + a = null !== (r2 = t4.options.x) && void 0 !== r2 ? r2 : 0, h = a + (null !== (n2 = t4.options.width) && void 0 !== n2 ? n2 : 1), e3 >= a && e3 < h && (!i3 || (null !== (o2 = t4.options.layer) && void 0 !== o2 ? o2 : "bottom") === i3) && s3(t4); + })); + } + } + t2.DecorationService = c; + class l extends n.Disposable { + get isDisposed() { + return this._isDisposed; + } + get backgroundColorRGB() { + return null === this._cachedBg && (this.options.backgroundColor ? this._cachedBg = s2.css.toColor(this.options.backgroundColor) : this._cachedBg = void 0), this._cachedBg; + } + get foregroundColorRGB() { + return null === this._cachedFg && (this.options.foregroundColor ? this._cachedFg = s2.css.toColor(this.options.foregroundColor) : this._cachedFg = void 0), this._cachedFg; + } + constructor(e3) { + super(), this.options = e3, 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 = e3.marker, this.options.overviewRulerOptions && !this.options.overviewRulerOptions.position && (this.options.overviewRulerOptions.position = "full"); + } + dispose() { + this._onDispose.fire(), super.dispose(); + } + } + }, 4348: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.InstantiationService = t2.ServiceCollection = void 0; + const s2 = i2(2585), r = i2(8343); + class n { + constructor(...e3) { + this._entries = /* @__PURE__ */ new Map(); + for (const [t3, i3] of e3) this.set(t3, i3); + } + set(e3, t3) { + const i3 = this._entries.get(e3); + return this._entries.set(e3, t3), i3; + } + forEach(e3) { + for (const [t3, i3] of this._entries.entries()) e3(t3, i3); + } + has(e3) { + return this._entries.has(e3); + } + get(e3) { + return this._entries.get(e3); + } + } + t2.ServiceCollection = n, t2.InstantiationService = class { + constructor() { + this._services = new n(), this._services.set(s2.IInstantiationService, this); + } + setService(e3, t3) { + this._services.set(e3, t3); + } + getService(e3) { + return this._services.get(e3); + } + createInstance(e3, ...t3) { + const i3 = (0, r.getServiceDependencies)(e3).sort(((e4, t4) => e4.index - t4.index)), s3 = []; + for (const t4 of i3) { + const i4 = this._services.get(t4.id); + if (!i4) throw new Error(`[createInstance] ${e3.name} depends on UNKNOWN service ${t4.id}.`); + s3.push(i4); + } + const n2 = i3.length > 0 ? i3[0].index : t3.length; + if (t3.length !== n2) throw new Error(`[createInstance] First service dependency of ${e3.name} at position ${n2 + 1} conflicts with ${t3.length} static arguments`); + return new e3(...[...t3, ...s3]); + } + }; + }, 7866: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a2 = e3.length - 1; a2 >= 0; a2--) (r2 = e3[a2]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.traceCall = t2.setTraceLogger = t2.LogService = void 0; + const n = i2(844), o = i2(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, c = t2.LogService = class extends n.Disposable { + get logLevel() { + return this._logLevel; + } + constructor(e3) { + super(), this._optionsService = e3, 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(e3) { + for (let t3 = 0; t3 < e3.length; t3++) "function" == typeof e3[t3] && (e3[t3] = e3[t3]()); + } + _log(e3, t3, i3) { + this._evalLazyOptionalParams(i3), e3.call(console, (this._optionsService.options.logger ? "" : "xterm.js: ") + t3, ...i3); + } + trace(e3, ...t3) { + var i3, s3; + this._logLevel <= o.LogLevelEnum.TRACE && this._log(null !== (s3 = null === (i3 = this._optionsService.options.logger) || void 0 === i3 ? void 0 : i3.trace.bind(this._optionsService.options.logger)) && void 0 !== s3 ? s3 : console.log, e3, t3); + } + debug(e3, ...t3) { + var i3, s3; + this._logLevel <= o.LogLevelEnum.DEBUG && this._log(null !== (s3 = null === (i3 = this._optionsService.options.logger) || void 0 === i3 ? void 0 : i3.debug.bind(this._optionsService.options.logger)) && void 0 !== s3 ? s3 : console.log, e3, t3); + } + info(e3, ...t3) { + var i3, s3; + this._logLevel <= o.LogLevelEnum.INFO && this._log(null !== (s3 = null === (i3 = this._optionsService.options.logger) || void 0 === i3 ? void 0 : i3.info.bind(this._optionsService.options.logger)) && void 0 !== s3 ? s3 : console.info, e3, t3); + } + warn(e3, ...t3) { + var i3, s3; + this._logLevel <= o.LogLevelEnum.WARN && this._log(null !== (s3 = null === (i3 = this._optionsService.options.logger) || void 0 === i3 ? void 0 : i3.warn.bind(this._optionsService.options.logger)) && void 0 !== s3 ? s3 : console.warn, e3, t3); + } + error(e3, ...t3) { + var i3, s3; + this._logLevel <= o.LogLevelEnum.ERROR && this._log(null !== (s3 = null === (i3 = this._optionsService.options.logger) || void 0 === i3 ? void 0 : i3.error.bind(this._optionsService.options.logger)) && void 0 !== s3 ? s3 : console.error, e3, t3); + } + }; + t2.LogService = c = s2([r(0, o.IOptionsService)], c), t2.setTraceLogger = function(e3) { + h = e3; + }, t2.traceCall = function(e3, t3, i3) { + if ("function" != typeof i3.value) throw new Error("not supported"); + const s3 = i3.value; + i3.value = function(...e4) { + if (h.logLevel !== o.LogLevelEnum.TRACE) return s3.apply(this, e4); + h.trace(`GlyphRenderer#${s3.name}(${e4.map(((e5) => JSON.stringify(e5))).join(", ")})`); + const t4 = s3.apply(this, e4); + return h.trace(`GlyphRenderer#${s3.name} return`, t4), t4; + }; + }; + }, 7302: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.OptionsService = t2.DEFAULT_OPTIONS = void 0; + const s2 = i2(8460), r = i2(844), n = i2(6114); + t2.DEFAULT_OPTIONS = { cols: 80, rows: 24, cursorBlink: false, cursorStyle: "block", cursorWidth: 1, cursorInactiveStyle: "outline", customGlyphs: true, drawBoldTextInBrightColors: true, fastScrollModifier: "alt", fastScrollSensitivity: 5, fontFamily: "courier-new, courier, monospace", fontSize: 15, fontWeight: "normal", fontWeightBold: "bold", ignoreBracketedPasteMode: false, lineHeight: 1, letterSpacing: 0, linkHandler: null, logLevel: "info", logger: null, scrollback: 1e3, scrollOnUserInput: true, scrollSensitivity: 1, screenReaderMode: false, smoothScrollDuration: 0, macOptionIsMeta: false, macOptionClickForcesSelection: false, minimumContrastRatio: 1, disableStdin: false, allowProposedApi: false, allowTransparency: false, tabStopWidth: 8, theme: {}, rightClickSelectsWord: n.isMac, windowOptions: {}, windowsMode: false, windowsPty: {}, wordSeparator: " ()[]{}',\"`", altClickMovesCursor: true, convertEol: false, termName: "xterm", cancelEvents: false, overviewRulerWidth: 0 }; + const o = ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"]; + class a extends r.Disposable { + constructor(e3) { + super(), this._onOptionChange = this.register(new s2.EventEmitter()), this.onOptionChange = this._onOptionChange.event; + const i3 = Object.assign({}, t2.DEFAULT_OPTIONS); + for (const t3 in e3) if (t3 in i3) try { + const s3 = e3[t3]; + i3[t3] = this._sanitizeAndValidateOption(t3, s3); + } catch (e4) { + console.error(e4); + } + this.rawOptions = i3, this.options = Object.assign({}, i3), this._setupOptions(); + } + onSpecificOptionChange(e3, t3) { + return this.onOptionChange(((i3) => { + i3 === e3 && t3(this.rawOptions[e3]); + })); + } + onMultipleOptionChange(e3, t3) { + return this.onOptionChange(((i3) => { + -1 !== e3.indexOf(i3) && t3(); + })); + } + _setupOptions() { + const e3 = (e4) => { + if (!(e4 in t2.DEFAULT_OPTIONS)) throw new Error(`No option with key "${e4}"`); + return this.rawOptions[e4]; + }, i3 = (e4, i4) => { + if (!(e4 in t2.DEFAULT_OPTIONS)) throw new Error(`No option with key "${e4}"`); + i4 = this._sanitizeAndValidateOption(e4, i4), this.rawOptions[e4] !== i4 && (this.rawOptions[e4] = i4, this._onOptionChange.fire(e4)); + }; + for (const t3 in this.rawOptions) { + const s3 = { get: e3.bind(this, t3), set: i3.bind(this, t3) }; + Object.defineProperty(this.options, t3, s3); + } + } + _sanitizeAndValidateOption(e3, i3) { + switch (e3) { + case "cursorStyle": + if (i3 || (i3 = t2.DEFAULT_OPTIONS[e3]), !/* @__PURE__ */ (function(e4) { + return "block" === e4 || "underline" === e4 || "bar" === e4; + })(i3)) throw new Error(`"${i3}" is not a valid value for ${e3}`); + break; + case "wordSeparator": + i3 || (i3 = t2.DEFAULT_OPTIONS[e3]); + break; + case "fontWeight": + case "fontWeightBold": + if ("number" == typeof i3 && 1 <= i3 && i3 <= 1e3) break; + i3 = o.includes(i3) ? i3 : t2.DEFAULT_OPTIONS[e3]; + break; + case "cursorWidth": + i3 = Math.floor(i3); + case "lineHeight": + case "tabStopWidth": + if (i3 < 1) throw new Error(`${e3} cannot be less than 1, value: ${i3}`); + break; + case "minimumContrastRatio": + i3 = Math.max(1, Math.min(21, Math.round(10 * i3) / 10)); + break; + case "scrollback": + if ((i3 = Math.min(i3, 4294967295)) < 0) throw new Error(`${e3} cannot be less than 0, value: ${i3}`); + break; + case "fastScrollSensitivity": + case "scrollSensitivity": + if (i3 <= 0) throw new Error(`${e3} cannot be less than or equal to 0, value: ${i3}`); + break; + case "rows": + case "cols": + if (!i3 && 0 !== i3) throw new Error(`${e3} must be numeric, value: ${i3}`); + break; + case "windowsPty": + i3 = null != i3 ? i3 : {}; + } + return i3; + } + } + t2.OptionsService = a; + }, 2660: function(e2, t2, i2) { + var s2 = this && this.__decorate || function(e3, t3, i3, s3) { + var r2, n2 = arguments.length, o2 = n2 < 3 ? t3 : null === s3 ? s3 = Object.getOwnPropertyDescriptor(t3, i3) : s3; + if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o2 = Reflect.decorate(e3, t3, i3, s3); + else for (var a = e3.length - 1; a >= 0; a--) (r2 = e3[a]) && (o2 = (n2 < 3 ? r2(o2) : n2 > 3 ? r2(t3, i3, o2) : r2(t3, i3)) || o2); + return n2 > 3 && o2 && Object.defineProperty(t3, i3, o2), o2; + }, r = this && this.__param || function(e3, t3) { + return function(i3, s3) { + t3(i3, s3, e3); + }; + }; + Object.defineProperty(t2, "__esModule", { value: true }), t2.OscLinkService = void 0; + const n = i2(2585); + let o = t2.OscLinkService = class { + constructor(e3) { + this._bufferService = e3, this._nextId = 1, this._entriesWithId = /* @__PURE__ */ new Map(), this._dataByLinkId = /* @__PURE__ */ new Map(); + } + registerLink(e3) { + const t3 = this._bufferService.buffer; + if (void 0 === e3.id) { + const i4 = t3.addMarker(t3.ybase + t3.y), s4 = { data: e3, id: this._nextId++, lines: [i4] }; + return i4.onDispose((() => this._removeMarkerFromLink(s4, i4))), this._dataByLinkId.set(s4.id, s4), s4.id; + } + const i3 = e3, s3 = this._getEntryIdKey(i3), r2 = this._entriesWithId.get(s3); + if (r2) return this.addLineToLink(r2.id, t3.ybase + t3.y), r2.id; + const n2 = t3.addMarker(t3.ybase + t3.y), o2 = { id: this._nextId++, key: this._getEntryIdKey(i3), data: i3, lines: [n2] }; + return n2.onDispose((() => this._removeMarkerFromLink(o2, n2))), this._entriesWithId.set(o2.key, o2), this._dataByLinkId.set(o2.id, o2), o2.id; + } + addLineToLink(e3, t3) { + const i3 = this._dataByLinkId.get(e3); + if (i3 && i3.lines.every(((e4) => e4.line !== t3))) { + const e4 = this._bufferService.buffer.addMarker(t3); + i3.lines.push(e4), e4.onDispose((() => this._removeMarkerFromLink(i3, e4))); + } + } + getLinkData(e3) { + var t3; + return null === (t3 = this._dataByLinkId.get(e3)) || void 0 === t3 ? void 0 : t3.data; + } + _getEntryIdKey(e3) { + return `${e3.id};;${e3.uri}`; + } + _removeMarkerFromLink(e3, t3) { + const i3 = e3.lines.indexOf(t3); + -1 !== i3 && (e3.lines.splice(i3, 1), 0 === e3.lines.length && (void 0 !== e3.data.id && this._entriesWithId.delete(e3.key), this._dataByLinkId.delete(e3.id))); + } + }; + t2.OscLinkService = o = s2([r(0, n.IBufferService)], o); + }, 8343: (e2, t2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.createDecorator = t2.getServiceDependencies = t2.serviceRegistry = void 0; + const i2 = "di$target", s2 = "di$dependencies"; + t2.serviceRegistry = /* @__PURE__ */ new Map(), t2.getServiceDependencies = function(e3) { + return e3[s2] || []; + }, t2.createDecorator = function(e3) { + if (t2.serviceRegistry.has(e3)) return t2.serviceRegistry.get(e3); + const r = function(e4, t3, n) { + if (3 !== arguments.length) throw new Error("@IServiceName-decorator can only be used to decorate a parameter"); + !(function(e5, t4, r2) { + t4[i2] === t4 ? t4[s2].push({ id: e5, index: r2 }) : (t4[s2] = [{ id: e5, index: r2 }], t4[i2] = t4); + })(r, e4, n); + }; + return r.toString = () => e3, t2.serviceRegistry.set(e3, r), r; + }; + }, 2585: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.IDecorationService = t2.IUnicodeService = t2.IOscLinkService = t2.IOptionsService = t2.ILogService = t2.LogLevelEnum = t2.IInstantiationService = t2.ICharsetService = t2.ICoreService = t2.ICoreMouseService = t2.IBufferService = void 0; + const s2 = i2(8343); + var r; + t2.IBufferService = (0, s2.createDecorator)("BufferService"), t2.ICoreMouseService = (0, s2.createDecorator)("CoreMouseService"), t2.ICoreService = (0, s2.createDecorator)("CoreService"), t2.ICharsetService = (0, s2.createDecorator)("CharsetService"), t2.IInstantiationService = (0, s2.createDecorator)("InstantiationService"), (function(e3) { + e3[e3.TRACE = 0] = "TRACE", e3[e3.DEBUG = 1] = "DEBUG", e3[e3.INFO = 2] = "INFO", e3[e3.WARN = 3] = "WARN", e3[e3.ERROR = 4] = "ERROR", e3[e3.OFF = 5] = "OFF"; + })(r || (t2.LogLevelEnum = r = {})), t2.ILogService = (0, s2.createDecorator)("LogService"), t2.IOptionsService = (0, s2.createDecorator)("OptionsService"), t2.IOscLinkService = (0, s2.createDecorator)("OscLinkService"), t2.IUnicodeService = (0, s2.createDecorator)("UnicodeService"), t2.IDecorationService = (0, s2.createDecorator)("DecorationService"); + }, 1480: (e2, t2, i2) => { + Object.defineProperty(t2, "__esModule", { value: true }), t2.UnicodeService = void 0; + const s2 = i2(8460), r = i2(225); + t2.UnicodeService = class { + constructor() { + this._providers = /* @__PURE__ */ Object.create(null), this._active = "", this._onChange = new s2.EventEmitter(), this.onChange = this._onChange.event; + const e3 = new r.UnicodeV6(); + this.register(e3), this._active = e3.version, this._activeProvider = e3; + } + dispose() { + this._onChange.dispose(); + } + get versions() { + return Object.keys(this._providers); + } + get activeVersion() { + return this._active; + } + set activeVersion(e3) { + if (!this._providers[e3]) throw new Error(`unknown Unicode version "${e3}"`); + this._active = e3, this._activeProvider = this._providers[e3], this._onChange.fire(e3); + } + register(e3) { + this._providers[e3.version] = e3; + } + wcwidth(e3) { + return this._activeProvider.wcwidth(e3); + } + getStringCellWidth(e3) { + let t3 = 0; + const i3 = e3.length; + for (let s3 = 0; s3 < i3; ++s3) { + let r2 = e3.charCodeAt(s3); + if (55296 <= r2 && r2 <= 56319) { + if (++s3 >= i3) return t3 + this.wcwidth(r2); + const n = e3.charCodeAt(s3); + 56320 <= n && n <= 57343 ? r2 = 1024 * (r2 - 55296) + n - 56320 + 65536 : t3 += this.wcwidth(n); + } + t3 += this.wcwidth(r2); + } + return t3; + } + }; + } }, t = {}; + function i(s2) { + var r = t[s2]; + if (void 0 !== r) return r.exports; + var n = t[s2] = { exports: {} }; + return e[s2].call(n.exports, n, n.exports, i), n.exports; + } + var s = {}; + return (() => { + var e2 = s; + Object.defineProperty(e2, "__esModule", { value: true }), e2.Terminal = void 0; + const t2 = i(9042), r = i(3236), n = i(844), o = i(5741), a = i(8285), h = i(7975), c = i(7090), l = ["cols", "rows"]; + class d extends n.Disposable { + constructor(e3) { + super(), this._core = this.register(new r.Terminal(e3)), this._addonManager = this.register(new o.AddonManager()), this._publicOptions = Object.assign({}, this._core.options); + const t3 = (e4) => this._core.options[e4], i2 = (e4, t4) => { + this._checkReadonlyOptions(e4), this._core.options[e4] = t4; + }; + for (const e4 in this._core.options) { + const s2 = { get: t3.bind(this, e4), set: i2.bind(this, e4) }; + Object.defineProperty(this._publicOptions, e4, s2); + } + } + _checkReadonlyOptions(e3) { + if (l.includes(e3)) throw new Error(`Option "${e3}" 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 c.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 e3 = this._core.coreService.decPrivateModes; + let t3 = "none"; + switch (this._core.coreMouseService.activeProtocol) { + case "X10": + t3 = "x10"; + break; + case "VT200": + t3 = "vt200"; + break; + case "DRAG": + t3 = "drag"; + break; + case "ANY": + t3 = "any"; + } + return { applicationCursorKeysMode: e3.applicationCursorKeys, applicationKeypadMode: e3.applicationKeypad, bracketedPasteMode: e3.bracketedPasteMode, insertMode: this._core.coreService.modes.insertMode, mouseTrackingMode: t3, originMode: e3.origin, reverseWraparoundMode: e3.reverseWraparound, sendFocusMode: e3.sendFocus, wraparoundMode: e3.wraparound }; + } + get options() { + return this._publicOptions; + } + set options(e3) { + for (const t3 in e3) this._publicOptions[t3] = e3[t3]; + } + blur() { + this._core.blur(); + } + focus() { + this._core.focus(); + } + resize(e3, t3) { + this._verifyIntegers(e3, t3), this._core.resize(e3, t3); + } + open(e3) { + this._core.open(e3); + } + attachCustomKeyEventHandler(e3) { + this._core.attachCustomKeyEventHandler(e3); + } + registerLinkProvider(e3) { + return this._core.registerLinkProvider(e3); + } + registerCharacterJoiner(e3) { + return this._checkProposedApi(), this._core.registerCharacterJoiner(e3); + } + deregisterCharacterJoiner(e3) { + this._checkProposedApi(), this._core.deregisterCharacterJoiner(e3); + } + registerMarker(e3 = 0) { + return this._verifyIntegers(e3), this._core.registerMarker(e3); + } + registerDecoration(e3) { + var t3, i2, s2; + return this._checkProposedApi(), this._verifyPositiveIntegers(null !== (t3 = e3.x) && void 0 !== t3 ? t3 : 0, null !== (i2 = e3.width) && void 0 !== i2 ? i2 : 0, null !== (s2 = e3.height) && void 0 !== s2 ? s2 : 0), this._core.registerDecoration(e3); + } + hasSelection() { + return this._core.hasSelection(); + } + select(e3, t3, i2) { + this._verifyIntegers(e3, t3, i2), this._core.select(e3, t3, i2); + } + getSelection() { + return this._core.getSelection(); + } + getSelectionPosition() { + return this._core.getSelectionPosition(); + } + clearSelection() { + this._core.clearSelection(); + } + selectAll() { + this._core.selectAll(); + } + selectLines(e3, t3) { + this._verifyIntegers(e3, t3), this._core.selectLines(e3, t3); + } + dispose() { + super.dispose(); + } + scrollLines(e3) { + this._verifyIntegers(e3), this._core.scrollLines(e3); + } + scrollPages(e3) { + this._verifyIntegers(e3), this._core.scrollPages(e3); + } + scrollToTop() { + this._core.scrollToTop(); + } + scrollToBottom() { + this._core.scrollToBottom(); + } + scrollToLine(e3) { + this._verifyIntegers(e3), this._core.scrollToLine(e3); + } + clear() { + this._core.clear(); + } + write(e3, t3) { + this._core.write(e3, t3); + } + writeln(e3, t3) { + this._core.write(e3), this._core.write("\r\n", t3); + } + paste(e3) { + this._core.paste(e3); + } + refresh(e3, t3) { + this._verifyIntegers(e3, t3), this._core.refresh(e3, t3); + } + reset() { + this._core.reset(); + } + clearTextureAtlas() { + this._core.clearTextureAtlas(); + } + loadAddon(e3) { + this._addonManager.loadAddon(this, e3); + } + static get strings() { + return t2; + } + _verifyIntegers(...e3) { + for (const t3 of e3) if (t3 === 1 / 0 || isNaN(t3) || t3 % 1 != 0) throw new Error("This API only accepts integers"); + } + _verifyPositiveIntegers(...e3) { + for (const t3 of e3) if (t3 && (t3 === 1 / 0 || isNaN(t3) || t3 % 1 != 0 || t3 < 0)) throw new Error("This API only accepts positive integers"); + } + } + e2.Terminal = d; + })(), s; + })())); + } +}); + +// node_modules/highlight.js/lib/core.js +var require_core = __commonJS({ + "node_modules/highlight.js/lib/core.js"(exports, module2) { + function deepFreeze(obj) { + if (obj instanceof Map) { + obj.clear = obj.delete = obj.set = function() { + throw new Error("map is read-only"); + }; + } else if (obj instanceof Set) { + obj.add = obj.clear = obj.delete = function() { + throw new Error("set is read-only"); + }; + } + Object.freeze(obj); + Object.getOwnPropertyNames(obj).forEach((name) => { + const prop = obj[name]; + const type = typeof prop; + if ((type === "object" || type === "function") && !Object.isFrozen(prop)) { + deepFreeze(prop); + } + }); + return obj; + } + var Response = class { + /** + * @param {CompiledMode} mode + */ + constructor(mode) { + if (mode.data === void 0) mode.data = {}; + this.data = mode.data; + this.isMatchIgnored = false; + } + ignoreMatch() { + this.isMatchIgnored = true; + } + }; + function escapeHTML(value) { + return value.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); + } + function inherit$1(original, ...objects) { + const result = /* @__PURE__ */ Object.create(null); + for (const key in original) { + result[key] = original[key]; + } + objects.forEach(function(obj) { + for (const key in obj) { + result[key] = obj[key]; + } + }); + return ( + /** @type {T} */ + result + ); + } + var SPAN_CLOSE = ""; + var emitsWrappingTags = (node) => { + return !!node.scope; + }; + var scopeToCSSClass = (name, { prefix }) => { + if (name.startsWith("language:")) { + return name.replace("language:", "language-"); + } + if (name.includes(".")) { + const pieces = name.split("."); + return [ + `${prefix}${pieces.shift()}`, + ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`) + ].join(" "); + } + return `${prefix}${name}`; + }; + var HTMLRenderer = class { + /** + * Creates a new HTMLRenderer + * + * @param {Tree} parseTree - the parse tree (must support `walk` API) + * @param {{classPrefix: string}} options + */ + constructor(parseTree, options) { + this.buffer = ""; + this.classPrefix = options.classPrefix; + parseTree.walk(this); + } + /** + * Adds texts to the output stream + * + * @param {string} text */ + addText(text2) { + this.buffer += escapeHTML(text2); + } + /** + * Adds a node open to the output stream (if needed) + * + * @param {Node} node */ + openNode(node) { + if (!emitsWrappingTags(node)) return; + const className = scopeToCSSClass( + node.scope, + { prefix: this.classPrefix } + ); + this.span(className); + } + /** + * Adds a node close to the output stream (if needed) + * + * @param {Node} node */ + closeNode(node) { + if (!emitsWrappingTags(node)) return; + this.buffer += SPAN_CLOSE; + } + /** + * returns the accumulated buffer + */ + value() { + return this.buffer; + } + // helpers + /** + * Builds a span element + * + * @param {string} className */ + span(className) { + this.buffer += ``; + } + }; + var newNode = (opts = {}) => { + const result = { children: [] }; + Object.assign(result, opts); + return result; + }; + var TokenTree = class _TokenTree { + constructor() { + this.rootNode = newNode(); + this.stack = [this.rootNode]; + } + get top() { + return this.stack[this.stack.length - 1]; + } + get root() { + return this.rootNode; + } + /** @param {Node} node */ + add(node) { + this.top.children.push(node); + } + /** @param {string} scope */ + openNode(scope) { + const node = newNode({ scope }); + this.add(node); + this.stack.push(node); + } + closeNode() { + if (this.stack.length > 1) { + return this.stack.pop(); + } + return void 0; + } + closeAllNodes() { + while (this.closeNode()) ; + } + toJSON() { + return JSON.stringify(this.rootNode, null, 4); + } + /** + * @typedef { import("./html_renderer").Renderer } Renderer + * @param {Renderer} builder + */ + walk(builder) { + return this.constructor._walk(builder, this.rootNode); + } + /** + * @param {Renderer} builder + * @param {Node} node + */ + static _walk(builder, node) { + if (typeof node === "string") { + builder.addText(node); + } else if (node.children) { + builder.openNode(node); + node.children.forEach((child) => this._walk(builder, child)); + builder.closeNode(node); + } + return builder; + } + /** + * @param {Node} node + */ + static _collapse(node) { + if (typeof node === "string") return; + if (!node.children) return; + if (node.children.every((el) => typeof el === "string")) { + node.children = [node.children.join("")]; + } else { + node.children.forEach((child) => { + _TokenTree._collapse(child); + }); + } + } + }; + var TokenTreeEmitter = class extends TokenTree { + /** + * @param {*} options + */ + constructor(options) { + super(); + this.options = options; + } + /** + * @param {string} text + */ + addText(text2) { + if (text2 === "") { + return; + } + this.add(text2); + } + /** @param {string} scope */ + startScope(scope) { + this.openNode(scope); + } + endScope() { + this.closeNode(); + } + /** + * @param {Emitter & {root: DataNode}} emitter + * @param {string} name + */ + __addSublanguage(emitter, name) { + const node = emitter.root; + if (name) node.scope = `language:${name}`; + this.add(node); + } + toHTML() { + const renderer = new HTMLRenderer(this, this.options); + return renderer.value(); + } + finalize() { + this.closeAllNodes(); + return true; + } + }; + function source(re) { + if (!re) return null; + if (typeof re === "string") return re; + return re.source; + } + function lookahead(re) { + return concat("(?=", re, ")"); + } + function anyNumberOfTimes(re) { + return concat("(?:", re, ")*"); + } + function optional(re) { + return concat("(?:", re, ")?"); + } + function concat(...args) { + const joined = args.map((x) => source(x)).join(""); + return joined; + } + function stripOptionsFromArgs(args) { + const opts = args[args.length - 1]; + if (typeof opts === "object" && opts.constructor === Object) { + args.splice(args.length - 1, 1); + return opts; + } else { + return {}; + } + } + function either(...args) { + const opts = stripOptionsFromArgs(args); + const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")"; + return joined; + } + function countMatchGroups(re) { + return new RegExp(re.toString() + "|").exec("").length - 1; + } + function startsWith(re, lexeme) { + const match = re && re.exec(lexeme); + return match && match.index === 0; + } + var BACKREF_RE = new RegExp(either( + /\[(?:[^\\\]]|\\.)*\]/, + // a character class, inside which ( and \ lose their meaning + /\(\?<(?![=!])[^>]+>/, + // a named capture group `(?` (not a lookbehind `(?<=` / `(? { + numCaptures += 1; + const offset = numCaptures; + let re = source(regex); + let out = ""; + while (re.length > 0) { + const match = BACKREF_RE.exec(re); + if (!match) { + out += re; + break; + } + out += re.substring(0, match.index); + re = re.substring(match.index + match[0].length); + if (match[0][0] === "\\" && match[1]) { + out += "\\" + String(Number(match[1]) + offset); + } else { + out += match[0]; + if (match[0] === "(" || /^\(\?[<']/.test(match[0])) { + numCaptures++; + } + } + } + return out; + }).map((re) => `(${re})`).join(joinWith); + } + var MATCH_NOTHING_RE = /\b\B/; + var IDENT_RE3 = "[a-zA-Z]\\w*"; + var UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*"; + var NUMBER_RE = "\\b\\d+(\\.\\d+)?"; + var C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)"; + var BINARY_NUMBER_RE = "\\b(0b[01]+)"; + var RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~"; + var SHEBANG = (opts = {}) => { + const beginShebang = /^#![ ]*\//; + if (opts.binary) { + opts.begin = concat( + beginShebang, + /.*\b/, + opts.binary, + /\b.*/ + ); + } + return inherit$1({ + scope: "meta", + begin: beginShebang, + end: /$/, + relevance: 0, + /** @type {ModeCallback} */ + "on:begin": (m, resp) => { + if (m.index !== 0) resp.ignoreMatch(); + } + }, opts); + }; + var BACKSLASH_ESCAPE = { + begin: "\\\\[\\s\\S]", + relevance: 0 + }; + var APOS_STRING_MODE = { + scope: "string", + begin: "'", + end: "'", + illegal: "\\n", + contains: [BACKSLASH_ESCAPE] + }; + var QUOTE_STRING_MODE = { + scope: "string", + begin: '"', + end: '"', + illegal: "\\n", + contains: [BACKSLASH_ESCAPE] + }; + var PHRASAL_WORDS_MODE = { + begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ + }; + var COMMENT = function(begin, end, modeOptions = {}) { + const mode = inherit$1( + { + scope: "comment", + begin, + end, + contains: [] + }, + modeOptions + ); + mode.contains.push({ + scope: "doctag", + // hack to avoid the space from being included. the space is necessary to + // match here to prevent the plain text rule below from gobbling up doctags + begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)", + end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/, + excludeBegin: true, + relevance: 0 + }); + const ENGLISH_WORD = either( + // list of common 1 and 2 letter words in English + "I", + "a", + "is", + "so", + "us", + "to", + "at", + "if", + "in", + "it", + "on", + // note: this is not an exhaustive list of contractions, just popular ones + /[A-Za-z]+['](d|ve|re|ll|t|s|n)/, + // contractions - can't we'd they're let's, etc + /[A-Za-z]+[-][a-z]+/, + // `no-way`, etc. + /[A-Za-z][a-z]{2,}/ + // allow capitalized words at beginning of sentences + ); + mode.contains.push( + { + // TODO: how to include ", (, ) without breaking grammars that use these for + // comment delimiters? + // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/ + // --- + // this tries to find sequences of 3 english words in a row (without any + // "programming" type syntax) this gives us a strong signal that we've + // TRULY found a comment - vs perhaps scanning with the wrong language. + // It's possible to find something that LOOKS like the start of the + // comment - but then if there is no readable text - good chance it is a + // false match and not a comment. + // + // for a visual example please see: + // https://github.com/highlightjs/highlight.js/issues/2827 + begin: concat( + /[ ]+/, + // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */ + "(", + ENGLISH_WORD, + /[.]?[:]?([.][ ]|[ ])/, + "){3}" + ) + // look for 3 words in a row + } + ); + return mode; + }; + var C_LINE_COMMENT_MODE = COMMENT("//", "$"); + var C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/"); + var HASH_COMMENT_MODE = COMMENT("#", "$"); + var NUMBER_MODE = { + scope: "number", + begin: NUMBER_RE, + relevance: 0 + }; + var C_NUMBER_MODE = { + scope: "number", + begin: C_NUMBER_RE, + relevance: 0 + }; + var BINARY_NUMBER_MODE = { + scope: "number", + begin: BINARY_NUMBER_RE, + relevance: 0 + }; + var REGEXP_MODE = { + scope: "regexp", + begin: /\/(?=[^/\n]*\/)/, + end: /\/[gimuy]*/, + contains: [ + BACKSLASH_ESCAPE, + { + begin: /\[/, + end: /\]/, + relevance: 0, + contains: [BACKSLASH_ESCAPE] + } + ] + }; + var TITLE_MODE = { + scope: "title", + begin: IDENT_RE3, + relevance: 0 + }; + var UNDERSCORE_TITLE_MODE = { + scope: "title", + begin: UNDERSCORE_IDENT_RE, + relevance: 0 + }; + var METHOD_GUARD = { + // excludes method names from keyword processing + begin: "\\.\\s*" + UNDERSCORE_IDENT_RE, + relevance: 0 + }; + var END_SAME_AS_BEGIN = function(mode) { + return Object.assign( + mode, + { + /** @type {ModeCallback} */ + "on:begin": (m, resp) => { + resp.data._beginMatch = m[1]; + }, + /** @type {ModeCallback} */ + "on:end": (m, resp) => { + if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); + } + } + ); + }; + var MODES2 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + APOS_STRING_MODE, + BACKSLASH_ESCAPE, + BINARY_NUMBER_MODE, + BINARY_NUMBER_RE, + COMMENT, + C_BLOCK_COMMENT_MODE, + C_LINE_COMMENT_MODE, + C_NUMBER_MODE, + C_NUMBER_RE, + END_SAME_AS_BEGIN, + HASH_COMMENT_MODE, + IDENT_RE: IDENT_RE3, + MATCH_NOTHING_RE, + METHOD_GUARD, + NUMBER_MODE, + NUMBER_RE, + PHRASAL_WORDS_MODE, + QUOTE_STRING_MODE, + REGEXP_MODE, + RE_STARTERS_RE, + SHEBANG, + TITLE_MODE, + UNDERSCORE_IDENT_RE, + UNDERSCORE_TITLE_MODE + }); + function skipIfHasPrecedingDot(match, response) { + const before = match.input[match.index - 1]; + if (before === ".") { + response.ignoreMatch(); + } + } + function scopeClassName(mode, _parent) { + if (mode.className !== void 0) { + mode.scope = mode.className; + delete mode.className; + } + } + function beginKeywords(mode, parent) { + if (!parent) return; + if (!mode.beginKeywords) return; + mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)"; + mode.__beforeBegin = skipIfHasPrecedingDot; + mode.keywords = mode.keywords || mode.beginKeywords; + delete mode.beginKeywords; + if (mode.relevance === void 0) mode.relevance = 0; + } + function compileIllegal(mode, _parent) { + if (!Array.isArray(mode.illegal)) return; + mode.illegal = either(...mode.illegal); + } + function compileMatch(mode, _parent) { + if (!mode.match) return; + if (mode.begin || mode.end) throw new Error("begin & end are not supported with match"); + mode.begin = mode.match; + delete mode.match; + } + function compileRelevance(mode, _parent) { + if (mode.relevance === void 0) mode.relevance = 1; + } + var beforeMatchExt = (mode, parent) => { + if (!mode.beforeMatch) return; + if (mode.starts) throw new Error("beforeMatch cannot be used with starts"); + const originalMode = Object.assign({}, mode); + Object.keys(mode).forEach((key) => { + delete mode[key]; + }); + mode.keywords = originalMode.keywords; + mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin)); + mode.starts = { + relevance: 0, + contains: [ + Object.assign(originalMode, { endsParent: true }) + ] + }; + mode.relevance = 0; + delete originalMode.beforeMatch; + }; + var COMMON_KEYWORDS = [ + "of", + "and", + "for", + "in", + "not", + "or", + "if", + "then", + "parent", + // common variable name + "list", + // common variable name + "value" + // common variable name + ]; + var DEFAULT_KEYWORD_SCOPE = "keyword"; + function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) { + const compiledKeywords = /* @__PURE__ */ Object.create(null); + if (typeof rawKeywords === "string") { + compileList(scopeName, rawKeywords.split(" ")); + } else if (Array.isArray(rawKeywords)) { + compileList(scopeName, rawKeywords); + } else { + Object.keys(rawKeywords).forEach(function(scopeName2) { + Object.assign( + compiledKeywords, + compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2) + ); + }); + } + return compiledKeywords; + function compileList(scopeName2, keywordList) { + if (caseInsensitive) { + keywordList = keywordList.map((x) => x.toLowerCase()); + } + keywordList.forEach(function(keyword) { + const pair = keyword.split("|"); + compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])]; + }); + } + } + function scoreForKeyword(keyword, providedScore) { + if (providedScore) { + return Number(providedScore); + } + return commonKeyword(keyword) ? 0 : 1; + } + function commonKeyword(keyword) { + return COMMON_KEYWORDS.includes(keyword.toLowerCase()); + } + var seenDeprecations = {}; + var error2 = (message) => { + console.error(message); + }; + var warn = (message, ...args) => { + console.log(`WARN: ${message}`, ...args); + }; + var deprecated = (version2, message) => { + if (seenDeprecations[`${version2}/${message}`]) return; + console.log(`Deprecated as of ${version2}. ${message}`); + seenDeprecations[`${version2}/${message}`] = true; + }; + var MultiClassError = new Error(); + function remapScopeNames(mode, regexes, { key }) { + let offset = 0; + const scopeNames = mode[key]; + const emit = {}; + const positions = {}; + for (let i = 1; i <= regexes.length; i++) { + positions[i + offset] = scopeNames[i]; + emit[i + offset] = true; + offset += countMatchGroups(regexes[i - 1]); + } + mode[key] = positions; + mode[key]._emit = emit; + mode[key]._multi = true; + } + function beginMultiClass(mode) { + if (!Array.isArray(mode.begin)) return; + if (mode.skip || mode.excludeBegin || mode.returnBegin) { + error2("skip, excludeBegin, returnBegin not compatible with beginScope: {}"); + throw MultiClassError; + } + if (typeof mode.beginScope !== "object" || mode.beginScope === null) { + error2("beginScope must be object"); + throw MultiClassError; + } + remapScopeNames(mode, mode.begin, { key: "beginScope" }); + mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" }); + } + function endMultiClass(mode) { + if (!Array.isArray(mode.end)) return; + if (mode.skip || mode.excludeEnd || mode.returnEnd) { + error2("skip, excludeEnd, returnEnd not compatible with endScope: {}"); + throw MultiClassError; + } + if (typeof mode.endScope !== "object" || mode.endScope === null) { + error2("endScope must be object"); + throw MultiClassError; + } + remapScopeNames(mode, mode.end, { key: "endScope" }); + mode.end = _rewriteBackreferences(mode.end, { joinWith: "" }); + } + function scopeSugar(mode) { + if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) { + mode.beginScope = mode.scope; + delete mode.scope; + } + } + function MultiClass(mode) { + scopeSugar(mode); + if (typeof mode.beginScope === "string") { + mode.beginScope = { _wrap: mode.beginScope }; + } + if (typeof mode.endScope === "string") { + mode.endScope = { _wrap: mode.endScope }; + } + beginMultiClass(mode); + endMultiClass(mode); + } + function compileLanguage(language) { + function langRe(value, global) { + return new RegExp( + source(value), + "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "") + ); + } + class MultiRegex { + constructor() { + this.matchIndexes = {}; + this.regexes = []; + this.matchAt = 1; + this.position = 0; + } + // @ts-ignore + addRule(re, opts) { + opts.position = this.position++; + this.matchIndexes[this.matchAt] = opts; + this.regexes.push([opts, re]); + this.matchAt += countMatchGroups(re) + 1; + } + compile() { + if (this.regexes.length === 0) { + this.exec = () => null; + } + const terminators = this.regexes.map((el) => el[1]); + this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true); + this.lastIndex = 0; + } + /** @param {string} s */ + exec(s) { + this.matcherRe.lastIndex = this.lastIndex; + const match = this.matcherRe.exec(s); + if (!match) { + return null; + } + const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0); + const matchData = this.matchIndexes[i]; + match.splice(0, i); + return Object.assign(match, matchData); + } + } + class ResumableMultiRegex { + constructor() { + this.rules = []; + this.multiRegexes = []; + this.count = 0; + this.lastIndex = 0; + this.regexIndex = 0; + } + // @ts-ignore + getMatcher(index) { + if (this.multiRegexes[index]) return this.multiRegexes[index]; + const matcher = new MultiRegex(); + this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts)); + matcher.compile(); + this.multiRegexes[index] = matcher; + return matcher; + } + resumingScanAtSamePosition() { + return this.regexIndex !== 0; + } + considerAll() { + this.regexIndex = 0; + } + // @ts-ignore + addRule(re, opts) { + this.rules.push([re, opts]); + if (opts.type === "begin") this.count++; + } + /** @param {string} s */ + exec(s) { + const m = this.getMatcher(this.regexIndex); + m.lastIndex = this.lastIndex; + let result = m.exec(s); + if (this.resumingScanAtSamePosition()) { + if (result && result.index === this.lastIndex) ; + else { + const m2 = this.getMatcher(0); + m2.lastIndex = this.lastIndex + 1; + result = m2.exec(s); + } + } + if (result) { + this.regexIndex += result.position + 1; + if (this.regexIndex === this.count) { + this.considerAll(); + } + } + return result; + } + } + function buildModeRegex(mode) { + const mm = new ResumableMultiRegex(); + mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" })); + if (mode.terminatorEnd) { + mm.addRule(mode.terminatorEnd, { type: "end" }); + } + if (mode.illegal) { + mm.addRule(mode.illegal, { type: "illegal" }); + } + return mm; + } + function compileMode(mode, parent) { + const cmode = ( + /** @type CompiledMode */ + mode + ); + if (mode.isCompiled) return cmode; + [ + scopeClassName, + // do this early so compiler extensions generally don't have to worry about + // the distinction between match/begin + compileMatch, + MultiClass, + beforeMatchExt + ].forEach((ext) => ext(mode, parent)); + language.compilerExtensions.forEach((ext) => ext(mode, parent)); + mode.__beforeBegin = null; + [ + beginKeywords, + // do this later so compiler extensions that come earlier have access to the + // raw array if they wanted to perhaps manipulate it, etc. + compileIllegal, + // default to 1 relevance if not specified + compileRelevance + ].forEach((ext) => ext(mode, parent)); + mode.isCompiled = true; + let keywordPattern = null; + if (typeof mode.keywords === "object" && mode.keywords.$pattern) { + mode.keywords = Object.assign({}, mode.keywords); + keywordPattern = mode.keywords.$pattern; + delete mode.keywords.$pattern; + } + keywordPattern = keywordPattern || /\w+/; + if (mode.keywords) { + mode.keywords = compileKeywords(mode.keywords, language.case_insensitive); + } + cmode.keywordPatternRe = langRe(keywordPattern, true); + if (parent) { + if (!mode.begin) mode.begin = /\B|\b/; + cmode.beginRe = langRe(cmode.begin); + if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/; + if (mode.end) cmode.endRe = langRe(cmode.end); + cmode.terminatorEnd = source(cmode.end) || ""; + if (mode.endsWithParent && parent.terminatorEnd) { + cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd; + } + } + if (mode.illegal) cmode.illegalRe = langRe( + /** @type {RegExp | string} */ + mode.illegal + ); + if (!mode.contains) mode.contains = []; + mode.contains = [].concat(...mode.contains.map(function(c) { + return expandOrCloneMode(c === "self" ? mode : c); + })); + mode.contains.forEach(function(c) { + compileMode( + /** @type Mode */ + c, + cmode + ); + }); + if (mode.starts) { + compileMode(mode.starts, parent); + } + cmode.matcher = buildModeRegex(cmode); + return cmode; + } + if (!language.compilerExtensions) language.compilerExtensions = []; + if (language.contains && language.contains.includes("self")) { + throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation."); + } + language.classNameAliases = inherit$1(language.classNameAliases || {}); + return compileMode( + /** @type Mode */ + language + ); + } + function dependencyOnParent(mode) { + if (!mode) return false; + return mode.endsWithParent || dependencyOnParent(mode.starts); + } + function expandOrCloneMode(mode) { + if (mode.variants && !mode.cachedVariants) { + mode.cachedVariants = mode.variants.map(function(variant) { + return inherit$1(mode, { variants: null }, variant); + }); + } + if (mode.cachedVariants) { + return mode.cachedVariants; + } + if (dependencyOnParent(mode)) { + return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null }); + } + if (Object.isFrozen(mode)) { + return inherit$1(mode); + } + return mode; + } + var version = "11.12.0"; + var HTMLInjectionError = class extends Error { + constructor(reason, html) { + super(reason); + this.name = "HTMLInjectionError"; + this.html = html; + } + }; + var escape2 = escapeHTML; + var inherit = inherit$1; + var NO_MATCH = Symbol("nomatch"); + var MAX_KEYWORD_HITS = 7; + var HLJS = function(hljs) { + const languages = /* @__PURE__ */ Object.create(null); + const aliases = /* @__PURE__ */ Object.create(null); + const plugins = []; + let SAFE_MODE = true; + const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?"; + const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] }; + let options = { + ignoreUnescapedHTML: false, + throwUnescapedHTML: false, + noHighlightRe: /^(no-?highlight)$/i, + languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i, + classPrefix: "hljs-", + cssSelector: "pre code", + languages: null, + // beta configuration options, subject to change, welcome to discuss + // https://github.com/highlightjs/highlight.js/issues/1086 + __emitter: TokenTreeEmitter + }; + function shouldNotHighlight(languageName) { + return options.noHighlightRe.test(languageName); + } + function blockLanguage(block2) { + let classes = block2.className + " "; + classes += block2.parentNode ? block2.parentNode.className : ""; + const match = options.languageDetectRe.exec(classes); + if (match) { + const language = getLanguage(match[1]); + if (!language) { + warn(LANGUAGE_NOT_FOUND.replace("{}", match[1])); + warn("Falling back to no-highlight mode for this block.", block2); + } + return language ? match[1] : "no-highlight"; + } + return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class)); + } + function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) { + let code2 = ""; + let languageName = ""; + if (typeof optionsOrCode === "object") { + code2 = codeOrLanguageName; + ignoreIllegals = optionsOrCode.ignoreIllegals; + languageName = optionsOrCode.language; + } else { + deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated."); + deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"); + languageName = codeOrLanguageName; + code2 = optionsOrCode; + } + if (ignoreIllegals === void 0) { + ignoreIllegals = true; + } + const context = { + code: code2, + language: languageName + }; + fire("before:highlight", context); + const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals); + result.code = context.code; + fire("after:highlight", result); + return result; + } + function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) { + const keywordHits = /* @__PURE__ */ Object.create(null); + function keywordData(mode, matchText) { + return mode.keywords[matchText]; + } + function processKeywords() { + if (!top.keywords) { + emitter.addText(modeBuffer); + return; + } + let lastIndex = 0; + top.keywordPatternRe.lastIndex = 0; + let match = top.keywordPatternRe.exec(modeBuffer); + let buf = ""; + while (match) { + buf += modeBuffer.substring(lastIndex, match.index); + const word = language.case_insensitive ? match[0].toLowerCase() : match[0]; + const data = keywordData(top, word); + if (data) { + const [kind, keywordRelevance] = data; + emitter.addText(buf); + buf = ""; + keywordHits[word] = (keywordHits[word] || 0) + 1; + if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance; + if (kind.startsWith("_")) { + buf += match[0]; + } else { + const cssClass = language.classNameAliases[kind] || kind; + emitKeyword(match[0], cssClass); + } + } else { + buf += match[0]; + } + lastIndex = top.keywordPatternRe.lastIndex; + match = top.keywordPatternRe.exec(modeBuffer); + } + buf += modeBuffer.substring(lastIndex); + emitter.addText(buf); + } + function processSubLanguage() { + if (modeBuffer === "") return; + let result2 = null; + if (typeof top.subLanguage === "string") { + if (!languages[top.subLanguage]) { + emitter.addText(modeBuffer); + return; + } + result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]); + continuations[top.subLanguage] = /** @type {CompiledMode} */ + result2._top; + } else { + result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null); + } + if (top.relevance > 0) { + relevance += result2.relevance; + } + emitter.__addSublanguage(result2._emitter, result2.language); + } + function processBuffer() { + if (top.subLanguage != null) { + processSubLanguage(); + } else { + processKeywords(); + } + modeBuffer = ""; + } + function emitKeyword(keyword, scope) { + if (keyword === "") return; + emitter.startScope(scope); + emitter.addText(keyword); + emitter.endScope(); + } + function emitMultiClass(scope, match) { + let i = 1; + const max = match.length - 1; + while (i <= max) { + if (!scope._emit[i]) { + i++; + continue; + } + const klass = language.classNameAliases[scope[i]] || scope[i]; + const text2 = match[i]; + if (klass) { + emitKeyword(text2, klass); + } else { + modeBuffer = text2; + processKeywords(); + modeBuffer = ""; + } + i++; + } + } + function startNewMode(mode, match) { + if (mode.scope && typeof mode.scope === "string") { + emitter.openNode(language.classNameAliases[mode.scope] || mode.scope); + } + if (mode.beginScope) { + if (mode.beginScope._wrap) { + emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap); + modeBuffer = ""; + } else if (mode.beginScope._multi) { + emitMultiClass(mode.beginScope, match); + modeBuffer = ""; + } + } + top = Object.create(mode, { parent: { value: top } }); + return top; + } + function endOfMode(mode, match, matchPlusRemainder) { + let matched = startsWith(mode.endRe, matchPlusRemainder); + if (matched) { + if (mode["on:end"]) { + const resp = new Response(mode); + mode["on:end"](match, resp); + if (resp.isMatchIgnored) matched = false; + } + if (matched) { + while (mode.endsParent && mode.parent) { + mode = mode.parent; + } + return mode; + } + } + if (mode.endsWithParent) { + return endOfMode(mode.parent, match, matchPlusRemainder); + } + } + function doIgnore(lexeme) { + if (top.matcher.regexIndex === 0) { + modeBuffer += lexeme[0]; + return 1; + } else { + resumeScanAtSamePosition = true; + return 0; + } + } + function doBeginMatch(match) { + const lexeme = match[0]; + const newMode = match.rule; + const resp = new Response(newMode); + const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]]; + for (const cb of beforeCallbacks) { + if (!cb) continue; + cb(match, resp); + if (resp.isMatchIgnored) return doIgnore(lexeme); + } + if (newMode.skip) { + modeBuffer += lexeme; + } else { + if (newMode.excludeBegin) { + modeBuffer += lexeme; + } + processBuffer(); + if (!newMode.returnBegin && !newMode.excludeBegin) { + modeBuffer = lexeme; + } + } + startNewMode(newMode, match); + return newMode.returnBegin ? 0 : lexeme.length; + } + function doEndMatch(match) { + const lexeme = match[0]; + const matchPlusRemainder = codeToHighlight.substring(match.index); + const endMode = endOfMode(top, match, matchPlusRemainder); + if (!endMode) { + return NO_MATCH; + } + const origin = top; + if (top.endScope && top.endScope._wrap) { + processBuffer(); + emitKeyword(lexeme, top.endScope._wrap); + } else if (top.endScope && top.endScope._multi) { + processBuffer(); + emitMultiClass(top.endScope, match); + } else if (origin.skip) { + modeBuffer += lexeme; + } else { + if (!(origin.returnEnd || origin.excludeEnd)) { + modeBuffer += lexeme; + } + processBuffer(); + if (origin.excludeEnd) { + modeBuffer = lexeme; + } + } + do { + if (top.scope) { + emitter.closeNode(); + } + if (!top.skip && !top.subLanguage) { + relevance += top.relevance; + } + top = top.parent; + } while (top !== endMode.parent); + if (endMode.starts) { + startNewMode(endMode.starts, match); + } + return origin.returnEnd ? 0 : lexeme.length; + } + function processContinuations() { + const list2 = []; + for (let current = top; current !== language; current = current.parent) { + if (current.scope) { + list2.unshift(current.scope); + } + } + list2.forEach((item) => emitter.openNode(item)); + } + let lastMatch = {}; + function processLexeme(textBeforeMatch, match) { + const lexeme = match && match[0]; + modeBuffer += textBeforeMatch; + if (lexeme == null) { + processBuffer(); + return 0; + } + if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") { + modeBuffer += codeToHighlight.slice(match.index, match.index + 1); + if (!SAFE_MODE) { + const err = new Error(`0 width match regex (${languageName})`); + err.languageName = languageName; + err.badRule = lastMatch.rule; + throw err; + } + return 1; + } + lastMatch = match; + if (match.type === "begin") { + return doBeginMatch(match); + } else if (match.type === "illegal" && !ignoreIllegals) { + const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "") + '"'); + err.mode = top; + throw err; + } else if (match.type === "end") { + const processed = doEndMatch(match); + if (processed !== NO_MATCH) { + return processed; + } + } + if (match.type === "illegal" && lexeme === "") { + if (match.index === codeToHighlight.length) ; + else { + modeBuffer += "\n"; + } + return 1; + } + if (iterations > 1e5 && iterations > match.index * 3) { + const err = new Error("potential infinite loop, way more iterations than matches"); + throw err; + } + modeBuffer += lexeme; + return lexeme.length; + } + const language = getLanguage(languageName); + if (!language) { + error2(LANGUAGE_NOT_FOUND.replace("{}", languageName)); + throw new Error('Unknown language: "' + languageName + '"'); + } + const md = compileLanguage(language); + let result = ""; + let top = continuation || md; + const continuations = {}; + const emitter = new options.__emitter(options); + processContinuations(); + let modeBuffer = ""; + let relevance = 0; + let index = 0; + let iterations = 0; + let resumeScanAtSamePosition = false; + try { + if (!language.__emitTokens) { + top.matcher.considerAll(); + for (; ; ) { + iterations++; + if (resumeScanAtSamePosition) { + resumeScanAtSamePosition = false; + } else { + top.matcher.considerAll(); + } + top.matcher.lastIndex = index; + const match = top.matcher.exec(codeToHighlight); + if (!match) break; + const beforeMatch = codeToHighlight.substring(index, match.index); + const processedCount = processLexeme(beforeMatch, match); + index = match.index + processedCount; + } + processLexeme(codeToHighlight.substring(index)); + } else { + language.__emitTokens(codeToHighlight, emitter); + } + emitter.finalize(); + result = emitter.toHTML(); + return { + language: languageName, + value: result, + relevance, + illegal: false, + _emitter: emitter, + _top: top + }; + } catch (err) { + if (err.message && err.message.includes("Illegal")) { + return { + language: languageName, + value: escape2(codeToHighlight), + illegal: true, + relevance: 0, + _illegalBy: { + message: err.message, + index, + context: codeToHighlight.slice(index - 100, index + 100), + mode: err.mode, + resultSoFar: result + }, + _emitter: emitter + }; + } else if (SAFE_MODE) { + return { + language: languageName, + value: escape2(codeToHighlight), + illegal: false, + relevance: 0, + errorRaised: err, + _emitter: emitter, + _top: top + }; + } else { + throw err; + } + } + } + function justTextHighlightResult(code2) { + const result = { + value: escape2(code2), + illegal: false, + relevance: 0, + _top: PLAINTEXT_LANGUAGE, + _emitter: new options.__emitter(options) + }; + result._emitter.addText(code2); + return result; + } + function highlightAuto(code2, languageSubset) { + languageSubset = languageSubset || options.languages || Object.keys(languages); + const plaintext = justTextHighlightResult(code2); + const results = languageSubset.filter(getLanguage).filter(autoDetection).map( + (name) => _highlight(name, code2, false) + ); + results.unshift(plaintext); + const sorted = results.sort((a, b) => { + if (a.relevance !== b.relevance) return b.relevance - a.relevance; + if (a.language && b.language) { + if (getLanguage(a.language).supersetOf === b.language) { + return 1; + } else if (getLanguage(b.language).supersetOf === a.language) { + return -1; + } + } + return 0; + }); + const [best, secondBest] = sorted; + const result = best; + result.secondBest = secondBest; + return result; + } + function updateClassName(element, currentLang, resultLang) { + const language = currentLang && aliases[currentLang] || resultLang; + element.classList.add("hljs"); + element.classList.add(`language-${language}`); + } + function highlightElement(element) { + let node = null; + const language = blockLanguage(element); + if (shouldNotHighlight(language)) return; + fire( + "before:highlightElement", + { el: element, language } + ); + if (element.dataset.highlighted) { + console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element); + return; + } + if (element.children.length > 0) { + if (!options.ignoreUnescapedHTML) { + console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."); + console.warn("https://github.com/highlightjs/highlight.js/wiki/security"); + console.warn("The element with unescaped HTML:"); + console.warn(element); + } + if (options.throwUnescapedHTML) { + const err = new HTMLInjectionError( + "One of your code blocks includes unescaped HTML.", + element.innerHTML + ); + throw err; + } + } + node = element; + const text2 = node.textContent; + const result = language ? highlight2(text2, { language, ignoreIllegals: true }) : highlightAuto(text2); + element.innerHTML = result.value; + element.dataset.highlighted = "yes"; + updateClassName(element, language, result.language); + element.result = { + language: result.language, + // TODO: remove with version 11.0 + re: result.relevance, + relevance: result.relevance + }; + if (result.secondBest) { + element.secondBest = { + language: result.secondBest.language, + relevance: result.secondBest.relevance + }; + } + fire("after:highlightElement", { el: element, result, text: text2 }); + } + function configure(userOptions) { + options = inherit(options, userOptions); + } + const initHighlighting = () => { + highlightAll(); + deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now."); + }; + function initHighlightingOnLoad() { + highlightAll(); + deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now."); + } + let wantsHighlight = false; + function highlightAll() { + function boot() { + highlightAll(); + } + if (document.readyState === "loading") { + if (!wantsHighlight) { + window.addEventListener("DOMContentLoaded", boot, false); + } + wantsHighlight = true; + return; + } + const blocks = document.querySelectorAll(options.cssSelector); + blocks.forEach(highlightElement); + } + function registerLanguage(languageName, languageDefinition) { + let lang = null; + try { + lang = languageDefinition(hljs); + } catch (error$1) { + error2("Language definition for '{}' could not be registered.".replace("{}", languageName)); + if (!SAFE_MODE) { + throw error$1; + } else { + error2(error$1); + } + lang = PLAINTEXT_LANGUAGE; + } + if (!lang.name) lang.name = languageName; + languages[languageName] = lang; + lang.rawDefinition = languageDefinition.bind(null, hljs); + if (lang.aliases) { + registerAliases(lang.aliases, { languageName }); + } + } + function unregisterLanguage(languageName) { + delete languages[languageName]; + for (const alias of Object.keys(aliases)) { + if (aliases[alias] === languageName) { + delete aliases[alias]; + } + } + } + function listLanguages() { + return Object.keys(languages); + } + function getLanguage(name) { + name = (name || "").toLowerCase(); + return languages[name] || languages[aliases[name]]; + } + function registerAliases(aliasList, { languageName }) { + if (typeof aliasList === "string") { + aliasList = [aliasList]; + } + aliasList.forEach((alias) => { + aliases[alias.toLowerCase()] = languageName; + }); + } + function autoDetection(name) { + const lang = getLanguage(name); + return lang && !lang.disableAutodetect; + } + function upgradePluginAPI(plugin) { + if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) { + plugin["before:highlightElement"] = (data) => { + plugin["before:highlightBlock"]( + Object.assign({ block: data.el }, data) + ); + }; + } + if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) { + plugin["after:highlightElement"] = (data) => { + plugin["after:highlightBlock"]( + Object.assign({ block: data.el }, data) + ); + }; + } + } + function addPlugin(plugin) { + upgradePluginAPI(plugin); + plugins.push(plugin); + } + function removePlugin(plugin) { + const index = plugins.indexOf(plugin); + if (index !== -1) { + plugins.splice(index, 1); + } + } + function fire(event, args) { + const cb = event; + plugins.forEach(function(plugin) { + if (plugin[cb]) { + plugin[cb](args); + } + }); + } + function deprecateHighlightBlock(el) { + deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0"); + deprecated("10.7.0", "Please use highlightElement now."); + return highlightElement(el); + } + Object.assign(hljs, { + highlight: highlight2, + highlightAuto, + highlightAll, + highlightElement, + // TODO: Remove with v12 API + highlightBlock: deprecateHighlightBlock, + configure, + initHighlighting, + initHighlightingOnLoad, + registerLanguage, + unregisterLanguage, + listLanguages, + getLanguage, + registerAliases, + autoDetection, + inherit, + addPlugin, + removePlugin + }); + hljs.debugMode = function() { + SAFE_MODE = false; + }; + hljs.safeMode = function() { + SAFE_MODE = true; + }; + hljs.versionString = version; + hljs.regex = { + concat, + lookahead, + either, + optional, + anyNumberOfTimes + }; + for (const key in MODES2) { + if (typeof MODES2[key] === "object") { + deepFreeze(MODES2[key]); + } + } + Object.assign(hljs, MODES2); + return hljs; + }; + var highlight = HLJS({}); + highlight.newInstance = () => HLJS({}); + module2.exports = highlight; + highlight.HighlightJS = highlight; + highlight.default = highlight; + } +}); + +// src/client/index.tsx +var index_exports = {}; +__export(index_exports, { + WorktableSection: () => WorktableSection, + apply: () => apply, + createCustomSession: () => createCustomSession, + inject: () => inject, + sendCustomToSession: () => sendCustomToSession +}); +module.exports = __toCommonJS(index_exports); +var import_react2 = require("react"); + +// node_modules/xterm/css/xterm.css +var xterm_default = `/** + * Copyright (c) 2014 The xterm.js authors. All rights reserved. + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * https://github.com/chjj/term.js + * @license MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + * The original design remains. The terminal itself + * has been extended to include xterm CSI codes, among + * other features. + */ + +/** + * Default styles for xterm.js + */ + +.xterm { + cursor: text; + position: relative; + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; +} + +.xterm.focus, +.xterm:focus { + outline: none; +} + +.xterm .xterm-helpers { + position: absolute; + top: 0; + /** + * The z-index of the helpers must be higher than the canvases in order for + * IMEs to appear on top. + */ + z-index: 5; +} + +.xterm .xterm-helper-textarea { + padding: 0; + border: 0; + margin: 0; + /* Move textarea out of the screen to the far left, so that the cursor is not visible */ + position: absolute; + opacity: 0; + left: -9999em; + top: 0; + width: 0; + height: 0; + z-index: -5; + /** Prevent wrapping so the IME appears against the textarea at the correct position */ + white-space: nowrap; + overflow: hidden; + resize: none; +} + +.xterm .composition-view { + /* TODO: Composition position got messed up somewhere */ + background: #000; + color: #FFF; + display: none; + position: absolute; + white-space: nowrap; + z-index: 1; +} + +.xterm .composition-view.active { + display: block; +} + +.xterm .xterm-viewport { + /* On OS X this is required in order for the scroll bar to appear fully opaque */ + background-color: #000; + overflow-y: scroll; + cursor: default; + position: absolute; + right: 0; + left: 0; + top: 0; + bottom: 0; +} + +.xterm .xterm-screen { + position: relative; +} + +.xterm .xterm-screen canvas { + position: absolute; + left: 0; + top: 0; +} + +.xterm .xterm-scroll-area { + visibility: hidden; +} + +.xterm-char-measure-element { + display: inline-block; + visibility: hidden; + position: absolute; + top: 0; + left: -9999em; + line-height: normal; +} + +.xterm.enable-mouse-events { + /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ + cursor: default; +} + +.xterm.xterm-cursor-pointer, +.xterm .xterm-cursor-pointer { + cursor: pointer; +} + +.xterm.column-select.focus { + /* Column selection mode */ + cursor: crosshair; +} + +.xterm .xterm-accessibility, +.xterm .xterm-message { + position: absolute; + left: 0; + top: 0; + bottom: 0; + right: 0; + z-index: 10; + color: transparent; + pointer-events: none; +} + +.xterm .live-region { + position: absolute; + left: -9999px; + width: 1px; + height: 1px; + overflow: hidden; +} + +.xterm-dim { + /* Dim should not apply to background, so the opacity of the foreground color is applied + * explicitly in the generated class and reset to 1 here */ + opacity: 1 !important; +} + +.xterm-underline-1 { text-decoration: underline; } +.xterm-underline-2 { text-decoration: double underline; } +.xterm-underline-3 { text-decoration: wavy underline; } +.xterm-underline-4 { text-decoration: dotted underline; } +.xterm-underline-5 { text-decoration: dashed underline; } + +.xterm-overline { + text-decoration: overline; +} + +.xterm-overline.xterm-underline-1 { text-decoration: overline underline; } +.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; } +.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; } +.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; } +.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; } + +.xterm-strikethrough { + text-decoration: line-through; +} + +.xterm-screen .xterm-decoration-container .xterm-decoration { + z-index: 6; + position: absolute; +} + +.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { + z-index: 7; +} + +.xterm-decoration-overview-ruler { + z-index: 8; + position: absolute; + top: 0; + right: 0; + pointer-events: none; +} + +.xterm-decoration-top { + z-index: 2; + position: relative; +} +`; + +// src/client/styles.ts +var css = xterm_default + "\n" + [ + // 区块整体 + ".dsh-wt_section{box-sizing:border-box;display:flex;flex-direction:column;gap:6px;width:100%;padding:0}", + ".dsh-wt_float{min-width:176px;max-width:264px;background:var(--dsw-alias-bg-base,#0b0e14);border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:10px;padding:8px;box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_rail{pointer-events:none}", + ".dsh-wt_railBox{display:flex;flex-wrap:wrap;gap:5px;justify-content:center;padding:5px 3px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:8px;background:var(--dsw-alias-bg-base,#0b0e14)}", + ".dsh-wt_railBtn{flex:none;width:22px;height:22px;padding:0;display:flex;align-items:center;justify-content:center;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:7px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:13px;line-height:1;cursor:pointer;pointer-events:auto}", + ".dsh-wt_railBtn:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.08));border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_railIcon{font-size:17px;line-height:22px}", + // 分隔线 + ".dsh-wt_divider{flex:none;height:1px;background:var(--dsw-alias-border-l1,#262b36);margin:2px 0}", + // 头部 + ".dsh-wt_header{display:flex;align-items:center;gap:6px;padding:0 2px}", + ".dsh-wt_handle{display:flex;align-items:center;justify-content:center;width:25px;height:25px;padding:0;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:15px;line-height:1;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}", + ".dsh-wt_handle:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_handle:active{cursor:grabbing}", + ".dsh-wt_handle[data-float=true]{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_title{font-size:11px;font-weight:600;letter-spacing:.06em;color:var(--dsw-alias-label-secondary,#9aa4b2);cursor:grab;user-select:none;-webkit-user-select:none;touch-action:none}", + ".dsh-wt_actions{margin-left:auto;display:flex;align-items:center;gap:7px}", + ".dsh-wt_iconBtn{display:flex;align-items:center;justify-content:center;width:24px;height:22px;padding:0;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:12px;line-height:1;cursor:pointer}", + ".dsh-wt_iconBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + // 搜索行 + ".dsh-wt_search{display:flex;align-items:center;gap:6px;padding:3px 6px 3px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03))}", + ".dsh-wt_search input{flex:1;min-width:0;background:transparent;border:none;outline:none;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px}", + ".dsh-wt_search input::placeholder{color:var(--dsw-alias-label-tertiary,#6e7683)}", + ".dsh-wt_searchClear{display:flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:11px;cursor:pointer}", + ".dsh-wt_searchClear:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + // 菜单与提示 + ".dsh-wt_menu{position:relative;z-index:12;display:flex;flex-direction:column;gap:1px;padding:5px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:8px;background:var(--dsw-alias-bg-base,#0b0e14);box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_menuLabel{font-size:10px;letter-spacing:.05em;color:var(--dsw-alias-label-tertiary,#6e7683);padding:3px 7px 1px}", + ".dsh-wt_menuItem{display:flex;align-items:center;padding:5px 8px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:16px;cursor:pointer;text-align:left}", + ".dsh-wt_menuItem:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_menuItem[data-on=true]{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 菜单分隔线 + ".dsh-wt_menuSep{height:1px;background:var(--dsw-alias-border-l1,#262b36);margin:4px 2px}", + // 添加面板 + ".dsh-wt_add{max-height:500px;overflow:auto}", + ".dsh-wt_addText{font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#9aa4b2);padding:2px 8px 4px;margin:0}", + ".dsh-wt_addLink{color:var(--dsw-alias-state-accent-primary,#4f8ef7);text-decoration:none}", + ".dsh-wt_addForm{display:flex;flex-direction:column;gap:5px;padding:4px 8px 8px}", + ".dsh-wt_addForm input{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;padding:5px 8px;outline:none}", + ".dsh-wt_addForm input:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_addForm .dsh-wt_addIcon{width:64px}", + ".dsh-wt_addBtn{display:flex;align-items:center;justify-content:center;padding:5px 8px;border:none;border-radius:6px;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font:inherit;font-size:12px;line-height:16px;cursor:pointer}", + ".dsh-wt_addBtn:hover{filter:brightness(1.08)}", + ".dsh-wt_addError{font-size:11px;color:var(--dsw-alias-state-danger,#e5484d);padding:0 8px 8px;margin:0}", + // 管理项目(编辑模式) + ".dsh-wt_manage{position:relative;z-index:12;display:flex;flex-direction:column;gap:4px;padding:6px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:8px;background:var(--dsw-alias-bg-base,#0b0e14)}", + ".dsh-wt_manageHead{display:flex;align-items:center;justify-content:space-between;padding:1px 2px 4px}", + ".dsh-wt_manageTitle{font-size:11px;font-weight:600;letter-spacing:.04em;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_manageDone{display:flex;align-items:center;padding:2px 8px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-state-accent-primary,#4f8ef7);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_manageDone:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + // 排序方式:一左一右两个选择按钮(手动 / 最近) + ".dsh-wt_sortRow{display:flex;gap:6px;padding:0 8px 2px}", + ".dsh-wt_sortBtn{flex:1;display:flex;align-items:center;justify-content:center;padding:4px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_sortBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_sortBtn[data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_manageRow{display:flex;align-items:center;gap:6px;padding:4px 6px;border:1px solid transparent;border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03))}", + ".dsh-wt_manageRow:hover{border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_manageRowOff{opacity:.45}", + ".dsh-wt_manageGrip{flex:none;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:12px;cursor:grab;user-select:none;-webkit-user-select:none}", + ".dsh-wt_manageIcon{flex:none;width:20px;font-size:15px;text-align:center}", + ".dsh-wt_manageInput{flex:1;min-width:0;background:transparent;border:none;outline:none;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;padding:2px 0}", + ".dsh-wt_manageBtn{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:11px;line-height:1;cursor:pointer}", + ".dsh-wt_manageBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_manageScName{flex:1;min-width:0;font-size:12px;color:var(--dsw-alias-label-secondary,#9aa4b2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}", + ".dsh-wt_manageReset{align-self:flex-start;margin-top:2px;padding:3px 8px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-tertiary,#6e7683);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_manageReset:hover{color:var(--dsw-alias-state-danger,#e5484d);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + // 快捷方式 + ".dsh-wt_shortcuts{display:flex;flex-direction:column;gap:4px}", + ".dsh-wt_shortcut{display:flex;align-items:center;gap:7px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));color:var(--dsw-alias-label-primary,#e6e8eb);text-decoration:none;font-size:12px;line-height:18px}", + ".dsh-wt_shortcut:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_shortcutIcon{flex:none;font-size:15px}", + ".dsh-wt_shortcutName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_shortcutBadge{flex:none;font-size:9px;line-height:14px;padding:0 5px;border-radius:8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06));color:var(--dsw-alias-label-tertiary,#6e7683)}", + // 项目区 + ".dsh-wt_projects{display:flex;flex-direction:column;gap:4px}", + ".dsh-wt_projects[data-managing=true]{opacity:.55;pointer-events:none}", + ".dsh-wt_empty{padding:8px 10px;border:1px dashed var(--dsw-alias-border-l1,#262b36);border-radius:8px;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:11px;text-align:center}", + // 分栏工作区(M1 通用引擎) + ".dsh-wt_splitBar{display:flex;align-items:center;gap:10px;height:26px;padding:0 10px;box-sizing:border-box;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-bg-base,#0b0e14)}", + ".dsh-wt_splitTitle{flex:1;min-width:0;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_splitClose{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:12px;cursor:pointer}", + ".dsh-wt_splitClose:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_pane{display:flex;flex-direction:column;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;background:var(--dsw-alias-bg-base,#0b0e14);overflow:hidden;transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease}", + // 文件预览:文本/MD 滚动容器 + MD 排版 + 图片居中 + ".dsh-wt_fileView{flex:1;min-height:0;overflow:auto;padding:12px 14px;background:var(--dsw-alias-bg-base,#0b0e14);color:var(--dsw-alias-label-primary,#e6e8eb);font-size:12.5px;line-height:1.7}", + ".dsh-wt_txt{margin:0;font-family:var(--dsw-font-mono,Consolas,Menlo,monospace);font-size:12px;line-height:1.65;white-space:pre-wrap;word-break:break-word}", + // MD 编辑/预览切换工具栏 + ".dsh-wt_mdBar{flex:none;display:flex;align-items:center;gap:6px;padding:4px 8px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02))}", + ".dsh-wt_mdBtn{flex:none;padding:3px 10px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_mdBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_mdBtnOn{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_mdSave{margin-left:auto;padding:3px 12px;border:none;border-radius:5px;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font:inherit;font-size:11px;cursor:pointer}", + ".dsh-wt_mdSave:disabled{opacity:.6;cursor:default}", + ".dsh-wt_mdMsg{font-size:11px;color:var(--dsw-alias-state-danger,#e5484d)}", + ".dsh-wt_mdEdit{flex:1;min-height:0;width:100%;box-sizing:border-box;padding:12px 14px;background:var(--dsw-alias-bg-base,#0b0e14);color:var(--dsw-alias-label-primary,#e6e8eb);border:none;outline:none;resize:none;font-family:var(--dsw-font-mono,Consolas,Menlo,monospace);font-size:12px;line-height:1.7}", + // 代码语法着色(GitHub Dark 风格 token 配色) + ".dsh-wt_code{margin:0;font-family:var(--dsw-font-mono,Consolas,Menlo,monospace);font-size:12px;line-height:1.65;white-space:pre;word-break:normal}", + ".dsh-wt_code .hljs-keyword,.dsh-wt_code .hljs-selector-tag,.dsh-wt_code .hljs-literal,.dsh-wt_code .hljs-doctag{color:#ff7b72}", + ".dsh-wt_code .hljs-string,.dsh-wt_code .hljs-attr,.dsh-wt_code .hljs-regexp{color:#a5d6ff}", + ".dsh-wt_code .hljs-comment,.dsh-wt_code .hljs-quote{color:#8b949e;font-style:italic}", + ".dsh-wt_code .hljs-number,.dsh-wt_code .hljs-symbol,.dsh-wt_code .hljs-bullet{color:#79c0ff}", + ".dsh-wt_code .hljs-title,.dsh-wt_code .hljs-function .hljs-title,.dsh-wt_code .hljs-section{color:#d2a8ff}", + ".dsh-wt_code .hljs-built_in,.dsh-wt_code .hljs-type,.dsh-wt_code .hljs-class .hljs-title{color:#ffa657}", + ".dsh-wt_code .hljs-variable,.dsh-wt_code .hljs-params,.dsh-wt_code .hljs-meta{color:#e6edf3}", + ".dsh-wt_code .hljs-property,.dsh-wt_code .hljs-attribute{color:#79c0ff}", + ".dsh-wt_code .hljs-tag,.dsh-wt_code .hljs-name{color:#7ee787}", + ".dsh-wt_code .hljs-selector-class,.dsh-wt_code .hljs-selector-id{color:#d2a8ff}", + ".dsh-wt_code .hljs-addition{color:#7ee787}", + ".dsh-wt_code .hljs-deletion{color:#ff7b72}", + ".dsh-wt_md h1,.dsh-wt_md h2,.dsh-wt_md h3,.dsh-wt_md h4{margin:14px 0 8px;line-height:1.3;font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_md h1{font-size:20px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);padding-bottom:6px}", + ".dsh-wt_md h2{font-size:16.5px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);padding-bottom:5px}", + ".dsh-wt_md h3{font-size:14.5px}", + ".dsh-wt_md h4{font-size:13px}", + ".dsh-wt_md p{margin:6px 0}", + ".dsh-wt_md a{color:var(--dsw-alias-state-accent-primary,#4f8ef7);text-decoration:none}", + ".dsh-wt_md a:hover{text-decoration:underline}", + ".dsh-wt_md code{font-family:var(--dsw-font-mono,Consolas,Menlo,monospace);font-size:11.5px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06));padding:1px 5px;border-radius:4px}", + ".dsh-wt_md pre{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.04));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;padding:10px 12px;overflow:auto;margin:8px 0}", + ".dsh-wt_md pre code{background:transparent;padding:0;font-size:12px}", + ".dsh-wt_md blockquote{margin:8px 0;padding:2px 12px;border-left:3px solid var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));color:var(--dsw-alias-label-secondary,#9aa4b2)}", + ".dsh-wt_md ul,.dsh-wt_md ol{margin:6px 0;padding-left:22px}", + ".dsh-wt_md li{margin:2px 0}", + ".dsh-wt_md table{border-collapse:collapse;margin:8px 0;font-size:12px}", + ".dsh-wt_md th,.dsh-wt_md td{border:1px solid var(--dsw-alias-border-l1,#262b36);padding:4px 10px;text-align:left}", + ".dsh-wt_md th{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_md hr{border:none;border-top:1px solid var(--dsw-alias-border-l1,#262b36);margin:12px 0}", + ".dsh-wt_md img{max-width:100%}", + ".dsh-wt_imgView{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto;padding:10px;background:var(--dsw-alias-bg-base,#0b0e14)}", + ".dsh-wt_imgView img{max-width:100%;max-height:100%;object-fit:contain}", + ".dsh-wt_pane[data-drop-hover=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);box-shadow:0 0 0 2px rgba(79,142,247,.4),var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4));transform:scale(1.012)}", + ".dsh-wt_paneBar{flex:none;display:flex;align-items:center;height:22px;padding:0 8px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02))}", + ".dsh-wt_paneTitle{flex:1;min-width:0;font-size:11px;font-weight:600;color:var(--dsw-alias-label-secondary,#9aa4b2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_paneFrame{flex:1;width:100%;border:0;background:#010409;min-height:0}", + // iframe 内容标签:容器 + 右上角常驻刷新按钮 + ".dsh-wt_tabRefresh{flex:none;width:14px;height:14px;padding:0;border:none;border-radius:3px;background:transparent;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:10px;line-height:1;cursor:pointer}", + ".dsh-wt_tabRefresh:hover{color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.08))}", + ".dsh-wt_splitDivider{background:var(--dsw-alias-border-l2,#3a4150);cursor:col-resize;touch-action:none;box-sizing:border-box}", + ".dsh-wt_splitDividerH{cursor:row-resize}", + ".dsh-wt_splitDivider:hover,.dsh-wt_splitDividerH:hover{background:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 新建工作区(拓扑预设) + ".dsh-wt_presets{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;padding:2px 8px 6px}", + ".dsh-wt_preset{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px 2px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:10px;line-height:13px;cursor:pointer}", + ".dsh-wt_preset:hover{border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_preset[data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_thumb{display:flex;flex-direction:column;width:54px;height:36px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:3px;overflow:hidden;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03))}", + ".dsh-wt_thumbRow{flex:1;display:flex;min-height:0}", + ".dsh-wt_thumbCols{flex-direction:row}", + ".dsh-wt_thumbCol{flex:1;min-width:0;display:flex;flex-direction:column}", + ".dsh-wt_thumbRow:last-child .dsh-wt_thumbCell{border-bottom:none}", + ".dsh-wt_thumbCell{flex:1;min-width:0;border-right:1px solid var(--dsw-alias-border-l1,#262b36);border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);display:flex;align-items:center;justify-content:center;font-size:8px;line-height:1}", + ".dsh-wt_thumbRow .dsh-wt_thumbCell:last-child{border-right:none}", + ".dsh-wt_thumbChat{background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff}", + // 预设网格末尾的 + 自定义磁贴 + ".dsh-wt_presetAdd{border-style:dashed;color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_presetAddIcon{font-size:18px;line-height:20px}", + ".dsh-wt_presetAddText{font-size:10px;line-height:13px}", + // 项目卡片上的对话绑定按钮(○○ 空心 = 未绑定 / ●● 实心 = 已绑定;CSS 双圆绘制,黑白单色克制: + // 未绑定次级灰空心、已绑定主色实心,不用强调色;hover 区域 = 22×22 圆角矩形按钮底, + // 气泡为 body 级元素向右伸出(跨层显示),垂直居中于按钮) + ".dsh-wt_bindBtn{position:absolute;right:26px;top:50%;transform:translateY(-50%);width:22px;height:22px;margin:0;display:block;border-radius:6px;color:var(--dsw-alias-label-secondary,#9aa4b2);cursor:pointer;user-select:none}", + ".dsh-wt_bindBtn:hover{background:var(--dsw-alias-fill-l2,rgba(255,255,255,.09));color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_bindBtn[data-bound=true]{color:var(--dsw-alias-label-primary,#e6e8eb)}", + // 任务完成提醒镜像:绿色发光 / 待决提醒:黄色发光(点击项目即 ack 恢复常态实心); + // 工作中:蓝色发光 + 两圆交替亮灭(对应 DSH 对话的转圈标记,无需 ack,running 变 false 自动停) + ".dsh-wt_bindBtn[data-bound=done]{color:#3fb950}", + ".dsh-wt_bindBtn[data-bound=need]{color:#d29922}", + ".dsh-wt_bindBtn[data-bound=busy]{color:#4f8ef7}", + "@keyframes dsh-wt-busyA{0%,44%{opacity:1}50%,94%{opacity:.12}100%{opacity:1}}", + "@keyframes dsh-wt-busyB{0%,44%{opacity:.12}50%,94%{opacity:1}100%{opacity:.12}}", + ".dsh-wt_bindBtn[data-bound=busy] .dsh-wt_bindCircles::before{animation:dsh-wt-busyA 1s ease-in-out infinite}", + ".dsh-wt_bindBtn[data-bound=busy] .dsh-wt_bindCircles::after{animation:dsh-wt-busyB 1s ease-in-out infinite}", + ".dsh-wt_bindBtn[data-bound=done] .dsh-wt_bindCircles,.dsh-wt_bindBtn[data-bound=need] .dsh-wt_bindCircles,.dsh-wt_bindBtn[data-bound=busy] .dsh-wt_bindCircles{filter:drop-shadow(0 0 3px currentColor)}", + // 气泡为 body 级独立元素(.dsh-wt_bindTip),此处只保留按钮本体样式 + ".dsh-wt_bindTip{position:fixed;transform:translateY(-50%);padding:5px 9px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:6px;background:var(--dsw-alias-fill-l2,#171b22);color:var(--dsw-alias-label-primary,#e6e8eb);font-size:11px;line-height:15px;white-space:nowrap;pointer-events:none;z-index:1200;box-shadow:0 4px 12px rgba(0,0,0,.35);display:none}", + ".dsh-wt_bindCircles{position:absolute;left:50%;top:50%;width:17px;height:7px;transform:translate(-50%,-50%)}", + ".dsh-wt_bindCircles::before,.dsh-wt_bindCircles::after{content:'';position:absolute;top:50%;width:6px;height:6px;margin-top:-3px;border-radius:50%;box-sizing:border-box;border:1.2px solid currentColor;background:transparent}", + ".dsh-wt_bindCircles::before{left:0}", + ".dsh-wt_bindCircles::after{left:10px}", + ".dsh-wt_bindBtn[data-bound=true] .dsh-wt_bindCircles::before,.dsh-wt_bindBtn[data-bound=true] .dsh-wt_bindCircles::after,.dsh-wt_bindBtn[data-bound=done] .dsh-wt_bindCircles::before,.dsh-wt_bindBtn[data-bound=done] .dsh-wt_bindCircles::after,.dsh-wt_bindBtn[data-bound=need] .dsh-wt_bindCircles::before,.dsh-wt_bindBtn[data-bound=need] .dsh-wt_bindCircles::after,.dsh-wt_bindBtn[data-bound=busy] .dsh-wt_bindCircles::before,.dsh-wt_bindBtn[data-bound=busy] .dsh-wt_bindCircles::after{background:currentColor}", + // 布局条目卡片 + ".dsh-wt_layout{display:flex;align-items:center;gap:7px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;cursor:pointer;text-align:left}", + ".dsh-wt_layout:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_layout[data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_layout[data-on=true] .dsh-wt_layoutName{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_layoutIcon{flex:none;font-size:15px}", + ".dsh-wt_layoutText{flex:1;min-width:0;display:flex;flex-direction:column;gap:0}", + ".dsh-wt_layoutName{font-size:12px;font-weight:400;line-height:17px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + // 箭头与项目名同一行高 + 字面中心对齐;› 墨迹在字面框内偏下,整体上移 1px 使视觉居中 + ".dsh-wt_layoutArrow{flex:none;display:inline-flex;align-items:center;height:18px;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:14px;line-height:18px;transform:translateY(-1.5px)}", + // 入驻项目卡自带箭头(桥注入 .dsh-wt_resArrow):与布局卡同款视觉居中 + "button[data-wt-id] > .dsh-wt_resArrow{display:inline-flex;align-items:center;height:18px;line-height:18px;transform:translateY(-1.5px)}", + // 项目卡片统一:所有入驻项目卡片(data-wt-id 通用标记)与布局卡片同款常显框 + ".dsh-wt_projects [data-wt-id]{border-color:var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02))}", + ".dsh-wt_projects [data-wt-id]:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_projects [data-wt-id][data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + // 标签精简:项目卡片只留名称一行,小字描述行去掉 + ".dsh-wt_projects [data-wt-id] > :nth-child(2) > :nth-child(2){display:none}", + // 图标选择弹窗(固定定位,点击项目/布局/快捷方式的图标唤出) + ".dsh-wt_iconPop{position:fixed;z-index:81;width:256px;padding:8px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:10px;background:var(--dsw-alias-bg-base,#0b0e14);box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_iconPopTitle{font-size:10px;letter-spacing:.05em;color:var(--dsw-alias-label-tertiary,#6e7683);padding:1px 4px 6px}", + ".dsh-wt_iconGrid{display:grid;grid-template-columns:repeat(6,1fr);gap:4px}", + ".dsh-wt_iconCell{display:flex;align-items:center;justify-content:center;aspect-ratio:1;border:1px solid transparent;border-radius:6px;background:transparent;font-size:17px;line-height:1;cursor:pointer;padding:0}", + ".dsh-wt_iconCell:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05));border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_iconCell[data-on=true]{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.08));border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 可点图标(布局卡 / 管理行 / 快捷方式上的图标,点击换 emoji) + ".dsh-wt_iconPick{flex:none;display:inline-flex;align-items:center;justify-content:center;padding:1px;border:none;background:transparent;cursor:pointer;border-radius:4px}", + ".dsh-wt_iconPick:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.08))}", + // 四类项目卡片统一竖向高度(常驻×2 / 布局 / 快捷方式;新建条目自动继承) + ".dsh-wt_projects [data-wt-id],.dsh-wt_layout,.dsh-wt_shortcut{height:34px;box-sizing:border-box}", + // 入驻项目卡片图标覆盖:data-wt-icon 存在时用 attr() 替换显示(原字符字号压到 0) + ".dsh-wt_projects [data-wt-id] > :first-child[data-wt-icon]{font-size:0;line-height:20px}", + ".dsh-wt_projects [data-wt-id] > :first-child[data-wt-icon]::before{content:attr(data-wt-icon);font-size:15px;line-height:20px}", + // 常驻项目卡片与新建项目统一:emoji 字号 15px、名称不加粗 + ".dsh-wt_projects [data-wt-id] > :first-child{font-size:15px;line-height:20px}", + ".dsh-wt_projects [data-wt-id] > :nth-child(2) > :first-child{font-weight:400}", + // 头部按钮内的官方 SVG 图标 + ".dsh-wt_iconBtn svg{display:block}", + // 窗内容:选择器 / 自定义 / 浏览器 / 占位 + ".dsh-wt_panePicker{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:12px;overflow:auto}", + ".dsh-wt_panePicker-row{flex-direction:row;flex-wrap:wrap}", + ".dsh-wt_panePicker-grid{display:grid;grid-template-columns:auto auto;grid-template-rows:auto auto;gap:10px;place-content:center}", + ".dsh-wt_panePicker-col{flex-direction:column}", + // 自定义窗口对话框(居中卡片) + ".dsh-wt_customBox{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:14px;overflow:auto}", + ".dsh-wt_customCard{display:flex;flex-direction:column;gap:10px;width:100%;max-width:360px;padding:14px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:10px;background:var(--dsw-alias-bg-base,#0b0e14);box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_customTitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_customHint{font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-secondary,#9aa4b2);margin:0}", + // 自定义对话框:模式切换(新建对话 / 发送到会话) + ".dsh-wt_customModes{display:flex;gap:6px}", + ".dsh-wt_customModeBtn{flex:1;display:flex;align-items:center;justify-content:center;padding:4px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_customModeBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_customModeBtnOn{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_customInput{width:100%;box-sizing:border-box;min-height:96px;padding:8px 10px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;outline:none;resize:vertical}", + ".dsh-wt_customInput:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 新建分组:父目录 / 名称单行输入 + ".dsh-wt_customPathInput{flex:1;min-width:0;box-sizing:border-box;padding:5px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;outline:none}", + ".dsh-wt_customPathInput:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 新建项目强制文件夹:两行(父目录/名称) + ".dsh-wt_addFolderRow{display:flex;align-items:center;gap:8px;margin-top:6px;padding:0 2px}", + ".dsh-wt_addFolderPath{flex:1;min-width:0;padding:4px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-primary,#e6e8eb);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_addFolderPathNone{color:var(--dsw-alias-label-tertiary,#6b7280);border-style:dashed}", + ".dsh-wt_addFolderRow .dsh-wt_customLabel{flex:none;width:auto;text-align:left}", + // 绑定弹窗内的项目文件夹区 + ".dsh-wt_bindFolderBox{margin-top:8px;padding:6px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px}", + ".dsh-wt_bindFolderRow{display:flex;align-items:center;justify-content:space-between}", + ".dsh-wt_bindFolderLabel{font-size:12px;line-height:18px;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_bindFolderChange{flex:none;padding:1px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_bindFolderChange:hover{color:var(--dsw-alias-label-primary,#e6e8eb);border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_bindFolderPath{margin-top:4px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#9aa4b2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_bindFolderPathNone{color:var(--dsw-alias-label-tertiary,#6b7280)}", + ".dsh-wt_bindFolderForm{display:flex;flex-direction:column;gap:6px;margin-top:6px}", + // 自定义布局弹窗(+磁贴):描述输入 + 复制提示词 + Toast + ".dsh-wt_customLayoutInput{width:100%;box-sizing:border-box;min-height:110px;margin-top:8px;padding:8px 10px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;outline:none;resize:vertical}", + ".dsh-wt_customLayoutInput:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_customLayoutBtn{width:100%;margin-top:8px;padding:7px 10px;border:1px solid var(--dsw-alias-state-accent-primary,#4f8ef7);border-radius:8px;background:transparent;color:var(--dsw-alias-state-accent-primary,#4f8ef7);font:inherit;font-size:12px;line-height:18px;cursor:pointer}", + ".dsh-wt_customLayoutBtn:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_customLayoutToast{margin:8px 0 0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success,#3fb950)}", + ".dsh-wt_customLayoutToastFail{color:var(--dsw-alias-state-danger,#f85149)}", + // 对话绑定弹窗:绑定对话框内的对话行(点击右侧弹列表) + ".dsh-wt_bindNoneText{font-size:12px;line-height:18px}", + ".dsh-wt_bindFolder{flex:none;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#9aa4b2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:40%}", + ".dsh-wt_bindSep{flex:none;color:var(--dsw-alias-border-l2,#3a4150);font-size:11px}", + ".dsh-wt_bindConvRow{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;margin-top:4px;padding:3px 4px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;cursor:pointer;text-align:left}", + ".dsh-wt_bindConvRow:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05));border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_bindConvRowNone{color:var(--dsw-alias-label-secondary,#9aa4b2)}", + ".dsh-wt_bindConvName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_bindConvChevron{flex:none;color:var(--dsw-alias-label-tertiary,#6b7280);font-size:9px;line-height:1}", + ".dsh-wt_bindHint{margin:6px 0 2px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#9aa4b2)}", + // 自定义窗完成页:自动绑定提示 + ".dsh-wt_customDoneBind{margin:6px 0 0;font-size:11px;line-height:16px;color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_bindUnbind{flex:none;display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}", + ".dsh-wt_bindUnbind:hover{color:var(--dsw-alias-state-danger,#f85149);border-color:var(--dsw-alias-state-danger,#f85149)}", + ".dsh-wt_bindList{max-height:280px;overflow:auto;position:static}", + ".dsh-wt_bindListPop{display:flex;flex-direction:column;padding:6px}", + ".dsh-wt_bindListPop .dsh-wt_bindList{max-height:320px}", + ".dsh-wt_customRow{display:flex;align-items:center;gap:8px}", + ".dsh-wt_customLabel{flex:none;font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa4b2)}", + ".dsh-wt_customSelect{flex:1;min-width:0;padding:5px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;outline:none}", + ".dsh-wt_customSelect option{background-color:var(--dsw-alias-bg-base,#0b0e14);color:var(--dsw-alias-label-primary,#e6e8eb)}", + // 自制下拉(文件夹分组 + 细分隔线) + ".dsh-wt_select{position:relative;flex:1;min-width:0}", + ".dsh-wt_selectBtn{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;padding:5px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;cursor:pointer}", + ".dsh-wt_selectBtn:hover{border-color:var(--dsw-alias-border-l2,#3a4150)}", + ".dsh-wt_selectVal{flex:1;min-width:0;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_selectPh{color:var(--dsw-alias-label-tertiary,#6e7683)}", + ".dsh-wt_selectCaret{flex:none;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:10px;line-height:1}", + ".dsh-wt_selectList{margin-top:4px;max-height:180px;overflow:auto;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:8px;background:var(--dsw-alias-bg-base,#0b0e14);padding:4px;box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_selectItem{display:flex;align-items:center;gap:6px;width:100%;padding:6px 8px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:17px;cursor:pointer;text-align:left}", + ".dsh-wt_selectItem:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_selectItemOn{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06));color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_selectItemTitle{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_selectCurrent{flex:none;font-size:10px;color:var(--dsw-alias-label-tertiary,#6e7683)}", + ".dsh-wt_selectDivider{height:1px;background:var(--dsw-alias-border-l1,#262b36);margin:6px 2px}", + // 文件夹分组标题:与选项同字号、加粗、左侧蓝色竖条 + 微底色,明显区别于下方对话 + ".dsh-wt_selectGroup{display:flex;align-items:center;gap:6px;margin:2px 0 2px;padding:6px 8px;border-left:2px solid var(--dsw-alias-state-accent-primary,#4f8ef7);border-radius:4px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.04));font-size:12px;font-weight:600;letter-spacing:.02em;color:var(--dsw-alias-label-secondary,#9aa4b2);user-select:none}", + ".dsh-wt_customSend{align-self:flex-end;padding:6px 14px;border:none;border-radius:6px;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font:inherit;font-size:12px;cursor:pointer}", + ".dsh-wt_customSend:disabled{opacity:.55;cursor:default}", + ".dsh-wt_customFail{font-size:11px;color:var(--dsw-alias-state-danger,#e5484d);margin:0}", + ".dsh-wt_customDone{font-size:26px;line-height:32px}", + ".dsh-wt_customDoneText{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb);margin:4px 0 0}", + ".dsh-wt_customDoneHint{font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa4b2);margin:0}", + ".dsh-wt_customDone{display:block}", + ".dsh-wt_customBox:has(.dsh-wt_customDone){flex-direction:column;gap:4px;text-align:center}", + ".dsh-wt_panePick{flex:none;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;width:92px;height:78px;padding:8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:10px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:11px;line-height:15px;cursor:pointer;transition:border-color .15s,background .15s,transform .15s}", + ".dsh-wt_panePick:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05));transform:translateY(-1px)}", + ".dsh-wt_panePick span{font-size:22px;line-height:24px}", + ".dsh-wt_paneCustom{flex:none;width:100%;max-width:320px;display:flex;align-items:center;gap:6px;padding:4px}", + ".dsh-wt_paneCustom input{flex:1;min-width:0;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;padding:5px 8px;outline:none}", + ".dsh-wt_paneCustom input:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_paneCustomGo{flex:none;padding:5px 10px;border:none;border-radius:6px;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font:inherit;font-size:12px;cursor:pointer}", + ".dsh-wt_browserBar{flex:none;display:flex;align-items:center;gap:5px;padding:4px 6px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02))}", + ".dsh-wt_browserInput{flex:1;min-width:0;background:transparent;border:none;outline:none;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:11px;line-height:16px}", + ".dsh-wt_browserGo{flex:none;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:12px;cursor:pointer}", + ".dsh-wt_browserGo:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_paneWip{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;color:var(--dsw-alias-label-tertiary,#6e7683)}", + ".dsh-wt_paneWipIcon{font-size:26px;line-height:30px}", + ".dsh-wt_paneWipText{font-size:11px}", + ".dsh-wt_splitFlip{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:13px;cursor:pointer}", + ".dsh-wt_splitFlip:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + // + 右侧弹出面板 + ".dsh-wt_popBackdrop{position:fixed;left:0;top:0;right:0;bottom:0;z-index:79;background:transparent}", + // 删除二次确认(fixed 居中模态,压在弹窗之上) + ".dsh-wt_confirmBackdrop{position:fixed;left:0;top:0;right:0;bottom:0;z-index:81;background:rgba(0,0,0,.35)}", + ".dsh-wt_confirm{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);z-index:82;width:292px;display:flex;flex-direction:column;gap:8px;padding:14px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:10px;background:var(--dsw-alias-bg-base,#0b0e14);box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + ".dsh-wt_confirmTitle{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_confirmBody{font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-secondary,#9aa4b2)}", + ".dsh-wt_confirmActions{display:flex;justify-content:flex-end;gap:8px;margin-top:4px}", + ".dsh-wt_confirmCancel{padding:5px 12px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:12px;cursor:pointer}", + ".dsh-wt_confirmCancel:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_confirmDelete{padding:5px 12px;border:none;border-radius:6px;background:var(--dsw-alias-state-danger,#e5484d);color:#fff;font:inherit;font-size:12px;cursor:pointer}", + ".dsh-wt_confirmDelete:hover{filter:brightness(1.1)}", + ".dsh-wt_pop{max-height:min(540px,calc(100vh - 32px));overflow:auto;box-shadow:var(--dsw-shadow-lv2,0 8px 24px rgba(0,0,0,.4))}", + // 功能窗(资源管理器/SCM/任务/终端) + ".dsh-wt_subBar{flex:none;display:flex;align-items:center;gap:4px;padding:3px 6px;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02))}", + ".dsh-wt_subBtn{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:11px;cursor:pointer}", + ".dsh-wt_subBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_subPath{flex:1;min-width:0;font-size:10.5px;color:var(--dsw-alias-label-tertiary,#6e7683);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_subList{flex:1;min-height:0;overflow:auto;padding:3px}", + ".dsh-wt_subRow{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;padding:3px 6px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:11px;line-height:16px;cursor:pointer;text-align:left}", + ".dsh-wt_subRow:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_subRowStatic{cursor:default}", + ".dsh-wt_subRowStatic:hover{background:transparent}", + ".dsh-wt_subIcon{flex:none;font-size:11px}", + ".dsh-wt_subName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_subEmpty{padding:14px 10px;font-size:11px;color:var(--dsw-alias-label-tertiary,#6e7683);text-align:center}", + ".dsh-wt_subTag{flex:none;font-size:9px;color:var(--dsw-alias-label-tertiary,#6e7683);padding:0 5px;border-radius:8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}", + ".dsh-wt_gitXY{flex:none;width:20px;font-size:9px;text-align:center;border-radius:4px;padding:1px 0}", + ".dsh-wt_gitXYMod{color:#e5b567;background:rgba(229,181,103,.12)}", + ".dsh-wt_gitXYNew{color:#7fd88f;background:rgba(127,216,143,.12)}", + ".dsh-wt_jobDot{flex:none;font-size:8px;line-height:16px}", + ".dsh-wt_jobDot-running{color:#e5b567}", + ".dsh-wt_jobDot-completed{color:#7fd88f}", + ".dsh-wt_jobDot-failed{color:#e5484d}", + ".dsh-wt_jobDot-killed{color:#6e7683}", + ".dsh-wt_jobDot-stopping{color:#9aa4b2}", + ".dsh-wt_termHost{flex:1;min-height:0;padding:6px 2px 2px 8px;background:#010409;overflow:hidden}", + ".dsh-wt_termHost .xterm{height:100%}", + // 窗内标签页 + ".dsh-wt_tabBar{flex:none;display:flex;align-items:center;gap:3px;padding:3px 5px 0;border-bottom:1px solid var(--dsw-alias-border-l1,#262b36);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.02));overflow-x:auto}", + ".dsh-wt_tab{flex:none;display:flex;align-items:center;gap:5px;max-width:150px;padding:3px 8px;border:1px solid transparent;border-bottom:none;border-radius:6px 6px 0 0;color:var(--dsw-alias-label-secondary,#9aa4b2);font-size:10.5px;line-height:16px;cursor:grab;user-select:none;-webkit-user-select:none}", + ".dsh-wt_tab:active{cursor:grabbing}", + ".dsh-wt_tab:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.04))}", + ".dsh-wt_tabOn{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-bg-base,#0b0e14);border-color:var(--dsw-alias-border-l1,#262b36)}", + ".dsh-wt_tabTitle{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_tabClose{flex:none;width:14px;height:14px;padding:0;border:none;border-radius:3px;background:transparent;color:var(--dsw-alias-label-tertiary,#6e7683);font-size:9px;line-height:1;cursor:pointer}", + ".dsh-wt_tabClose:hover{color:var(--dsw-alias-label-primary,#e6e8eb);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.08))}", + // 树形资源管理器 + ".dsh-wt_treeRow{display:flex;align-items:center;gap:5px;width:100%;box-sizing:border-box;padding:3px 6px;border:none;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:11px;line-height:16px;cursor:pointer;text-align:left}", + ".dsh-wt_treeRow:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_treeArrow{flex:none;width:10px;font-size:8px;color:var(--dsw-alias-label-tertiary,#6e7683);transition:transform .12s ease}", + ".dsh-wt_treeArrowOpen{transform:rotate(90deg)}", + ".dsh-wt_treeIcon{flex:none}", + ".dsh-wt_treeName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".dsh-wt_subSection{flex:none;padding:6px 8px 2px;font-size:10px;font-weight:600;letter-spacing:.05em;color:var(--dsw-alias-label-tertiary,#6e7683)}", + // 控制室面板:项目卡片网格(每行 3 张、超出换行;DSH 简洁 + 苹果式卡片)。 + // 主题变量自带作用域:dark 缺省;data-wt-theme=light 换浅色;system 由面板读宿主 color-scheme 落成 dark/light。 + ".dsh-wt_console{--wt-bg:#0a0d13;--wt-card:#171c25;--wt-cardHover:#1d232e;--wt-border:#2a3140;--wt-borderHover:#39445a;--wt-text:#e6e8eb;--wt-text2:#9aa4b2;--wt-text3:#6e7683;--wt-chip:rgba(255,255,255,.06);--wt-grid:rgba(255,255,255,.045);--wt-shadow:0 6px 20px rgba(0,0,0,.35);position:relative;flex:1;min-height:0;overflow:auto;padding:22px;background-image:linear-gradient(var(--wt-grid) 1px,transparent 1px),linear-gradient(90deg,var(--wt-grid) 1px,transparent 1px);background-size:30px 30px;background-color:var(--wt-bg)}", + // 工作中的卡片流光:光带加长羽化 + 光层超出卡片(移动时不露整齐边缘),每 ~3.2s 从左上斜扫到右下 + ".dsh-wt_consoleSweep{position:absolute;inset:-30%;border-radius:inherit;pointer-events:none;background:linear-gradient(115deg,rgba(255,255,255,.01) 0%,rgba(255,255,255,.045) 30%,rgba(255,255,255,.13) 50%,rgba(255,255,255,.045) 70%,rgba(255,255,255,.01) 100%);opacity:0;animation:consoleSweep 3.2s ease-in-out infinite}", + ".dsh-wt_console[data-wt-theme=light] .dsh-wt_consoleSweep{background:linear-gradient(115deg,rgba(255,255,255,.1) 0%,rgba(255,255,255,.3) 30%,rgba(255,255,255,.55) 50%,rgba(255,255,255,.3) 70%,rgba(255,255,255,.1) 100%)}", + "@keyframes consoleSweep{0%{opacity:0;transform:translate(-12%,-12%)}35%{opacity:1}55%{opacity:1}92%,100%{opacity:0;transform:translate(12%,12%)}}", + ".dsh-wt_console[data-wt-theme=light]{--wt-bg:#eef1f5;--wt-card:#ffffff;--wt-cardHover:#f7f9fb;--wt-border:#d8dee6;--wt-borderHover:#b9c4d2;--wt-grid:rgba(27,31,36,.07);--wt-text:#1c2128;--wt-text2:#57606a;--wt-text3:#8b949e;--wt-chip:rgba(27,31,36,.07);--wt-shadow:0 6px 20px rgba(31,41,55,.10)}", + ".dsh-wt_consoleHead{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-bottom:12px}", + ".dsh-wt_consoleTitle{font-size:14px;font-weight:700;line-height:20px;color:var(--wt-text)}", + ".dsh-wt_consoleTheme{display:inline-flex;align-items:center;padding:2px;border:1px solid var(--wt-border);border-radius:999px;background:var(--wt-card)}", + ".dsh-wt_consoleThemeBtn{flex:none;padding:3px 9px;border:none;border-radius:999px;background:transparent;color:var(--wt-text3);font:inherit;font-size:12px;line-height:18px;cursor:pointer;opacity:.85}", + ".dsh-wt_consoleThemeBtn:hover{opacity:1;background:var(--wt-chip)}", + ".dsh-wt_consoleThemeBtnOn{background:var(--wt-chip);color:var(--wt-text);opacity:1}", + ".dsh-wt_consoleGrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:64px;align-content:start;margin-top:clamp(32px,9vh,110px);max-width:856px;margin-left:auto;margin-right:auto}", + ".dsh-wt_consoleCard{position:relative;display:flex;flex-direction:column;gap:14px;aspect-ratio:1/1;min-height:192px;padding:21px;background:linear-gradient(135deg,rgba(255,255,255,.22) 0%,rgba(255,255,255,.07) 30%,rgba(255,255,255,.01) 60%,rgba(0,0,0,.07) 100%),rgba(18,23,32,.24);border:1px solid transparent;border-radius:16px;box-shadow:0 10px 28px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.13);cursor:pointer;transition:transform .14s ease,box-shadow .14s ease;overflow:hidden}", + // 玻璃边缘:四角黑白渐变描边(左上/右下=白,右上/左下=黑),1px 环挖空实现 + '.dsh-wt_consoleCard::after{content:"";position:absolute;inset:0;border-radius:inherit;padding:1px;background:conic-gradient(from 45deg,rgba(0,0,0,.4) 0deg,rgba(255,255,255,.55) 90deg,rgba(0,0,0,.4) 180deg,rgba(255,255,255,.55) 270deg,rgba(0,0,0,.4) 360deg);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;pointer-events:none;opacity:.5}', + ".dsh-wt_console[data-wt-theme=light] .dsh-wt_consoleCard{background:linear-gradient(135deg,rgba(255,255,255,1) 0%,rgba(255,255,255,.65) 30%,rgba(255,255,255,.12) 60%,rgba(31,41,55,.06) 100%),rgba(255,255,255,.34);box-shadow:0 10px 28px rgba(31,41,55,.18),inset 0 1px 0 rgba(255,255,255,1)}", + ".dsh-wt_console[data-wt-theme=light] .dsh-wt_consoleCard::after{background:conic-gradient(from 45deg,rgba(27,31,36,.4) 0deg,rgba(255,255,255,1) 90deg,rgba(27,31,36,.4) 180deg,rgba(255,255,255,1) 270deg,rgba(27,31,36,.4) 360deg);opacity:.9}", + // 状态光效卡片:玻璃边缘让位给霓虹描边/旋转光环 + ".dsh-wt_consoleCard-glowDone::after,.dsh-wt_consoleCard-glowNeed::after{opacity:0}", + ".dsh-wt_consoleCard:hover{transform:translateY(-2px);box-shadow:0 14px 32px rgba(0,0,0,.32),inset 0 1px 0 rgba(255,255,255,.09)}", + ".dsh-wt_consoleCardSelf{cursor:default;opacity:.97}", + ".dsh-wt_consoleCardHead{display:flex;align-items:center;gap:13px;min-width:0}", + ".dsh-wt_consoleIcon{flex:none;font-size:31px;line-height:1}", + ".dsh-wt_consoleName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:20px;font-weight:700;line-height:28px;color:var(--wt-text)}", + ".dsh-wt_consoleDivider{flex:none;height:1px;background:var(--wt-border)}", + ".dsh-wt_consoleStatusRow{display:flex;align-items:baseline;justify-content:space-between;gap:9px;min-width:0}", + ".dsh-wt_consoleStatus{flex:none;font-size:22px;font-weight:700;line-height:30px;color:var(--wt-text2)}", + ".dsh-wt_consoleStatus-busy{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_consoleStatus-need{color:var(--dsw-alias-state-warning,#d29922)}", + ".dsh-wt_consoleStatus-done{color:var(--dsw-alias-state-success,#3fb950)}", + ".dsh-wt_consoleRuntime{flex:none;font-size:17px;font-weight:600;line-height:24px;color:var(--wt-text2);font-variant-numeric:tabular-nums}", + ".dsh-wt_consolePreview{display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;font-size:8.5px;line-height:13px;color:var(--wt-text2);word-break:break-word}", + ".dsh-wt_consolePreviewNone{color:var(--wt-text3);font-style:italic;-webkit-line-clamp:1}", + // 三色光效:整卡霓虹描边光晕(像侧栏双圆点的发光质感)——完成=绿、待决=黄;工作=蓝色描边顺时针旋转 + ".dsh-wt_consoleCard-glowDone{border-color:rgba(63,185,80,.9);box-shadow:0 0 8px rgba(63,185,80,.5),0 0 26px rgba(63,185,80,.3),inset 0 0 16px rgba(63,185,80,.07)}", + ".dsh-wt_consoleCard-glowNeed{border-color:rgba(210,153,34,.95);box-shadow:0 0 8px rgba(210,153,34,.5),0 0 26px rgba(210,153,34,.3),inset 0 0 16px rgba(210,153,34,.08)}", + '@property --consoleAngle{syntax:"";initial-value:0deg;inherits:false}', + ".dsh-wt_consoleCard-busy{box-shadow:0 0 10px rgba(94,160,255,.55),0 0 34px rgba(79,142,247,.4)}", + '.dsh-wt_consoleCard-busy::before{content:"";position:absolute;inset:-4px;border-radius:19px;padding:4px;background:conic-gradient(from var(--consoleAngle),transparent 0deg,rgba(94,160,255,0) 25deg,#dcebff 55deg,#9cc6ff 85deg,rgba(94,160,255,0) 125deg,transparent 200deg);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;animation:consoleAngleSpin 1.4s linear infinite;filter:drop-shadow(0 0 8px rgba(140,190,255,.85));pointer-events:none}', + "@keyframes consoleAngleSpin{to{--consoleAngle:360deg}}", + ".dsh-wt_consoleEmpty{padding:40px 0;text-align:center;font-size:12px;color:var(--wt-text3)}", + // 创建卡片:虚线 + 居中加号,永远最后一位 + // 创建卡片:玻璃底 + 虚线边,永远最后一位 + ".dsh-wt_consoleAdd{justify-content:center;align-items:center;gap:10px;background:radial-gradient(circle at 50% 42%,rgba(255,255,255,.09),rgba(255,255,255,0) 65%),rgba(18,23,32,.34);border:1.5px dashed var(--wt-borderHover)}", + ".dsh-wt_consoleAdd::after{display:none}", + ".dsh-wt_console[data-wt-theme=light] .dsh-wt_consoleAdd{background:radial-gradient(circle at 50% 42%,rgba(255,255,255,.95),rgba(255,255,255,0) 65%),rgba(255,255,255,.55)}", + ".dsh-wt_consoleAdd:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:rgba(23,28,37,.45)}", + ".dsh-wt_consoleAddPlus{font-size:34px;line-height:1;color:var(--wt-text2);font-weight:400}", + ".dsh-wt_consoleAdd:hover .dsh-wt_consoleAddPlus{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_consoleAddLabel{font-size:17px;font-weight:600;color:var(--wt-text2)}", + ".dsh-wt_consoleAdd:hover .dsh-wt_consoleAddLabel{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + // 控制室入口卡:统筹主程序的差异化(渐变底 + 微光;无描边,颜色更亮更饱和) + ".dsh-wt_projects .dsh-wt_consoleEntry{background:linear-gradient(135deg,rgba(109,164,255,.30),rgba(167,130,255,.22));border-color:transparent;box-shadow:0 0 14px rgba(96,150,255,.22)}", + ".dsh-wt_projects .dsh-wt_consoleEntry:hover{background:linear-gradient(135deg,rgba(109,164,255,.42),rgba(167,130,255,.32));box-shadow:0 0 18px rgba(96,150,255,.32)}", + ".dsh-wt_projects .dsh-wt_consoleEntry[data-on=true]{background:linear-gradient(135deg,rgba(109,164,255,.38),rgba(167,130,255,.28));box-shadow:0 0 18px rgba(96,150,255,.34)}", + ".dsh-wt_projects .dsh-wt_consoleEntry .dsh-wt_layoutIcon{font-size:15px}", + ".dsh-wt_projects .dsh-wt_consoleEntry .dsh-wt_layoutName{font-weight:600;color:var(--dsw-alias-label-primary,#e6e8eb)}", + // 控制室强制绑定弹窗:左加入现有 / 右新建对话 + ".dsh-wt_consoleBindCols{display:flex;gap:12px}", + ".dsh-wt_consoleBindCol{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}", + ".dsh-wt_consoleBindColNew{border-left:1px solid var(--dsw-alias-border-l1,#262b36);padding-left:12px}", + ".dsh-wt_consoleBindLabel{font-size:12px;font-weight:600;line-height:18px;color:var(--dsw-alias-label-primary,#e6e8eb)}", + ".dsh-wt_consoleBindList{max-height:300px;overflow:auto;position:static}", + ".dsh-wt_consoleBindEmpty{padding:20px 0;text-align:center;font-size:11px;color:var(--dsw-alias-label-tertiary,#6e7683)}", + ".dsh-wt_consoleSelect,.dsh-wt_consoleInput{width:100%;box-sizing:border-box;padding:6px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:11.5px;line-height:16px;outline:none}", + ".dsh-wt_consoleSelect:focus,.dsh-wt_consoleInput:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}", + ".dsh-wt_consoleErr{margin:0;font-size:11px;line-height:16px;color:var(--dsw-alias-state-danger,#f85149)}", + ".dsh-wt_consoleCreateBtn{margin-top:2px;padding:7px 10px;border:1px solid var(--dsw-alias-state-accent-primary,#4f8ef7);border-radius:8px;background:transparent;color:var(--dsw-alias-state-accent-primary,#4f8ef7);font:inherit;font-size:12px;line-height:18px;cursor:pointer}", + ".dsh-wt_consoleCreateBtn:hover:not(:disabled){background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}", + ".dsh-wt_consoleCreateBtn:disabled{opacity:.55;cursor:default}" +].join("\n"); + +// src/client/locales.ts +var zh = { + "title": "\u5DE5\u4F5C\u53F0", + "rail.title": "\u5DE5\u4F5C\u53F0\uFF08\u5C55\u5F00\u4FA7\u8FB9\u680F\u67E5\u770B\uFF09", + "handle.title": "\u6309\u4F4F\u62D6\u52A8\u4F4D\u7F6E \xB7 \u53CC\u51FB\u590D\u4F4D", + "handle.aria": "\u62D6\u52A8\u5DE5\u4F5C\u53F0\u4F4D\u7F6E", + "menu.search": "\u641C\u7D22\u9879\u76EE", + "menu.viewOptions": "\u8BBE\u7F6E", + "menu.add": "\u6DFB\u52A0\u9879\u76EE", + "search.placeholder": "\u641C\u7D22\u9879\u76EE\u2026", + "search.close": "\u5173\u95ED\u641C\u7D22", + "sort.label": "\u6392\u5E8F\u65B9\u5F0F", + "sort.manual": "\u624B\u52A8", + "sort.recent": "\u6700\u8FD1", + "menu.manage": "\u7BA1\u7406\u9879\u76EE\u2026", + "add.guideTitle": "\u63A5\u5165\u65B0\u9879\u76EE", + "add.guideBody": "\u5DE5\u4F5C\u53F0\u91CC\u7684\u9879\u76EE\u5C31\u662F DSH \u63D2\u4EF6\u2014\u2014\u63D2\u4EF6\u6CE8\u518C\u4E00\u5F20\u300C\u5DE5\u4F5C\u53F0\u9879\u76EE\u5361\u7247\u300D\u5373\u81EA\u52A8\u5165\u9A7B\uFF08\u534F\u8BAE\u89C1\u9879\u76EE PRD \xA75.3\uFF09\u3002\u5DF2\u5B89\u88C5\u4F46\u672A\u5165\u9A7B\u7684\u63D2\u4EF6\u9700\u5728\u63D2\u4EF6\u4EE3\u7801\u91CC\u5B8C\u6210\u6CE8\u518C\u3002", + "add.market": "\u6D4F\u89C8\u63D2\u4EF6\u5E02\u573A", + "add.shortcutTitle": "\u672C\u5730\u5FEB\u6377\u65B9\u5F0F", + "add.shortcutDesc": "\u628A\u4EFB\u610F\u7F51\u5740\u6536\u8FDB\u5DE5\u4F5C\u53F0\uFF0C\u70B9\u51FB\u65B0\u6807\u7B7E\u6253\u5F00\uFF08\u4EC5\u5B58\u672C\u673A\uFF09\u3002", + "add.shortcutNamePh": "\u540D\u79F0", + "add.shortcutIcon": "\u56FE\u6807\uFF08emoji\uFF0C\u53EF\u9009\uFF09", + "add.shortcutHref": "\u94FE\u63A5\uFF08http/https\uFF09", + "add.shortcutAdd": "\u6DFB\u52A0", + "add.shortcutInvalid": "\u8BF7\u586B\u5199\u540D\u79F0\u4E0E\u5408\u6CD5\u7684 http/https \u94FE\u63A5", + "manage.title": "\u7BA1\u7406\u9879\u76EE", + "manage.done": "\u5B8C\u6210", + "manage.renamePh": "\u663E\u793A\u540D", + "manage.hide": "\u9690\u85CF", + "manage.show": "\u663E\u793A", + "manage.removed": "\u5DF2\u5220\u9664\u7684\u9879\u76EE", + "manage.readd": "\u91CD\u65B0\u6DFB\u52A0", + "manage.deleteShortcut": "\u5220\u9664\u5FEB\u6377\u65B9\u5F0F", + "shortcut.badge": "\u672C\u5730", + "add.chooseLayout": "\u9009\u62E9\u5E03\u5C40\u6A21\u5F0F", + "add.layoutNamePh": "\u5E03\u5C40\u540D\u79F0", + "add.folderParent": "\u9879\u76EE\u6587\u4EF6\u5939", + "add.folderPick": "\u9009\u62E9\u4F4D\u7F6E\u2026", + "add.folderNone": "\u672A\u9009\u62E9\uFF08\u70B9\u53F3\u4FA7\u300C\u9009\u62E9\u4F4D\u7F6E\u2026\u300D\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u7A97\u53E3\u91CC\u6311\u4E00\u4E2A\u6587\u4EF6\u5939\uFF09", + "add.folderRequired": "\u8BF7\u5148\u9009\u62E9\u9879\u76EE\u6587\u4EF6\u5939\u7684\u4F4D\u7F6E", + "add.layoutSave": "\u8FDB\u5165\u5DE5\u4F5C\u533A", + "add.layoutInvalid": "\u8BF7\u586B\u5199\u5E03\u5C40\u540D\u79F0", + "manage.deleteLayout": "\u5220\u9664\u5E03\u5C40", + "manage.deleteProject": "\u5220\u9664\u9879\u76EE", + "manage.changeView": "\u53D8\u66F4\u89C6\u56FE", + "viewPick.title": "\u9009\u62E9\u65B0\u89C6\u56FE\uFF08\u5185\u5BB9\u7A97\u81EA\u52A8\u8FC1\u5165\uFF09", + "confirm.title": "\u5220\u9664\u9879\u76EE", + "confirm.cancel": "\u53D6\u6D88", + "confirm.delete": "\u5220\u9664", + "confirm.layoutBody": "\u786E\u5B9A\u5220\u9664\u300C{name}\u300D\uFF1F\u8BE5\u5DE5\u4F5C\u533A\u53CA\u5176\u5E03\u5C40\u5C06\u88AB\u79FB\u9664\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002", + "confirm.shortcutBody": "\u786E\u5B9A\u5220\u9664\u5FEB\u6377\u65B9\u5F0F\u300C{name}\u300D\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002", + "confirm.projectBody": "\u300C{name}\u300D\u5C06\u4ECE\u5DE5\u4F5C\u53F0\u5F7B\u5E95\u79FB\u9664\uFF08\u5BF9\u8BDD\u4E0E\u9879\u76EE\u6587\u4EF6\u90FD\u4FDD\u7559\uFF0C\u53EA\u662F\u4E0D\u518D\u663E\u793A\u9879\u76EE\u5361\u7247\uFF09\u3002", + "pane.browser": "\u6D4F\u89C8\u5668", + "pane.explorer": "\u8D44\u6E90\u7BA1\u7406\u5668", + "pane.scm": "\u6E90\u4EE3\u7801\u7BA1\u7406", + "pane.tasks": "\u4EFB\u52A1\u7BA1\u7406", + "pane.terminal": "\u7EC8\u7AEF", + "pane.custom": "\u81EA\u5B9A\u4E49", + "pane.anim": "\u52A8\u753B", + "pane.console": "\u63A7\u5236\u5BA4", + "pane.refresh": "\u5237\u65B0", + "pane.animUrlPh": "\u7C98\u8D34\u52A8\u753B\u7AD9\u70B9\u5730\u5740\u540E\u56DE\u8F66", + "custom.title": "\u81EA\u5B9A\u4E49\u8FD9\u4E2A\u7A97\u53E3", + "custom.hint": "\u53D1\u9001\u540E\u5C06\u81EA\u52A8\u65B0\u5EFA\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u4E13\u95E8\u8D1F\u8D23\u8FD9\u4E2A\u7A97\u53E3\u7684\u81EA\u5B9A\u4E49\u8BBE\u8BA1\u3002", + "custom.placeholder": "\u544A\u8BC9 AI \u4F60\u60F3\u8BA9\u8FD9\u4E2A\u7A97\u53E3\u505A\u4EC0\u4E48\uFF0C\u4F8B\u5982\uFF1A\u505A\u4E00\u4E2A\u5C55\u793A\u6211\u65C5\u884C\u8DB3\u8FF9\u7684\u65F6\u95F4\u7EBF\u9875\u9762\u2026", + "custom.project": "\u6240\u5C5E\u9879\u76EE", + "custom.modeNew": "\u65B0\u5EFA\u5BF9\u8BDD", + "custom.modeSend": "\u53D1\u9001\u5230\u4F1A\u8BDD", + "custom.session": "\u9009\u62E9\u4F1A\u8BDD", + "custom.sessionCurrent": "\uFF08\u5F53\u524D\uFF09", + "custom.hintSend": "\u5185\u5BB9\u5C06\u76F4\u63A5\u53D1\u9001\u5230\u4F60\u9009\u62E9\u7684\u4F1A\u8BDD\uFF08\u9ED8\u8BA4\u5F53\u524D\u4F1A\u8BDD\uFF09\uFF0C\u7528\u4E8E\u8BA8\u8BBA\u8FD9\u4E2A\u7A97\u53E3\u7684\u81EA\u5B9A\u4E49\u8BBE\u8BA1\u3002", + "custom.send": "\u53D1\u9001\u5E76\u65B0\u5EFA\u5BF9\u8BDD", + "custom.sendToSession": "\u53D1\u9001\u5230\u8BE5\u4F1A\u8BDD", + "custom.sent": "\u5DF2\u53D1\u9001\u5230\u4F1A\u8BDD", + "custom.done": "\u5DF2\u65B0\u5EFA\u4E13\u5C5E\u5BF9\u8BDD", + "custom.doneHint": "AI \u6B63\u5728\u65B0\u4F1A\u8BDD\u4E2D\u4E3A\u4F60\u8BBE\u8BA1\u8FD9\u4E2A\u7A97\u53E3\u3002\u5173\u95ED\u672C\u6807\u7B7E\u5373\u53EF\u8FD4\u56DE\u7A97\u53E3\u9009\u62E9\u3002", + "custom.fail": "\u521B\u5EFA\u5BF9\u8BDD\u5931\u8D25", + "custom.group": "\u5206\u7EC4\uFF08\u5DE5\u4F5C\u533A\uFF09", + "custom.groupNone": "\u672A\u5206\u7EC4", + "custom.groupNew": "\uFF0B \u65B0\u5EFA\u4E00\u4E2A\u5206\u7EC4\u2026", + "custom.groupNewParent": "\u5206\u7EC4\u7236\u76EE\u5F55", + "custom.groupNewName": "\u65B0\u5206\u7EC4\u540D", + "custom.groupNewParentPh": "\u4F8B\u5982 E:\\AI_Workspace\\DeepseekHarness", + "custom.groupNewNamePh": "\u4F8B\u5982 MyProject\uFF08\u5C06\u65B0\u5EFA\u6B64\u6587\u4EF6\u5939\u5E76\u6CE8\u518C\u4E3A\u5206\u7EC4\uFF09", + "custom.groupNeedPath": "\u8BF7\u586B\u5199\u5206\u7EC4\u7236\u76EE\u5F55\u548C\u65B0\u5206\u7EC4\u540D", + "bind.title": "\u7ED1\u5B9A\u5BF9\u8BDD", + "bind.unbind": "\u89E3\u7ED1", + "bind.unbound": "\u672A\u7ED1\u5B9A\u5BF9\u8BDD", + "bind.titleUnbound": "\u7ED1\u5B9A\u5BF9\u8BDD\uFF08\u672A\u7ED1\u5B9A \u25CB\u25CB\uFF09\uFF1A\u70B9\u51FB\u9009\u62E9\u8981\u8DDF\u968F\u7684\u5BF9\u8BDD", + "bind.titleBound": "\u5DF2\u7ED1\u5B9A\u5BF9\u8BDD\uFF08\u25CF\u25CF\uFF09\uFF1A\u70B9\u51FB\u66F4\u6362\u6216\u89E3\u7ED1", + "bind.tipUnbound": "\u672A\u7ED1\u5B9A\u5BF9\u8BDD\uFF1A\u70B9\u51FB\u9009\u62E9\u8981\u8DDF\u968F\u7684\u5BF9\u8BDD", + "bind.tipDone": "\uFF08\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u70B9\u51FB\u9879\u76EE\u67E5\u770B\uFF09", + "bind.tipBusy": "\uFF08\u5BF9\u8BDD\u6B63\u5728\u5904\u7406\u4EFB\u52A1\u2026\uFF09", + "bind.tipNeed": "\uFF08\u9700\u8981\u4F60\u7684\u51B3\u5B9A\uFF0C\u70B9\u51FB\u9879\u76EE\u5904\u7406\uFF09", + "bind.folder": "\u9879\u76EE\u6587\u4EF6\u5939", + "bind.folderChange": "\u66F4\u6539", + "bind.folderNone": "\u672A\u8BBE\u7F6E\uFF08\u5EFA\u8BAE\u8BBE\u7F6E\uFF1A\u9879\u76EE\u4EA7\u51FA\u6587\u4EF6\u90FD\u4F1A\u653E\u8FDB\u8FD9\u91CC\uFF09", + "bind.tipBound": "\u5DF2\u7ED1\u5B9A\u5BF9\u8BDD\uFF1A{name}", + "bind.clickPick": "\u70B9\u51FB\u9009\u62E9\u5BF9\u8BDD", + "bind.hint": "\u6253\u5F00\u9879\u76EE\u65F6\uFF0C\u53F3\u4FA7\u5BF9\u8BDD\u7A97\u4F1A\u81EA\u52A8\u5207\u6362\u5230\u8FD9\u4E2A\u5BF9\u8BDD\u3002", + "customLayout.add": "\u81EA\u5B9A\u4E49", + "customLayout.addTitle": "\u81EA\u5B9A\u4E49\u4E00\u4E2A\u5E03\u5C40\uFF08\u751F\u6210\u63D0\u793A\u8BCD\uFF09", + "customLayout.title": "\u81EA\u5B9A\u4E49\u5E03\u5C40", + "customLayout.placeholder": "\u63CF\u8FF0\u4F60\u60F3\u8981\u7684\u5E03\u5C40\uFF0C\u4F8B\u5982\uFF1A\u53F3\u4FA7\u7AD6\u957F\u5BF9\u8BDD\u7A97\uFF0C\u5DE6\u4FA7\u4E0A\u4E0B\u4E24\u4E2A\u4E00\u6837\u5927\u7684\u7A97\u2026", + "customLayout.copy": "\u590D\u5236\u63D0\u793A\u8BCD\u5230\u526A\u8D34\u677F", + "customLayout.copied": "\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\u3002\u53BB\u4EFB\u610F\u4E00\u4E2A DSH \u5BF9\u8BDD\u91CC\u7C98\u8D34\u53D1\u9001\uFF0C\u5BF9\u65B9\u7684 dsh \u5C31\u77E5\u9053\u8981\u505A\u4EC0\u4E48\u4E86\u3002", + "customLayout.copyFail": "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u5168\u9009\u8F93\u5165\u6846\u5185\u5BB9\u590D\u5236\u3002", + "custom.autoBound": "\u5DF2\u81EA\u52A8\u628A\u8FD9\u4E2A\u9879\u76EE\u7ED1\u5B9A\u5230\u8FD9\u4E2A\u5BF9\u8BDD\uFF08\u5361\u7247\u4E0A\u7684 \u25CF\u25CF \u6309\u94AE\u53EF\u66F4\u6362\u6216\u89E3\u7ED1\uFF09\u3002", + "custom.keptBinding": "\u8BE5\u9879\u76EE\u5DF2\u6709\u7ED1\u5B9A\u7684\u5BF9\u8BDD\uFF0C\u6309\u89C4\u5219\u672A\u81EA\u52A8\u66F4\u6539\u3002", + "console.name": "\u63A7\u5236\u5BA4", + "console.title": "\u63A7\u5236\u5BA4", + "console.themeLabel": "\u9762\u677F\u4E3B\u9898", + "console.themeDark": "\u6DF1\u8272", + "console.themeLight": "\u767D\u8272", + "console.themeSystem": "\u8DDF\u968F\u7CFB\u7EDF", + "console.idle": "\u7A7A\u95F2", + "console.busy": "\u5DE5\u4F5C\u4E2D", + "console.need": "\u5F85\u4F60\u51B3\u5B9A", + "console.done": "\u5DF2\u5B8C\u6210", + "console.kids": "\u5B50\u4EE3\u7406", + "console.noPreview": "\u6682\u65E0\u6D88\u606F", + "console.unboundShort": "\u672A\u7ED1\u5B9A\u5BF9\u8BDD", + "console.jump": "\u8DF3\u8F6C\u5230\u7ED1\u5B9A\u5BF9\u8BDD", + "console.empty": "\u8FD8\u6CA1\u6709\u9879\u76EE", + "console.joinExisting": "\u52A0\u5165\u73B0\u6709\u5BF9\u8BDD", + "console.newConv": "\u65B0\u5EFA\u5BF9\u8BDD", + "console.groupNone": "\u65E0\u5206\u7EC4\uFF08\u7528\u9879\u76EE\u6587\u4EF6\u5939\uFF09", + "console.groupExisting": "\u52A0\u5165\u73B0\u6709\u5206\u7EC4", + "console.groupNew": "\u65B0\u5EFA\u5206\u7EC4", + "console.newParentPh": "\u5206\u7EC4\u7236\u76EE\u5F55\uFF0C\u4F8B\u5982 E:\\AI_Workspace", + "console.newNamePh": "\u5206\u7EC4\u6587\u4EF6\u5939\u540D\uFF08\u5C06\u521B\u5EFA\u5E76\u6CE8\u518C\uFF09", + "console.createBind": "\u65B0\u5EFA\u5E76\u7ED1\u5B9A", + "console.bindFail": "\u521B\u5EFA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5", + "console.noSessions": "\u6CA1\u6709\u53EF\u7528\u5BF9\u8BDD", + "console.addProject": "\u6DFB\u52A0\u9879\u76EE", + "pane.wip": "\u5F00\u53D1\u4E2D\uFF08\u540E\u7EED\u7248\u672C\u63A5\u5165\uFF09", + "pane.explorerNoCwd": "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u76EE\u5F55", + "pane.openLater": "\u8BE5\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u9884\u89C8", + "file.loading": "\u52A0\u8F7D\u4E2D\u2026", + "file.fail": "\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25", + "file.preview": "\u9884\u89C8", + "file.edit": "\u7F16\u8F91", + "file.save": "\u4FDD\u5B58", + "file.saveFail": "\u4FDD\u5B58\u5931\u8D25", + "pane.gitNotRepo": "\u5F53\u524D\u76EE\u5F55\u4E0D\u662F git \u4ED3\u5E93", + "pane.gitClean": "\u5DE5\u4F5C\u533A\u5E72\u51C0", + "pane.jobsEmpty": "\u5F53\u524D\u4F1A\u8BDD\u6682\u65E0\u540E\u53F0\u4EFB\u52A1", + "pane.termFail": "\u7EC8\u7AEF\u4E0D\u53EF\u7528\uFF08\u5BBF\u4E3B\u7F3A\u5C11 node-pty/ws \u6216\u8FDE\u63A5\u5931\u8D25\uFF09", + "pane.closeTab": "\u5173\u95ED\u6807\u7B7E\u9875", + "pane.jobsTitle": "\u540E\u53F0\u4EFB\u52A1", + "pane.subagents": "\u5B50\u4EE3\u7406", + "pane.subagentsEmpty": "\u5F53\u524D\u4F1A\u8BDD\u6682\u65E0\u5B50\u4EE3\u7406", + "split.flip": "\u5207\u6362\u5BF9\u8BDD\u7A97\u4F4D\u7F6E\uFF08\u5DE6\u21C4\u53F3\uFF09", + "split.dragSwap": "\u62D6\u52A8\u6807\u9898\u680F\u4E0E\u5176\u4ED6\u7A97\u4EA4\u6362\u4F4D\u7F6E", + "icons.title": "\u9009\u62E9\u56FE\u6807", + "icons.change": "\u66F4\u6362\u56FE\u6807", + "empty": "\u6682\u65E0\u9879\u76EE" +}; +var en = { + "title": "Worktable", + "rail.title": "Worktable (expand sidebar to view)", + "handle.title": "Drag to move \xB7 double-click to reset", + "handle.aria": "Drag worktable position", + "menu.search": "Search projects", + "menu.viewOptions": "Settings", + "menu.add": "Add project", + "search.placeholder": "Search projects\u2026", + "search.close": "Close search", + "sort.label": "Sort by", + "sort.manual": "Manual", + "sort.recent": "Recent", + "menu.manage": "Manage projects\u2026", + "add.guideTitle": "Add a project", + "add.guideBody": "Projects in the worktable are DSH plugins \u2014 a plugin joins by registering a worktable project card (protocol in the project PRD \xA75.3). Installed plugins that have not registered need to do so in their code.", + "add.market": "Browse plugin marketplace", + "add.shortcutTitle": "Local shortcut", + "add.shortcutDesc": "Pin any URL into the worktable; opens in a new tab (stored locally only).", + "add.shortcutNamePh": "Name", + "add.shortcutIcon": "Icon (emoji, optional)", + "add.shortcutHref": "URL (http/https)", + "add.shortcutAdd": "Add", + "add.shortcutInvalid": "Enter a name and a valid http/https URL", + "manage.title": "Manage projects", + "manage.done": "Done", + "manage.renamePh": "Display name", + "manage.hide": "Hide", + "manage.show": "Show", + "manage.removed": "Removed projects", + "manage.readd": "Re-add", + "manage.deleteShortcut": "Delete shortcut", + "shortcut.badge": "Local", + "add.chooseLayout": "Choose a layout", + "add.layoutNamePh": "Layout name", + "add.folderParent": "Project folder", + "add.folderPick": "Choose\u2026", + "add.folderNone": "Not chosen (click Choose\u2026 to pick a folder in the explorer window)", + "add.folderRequired": "Pick the project folder location first", + "add.layoutSave": "Enter workspace", + "add.layoutInvalid": "Enter a layout name", + "manage.deleteLayout": "Delete layout", + "manage.deleteProject": "Delete project", + "manage.changeView": "Change layout", + "viewPick.title": "Pick a new layout (panes migrate automatically)", + "confirm.title": "Delete project", + "confirm.cancel": "Cancel", + "confirm.delete": "Delete", + "confirm.layoutBody": 'Delete "{name}"? Its workspace and layout will be removed. This cannot be undone.', + "confirm.shortcutBody": 'Delete shortcut "{name}"? This cannot be undone.', + "confirm.projectBody": '"{name}" will be removed from the worktable permanently (the conversation and project files are kept).', + "pane.browser": "Browser", + "pane.explorer": "Explorer", + "pane.scm": "Source control", + "pane.tasks": "Tasks", + "pane.terminal": "Terminal", + "pane.custom": "Custom", + "pane.anim": "Animation", + "pane.console": "Console", + "pane.refresh": "Refresh", + "pane.animUrlPh": "Paste the animation site URL and press Enter", + "custom.title": "Customize this pane", + "custom.hint": "Sending will create a new conversation dedicated to designing this pane.", + "custom.placeholder": "Tell the AI what you want this pane to do, e.g. a timeline page of my travels\u2026", + "custom.project": "Project", + "custom.modeNew": "New conversation", + "custom.modeSend": "Send to a conversation", + "custom.session": "Conversation", + "custom.sessionCurrent": " (current)", + "custom.hintSend": "The content will be sent directly to the conversation you pick (current by default).", + "custom.send": "Send & create conversation", + "custom.sendToSession": "Send to this conversation", + "custom.sent": "Sent to the conversation", + "custom.done": "Conversation created", + "custom.doneHint": "The AI is designing your pane in the new conversation. Close this tab to return to the pane picker.", + "custom.fail": "Failed to create conversation", + "custom.group": "Group (workspace)", + "custom.groupNone": "Ungrouped", + "custom.groupNew": "\uFF0B Create a new group\u2026", + "custom.groupNewParent": "Group parent folder", + "custom.groupNewName": "New group name", + "custom.groupNewParentPh": "e.g. E:\\AI_Workspace\\DeepseekHarness", + "custom.groupNewNamePh": "e.g. MyProject (folder will be created and registered)", + "custom.groupNeedPath": "Fill in the parent folder and new group name", + "bind.title": "Bind conversation", + "bind.unbind": "Unbind", + "bind.unbound": "No conversation bound", + "bind.titleUnbound": "Bind conversation (unbound \u25CB\u25CB): pick the conversation to follow", + "bind.titleBound": "Conversation bound (\u25CF\u25CF): click to change or unbind", + "bind.tipUnbound": "No conversation bound \u2014 click to pick one", + "bind.tipDone": " (task completed \u2014 click the project to view)", + "bind.tipBusy": " (conversation is working on the task\u2026)", + "bind.tipNeed": " (needs your decision \u2014 click the project to handle)", + "bind.folder": "Project folder", + "bind.folderChange": "Change", + "bind.folderNone": "Not set (recommended: project outputs go here)", + "bind.tipBound": "Bound to: {name}", + "bind.clickPick": "click to pick", + "bind.hint": "Opening the project switches the right chat pane to this conversation.", + "customLayout.add": "Custom", + "customLayout.addTitle": "Customize a layout (generate a prompt)", + "customLayout.title": "Custom layout", + "customLayout.placeholder": "Describe the layout you want, e.g. a tall chat column on the right and two equal panes stacked on the left\u2026", + "customLayout.copy": "Copy prompt to clipboard", + "customLayout.copied": "Prompt copied to clipboard. Paste it into any DSH conversation and send \u2014 that dsh will know what to do.", + "customLayout.copyFail": "Copy failed \u2014 select the text above and copy it manually.", + "custom.autoBound": "This project was auto-bound to this conversation (use the \u25CF\u25CF button on its card to change or unbind).", + "custom.keptBinding": "This project already has a bound conversation, so it was not auto-changed.", + "console.name": "Console", + "console.title": "Console", + "console.themeLabel": "Panel theme", + "console.themeDark": "Dark", + "console.themeLight": "Light", + "console.themeSystem": "System", + "console.idle": "Idle", + "console.busy": "Working", + "console.need": "Needs you", + "console.done": "Done", + "console.kids": "subagents", + "console.noPreview": "No messages yet", + "console.unboundShort": "No conversation bound", + "console.jump": "Jump to bound conversation", + "console.empty": "No projects yet", + "console.joinExisting": "Join existing conversation", + "console.newConv": "New conversation", + "console.groupNone": "No group (use project folder)", + "console.groupExisting": "Join existing group", + "console.groupNew": "New group", + "console.newParentPh": "Group parent folder, e.g. E:\\AI_Workspace", + "console.newNamePh": "Group folder name (created & registered)", + "console.createBind": "Create & bind", + "console.bindFail": "Creation failed, try again", + "console.noSessions": "No sessions available", + "console.addProject": "Add project", + "pane.wip": "Coming in a later version", + "pane.explorerNoCwd": "No working directory for the current session", + "pane.openLater": "Preview not supported for this type", + "file.loading": "Loading\u2026", + "file.fail": "Failed to read file", + "file.preview": "Preview", + "file.edit": "Edit", + "file.save": "Save", + "file.saveFail": "Save failed", + "pane.gitNotRepo": "Not a git repository", + "pane.gitClean": "Working tree clean", + "pane.jobsEmpty": "No background jobs in the current session", + "pane.termFail": "Terminal unavailable (host missing node-pty/ws, or connection failed)", + "pane.closeTab": "Close tab", + "pane.jobsTitle": "Background jobs", + "pane.subagents": "Subagents", + "pane.subagentsEmpty": "No subagents in the current session", + "split.flip": "Flip chat side (left \u21C4 right)", + "split.dragSwap": "Drag the title bar to swap panes", + "icons.title": "Pick an icon", + "icons.change": "Change icon", + "empty": "No projects yet" +}; +var NS = "worktable"; + +// src/client/split.tsx +var import_react = require("react"); +var import_xterm2 = __toESM(require_xterm(), 1); + +// node_modules/mdurl/index.mjs +var mdurl_exports = {}; +__export(mdurl_exports, { + decode: () => decode_default, + encode: () => encode_default, + format: () => format, + parse: () => parse_default +}); + +// node_modules/mdurl/lib/decode.mjs +var decodeCache = {}; +function getDecodeCache(exclude) { + let cache = decodeCache[exclude]; + if (cache) { + return cache; + } + cache = decodeCache[exclude] = []; + for (let i = 0; i < 128; i++) { + const ch = String.fromCharCode(i); + cache.push(ch); + } + for (let i = 0; i < exclude.length; i++) { + const ch = exclude.charCodeAt(i); + cache[ch] = "%" + ("0" + ch.toString(16).toUpperCase()).slice(-2); + } + return cache; +} +function decode(string, exclude) { + if (typeof exclude !== "string") { + exclude = decode.defaultChars; + } + const cache = getDecodeCache(exclude); + return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) { + let result = ""; + for (let i = 0, l = seq.length; i < l; i += 3) { + const b1 = parseInt(seq.slice(i + 1, i + 3), 16); + if (b1 < 128) { + result += cache[b1]; + continue; + } + if ((b1 & 224) === 192 && i + 3 < l) { + const b2 = parseInt(seq.slice(i + 4, i + 6), 16); + if ((b2 & 192) === 128) { + const chr = b1 << 6 & 1984 | b2 & 63; + if (chr < 128) { + result += "\uFFFD\uFFFD"; + } else { + result += String.fromCharCode(chr); + } + i += 3; + continue; + } + } + if ((b1 & 240) === 224 && i + 6 < l) { + const b2 = parseInt(seq.slice(i + 4, i + 6), 16); + const b3 = parseInt(seq.slice(i + 7, i + 9), 16); + if ((b2 & 192) === 128 && (b3 & 192) === 128) { + const chr = b1 << 12 & 61440 | b2 << 6 & 4032 | b3 & 63; + if (chr < 2048 || chr >= 55296 && chr <= 57343) { + result += "\uFFFD\uFFFD\uFFFD"; + } else { + result += String.fromCharCode(chr); + } + i += 6; + continue; + } + } + if ((b1 & 248) === 240 && i + 9 < l) { + const b2 = parseInt(seq.slice(i + 4, i + 6), 16); + const b3 = parseInt(seq.slice(i + 7, i + 9), 16); + const b4 = parseInt(seq.slice(i + 10, i + 12), 16); + if ((b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128) { + let chr = b1 << 18 & 1835008 | b2 << 12 & 258048 | b3 << 6 & 4032 | b4 & 63; + if (chr < 65536 || chr > 1114111) { + result += "\uFFFD\uFFFD\uFFFD\uFFFD"; + } else { + chr -= 65536; + result += String.fromCharCode(55296 + (chr >> 10), 56320 + (chr & 1023)); + } + i += 9; + continue; + } + } + result += "\uFFFD"; + } + return result; + }); +} +decode.defaultChars = ";/?:@&=+$,#"; +decode.componentChars = ""; +var decode_default = decode; + +// node_modules/mdurl/lib/encode.mjs +var encodeCache = {}; +function getEncodeCache(exclude) { + let cache = encodeCache[exclude]; + if (cache) { + return cache; + } + cache = encodeCache[exclude] = []; + for (let i = 0; i < 128; i++) { + const ch = String.fromCharCode(i); + if (/^[0-9a-z]$/i.test(ch)) { + cache.push(ch); + } else { + cache.push("%" + ("0" + i.toString(16).toUpperCase()).slice(-2)); + } + } + for (let i = 0; i < exclude.length; i++) { + cache[exclude.charCodeAt(i)] = exclude[i]; + } + return cache; +} +function encode(string, exclude, keepEscaped) { + if (typeof exclude !== "string") { + keepEscaped = exclude; + exclude = encode.defaultChars; + } + if (typeof keepEscaped === "undefined") { + keepEscaped = true; + } + const cache = getEncodeCache(exclude); + let result = ""; + for (let i = 0, l = string.length; i < l; i++) { + const code2 = string.charCodeAt(i); + if (keepEscaped && code2 === 37 && i + 2 < l) { + if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) { + result += string.slice(i, i + 3); + i += 2; + continue; + } + } + if (code2 < 128) { + result += cache[code2]; + continue; + } + if (code2 >= 55296 && code2 <= 57343) { + if (code2 >= 55296 && code2 <= 56319 && i + 1 < l) { + const nextCode = string.charCodeAt(i + 1); + if (nextCode >= 56320 && nextCode <= 57343) { + result += encodeURIComponent(string[i] + string[i + 1]); + i++; + continue; + } + } + result += "%EF%BF%BD"; + continue; + } + result += encodeURIComponent(string[i]); + } + return result; +} +encode.defaultChars = ";/?:@&=+$,-_.!~*'()#"; +encode.componentChars = "-_.!~*'()"; +var encode_default = encode; + +// node_modules/mdurl/lib/format.mjs +function format(url) { + let result = ""; + result += url.protocol || ""; + result += url.slashes ? "//" : ""; + result += url.auth ? url.auth + "@" : ""; + if (url.hostname && url.hostname.indexOf(":") !== -1) { + result += "[" + url.hostname + "]"; + } else { + result += url.hostname || ""; + } + result += url.port ? ":" + url.port : ""; + result += url.pathname || ""; + result += url.search || ""; + result += url.hash || ""; + return result; +} + +// node_modules/mdurl/lib/parse.mjs +function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.pathname = null; +} +var protocolPattern = /^([a-z0-9.+-]+:)/i; +var portPattern = /:[0-9]*$/; +var simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/; +var delims = ["<", ">", '"', "`", " ", "\r", "\n", " "]; +var unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims); +var autoEscape = ["'"].concat(unwise); +var nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape); +var hostEndingChars = ["/", "?", "#"]; +var hostnameMaxLen = 255; +var hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/; +var hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/; +var hostlessProtocol = { + javascript: true, + "javascript:": true +}; +var slashedProtocol = { + http: true, + https: true, + ftp: true, + gopher: true, + file: true, + "http:": true, + "https:": true, + "ftp:": true, + "gopher:": true, + "file:": true +}; +function urlParse(url, slashesDenoteHost) { + if (url && url instanceof Url) return url; + const u = new Url(); + u.parse(url, slashesDenoteHost); + return u; +} +Url.prototype.parse = function(url, slashesDenoteHost) { + let lowerProto, hec, slashes; + let rest = url; + rest = rest.trim(); + if (!slashesDenoteHost && url.split("#").length === 1) { + const simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + } + return this; + } + } + let proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + lowerProto = proto.toLowerCase(); + this.protocol = proto; + rest = rest.substr(proto.length); + } + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + slashes = rest.substr(0, 2) === "//"; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; + } + } + if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) { + let hostEnd = -1; + for (let i = 0; i < hostEndingChars.length; i++) { + hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { + hostEnd = hec; + } + } + let auth, atSign; + if (hostEnd === -1) { + atSign = rest.lastIndexOf("@"); + } else { + atSign = rest.lastIndexOf("@", hostEnd); + } + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = auth; + } + hostEnd = -1; + for (let i = 0; i < nonHostChars.length; i++) { + hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { + hostEnd = hec; + } + } + if (hostEnd === -1) { + hostEnd = rest.length; + } + if (rest[hostEnd - 1] === ":") { + hostEnd--; + } + const host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + this.parseHost(host); + this.hostname = this.hostname || ""; + const ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]"; + if (!ipv6Hostname) { + const hostparts = this.hostname.split(/\./); + for (let i = 0, l = hostparts.length; i < l; i++) { + const part = hostparts[i]; + if (!part) { + continue; + } + if (!part.match(hostnamePartPattern)) { + let newpart = ""; + for (let j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + newpart += "x"; + } else { + newpart += part[j]; + } + } + if (!newpart.match(hostnamePartPattern)) { + const validParts = hostparts.slice(0, i); + const notHost = hostparts.slice(i + 1); + const bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = notHost.join(".") + rest; + } + this.hostname = validParts.join("."); + break; + } + } + } + } + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ""; + } + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + } + } + const hash = rest.indexOf("#"); + if (hash !== -1) { + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + const qm = rest.indexOf("?"); + if (qm !== -1) { + this.search = rest.substr(qm); + rest = rest.slice(0, qm); + } + if (rest) { + this.pathname = rest; + } + if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) { + this.pathname = ""; + } + return this; +}; +Url.prototype.parseHost = function(host) { + let port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ":") { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) { + this.hostname = host; + } +}; +var parse_default = urlParse; + +// node_modules/uc.micro/build/index.mjs +var build_exports = {}; +__export(build_exports, { + Any: () => Any, + Cc: () => Cc, + Cf: () => Cf, + P: () => P, + S: () => S, + Z: () => Z +}); +var Any = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var Cc = /[\0-\x1F\x7F-\x9F]/; +var Cf = /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/; +var P = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]/; +var S = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/; +var Z = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/; + +// node_modules/entities/dist/decode-codepoint.js +var decodeMap = /* @__PURE__ */ new Map([ + [0, 65533], + // C1 Unicode control character reference replacements + [128, 8364], + [130, 8218], + [131, 402], + [132, 8222], + [133, 8230], + [134, 8224], + [135, 8225], + [136, 710], + [137, 8240], + [138, 352], + [139, 8249], + [140, 338], + [142, 381], + [145, 8216], + [146, 8217], + [147, 8220], + [148, 8221], + [149, 8226], + [150, 8211], + [151, 8212], + [152, 732], + [153, 8482], + [154, 353], + [155, 8250], + [156, 339], + [158, 382], + [159, 376] +]); +function replaceCodePoint(codePoint) { + if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) { + return 65533; + } + return decodeMap.get(codePoint) ?? codePoint; +} + +// node_modules/entities/dist/internal/decode-shared.js +function decodeBase64(input) { + const binary = atob(input); + const evenLength = binary.length & ~1; + const out = new Uint16Array(evenLength / 2); + for (let index = 0, outIndex = 0; index < evenLength; index += 2) { + const lo = binary.charCodeAt(index); + const hi = binary.charCodeAt(index + 1); + out[outIndex++] = lo | hi << 8; + } + return out; +} + +// node_modules/entities/dist/generated/decode-data-html.js +var htmlDecodeTree = /* @__PURE__ */ decodeBase64("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZABlADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcwCgLCFhAJJjcgAA4DXYBd1wAGYAAOA12Dnd5SF2ZdhiYwDyAOoAbSJwZXEAAKBOIgAHSE9hY2RlZmhpbG9yc3UXARoBHwE6AVIBVQFiAWQBZgGCAakB6QHtAfIBYwB5ACdkUABZADuAqQCpQIABY3B5ACUBKAE1AfUhdGUGYWmg0iJ0KGFsRGlmZmVyZW50aWFsRAAAoEUhbCJleXMAAKAtIQACYWVpb0EBRAFKAU0B8iFvbgxhZABpAGwAO4DHAMdAcgBjAAhhbiJpbnQAAKAwIm8AdAAKYQABZG5ZAV0BaSJsbGEAuGB0I2VyRG90ALdg8gA5AWkAp2NyImNsZQAAAkRNUFRwAXQBeQF9AW8AdAAAoJkiaSJudXMAAKCWIuwhdXMAoJUiaSJtZXMAAKCXIm8AAAFjc4cBlAFrKndpc2VDb250b3VySW50ZWdyYWwAAKAyImUjQ3VybHkAAAFEUZwBpAFvJXVibGVRdW90ZQAAoB0gdSJvdGUAAKAZIAACbG5wdbABtgHNAdgBbwBuAGWgNyIAoHQqgAFnaXQAvAHBAcUB8iJ1ZW50AKBhIm4AdAAAoC8i7yV1ckludGVncmFsAKAuIgABZnLRAdMBAKACIe8iZHVjdACgECJuLnRlckNsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbAAAoDMi7yFzcwCgLypjAHIAAOA12J7ccABDoNMiYQBwAACgTSKABURKU1phY2VmaW9zAAsCEgIVAhgCGwIsAjQCOQI9AnMCfwNvoEUh9CJyYWhkAKARKWMAeQACZGMAeQAFZGMAeQAPZIABZ3JzACECJQIoAuchZXIAoCEgcgAAoKEhaAB2AACg5CoAAWF5MAIzAvIhb24OYRRkbAB0oAciYQCUY3IAAOA12AfdAAFhZkECawIAAWNtRQJnAvIjaXRpY2FsAAJBREdUUAJUAl8CYwJjInV0ZQC0YG8AdAFZAloC2WJiJGxlQWN1dGUA3WJyImF2ZQBgYGkibGRlANxi7yFuZACgxCJmJWVyZW50aWFsRAAAoEYhcAR9AgAAAAAAAIECjgIAABoDZgAA4DXYO91EoagAhQKJAm8AdAAAoNwgcSJ1YWwAAKBQIuIhbGUAA0NETFJVVpkCqAK1Au8C/wIRA28AbgB0AG8AdQByAEkAbgB0AGUAZwByAGEA7ADEAW8AdAKvAgAAAACwAqhgbiNBcnJvdwAAoNMhAAFlb7kC0AJmAHQAgAFBUlQAwQLGAs0CciJyb3cAAKDQIekkZ2h0QXJyb3cAoNQhZQDlACsCbgBnAAABTFLWAugC5SFmdAABQVLcAuECciJyb3cAAKD4J+kkZ2h0QXJyb3cAoPon6SRnaHRBcnJvdwCg+SdpImdodAAAAUFU9gL7AnIicm93AACg0iFlAGUAAKCoInAAQQIGAwAAAAALA3Iicm93AACg0SFvJHduQXJyb3cAAKDVIWUlcnRpY2FsQmFyAACgJSJuAAADQUJMUlRhJAM2AzoDWgNxA3oDciJyb3cAAKGTIUJVLAMwA2EAcgAAoBMpcCNBcnJvdwAAoPUhciJldmUAEWPlIWZ00gJDAwAASwMAAFIDaSVnaHRWZWN0b3IAAKBQKWUkZVZlY3RvcgAAoF4p5SJjdG9yQqC9IWEAcgAAoFYpaSJnaHQA1AFiAwAAaQNlJGVWZWN0b3IAAKBfKeUiY3RvckKgwSFhAHIAAKBXKWUAZQBBoKQiciJyb3cAAKCnIXIAcgBvAPcAtAIAAWN0gwOHA3IAAOA12J/c8iFvaxBhAAhOVGFjZGZnbG1vcHFzdHV4owOlA6kDsAO/A8IDxgPNA9ID8gP9AwEEFAQeBCAEJQRHAEphSAA7gNAA0EBjAHUAdABlADuAyQDJQIABYWl5ALYDuQO+A/Ihb24aYXIAYwA7gMoAykAtZG8AdAAWYXIAAOA12AjdcgBhAHYAZQA7gMgAyEDlIm1lbnQAoAgiAAFhcNYD2QNjAHIAEmF0AHkAUwLhAwAAAADpA20lYWxsU3F1YXJlAACg+yVlJ3J5U21hbGxTcXVhcmUAAKCrJQABZ3D2A/kDbwBuABhhZgAA4DXYPN3zImlsb26VY3UAAAFhaQYEDgRsAFSgdSppImxkZQAAoEIi7CNpYnJpdW0AoMwhAAFjaRgEGwRyAACgMCFtAACgcyphAJdjbQBsADuAywDLQAABaXApBC0E8yF0cwCgAyLvJG5lbnRpYWxFAKBHIYACY2Zpb3MAPQQ/BEMEXQRyBHkAJGRyAADgNdgJ3WwibGVkAFMCTAQAAAAAVARtJWFsbFNxdWFyZQAAoPwlZSdyeVNtYWxsU3F1YXJlAACgqiVwA2UEAABpBAAAAABtBGYAAOA12D3dwSFsbACgACLyI2llcnRyZgCgMSFjAPIAcQQABkpUYWJjZGZnb3JzdIgEiwSOBJMElwSkBKcEqwStBLIE5QTqBGMAeQADZDuAPgA+QO0hbWFkoJMD3GNyImV2ZQAeYYABZWl5AJ0EoASjBOQhaWwiYXIAYwAcYRNkbwB0ACBhcgAA4DXYCt0AoNkicABmAADgNdg+3eUiYXRlcgADRUZHTFNUvwTIBM8E1QTZBOAEcSJ1YWwATKBlIuUhc3MAoNsidSRsbEVxdWFsAACgZyJyI2VhdGVyAACgoirlIXNzAKB3IuwkYW50RXF1YWwAoH4qaSJsZGUAAKBzImMAcgAA4DXYotwAoGsiAARBYWNmaW9zdfkE/QQFBQgFCwUTBSIFKwVSIkRjeQAqZAABY3QBBQQFZQBrAMdiXmDpIXJjJGFyAACgDCFsJWJlcnRTcGFjZQAAoAsh8AEYBQAAGwVmAACgDSHpJXpvbnRhbExpbmUAoAAlAAFjdCYFKAXyABIF8iFvayZhbQBwAEQBMQU5BW8AdwBuAEgAdQBtAPAAAAFxInVhbAAAoE8iAAdFSk9hY2RmZ21ub3N0dVMFVgVZBVwFYwVtBXAFcwV6BZAFtgXFBckFzQVjAHkAFWTsIWlnMmFjAHkAAWRjAHUAdABlADuAzQDNQAABaXlnBWwFcgBjADuAzgDOQBhkbwB0ADBhcgAAoBEhcgBhAHYAZQA7gMwAzEAAoREhYXB/BYsFAAFjZ4MFhQVyACphaSNuYXJ5SQAAoEghbABpAGUA8wD6AvQBlQUAAKUFZaAsIgABZ3KaBZ4F8iFhbACgKyLzI2VjdGlvbgCgwiJpI3NpYmxlAAABQ1SsBbEFbyJtbWEAAKBjIGkibWVzAACgYiCAAWdwdAC8Bb8FwwVvAG4ALmFmAADgNdhA3WEAmWNjAHIAAKAQIWkibGRlAChh6wHSBQAA1QVjAHkABmRsADuAzwDPQIACY2Zvc3UA4QXpBe0F8gX9BQABaXnlBegFcgBjADRhGWRyAADgNdgN3XAAZgAA4DXYQd3jAfcFAAD7BXIAAOA12KXc8iFjeQhk6yFjeQRkgANISmFjZm9zAAwGDwYSBhUGHQYhBiYGYwB5ACVkYwB5AAxk8CFwYZpjAAFleRkGHAbkIWlsNmEaZHIAAOA12A7dcABmAADgNdhC3WMAcgAA4DXYptyABUpUYWNlZmxtb3N0AD0GQAZDBl4GawZkB2gHcAd0B80H2gdjAHkACWQ7gDwAPECAAmNtbnByAEwGTwZSBlUGWwb1IXRlOWHiIWRhm2NnAACg6ifsI2FjZXRyZgCgEiFyAACgniGAAWFleQBkBmcGagbyIW9uPWHkIWlsO2EbZAABZnNvBjQHdAAABUFDREZSVFVWYXKABp4GpAbGBssG3AYDByEHwQIqBwABbnKEBowGZyVsZUJyYWNrZXQAAKDoJ/Ihb3cAoZAhQlKTBpcGYQByAACg5CHpJGdodEFycm93AKDGIWUjaWxpbmcAAKAII28A9QGqBgAAsgZiJWxlQnJhY2tldAAAoOYnbgDUAbcGAAC+BmUkZVZlY3RvcgAAoGEp5SJjdG9yQqDDIWEAcgAAoFkpbCJvb3IAAKAKI2kiZ2h0AAABQVbSBtcGciJyb3cAAKCUIeUiY3RvcgCgTikAAWVy4AbwBmUAAKGjIkFW5gbrBnIicm93AACgpCHlImN0b3IAoFopaSNhbmdsZQBCorIi+wYAAAAA/wZhAHIAAKDPKXEidWFsAACgtCJwAIABRFRWAAoHEQcYB+8kd25WZWN0b3IAoFEpZSRlVmVjdG9yAACgYCnlImN0b3JCoL8hYQByAACgWCnlImN0b3JCoLwhYQByAACgUilpAGcAaAB0AGEAcgByAG8A9wDMAnMAAANFRkdMU1Q/B0cHTgdUB1gHXwfxJXVhbEdyZWF0ZXIAoNoidSRsbEVxdWFsAACgZiJyI2VhdGVyAACgdiLlIXNzAKChKuwkYW50RXF1YWwAoH0qaSJsZGUAAKByInIAAOA12A/dZaDYIuYjdGFycm93AKDaIWkiZG90AD9hgAFucHcAege1B7kHZwAAAkxSbHKCB5QHmwerB+UhZnQAAUFSiAeNB3Iicm93AACg9SfpJGdodEFycm93AKD3J+kkZ2h0QXJyb3cAoPYn5SFmdAABYXLcAqEHaQBnAGgAdABhAHIAcgBvAPcA5wJpAGcAaAB0AGEAcgByAG8A9wDuAmYAAOA12EPdZQByAAABTFK/B8YHZSRmdEFycm93AACgmSHpJGdodEFycm93AKCYIYABY2h0ANMH1QfXB/IAWgYAoLAh8iFva0FhAKBqIgAEYWNlZmlvc3XpB+wH7gf/BwMICQgOCBEIcAAAoAUpeQAcZAABZGzyB/kHaSR1bVNwYWNlAACgXyBsI2ludHJmAACgMyFyAADgNdgQ3e4jdXNQbHVzAKATInAAZgAA4DXYRN1jAPIA/gecY4AESmFjZWZvc3R1ACEIJAgoCDUIgQiFCDsKQApHCmMAeQAKZGMidXRlAENhgAFhZXkALggxCDQI8iFvbkdh5CFpbEVhHWSAAWdzdwA7CGEIfQjhInRpdmWAAU1UVgBECEwIWQhlJWRpdW1TcGFjZQAAoAsgaABpAAABY25SCFMIawBTAHAAYQBjAOUASwhlAHIAeQBUAGgAaQDuAFQI9CFlZAABR0xnCHUIcgBlAGEAdABlAHIARwByAGUAYQB0AGUA8gDrBGUAcwBzAEwAZQBzAPMA2wdMImluZQAKYHIAAOA12BHdAAJCbnB0jAiRCJkInAhyImVhawAAoGAgwiZyZWFraW5nU3BhY2WgYGYAAKAVIUOq7CqzCMIIzQgAAOcIGwkAAAAAAAAtCQAAbwkAAIcJAACdCcAJGQoAADQKAAFvdbYIvAjuI2dydWVudACgYiJwIkNhcAAAoG0ibyh1YmxlVmVydGljYWxCYXIAAKAmIoABbHF4ANII1wjhCOUibWVudACgCSL1IWFsVKBgImkibGRlAADgQiI4A2kic3RzAACgBCJyI2VhdGVyAACjbyJFRkdMU1T1CPoIAgkJCQ0JFQlxInVhbAAAoHEidSRsbEVxdWFsAADgZyI4A3IjZWF0ZXIAAOBrIjgD5SFzcwCgeSLsJGFudEVxdWFsAOB+KjgDaSJsZGUAAKB1IvUhbXBEASAJJwnvI3duSHVtcADgTiI4A3EidWFsAADgTyI4A2UAAAFmczEJRgn0JFRyaWFuZ2xlQqLqIj0JAAAAAEIJYQByAADgzyk4A3EidWFsAACg7CJzAICibiJFR0xTVABRCVYJXAlhCWkJcSJ1YWwAAKBwInIjZWF0ZXIAAKB4IuUhc3MA4GoiOAPsJGFudEVxdWFsAOB9KjgDaSJsZGUAAKB0IuUic3RlZAABR0x1CX8J8iZlYXRlckdyZWF0ZXIA4KIqOAPlI3NzTGVzcwDgoSo4A/IjZWNlZGVzAKGAIkVTjwmVCXEidWFsAADgryo4A+wkYW50RXF1YWwAoOAiAAFlaaAJqQl2JmVyc2VFbGVtZW50AACgDCLnJWh0VHJpYW5nbGVCousitgkAAAAAuwlhAHIAAODQKTgDcSJ1YWwAAKDtIgABcXXDCeAJdSNhcmVTdQAAAWJwywnVCfMhZXRF4I8iOANxInVhbAAAoOIi5SJyc2V0ReCQIjgDcSJ1YWwAAKDjIoABYmNwAOYJ8AkNCvMhZXRF4IIi0iBxInVhbAAAoIgi4yJlZWRzgKGBIkVTVAD6CQAKBwpxInVhbAAA4LAqOAPsJGFudEVxdWFsAKDhImkibGRlAADgfyI4A+UicnNldEXggyLSIHEidWFsAACgiSJpImxkZQCAoUEiRUZUACIKJwouCnEidWFsAACgRCJ1JGxsRXF1YWwAAKBHImkibGRlAACgSSJlJXJ0aWNhbEJhcgAAoCQiYwByAADgNdip3GkAbABkAGUAO4DRANFAnWMAB0VhY2RmZ21vcHJzdHV2XgphCmgKcgp2CnoKgQqRCpYKqwqtCrsKyArNCuwhaWdSYWMAdQB0AGUAO4DTANNAAAFpeWwKcQpyAGMAO4DUANRAHmRiImxhYwBQYXIAAOA12BLdcgBhAHYAZQA7gNIA0kCAAWFlaQCHCooKjQpjAHIATGFnAGEAqWNjInJvbgCfY3AAZgAA4DXYRt3lI25DdXJseQABRFGeCqYKbyV1YmxlUXVvdGUAAKAcIHUib3RlAACgGCAAoFQqAAFjbLEKtQpyAADgNdiq3GEAcwBoADuA2ADYQGkAbAHACsUKZABlADuA1QDVQGUAcwAAoDcqbQBsADuA1gDWQGUAcgAAAUJQ0wrmCgABYXLXCtoKcgAAoD4gYQBjAAABZWvgCuIKAKDeI2UAdAAAoLQjYSVyZW50aGVzaXMAAKDcI4AEYWNmaGlsb3JzAP0KAwsFCwkLCwsMCxELIwtaC3IjdGlhbEQAAKACInkAH2RyAADgNdgT3WkApmOgY/Ujc01pbnVzsWAAAWlwFQsgC24AYwBhAHIAZQBwAGwAYQBuAOUACgVmAACgGSGAobsqZWlvACoLRQtJC+MiZWRlc4CheiJFU1QANAs5C0ALcSJ1YWwAAKCvKuwkYW50RXF1YWwAoHwiaSJsZGUAAKB+Im0AZQAAoDMgAAFkcE0LUQv1IWN0AKAPIm8jcnRpb24AYaA3ImwAAKAdIgABY2leC2ILcgAA4DXYq9yoYwACVWZvc2oLbwtzC3cLTwBUADuAIgAiQHIAAOA12BTdcABmAACgGiFjAHIAAOA12KzcAAZCRWFjZWZoaW9yc3WPC5MLlwupC7YL2AvbC90LhQyTDJoMowzhIXJyAKAQKUcAO4CuAK5AgAFjbnIAnQugC6ML9SF0ZVRhZwAAoOsncgB0oKAhbAAAoBYpgAFhZXkArwuyC7UL8iFvblhh5CFpbFZhIGR2oBwhZSJyc2UAAAFFVb8LzwsAAWxxwwvIC+UibWVudACgCyL1JGlsaWJyaXVtAKDLIXAmRXF1aWxpYnJpdW0AAKBvKXIAAKAcIW8AoWPnIWh0AARBQ0RGVFVWYewLCgwQDDIMNwxeDHwM9gIAAW5y8Av4C2clbGVCcmFja2V0AACg6SfyIW93AKGSIUJM/wsDDGEAcgAAoOUhZSRmdEFycm93AACgxCFlI2lsaW5nAACgCSNvAPUBFgwAAB4MYiVsZUJyYWNrZXQAAKDnJ24A1AEjDAAAKgxlJGVWZWN0b3IAAKBdKeUiY3RvckKgwiFhAHIAAKBVKWwib29yAACgCyMAAWVyOwxLDGUAAKGiIkFWQQxGDHIicm93AACgpiHlImN0b3IAoFspaSNhbmdsZQBCorMiVgwAAAAAWgxhAHIAAKDQKXEidWFsAACgtSJwAIABRFRWAGUMbAxzDO8kd25WZWN0b3IAoE8pZSRlVmVjdG9yAACgXCnlImN0b3JCoL4hYQByAACgVCnlImN0b3JCoMAhYQByAACgUykAAXB1iQyMDGYAAKAdIe4kZEltcGxpZXMAoHAp6SRnaHRhcnJvdwCg2yEAAWNongyhDHIAAKAbIQCgsSHsJGVEZWxheWVkAKD0KYAGSE9hY2ZoaW1vcXN0dQC/DMgMzAzQDOIM5gwKDQ0NFA0ZDU8NVA1YDQABQ2PDDMYMyCFjeSlkeQAoZEYiVGN5ACxkYyJ1dGUAWmEAorwqYWVpedgM2wzeDOEM8iFvbmBh5CFpbF5hcgBjAFxhIWRyAADgNdgW3e8hcnQAAkRMUlXvDPYM/QwEDW8kd25BcnJvdwAAoJMhZSRmdEFycm93AACgkCHpJGdodEFycm93AKCSIXAjQXJyb3cAAKCRIechbWGjY+EkbGxDaXJjbGUAoBgicABmAADgNdhK3XICHw0AAAAAIg10AACgGiLhIXJlgKGhJUlTVQAqDTINSg3uJXRlcnNlY3Rpb24AoJMidQAAAWJwNw1ADfMhZXRFoI8icSJ1YWwAAKCRIuUicnNldEWgkCJxInVhbAAAoJIibiJpb24AAKCUImMAcgAA4DXYrtxhAHIAAKDGIgACYmNtcF8Nag2ODZANc6DQImUAdABFoNAicSJ1YWwAAKCGIgABY2huDYkNZSJlZHMAgKF7IkVTVAB4DX0NhA1xInVhbAAAoLAq7CRhbnRFcXVhbACgfSJpImxkZQAAoH8iVABoAGEA9ADHCwCgESIAodEiZXOVDZ8NciJzZXQARaCDInEidWFsAACghyJlAHQAAKDRIoAFSFJTYWNmaGlvcnMAtQ27Db8NyA3ODdsN3w3+DRgOHQ4jDk8AUgBOADuA3gDeQMEhREUAoCIhAAFIY8MNxg1jAHkAC2R5ACZkAAFidcwNzQ0JYKRjgAFhZXkA1A3XDdoN8iFvbmRh5CFpbGJhImRyAADgNdgX3QABZWnjDe4N8gHoDQAA7Q3lImZvcmUAoDQiYQCYYwABY27yDfkNayNTcGFjZQAA4F8gCiDTInBhY2UAoAkg7CFkZYChPCJFRlQABw4MDhMOcSJ1YWwAAKBDInUkbGxFcXVhbAAAoEUiaSJsZGUAAKBIInAAZgAA4DXYS93pI3BsZURvdACg2yAAAWN0Jw4rDnIAAOA12K/c8iFva2Zh4QpFDlYOYA5qDgAAbg5yDgAAAAAAAAAAAAB5DnwOqA6zDgAADg8RDxYPGg8AAWNySA5ODnUAdABlADuA2gDaQHIAb6CfIeMhaXIAoEkpcgDjAVsOAABdDnkADmR2AGUAbGEAAWl5Yw5oDnIAYwA7gNsA20AjZGIibGFjAHBhcgAA4DXYGN1yAGEAdgBlADuA2QDZQOEhY3JqYQABZGl/Dp8OZQByAAABQlCFDpcOAAFhcokOiw5yAF9gYQBjAAABZWuRDpMOAKDfI2UAdAAAoLUjYSVyZW50aGVzaXMAAKDdI28AbgBQoMMi7CF1cwCgjiIAAWdwqw6uDm8AbgByYWYAAOA12EzdAARBREVUYWRwc78O0g7ZDuEOBQPqDvMOBw9yInJvdwDCoZEhyA4AAMwOYQByAACgEilvJHduQXJyb3cAAKDFIW8kd25BcnJvdwAAoJUhcSV1aWxpYnJpdW0AAKBuKWUAZQBBoKUiciJyb3cAAKClIW8AdwBuAGEAcgByAG8A9wAQA2UAcgAAAUxS+Q4AD2UkZnRBcnJvdwAAoJYh6SRnaHRBcnJvdwCglyFpAGyg0gNvAG4ApWPpIW5nbmFjAHIAAOA12LDcaSJsZGUAaGFtAGwAO4DcANxAgAREYmNkZWZvc3YALQ8xDzUPNw89D3IPdg97D4AP4SFzaACgqyJhAHIAAKDrKnkAEmThIXNobKCpIgCg5ioAAWVyQQ9DDwCgwSKAAWJ0eQBJD00Paw9hAHIAAKAWIGmgFiDjIWFsAAJCTFNUWA9cD18PZg9hAHIAAKAjIukhbmV8YGUkcGFyYXRvcgAAoFgnaSJsZGUAAKBAItQkaGluU3BhY2UAoAogcgAA4DXYGd1wAGYAAOA12E3dYwByAADgNdix3GQiYXNoAACgqiKAAmNlZm9zAI4PkQ+VD5kPng/pIXJjdGHkIWdlAKDAInIAAOA12BrdcABmAADgNdhO3WMAcgAA4DXYstwAAmZpb3OqD64Prw+0D3IAAOA12BvdnmNwAGYAAOA12E/dYwByAADgNdiz3IAEQUlVYWNmb3N1AMgPyw/OD9EP2A/gD+QP6Q/uD2MAeQAvZGMAeQAHZGMAeQAuZGMAdQB0AGUAO4DdAN1AAAFpedwP3w9yAGMAdmErZHIAAOA12BzdcABmAADgNdhQ3WMAcgAA4DXYtNxtAGwAeGEABEhhY2RlZm9z/g8BEAUQDRAQEB0QIBAkEGMAeQAWZGMidXRlAHlhAAFheQkQDBDyIW9ufWEXZG8AdAB7YfIBFRAAABwQbwBXAGkAZAB0AOgAVAhhAJZjcgAAoCghcABmAACgJCFjAHIAAOA12LXc4QtCEEkQTRAAAGcQbRByEAAAAAAAAAAAeRCKEJcQ8hD9EAAAGxEhETIROREAAD4RYwB1AHQAZQA7gOEA4UByImV2ZQADYYCiPiJFZGl1eQBWEFkQWxBgEGUQAOA+IjMDAKA/InIAYwA7gOIA4kB0AGUAO4C0ALRAMGRsAGkAZwA7gOYA5kByoGEgAOA12B7dcgBhAHYAZQA7gOAA4EAAAWVwfBCGEAABZnCAEIQQ8yF5bQCgNSHoAIMQaABhALFjAAFhcI0QWwAAAWNskRCTEHIAAWFnAACgPypkApwQAAAAALEQAKInImFkc3ajEKcQqRCuEG4AZAAAoFUqAKBcKmwib3BlAACgWCoAoFoqAKMgImVsbXJzersQvRDAEN0Q5RDtEACgpCllAACgICJzAGQAYaAhImEEzhDQENIQ1BDWENgQ2hDcEACgqCkAoKkpAKCqKQCgqykAoKwpAKCtKQCgrikAoK8pdAB2oB8iYgBkoL4iAKCdKQABcHTpEOwQaAAAoCIixWDhIXJyAKB8IwABZ3D1EPgQbwBuAAVhZgAA4DXYUt0Ao0giRWFlaW9wBxEJEQ0RDxESERQRAKBwKuMhaXIAoG8qAKBKImQAAKBLInMAJ2DyIW94ZaBIIvEADhFpAG4AZwA7gOUA5UCAAWN0eQAmESoRKxFyAADgNdi23CpgbQBwAGWgSCLxAPgBaQBsAGQAZQA7gOMA40BtAGwAO4DkAORAAAFjaUERRxFvAG4AaQBuAPQA6AFuAHQAAKARKgAITmFiY2RlZmlrbG5vcHJzdWQRaBGXEZ8RpxGrEdIR1hErEjASexKKEn0RThNbE3oTbwB0AACg7SoAAWNybBGJEWsAAAJjZXBzdBF4EX0RghHvIW5nAKBMInAjc2lsb24A9mNyImltZQAAoDUgaQBtAGWgPSJxAACgzSJ2AY0RkRFlAGUAAKC9ImUAZABnoAUjZQAAoAUjcgBrAHSgtSPiIXJrAKC2IwABb3mjEaYRbgDnAHcRMWTxIXVvAKAeIIACY21wcnQAtBG5Eb4RwRHFEeEhdXPloDUi5ABwInR5dgAAoLApcwDpAH0RbgBvAPUA6gCAAWFodwDLEcwRzhGyYwCgNiHlIWVuAKBsInIAAOA12B/dZwCAA2Nvc3R1dncA4xHyEQUSEhIhEiYSKRKAAWFpdQDpEesR7xHwAKMFcgBjAACg7yVwAACgwyKAAWRwdAD4EfwRABJvAHQAAKAAKuwhdXMAoAEqaSJtZXMAAKACKnECCxIAAAAADxLjIXVwAKAGKmEAcgAAoAUm8iNpYW5nbGUAAWR1GhIeEu8hd24AoL0lcAAAoLMlcCJsdXMAAKAEKmUA5QBCD+UAkg9hInJvdwAAoA0pgAFha28ANhJoEncSAAFjbjoSZRJrAIABbHN0AEESRxJNEm8jemVuZ2UAAKDrKXEAdQBhAHIA5QBcBPIjaWFuZ2xlgKG0JWRscgBYElwSYBLvIXduAKC+JeUhZnQAoMIlaSJnaHQAAKC4JWsAAKAjJLEBbRIAAHUSsgFxEgAAcxIAoJIlAKCRJTQAAKCTJWMAawAAoIglAAFlb38ShxJx4D0A5SD1IWl2AOBhIuUgdAAAoBAjAAJwdHd4kRKVEpsSnxJmAADgNdhT3XSgpSJvAG0AAKClIvQhaWUAoMgiAAZESFVWYmRobXB0dXayEsES0RLgEvcS+xIKExoTHxMjEygTNxMAAkxSbHK5ErsSvRK/EgCgVyUAoFQlAKBWJQCgUyUAolAlRFVkdckSyxLNEs8SAKBmJQCgaSUAoGQlAKBnJQACTFJsctgS2hLcEt4SAKBdJQCgWiUAoFwlAKBZJQCjUSVITFJobHLrEu0S7xLxEvMS9RIAoGwlAKBjJQCgYCUAoGslAKBiJQCgXyVvAHgAAKDJKQACTFJscgITBBMGEwgTAKBVJQCgUiUAoBAlAKAMJQCiACVEVWR1EhMUExYTGBMAoGUlAKBoJQCgLCUAoDQlaSJudXMAAKCfIuwhdXMAoJ4iaSJtZXMAAKCgIgACTFJsci8TMRMzEzUTAKBbJQCgWCUAoBglAKAUJQCjAiVITFJobHJCE0QTRhNIE0oTTBMAoGolAKBhJQCgXiUAoDwlAKAkJQCgHCUAAWV2UhNVE3YA5QD5AGIAYQByADuApgCmQAACY2Vpb2ITZhNqE24TcgAA4DXYt9xtAGkAAKBPIG0A5aA9IogRbAAAoVwAYmh0E3YTAKDFKfMhdWIAoMgnbAF+E4QTbABloCIgdAAAoCIgcAAAoU4iRWWJE4sTAKCuKvGgTyI8BeEMqRMAAN8TABQDFB8UAAAjFDQUAAAAAIUUAAAAAI0UAAAAANcU4xT3FPsUAACIFQAAlhWAAWNwcgCuE7ET1RP1IXRlB2GAoikiYWJjZHMAuxO/E8QTzhPSE24AZAAAoEQqciJjdXAAAKBJKgABYXXIE8sTcAAAoEsqcAAAoEcqbwB0AACgQCoA4CkiAP4AAWVv2RPcE3QAAKBBIO4ABAUAAmFlaXXlE+8T9RP4E/AB6hMAAO0TcwAAoE0qbwBuAA1hZABpAGwAO4DnAOdAcgBjAAlhcABzAHOgTCptAACgUCpvAHQAC2GAAWRtbgAIFA0UEhRpAGwAO4C4ALhAcCJ0eXYAAKCyKXQAAIGiADtlGBQZFKJAcgBkAG8A9ABiAXIAAOA12CDdgAFjZWkAKBQqFDIUeQBHZGMAawBtoBMn4SFyawCgEyfHY3IAAKPLJUVjZWZtcz8UQRRHFHcUfBSAFACgwykAocYCZWxGFEkUcQAAoFciZQBhAlAUAAAAAGAUciJyb3cAAAFsclYUWhTlIWZ0AKC6IWkiZ2h0AACguyGAAlJTYWNkAGgUaRRrFG8UcxSuYACgyCRzAHQAAKCbIukhcmMAoJoi4SFzaACgnSJuImludAAAoBAqaQBkAACg7yrjIWlyAKDCKfUhYnN1oGMmaQB0AACgYybsApMUmhS2FAAAwxRvAG4AZaA6APGgVCKrAG0CnxQAAAAAoxRhAHSgLABAYAChASJmbKcUqRTuABMNZQAAAW14rhSyFOUhbnQAoAEiZQDzANIB5wG6FAAAwBRkoEUibwB0AACgbSpuAPQAzAGAAWZyeQDIFMsUzhQA4DXYVN1vAOQA1wEAgakAO3MeAdMUcgAAoBchAAFhb9oU3hRyAHIAAKC1IXMAcwAAoBcnAAFjdeYU6hRyAADgNdi43AABYnDuFPIUZaDPKgCg0SploNAqAKDSKuQhb3QAoO8igANkZWxwcnZ3AAYVEBUbFSEVRBVlFYQV4SFycgABbHIMFQ4VAKA4KQCgNSlwAhYVAAAAABkVcgAAoN4iYwAAoN8i4SFycnCgtiEAoD0pgKIqImJjZG9zACsVMBU6FT4VQRVyImNhcAAAoEgqAAFhdTQVNxVwAACgRipwAACgSipvAHQAAKCNInIAAKBFKgDgKiIA/gACYWxydksVURVuFXMVcgByAG2gtyEAoDwpeQCAAWV2dwBYFWUVaRVxAHACXxUAAAAAYxVyAGUA4wAXFXUA4wAZFWUAZQAAoM4iZSJkZ2UAAKDPImUAbgA7gKQApEBlI2Fycm93AAABbHJ7FX8V5SFmdACgtiFpImdodAAAoLchZQDkAG0VAAFjaYsVkRVvAG4AaQBuAPQAkwFuAHQAAKAxImwiY3R5AACgLSOACUFIYWJjZGVmaGlqbG9yc3R1d3oAuBW7Fb8V1RXgFegV+RUKFhUWHxZUFlcWZRbFFtsW7xb7FgUXChdyAPIAtAJhAHIAAKBlKQACZ2xyc8YVyhXOFdAV5yFlcgCgICDlIXRoAKA4IfIA9QxoAHagECAAoKMiawHZFd4VYSJyb3cAAKAPKWEA4wBfAgABYXnkFecV8iFvbg9hNGQAoUYhYW/tFfQVAAFnciEC8RVyAACgyiF0InNlcQAAoHcqgAFnbG0A/xUCFgUWO4CwALBAdABhALRjcCJ0eXYAAKCxKQABaXIOFhIW8yFodACgfykA4DXYId1hAHIAAAFschsWHRYAoMMhAKDCIYACYWVnc3YAKBauAjYWOhY+Fm0AAKHEIm9zLhY0Fm4AZABzoMQi9SFpdACgZiZhIm1tYQDdY2kAbgAAoPIiAKH3AGlvQxZRFmQAZQAAgfcAO29KFksW90BuI3RpbWVzAACgxyJuAPgAUBZjAHkAUmRjAG8CXhYAAAAAYhZyAG4AAKAeI28AcAAAoA0jgAJscHR1dwBuFnEWdRaSFp4W7CFhciRgZgAA4DXYVd0AotkCZW1wc30WhBaJFo0WcQBkoFAibwB0AACgUSJpIm51cwAAoDgi7CF1cwCgFCLxInVhcmUAoKEiYgBsAGUAYgBhAHIAdwBlAGQAZwDlANcAbgCAAWFkaAClFqoWtBZyAHIAbwD3APUMbwB3AG4AYQByAHIAbwB3APMA8xVhI3Jwb29uAAABbHK8FsAWZQBmAPQAHBZpAGcAaAD0AB4WYgHJFs8WawBhAHIAbwD3AJILbwLUFgAAAADYFnIAbgAAoB8jbwBwAACgDCOAAWNvdADhFukW7BYAAXJ55RboFgDgNdi53FVkbAAAoPYp8iFvaxFhAAFkcvMW9xZvAHQAAKDxImkA5qC/JVsSAAFhaP8WAhdyAPIANQNhAPIA1wvhIm5nbGUAoKYpAAFjaQ4XEBd5AF9k5yJyYXJyAKD/JwAJRGFjZGVmZ2xtbm9wcXJzdHV4MRc4F0YXWxcyBF4XaRd5F40XrBe0F78X2RcVGCEYLRg1GEAYAAFEbzUXgRZvAPQA+BUAAWNzPBdCF3UAdABlADuA6QDpQPQhZXIAoG4qAAJhaW95TRdQF1YXWhfyIW9uG2FyAGOgViI7gOoA6kDsIW9uAKBVIk1kbwB0ABdhAAFEcmIXZhdvAHQAAKBSIgDgNdgi3XKhmipuF3QXYQB2AGUAO4DoAOhAZKCWKm8AdAAAoJgqgKGZKmlscwCAF4UXhxfuInRlcnMAoOcjAKATIWSglSpvAHQAAKCXKoABYXBzAJMXlheiF2MAcgATYXQAeQBzogUinxcAAAAAoRdlAHQAAKAFInAAMaADIDMBqRerFwCgBCAAoAUgAAFnc7AXsRdLYXAAAKACIAABZ3C4F7sXbwBuABlhZgAA4DXYVt2AAWFscwDFF8sXzxdyAHOg1SJsAACg4yl1AHMAAKBxKmkAAKG1A2x21RfYF28AbgC1Y/VjAAJjc3V24BfoF/0XEBgAAWlv5BdWF3IAYwAAoFYiaQLuFwAAAADwF+0ADQThIW50AAFnbPUX+Rd0AHIAAKCWKuUhc3MAoJUqgAFhZWkAAxgGGAoYbABzAD1gcwB0AACgXyJ2AESgYSJEAACgeCrwImFyc2wAoOUpAAFEYRkYHRhvAHQAAKBTInIAcgAAoHEpgAFjZGkAJxgqGO0XcgAAoC8hbwD0AIwCAAFhaDEYMhi3YzuA8ADwQAABbXI5GD0YbAA7gOsA60BvAACgrCCAAWNpcABGGEgYSxhsACFgcwD0ACwEAAFlb08YVxhjAHQAYQB0AGkAbwDuABoEbgBlAG4AdABpAGEAbADlADME4Ql1GAAAgRgAAIMYiBgAAAAAoRilGAAAqhgAALsYvhjRGAAA1xgnGWwAbABpAG4AZwBkAG8AdABzAGUA8QBlF3kARGRtImFsZQAAoEAmgAFpbHIAjRiRGJ0Y7CFpZwCgA/tpApcYAAAAAJoYZwAAoAD7aQBnAACgBPsA4DXYI93sIWlnAKAB++whaWcA4GYAagCAAWFsdACvGLIYthh0AACgbSZpAGcAAKAC+24AcwAAoLElbwBmAJJh8AHCGAAAxhhmAADgNdhX3QABYWvJGMwYbADsAGsEdqDUIgCg2SphI3J0aW50AACgDSoAAWFv2hgiGQABY3PeGB8ZsQPnGP0YBRkSGRUZAAAdGbID7xjyGPQY9xj5GAAA+xg7gL0AvUAAoFMhO4C8ALxAAKBVIQCgWSEAoFshswEBGQAAAxkAoFQhAKBWIbQCCxkOGQAAAAAQGTuAvgC+QACgVyEAoFwhNQAAoFghtgEZGQAAGxkAoFohAKBdITgAAKBeIWwAAKBEIHcAbgAAoCIjYwByAADgNdi73IAIRWFiY2RlZmdpamxub3JzdHYARhlKGVoZXhlmGWkZkhmWGZkZnRmgGa0ZxhnLGc8Z4BkjGmygZyIAoIwqgAFjbXAAUBlTGVgZ9SF0ZfVhbQBhAOSgswM6FgCghipyImV2ZQAfYQABaXliGWUZcgBjAB1hM2RvAHQAIWGAoWUibHFzAMYEcBl6GfGhZSLOBAAAdhlsAGEAbgD0AN8EgKF+KmNkbACBGYQZjBljAACgqSpvAHQAb6CAKmyggioAoIQqZeDbIgD+cwAAoJQqcgAA4DXYJN3noGsirATtIWVsAKA3IWMAeQBTZIChdyJFYWoApxmpGasZAKCSKgCgpSoAoKQqAAJFYWVztBm2Gb0ZwhkAoGkicABwoIoq8iFveACgiipxoIgq8aCIKrUZaQBtAACg5yJwAGYAAOA12FjdYQB2AOUAYwIAAWNp0xnWGXIAAKAKIW0AAKFzImVs3BneGQCgjioAoJAqAIM+ADtjZGxxco0E6xn0GfgZ/BkBGgABY2nvGfEZAKCnKnIAAKB6Km8AdAAAoNci0CFhcgCglSl1ImVzdAAAoHwqgAJhZGVscwAKGvQZFhrVBCAa8AEPGgAAFBpwAHIAbwD4AFkZcgAAoHgpcQAAAWxxxAQbGmwAZQBzAPMASRlpAO0A5AQAAWVuJxouGnIjdG5lcXEAAOBpIgD+xQAsGgAFQWFiY2Vma29zeUAaQxpmGmoabRqDGocalhrCGtMacgDyAMwCAAJpbG1yShpOGlAaVBpyAHMA8ABxD2YAvWBpAGwA9AASBQABZHJYGlsaYwB5AEpkAKGUIWN3YBpkGmkAcgAAoEgpAKCtIWEAcgAAoA8h6SFyYyVhgAFhbHIAcxp7Gn8a8iF0c3WgZSZpAHQAAKBlJuwhaXAAoCYg4yFvbgCguSJyAADgNdgl3XMAAAFld4wakRphInJvdwAAoCUpYSJyb3cAAKAmKYACYW1vcHIAnxqjGqcauhq+GnIAcgAAoP8h9CFodACgOyJrAAABbHKsGrMaZSRmdGFycm93AACgqSHpJGdodGFycm93AKCqIWYAAOA12Fnd4iFhcgCgFSCAAWNsdADIGswa0BpyAADgNdi93GEAcwDoAGka8iFvaydhAAFicNca2xr1IWxsAKBDIOghZW4AoBAg4Qr2GgAA/RoAAAgbExsaGwAAIRs7GwAAAAA+G2IbmRuVG6sbAACyG80b0htjAHUAdABlADuA7QDtQAChYyBpeQEbBhtyAGMAO4DuAO5AOGQAAWN4CxsNG3kANWRjAGwAO4ChAKFAAAFmcssCFhsA4DXYJt1yAGEAdgBlADuA7ADsQIChSCFpbm8AJxsyGzYbAAFpbisbLxtuAHQAAKAMKnQAAKAtIuYhaW4AoNwpdABhAACgKSHsIWlnM2GAAWFvcABDG1sbXhuAAWNndABJG0sbWRtyACthgAFlbHAAcQVRG1UbaQBuAOUAyAVhAHIA9AByBWgAMWFmAACgtyJlAGQAtWEAoggiY2ZvdGkbbRt1G3kb4SFyZQCgBSFpAG4AdKAeImkAZQAAoN0pZABvAPQAWxsAoisiY2VscIEbhRuPG5QbYQBsAACguiIAAWdyiRuNG2UAcgDzACMQ4wCCG2EicmhrAACgFyryIW9kAKA8KgACY2dwdJ8boRukG6gbeQBRZG8AbgAvYWYAAOA12FrdYQC5Y3UAZQBzAHQAO4C/AL9AAAFjabUbuRtyAADgNdi+3G4AAKIIIkVkc3bCG8QbyBvQAwCg+SJvAHQAAKD1Inag9CIAoPMiaaBiIOwhZGUpYesB1hsAANkbYwB5AFZkbAA7gO8A70AAA2NmbW9zdeYb7hvyG/Ub+hsFHAABaXnqG+0bcgBjADVhOWRyAADgNdgn3eEhdGg3YnAAZgAA4DXYW93jAf8bAAADHHIAAOA12L/c8iFjeVhk6yFjeVRkAARhY2ZnaGpvcxUcGhwiHCYcKhwtHDAcNRzwIXBhdqC6A/BjAAFleR4cIRzkIWlsN2E6ZHIAAOA12CjdciJlZW4AOGFjAHkARWRjAHkAXGRwAGYAAOA12FzdYwByAADgNdjA3IALQUJFSGFiY2RlZmdoamxtbm9wcnN0dXYAXhxtHHEcdRx5HN8cBx0dHTwd3B3tHfEdAR4EHh0eLB5FHrwewx7hHgkfPR9LH4ABYXJ0AGQcZxxpHHIA8gBvB/IAxQLhIWlsAKAbKeEhcnIAoA4pZ6BmIgCgiyphAHIAAKBiKWMJjRwAAJAcAACVHAAAAAAAAAAAAACZHJwcAACmHKgcrRwAANIc9SF0ZTph7SJwdHl2AKC0KXIAYQDuAFoG4iFkYbtjZwAAoegnZGyhHKMcAKCRKeUAiwYAoIUqdQBvADuAqwCrQHIAgKOQIWJmaGxwc3QAuhy/HMIcxBzHHMoczhxmoOQhcwAAoB8pcwAAoB0p6wCyGnAAAKCrIWwAAKA5KWkAbQAAoHMpbAAAoKIhAKGrKmFl1hzaHGkAbAAAoBkpc6CtKgDgrSoA/oABYWJyAOUc6RztHHIAcgAAoAwpcgBrAACgcicAAWFr8Rz4HGMAAAFla/Yc9xx7YFtgAAFlc/wc/hwAoIspbAAAAWR1Ax0FHQCgjykAoI0pAAJhZXV5Dh0RHRodHB3yIW9uPmEAAWRpFR0YHWkAbAA8YewAowbiAPccO2QAAmNxcnMkHScdLB05HWEAAKA2KXUAbwDyoBwgqhEAAWR1MB00HeghYXIAoGcpcyJoYXIAAKBLKWgAAKCyIQCiZCJmZ3FzRB1FB5Qdnh10AIACYWhscnQATh1WHWUdbB2NHXIicm93AHSgkCFhAOkAzxxhI3Jwb29uAAABZHVeHWId7yF3bgCgvSFwAACgvCHlJGZ0YXJyb3dzAKDHIWkiZ2h0AIABYWhzAHUdex2DHXIicm93APOglCGdBmEAcgBwAG8AbwBuAPMAzgtxAHUAaQBnAGEAcgByAG8A9wBlGugkcmVldGltZXMAoMsi8aFkIk0HAACaHWwAYQBuAPQAXgcAon0qY2Rnc6YdqR2xHbcdYwAAoKgqbwB0AG+gfypyoIEqAKCDKmXg2iIA/nMAAKCTKoACYWRlZ3MAwB3GHcod1h3ZHXAAcAByAG8A+ACmHG8AdAAAoNYicQAAAWdxzx3SHXQA8gBGB2cAdADyAHQcdADyAFMHaQDtAGMHgAFpbHIA4h3mHeod8yFodACgfClvAG8A8gDKBgDgNdgp3UWgdiIAoJEqYQH1Hf4dcgAAAWR1YB35HWygvCEAoGopbABrAACghCVjAHkAWWQAomoiYWNodAweDx4VHhkecgDyAGsdbwByAG4AZQDyAGAW4SFyZACgaylyAGkAAKD6JQABaW8hHiQe5CFvdEBh9SFzdGGgsCPjIWhlAKCwIwACRWFlczMeNR48HkEeAKBoInAAcKCJKvIhb3gAoIkqcaCHKvGghyo0HmkAbQAAoOYiAARhYm5vcHR3elIeXB5fHoUelh6mHqsetB4AAW5yVh5ZHmcAAKDsJ3IAAKD9IXIA6wCwBmcAgAFsbXIAZh52Hnse5SFmdAABYXKIB2weaQBnAGgAdABhAHIAcgBvAPcAkwfhInBzdG8AoPwnaQBnAGgAdABhAHIAcgBvAPcAmgdwI2Fycm93AAABbHKNHpEeZQBmAPQAxhxpImdodAAAoKwhgAFhZmwAnB6fHqIecgAAoIUpAOA12F3ddQBzAACgLSppIm1lcwAAoDQqYQGvHrMecwB0AACgFyLhAIoOZaHKJbkeRhLuIWdlAKDKJWEAcgBsoCgAdAAAoJMpgAJhY2htdADMHs8e1R7bHt0ecgDyAJ0GbwByAG4AZQDyANYWYQByAGSgyyEAoG0pAKAOIHIAaQAAoL8iAANhY2hpcXTrHu8e1QfzHv0eBh/xIXVvAKA5IHIAAOA12MHcbQDloXIi+h4AAPweAKCNKgCgjyoAAWJ19xwBH28AcqAYIACgGiDyIW9rQmEAhDwAO2NkaGlscXJCBhcfxh0gHyQfKB8sHzEfAAFjaRsfHR8AoKYqcgAAoHkqcgBlAOUAkx3tIWVzAKDJIuEhcnIAoHYpdSJlc3QAAKB7KgABUGk1HzkfYQByAACglillocMlAgdfEnIAAAFkdUIfRx9zImhhcgAAoEop6CFhcgCgZikAAWVuTx9WH3IjdG5lcXEAAOBoIgD+xQBUHwAHRGFjZGVmaGlsbm9wc3VuH3Ifoh+rH68ftx+7H74f5h/uH/MfBwj/HwsgxCFvdACgOiIAAmNscHJ5H30fiR+eH3IAO4CvAK9AAAFldIEfgx8AoEImZaAgJ3MAZQAAoCAnc6CmIXQAbwCAoaYhZGx1AJQfmB+cH28AdwDuAHkDZQBmAPQA6gbwAOkO6yFlcgCgriUAAW95ph+qH+0hbWEAoCkqPGThIXNoAKAUIOElc3VyZWRhbmdsZQCgISJyAADgNdgq3W8AAKAnIYABY2RuAMQfyR/bH3IAbwA7gLUAtUBhoiMi0B8AANMf1x9zAPQAKxFpAHIAAKDwKm8AdAA7gLcAt0B1AHMA4qESIh4TAADjH3WgOCIAoCoqYwHqH+0fcAAAoNsq8gB+GnAAbAB1APMACAgAAWRw9x/7H+UhbHMAoKciZgAA4DXYXt0AAWN0AyAHIHIAAOA12MLc8CFvcwCgPiJsobwDECAVIPQiaW1hcACguCJhAPAAEyAADEdMUlZhYmNkZWZnaGlqbG1vcHJzdHV2dzwgRyBmIG0geSCqILgg2iDeIBEhFSEyIUMhTSFQIZwhnyHSIQAiIyKLIrEivyIUIwABZ3RAIEMgAODZIjgD9uBrItIgBwmAAWVsdABNIF8gYiBmAHQAAAFhclMgWCByInJvdwAAoM0h6SRnaHRhcnJvdwCgziEA4NgiOAP24Goi0iBfCekkZ2h0YXJyb3cAoM8hAAFEZHEgdSDhIXNoAKCvIuEhc2gAoK4igAJiY25wdACCIIYgiSCNIKIgbABhAACgByL1IXRlRGFnAADgICLSIACiSSJFaW9wlSCYIJwgniAA4HAqOANkAADgSyI4A3MASWFyAG8A+AAyCnUAcgBhoG4mbADzoG4mmwjzAa8gAACzIHAAO4CgAKBAbQBwAOXgTiI4AyoJgAJhZW91eQDBIMogzSDWINkg8AHGIAAAyCAAoEMqbwBuAEhh5CFpbEZhbgBnAGSgRyJvAHQAAOBtKjgDcAAAoEIqPWThIXNoAKATIACjYCJBYWRxc3jpIO0g+SD+IAIhDCFyAHIAAKDXIXIAAAFocvIg9SBrAACgJClvoJch9wAGD28AdAAA4FAiOAN1AGkA9gC7CAABZWkGIQohYQByAACgKCntAN8I6SFzdPOgBCLlCHIAAOA12CvdAAJFZXN0/wgcISshLiHxoXEiIiEAABMJ8aFxIgAJAAAnIWwAYQBuAPQAEwlpAO0AGQlyoG8iAKBvIoABQWFwADghOyE/IXIA8gBeIHIAcgAAoK4hYQByAACg8ipzogsiSiEAAAAAxwtkoPwiAKD6ImMAeQBaZIADQUVhZGVzdABcIV8hYiFmIWkhkyGWIXIA8gBXIADgZiI4A3IAcgAAoJohcgAAoCUggKFwImZxcwBwIYQhjiF0AAABYXJ1IXohcgByAG8A9wBlIWkAZwBoAHQAYQByAHIAbwD3AD4h8aFwImAhAACKIWwAYQBuAPQAZwlz4H0qOAMAoG4iaQDtAG0JcqBuImkA5aDqIkUJaQDkADoKAAFwdKMhpyFmAADgNdhf3YCBrAA7aW4AriGvIcchrEBuAIChCSJFZHYAtyG6Ib8hAOD5IjgDbwB0AADg9SI4A+EB1gjEIcYhAKD3IgCg9iJpAHagDCLhAagJzyHRIQCg/iIAoP0igAFhb3IA2CHsIfEhcgCAoSYiYXN0AOAh5SHpIWwAbABlAOwAywhsAADg/SrlIADgAiI4A2wiaW50AACgFCrjoYAi9yEAAPohdQDlAJsJY+CvKjgDZaCAIvEAkwkAAkFhaXQHIgoiFyIeInIA8gBsIHIAcgAAoZshY3cRIhQiAOAzKTgDAOCdITgDZyRodGFycm93AACgmyFyAGkA5aDrIr4JgANjaGltcHF1AC8iPCJHIpwhTSJQIloigKGBImNlcgA2Iv0JOSJ1AOUABgoA4DXYw9zvIXJ0bQKdIQAAAABEImEAcgDhAOEhbQBloEEi8aBEIiYKYQDyAMsIcwB1AAABYnBWIlgi5QDUCeUA3wmAAWJjcABgInMieCKAoYQiRWVzAGci7glqIgDgxSo4A2UAdABl4IIi0iBxAPGgiCJoImMAZaCBIvEA/gmAoYUiRWVzAH8iFgqCIgDgxio4A2UAdABl4IMi0iBxAPGgiSKAIgACZ2lscpIilCKaIpwi7AAMCWwAZABlADuA8QDxQOcAWwlpI2FuZ2xlAAABbHKkIqoi5SFmdGWg6iLxAEUJaSJnaHQAZaDrIvEAvgltoL0DAKEjAGVzuCK8InIAbwAAoBYhcAAAoAcggARESGFkZ2lscnMAziLSItYi2iLeIugi7SICIw8j4SFzaACgrSLhIXJyAKAEKXAAAOBNItIg4SFzaACgrCIAAWV04iLlIgDgZSLSIADgPgDSIG4iZmluAACg3imAAUFldADzIvci+iJyAHIAAKACKQDgZCLSIHLgPADSIGkAZQAA4LQi0iAAAUF0BiMKI3IAcgAAoAMp8iFpZQDgtSLSIGkAbQAA4Dwi0iCAAUFhbgAaIx4jKiNyAHIAAKDWIXIAAAFociMjJiNrAACgIylvoJYh9wD/DuUhYXIAoCcpUxJqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVCMAAF4jaSN/I4IjjSOeI8AUAAAAAKYjwCMAANoj3yMAAO8jHiQvJD8kRCQAAWNzVyNsFHUAdABlADuA8wDzQAABaXlhI2cjcgBjoJoiO4D0APRAPmSAAmFiaW9zAHEjdCN3I3EBeiNzAOgAdhTsIWFjUWF2AACgOCrvIWxkAKC8KewhaWdTYQABY3KFI4kjaQByAACgvykA4DXYLN1vA5QjAAAAAJYjAACcI24A22JhAHYAZQA7gPIA8kAAoMEpAAFibaEjjAphAHIAAKC1KQACYWNpdKwjryO6I70jcgDyAFkUAAFpcrMjtiNyAACgvinvIXNzAKC7KW4A5QDZCgCgwCmAAWFlaQDFI8gjyyNjAHIATWFnAGEAyWOAAWNkbgDRI9Qj1iPyIW9uv2MAoLYpdQDzAHgBcABmAADgNdhg3YABYWVsAOQj5yPrI3IAAKC3KXIAcAAAoLkpdQDzAHwBAKMoImFkaW9zdvkj/CMPJBMkFiQbJHIA8gBeFIChXSplZm0AAyQJJAwkcgBvoDQhZgAAoDQhO4CqAKpAO4C6ALpA5yFvZgCgtiJyAACgVipsIm9wZQAAoFcqAKBbKoABY2xvACMkJSQrJPIACCRhAHMAaAA7gPgA+EBsAACgmCJpAGwBMyQ4JGQAZQA7gPUA9UBlAHMAYaCXInMAAKA2Km0AbAA7gPYA9kDiIWFyAKA9I+EKXiQAAHokAAB8JJQkAACYJKkkAAAAALUkEQsAAPAkAAAAAAQleiUAAIMlcgCAoSUiYXN0AGUkbyQBCwCBtgA7bGokayS2QGwAZQDsABgDaQJ1JAAAAAB4JG0AAKDzKgCg/Sp5AD9kcgCAAmNpbXB0AIUkiCSLJJkSjyRuAHQAJWBvAGQALmBpAGwAAKAwIOUhbmsAoDEgcgAA4DXYLd2AAWltbwCdJKAkpCR2oMYD1WNtAGEA9AD+B24AZQAAoA4m9KHAA64kAAC0JGMjaGZvcmsAAKDUItZjAAFhdbgkxCRuAAABY2u9JMIkawBooA8hAKAOIfYAaRpzAACkKwBhYmNkZW1zdNMkIRPXJNsk4STjJOck6yTjIWlyAKAjKmkAcgAAoCIqAAFvdYsW3yQAoCUqAKByKm4AO4CxALFAaQBtAACgJip3AG8AAKAnKoABaXB1APUk+iT+JO4idGludACgFSpmAADgNdhh3W4AZAA7gKMAo0CApHoiRWFjZWlub3N1ABMlFSUYJRslTCVRJVklSSV1JQCgsypwAACgtyp1AOUAPwtjoK8qgKJ6ImFjZW5zACclLSU0JTYlSSVwAHAAcgBvAPgAFyV1AHIAbAB5AGUA8QA/C/EAOAuAAWFlcwA8JUElRSXwInByb3gAoLkqcQBxAACgtSppAG0AAKDoImkA7QBEC20AZQDzoDIgIguAAUVhcwBDJVclRSXwAEAlgAFkZnAATwtfJXElgAFhbHMAZSVpJW0l7CFhcgCgLiPpIW5lAKASI/UhcmYAoBMjdKAdIu8AWQvyIWVsAKCwIgABY2l9JYElcgAA4DXYxdzIY24iY3NwAACgCCAAA2Zpb3BzdZElKxuVJZolnyWkJXIAAOA12C7dcABmAADgNdhi3XIiaW1lAACgVyBjAHIAAOA12MbcgAFhZW8AqiW6JcAldAAAAWVpryW2JXIAbgBpAG8AbgDzABkFbgB0AACgFipzAHQAZaA/APEACRj0AG0LgApBQkhhYmNkZWZoaWxtbm9wcnN0dXgA4yXyJfYl+iVpJpAmpia9JtUm5ib4JlonaCdxJ3UnnietJ7EnyCfiJ+cngAFhcnQA6SXsJe4lcgDyAJkM8gD6AuEhaWwAoBwpYQByAPIA3BVhAHIAAKBkKYADY2RlbnFydAAGJhAmEyYYJiYmKyZaJgABZXUKJg0mAOA9IjEDdABlAFVhaQDjACAN7SJwdHl2AKCzKWcAgKHpJ2RlbAAgJiImJCYAoJIpAKClKeUA9wt1AG8AO4C7ALtAcgAApZIhYWJjZmhscHN0dz0mQCZFJkcmSiZMJk4mUSZVJlgmcAAAoHUpZqDlIXMAAKAgKQCgMylzAACgHinrALka8ACVHmwAAKBFKWkAbQAAoHQpbAAAoKMhAKCdIQABYWleJmImaQBsAACgGilvAG6gNiJhAGwA8wB2C4ABYWJyAG8mciZ2JnIA8gAvEnIAawAAoHMnAAFha3omgSZjAAABZWt/JoAmfWBdYAABZXOFJocmAKCMKWwAAAFkdYwmjiYAoI4pAKCQKQACYWV1eZcmmiajJqUm8iFvbllhAAFkaZ4moSZpAGwAV2HsAA8M4gCAJkBkAAJjbHFzrSawJrUmuiZhAACgNylkImhhcgAAoGkpdQBvAPKgHSCjAWgAAKCzIYABYWNnAMMm0iaUC2wAgKEcIWlwcwDLJs4migxuAOUAoAxhAHIA9ADaC3QAAKCtJYABaWxyANsm3ybjJvMhaHQAoH0pbwBvAPIANgwA4DXYL90AAWFv6ib1JnIAAAFkde8m8SYAoMEhbKDAIQCgbCl2oMED8WOAAWducwD+Jk4nUCdoAHQAAANhaGxyc3QKJxInISc1Jz0nRydyInJvdwB0oJIhYQDpAFYmYSNycG9vbgAAAWR1GiceJ28AdwDuAPAmcAAAoMAh5SFmdAABYWgnJy0ncgByAG8AdwDzAAkMYQByAHAAbwBvAG4A8wATBGklZ2h0YXJyb3dzAACgySFxAHUAaQBnAGEAcgByAG8A9wBZJugkcmVldGltZXMAoMwiZwDaYmkAbgBnAGQAbwB0AHMAZQDxABwYgAFhaG0AYCdjJ2YncgDyAAkMYQDyABMEAKAPIG8idXN0AGGgsSPjIWhlAKCxI+0haWQAoO4qAAJhYnB0fCeGJ4knmScAAW5ygCeDJ2cAAKDtJ3IAAKD+IXIA6wAcDIABYWZsAI8nkieVJ3IAAKCGKQDgNdhj3XUAcwAAoC4qaSJtZXMAAKA1KgABYXCiJ6gncgBnoCkAdAAAoJQp7yJsaW50AKASKmEAcgDyADwnAAJhY2hxuCe8J6EMwCfxIXVvAKA6IHIAAOA12MfcAAFidYAmxCdvAPKgGSCoAYABaGlyAM4n0ifWJ3IAZQDlAE0n7SFlcwCgyiJpAIChuSVlZmwAXAxjEt4n9CFyaQCgzinsInVoYXIAoGgpAKAeIWENBSgJKA0oSyhVKIYoAACLKLAoAAAAAOMo5ygAABApJCkxKW0pcSmHKaYpAACYKgAAAACxKmMidXRlAFthcQB1AO8ABR+ApHsiRWFjZWlucHN5ABwoHignKCooLygyKEEoRihJKACgtCrwASMoAAAlKACguCpvAG4AYWF1AOUAgw1koLAqaQBsAF9hcgBjAF1hgAFFYXMAOCg6KD0oAKC2KnAAAKC6KmkAbQAAoOki7yJsaW50AKATKmkA7QCIDUFkbwB0AGKixSKRFgAAAABTKACgZiqAA0FhY21zdHgAYChkKG8ocyh1KHkogihyAHIAAKDYIXIAAAFocmkoayjrAJAab6CYIfcAzAd0ADuApwCnQGkAO2D3IWFyAKApKW0AAAFpbn4ozQBuAHUA8wDOAHQAAKA2J3IA7+A12DDdIxkAAmFjb3mRKJUonSisKHIAcAAAoG8mAAFoeZkonChjAHkASWRIZHIAdABtAqUoAAAAAKgoaQDkAFsPYQByAGEA7ABsJDuArQCtQAABZ22zKLsobQBhAAChwwNmdroouijCY4CjPCJkZWdsbnByAMgozCjPKNMo1yjaKN4obwB0AACgairxoEMiCw5FoJ4qAKCgKkWgnSoAoJ8qZQAAoEYi7CF1cwCgJCrhIXJyAKByKWEAcgDyAPwMAAJhZWl07Sj8KAEpCCkAAWxz8Sj4KGwAcwBlAHQAbQDpAH8oaABwAACgMyrwImFyc2wAoOQpAAFkbFoPBSllAACgIyNloKoqc6CsKgDgrCoA/oABZmxwABUpGCkfKfQhY3lMZGKgLwBhoMQpcgAAoD8jZgAA4DXYZN1hAAABZHIoKRcDZQBzAHWgYCZpAHQAAKBgJoABY3N1ADYpRilhKQABYXU6KUApcABzoJMiAOCTIgD+cABzoJQiAOCUIgD+dQAAAWJwSylWKQChjyJlcz4NUCllAHQAZaCPIvEAPw0AoZAiZXNIDVspZQB0AGWgkCLxAEkNAKGhJWFmZilbBHIAZQFrKVwEAKChJWEAcgDyAAMNAAJjZW10dyl7KX8pgilyAADgNdjI3HQAbQDuAM4AaQDsAAYpYQByAOYAVw0AAWFyiimOKXIA5qAGJhESAAFhbpIpoylpImdodAAAAWVwmSmgKXAAcwBpAGwAbwDuANkXaADpAKAkcwCvYIACYmNtbnAArin8KY4NJSooKgCkgiJFZGVtbnByc7wpvinCKcgpzCnUKdgp3CkAoMUqbwB0AACgvSpkoIYibwB0AACgwyr1IWx0AKDBKgABRWXQKdIpAKDLKgCgiiLsIXVzAKC/KuEhcnIAoHkpgAFlaXUA4inxKfQpdAAAoYIiZW7oKewpcQDxoIYivSllAHEA8aCKItEpbQAAoMcqAAFicPgp+ikAoNUqAKDTKmMAgKJ7ImFjZW5zAAcqDSoUKhYqRihwAHAAcgBvAPgAIyh1AHIAbAB5AGUA8QCDDfEAfA2AAWFlcwAcKiIqPShwAHAAcgBvAPgAPChxAPEAOShnAACgaiYApoMiMTIzRWRlaGxtbnBzPCo/KkIqRSpHKlIqWCpjKmcqaypzKncqO4C5ALlAO4CyALJAO4CzALNAAKDGKgABb3NLKk4qdAAAoL4qdQBiAACg2CpkoIcibwB0AACgxCpzAAABb3VdKmAqbAAAoMknYgAAoNcq4SFycgCgeyn1IWx0AKDCKgABRWVvKnEqAKDMKgCgiyLsIXVzAKDAKoABZWl1AH0qjCqPKnQAAKGDImVugyqHKnEA8aCHIkYqZQBxAPGgiyJwKm0AAKDIKgABYnCTKpUqAKDUKgCg1iqAAUFhbgCdKqEqrCpyAHIAAKDZIXIAAAFocqYqqCrrAJUab6CZIfcAxQf3IWFyAKAqKWwAaQBnADuA3wDfQOELzyrZKtwq6SrsKvEqAAD1KjQrAAAAAAAAAAAAAEwrbCsAAHErvSsAAAAAAADRK3IC1CoAAAAA2CrnIWV0AKAWI8RjcgDrAOUKgAFhZXkA4SrkKucq8iFvbmVh5CFpbGNhQmRvAPQAIg5sInJlYwAAoBUjcgAA4DXYMd0AAmVpa2/7KhIrKCsuK/IBACsAAAkrZQAAATRm6g0EK28AcgDlAOsNYQBzorgDECsAAAAAEit5AG0A0WMAAWNuFislK2sAAAFhcxsrIStwAHAAcgBvAPgAFw5pAG0AAKA8InMA8AD9DQABYXMsKyEr8AAXDnIAbgA7gP4A/kDsATgrOyswG2QA5QBnAmUAcwCAgdcAO2JkAEMrRCtJK9dAYaCgInIAAKAxKgCgMCqAAWVwcwBRK1MraSvhAAkh4qKkIlsrXysAAAAAYytvAHQAAKA2I2kAcgAAoPEqb+A12GXdcgBrAACg2irhAHgociJpbWUAAKA0IIABYWlwAHYreSu3K2QA5QC+DYADYWRlbXBzdACFK6MrmiunK6wrsCuzK24iZ2xlAACitSVkbHFykCuUK5ornCvvIXduAKC/JeUhZnRloMMl8QACBwCgXCJpImdodABloLkl8QBdDG8AdAAAoOwlaSJudXMAAKA6KuwhdXMAoDkqYgAAoM0p6SFtZQCgOyrlInppdW0AoOIjgAFjaHQAwivKK80rAAFyecYrySsA4DXYydxGZGMAeQBbZPIhb2tnYQABaW/UK9creAD0ANERaCJlYWQAAAFsct4r5ytlAGYAdABhAHIAcgBvAPcAXQbpJGdodGFycm93AKCgIQAJQUhhYmNkZmdobG1vcHJzdHV3CiwNLBEsHSwnLDEsQCxLLFIsYix6LIQsjyzLLOgs7Sz/LAotcgDyAAkDYQByAACgYykAAWNyFSwbLHUAdABlADuA+gD6QPIACQ1yAOMBIywAACUseQBeZHYAZQBtYQABaXkrLDAscgBjADuA+wD7QENkgAFhYmgANyw6LD0scgDyANEO7CFhY3FhYQDyAOAOAAFpckQsSCzzIWh0AKB+KQDgNdgy3XIAYQB2AGUAO4D5APlAYQFWLF8scgAAAWxyWixcLACgvyEAoL4hbABrAACggCUAAWN0Zix2LG8CbCwAAAAAcyxyAG4AZaAcI3IAAKAcI28AcAAAoA8jcgBpAACg+CUAAWFsfiyBLGMAcgBrYTuAqACoQAABZ3CILIssbwBuAHNhZgAA4DXYZt0AA2FkaGxzdZksniynLLgsuyzFLHIAcgBvAPcACQ1vAHcAbgBhAHIAcgBvAPcA2A5hI3Jwb29uAAABbHKvLLMsZQBmAPQAWyxpAGcAaAD0AF0sdQDzAKYOaQAAocUDaGzBLMIs0mNvAG4AxWPwI2Fycm93cwCgyCGAAWNpdADRLOEs5CxvAtcsAAAAAN4scgBuAGWgHSNyAACgHSNvAHAAAKAOI24AZwBvYXIAaQAAoPklYwByAADgNdjK3IABZGlyAPMs9yz6LG8AdAAAoPAi7CFkZWlhaQBmoLUlAKC0JQABYW0DLQYtcgDyAMosbAA7gPwA/EDhIm5nbGUAoKcpgAdBQkRhY2RlZmxub3Byc3oAJy0qLTAtNC2bLZ0toS2/LcMtxy3TLdgt3C3gLfwtcgDyABADYQByAHag6CoAoOkqYQBzAOgA/gIAAW5yOC08LechcnQAoJwpgANla25wcnN0AJkpSC1NLVQtXi1iLYItYQBwAHAA4QAaHG8AdABoAGkAbgDnAKEXgAFoaXIAoSmzJFotbwBwAPQAdCVooJUh7wD4JgABaXVmLWotZwBtAOEAuygAAWJwbi14LXMjZXRuZXEAceCKIgD+AODLKgD+cyNldG5lcQBx4IsiAP4A4MwqAP4AAWhyhi2KLWUAdADhABIraSNhbmdsZQAAAWxyki2WLeUhZnQAoLIiaSJnaHQAAKCzInkAMmThIXNoAKCiIoABZWxyAKcttC24LWKiKCKuLQAAAACyLWEAcgAAoLsicQAAoFoi7CFpcACg7iIAAWJ0vC1eD2EA8gBfD3IAAOA12DPddAByAOkAlS1zAHUAAAFicM0t0C0A4IIi0iAA4IMi0iBwAGYAAOA12GfdcgBvAPAAWQt0AHIA6QCaLQABY3XkLegtcgAA4DXYy9wAAWJw7C30LW4AAAFFZXUt8S0A4IoiAP5uAAABRWV/LfktAOCLIgD+6SJnemFnAKCaKYADY2Vmb3BycwANLhAuJS4pLiMuLi40LukhcmN1YQABZGkULiEuAAFiZxguHC5hAHIAAKBfKmUAcaAnIgCgWSLlIXJwAKAYIXIAAOA12DTdcABmAADgNdho3WWgQCJhAHQA6ABqD2MAcgAA4DXYzNzjCuQRUC4AAFQuAABYLmIuAAAAAGMubS5wLnQuAAAAAIguki4AAJouJxIqEnQAcgDpAB0ScgAA4DXYNd0AAUFhWy5eLnIA8gDnAnIA8gCTB75jAAFBYWYuaS5yAPIA4AJyAPIAjAdhAPAAeh5pAHMAAKD7IoABZHB0APgReS6DLgABZmx9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg"); + +// node_modules/entities/dist/internal/bin-trie-flags.js +var BinTrieFlags; +(function(BinTrieFlags2) { + BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH"; + BinTrieFlags2[BinTrieFlags2["FLAG13"] = 8192] = "FLAG13"; + BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH"; + BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE"; +})(BinTrieFlags || (BinTrieFlags = {})); + +// node_modules/entities/dist/decode.js +var CharCodes; +(function(CharCodes2) { + CharCodes2[CharCodes2["NUM"] = 35] = "NUM"; + CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI"; + CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS"; + CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO"; + CharCodes2[CharCodes2["NINE"] = 57] = "NINE"; + CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A"; + CharCodes2[CharCodes2["LOWER_F"] = 102] = "LOWER_F"; + CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X"; + CharCodes2[CharCodes2["LOWER_Z"] = 122] = "LOWER_Z"; + CharCodes2[CharCodes2["UPPER_A"] = 65] = "UPPER_A"; + CharCodes2[CharCodes2["UPPER_F"] = 70] = "UPPER_F"; + CharCodes2[CharCodes2["UPPER_Z"] = 90] = "UPPER_Z"; +})(CharCodes || (CharCodes = {})); +var TO_LOWER_BIT = 32; +function isNumber(code2) { + return code2 >= CharCodes.ZERO && code2 <= CharCodes.NINE; +} +function isHexadecimalCharacter(code2) { + return code2 >= CharCodes.UPPER_A && code2 <= CharCodes.UPPER_F || code2 >= CharCodes.LOWER_A && code2 <= CharCodes.LOWER_F; +} +function isAsciiAlphaNumeric(code2) { + return code2 >= CharCodes.UPPER_A && code2 <= CharCodes.UPPER_Z || code2 >= CharCodes.LOWER_A && code2 <= CharCodes.LOWER_Z || isNumber(code2); +} +function isEntityInAttributeInvalidEnd(code2) { + return code2 === CharCodes.EQUALS || isAsciiAlphaNumeric(code2); +} +var EntityDecoderState; +(function(EntityDecoderState2) { + EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart"; + EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart"; + EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal"; + EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex"; + EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity"; +})(EntityDecoderState || (EntityDecoderState = {})); +var DecodingMode; +(function(DecodingMode2) { + DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy"; + DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict"; + DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute"; +})(DecodingMode || (DecodingMode = {})); +var EntityDecoder = class { + decodeTree; + emitCodePoint; + errors; + constructor(decodeTree, emitCodePoint, errors2) { + this.decodeTree = decodeTree; + this.emitCodePoint = emitCodePoint; + this.errors = errors2; + } + /** The current state of the decoder. */ + state = EntityDecoderState.EntityStart; + /** Characters that were consumed while parsing an entity. */ + consumed = 1; + /** + * The result of the entity. + * + * Either the result index of a numeric entity, or the codepoint of a + * numeric entity. + */ + result = 0; + /** The current index in the decode tree. */ + treeIndex = 0; + /** The number of characters that were consumed in excess. */ + excess = 1; + /** The mode in which the decoder is operating. */ + decodeMode = DecodingMode.Strict; + /** The number of characters that have been consumed in the current run. */ + runConsumed = 0; + /** + * Resets the instance to make it reusable. + * @param decodeMode Entity decoding mode to use. + */ + startEntity(decodeMode) { + this.decodeMode = decodeMode; + this.state = EntityDecoderState.EntityStart; + this.result = 0; + this.treeIndex = 0; + this.excess = 1; + this.consumed = 1; + this.runConsumed = 0; + } + /** + * Write an entity to the decoder. This can be called multiple times with partial entities. + * If the entity is incomplete, the decoder will return -1. + * + * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the + * entity is incomplete, and resume when the next string is written. + * @param input The string containing the entity (or a continuation of the entity). + * @param offset The offset at which the entity begins. Should be 0 if this is not the first call. + * @returns The number of characters that were consumed, or -1 if the entity is incomplete. + */ + write(input, offset) { + switch (this.state) { + case EntityDecoderState.EntityStart: { + if (input.charCodeAt(offset) === CharCodes.NUM) { + this.state = EntityDecoderState.NumericStart; + this.consumed += 1; + return this.stateNumericStart(input, offset + 1); + } + this.state = EntityDecoderState.NamedEntity; + return this.stateNamedEntity(input, offset); + } + case EntityDecoderState.NumericStart: { + return this.stateNumericStart(input, offset); + } + case EntityDecoderState.NumericDecimal: { + return this.stateNumericDecimal(input, offset); + } + case EntityDecoderState.NumericHex: { + return this.stateNumericHex(input, offset); + } + case EntityDecoderState.NamedEntity: { + return this.stateNamedEntity(input, offset); + } + } + } + /** + * Switches between the numeric decimal and hexadecimal states. + * + * Equivalent to the `Numeric character reference state` in the HTML spec. + * @param input The string containing the entity (or a continuation of the entity). + * @param offset The current offset. + * @returns The number of characters that were consumed, or -1 if the entity is incomplete. + */ + stateNumericStart(input, offset) { + if (offset >= input.length) { + return -1; + } + if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) { + this.state = EntityDecoderState.NumericHex; + this.consumed += 1; + return this.stateNumericHex(input, offset + 1); + } + this.state = EntityDecoderState.NumericDecimal; + return this.stateNumericDecimal(input, offset); + } + /** + * Parses a hexadecimal numeric entity. + * + * Equivalent to the `Hexademical character reference state` in the HTML spec. + * @param input The string containing the entity (or a continuation of the entity). + * @param offset The current offset. + * @returns The number of characters that were consumed, or -1 if the entity is incomplete. + */ + stateNumericHex(input, offset) { + while (offset < input.length) { + const char = input.charCodeAt(offset); + if (isNumber(char) || isHexadecimalCharacter(char)) { + const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10; + this.result = this.result * 16 + digit; + this.consumed++; + offset++; + } else { + return this.emitNumericEntity(char, 3); + } + } + return -1; + } + /** + * Parses a decimal numeric entity. + * + * Equivalent to the `Decimal character reference state` in the HTML spec. + * @param input The string containing the entity (or a continuation of the entity). + * @param offset The current offset. + * @returns The number of characters that were consumed, or -1 if the entity is incomplete. + */ + stateNumericDecimal(input, offset) { + while (offset < input.length) { + const char = input.charCodeAt(offset); + if (isNumber(char)) { + this.result = this.result * 10 + (char - CharCodes.ZERO); + this.consumed++; + offset++; + } else { + return this.emitNumericEntity(char, 2); + } + } + return -1; + } + /** + * Validate and emit a numeric entity. + * + * Implements the logic from the `Hexademical character reference start + * state` and `Numeric character reference end state` in the HTML spec. + * @param lastCp The last code point of the entity. Used to see if the + * entity was terminated with a semicolon. + * @param expectedLength The minimum number of characters that should be + * consumed. Used to validate that at least one digit + * was consumed. + * @returns The number of characters that were consumed. + */ + emitNumericEntity(lastCp, expectedLength) { + if (this.consumed <= expectedLength) { + this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed); + return 0; + } + if (lastCp === CharCodes.SEMI) { + this.consumed += 1; + } else if (this.decodeMode === DecodingMode.Strict) { + return 0; + } + this.emitCodePoint(replaceCodePoint(this.result), this.consumed); + if (this.errors) { + if (lastCp !== CharCodes.SEMI) { + this.errors.missingSemicolonAfterCharacterReference(); + } + this.errors.validateNumericCharacterReference(this.result); + } + return this.consumed; + } + /** + * Parses a named entity. + * + * Equivalent to the `Named character reference state` in the HTML spec. + * @param input The string containing the entity (or a continuation of the entity). + * @param offset The current offset. + * @returns The number of characters that were consumed, or -1 if the entity is incomplete. + */ + stateNamedEntity(input, offset) { + const { decodeTree } = this; + let current = decodeTree[this.treeIndex]; + let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; + while (offset < input.length) { + if (valueLength === 0 && (current & BinTrieFlags.FLAG13) !== 0) { + const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; + if (this.runConsumed === 0) { + const firstChar = current & BinTrieFlags.JUMP_TABLE; + if (input.charCodeAt(offset) !== firstChar) { + return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity(); + } + offset++; + this.excess++; + this.runConsumed++; + } + while (this.runConsumed < runLength) { + if (offset >= input.length) { + return -1; + } + const charIndexInPacked = this.runConsumed - 1; + const packedWord = decodeTree[this.treeIndex + 1 + (charIndexInPacked >> 1)]; + const expectedChar = charIndexInPacked % 2 === 0 ? packedWord & 255 : packedWord >> 8 & 255; + if (input.charCodeAt(offset) !== expectedChar) { + this.runConsumed = 0; + return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity(); + } + offset++; + this.excess++; + this.runConsumed++; + } + this.runConsumed = 0; + this.treeIndex += 1 + (runLength >> 1); + current = decodeTree[this.treeIndex]; + valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; + } + if (offset >= input.length) + break; + const char = input.charCodeAt(offset); + if (char === CharCodes.SEMI && valueLength !== 0 && (current & BinTrieFlags.FLAG13) !== 0) { + return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess); + } + this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char); + if (this.treeIndex < 0) { + return this.result === 0 || // If we are parsing an attribute + this.decodeMode === DecodingMode.Attribute && // We shouldn't have consumed any characters after the entity, + (valueLength === 0 || // And there should be no invalid characters. + isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity(); + } + current = decodeTree[this.treeIndex]; + valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; + if (valueLength !== 0) { + if (char === CharCodes.SEMI) { + return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess); + } + if (this.decodeMode !== DecodingMode.Strict && (current & BinTrieFlags.FLAG13) === 0) { + this.result = this.treeIndex; + this.consumed += this.excess; + this.excess = 0; + } + } + offset++; + this.excess++; + } + return -1; + } + /** + * Emit a named entity that was not terminated with a semicolon. + * @returns The number of characters consumed. + */ + emitNotTerminatedNamedEntity() { + const { result, decodeTree } = this; + const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14; + this.emitNamedEntityData(result, valueLength, this.consumed); + this.errors?.missingSemicolonAfterCharacterReference(); + return this.consumed; + } + /** + * Emit a named entity. + * @param result The index of the entity in the decode tree. + * @param valueLength The number of bytes in the entity. + * @param consumed The number of characters consumed. + * @returns The number of characters consumed. + */ + emitNamedEntityData(result, valueLength, consumed) { + const { decodeTree } = this; + this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13) : decodeTree[result + 1], consumed); + if (valueLength === 3) { + this.emitCodePoint(decodeTree[result + 2], consumed); + } + return consumed; + } + /** + * Signal to the parser that the end of the input was reached. + * + * Remaining data will be emitted and relevant errors will be produced. + * @returns The number of characters consumed. + */ + end() { + switch (this.state) { + case EntityDecoderState.NamedEntity: { + return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0; + } + // Otherwise, emit a numeric entity if we have one. + case EntityDecoderState.NumericDecimal: { + return this.emitNumericEntity(0, 2); + } + case EntityDecoderState.NumericHex: { + return this.emitNumericEntity(0, 3); + } + case EntityDecoderState.NumericStart: { + this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed); + return 0; + } + case EntityDecoderState.EntityStart: { + return 0; + } + } + } +}; +function getDecoder(decodeTree) { + let returnValue = ""; + const decoder = new EntityDecoder(decodeTree, (data) => returnValue += String.fromCodePoint(data)); + return function decodeWithTrie(input, decodeMode) { + let lastIndex = 0; + let offset = 0; + while ((offset = input.indexOf("&", offset)) >= 0) { + returnValue += input.slice(lastIndex, offset); + decoder.startEntity(decodeMode); + const length = decoder.write( + input, + // Skip the "&" + offset + 1 + ); + if (length < 0) { + lastIndex = offset + decoder.end(); + break; + } + lastIndex = offset + length; + offset = length === 0 ? lastIndex + 1 : lastIndex; + } + const result = returnValue + input.slice(lastIndex); + returnValue = ""; + return result; + }; +} +function determineBranch(decodeTree, current, nodeIndex, char) { + const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; + const jumpOffset = current & BinTrieFlags.JUMP_TABLE; + if (branchCount === 0) { + return jumpOffset !== 0 && char === jumpOffset ? nodeIndex : -1; + } + if (jumpOffset) { + const value = char - jumpOffset; + return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIndex + value] - 1; + } + const packedKeySlots = branchCount + 1 >> 1; + let lo = 0; + let hi = branchCount - 1; + while (lo <= hi) { + const mid = lo + hi >>> 1; + const slot = mid >> 1; + const packed = decodeTree[nodeIndex + slot]; + const midKey = packed >> (mid & 1) * 8 & 255; + if (midKey < char) { + lo = mid + 1; + } else if (midKey > char) { + hi = mid - 1; + } else { + return decodeTree[nodeIndex + packedKeySlots + mid]; + } + } + return -1; +} +var htmlDecoder = /* @__PURE__ */ getDecoder(htmlDecodeTree); +function decodeHTMLStrict(htmlString) { + return htmlDecoder(htmlString, DecodingMode.Strict); +} + +// node_modules/entities/dist/index.js +var EntityLevel; +(function(EntityLevel2) { + EntityLevel2[EntityLevel2["XML"] = 0] = "XML"; + EntityLevel2[EntityLevel2["HTML"] = 1] = "HTML"; +})(EntityLevel || (EntityLevel = {})); +var EncodingMode; +(function(EncodingMode2) { + EncodingMode2[EncodingMode2["UTF8"] = 0] = "UTF8"; + EncodingMode2[EncodingMode2["ASCII"] = 1] = "ASCII"; + EncodingMode2[EncodingMode2["Extensive"] = 2] = "Extensive"; + EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute"; + EncodingMode2[EncodingMode2["Text"] = 4] = "Text"; +})(EncodingMode || (EncodingMode = {})); + +// node_modules/linkify-it/build/index.mjs +var REBuilder = class { + src_Any = Any.source; + src_Cc = Cc.source; + src_Z = Z.source; + src_P = P.source; + src_ZPCc = [ + this.src_Z, + this.src_P, + this.src_Cc + ].join("|"); + src_ZCc = [this.src_Z, this.src_Cc].join("|"); + cache = {}; + opts = { + maxLength: 1e4, + urlAuth: false, + schema_names: [] + }; + constructor(opts = {}) { + this.opts = { + ...this.opts, + ...opts + }; + } + set(opts = {}) { + this.opts = { + ...this.opts, + ...opts + }; + this.cache = {}; + return this; + } + escapeRE(str) { + return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); + } + nestedPairRE(open, close, depth = 4) { + const openRE = this.escapeRE(open); + const closeRE = this.escapeRE(close); + const atom = `(?:(?!${this.src_ZCc}|${openRE}|${closeRE}).)`; + let pair = `${openRE}${atom}{0,1000}${closeRE}`; + for (let level = 2; level <= depth; level++) pair = `${openRE}(?:${atom}|${pair}){0,1000}${closeRE}`; + return pair; + } + get_text_separators() { + return this.cache.text_separators ??= /[><\uff5c]/; + } + get_pseudo_letter() { + return this.cache.src_pseudo_letter ??= new RegExp(`(?:(?!${this.get_text_separators().source}|${this.src_ZPCc})${this.src_Any})`); + } + get_ipv4_addr() { + return this.cache.src_ip4 ??= /* @__PURE__ */ new RegExp("(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])"); + } + get_ipv6_addr() { + const h16 = "[0-9A-Fa-f]{1,4}"; + const ls32 = `(?:(?:${h16}:${h16})|${this.get_ipv4_addr().source})`; + return this.cache.src_ip6_addr ??= new RegExp(`(?:(?:${h16}:){6}${ls32}|::(?:${h16}:){5}${ls32}|(?:${h16})?::(?:${h16}:){4}${ls32}|(?:(?:${h16}:){0,1}${h16})?::(?:${h16}:){3}${ls32}|(?:(?:${h16}:){0,2}${h16})?::(?:${h16}:){2}${ls32}|(?:(?:${h16}:){0,3}${h16})?::${h16}:${ls32}|(?:(?:${h16}:){0,4}${h16})?::${ls32}|(?:(?:${h16}:){0,5}${h16})?::${h16}|(?:(?:${h16}:){0,6}${h16})?::)`); + } + get_ipv6_url_host() { + return this.cache.src_ip6_host ??= new RegExp(`\\[${this.get_ipv6_addr().source}\\]`); + } + get_ipv6_mail_host() { + return this.cache.src_ipv6_mail_host ??= new RegExp(`\\[IPv6:${this.get_ipv6_addr().source}\\]`); + } + get_auth() { + return this.cache.src_auth ??= new RegExp(`(?:(?:(?!${this.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`); + } + get_port() { + return this.cache.src_port ??= /* @__PURE__ */ new RegExp("(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?"); + } + get_host_terminator() { + return this.cache.src_host_terminator ??= new RegExp(`(?=$|${this.get_text_separators().source}|${this.src_ZPCc})(?!${this.opts["---"] ? "-(?!--)|" : "-|"}_|:\\d|\\.-|\\.(?!$|${this.src_ZPCc}))`); + } + get_path_terminator() { + return this.cache.src_path_terminator ??= new RegExp(`${this.src_ZPCc}|${this.get_text_separators().source}`); + } + get_path() { + return this.cache.src_path ??= new RegExp(`(?:[/?#](?:${this.nestedPairRE("[", "]")}|${this.nestedPairRE("(", ")")}|${this.nestedPairRE("{", "}")}|\\"(?:(?!${this.src_ZCc}|["]).){1,100}\\"|\\'(?:(?!${this.src_ZCc}|[']).){1,100}\\'|\\'(?=${this.get_pseudo_letter().source}|[-])|\\.{2,20}[:]?[a-zA-Z0-9%/&]|\\.(?!${this.src_ZCc}|[.]|$)|` + (this.opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-{0,19})|" : "\\-{1,20}|") + `,(?!${this.src_ZCc}|$)|;(?!${this.src_ZCc}|$)|\\!{1,20}(?!${this.src_ZCc}|[!]|$)|\\?(?!${this.src_ZCc}|[?]|$)|` + this.get_path_extra().source + `[\\\\/:%@#&=_~*]|(?!${this.get_path_terminator().source}).){1,${this.opts.maxLength}}|\\/)?`); + } + get_mail_name() { + return this.cache.src_mail_name ??= /* @__PURE__ */ new RegExp("[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9](?:[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9]|[.](?=[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9])){0,63}"); + } + get_xn() { + return this.cache.src_xn ??= /* @__PURE__ */ new RegExp("xn--[a-z0-9\\-]{1,59}"); + } + get_tld() { + if (this.cache.tld) return this.cache.tld; + const tlds_src = [...new Set(this.opts.tlds || [])].sort().reverse().join("|"); + this.cache.tld = new RegExp(`${tlds_src || "$#none#$"}|${this.get_xn().source}`); + return this.cache.tld; + } + get_domain_root() { + return this.cache.src_domain_root ??= new RegExp("(?:" + this.get_xn().source + `|${this.get_pseudo_letter().source}{1,63})`); + } + get_domain() { + return this.cache.src_domain ??= new RegExp("(?:" + this.get_xn().source + `|(?:${this.get_pseudo_letter().source})|(?:${this.get_pseudo_letter().source}(?:-|${this.get_pseudo_letter().source}){0,61}${this.get_pseudo_letter().source}))`); + } + get_url_host_port() { + return this.cache.url_host_port ??= new RegExp("(?:" + this.get_ipv6_url_host().source + `|(?:(?:(?:${this.get_domain().source})\\.){0,10}${this.get_domain().source}))` + this.get_port().source + this.get_host_terminator().source); + } + get_fuzzy_url_host_port() { + return this.cache.fuzzy_url_host_port ??= new RegExp("(?:" + (this.opts.fuzzyIP ? this.get_ipv4_addr().source + "|" : "") + `(?:(?:(?:${this.get_domain().source})\\.){1,10}(?:${this.get_tld().source})))` + this.get_host_terminator().source); + } + get_mail_host() { + return this.cache.src_mail_host ??= new RegExp("(?:" + this.get_ipv6_mail_host().source + `|(?:(?:(?:${this.get_domain().source})\\.){0,4}${this.get_domain().source}))` + this.get_host_terminator().source); + } + get_fuzzy_mail_host() { + return this.cache.src_fuzzy_mail_host ??= new RegExp("(?:" + this.get_ipv6_mail_host().source + `|(?:(?:(?:${this.get_domain().source})[.]){1,4}${this.get_domain_root().source}))` + this.get_host_terminator().source); + } + get_path_extra() { + return this.cache.src_path_extra ??= /* @__PURE__ */ new RegExp(""); + } + get_fuzzy_mail_host_search() { + return this.cache.mail_fuzzy_host_search ??= new RegExp(`@${this.get_fuzzy_mail_host().source}`, "ig"); + } + get_fuzzy_link_search() { + return this.cache.link_fuzzy_search ??= new RegExp(`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uFF5C]|${this.src_ZPCc}))(?:(?![$+<=>^\`|\uFF5C])${this.get_fuzzy_url_host_port().source}${this.get_path().source})`, "ig"); + } + get_http_validator() { + return this.cache.http_validator ??= new RegExp("\\/\\/" + (this.opts.urlAuth ? this.get_auth().source : "") + this.get_url_host_port().source + this.get_path().source, "iy"); + } + get_relative_proto_validator() { + return this.cache.relative_proto_validator ??= new RegExp((this.opts.urlAuth ? this.get_auth().source : "") + `(?:localhost|${this.get_ipv6_url_host().source}|(?:(?:${this.get_domain().source})[.]){1,10}${this.get_domain_root().source})` + this.get_port().source + this.get_host_terminator().source + this.get_path().source, "iy"); + } + get_mail_name_validator() { + return this.cache.mail_name_validator ??= new RegExp(`(?:^|${this.get_text_separators().source}|"|\\(|${this.src_ZCc})(${this.get_mail_name().source})$`); + } + get_mailto_validator() { + return this.cache.mailto_validator ??= new RegExp(`${this.get_mail_name().source}@${this.get_mail_host().source}`, "iy"); + } + get_schema_names() { + return this.cache.schema_names ??= new RegExp((this.opts.schema_names || []).map((name) => this.escapeRE(name)).join("|")); + } + get_schema_search() { + return this.cache.schema_search ??= new RegExp(`(^|(?!_)(?:[><\uFF5C]|${this.src_ZPCc}))(${this.get_schema_names().source})`, "ig"); + } + get_schema_at_start() { + return this.cache.schema_at_start ??= new RegExp(`^${this.get_schema_search().source}`, "i"); + } +}; +var web_schema = { + validate: (text2, pos, self2) => { + const re = self2.re.get_http_validator(); + re.lastIndex = pos; + const m = re.exec(text2); + return m ? m[0].length : 0; + }, + normalize: (match, self2) => self2.normalize(match) +}; +var defaultSchemas = { + "http:": web_schema, + "https:": web_schema, + "ftp:": web_schema, + "//": { + validate: function(text2, pos, self2) { + const re = self2.re.get_relative_proto_validator(); + re.lastIndex = pos; + const m = re.exec(text2); + if (m) { + if (pos >= 3 && text2[pos - 3] === ":") return 0; + if (pos >= 3 && text2[pos - 3] === "/") return 0; + return m[0].length; + } + return 0; + }, + normalize: (match, self2) => self2.normalize(match) + }, + "mailto:": { + validate: function(text2, pos, self2) { + const re = self2.re.get_mailto_validator(); + re.lastIndex = pos; + const m = re.exec(text2); + return m ? m[0].length : 0; + }, + normalize: (match, self2) => self2.normalize(match) + } +}; +var tlds_2ch = "a:cdefgilmnoqrstuwxz|b:abdefghijmnorstvwyz|c:acdfghiklmnoruvwxyz|d:ejkmoz|e:cegrstu|f:ijkmor|g:abdefghilmnpqrstuwy|h:kmnrtu|i:delmnoqrst|j:emop|k:eghimnprwyz|l:abcikrstuvy|m:acdeghklmnopqrstuvwxyz|n:acefgilopruz|o:m|p:aefghklmnrstwy|q:a|r:eosuw|s:abcdeghijklmnortuvxyz|t:cdfghjklmnortvwz|u:agksyz|v:aceginu|w:fs|y:et|z:amw"; +var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444"; +function unpackTlds() { + const result = tlds_default.split("|"); + tlds_2ch.split("|").forEach((item) => { + const sep = item.indexOf(":"); + const prefix = item.slice(0, sep); + for (const suffix of item.slice(sep + 1)) result.push(prefix + suffix); + }); + return result; +} +var defaultOptions = { + fuzzyLink: false, + fuzzyEmail: true, + fuzzyIP: false, + "---": false, + tlds: unpackTlds(), + urlAuth: false, + maxLength: 1e4 +}; +var Match = class { + /** Prefix (protocol) for matched string. Empty for fuzzy links. */ + schema; + /** First position of matched string. */ + index; + /** Next position after matched string. */ + lastIndex; + /** Matched string. */ + raw; + /** Normalized text of matched string. */ + text; + /** Normalized URL of matched string. */ + url; + constructor(text2, schema, index, lastIndex) { + const raw = text2.slice(index, lastIndex); + this.schema = schema.toLowerCase(); + this.index = index; + this.lastIndex = lastIndex; + this.raw = raw; + this.text = raw; + this.url = raw; + } +}; +var LinkifyIt = class { + __opts__; + __schemas__; + re; + /** + * Creates new linkifier instance. + * + * By default understands: + * + * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links + * - "fuzzy" emails (foo@bar.com). + * + * See {@link LinkifyConstructorOptions} for available options. + * + * @param options Recognition options. + * + * @example + * ```javascript + * import { LinkifyIt } from 'linkify-it' + * + * const linkify = new LinkifyIt({ fuzzyLink: true }) + * + * linkify + * .tlds(require('tlds')) // Reload with full TLD list + * .tlds('onion', true) // Add unofficial `.onion` domain + * .add('ftp:', null) // Disable `ftp:` protocol + * .set({ fuzzyIP: true }) // Enable IPs in fuzzy links + * + * console.log(linkify.test('Site github.com!')) // true + * console.log(linkify.match('Site github.com!')) + * ``` + */ + constructor(options = {}) { + const { rebuilder, ...linkifyOptions } = options; + this.__opts__ = { + ...defaultOptions, + ...linkifyOptions + }; + this.__schemas__ = { ...defaultSchemas }; + this.re = rebuilder || new REBuilder(); + this.re.set({ + ...this.__opts__, + schema_names: Object.keys(this.__schemas__) + }); + } + /** + * Add new rule definition. + * + * `schema` is a link prefix (usually, protocol name with `:` at the end, + * `skype:` for example). `linkify-it` makes sure that prefix is not + * preceded with alphanumeric char and symbols. Only whitespaces and + * punctuation allowed. + * + * `definition` is a rule to check tail after link prefix. To disable an + * existing rule, pass `null`. + * + * @param schema Rule name (fixed pattern prefix). + * @param definition Schema definition, or `null` to disable the rule. + * + * See [twitter mentions example](https://github.com/markdown-it/linkify-it/blob/master/examples/twitter.mjs). + */ + add(schema, definition = null) { + if (!definition) delete this.__schemas__[schema]; + else { + const def = { + normalize: (match, self2) => self2.normalize(match), + ...definition + }; + this.__schemas__[schema] = def; + } + this.re.set({ + ...this.__opts__, + schema_names: Object.keys(this.__schemas__) + }); + return this; + } + /** + * Set recognition options for links without schema. + * + * @param options Recognition options. + */ + set(options = {}) { + this.__opts__ = { + ...this.__opts__, + ...options + }; + this.re.set({ + ...this.__opts__, + schema_names: Object.keys(this.__schemas__) + }); + return this; + } + /** + * Searches linkifiable pattern and returns `true` on success or `false` on fail. + * + * @param text Text to scan. + */ + test(text2) { + if (!text2.length) return false; + let m, re; + re = this.re.get_schema_search(); + re.lastIndex = 0; + while ((m = re.exec(text2)) !== null) if (this.testSchemaAt(text2, m[2], re.lastIndex)) return true; + if (this.__opts__.fuzzyLink && this.__schemas__["http:"]) { + re = this.re.get_fuzzy_link_search(); + re.lastIndex = 0; + if (re.exec(text2) !== null) return true; + } + if (this.__opts__.fuzzyEmail && this.__schemas__["mailto:"]) { + if (text2.indexOf("@") >= 0) { + const mailHostRe = this.re.get_fuzzy_mail_host_search(); + const mailNameRe = this.re.get_mail_name_validator(); + mailHostRe.lastIndex = 0; + while ((m = mailHostRe.exec(text2)) !== null) { + const name = text2.slice(Math.max(0, m.index - 65), m.index); + if (mailNameRe.test(name)) return true; + } + } + } + return false; + } + /** + * Similar to {@link LinkifyIt.test} but checks only specific protocol tail exactly + * at given position. Returns length of found pattern (0 on fail). + * + * @param text Text to scan. + * @param schema Rule (schema) name. + * @param pos Text offset to check from. + */ + testSchemaAt(text2, schema, pos) { + if (!this.__schemas__[schema.toLowerCase()]) return 0; + return this.__schemas__[schema.toLowerCase()].validate(text2.slice(0, pos + this.__opts__.maxLength), pos, this); + } + /** + * Returns array of found link descriptions or `null` on fail. We strongly + * recommend to use {@link LinkifyIt.test} first, for best speed. + * + * @param text Text to scan. + */ + match(text2) { + const result = []; + const schemaRe = this.re.get_schema_search(); + let fuzzyLinkRe; + let mailHostRe; + let mailNameRe; + let fuzzyLinkCandidate; + let fuzzyEmailCandidate; + let schemaPrefix; + let schemaDone = false; + let fuzzyLinkDone = false; + let fuzzyEmailDone = false; + let pos = 0; + if (!text2.length) return null; + schemaRe.lastIndex = 0; + if (this.__opts__.fuzzyLink && this.__schemas__["http:"]) { + fuzzyLinkRe = this.re.get_fuzzy_link_search(); + fuzzyLinkRe.lastIndex = 0; + } + if (this.__opts__.fuzzyEmail && this.__schemas__["mailto:"]) { + mailHostRe = this.re.get_fuzzy_mail_host_search(); + mailHostRe.lastIndex = 0; + mailNameRe = this.re.get_mail_name_validator(); + } + for (; ; ) { + const scanFrom = Math.max(pos - 1, 0); + if (mailHostRe && mailNameRe && !fuzzyEmailDone && (!fuzzyEmailCandidate || fuzzyEmailCandidate.index < pos)) { + if (mailHostRe.lastIndex < scanFrom) mailHostRe.lastIndex = scanFrom; + for (; ; ) { + const m = mailHostRe.exec(text2); + if (!m) { + fuzzyEmailDone = true; + fuzzyEmailCandidate = void 0; + break; + } + const name = mailNameRe.exec(text2.slice(Math.max(0, m.index - 65), m.index)); + if (!name) continue; + fuzzyEmailCandidate = { + schema: "mailto:", + index: m.index - name[1].length, + lastIndex: m.index + m[0].length + }; + if (fuzzyEmailCandidate.index >= pos) break; + if (mailHostRe.lastIndex < scanFrom) mailHostRe.lastIndex = scanFrom; + } + } + if (fuzzyLinkRe && !fuzzyLinkDone && (!fuzzyLinkCandidate || fuzzyLinkCandidate.index < pos)) { + if (fuzzyLinkRe.lastIndex < scanFrom) fuzzyLinkRe.lastIndex = scanFrom; + for (; ; ) { + const m = fuzzyLinkRe.exec(text2); + if (!m) { + fuzzyLinkDone = true; + fuzzyLinkCandidate = void 0; + break; + } + fuzzyLinkCandidate = { + schema: "", + index: m.index + m[1].length, + lastIndex: m.index + m[0].length + }; + if (fuzzyLinkCandidate.index >= pos) break; + if (fuzzyLinkRe.lastIndex < scanFrom) fuzzyLinkRe.lastIndex = scanFrom; + } + } + let fuzzyCandidate = fuzzyEmailCandidate; + if (!fuzzyCandidate || fuzzyLinkCandidate && (fuzzyLinkCandidate.index < fuzzyCandidate.index || fuzzyLinkCandidate.index === fuzzyCandidate.index && fuzzyLinkCandidate.lastIndex > fuzzyCandidate.lastIndex)) fuzzyCandidate = fuzzyLinkCandidate; + let schemaCandidate; + if (!schemaDone) for (; ; ) { + if (!schemaPrefix) { + if (schemaRe.lastIndex < scanFrom) schemaRe.lastIndex = scanFrom; + const m = schemaRe.exec(text2); + if (!m) { + schemaDone = true; + break; + } + schemaPrefix = { + schema: m[2], + index: m.index + m[1].length, + lastIndex: m.index + m[0].length + }; + } + if (schemaPrefix.index < pos) { + schemaPrefix = void 0; + continue; + } + if (fuzzyCandidate && schemaPrefix.index > fuzzyCandidate.index) break; + const prefix = schemaPrefix; + schemaPrefix = void 0; + const len = this.testSchemaAt(text2, prefix.schema, prefix.lastIndex); + if (len) { + schemaCandidate = { + schema: prefix.schema, + index: prefix.index, + lastIndex: prefix.lastIndex + len + }; + break; + } + } + let candidate = schemaCandidate; + if (!candidate || fuzzyEmailCandidate && (fuzzyEmailCandidate.index < candidate.index || fuzzyEmailCandidate.index === candidate.index && fuzzyEmailCandidate.lastIndex > candidate.lastIndex)) candidate = fuzzyEmailCandidate; + if (!candidate || fuzzyLinkCandidate && (fuzzyLinkCandidate.index < candidate.index || fuzzyLinkCandidate.index === candidate.index && fuzzyLinkCandidate.lastIndex > candidate.lastIndex)) candidate = fuzzyLinkCandidate; + if (!candidate) break; + if (candidate === fuzzyEmailCandidate) fuzzyEmailCandidate = void 0; + else if (candidate === fuzzyLinkCandidate) fuzzyLinkCandidate = void 0; + const match = new Match(text2, candidate.schema, candidate.index, candidate.lastIndex); + if (match.schema) this.__schemas__[match.schema].normalize(match, this); + else this.normalize(match); + result.push(match); + pos = candidate.lastIndex; + } + if (result.length) return result; + return null; + } + /** + * Returns fully-formed (not fuzzy) link if it starts at the beginning + * of the string, and null otherwise. + * + * @param text Text to scan. + */ + matchAtStart(text2) { + if (!text2.length) return null; + const m = this.re.get_schema_at_start().exec(text2); + if (!m) return null; + const len = this.testSchemaAt(text2, m[2], m[0].length); + if (!len) return null; + const match = new Match(text2, m[2], m.index + m[1].length, m.index + m[0].length + len); + this.__schemas__[match.schema].normalize(match, this); + return match; + } + /** + * Load (or merge) new TLDs list. Those are used for fuzzy links (without + * prefix) to avoid false positives. By default this algorithm is used: + * + * - hostname with any 2-letter root zones are ok. + * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф + * are ok. + * - encoded (`xn--...`) root zones are ok. + * + * If list is replaced, then exact match for 2-chars root zones will be checked. + * + * @param list List of TLDs. + * @param keepOld Merge with current list if `true` (`false` by default). + */ + tlds(list2, keepOld = false) { + list2 = Array.isArray(list2) ? list2 : [list2]; + if (!keepOld) this.__opts__.tlds = list2; + else this.__opts__.tlds = this.__opts__.tlds.concat(list2); + this.re.set({ + ...this.__opts__, + schema_names: Object.keys(this.__schemas__) + }); + return this; + } + /** + * Default normalizer (if schema does not define its own). + * + * @param match Match to normalize. + */ + normalize(match) { + if (!match.schema) match.url = `http://${match.url}`; + if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) match.url = `mailto:${match.url}`; + } +}; + +// node_modules/punycode.js/punycode.es6.js +var maxInt = 2147483647; +var base = 36; +var tMin = 1; +var tMax = 26; +var skew = 38; +var damp = 700; +var initialBias = 72; +var initialN = 128; +var delimiter = "-"; +var regexPunycode = /^xn--/; +var regexNonASCII = /[^\0-\x7F]/; +var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; +var errors = { + "overflow": "Overflow: input needs wider integers to process", + "not-basic": "Illegal input >= 0x80 (not a basic code point)", + "invalid-input": "Invalid input" +}; +var baseMinusTMin = base - tMin; +var floor = Math.floor; +var stringFromCharCode = String.fromCharCode; +function error(type) { + throw new RangeError(errors[type]); +} +function map(array, callback) { + const result = []; + let length = array.length; + while (length--) { + result[length] = callback(array[length]); + } + return result; +} +function mapDomain(domain, callback) { + const parts = domain.split("@"); + let result = ""; + if (parts.length > 1) { + result = parts[0] + "@"; + domain = parts[1]; + } + domain = domain.replace(regexSeparators, "."); + const labels = domain.split("."); + const encoded = map(labels, callback).join("."); + return result + encoded; +} +function ucs2decode(string) { + const output = []; + let counter = 0; + const length = string.length; + while (counter < length) { + const value = string.charCodeAt(counter++); + if (value >= 55296 && value <= 56319 && counter < length) { + const extra = string.charCodeAt(counter++); + if ((extra & 64512) == 56320) { + output.push(((value & 1023) << 10) + (extra & 1023) + 65536); + } else { + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; +} +var ucs2encode = (codePoints) => String.fromCodePoint(...codePoints); +var basicToDigit = function(codePoint) { + if (codePoint >= 48 && codePoint < 58) { + return 26 + (codePoint - 48); + } + if (codePoint >= 65 && codePoint < 91) { + return codePoint - 65; + } + if (codePoint >= 97 && codePoint < 123) { + return codePoint - 97; + } + return base; +}; +var digitToBasic = function(digit, flag) { + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); +}; +var adapt = function(delta, numPoints, firstTime) { + let k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); +}; +var decode2 = function(input) { + const output = []; + const inputLength = input.length; + let i = 0; + let n = initialN; + let bias = initialBias; + let basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + for (let j = 0; j < basic; ++j) { + if (input.charCodeAt(j) >= 128) { + error("not-basic"); + } + output.push(input.charCodeAt(j)); + } + for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) { + const oldi = i; + for (let w = 1, k = base; ; k += base) { + if (index >= inputLength) { + error("invalid-input"); + } + const digit = basicToDigit(input.charCodeAt(index++)); + if (digit >= base) { + error("invalid-input"); + } + if (digit > floor((maxInt - i) / w)) { + error("overflow"); + } + i += digit * w; + const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; + if (digit < t) { + break; + } + const baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error("overflow"); + } + w *= baseMinusT; + } + const out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + if (floor(i / out) > maxInt - n) { + error("overflow"); + } + n += floor(i / out); + i %= out; + output.splice(i++, 0, n); + } + return String.fromCodePoint(...output); +}; +var encode2 = function(input) { + const output = []; + input = ucs2decode(input); + const inputLength = input.length; + let n = initialN; + let delta = 0; + let bias = initialBias; + for (const currentValue of input) { + if (currentValue < 128) { + output.push(stringFromCharCode(currentValue)); + } + } + const basicLength = output.length; + let handledCPCount = basicLength; + if (basicLength) { + output.push(delimiter); + } + while (handledCPCount < inputLength) { + let m = maxInt; + for (const currentValue of input) { + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + const handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error("overflow"); + } + delta += (m - n) * handledCPCountPlusOne; + n = m; + for (const currentValue of input) { + if (currentValue < n && ++delta > maxInt) { + error("overflow"); + } + if (currentValue === n) { + let q = delta; + for (let k = base; ; k += base) { + const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; + if (q < t) { + break; + } + const qMinusT = q - t; + const baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength); + delta = 0; + ++handledCPCount; + } + } + ++delta; + ++n; + } + return output.join(""); +}; +var toUnicode = function(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) ? decode2(string.slice(4).toLowerCase()) : string; + }); +}; +var toASCII = function(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) ? "xn--" + encode2(string) : string; + }); +}; +var punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + "version": "2.3.1", + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + "ucs2": { + "decode": ucs2decode, + "encode": ucs2encode + }, + "decode": decode2, + "encode": encode2, + "toASCII": toASCII, + "toUnicode": toUnicode +}; +var punycode_es6_default = punycode; + +// node_modules/markdown-it/dist/markdown-it.mjs +var __defProp2 = Object.defineProperty; +var __exportAll = (all, no_symbols) => { + let target = {}; + for (var name in all) __defProp2(target, name, { + get: all[name], + enumerable: true + }); + if (!no_symbols) __defProp2(target, Symbol.toStringTag, { value: "Module" }); + return target; +}; +var utils_exports = /* @__PURE__ */ __exportAll({ + arrayReplaceAt: () => arrayReplaceAt, + asciiTrim: () => asciiTrim, + callable: () => callable, + escapeHtml: () => escapeHtml, + escapeRE: () => escapeRE, + fromCodePoint: () => fromCodePoint, + isMdAsciiPunct: () => isMdAsciiPunct, + isPunctChar: () => isPunctChar, + isPunctCharCode: () => isPunctCharCode, + isSpace: () => isSpace, + isValidEntityCode: () => isValidEntityCode, + isWhiteSpace: () => isWhiteSpace, + lib: () => lib, + normalizeReference: () => normalizeReference, + unescapeAll: () => unescapeAll, + unescapeMd: () => unescapeMd +}); +function callable(cls) { + const wrapper = function(...args) { + return Reflect.construct(cls, args, new.target && new.target !== wrapper ? new.target : cls); + }; + Object.defineProperty(wrapper, "name", { value: cls.name }); + Object.setPrototypeOf(wrapper, cls); + wrapper.prototype = cls.prototype; + return wrapper; +} +function arrayReplaceAt(src, pos, newElements) { + return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1)); +} +function isValidEntityCode(c) { + if (c >= 55296 && c <= 57343) return false; + if (c >= 64976 && c <= 65007) return false; + if ((c & 65535) === 65535 || (c & 65535) === 65534) return false; + if (c >= 0 && c <= 8) return false; + if (c === 11) return false; + if (c >= 14 && c <= 31) return false; + if (c >= 127 && c <= 159) return false; + if (c > 1114111) return false; + return true; +} +function fromCodePoint(c) { + if (c > 65535) { + c -= 65536; + const surrogate1 = 55296 + (c >> 10); + const surrogate2 = 56320 + (c & 1023); + return String.fromCharCode(surrogate1, surrogate2); + } + return String.fromCharCode(c); +} +var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g; +var UNESCAPE_ALL_RE = new RegExp(`${UNESCAPE_MD_RE.source}|${/&([a-z#][a-z0-9]{1,31});/gi.source}`, "gi"); +var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i; +function replaceEntityPattern(match, name) { + if (name.charCodeAt(0) === 35 && DIGITAL_ENTITY_TEST_RE.test(name)) { + const code2 = name[1].toLowerCase() === "x" ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10); + if (isValidEntityCode(code2)) return fromCodePoint(code2); + return match; + } + const decoded = decodeHTMLStrict(match); + if (decoded !== match) return decoded; + return match; +} +function unescapeMd(str) { + if (str.indexOf("\\") < 0) return str; + return str.replace(UNESCAPE_MD_RE, "$1"); +} +function unescapeAll(str) { + if (str.indexOf("\\") < 0 && str.indexOf("&") < 0) return str; + return str.replace(UNESCAPE_ALL_RE, function(match, escaped, entity2) { + if (escaped) return escaped; + return replaceEntityPattern(match, entity2); + }); +} +var HTML_ESCAPE_TEST_RE = /[&<>"]/; +var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g; +var HTML_REPLACEMENTS = { + "&": "&", + "<": "<", + ">": ">", + '"': """ +}; +function replaceUnsafeChar(ch) { + return HTML_REPLACEMENTS[ch]; +} +function escapeHtml(str) { + if (HTML_ESCAPE_TEST_RE.test(str)) return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); + return str; +} +var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g; +function escapeRE(str) { + return str.replace(REGEXP_ESCAPE_RE, "\\$&"); +} +function isSpace(code2) { + switch (code2) { + case 9: + case 32: + return true; + } + return false; +} +function isWhiteSpace(code2) { + if (code2 >= 8192 && code2 <= 8202) return true; + switch (code2) { + case 9: + case 10: + case 11: + case 12: + case 13: + case 32: + case 160: + case 5760: + case 8239: + case 8287: + case 12288: + return true; + } + return false; +} +function isPunctChar(ch) { + return P.test(ch) || S.test(ch); +} +function isPunctCharCode(code2) { + return isPunctChar(fromCodePoint(code2)); +} +function isMdAsciiPunct(ch) { + switch (ch) { + case 33: + case 34: + case 35: + case 36: + case 37: + case 38: + case 39: + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 58: + case 59: + case 60: + case 61: + case 62: + case 63: + case 64: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 123: + case 124: + case 125: + case 126: + return true; + default: + return false; + } +} +function normalizeReference(str) { + str = str.trim().replace(/\s+/g, " "); + return str.toLowerCase().toUpperCase(); +} +function isAsciiTrimmable(c) { + return c === 32 || c === 9 || c === 10 || c === 13; +} +function asciiTrim(str) { + let start = 0; + for (; start < str.length; start++) if (!isAsciiTrimmable(str.charCodeAt(start))) break; + let end = str.length - 1; + for (; end >= start; end--) if (!isAsciiTrimmable(str.charCodeAt(end))) break; + return str.slice(start, end + 1); +} +var lib = { + mdurl: mdurl_exports, + ucmicro: build_exports +}; +function parseLinkLabel(state, start, disableNested) { + let level, found, marker, prevPos; + const max = state.posMax; + const oldPos = state.pos; + state.pos = start + 1; + level = 1; + while (state.pos < max) { + marker = state.src.charCodeAt(state.pos); + if (marker === 93) { + level--; + if (level === 0) { + found = true; + break; + } + } + prevPos = state.pos; + state.md.inline.skipToken(state); + if (marker === 91) { + if (prevPos === state.pos - 1) level++; + else if (disableNested) { + state.pos = oldPos; + return -1; + } + } + } + let labelEnd = -1; + if (found) labelEnd = state.pos; + state.pos = oldPos; + return labelEnd; +} +function parseLinkDestination(str, start, max) { + let code2; + let pos = start; + const result = { + ok: false, + pos: 0, + str: "" + }; + if (str.charCodeAt(pos) === 60) { + pos++; + while (pos < max) { + code2 = str.charCodeAt(pos); + if (code2 === 10) return result; + if (code2 === 60) return result; + if (code2 === 62) { + result.pos = pos + 1; + result.str = unescapeAll(str.slice(start + 1, pos)); + result.ok = true; + return result; + } + if (code2 === 92 && pos + 1 < max) { + pos += 2; + continue; + } + pos++; + } + return result; + } + let level = 0; + while (pos < max) { + code2 = str.charCodeAt(pos); + if (code2 === 32) break; + if (code2 < 32 || code2 === 127) break; + if (code2 === 92 && pos + 1 < max) { + if (str.charCodeAt(pos + 1) === 32) { + pos++; + continue; + } + pos += 2; + continue; + } + if (code2 === 40) { + level++; + if (level > 32) return result; + } + if (code2 === 41) { + if (level === 0) break; + level--; + } + pos++; + } + if (start === pos) return result; + if (level !== 0) return result; + result.str = unescapeAll(str.slice(start, pos)); + result.pos = pos; + result.ok = true; + return result; +} +function parseLinkTitle(str, start, max, prev_state) { + let code2; + let pos = start; + const state = { + ok: false, + can_continue: false, + pos: 0, + str: "", + marker: 0 + }; + if (prev_state) { + state.str = prev_state.str; + state.marker = prev_state.marker; + } else { + if (pos >= max) return state; + let marker = str.charCodeAt(pos); + if (marker !== 34 && marker !== 39 && marker !== 40) return state; + start++; + pos++; + if (marker === 40) marker = 41; + state.marker = marker; + } + while (pos < max) { + code2 = str.charCodeAt(pos); + if (code2 === state.marker) { + state.pos = pos + 1; + state.str += unescapeAll(str.slice(start, pos)); + state.ok = true; + return state; + } else if (code2 === 40 && state.marker === 41) return state; + else if (code2 === 92 && pos + 1 < max) pos++; + pos++; + } + state.can_continue = true; + state.str += unescapeAll(str.slice(start, pos)); + return state; +} +var helpers_exports = /* @__PURE__ */ __exportAll({ + parseLinkDestination: () => parseLinkDestination, + parseLinkLabel: () => parseLinkLabel, + parseLinkTitle: () => parseLinkTitle +}); +function _typeof(o) { + "@babel/helpers - typeof"; + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { + return typeof o2; + } : function(o2) { + return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; + }, _typeof(o); +} +function toPrimitive(t, r) { + if ("object" != _typeof(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r || "default"); + if ("object" != _typeof(i)) return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return ("string" === r ? String : Number)(t); +} +function toPropertyKey(t) { + var i = toPrimitive(t, "string"); + return "symbol" == _typeof(i) ? i : i + ""; +} +function _defineProperty(e, r, t) { + return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: true, + configurable: true, + writable: true + }) : e[r] = t, e; +} +var Token = class { + constructor(type, tag, nesting) { + _defineProperty( + this, + /** + * Source map info. Format: `[ line_begin, line_end ]` + */ + "map", + null + ); + _defineProperty( + this, + /** + * nesting level, the same as `state.level` + */ + "level", + 0 + ); + _defineProperty( + this, + /** + * An array of child nodes (inline and img tokens) + */ + "children", + null + ); + _defineProperty( + this, + /** + * In a case of self-closing tag (code, html, fence, etc.), + * it has contents of this tag. + */ + "content", + "" + ); + _defineProperty( + this, + /** + * '*' or '_' for emphasis, fence string for fence, etc. + */ + "markup", + "" + ); + _defineProperty( + this, + /** + * Additional information: + * + * - Info string for "fence" tokens + * - The value "auto" for autolink "link_open" and "link_close" tokens + * - The string value of the item marker for ordered-list "list_item_open" tokens + */ + "info", + "" + ); + _defineProperty( + this, + /** + * True for block-level tokens, false for inline tokens. + * Used in renderer to calculate line breaks + */ + "block", + false + ); + _defineProperty( + this, + /** + * If it's true, ignore this element when rendering. Used for tight lists + * to hide paragraphs. + */ + "hidden", + false + ); + this.type = type; + this.tag = tag; + this.attrs = null; + this.nesting = nesting; + this.meta = null; + } + /** + * Search attribute index by name. + */ + attrIndex(name) { + if (!this.attrs) return -1; + const attrs = this.attrs; + for (let i = 0, len = attrs.length; i < len; i++) if (attrs[i][0] === name) return i; + return -1; + } + /** + * Add `[ name, value ]` attribute to list. Init attrs if necessary + */ + attrPush(attrData) { + if (this.attrs) this.attrs.push(attrData); + else this.attrs = [attrData]; + } + /** + * Set `name` attribute to `value`. Override old value if exists. + */ + attrSet(name, value) { + const idx = this.attrIndex(name); + const attrData = [name, value]; + if (idx < 0) this.attrPush(attrData); + else this.attrs[idx] = attrData; + } + /** + * Get the value of attribute `name`, or null if it does not exist. + */ + attrGet(name) { + const idx = this.attrIndex(name); + let value = null; + if (idx >= 0) value = this.attrs[idx][1]; + return value; + } + /** + * Join value to existing attribute via space. Or create new attribute if not + * exists. Useful to operate with token classes. + */ + attrJoin(name, value) { + const idx = this.attrIndex(name); + if (idx < 0) this.attrPush([name, value]); + else this.attrs[idx][1] = `${this.attrs[idx][1]} ${value}`; + } +}; +var Ruler = class { + constructor() { + _defineProperty(this, "__rules__", []); + _defineProperty(this, "__cache__", null); + } + __find__(name) { + for (let i = 0; i < this.__rules__.length; i++) if (this.__rules__[i].name === name) return i; + return -1; + } + __compile__() { + const chains = /* @__PURE__ */ new Set(); + this.__rules__.forEach((rule) => { + if (!rule.enabled) return; + rule.alt.forEach((altName) => { + if (altName) chains.add(altName); + }); + }); + this.__cache__ = /* @__PURE__ */ Object.create(null); + this.__cache__[""] = []; + this.__rules__.forEach((rule) => { + if (rule.enabled) this.__cache__[""].push(rule.fn); + }); + chains.forEach((chain) => { + this.__cache__[chain] = []; + this.__rules__.forEach((rule) => { + if (rule.enabled && rule.alt.indexOf(chain) >= 0) this.__cache__[chain].push(rule.fn); + }); + }); + } + /** + * Replace rule by name with new function & options. Throws error if name not + * found. + * + * @param name Rule name to replace. + * @param fn New rule function. + * @param options Rule options. `alt` is an array with names of "alternate" + * chains. + * + * @example Replace existing typographer replacement rule with new one + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * md.core.ruler.at('replacements', function replace(state) { + * //... + * }); + * ``` + */ + at(name, fn, options = {}) { + const index = this.__find__(name); + if (index === -1) throw new Error(`Parser rule not found: ${name}`); + this.__rules__[index].fn = fn; + this.__rules__[index].alt = options.alt || []; + this.__cache__ = null; + } + /** + * Add new rule to chain before one with given name. See also + * {@link Ruler.after}, {@link Ruler.push}. + * + * @param beforeName New rule will be added before this one. + * @param ruleName Name of added rule. + * @param fn Rule function. + * @param options Rule options. `alt` is an array with names of "alternate" + * chains. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * md.block.ruler.before('paragraph', 'my_rule', function replace(state) { + * //... + * }); + * ``` + */ + before(beforeName, ruleName, fn, options = {}) { + const index = this.__find__(beforeName); + if (index === -1) throw new Error(`Parser rule not found: ${beforeName}`); + this.__rules__.splice(index, 0, { + name: ruleName, + enabled: true, + fn, + alt: options.alt || [] + }); + this.__cache__ = null; + } + /** + * Add new rule to chain after one with given name. See also + * {@link Ruler.before}, {@link Ruler.push}. + * + * @param afterName New rule will be added after this one. + * @param ruleName Name of added rule. + * @param fn Rule function. + * @param options Rule options. `alt` is an array with names of "alternate" + * chains. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * md.inline.ruler.after('text', 'my_rule', function replace(state) { + * //... + * }); + * ``` + */ + after(afterName, ruleName, fn, options = {}) { + const index = this.__find__(afterName); + if (index === -1) throw new Error(`Parser rule not found: ${afterName}`); + this.__rules__.splice(index + 1, 0, { + name: ruleName, + enabled: true, + fn, + alt: options.alt || [] + }); + this.__cache__ = null; + } + /** + * Push new rule to the end of chain. See also + * {@link Ruler.before}, {@link Ruler.after}. + * + * @param ruleName Name of added rule. + * @param fn Rule function. + * @param options Rule options. `alt` is an array with names of "alternate" + * chains. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * md.core.ruler.push('my_rule', function replace(state) { + * //... + * }); + * ``` + */ + push(ruleName, fn, options = {}) { + this.__rules__.push({ + name: ruleName, + enabled: true, + fn, + alt: options.alt || [] + }); + this.__cache__ = null; + } + /** + * Enable rules with given names. If any rule name not found - throw Error. + * Errors can be disabled by second param. + * + * See also {@link Ruler.disable}, {@link Ruler.enableOnly}. + * + * @param list List of rule names to enable. + * @param ignoreInvalid Set `true` to ignore errors when rule not found. + * @returns List of found rule names (if no exception happened). + */ + enable(list2, ignoreInvalid = false) { + if (!Array.isArray(list2)) list2 = [list2]; + const result = []; + list2.forEach((name) => { + const idx = this.__find__(name); + if (idx < 0) { + if (ignoreInvalid) return; + throw new Error(`Rules manager: invalid rule name ${name}`); + } + this.__rules__[idx].enabled = true; + result.push(name); + }); + this.__cache__ = null; + return result; + } + /** + * Enable rules with given names, and disable everything else. If any rule name + * not found - throw Error. Errors can be disabled by second param. + * + * See also {@link Ruler.disable}, {@link Ruler.enable}. + * + * @param list List of rule names to enable (whitelist). + * @param ignoreInvalid Set `true` to ignore errors when rule not found. + */ + enableOnly(list2, ignoreInvalid = false) { + if (!Array.isArray(list2)) list2 = [list2]; + this.__rules__.forEach((rule) => { + rule.enabled = false; + }); + this.enable(list2, ignoreInvalid); + } + /** + * Disable rules with given names. If any rule name not found - throw Error. + * Errors can be disabled by second param. + * + * See also {@link Ruler.enable}, {@link Ruler.enableOnly}. + * + * @param list List of rule names to disable. + * @param ignoreInvalid Set `true` to ignore errors when rule not found. + * @returns List of found rule names (if no exception happened). + */ + disable(list2, ignoreInvalid = false) { + if (!Array.isArray(list2)) list2 = [list2]; + const result = []; + list2.forEach((name) => { + const idx = this.__find__(name); + if (idx < 0) { + if (ignoreInvalid) return; + throw new Error(`Rules manager: invalid rule name ${name}`); + } + this.__rules__[idx].enabled = false; + result.push(name); + }); + this.__cache__ = null; + return result; + } + /** + * Return array of active functions (rules) for given chain name. It analyzes + * rules configuration, compiles caches if not exists and returns result. + * + * Default chain name is `''` (empty string). It can't be skipped. That's + * done intentionally, to keep signature monomorphic for high speed. + */ + getRules(chainName) { + if (!this.__cache__) this.__compile__(); + return this.__cache__[chainName] || []; + } +}; +var default_rules = {}; +default_rules.code_inline = function(tokens, idx, options, env, slf) { + const token = tokens[idx]; + return `${escapeHtml(token.content)}`; +}; +default_rules.code_block = function(tokens, idx, options, env, slf) { + const token = tokens[idx]; + return `${escapeHtml(tokens[idx].content)} +`; +}; +default_rules.fence = function(tokens, idx, options, env, slf) { + const token = tokens[idx]; + const info = token.info ? unescapeAll(token.info).trim() : ""; + let langName = ""; + let langAttrs = ""; + if (info) { + const arr = info.split(/(\s+)/g); + langName = arr[0]; + langAttrs = arr.slice(2).join(""); + } + let highlighted; + if (options.highlight) highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content); + else highlighted = escapeHtml(token.content); + if (highlighted.indexOf("${highlighted} +`; + } + return `
${highlighted}
+`; +}; +default_rules.image = function(tokens, idx, options, env, slf) { + const token = tokens[idx]; + token.attrs[token.attrIndex("alt")][1] = slf.renderInlineAsText(token.children, options, env); + return slf.renderToken(tokens, idx, options); +}; +default_rules.hardbreak = function(tokens, idx, options) { + return options.xhtmlOut ? "
\n" : "
\n"; +}; +default_rules.softbreak = function(tokens, idx, options) { + return options.breaks ? options.xhtmlOut ? "
\n" : "
\n" : "\n"; +}; +default_rules.text = function(tokens, idx) { + return escapeHtml(tokens[idx].content); +}; +default_rules.html_block = function(tokens, idx) { + return tokens[idx].content; +}; +default_rules.html_inline = function(tokens, idx) { + return tokens[idx].content; +}; +var Renderer = class { + constructor() { + _defineProperty( + this, + /** + * Contains render rules for tokens. Can be updated and extended. + * + * See [source code](https://github.com/markdown-it/markdown-it/blob/master/src/renderer.ts) + * for more details and examples. + * + * @example Custom render rules + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * md.renderer.rules.strong_open = function () { return ''; }; + * md.renderer.rules.strong_close = function () { return ''; }; + * + * const result = md.renderInline(...); + * ``` + * + * @example Each rule is called as independent static function with fixed signature + * ```javascript + * function my_token_render(tokens, idx, options, env, renderer) { + * // ... + * return renderedHTML; + * } + * ``` + */ + "rules", + Object.assign({}, default_rules) + ); + } + /** + * Render token attributes to string. + */ + renderAttrs(token) { + let i, l, result; + if (!token.attrs) return ""; + result = ""; + for (i = 0, l = token.attrs.length; i < l; i++) result += ` ${escapeHtml(token.attrs[i][0])}="${escapeHtml(String(token.attrs[i][1]))}"`; + return result; + } + /** + * Default token renderer. Can be overriden by custom function + * in {@link Renderer.rules}. + * + * @param tokens List of tokens. + * @param idx Token index to render. + * @param options Params of parser instance. + */ + renderToken(tokens, idx, options) { + const token = tokens[idx]; + let result = ""; + if (token.hidden) return ""; + let prev = idx - 1; + while (prev >= 0 && tokens[prev].hidden && tokens[prev].nesting === 0) prev--; + if (token.block && token.nesting !== -1 && prev >= 0 && tokens[prev].hidden && tokens[prev].nesting === -1) result += "\n"; + result += (token.nesting === -1 ? "\n" : ">"; + return result; + } + /** + * The same as {@link Renderer.render}, but for single token of `inline` type. + * + * @param tokens List on block tokens to render. + * @param options Params of parser instance. + * @param env Additional data from parsed input (references, for example). + */ + renderInline(tokens, options, env) { + let result = ""; + const rules = this.rules; + for (let i = 0, len = tokens.length; i < len; i++) { + const type = tokens[i].type; + if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this); + else result += this.renderToken(tokens, i, options); + } + return result; + } + /** + * Special kludge for image `alt` attributes to conform CommonMark spec. + * Don't try to use it! Spec requires to show `alt` content with stripped markup, + * instead of simple escaping. + * + * @param tokens List on block tokens to render. + * @param options Params of parser instance. + * @param env Additional data from parsed input (references, for example). + */ + renderInlineAsText(tokens, options, env) { + let result = ""; + for (let i = 0, len = tokens.length; i < len; i++) switch (tokens[i].type) { + case "text": + case "code_inline": + result += tokens[i].content; + break; + case "image": + result += this.renderInlineAsText(tokens[i].children, options, env); + break; + case "html_inline": + case "html_block": + result += tokens[i].content; + break; + case "softbreak": + case "hardbreak": + result += "\n"; + } + return result; + } + /** + * Takes token stream and generates HTML. Probably, you will never need to call + * this method directly. + * + * @param tokens List on block tokens to render. + * @param options Params of parser instance. + * @param env Additional data from parsed input (references, for example). + */ + render(tokens, options, env) { + let result = ""; + const rules = this.rules; + for (let i = 0, len = tokens.length; i < len; i++) { + const type = tokens[i].type; + if (type === "inline") result += this.renderInline(tokens[i].children, options, env); + else if (typeof rules[type] !== "undefined") result += rules[type](tokens, i, options, env, this); + else result += this.renderToken(tokens, i, options); + } + return result; + } +}; +var StateCore = class { + constructor(src, md, env) { + _defineProperty(this, "tokens", []); + _defineProperty(this, "inlineMode", false); + _defineProperty(this, "Token", Token); + this.src = src; + this.env = env; + this.md = md; + } +}; +var NEWLINES_RE = /\r\n?|\n/g; +var NULL_RE = /\0/g; +function normalize(state) { + let str; + str = state.src.replace(NEWLINES_RE, "\n"); + str = str.replace(NULL_RE, "\uFFFD"); + state.src = str; +} +function block(state) { + let token; + if (state.inlineMode) { + token = new state.Token("inline", "", 0); + token.content = state.src; + token.map = [0, 1]; + token.children = []; + state.tokens.push(token); + } else state.md.block.parse(state.src, state.md, state.env, state.tokens); +} +function strip_references(state) { + const tokens = state.tokens; + let last = 0; + for (let curr = 0; curr < tokens.length; curr++) { + if (tokens[curr].type === "reference_definition") continue; + if (curr !== last) tokens[last] = tokens[curr]; + last++; + } + if (tokens.length !== last) tokens.length = last; +} +function inline(state) { + const tokens = state.tokens; + for (let i = 0, l = tokens.length; i < l; i++) { + const tok = tokens[i]; + if (tok.type === "inline") state.md.inline.parse(tok.content, state.md, state.env, tok.children); + } +} +function isLinkOpen$1(str) { + return /^\s]/i.test(str); +} +function isLinkClose$1(str) { + return /^<\/a\s*>/i.test(str); +} +function linkify$1(state) { + const blockTokens = state.tokens; + if (!state.md.options.linkify) return; + for (let j = 0, l = blockTokens.length; j < l; j++) { + if (blockTokens[j].type !== "inline" || !state.md.linkify.test(blockTokens[j].content)) continue; + let tokens = blockTokens[j].children; + let htmlLinkLevel = 0; + for (let i = tokens.length - 1; i >= 0; i--) { + const currentToken = tokens[i]; + if (currentToken.type === "link_close") { + i--; + while (tokens[i].level !== currentToken.level && tokens[i].type !== "link_open") i--; + continue; + } + if (currentToken.type === "html_inline") { + if (isLinkOpen$1(currentToken.content) && htmlLinkLevel > 0) htmlLinkLevel--; + if (isLinkClose$1(currentToken.content)) htmlLinkLevel++; + } + if (htmlLinkLevel > 0) continue; + if (currentToken.type === "text" && state.md.linkify.test(currentToken.content)) { + const text2 = currentToken.content; + let links = state.md.linkify.match(text2); + const nodes = []; + let level = currentToken.level; + let lastPos = 0; + if (links.length > 0 && links[0].index === 0 && i > 0 && tokens[i - 1].type === "text_special") links = links.slice(1); + for (let ln = 0; ln < links.length; ln++) { + const url = links[ln].url; + const fullUrl = state.md.normalizeLink(url); + if (!state.md.validateLink(fullUrl)) continue; + let urlText = links[ln].text; + if (!links[ln].schema) urlText = state.md.normalizeLinkText(`http://${urlText}`).replace(/^http:\/\//, ""); + else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) urlText = state.md.normalizeLinkText(`mailto:${urlText}`).replace(/^mailto:/, ""); + else urlText = state.md.normalizeLinkText(urlText); + const pos = links[ln].index; + if (pos > lastPos) { + const token = new state.Token("text", "", 0); + token.content = text2.slice(lastPos, pos); + token.level = level; + nodes.push(token); + } + const token_o = new state.Token("link_open", "a", 1); + token_o.attrs = [["href", fullUrl]]; + token_o.level = level++; + token_o.markup = "linkify"; + token_o.info = "auto"; + nodes.push(token_o); + const token_t = new state.Token("text", "", 0); + token_t.content = urlText; + token_t.level = level; + nodes.push(token_t); + const token_c = new state.Token("link_close", "a", -1); + token_c.level = --level; + token_c.markup = "linkify"; + token_c.info = "auto"; + nodes.push(token_c); + lastPos = links[ln].lastIndex; + } + if (lastPos < text2.length) { + const token = new state.Token("text", "", 0); + token.content = text2.slice(lastPos); + token.level = level; + nodes.push(token); + } + blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes); + } + } + } +} +var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/; +var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i; +var SCOPED_ABBR_RE = /\((c|tm|r)\)/gi; +var SCOPED_ABBR = { + c: "\xA9", + r: "\xAE", + tm: "\u2122" +}; +function replaceFn(match, name) { + return SCOPED_ABBR[name.toLowerCase()]; +} +function replace_scoped(inlineTokens) { + let inside_autolink = 0; + for (let i = inlineTokens.length - 1; i >= 0; i--) { + const token = inlineTokens[i]; + if (token.type === "text" && !inside_autolink) token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn); + if (token.type === "link_open" && token.info === "auto") inside_autolink--; + if (token.type === "link_close" && token.info === "auto") inside_autolink++; + } +} +function replace_rare(inlineTokens) { + let inside_autolink = 0; + for (let i = inlineTokens.length - 1; i >= 0; i--) { + const token = inlineTokens[i]; + if (token.type === "text" && !inside_autolink) { + if (RARE_RE.test(token.content)) token.content = token.content.replace(/\+-/g, "\xB1").replace(/\.{2,}/g, "\u2026").replace(/([?!])…/g, "$1..").replace(/([?!]){4,}/g, "$1$1$1").replace(/,{2,}/g, ",").replace(/(^|[^-])---(?=[^-]|$)/gm, "$1\u2014").replace(/(^|\s)--(?=\s|$)/gm, "$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm, "$1\u2013"); + } + if (token.type === "link_open" && token.info === "auto") inside_autolink--; + if (token.type === "link_close" && token.info === "auto") inside_autolink++; + } +} +function replace(state) { + let blkIdx; + if (!state.md.options.typographer) return; + for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) { + if (state.tokens[blkIdx].type !== "inline") continue; + if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) replace_scoped(state.tokens[blkIdx].children); + if (RARE_RE.test(state.tokens[blkIdx].content)) replace_rare(state.tokens[blkIdx].children); + } +} +var QUOTE_TEST_RE = /['"]/; +var QUOTE_RE = /['"]/g; +var APOSTROPHE = "\u2019"; +function addReplacement(replacements, tokenIdx, pos, ch) { + if (!replacements[tokenIdx]) replacements[tokenIdx] = []; + replacements[tokenIdx].push({ + pos, + ch + }); +} +function applyReplacements(str, replacements) { + let result = ""; + let lastPos = 0; + replacements.sort((a, b) => a.pos - b.pos); + for (let i = 0; i < replacements.length; i++) { + const replacement = replacements[i]; + result += str.slice(lastPos, replacement.pos) + replacement.ch; + lastPos = replacement.pos + 1; + } + return result + str.slice(lastPos); +} +function process_inlines(tokens, state) { + let j; + const stack = []; + const replacements = {}; + for (let i = 0; i < tokens.length; i++) { + const token = tokens[i]; + const thisLevel = tokens[i].level; + for (j = stack.length - 1; j >= 0; j--) if (stack[j].level <= thisLevel) break; + stack.length = j + 1; + if (token.type !== "text") continue; + const text2 = token.content; + let pos = 0; + const max = text2.length; + OUTER: while (pos < max) { + QUOTE_RE.lastIndex = pos; + const t = QUOTE_RE.exec(text2); + if (!t) break; + let canOpen = true; + let canClose = true; + pos = t.index + 1; + const isSingle = t[0] === "'"; + let lastChar = 32; + if (t.index - 1 >= 0) lastChar = text2.charCodeAt(t.index - 1); + else for (j = i - 1; j >= 0; j--) { + if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break; + if (!tokens[j].content) continue; + lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1); + break; + } + let nextChar = 32; + if (pos < max) nextChar = text2.charCodeAt(pos); + else for (j = i + 1; j < tokens.length; j++) { + if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break; + if (!tokens[j].content) continue; + nextChar = tokens[j].content.charCodeAt(0); + break; + } + const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar); + const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar); + const isLastWhiteSpace = isWhiteSpace(lastChar); + const isNextWhiteSpace = isWhiteSpace(nextChar); + if (isNextWhiteSpace) canOpen = false; + else if (isNextPunctChar) { + if (!(isLastWhiteSpace || isLastPunctChar)) canOpen = false; + } + if (isLastWhiteSpace) canClose = false; + else if (isLastPunctChar) { + if (!(isNextWhiteSpace || isNextPunctChar)) canClose = false; + } + if (nextChar === 34 && t[0] === '"') { + if (lastChar >= 48 && lastChar <= 57) canClose = canOpen = false; + } + if (canOpen && canClose) { + canOpen = isLastPunctChar; + canClose = isNextPunctChar; + } + if (!canOpen && !canClose) { + if (isSingle) addReplacement(replacements, i, t.index, APOSTROPHE); + continue; + } + if (canClose) for (j = stack.length - 1; j >= 0; j--) { + let item = stack[j]; + if (stack[j].level < thisLevel) break; + if (item.single === isSingle && stack[j].level === thisLevel) { + item = stack[j]; + let openQuote; + let closeQuote; + if (isSingle) { + openQuote = state.md.options.quotes[2]; + closeQuote = state.md.options.quotes[3]; + } else { + openQuote = state.md.options.quotes[0]; + closeQuote = state.md.options.quotes[1]; + } + addReplacement(replacements, i, t.index, closeQuote); + addReplacement(replacements, item.token, item.pos, openQuote); + stack.length = j; + continue OUTER; + } + } + if (canOpen) stack.push({ + token: i, + pos: t.index, + single: isSingle, + level: thisLevel + }); + else if (canClose && isSingle) addReplacement(replacements, i, t.index, APOSTROPHE); + } + } + Object.keys(replacements).forEach(function(tokenIdx) { + const idx = Number(tokenIdx); + tokens[idx].content = applyReplacements(tokens[idx].content, replacements[tokenIdx]); + }); +} +function smartquotes(state) { + if (!state.md.options.typographer) return; + for (let blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) { + if (state.tokens[blkIdx].type !== "inline" || !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) continue; + process_inlines(state.tokens[blkIdx].children, state); + } +} +function join_alt(tokens) { + let curr, last; + const max = tokens.length; + for (curr = 0; curr < max; curr++) if (tokens[curr].type === "text_special") tokens[curr].type = "text"; + for (curr = last = 0; curr < max; curr++) if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content; + else { + if (curr !== last) tokens[last] = tokens[curr]; + last++; + } + if (curr !== last) tokens.length = last; +} +function text_join(state) { + let curr, last; + const blockTokens = state.tokens; + const l = blockTokens.length; + for (let j = 0; j < l; j++) { + if (blockTokens[j].type !== "inline") continue; + const tokens = blockTokens[j].children; + const max = tokens.length; + for (curr = 0; curr < max; curr++) { + if (tokens[curr].type === "text_special") tokens[curr].type = "text"; + if (tokens[curr].children) join_alt(tokens[curr].children); + } + for (curr = last = 0; curr < max; curr++) if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content; + else { + if (curr !== last) tokens[last] = tokens[curr]; + last++; + } + if (curr !== last) tokens.length = last; + } +} +var _rules$2 = [ + ["normalize", normalize], + ["block", block], + ["strip_references", strip_references], + ["inline", inline], + ["linkify", linkify$1], + ["replacements", replace], + ["smartquotes", smartquotes], + ["text_join", text_join] +]; +var ParserCore = class { + constructor() { + _defineProperty( + this, + /** + * {@link Ruler} instance. Keep configuration of core rules. + */ + "ruler", + new Ruler() + ); + _defineProperty(this, "State", StateCore); + for (let i = 0; i < _rules$2.length; i++) this.ruler.push(_rules$2[i][0], _rules$2[i][1]); + } + /** + * Executes core chain rules. + */ + process(state) { + const rules = this.ruler.getRules(""); + for (let i = 0, l = rules.length; i < l; i++) rules[i](state); + } +}; +var StateBlock = class { + constructor(src, md, env, tokens) { + _defineProperty(this, "bMarks", []); + _defineProperty(this, "eMarks", []); + _defineProperty(this, "tShift", []); + _defineProperty(this, "sCount", []); + _defineProperty(this, "bsCount", []); + _defineProperty(this, "blkIndent", 0); + _defineProperty(this, "line", 0); + _defineProperty(this, "lineMax", 0); + _defineProperty(this, "tight", false); + _defineProperty(this, "listIndent", -1); + _defineProperty(this, "parentType", "root"); + _defineProperty(this, "level", 0); + _defineProperty(this, "Token", Token); + this.src = src; + this.md = md; + this.env = env; + this.tokens = tokens; + const s = this.src; + for (let start = 0, pos = 0, indent = 0, offset = 0, len = s.length, indent_found = false; pos < len; pos++) { + const ch = s.charCodeAt(pos); + if (!indent_found) if (isSpace(ch)) { + indent++; + if (ch === 9) offset += 4 - offset % 4; + else offset++; + continue; + } else indent_found = true; + if (ch === 10 || pos === len - 1) { + if (ch !== 10) pos++; + this.bMarks.push(start); + this.eMarks.push(pos); + this.tShift.push(indent); + this.sCount.push(offset); + this.bsCount.push(0); + indent_found = false; + indent = 0; + offset = 0; + start = pos + 1; + } + } + this.bMarks.push(s.length); + this.eMarks.push(s.length); + this.tShift.push(0); + this.sCount.push(0); + this.bsCount.push(0); + this.lineMax = this.bMarks.length - 1; + } + push(type, tag, nesting) { + const token = new Token(type, tag, nesting); + token.block = true; + if (nesting < 0) this.level--; + token.level = this.level; + if (nesting > 0) this.level++; + this.tokens.push(token); + return token; + } + isEmpty(line) { + return this.bMarks[line] + this.tShift[line] >= this.eMarks[line]; + } + skipEmptyLines(from) { + for (let max = this.lineMax; from < max; from++) if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) break; + return from; + } + skipSpaces(pos) { + for (let max = this.src.length; pos < max; pos++) if (!isSpace(this.src.charCodeAt(pos))) break; + return pos; + } + skipSpacesBack(pos, min) { + if (pos <= min) return pos; + while (pos > min) if (!isSpace(this.src.charCodeAt(--pos))) return pos + 1; + return pos; + } + skipChars(pos, code2) { + for (let max = this.src.length; pos < max; pos++) if (this.src.charCodeAt(pos) !== code2) break; + return pos; + } + skipCharsBack(pos, code2, min) { + if (pos <= min) return pos; + while (pos > min) if (code2 !== this.src.charCodeAt(--pos)) return pos + 1; + return pos; + } + getLines(begin, end, indent, keepLastLF) { + if (begin >= end) return ""; + const queue = new Array(end - begin); + for (let i = 0, line = begin; line < end; line++, i++) { + let lineIndent = 0; + const lineStart = this.bMarks[line]; + let first = lineStart; + let last; + if (line + 1 < end || keepLastLF) last = this.eMarks[line] + 1; + else last = this.eMarks[line]; + while (first < last && lineIndent < indent) { + const ch = this.src.charCodeAt(first); + if (isSpace(ch)) if (ch === 9) lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4; + else lineIndent++; + else if (first - lineStart < this.tShift[line]) lineIndent++; + else break; + first++; + } + if (lineIndent > indent) queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last); + else queue[i] = this.src.slice(first, last); + } + return queue.join(""); + } +}; +var MAX_AUTOCOMPLETED_CELLS = 65536; +function getLine(state, line) { + const pos = state.bMarks[line] + state.tShift[line]; + const max = state.eMarks[line]; + return state.src.slice(pos, max); +} +function escapedSplit(str) { + const result = []; + const max = str.length; + let pos = 0; + let ch = str.charCodeAt(pos); + let isEscaped = false; + let lastPos = 0; + let current = ""; + while (pos < max) { + if (ch === 124) if (!isEscaped) { + result.push(current + str.substring(lastPos, pos)); + current = ""; + lastPos = pos + 1; + } else { + current += str.substring(lastPos, pos - 1); + lastPos = pos; + } + isEscaped = ch === 92; + pos++; + ch = str.charCodeAt(pos); + } + result.push(current + str.substring(lastPos)); + return result; +} +function table(state, startLine, endLine, silent) { + if (startLine + 2 > endLine) return false; + let nextLine = startLine + 1; + if (state.sCount[nextLine] < state.blkIndent) return false; + if (state.sCount[nextLine] - state.blkIndent >= 4) return false; + let pos = state.bMarks[nextLine] + state.tShift[nextLine]; + if (pos >= state.eMarks[nextLine]) return false; + const firstCh = state.src.charCodeAt(pos++); + if (firstCh !== 124 && firstCh !== 45 && firstCh !== 58) return false; + if (pos >= state.eMarks[nextLine]) return false; + const secondCh = state.src.charCodeAt(pos++); + if (secondCh !== 124 && secondCh !== 45 && secondCh !== 58 && !isSpace(secondCh)) return false; + if (firstCh === 45 && isSpace(secondCh)) return false; + while (pos < state.eMarks[nextLine]) { + const ch = state.src.charCodeAt(pos); + if (ch !== 124 && ch !== 45 && ch !== 58 && !isSpace(ch)) return false; + pos++; + } + let lineText = getLine(state, startLine + 1); + let columns = lineText.split("|"); + const aligns = []; + for (let i = 0; i < columns.length; i++) { + const t = columns[i].trim(); + if (!t) if (i === 0 || i === columns.length - 1) continue; + else return false; + if (!/^:?-+:?$/.test(t)) return false; + if (t.charCodeAt(t.length - 1) === 58) aligns.push(t.charCodeAt(0) === 58 ? "center" : "right"); + else if (t.charCodeAt(0) === 58) aligns.push("left"); + else aligns.push(""); + } + lineText = getLine(state, startLine).trim(); + if (lineText.indexOf("|") === -1) return false; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + columns = escapedSplit(lineText); + if (columns.length && columns[0] === "") columns.shift(); + if (columns.length && columns[columns.length - 1] === "") columns.pop(); + const columnCount = columns.length; + if (columnCount === 0 || columnCount !== aligns.length) return false; + if (silent) return true; + const oldParentType = state.parentType; + state.parentType = "table"; + const terminatorRules = state.md.block.ruler.getRules("blockquote"); + const token_to = state.push("table_open", "table", 1); + const tableLines = [startLine, 0]; + token_to.map = tableLines; + const token_tho = state.push("thead_open", "thead", 1); + token_tho.map = [startLine, startLine + 1]; + const token_htro = state.push("tr_open", "tr", 1); + token_htro.map = [startLine, startLine + 1]; + for (let i = 0; i < columns.length; i++) { + const token_ho = state.push("th_open", "th", 1); + if (aligns[i]) token_ho.attrs = [["style", `text-align:${aligns[i]}`]]; + const token_il = state.push("inline", "", 0); + token_il.content = columns[i].trim(); + token_il.children = []; + state.push("th_close", "th", -1); + } + state.push("tr_close", "tr", -1); + state.push("thead_close", "thead", -1); + let tbodyLines; + let autocompletedCells = 0; + for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { + if (state.sCount[nextLine] < state.blkIndent) break; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + if (terminate) break; + lineText = getLine(state, nextLine).trim(); + if (!lineText) break; + if (state.sCount[nextLine] - state.blkIndent >= 4) break; + columns = escapedSplit(lineText); + if (columns.length && columns[0] === "") columns.shift(); + if (columns.length && columns[columns.length - 1] === "") columns.pop(); + autocompletedCells += columnCount - columns.length; + if (autocompletedCells > MAX_AUTOCOMPLETED_CELLS) break; + if (nextLine === startLine + 2) { + const token_tbo = state.push("tbody_open", "tbody", 1); + token_tbo.map = tbodyLines = [startLine + 2, 0]; + } + const token_tro = state.push("tr_open", "tr", 1); + token_tro.map = [nextLine, nextLine + 1]; + for (let i = 0; i < columnCount; i++) { + const token_tdo = state.push("td_open", "td", 1); + if (aligns[i]) token_tdo.attrs = [["style", `text-align:${aligns[i]}`]]; + const token_il = state.push("inline", "", 0); + token_il.content = columns[i] ? columns[i].trim() : ""; + token_il.children = []; + state.push("td_close", "td", -1); + } + state.push("tr_close", "tr", -1); + } + if (tbodyLines) { + state.push("tbody_close", "tbody", -1); + tbodyLines[1] = nextLine; + } + state.push("table_close", "table", -1); + tableLines[1] = nextLine; + state.parentType = oldParentType; + state.line = nextLine; + return true; +} +function code(state, startLine, endLine) { + if (state.sCount[startLine] - state.blkIndent < 4) return false; + let nextLine = startLine + 1; + let last = nextLine; + while (nextLine < endLine) { + if (state.isEmpty(nextLine)) { + nextLine++; + continue; + } + if (state.sCount[nextLine] - state.blkIndent >= 4) { + nextLine++; + last = nextLine; + continue; + } + break; + } + state.line = last; + const token = state.push("code_block", "code", 0); + token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + "\n"; + token.map = [startLine, state.line]; + return true; +} +function fence(state, startLine, endLine, silent) { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + let max = state.eMarks[startLine]; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + if (pos + 3 > max) return false; + const marker = state.src.charCodeAt(pos); + if (marker !== 126 && marker !== 96) return false; + let mem = pos; + pos = state.skipChars(pos, marker); + let len = pos - mem; + if (len < 3) return false; + const markup = state.src.slice(mem, pos); + const params = state.src.slice(pos, max); + if (marker === 96) { + if (params.indexOf(String.fromCharCode(marker)) >= 0) return false; + } + if (silent) return true; + let nextLine = startLine; + let haveEndMarker = false; + for (; ; ) { + nextLine++; + if (nextLine >= endLine) break; + pos = mem = state.bMarks[nextLine] + state.tShift[nextLine]; + max = state.eMarks[nextLine]; + if (pos < max && state.sCount[nextLine] < state.blkIndent) break; + if (state.src.charCodeAt(pos) !== marker) continue; + if (state.sCount[nextLine] - state.blkIndent >= 4) continue; + pos = state.skipChars(pos, marker); + if (pos - mem < len) continue; + pos = state.skipSpaces(pos); + if (pos < max) continue; + haveEndMarker = true; + break; + } + len = state.sCount[startLine]; + state.line = nextLine + (haveEndMarker ? 1 : 0); + const token = state.push("fence", "code", 0); + token.info = params; + token.content = state.getLines(startLine + 1, nextLine, len, true); + token.markup = markup; + token.map = [startLine, state.line]; + return true; +} +function blockquote(state, startLine, endLine, silent) { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + let max = state.eMarks[startLine]; + const oldLineMax = state.lineMax; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + if (state.src.charCodeAt(pos) !== 62) return false; + if (silent) return true; + const oldBMarks = []; + const oldBSCount = []; + const oldSCount = []; + const oldTShift = []; + const terminatorRules = state.md.block.ruler.getRules("blockquote"); + const oldParentType = state.parentType; + state.parentType = "blockquote"; + let lastLineEmpty = false; + let nextLine; + for (nextLine = startLine; nextLine < endLine; nextLine++) { + const isOutdented = state.sCount[nextLine] < state.blkIndent; + pos = state.bMarks[nextLine] + state.tShift[nextLine]; + max = state.eMarks[nextLine]; + if (pos >= max) break; + if (state.src.charCodeAt(pos++) === 62 && !isOutdented) { + let initial = state.sCount[nextLine] + 1; + let spaceAfterMarker; + let adjustTab; + if (state.src.charCodeAt(pos) === 32) { + pos++; + initial++; + adjustTab = false; + spaceAfterMarker = true; + } else if (state.src.charCodeAt(pos) === 9) { + spaceAfterMarker = true; + if ((state.bsCount[nextLine] + initial) % 4 === 3) { + pos++; + initial++; + adjustTab = false; + } else adjustTab = true; + } else spaceAfterMarker = false; + let offset = initial; + oldBMarks.push(state.bMarks[nextLine]); + state.bMarks[nextLine] = pos; + while (pos < max) { + const ch = state.src.charCodeAt(pos); + if (isSpace(ch)) if (ch === 9) offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4; + else offset++; + else break; + pos++; + } + lastLineEmpty = pos >= max; + oldBSCount.push(state.bsCount[nextLine]); + state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0); + oldSCount.push(state.sCount[nextLine]); + state.sCount[nextLine] = offset - initial; + oldTShift.push(state.tShift[nextLine]); + state.tShift[nextLine] = pos - state.bMarks[nextLine]; + continue; + } + if (lastLineEmpty) break; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + if (terminate) { + state.lineMax = nextLine; + if (state.blkIndent !== 0) { + oldBMarks.push(state.bMarks[nextLine]); + oldBSCount.push(state.bsCount[nextLine]); + oldTShift.push(state.tShift[nextLine]); + oldSCount.push(state.sCount[nextLine]); + state.sCount[nextLine] -= state.blkIndent; + } + break; + } + oldBMarks.push(state.bMarks[nextLine]); + oldBSCount.push(state.bsCount[nextLine]); + oldTShift.push(state.tShift[nextLine]); + oldSCount.push(state.sCount[nextLine]); + state.sCount[nextLine] = -1; + } + const oldIndent = state.blkIndent; + state.blkIndent = 0; + const token_o = state.push("blockquote_open", "blockquote", 1); + token_o.markup = ">"; + const lines = [startLine, 0]; + token_o.map = lines; + state.md.block.tokenize(state, startLine, nextLine); + const token_c = state.push("blockquote_close", "blockquote", -1); + token_c.markup = ">"; + state.lineMax = oldLineMax; + state.parentType = oldParentType; + lines[1] = state.line; + for (let i = 0; i < oldTShift.length; i++) { + state.bMarks[i + startLine] = oldBMarks[i]; + state.tShift[i + startLine] = oldTShift[i]; + state.sCount[i + startLine] = oldSCount[i]; + state.bsCount[i + startLine] = oldBSCount[i]; + } + state.blkIndent = oldIndent; + return true; +} +function hr(state, startLine, endLine, silent) { + const max = state.eMarks[startLine]; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + let pos = state.bMarks[startLine] + state.tShift[startLine]; + const marker = state.src.charCodeAt(pos++); + if (marker !== 42 && marker !== 45 && marker !== 95) return false; + let cnt = 1; + while (pos < max) { + const ch = state.src.charCodeAt(pos++); + if (ch !== marker && !isSpace(ch)) return false; + if (ch === marker) cnt++; + } + if (cnt < 3) return false; + if (silent) return true; + state.line = startLine + 1; + const token = state.push("hr", "hr", 0); + token.map = [startLine, state.line]; + token.markup = Array(cnt + 1).join(String.fromCharCode(marker)); + return true; +} +function skipBulletListMarker(state, startLine) { + const max = state.eMarks[startLine]; + let pos = state.bMarks[startLine] + state.tShift[startLine]; + const marker = state.src.charCodeAt(pos++); + if (marker !== 42 && marker !== 45 && marker !== 43) return -1; + if (pos < max) { + if (!isSpace(state.src.charCodeAt(pos))) return -1; + } + return pos; +} +function skipOrderedListMarker(state, startLine) { + const start = state.bMarks[startLine] + state.tShift[startLine]; + const max = state.eMarks[startLine]; + let pos = start; + if (pos + 1 >= max) return -1; + let ch = state.src.charCodeAt(pos++); + if (ch < 48 || ch > 57) return -1; + for (; ; ) { + if (pos >= max) return -1; + ch = state.src.charCodeAt(pos++); + if (ch >= 48 && ch <= 57) { + if (pos - start >= 10) return -1; + continue; + } + if (ch === 41 || ch === 46) break; + return -1; + } + if (pos < max) { + ch = state.src.charCodeAt(pos); + if (!isSpace(ch)) return -1; + } + return pos; +} +function markTightParagraphs(state, idx) { + const level = state.level + 2; + for (let i = idx + 2, l = state.tokens.length - 2; i < l; i++) if (state.tokens[i].level === level && state.tokens[i].type === "paragraph_open") { + state.tokens[i + 2].hidden = true; + state.tokens[i].hidden = true; + i += 2; + } +} +function list(state, startLine, endLine, silent) { + let max, pos, start, token; + let nextLine = startLine; + let tight = true; + if (state.sCount[nextLine] - state.blkIndent >= 4) return false; + if (state.listIndent >= 0 && state.sCount[nextLine] - state.listIndent >= 4 && state.sCount[nextLine] < state.blkIndent) return false; + let isTerminatingParagraph = false; + if (silent && state.parentType === "paragraph") { + if (state.sCount[nextLine] >= state.blkIndent) isTerminatingParagraph = true; + } + let isOrdered; + let markerValue; + let posAfterMarker; + if ((posAfterMarker = skipOrderedListMarker(state, nextLine)) >= 0) { + isOrdered = true; + start = state.bMarks[nextLine] + state.tShift[nextLine]; + markerValue = Number(state.src.slice(start, posAfterMarker - 1)); + if (isTerminatingParagraph && markerValue !== 1) return false; + } else if ((posAfterMarker = skipBulletListMarker(state, nextLine)) >= 0) isOrdered = false; + else return false; + if (isTerminatingParagraph) { + if (state.skipSpaces(posAfterMarker) >= state.eMarks[nextLine]) return false; + } + if (silent) return true; + const markerCharCode = state.src.charCodeAt(posAfterMarker - 1); + const listTokIdx = state.tokens.length; + if (isOrdered) { + token = state.push("ordered_list_open", "ol", 1); + if (markerValue !== 1) token.attrs = [["start", markerValue]]; + } else token = state.push("bullet_list_open", "ul", 1); + const listLines = [nextLine, 0]; + token.map = listLines; + token.markup = String.fromCharCode(markerCharCode); + let prevEmptyEnd = false; + const terminatorRules = state.md.block.ruler.getRules("list"); + const oldParentType = state.parentType; + state.parentType = "list"; + while (nextLine < endLine) { + pos = posAfterMarker; + max = state.eMarks[nextLine]; + const initial = state.sCount[nextLine] + posAfterMarker - (state.bMarks[nextLine] + state.tShift[nextLine]); + let offset = initial; + while (pos < max) { + const ch = state.src.charCodeAt(pos); + if (ch === 9) offset += 4 - (offset + state.bsCount[nextLine]) % 4; + else if (ch === 32) offset++; + else break; + pos++; + } + const contentStart = pos; + let indentAfterMarker; + if (contentStart >= max) indentAfterMarker = 1; + else indentAfterMarker = offset - initial; + if (indentAfterMarker > 4) indentAfterMarker = 1; + const indent = initial + indentAfterMarker; + token = state.push("list_item_open", "li", 1); + token.markup = String.fromCharCode(markerCharCode); + const itemLines = [nextLine, 0]; + token.map = itemLines; + if (isOrdered) token.info = state.src.slice(start, posAfterMarker - 1); + const oldTight = state.tight; + const oldTShift = state.tShift[nextLine]; + const oldSCount = state.sCount[nextLine]; + const oldListIndent = state.listIndent; + state.listIndent = state.blkIndent; + state.blkIndent = indent; + state.tight = true; + state.tShift[nextLine] = contentStart - state.bMarks[nextLine]; + state.sCount[nextLine] = offset; + if (contentStart >= max && state.isEmpty(nextLine + 1)) state.line = Math.min(state.line + 2, endLine); + else state.md.block.tokenize(state, nextLine, endLine); + if (!state.tight || prevEmptyEnd) tight = false; + prevEmptyEnd = state.line - nextLine > 1 && state.isEmpty(state.line - 1); + state.blkIndent = state.listIndent; + state.listIndent = oldListIndent; + state.tShift[nextLine] = oldTShift; + state.sCount[nextLine] = oldSCount; + state.tight = oldTight; + token = state.push("list_item_close", "li", -1); + token.markup = String.fromCharCode(markerCharCode); + nextLine = state.line; + itemLines[1] = nextLine; + if (nextLine >= endLine) break; + if (state.sCount[nextLine] < state.blkIndent) break; + if (state.sCount[nextLine] - state.blkIndent >= 4) break; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + if (terminate) break; + if (isOrdered) { + posAfterMarker = skipOrderedListMarker(state, nextLine); + if (posAfterMarker < 0) break; + start = state.bMarks[nextLine] + state.tShift[nextLine]; + } else { + posAfterMarker = skipBulletListMarker(state, nextLine); + if (posAfterMarker < 0) break; + } + if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) break; + } + if (isOrdered) token = state.push("ordered_list_close", "ol", -1); + else token = state.push("bullet_list_close", "ul", -1); + token.markup = String.fromCharCode(markerCharCode); + listLines[1] = nextLine; + state.line = nextLine; + state.parentType = oldParentType; + if (tight) markTightParagraphs(state, listTokIdx); + return true; +} +function reference(state, startLine, _endLine, silent) { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + let max = state.eMarks[startLine]; + let nextLine = startLine + 1; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + if (state.src.charCodeAt(pos) !== 91) return false; + function getNextLine(nextLine2) { + const endLine = state.lineMax; + if (nextLine2 >= endLine || state.isEmpty(nextLine2)) return null; + let isContinuation = false; + if (state.sCount[nextLine2] - state.blkIndent > 3) isContinuation = true; + if (state.sCount[nextLine2] < 0) isContinuation = true; + if (!isContinuation) { + const terminatorRules = state.md.block.ruler.getRules("reference"); + const oldParentType = state.parentType; + state.parentType = "reference"; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine2, endLine, true)) { + terminate = true; + break; + } + state.parentType = oldParentType; + if (terminate) return null; + } + const pos2 = state.bMarks[nextLine2] + state.tShift[nextLine2]; + const max2 = state.eMarks[nextLine2]; + return state.src.slice(pos2, max2 + 1); + } + let str = state.src.slice(pos, max + 1); + max = str.length; + let labelEnd = -1; + for (pos = 1; pos < max; pos++) { + const ch = str.charCodeAt(pos); + if (ch === 91) return false; + else if (ch === 93) { + labelEnd = pos; + break; + } else if (ch === 10) { + const lineContent = getNextLine(nextLine); + if (lineContent !== null) { + str += lineContent; + max = str.length; + nextLine++; + } + } else if (ch === 92) { + pos++; + if (pos < max && str.charCodeAt(pos) === 10) { + const lineContent = getNextLine(nextLine); + if (lineContent !== null) { + str += lineContent; + max = str.length; + nextLine++; + } + } + } + } + if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58) return false; + for (pos = labelEnd + 2; pos < max; pos++) { + const ch = str.charCodeAt(pos); + if (ch === 10) { + const lineContent = getNextLine(nextLine); + if (lineContent !== null) { + str += lineContent; + max = str.length; + nextLine++; + } + } else if (isSpace(ch)) { + } else break; + } + const destRes = state.md.helpers.parseLinkDestination(str, pos, max); + if (!destRes.ok) return false; + const href = state.md.normalizeLink(destRes.str); + if (!state.md.validateLink(href)) return false; + pos = destRes.pos; + const destEndPos = pos; + const destEndLineNo = nextLine; + const start = pos; + for (; pos < max; pos++) { + const ch = str.charCodeAt(pos); + if (ch === 10) { + const lineContent = getNextLine(nextLine); + if (lineContent !== null) { + str += lineContent; + max = str.length; + nextLine++; + } + } else if (isSpace(ch)) { + } else break; + } + let titleRes = state.md.helpers.parseLinkTitle(str, pos, max); + while (titleRes.can_continue) { + const lineContent = getNextLine(nextLine); + if (lineContent === null) break; + str += lineContent; + pos = max; + max = str.length; + nextLine++; + titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes); + } + let title; + if (pos < max && start !== pos && titleRes.ok) { + title = titleRes.str; + pos = titleRes.pos; + } else { + title = ""; + pos = destEndPos; + nextLine = destEndLineNo; + } + while (pos < max) { + if (!isSpace(str.charCodeAt(pos))) break; + pos++; + } + if (pos < max && str.charCodeAt(pos) !== 10) { + if (title) { + title = ""; + pos = destEndPos; + nextLine = destEndLineNo; + while (pos < max) { + if (!isSpace(str.charCodeAt(pos))) break; + pos++; + } + } + } + if (pos < max && str.charCodeAt(pos) !== 10) return false; + const label = normalizeReference(str.slice(1, labelEnd)); + if (!label) return false; + if (silent) return true; + if (typeof state.env.references === "undefined") state.env.references = {}; + if (typeof state.env.references[label] === "undefined") state.env.references[label] = { + title, + href + }; + const token = state.push("reference_definition", "", 0); + token.map = [startLine, nextLine]; + token.hidden = true; + const meta = /* @__PURE__ */ Object.create(null); + meta.label = label; + token.meta = meta; + state.line = nextLine; + return true; +} +var html_blocks_default = [ + "address", + "article", + "aside", + "base", + "basefont", + "blockquote", + "body", + "caption", + "center", + "col", + "colgroup", + "dd", + "details", + "dialog", + "dir", + "div", + "dl", + "dt", + "fieldset", + "figcaption", + "figure", + "footer", + "form", + "frame", + "frameset", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "head", + "header", + "hr", + "html", + "iframe", + "legend", + "li", + "link", + "main", + "menu", + "menuitem", + "nav", + "noframes", + "ol", + "optgroup", + "option", + "p", + "param", + "search", + "section", + "summary", + "table", + "tbody", + "td", + "tfoot", + "th", + "thead", + "title", + "tr", + "track", + "ul" +]; +var open_tag = `<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`; +var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>"; +var HTML_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag}||<[?][\\s\\S]*?[?]>|]*>|)`); +var HTML_OPEN_CLOSE_TAG_RE = new RegExp(`^(?:${open_tag}|${close_tag})`); +var HTML_SEQUENCES = [ + [ + /^<(script|pre|style|textarea)(?=(\s|>|$))/i, + /<\/(script|pre|style|textarea)>/i, + true + ], + [ + /^/, + true + ], + [ + /^<\?/, + /\?>/, + true + ], + [ + /^/, + true + ], + [ + /^/, + true + ], + [ + new RegExp(`^|$))`, "i"), + /^$/, + true + ], + [ + new RegExp(`${HTML_OPEN_CLOSE_TAG_RE.source}\\s*$`), + /^$/, + false + ] +]; +function html_block(state, startLine, endLine, silent) { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + let max = state.eMarks[startLine]; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + if (!state.md.options.html) return false; + if (state.src.charCodeAt(pos) !== 60) return false; + let lineText = state.src.slice(pos, max); + let i = 0; + for (; i < HTML_SEQUENCES.length; i++) if (HTML_SEQUENCES[i][0].test(lineText)) break; + if (i === HTML_SEQUENCES.length) return false; + if (silent) return HTML_SEQUENCES[i][2]; + let nextLine = startLine + 1; + const endsOnBlankLine = HTML_SEQUENCES[i][1].test(""); + if (!HTML_SEQUENCES[i][1].test(lineText)) for (; nextLine < endLine; nextLine++) { + if (state.sCount[nextLine] < state.blkIndent) { + if (endsOnBlankLine || !state.isEmpty(nextLine)) break; + } + pos = state.bMarks[nextLine] + state.tShift[nextLine]; + max = state.eMarks[nextLine]; + lineText = state.src.slice(pos, max); + if (HTML_SEQUENCES[i][1].test(lineText)) { + if (lineText.length !== 0) nextLine++; + break; + } + } + state.line = nextLine; + const token = state.push("html_block", "", 0); + token.map = [startLine, nextLine]; + token.content = state.getLines(startLine, nextLine, state.blkIndent, true); + return true; +} +function heading(state, startLine, endLine, silent) { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + let max = state.eMarks[startLine]; + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + let ch = state.src.charCodeAt(pos); + if (ch !== 35 || pos >= max) return false; + let level = 1; + ch = state.src.charCodeAt(++pos); + while (ch === 35 && pos < max && level <= 6) { + level++; + ch = state.src.charCodeAt(++pos); + } + if (level > 6 || pos < max && !isSpace(ch)) return false; + if (silent) return true; + max = state.skipSpacesBack(max, pos); + const tmp = state.skipCharsBack(max, 35, pos); + if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) max = tmp; + state.line = startLine + 1; + const token_o = state.push("heading_open", `h${level}`, 1); + token_o.markup = "########".slice(0, level); + token_o.map = [startLine, state.line]; + const token_i = state.push("inline", "", 0); + token_i.content = asciiTrim(state.src.slice(pos, max)); + token_i.map = [startLine, state.line]; + token_i.children = []; + const token_c = state.push("heading_close", `h${level}`, -1); + token_c.markup = "########".slice(0, level); + return true; +} +function lheading(state, startLine, endLine) { + const terminatorRules = state.md.block.ruler.getRules("paragraph"); + if (state.sCount[startLine] - state.blkIndent >= 4) return false; + const oldParentType = state.parentType; + state.parentType = "paragraph"; + let level = 0; + let marker; + let nextLine = startLine + 1; + for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { + if (state.sCount[nextLine] - state.blkIndent > 3) continue; + if (state.sCount[nextLine] >= state.blkIndent) { + let pos = state.bMarks[nextLine] + state.tShift[nextLine]; + const max = state.eMarks[nextLine]; + if (pos < max) { + marker = state.src.charCodeAt(pos); + if (marker === 45 || marker === 61) { + pos = state.skipChars(pos, marker); + pos = state.skipSpaces(pos); + if (pos >= max) { + level = marker === 61 ? 1 : 2; + break; + } + } + } + } + if (state.sCount[nextLine] < 0) continue; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + if (terminate) break; + } + if (!level) { + state.parentType = oldParentType; + return false; + } + const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false)); + state.line = nextLine + 1; + const token_o = state.push("heading_open", `h${level}`, 1); + token_o.markup = String.fromCharCode(marker); + token_o.map = [startLine, state.line]; + const token_i = state.push("inline", "", 0); + token_i.content = content; + token_i.map = [startLine, state.line - 1]; + token_i.children = []; + const token_c = state.push("heading_close", `h${level}`, -1); + token_c.markup = String.fromCharCode(marker); + state.parentType = oldParentType; + return true; +} +function paragraph(state, startLine, endLine) { + const terminatorRules = state.md.block.ruler.getRules("paragraph"); + const oldParentType = state.parentType; + let nextLine = startLine + 1; + state.parentType = "paragraph"; + for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { + if (state.sCount[nextLine] - state.blkIndent > 3) continue; + if (state.sCount[nextLine] < 0) continue; + let terminate = false; + for (let i = 0, l = terminatorRules.length; i < l; i++) if (terminatorRules[i](state, nextLine, endLine, true)) { + terminate = true; + break; + } + if (terminate) break; + } + const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false)); + state.line = nextLine; + const token_o = state.push("paragraph_open", "p", 1); + token_o.map = [startLine, state.line]; + const token_i = state.push("inline", "", 0); + token_i.content = content; + token_i.map = [startLine, state.line]; + token_i.children = []; + state.push("paragraph_close", "p", -1); + state.parentType = oldParentType; + return true; +} +var _rules$1 = [ + [ + "table", + table, + ["paragraph", "reference"] + ], + ["code", code], + [ + "fence", + fence, + [ + "paragraph", + "reference", + "blockquote", + "list" + ] + ], + [ + "blockquote", + blockquote, + [ + "paragraph", + "reference", + "blockquote", + "list" + ] + ], + [ + "hr", + hr, + [ + "paragraph", + "reference", + "blockquote", + "list" + ] + ], + [ + "list", + list, + [ + "paragraph", + "reference", + "blockquote" + ] + ], + ["reference", reference], + [ + "html_block", + html_block, + [ + "paragraph", + "reference", + "blockquote" + ] + ], + [ + "heading", + heading, + [ + "paragraph", + "reference", + "blockquote" + ] + ], + ["lheading", lheading], + ["paragraph", paragraph] +]; +var ParserBlock = class { + constructor() { + _defineProperty( + this, + /** + * {@link Ruler} instance. Keep configuration of block rules. + */ + "ruler", + new Ruler() + ); + _defineProperty(this, "State", StateBlock); + for (let i = 0; i < _rules$1.length; i++) this.ruler.push(_rules$1[i][0], _rules$1[i][1], { alt: (_rules$1[i][2] || []).slice() }); + } + tokenize(state, startLine, endLine) { + const rules = this.ruler.getRules(""); + const len = rules.length; + const maxNesting = state.md.options.maxNesting; + let line = startLine; + let hasEmptyLines = false; + while (line < endLine) { + state.line = line = state.skipEmptyLines(line); + if (line >= endLine) break; + if (state.sCount[line] < state.blkIndent) break; + if (state.level >= maxNesting) { + state.line = endLine; + break; + } + const prevLine = state.line; + let ok = false; + for (let i = 0; i < len; i++) { + ok = rules[i](state, line, endLine, false); + if (ok) { + if (prevLine >= state.line) throw new Error("block rule didn't increment state.line"); + break; + } + } + if (!ok) throw new Error("none of the block rules matched"); + state.tight = !hasEmptyLines; + if (state.isEmpty(state.line - 1)) hasEmptyLines = true; + line = state.line; + if (line < endLine && state.isEmpty(line)) { + hasEmptyLines = true; + line++; + state.line = line; + } + } + } + /** + * Process input string and push block tokens into `outTokens` + */ + parse(src, md, env, outTokens) { + if (!src) return; + const state = new this.State(src, md, env, outTokens); + this.tokenize(state, state.line, state.lineMax); + } +}; +var StateInline = class { + constructor(src, md, env, outTokens) { + _defineProperty(this, "pos", 0); + _defineProperty(this, "level", 0); + _defineProperty(this, "pending", ""); + _defineProperty(this, "pendingLevel", 0); + _defineProperty(this, "cache", {}); + _defineProperty(this, "backticks", {}); + _defineProperty(this, "backticksScanned", false); + _defineProperty(this, "linkLevel", 0); + _defineProperty(this, "delimiters", []); + _defineProperty(this, "_prev_delimiters", []); + _defineProperty(this, "Token", Token); + this.src = src; + this.env = env; + this.md = md; + this.tokens = outTokens; + this.tokens_meta = Array(outTokens.length); + this.posMax = this.src.length; + } + pushPending() { + const token = new Token("text", "", 0); + token.content = this.pending; + token.level = this.pendingLevel; + this.tokens.push(token); + this.pending = ""; + return token; + } + push(type, tag, nesting) { + if (this.pending) this.pushPending(); + const token = new Token(type, tag, nesting); + let token_meta = void 0; + if (nesting < 0) { + this.level--; + this.delimiters = this._prev_delimiters.pop(); + } + token.level = this.level; + if (nesting > 0) { + this.level++; + this._prev_delimiters.push(this.delimiters); + this.delimiters = []; + token_meta = { delimiters: this.delimiters }; + } + this.pendingLevel = this.level; + this.tokens.push(token); + this.tokens_meta.push(token_meta); + return token; + } + scanDelims(start, canSplitWord) { + const max = this.posMax; + const marker = this.src.charCodeAt(start); + let lastChar; + if (start === 0) lastChar = 32; + else if (start === 1) { + lastChar = this.src.charCodeAt(0); + if ((lastChar & 63488) === 55296) lastChar = 65533; + } else { + lastChar = this.src.charCodeAt(start - 1); + if ((lastChar & 64512) === 56320) { + const highSurr = this.src.charCodeAt(start - 2); + lastChar = (highSurr & 64512) === 55296 ? 65536 + (highSurr - 55296 << 10) + (lastChar - 56320) : 65533; + } else if ((lastChar & 64512) === 55296) lastChar = 65533; + } + let pos = start; + while (pos < max && this.src.charCodeAt(pos) === marker) pos++; + const count = pos - start; + let nextChar = pos < max ? this.src.charCodeAt(pos) : 32; + if ((nextChar & 64512) === 55296) { + const lowSurr = this.src.charCodeAt(pos + 1); + nextChar = (lowSurr & 64512) === 56320 ? 65536 + (nextChar - 55296 << 10) + (lowSurr - 56320) : 65533; + } else if ((nextChar & 64512) === 56320) nextChar = 65533; + const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar); + const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar); + const isLastWhiteSpace = isWhiteSpace(lastChar); + const isNextWhiteSpace = isWhiteSpace(nextChar); + const left_flanking = !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar); + const right_flanking = !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar); + return { + can_open: left_flanking && (canSplitWord || !right_flanking || isLastPunctChar), + can_close: right_flanking && (canSplitWord || !left_flanking || isNextPunctChar), + length: count + }; + } +}; +function isTerminatorChar(ch) { + switch (ch) { + case 10: + case 33: + case 35: + case 36: + case 37: + case 38: + case 42: + case 43: + case 45: + case 58: + case 60: + case 61: + case 62: + case 64: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 123: + case 125: + case 126: + return true; + default: + return false; + } +} +function text(state, silent) { + let pos = state.pos; + while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) pos++; + if (pos === state.pos) return false; + if (!silent) state.pending += state.src.slice(state.pos, pos); + state.pos = pos; + return true; +} +var SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i; +function linkify(state, silent) { + if (!state.md.options.linkify) return false; + if (state.linkLevel > 0) return false; + const pos = state.pos; + const max = state.posMax; + if (pos + 3 > max) return false; + if (state.src.charCodeAt(pos) !== 58) return false; + if (state.src.charCodeAt(pos + 1) !== 47) return false; + if (state.src.charCodeAt(pos + 2) !== 47) return false; + const match = state.pending.match(SCHEME_RE); + if (!match) return false; + const proto = match[1]; + const link2 = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length)); + if (!link2) return false; + let url = link2.url; + if (url.length <= proto.length) return false; + let urlEnd = url.length; + while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 42) urlEnd--; + if (urlEnd !== url.length) url = url.slice(0, urlEnd); + const fullUrl = state.md.normalizeLink(url); + if (!state.md.validateLink(fullUrl)) return false; + if (!silent) { + state.pending = state.pending.slice(0, -proto.length); + const token_o = state.push("link_open", "a", 1); + token_o.attrs = [["href", fullUrl]]; + token_o.markup = "linkify"; + token_o.info = "auto"; + const token_t = state.push("text", "", 0); + token_t.content = state.md.normalizeLinkText(url); + const token_c = state.push("link_close", "a", -1); + token_c.markup = "linkify"; + token_c.info = "auto"; + } + state.pos += url.length - proto.length; + return true; +} +function newline(state, silent) { + let pos = state.pos; + if (state.src.charCodeAt(pos) !== 10) return false; + const pmax = state.pending.length - 1; + const max = state.posMax; + if (!silent) if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) { + let ws = pmax - 1; + while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--; + state.pending = state.pending.slice(0, ws); + state.push("hardbreak", "br", 0); + } else { + state.pending = state.pending.slice(0, -1); + state.push("softbreak", "br", 0); + } + else state.push("softbreak", "br", 0); + pos++; + while (pos < max && isSpace(state.src.charCodeAt(pos))) pos++; + state.pos = pos; + return true; +} +var ESCAPED = []; +for (let i = 0; i < 256; i++) ESCAPED.push(0); +"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(ch) { + ESCAPED[ch.charCodeAt(0)] = 1; +}); +function escape(state, silent) { + let pos = state.pos; + const max = state.posMax; + if (state.src.charCodeAt(pos) !== 92) return false; + pos++; + if (pos >= max) return false; + let ch1 = state.src.charCodeAt(pos); + if (ch1 === 10) { + if (!silent) state.push("hardbreak", "br", 0); + pos++; + while (pos < max) { + ch1 = state.src.charCodeAt(pos); + if (!isSpace(ch1)) break; + pos++; + } + state.pos = pos; + return true; + } + if (ch1 === 32) { + if (!silent) { + const token = state.push("text_special", "", 0); + token.content = "\\"; + token.markup = "\\"; + token.info = "escape"; + } + state.pos = pos; + return true; + } + let escapedStr = state.src[pos]; + if (ch1 >= 55296 && ch1 <= 56319 && pos + 1 < max) { + const ch2 = state.src.charCodeAt(pos + 1); + if (ch2 >= 56320 && ch2 <= 57343) { + escapedStr += state.src[pos + 1]; + pos++; + } + } + const origStr = "\\" + escapedStr; + if (!silent) { + const token = state.push("text_special", "", 0); + if (ch1 < 256 && ESCAPED[ch1] !== 0) token.content = escapedStr; + else token.content = origStr; + token.markup = origStr; + token.info = "escape"; + } + state.pos = pos + 1; + return true; +} +function backtick(state, silent) { + let pos = state.pos; + if (state.src.charCodeAt(pos) !== 96) return false; + const start = pos; + pos++; + const max = state.posMax; + while (pos < max && state.src.charCodeAt(pos) === 96) pos++; + const marker = state.src.slice(start, pos); + const openerLength = marker.length; + if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) { + if (!silent) state.pending += marker; + state.pos += openerLength; + return true; + } + let matchEnd = pos; + let matchStart; + while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) { + matchEnd = matchStart + 1; + while (matchEnd < max && state.src.charCodeAt(matchEnd) === 96) matchEnd++; + const closerLength = matchEnd - matchStart; + if (closerLength === openerLength) { + if (!silent) { + const token = state.push("code_inline", "code", 0); + token.markup = marker; + token.content = state.src.slice(pos, matchStart).replace(/\n/g, " ").replace(/^ (.+) $/, "$1"); + } + state.pos = matchEnd; + return true; + } + state.backticks[closerLength] = matchStart; + } + state.backticksScanned = true; + if (!silent) state.pending += marker; + state.pos += openerLength; + return true; +} +function strikethrough_tokenize(state, silent) { + const start = state.pos; + const marker = state.src.charCodeAt(start); + if (silent) return false; + if (marker !== 126) return false; + const scanned = state.scanDelims(state.pos, true); + let len = scanned.length; + const ch = String.fromCharCode(marker); + if (len < 2) return false; + let token; + if (len % 2) { + token = state.push("text", "", 0); + token.content = ch; + len--; + } + for (let i = 0; i < len; i += 2) { + token = state.push("text", "", 0); + token.content = ch + ch; + state.delimiters.push({ + marker, + length: 0, + token: state.tokens.length - 1, + end: -1, + open: scanned.can_open, + close: scanned.can_close + }); + } + state.pos += scanned.length; + return true; +} +function postProcess$1(state, delimiters) { + let token; + const loneMarkers = []; + const max = delimiters.length; + for (let i = 0; i < max; i++) { + const startDelim = delimiters[i]; + if (startDelim.marker !== 126) continue; + if (startDelim.end === -1) continue; + const endDelim = delimiters[startDelim.end]; + token = state.tokens[startDelim.token]; + token.type = "s_open"; + token.tag = "s"; + token.nesting = 1; + token.markup = "~~"; + token.content = ""; + token = state.tokens[endDelim.token]; + token.type = "s_close"; + token.tag = "s"; + token.nesting = -1; + token.markup = "~~"; + token.content = ""; + if (state.tokens[endDelim.token - 1].type === "text" && state.tokens[endDelim.token - 1].content === "~") loneMarkers.push(endDelim.token - 1); + } + while (loneMarkers.length) { + const i = loneMarkers.pop(); + let j = i + 1; + while (j < state.tokens.length && state.tokens[j].type === "s_close") j++; + j--; + if (i !== j) { + token = state.tokens[j]; + state.tokens[j] = state.tokens[i]; + state.tokens[i] = token; + } + } +} +function strikethrough_postProcess(state) { + const tokens_meta = state.tokens_meta; + const max = state.tokens_meta.length; + postProcess$1(state, state.delimiters); + for (let curr = 0; curr < max; curr++) { + var _tokens_meta$curr; + const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters; + if (delimiters) postProcess$1(state, delimiters); + } +} +var strikethrough_default = { + tokenize: strikethrough_tokenize, + postProcess: strikethrough_postProcess +}; +function emphasis_tokenize(state, silent) { + const start = state.pos; + const marker = state.src.charCodeAt(start); + if (silent) return false; + if (marker !== 95 && marker !== 42) return false; + const scanned = state.scanDelims(state.pos, marker === 42); + for (let i = 0; i < scanned.length; i++) { + const token = state.push("text", "", 0); + token.content = String.fromCharCode(marker); + state.delimiters.push({ + marker, + length: scanned.length, + token: state.tokens.length - 1, + end: -1, + open: scanned.can_open, + close: scanned.can_close + }); + } + state.pos += scanned.length; + return true; +} +function postProcess(state, delimiters) { + const max = delimiters.length; + for (let i = max - 1; i >= 0; i--) { + const startDelim = delimiters[i]; + if (startDelim.marker !== 95 && startDelim.marker !== 42) continue; + if (startDelim.end === -1) continue; + const endDelim = delimiters[startDelim.end]; + const isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 && delimiters[i - 1].marker === startDelim.marker && delimiters[i - 1].token === startDelim.token - 1 && delimiters[startDelim.end + 1].token === endDelim.token + 1; + const ch = String.fromCharCode(startDelim.marker); + const token_o = state.tokens[startDelim.token]; + token_o.type = isStrong ? "strong_open" : "em_open"; + token_o.tag = isStrong ? "strong" : "em"; + token_o.nesting = 1; + token_o.markup = isStrong ? ch + ch : ch; + token_o.content = ""; + const token_c = state.tokens[endDelim.token]; + token_c.type = isStrong ? "strong_close" : "em_close"; + token_c.tag = isStrong ? "strong" : "em"; + token_c.nesting = -1; + token_c.markup = isStrong ? ch + ch : ch; + token_c.content = ""; + if (isStrong) { + state.tokens[delimiters[i - 1].token].content = ""; + state.tokens[delimiters[startDelim.end + 1].token].content = ""; + i--; + } + } +} +function emphasis_post_process(state) { + const tokens_meta = state.tokens_meta; + const max = state.tokens_meta.length; + postProcess(state, state.delimiters); + for (let curr = 0; curr < max; curr++) { + var _tokens_meta$curr; + const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters; + if (delimiters) postProcess(state, delimiters); + } +} +var emphasis_default = { + tokenize: emphasis_tokenize, + postProcess: emphasis_post_process +}; +function link(state, silent) { + let code2, label, res, ref; + let href = ""; + let title = ""; + let start = state.pos; + let parseReference = true; + if (state.src.charCodeAt(state.pos) !== 91) return false; + const oldPos = state.pos; + const max = state.posMax; + const labelStart = state.pos + 1; + const labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true); + if (labelEnd < 0) return false; + let pos = labelEnd + 1; + if (pos < max && state.src.charCodeAt(pos) === 40) { + parseReference = false; + pos++; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + if (pos >= max) return false; + start = pos; + res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax); + if (res.ok) { + href = state.md.normalizeLink(res.str); + if (state.md.validateLink(href)) pos = res.pos; + else href = ""; + start = pos; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax); + if (pos < max && start !== pos && res.ok) { + title = res.str; + pos = res.pos; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + } + } + if (pos >= max || state.src.charCodeAt(pos) !== 41) parseReference = true; + pos++; + } + if (parseReference) { + if (typeof state.env.references === "undefined") return false; + if (pos < max && state.src.charCodeAt(pos) === 91) { + start = pos + 1; + pos = state.md.helpers.parseLinkLabel(state, pos); + if (pos >= 0) label = state.src.slice(start, pos++); + else pos = labelEnd + 1; + } else pos = labelEnd + 1; + if (!label) label = state.src.slice(labelStart, labelEnd); + label = normalizeReference(label); + ref = state.env.references[label]; + if (!ref) { + state.pos = oldPos; + return false; + } + href = ref.href; + title = ref.title; + } + if (!silent) { + state.pos = labelStart; + state.posMax = labelEnd; + const token_o = state.push("link_open", "a", 1); + const attrs = [["href", href]]; + token_o.attrs = attrs; + if (title) attrs.push(["title", title]); + if (label) { + const meta = /* @__PURE__ */ Object.create(null); + meta.label = label; + token_o.meta = meta; + } + state.linkLevel++; + state.md.inline.tokenize(state); + state.linkLevel--; + state.push("link_close", "a", -1); + } + state.pos = pos; + state.posMax = max; + return true; +} +function image(state, silent) { + let code2, content, label, pos, ref, res, title, start; + let href = ""; + const oldPos = state.pos; + const max = state.posMax; + if (state.src.charCodeAt(state.pos) !== 33) return false; + if (state.src.charCodeAt(state.pos + 1) !== 91) return false; + const labelStart = state.pos + 2; + const labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false); + if (labelEnd < 0) return false; + pos = labelEnd + 1; + if (pos < max && state.src.charCodeAt(pos) === 40) { + pos++; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + if (pos >= max) return false; + start = pos; + res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax); + if (res.ok) { + href = state.md.normalizeLink(res.str); + if (state.md.validateLink(href)) pos = res.pos; + else href = ""; + } + start = pos; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax); + if (pos < max && start !== pos && res.ok) { + title = res.str; + pos = res.pos; + for (; pos < max; pos++) { + code2 = state.src.charCodeAt(pos); + if (!isSpace(code2) && code2 !== 10) break; + } + } else title = ""; + if (pos >= max || state.src.charCodeAt(pos) !== 41) { + state.pos = oldPos; + return false; + } + pos++; + } else { + if (typeof state.env.references === "undefined") return false; + if (pos < max && state.src.charCodeAt(pos) === 91) { + start = pos + 1; + pos = state.md.helpers.parseLinkLabel(state, pos); + if (pos >= 0) label = state.src.slice(start, pos++); + else pos = labelEnd + 1; + } else pos = labelEnd + 1; + if (!label) label = state.src.slice(labelStart, labelEnd); + label = normalizeReference(label); + ref = state.env.references[label]; + if (!ref) { + state.pos = oldPos; + return false; + } + href = ref.href; + title = ref.title; + } + if (!silent) { + content = state.src.slice(labelStart, labelEnd); + const tokens = []; + state.md.inline.parse(content, state.md, state.env, tokens); + const token = state.push("image", "img", 0); + const attrs = [["src", href], ["alt", ""]]; + token.attrs = attrs; + token.children = tokens; + token.content = content; + if (title) attrs.push(["title", title]); + if (label) { + const meta = /* @__PURE__ */ Object.create(null); + meta.label = label; + token.meta = meta; + } + } + state.pos = pos; + state.posMax = max; + return true; +} +var EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/; +var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/; +function autolink(state, silent) { + let pos = state.pos; + if (state.src.charCodeAt(pos) !== 60) return false; + const start = state.pos; + const max = state.posMax; + for (; ; ) { + if (++pos >= max) return false; + const ch = state.src.charCodeAt(pos); + if (ch === 60) return false; + if (ch === 62) break; + } + const url = state.src.slice(start + 1, pos); + if (AUTOLINK_RE.test(url)) { + const fullUrl = state.md.normalizeLink(url); + if (!state.md.validateLink(fullUrl)) return false; + if (!silent) { + const token_o = state.push("link_open", "a", 1); + token_o.attrs = [["href", fullUrl]]; + token_o.markup = "autolink"; + token_o.info = "auto"; + const token_t = state.push("text", "", 0); + token_t.content = state.md.normalizeLinkText(url); + const token_c = state.push("link_close", "a", -1); + token_c.markup = "autolink"; + token_c.info = "auto"; + } + state.pos += url.length + 2; + return true; + } + if (EMAIL_RE.test(url)) { + const fullUrl = state.md.normalizeLink(`mailto:${url}`); + if (!state.md.validateLink(fullUrl)) return false; + if (!silent) { + const token_o = state.push("link_open", "a", 1); + token_o.attrs = [["href", fullUrl]]; + token_o.markup = "autolink"; + token_o.info = "auto"; + const token_t = state.push("text", "", 0); + token_t.content = state.md.normalizeLinkText(url); + const token_c = state.push("link_close", "a", -1); + token_c.markup = "autolink"; + token_c.info = "auto"; + } + state.pos += url.length + 2; + return true; + } + return false; +} +function isLinkOpen(str) { + return /^\s]/i.test(str); +} +function isLinkClose(str) { + return /^<\/a\s*>/i.test(str); +} +function isLetter(ch) { + const lc = ch | 32; + return lc >= 97 && lc <= 122; +} +function html_inline(state, silent) { + if (!state.md.options.html) return false; + const max = state.posMax; + const pos = state.pos; + if (state.src.charCodeAt(pos) !== 60 || pos + 2 >= max) return false; + const ch = state.src.charCodeAt(pos + 1); + if (ch !== 33 && ch !== 63 && ch !== 47 && !isLetter(ch)) return false; + const match = state.src.slice(pos).match(HTML_TAG_RE); + if (!match) return false; + if (!silent) { + const token = state.push("html_inline", "", 0); + token.content = match[0]; + if (isLinkOpen(token.content)) state.linkLevel++; + if (isLinkClose(token.content)) state.linkLevel--; + } + state.pos += match[0].length; + return true; +} +var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i; +var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i; +function entity(state, silent) { + const pos = state.pos; + const max = state.posMax; + if (state.src.charCodeAt(pos) !== 38) return false; + if (pos + 1 >= max) return false; + if (state.src.charCodeAt(pos + 1) === 35) { + const match = state.src.slice(pos).match(DIGITAL_RE); + if (match) { + if (!silent) { + const code2 = match[1][0].toLowerCase() === "x" ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10); + const token = state.push("text_special", "", 0); + token.content = isValidEntityCode(code2) ? fromCodePoint(code2) : fromCodePoint(65533); + token.markup = match[0]; + token.info = "entity"; + } + state.pos += match[0].length; + return true; + } + } else { + const match = state.src.slice(pos).match(NAMED_RE); + if (match) { + const decoded = decodeHTMLStrict(match[0]); + if (decoded !== match[0]) { + if (!silent) { + const token = state.push("text_special", "", 0); + token.content = decoded; + token.markup = match[0]; + token.info = "entity"; + } + state.pos += match[0].length; + return true; + } + } + } + return false; +} +function processDelimiters(delimiters) { + const openersBottom = {}; + const max = delimiters.length; + if (!max) return; + let headerIdx = 0; + let lastTokenIdx = -2; + const jumps = []; + for (let closerIdx = 0; closerIdx < max; closerIdx++) { + const closer = delimiters[closerIdx]; + jumps.push(0); + if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) headerIdx = closerIdx; + lastTokenIdx = closer.token; + closer.length = closer.length || 0; + if (!closer.close) continue; + if (!openersBottom.hasOwnProperty(closer.marker)) openersBottom[closer.marker] = [ + -1, + -1, + -1, + -1, + -1, + -1 + ]; + const minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + closer.length % 3]; + let openerIdx = headerIdx - jumps[headerIdx] - 1; + let newMinOpenerIdx = openerIdx; + for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) { + const opener = delimiters[openerIdx]; + if (opener.marker !== closer.marker) continue; + if (opener.open && opener.end < 0) { + let isOddMatch = false; + if (opener.close || closer.open) { + if ((opener.length + closer.length) % 3 === 0) { + if (opener.length % 3 !== 0 || closer.length % 3 !== 0) isOddMatch = true; + } + } + if (!isOddMatch) { + const lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ? jumps[openerIdx - 1] + 1 : 0; + jumps[closerIdx] = closerIdx - openerIdx + lastJump; + jumps[openerIdx] = lastJump; + closer.open = false; + opener.end = closerIdx; + opener.close = false; + newMinOpenerIdx = -1; + lastTokenIdx = -2; + break; + } + } + } + if (newMinOpenerIdx !== -1) openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length || 0) % 3] = newMinOpenerIdx; + } +} +function link_pairs(state) { + const tokens_meta = state.tokens_meta; + const max = state.tokens_meta.length; + processDelimiters(state.delimiters); + for (let curr = 0; curr < max; curr++) { + var _tokens_meta$curr; + const delimiters = (_tokens_meta$curr = tokens_meta[curr]) === null || _tokens_meta$curr === void 0 ? void 0 : _tokens_meta$curr.delimiters; + if (delimiters) processDelimiters(delimiters); + } +} +function fragments_join(state) { + let curr, last; + let level = 0; + const tokens = state.tokens; + const max = state.tokens.length; + for (curr = last = 0; curr < max; curr++) { + if (tokens[curr].nesting < 0) level--; + tokens[curr].level = level; + if (tokens[curr].nesting > 0) level++; + if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content; + else { + if (curr !== last) tokens[last] = tokens[curr]; + last++; + } + } + if (curr !== last) tokens.length = last; +} +var _rules = [ + ["text", text], + ["linkify", linkify], + ["newline", newline], + ["escape", escape], + ["backticks", backtick], + ["strikethrough", strikethrough_default.tokenize], + ["emphasis", emphasis_default.tokenize], + ["link", link], + ["image", image], + ["autolink", autolink], + ["html_inline", html_inline], + ["entity", entity] +]; +var _rules2 = [ + ["balance_pairs", link_pairs], + ["strikethrough", strikethrough_default.postProcess], + ["emphasis", emphasis_default.postProcess], + ["fragments_join", fragments_join] +]; +var ParserInline = class { + constructor() { + _defineProperty( + this, + /** + * {@link Ruler} instance. Keep configuration of inline rules. + */ + "ruler", + new Ruler() + ); + _defineProperty( + this, + /** + * {@link Ruler} instance. Second ruler used for post-processing + * (e.g. in emphasis-like rules). + */ + "ruler2", + new Ruler() + ); + _defineProperty(this, "State", StateInline); + for (let i = 0; i < _rules.length; i++) this.ruler.push(_rules[i][0], _rules[i][1]); + for (let i = 0; i < _rules2.length; i++) this.ruler2.push(_rules2[i][0], _rules2[i][1]); + } + skipToken(state) { + const pos = state.pos; + const rules = this.ruler.getRules(""); + const len = rules.length; + const maxNesting = state.md.options.maxNesting; + const cache = state.cache; + if (typeof cache[pos] !== "undefined") { + state.pos = cache[pos]; + return; + } + let ok = false; + if (state.level < maxNesting) for (let i = 0; i < len; i++) { + state.level++; + ok = rules[i](state, true); + state.level--; + if (ok) { + if (pos >= state.pos) throw new Error("inline rule didn't increment state.pos"); + break; + } + } + else state.pos = state.posMax; + if (!ok) state.pos++; + cache[pos] = state.pos; + } + tokenize(state) { + const rules = this.ruler.getRules(""); + const len = rules.length; + const end = state.posMax; + const maxNesting = state.md.options.maxNesting; + while (state.pos < end) { + const prevPos = state.pos; + let ok = false; + if (state.level < maxNesting) for (let i = 0; i < len; i++) { + ok = rules[i](state, false); + if (ok) { + if (prevPos >= state.pos) throw new Error("inline rule didn't increment state.pos"); + break; + } + } + if (ok) { + if (state.pos >= end) break; + continue; + } + state.pending += state.src[state.pos++]; + } + if (state.pending) state.pushPending(); + } + /** + * Process input string and push inline tokens into `outTokens` + */ + parse(str, md, env, outTokens) { + const state = new this.State(str, md, env, outTokens); + this.tokenize(state); + const rules = this.ruler2.getRules(""); + const len = rules.length; + for (let i = 0; i < len; i++) rules[i](state); + } +}; +var config = { + default: { + options: { + html: false, + xhtmlOut: false, + breaks: false, + langPrefix: "language-", + linkify: false, + typographer: false, + quotes: "\u201C\u201D\u2018\u2019", + highlight: null, + maxNesting: 100 + }, + components: { + core: {}, + block: {}, + inline: {} + } + }, + zero: { + options: { + html: false, + xhtmlOut: false, + breaks: false, + langPrefix: "language-", + linkify: false, + typographer: false, + quotes: "\u201C\u201D\u2018\u2019", + highlight: null, + maxNesting: 20 + }, + components: { + core: { rules: [ + "normalize", + "block", + "strip_references", + "inline", + "text_join" + ] }, + block: { rules: ["paragraph"] }, + inline: { + rules: ["text"], + rules2: ["balance_pairs", "fragments_join"] + } + } + }, + commonmark: { + options: { + html: true, + xhtmlOut: true, + breaks: false, + langPrefix: "language-", + linkify: false, + typographer: false, + quotes: "\u201C\u201D\u2018\u2019", + highlight: null, + maxNesting: 20 + }, + components: { + core: { rules: [ + "normalize", + "block", + "strip_references", + "inline", + "text_join" + ] }, + block: { rules: [ + "blockquote", + "code", + "fence", + "heading", + "hr", + "html_block", + "lheading", + "list", + "reference", + "paragraph" + ] }, + inline: { + rules: [ + "autolink", + "backticks", + "emphasis", + "entity", + "escape", + "html_inline", + "image", + "link", + "newline", + "text" + ], + rules2: [ + "balance_pairs", + "emphasis", + "fragments_join" + ] + } + } + } +}; +var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/; +var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/; +var RECODE_HOSTNAME_FOR = [ + "http:", + "https:", + "mailto:" +]; +var MarkdownIt = class { + /** + * Link validation function. CommonMark allows too much in links. By default + * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas + * except some embedded image types. + * + * You can change this behaviour: + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * // enable everything + * md.validateLink = function () { return true; } + * ``` + */ + validateLink(url) { + const str = url.trim().toLowerCase(); + return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) : true; + } + /** + * Function used to encode link url to a machine-readable format, + * which includes url-encoding, punycode, etc. + */ + normalizeLink(url) { + const parsed = parse_default(url, true); + if (parsed.hostname) { + if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try { + parsed.hostname = punycode_es6_default.toASCII(parsed.hostname); + } catch (er) { + } + } + return encode_default(format(parsed)); + } + /** + * Function used to decode link url to a human-readable format` + */ + normalizeLinkText(url) { + const parsed = parse_default(url, true); + if (parsed.hostname) { + if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) try { + parsed.hostname = punycode_es6_default.toUnicode(parsed.hostname); + } catch (er) { + } + } + return decode_default(format(parsed), decode_default.defaultChars + "%"); + } + constructor(...args) { + _defineProperty( + this, + /** + * Instance of {@link ParserInline}. You may need it to add new rules when + * writing plugins. For simple rules control use {@link MarkdownIt.disable} + * and {@link MarkdownIt.enable}. + */ + "inline", + new ParserInline() + ); + _defineProperty( + this, + /** + * Instance of {@link ParserBlock}. You may need it to add new rules when + * writing plugins. For simple rules control use {@link MarkdownIt.disable} + * and {@link MarkdownIt.enable}. + */ + "block", + new ParserBlock() + ); + _defineProperty( + this, + /** + * Instance of {@link ParserCore} chain executor. You may need it to add new + * rules when writing plugins. For simple rules control use + * {@link MarkdownIt.disable} and {@link MarkdownIt.enable}. + */ + "core", + new ParserCore() + ); + _defineProperty( + this, + /** + * Instance of {@link Renderer}. Use it to modify output look. Or to add rendering + * rules for new token types, generated by plugins. + * + * See {@link Renderer} docs and + * [source code](https://github.com/markdown-it/markdown-it/blob/master/src/renderer.ts). + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * const md = new MarkdownIt() + * + * function myToken(tokens, idx, options, env, self) { + * //... + * return result; + * }; + * + * md.renderer.rules['my_token'] = myToken + * ``` + */ + "renderer", + new Renderer() + ); + _defineProperty( + this, + /** + * [linkify-it](https://github.com/markdown-it/linkify-it) instance. + * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/src/rules_core/linkify.ts) + * rule. + */ + "linkify", + new LinkifyIt() + ); + _defineProperty( + this, + /** + * Assorted utility functions, useful to write plugins. See details + * [here](https://github.com/markdown-it/markdown-it/blob/master/src/common/utils.ts). + */ + "utils", + utils_exports + ); + _defineProperty( + this, + /** + * Link components parser functions, useful to write plugins. See details + * [here](https://github.com/markdown-it/markdown-it/blob/master/src/helpers). + */ + "helpers", + Object.assign({}, helpers_exports) + ); + const [presetNameOrOptions, options] = args; + if (typeof presetNameOrOptions === "string") { + this.configure(presetNameOrOptions); + if (options) this.set(options); + } else { + this.configure("default"); + this.set(presetNameOrOptions || {}); + } + } + /** + * Set parser options (in the same format as in constructor). Probably, you + * will never need it, but you can change options after constructor call. + * + * __Note:__ To achieve the best possible performance, don't modify a + * `markdown-it` instance options on the fly. If you need multiple configurations + * it's best to create multiple instances and initialize each with separate + * config. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * + * const md = new MarkdownIt() + * .set({ html: true, breaks: true }) + * .set({ typographer: true }) + * ``` + */ + set(options) { + Object.assign(this.options, options); + return this; + } + /** + * Batch load of all options and compenent settings. This is internal method, + * and you probably will not need it. But if you will - see available presets + * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/src/presets) + * + * We strongly recommend to use presets instead of direct config loads. That + * will give better compatibility with next versions. + */ + configure(presets) { + let p; + if (typeof presets === "string") { + const presetName = presets; + p = config[presetName]; + if (!p) throw new Error(`Wrong 'markdown-it' preset "${presetName}", check name`); + } else p = presets; + if (!p) throw new Error("Wrong `markdown-it` preset, can't be empty"); + if (p.options) this.options = { ...p.options }; + const components = p.components; + if (components) { + var _components$inline; + [ + "core", + "block", + "inline" + ].forEach((name) => { + var _components$name; + const rules = (_components$name = components[name]) === null || _components$name === void 0 ? void 0 : _components$name.rules; + if (rules) this[name].ruler.enableOnly(rules); + }); + const rules2 = (_components$inline = components.inline) === null || _components$inline === void 0 ? void 0 : _components$inline.rules2; + if (rules2) this.inline.ruler2.enableOnly(rules2); + } + return this; + } + /** + * Enable list or rules. It will automatically find appropriate components, + * containing rules with given names. If rule not found, and `ignoreInvalid` + * not set - throws exception. + * + * @param list Rule name or list of rule names to enable. + * @param ignoreInvalid Set `true` to ignore errors when rule not found. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * + * const md = new MarkdownIt() + * .enable(['sub', 'sup']) + * .disable('smartquotes') + * ``` + */ + enable(list2, ignoreInvalid = false) { + let result = []; + if (!Array.isArray(list2)) list2 = [list2]; + [ + "core", + "block", + "inline" + ].forEach((chain) => { + result = result.concat(this[chain].ruler.enable(list2, true)); + }); + result = result.concat(this.inline.ruler2.enable(list2, true)); + const missed = list2.filter((name) => result.indexOf(name) < 0); + if (missed.length && !ignoreInvalid) throw new Error(`MarkdownIt. Failed to enable unknown rule(s): ${missed}`); + return this; + } + /** + * The same as {@link MarkdownIt.enable}, but turn specified rules off. + * + * @param list Rule name or list of rule names to disable. + * @param ignoreInvalid Set `true` to ignore errors when rule not found. + */ + disable(list2, ignoreInvalid = false) { + let result = []; + if (!Array.isArray(list2)) list2 = [list2]; + [ + "core", + "block", + "inline" + ].forEach((chain) => { + result = result.concat(this[chain].ruler.disable(list2, true)); + }); + result = result.concat(this.inline.ruler2.disable(list2, true)); + const missed = list2.filter((name) => result.indexOf(name) < 0); + if (missed.length && !ignoreInvalid) throw new Error(`MarkdownIt. Failed to disable unknown rule(s): ${missed}`); + return this; + } + /** + * Load specified plugin with given params into current parser instance. + * It's just a sugar to call `plugin(md, params)` with curring. + * + * @example + * ```javascript + * import MarkdownIt from 'markdown-it' + * import iterator from 'markdown-it-for-inline' + * + * const md = new MarkdownIt() + * .use(iterator, 'foo_replace', 'text', function (tokens, idx) { + * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar') + * }) + * ``` + */ + use(plugin, ...params) { + plugin.apply(plugin, [this, ...params]); + return this; + } + /** + * Parse input string and return list of block tokens (special token type + * "inline" will contain list of inline tokens). You should not call this + * method directly, until you write custom renderer (for example, to produce + * AST). + * + * `env` is used to pass data between "distributed" rules and return additional + * metadata like reference info, needed for the renderer. It also can be used to + * inject data in specific cases. Usually, you will be ok to pass `{}`, + * and then pass updated object to renderer. + * + * @param src Source string. + * @param env Environment sandbox. + */ + parse(src, env) { + if (typeof src !== "string") throw new Error("Input data should be a String"); + const state = new this.core.State(src, this, env); + this.core.process(state); + return state.tokens; + } + /** + * Render markdown string into html. It does all magic for you :). + * + * `env` can be used to inject additional metadata (`{}` by default). + * But you will not need it with high probability. See also comment + * in {@link MarkdownIt.parse}. + * + * @param src Source string. + * @param env Environment sandbox. + */ + render(src, env = {}) { + return this.renderer.render(this.parse(src, env), this.options, env); + } + /** + * The same as {@link MarkdownIt.parse} but skip all block rules. It returns + * the block tokens list with the single `inline` element, containing parsed + * inline tokens in `children` property. Also updates `env` object. + * + * @param src Source string. + * @param env Environment sandbox. + */ + parseInline(src, env) { + const state = new this.core.State(src, this, env); + state.inlineMode = true; + this.core.process(state); + return state.tokens; + } + /** + * Similar to {@link MarkdownIt.render} but for single paragraph content. + * Result will NOT be wrapped into `

` tags. + * + * @param src Source string. + * @param env Environment sandbox. + */ + renderInline(src, env = {}) { + return this.renderer.render(this.parseInline(src, env), this.options, env); + } +}; +_defineProperty(MarkdownIt, "Token", Token); +_defineProperty(MarkdownIt, "Ruler", Ruler); +_defineProperty(MarkdownIt, "Renderer", Renderer); +_defineProperty(MarkdownIt, "ParserCore", ParserCore); +_defineProperty(MarkdownIt, "StateCore", StateCore); +_defineProperty(MarkdownIt, "ParserBlock", ParserBlock); +_defineProperty(MarkdownIt, "StateBlock", StateBlock); +_defineProperty(MarkdownIt, "ParserInline", ParserInline); +_defineProperty(MarkdownIt, "StateInline", StateInline); +var MarkdownItCallable = callable(MarkdownIt); + +// node_modules/highlight.js/es/core.js +var import_core = __toESM(require_core(), 1); +var core_default = import_core.default; + +// node_modules/highlight.js/es/languages/typescript.js +var IDENT_RE = "[A-Za-z$_][0-9A-Za-z$_]*"; +var KEYWORDS = [ + "as", + // for exports + "in", + "of", + "if", + "for", + "while", + "finally", + "var", + "new", + "function", + "do", + "return", + "void", + "else", + "break", + "catch", + "instanceof", + "with", + "throw", + "case", + "default", + "try", + "switch", + "continue", + "typeof", + "delete", + "let", + "yield", + "const", + "class", + // JS handles these with a special rule + // "get", + // "set", + "debugger", + "async", + "await", + "static", + "import", + "from", + "export", + "extends", + // It's reached stage 3, which is "recommended for implementation": + "using" +]; +var LITERALS = [ + "true", + "false", + "null", + "undefined", + "NaN", + "Infinity" +]; +var TYPES = [ + // Fundamental objects + "Object", + "Function", + "Boolean", + "Symbol", + // numbers and dates + "Math", + "Date", + "Number", + "BigInt", + // text + "String", + "RegExp", + // Indexed collections + "Array", + "Float32Array", + "Float64Array", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Int32Array", + "Uint16Array", + "Uint32Array", + "BigInt64Array", + "BigUint64Array", + // Keyed collections + "Set", + "Map", + "WeakSet", + "WeakMap", + // Structured data + "ArrayBuffer", + "SharedArrayBuffer", + "Atomics", + "DataView", + "JSON", + // Control abstraction objects + "Promise", + "Generator", + "GeneratorFunction", + "AsyncFunction", + // Reflection + "Reflect", + "Proxy", + // Internationalization + "Intl", + // WebAssembly + "WebAssembly" +]; +var ERROR_TYPES = [ + "Error", + "EvalError", + "InternalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError" +]; +var BUILT_IN_GLOBALS = [ + "setInterval", + "setTimeout", + "clearInterval", + "clearTimeout", + "require", + "exports", + "eval", + "isFinite", + "isNaN", + "parseFloat", + "parseInt", + "decodeURI", + "decodeURIComponent", + "encodeURI", + "encodeURIComponent", + "escape", + "unescape" +]; +var BUILT_IN_VARIABLES = [ + "arguments", + "this", + "super", + "console", + "window", + "document", + "localStorage", + "sessionStorage", + "module", + "self", + "global" + // Node.js +]; +var BUILT_INS = [].concat( + BUILT_IN_GLOBALS, + TYPES, + ERROR_TYPES +); +function javascript(hljs) { + const regex = hljs.regex; + const hasClosingTag = (match, { after }) => { + const tag = "", + end: "" + }; + const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; + const XML_TAG = { + begin: /<[A-Za-z0-9\\._:-]+/, + end: /\/[A-Za-z0-9\\._:-]+>|\/>/, + /** + * @param {RegExpMatchArray} match + * @param {CallbackResponse} response + */ + isTrulyOpeningTag: (match, response) => { + const afterMatchIndex = match[0].length + match.index; + const nextChar = match.input[afterMatchIndex]; + if ( + // HTML should not include another raw `<` inside a tag + // nested type? + // `>`, etc. + nextChar === "<" || // the , gives away that this is not HTML + // `` + nextChar === "," + ) { + response.ignoreMatch(); + return; + } + if (nextChar === ">") { + if (!hasClosingTag(match, { after: afterMatchIndex })) { + response.ignoreMatch(); + } + } + let m; + const afterMatch = match.input.substring(afterMatchIndex); + if (m = afterMatch.match(/^\s*=/)) { + response.ignoreMatch(); + return; + } + if (m = afterMatch.match(/^\s+extends\s+/)) { + if (m.index === 0) { + response.ignoreMatch(); + return; + } + } + } + }; + const KEYWORDS$1 = { + $pattern: IDENT_RE, + keyword: KEYWORDS, + literal: LITERALS, + built_in: BUILT_INS, + "variable.language": BUILT_IN_VARIABLES + }; + const decimalDigits = "[0-9](_?[0-9])*"; + const frac = `\\.(${decimalDigits})`; + const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`; + const NUMBER = { + className: "number", + variants: [ + // DecimalLiteral + { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))[eE][+-]?(${decimalDigits})\\b` }, + { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` }, + // DecimalBigIntegerLiteral + { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` }, + // NonDecimalIntegerLiteral + { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" }, + { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" }, + { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" }, + // LegacyOctalIntegerLiteral (does not include underscore separators) + // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals + { begin: "\\b0[0-7]+n?\\b" } + ], + relevance: 0 + }; + const SUBST = { + className: "subst", + begin: "\\$\\{", + end: "\\}", + keywords: KEYWORDS$1, + contains: [] + // defined later + }; + const HTML_TEMPLATE = { + begin: ".?html`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "xml" + } + }; + const CSS_TEMPLATE = { + begin: ".?css`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "css" + } + }; + const GRAPHQL_TEMPLATE = { + begin: ".?gql`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "graphql" + } + }; + const TEMPLATE_STRING = { + className: "string", + begin: "`", + end: "`", + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ] + }; + const JSDOC_COMMENT = hljs.COMMENT( + /\/\*\*(?!\/)/, + "\\*/", + { + relevance: 0, + contains: [ + { + begin: "(?=@[A-Za-z]+)", + relevance: 0, + contains: [ + { + className: "doctag", + begin: "@[A-Za-z]+" + }, + { + className: "type", + begin: "\\{", + end: "\\}", + excludeEnd: true, + excludeBegin: true, + relevance: 0 + }, + { + className: "variable", + begin: IDENT_RE$1 + "(?=\\s*(-)|$)", + endsParent: true, + relevance: 0 + }, + // eat spaces (not newlines) so we can find + // types or variables + { + begin: /(?=[^\n])\s/, + relevance: 0 + } + ] + } + ] + } + ); + const COMMENT = { + className: "comment", + variants: [ + JSDOC_COMMENT, + hljs.C_BLOCK_COMMENT_MODE, + hljs.C_LINE_COMMENT_MODE + ] + }; + const SUBST_INTERNALS = [ + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + HTML_TEMPLATE, + CSS_TEMPLATE, + GRAPHQL_TEMPLATE, + TEMPLATE_STRING, + // Skip numbers when they are part of a variable name + { match: /\$\d+/ }, + NUMBER + // This is intentional: + // See https://github.com/highlightjs/highlight.js/issues/3288 + // hljs.REGEXP_MODE + ]; + SUBST.contains = SUBST_INTERNALS.concat({ + // we need to pair up {} inside our subst to prevent + // it from ending too early by matching another } + begin: /\{/, + end: /\}/, + keywords: KEYWORDS$1, + contains: [ + "self" + ].concat(SUBST_INTERNALS) + }); + const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains); + const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([ + // eat recursive parens in sub expressions + { + begin: /(\s*)\(/, + end: /\)/, + keywords: KEYWORDS$1, + contains: ["self"].concat(SUBST_AND_COMMENTS) + } + ]); + const PARAMS = { + className: "params", + // convert this to negative lookbehind in v12 + begin: /(\s*)\(/, + // to match the parms with + end: /\)/, + excludeBegin: true, + excludeEnd: true, + keywords: KEYWORDS$1, + contains: PARAMS_CONTAINS + }; + const CLASS_OR_EXTENDS = { + variants: [ + // class Car extends vehicle + { + match: [ + /class/, + /\s+/, + IDENT_RE$1, + /\s+/, + /extends/, + /\s+/, + regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") + ], + scope: { + 1: "keyword", + 3: "title.class", + 5: "keyword", + 7: "title.class.inherited" + } + }, + // class Car + { + match: [ + /class/, + /\s+/, + IDENT_RE$1 + ], + scope: { + 1: "keyword", + 3: "title.class" + } + } + ] + }; + const CLASS_REFERENCE = { + relevance: 0, + match: regex.either( + // Hard coded exceptions + /\bJSON/, + // Float32Array, OutT + /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, + // CSSFactory, CSSFactoryT + /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, + // FPs, FPsT + /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/ + // P + // single letters are not highlighted + // BLAH + // this will be flagged as a UPPER_CASE_CONSTANT instead + ), + className: "title.class", + keywords: { + _: [ + // se we still get relevance credit for JS library classes + ...TYPES, + ...ERROR_TYPES + ] + } + }; + const USE_STRICT = { + label: "use_strict", + className: "meta", + relevance: 10, + begin: /^\s*['"]use (strict|asm)['"]/ + }; + const FUNCTION_DEFINITION = { + variants: [ + { + match: [ + /function/, + /\s+/, + IDENT_RE$1, + /(?=\s*\()/ + ] + }, + // anonymous function + { + match: [ + /function/, + /\s*(?=\()/ + ] + } + ], + className: { + 1: "keyword", + 3: "title.function" + }, + label: "func.def", + contains: [PARAMS], + illegal: /%/ + }; + const UPPER_CASE_CONSTANT = { + relevance: 0, + match: /\b[A-Z][A-Z_0-9]+\b/, + className: "variable.constant" + }; + function noneOf(list2) { + return regex.concat("(?!", list2.join("|"), ")"); + } + const FUNCTION_CALL = { + match: regex.concat( + /\b/, + noneOf([ + ...BUILT_IN_GLOBALS, + "super", + "import", + "await" + ].map((x) => `${x}\\s*\\(`)), + IDENT_RE$1, + regex.lookahead(/\s*\(/) + ), + className: "title.function", + relevance: 0 + }; + const PROPERTY_ACCESS = { + begin: regex.concat(/\./, regex.lookahead( + regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) + )), + end: IDENT_RE$1, + excludeBegin: true, + keywords: "prototype", + className: "property", + relevance: 0 + }; + const GETTER_OR_SETTER = { + match: [ + /get|set/, + /\s+/, + IDENT_RE$1, + /(?=\()/ + ], + className: { + 1: "keyword", + 3: "title.function" + }, + contains: [ + { + // eat to avoid empty params + begin: /\(\)/ + }, + PARAMS + ] + }; + const FUNC_LEAD_IN_RE = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + hljs.UNDERSCORE_IDENT_RE + ")\\s*=>"; + const FUNCTION_VARIABLE = { + match: [ + /const|var|let/, + /\s+/, + IDENT_RE$1, + /\s*/, + /=\s*/, + /(async\s*)?/, + // async is optional + regex.lookahead(FUNC_LEAD_IN_RE) + ], + keywords: "async", + className: { + 1: "keyword", + 3: "title.function" + }, + contains: [ + PARAMS + ] + }; + return { + name: "JavaScript", + aliases: ["js", "jsx", "mjs", "cjs"], + keywords: KEYWORDS$1, + // this will be extended by TypeScript + exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, + illegal: /#(?![$_A-Za-z])/, + contains: [ + hljs.SHEBANG({ + label: "shebang", + binary: "node", + relevance: 5 + }), + USE_STRICT, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + HTML_TEMPLATE, + CSS_TEMPLATE, + GRAPHQL_TEMPLATE, + TEMPLATE_STRING, + COMMENT, + // Skip numbers when they are part of a variable name + { match: /\$\d+/ }, + NUMBER, + CLASS_REFERENCE, + { + scope: "attr", + match: IDENT_RE$1 + regex.lookahead(":"), + relevance: 0 + }, + FUNCTION_VARIABLE, + { + // "value" container + begin: "(" + hljs.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*", + keywords: "return throw case", + relevance: 0, + contains: [ + COMMENT, + hljs.REGEXP_MODE, + { + className: "function", + // we have to count the parens to make sure we actually have the + // correct bounding ( ) before the =>. There could be any number of + // sub-expressions inside also surrounded by parens. + begin: FUNC_LEAD_IN_RE, + returnBegin: true, + end: "\\s*=>", + contains: [ + { + className: "params", + variants: [ + { + begin: hljs.UNDERSCORE_IDENT_RE, + relevance: 0 + }, + { + className: null, + begin: /\(\s*\)/, + skip: true + }, + { + begin: /(\s*)\(/, + end: /\)/, + excludeBegin: true, + excludeEnd: true, + keywords: KEYWORDS$1, + contains: PARAMS_CONTAINS + } + ] + } + ] + }, + { + // could be a comma delimited list of params to a function call + begin: /,/, + relevance: 0 + }, + { + match: /\s+/, + relevance: 0 + }, + { + // JSX + variants: [ + { begin: FRAGMENT.begin, end: FRAGMENT.end }, + { match: XML_SELF_CLOSING }, + { + begin: XML_TAG.begin, + // we carefully check the opening tag to see if it truly + // is a tag and not a false positive + "on:begin": XML_TAG.isTrulyOpeningTag, + end: XML_TAG.end + } + ], + subLanguage: "xml", + contains: [ + { + begin: XML_TAG.begin, + end: XML_TAG.end, + skip: true, + contains: ["self"] + } + ] + } + ] + }, + FUNCTION_DEFINITION, + { + // prevent this from getting swallowed up by function + // since they appear "function like" + beginKeywords: "while if switch catch for" + }, + { + // we have to count the parens to make sure we actually have the correct + // bounding ( ). There could be any number of sub-expressions inside + // also surrounded by parens. + begin: "\\b(?!function)" + hljs.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{", + // end parens + returnBegin: true, + label: "func.def", + contains: [ + PARAMS, + hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: "title.function" }) + ] + }, + // catch ... so it won't trigger the property rule below + { + match: /\.\.\./, + relevance: 0 + }, + PROPERTY_ACCESS, + // hack: prevents detection of keywords in some circumstances + // .keyword() + // $keyword = x + { + match: "\\$" + IDENT_RE$1, + relevance: 0 + }, + { + match: [/\bconstructor(?=\s*\()/], + className: { 1: "title.function" }, + contains: [PARAMS] + }, + FUNCTION_CALL, + UPPER_CASE_CONSTANT, + CLASS_OR_EXTENDS, + GETTER_OR_SETTER, + { + match: /\$[(.]/ + // relevance booster for a pattern common to JS libs: `$(something)` and `$.something` + } + ] + }; +} +function typescript(hljs) { + const regex = hljs.regex; + const tsLanguage = javascript(hljs); + const IDENT_RE$1 = IDENT_RE; + const TYPES3 = [ + "any", + "void", + "number", + "boolean", + "string", + "object", + "never", + "symbol", + "bigint", + "unknown" + ]; + const NAMESPACE = { + begin: [ + /namespace/, + /\s+/, + hljs.IDENT_RE + ], + beginScope: { + 1: "keyword", + 3: "title.class" + } + }; + const INTERFACE = { + beginKeywords: "interface", + end: /\{/, + excludeEnd: true, + keywords: { + keyword: "interface extends", + built_in: TYPES3 + }, + contains: [tsLanguage.exports.CLASS_REFERENCE] + }; + const USE_STRICT = { + className: "meta", + relevance: 10, + begin: /^\s*['"]use strict['"]/ + }; + const TS_SPECIFIC_KEYWORDS = [ + "type", + // "namespace", + "interface", + "public", + "private", + "protected", + "implements", + "declare", + "abstract", + "readonly", + "enum", + "override", + "satisfies" + ]; + const KEYWORDS$1 = { + $pattern: IDENT_RE, + keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS), + literal: LITERALS, + built_in: BUILT_INS.concat(TYPES3), + "variable.language": BUILT_IN_VARIABLES + }; + const DECORATOR = { + className: "meta", + begin: "@" + IDENT_RE$1 + }; + const swapMode = (mode, label, replacement) => { + const indx = mode.contains.findIndex((m) => m.label === label); + if (indx === -1) { + throw new Error("can not find mode to replace"); + } + mode.contains.splice(indx, 1, replacement); + }; + Object.assign(tsLanguage.keywords, KEYWORDS$1); + tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR); + const ATTRIBUTE_HIGHLIGHT = tsLanguage.contains.find((c) => c.scope === "attr"); + const OPTIONAL_KEY_OR_ARGUMENT = Object.assign( + {}, + ATTRIBUTE_HIGHLIGHT, + { match: regex.concat(IDENT_RE$1, regex.lookahead(/\s*\?:/)) } + ); + tsLanguage.exports.PARAMS_CONTAINS.push([ + tsLanguage.exports.CLASS_REFERENCE, + // class reference for highlighting the params types + ATTRIBUTE_HIGHLIGHT, + // highlight the params key + OPTIONAL_KEY_OR_ARGUMENT + // Added for optional property assignment highlighting + ]); + tsLanguage.contains = tsLanguage.contains.concat([ + DECORATOR, + NAMESPACE, + INTERFACE, + OPTIONAL_KEY_OR_ARGUMENT + // Added for optional property assignment highlighting + ]); + swapMode(tsLanguage, "shebang", hljs.SHEBANG()); + swapMode(tsLanguage, "use_strict", USE_STRICT); + const functionDeclaration = tsLanguage.contains.find((m) => m.label === "func.def"); + functionDeclaration.relevance = 0; + Object.assign(tsLanguage, { + name: "TypeScript", + aliases: [ + "ts", + "tsx", + "mts", + "cts" + ] + }); + return tsLanguage; +} + +// node_modules/highlight.js/es/languages/javascript.js +var IDENT_RE2 = "[A-Za-z$_][0-9A-Za-z$_]*"; +var KEYWORDS2 = [ + "as", + // for exports + "in", + "of", + "if", + "for", + "while", + "finally", + "var", + "new", + "function", + "do", + "return", + "void", + "else", + "break", + "catch", + "instanceof", + "with", + "throw", + "case", + "default", + "try", + "switch", + "continue", + "typeof", + "delete", + "let", + "yield", + "const", + "class", + // JS handles these with a special rule + // "get", + // "set", + "debugger", + "async", + "await", + "static", + "import", + "from", + "export", + "extends", + // It's reached stage 3, which is "recommended for implementation": + "using" +]; +var LITERALS2 = [ + "true", + "false", + "null", + "undefined", + "NaN", + "Infinity" +]; +var TYPES2 = [ + // Fundamental objects + "Object", + "Function", + "Boolean", + "Symbol", + // numbers and dates + "Math", + "Date", + "Number", + "BigInt", + // text + "String", + "RegExp", + // Indexed collections + "Array", + "Float32Array", + "Float64Array", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Int32Array", + "Uint16Array", + "Uint32Array", + "BigInt64Array", + "BigUint64Array", + // Keyed collections + "Set", + "Map", + "WeakSet", + "WeakMap", + // Structured data + "ArrayBuffer", + "SharedArrayBuffer", + "Atomics", + "DataView", + "JSON", + // Control abstraction objects + "Promise", + "Generator", + "GeneratorFunction", + "AsyncFunction", + // Reflection + "Reflect", + "Proxy", + // Internationalization + "Intl", + // WebAssembly + "WebAssembly" +]; +var ERROR_TYPES2 = [ + "Error", + "EvalError", + "InternalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError" +]; +var BUILT_IN_GLOBALS2 = [ + "setInterval", + "setTimeout", + "clearInterval", + "clearTimeout", + "require", + "exports", + "eval", + "isFinite", + "isNaN", + "parseFloat", + "parseInt", + "decodeURI", + "decodeURIComponent", + "encodeURI", + "encodeURIComponent", + "escape", + "unescape" +]; +var BUILT_IN_VARIABLES2 = [ + "arguments", + "this", + "super", + "console", + "window", + "document", + "localStorage", + "sessionStorage", + "module", + "self", + "global" + // Node.js +]; +var BUILT_INS2 = [].concat( + BUILT_IN_GLOBALS2, + TYPES2, + ERROR_TYPES2 +); +function javascript2(hljs) { + const regex = hljs.regex; + const hasClosingTag = (match, { after }) => { + const tag = "", + end: "" + }; + const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; + const XML_TAG = { + begin: /<[A-Za-z0-9\\._:-]+/, + end: /\/[A-Za-z0-9\\._:-]+>|\/>/, + /** + * @param {RegExpMatchArray} match + * @param {CallbackResponse} response + */ + isTrulyOpeningTag: (match, response) => { + const afterMatchIndex = match[0].length + match.index; + const nextChar = match.input[afterMatchIndex]; + if ( + // HTML should not include another raw `<` inside a tag + // nested type? + // `>`, etc. + nextChar === "<" || // the , gives away that this is not HTML + // `` + nextChar === "," + ) { + response.ignoreMatch(); + return; + } + if (nextChar === ">") { + if (!hasClosingTag(match, { after: afterMatchIndex })) { + response.ignoreMatch(); + } + } + let m; + const afterMatch = match.input.substring(afterMatchIndex); + if (m = afterMatch.match(/^\s*=/)) { + response.ignoreMatch(); + return; + } + if (m = afterMatch.match(/^\s+extends\s+/)) { + if (m.index === 0) { + response.ignoreMatch(); + return; + } + } + } + }; + const KEYWORDS$1 = { + $pattern: IDENT_RE2, + keyword: KEYWORDS2, + literal: LITERALS2, + built_in: BUILT_INS2, + "variable.language": BUILT_IN_VARIABLES2 + }; + const decimalDigits = "[0-9](_?[0-9])*"; + const frac = `\\.(${decimalDigits})`; + const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`; + const NUMBER = { + className: "number", + variants: [ + // DecimalLiteral + { begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))[eE][+-]?(${decimalDigits})\\b` }, + { begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` }, + // DecimalBigIntegerLiteral + { begin: `\\b(0|[1-9](_?[0-9])*)n\\b` }, + // NonDecimalIntegerLiteral + { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" }, + { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" }, + { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" }, + // LegacyOctalIntegerLiteral (does not include underscore separators) + // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals + { begin: "\\b0[0-7]+n?\\b" } + ], + relevance: 0 + }; + const SUBST = { + className: "subst", + begin: "\\$\\{", + end: "\\}", + keywords: KEYWORDS$1, + contains: [] + // defined later + }; + const HTML_TEMPLATE = { + begin: ".?html`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "xml" + } + }; + const CSS_TEMPLATE = { + begin: ".?css`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "css" + } + }; + const GRAPHQL_TEMPLATE = { + begin: ".?gql`", + end: "", + starts: { + end: "`", + returnEnd: false, + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ], + subLanguage: "graphql" + } + }; + const TEMPLATE_STRING = { + className: "string", + begin: "`", + end: "`", + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ] + }; + const JSDOC_COMMENT = hljs.COMMENT( + /\/\*\*(?!\/)/, + "\\*/", + { + relevance: 0, + contains: [ + { + begin: "(?=@[A-Za-z]+)", + relevance: 0, + contains: [ + { + className: "doctag", + begin: "@[A-Za-z]+" + }, + { + className: "type", + begin: "\\{", + end: "\\}", + excludeEnd: true, + excludeBegin: true, + relevance: 0 + }, + { + className: "variable", + begin: IDENT_RE$1 + "(?=\\s*(-)|$)", + endsParent: true, + relevance: 0 + }, + // eat spaces (not newlines) so we can find + // types or variables + { + begin: /(?=[^\n])\s/, + relevance: 0 + } + ] + } + ] + } + ); + const COMMENT = { + className: "comment", + variants: [ + JSDOC_COMMENT, + hljs.C_BLOCK_COMMENT_MODE, + hljs.C_LINE_COMMENT_MODE + ] + }; + const SUBST_INTERNALS = [ + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + HTML_TEMPLATE, + CSS_TEMPLATE, + GRAPHQL_TEMPLATE, + TEMPLATE_STRING, + // Skip numbers when they are part of a variable name + { match: /\$\d+/ }, + NUMBER + // This is intentional: + // See https://github.com/highlightjs/highlight.js/issues/3288 + // hljs.REGEXP_MODE + ]; + SUBST.contains = SUBST_INTERNALS.concat({ + // we need to pair up {} inside our subst to prevent + // it from ending too early by matching another } + begin: /\{/, + end: /\}/, + keywords: KEYWORDS$1, + contains: [ + "self" + ].concat(SUBST_INTERNALS) + }); + const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains); + const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([ + // eat recursive parens in sub expressions + { + begin: /(\s*)\(/, + end: /\)/, + keywords: KEYWORDS$1, + contains: ["self"].concat(SUBST_AND_COMMENTS) + } + ]); + const PARAMS = { + className: "params", + // convert this to negative lookbehind in v12 + begin: /(\s*)\(/, + // to match the parms with + end: /\)/, + excludeBegin: true, + excludeEnd: true, + keywords: KEYWORDS$1, + contains: PARAMS_CONTAINS + }; + const CLASS_OR_EXTENDS = { + variants: [ + // class Car extends vehicle + { + match: [ + /class/, + /\s+/, + IDENT_RE$1, + /\s+/, + /extends/, + /\s+/, + regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") + ], + scope: { + 1: "keyword", + 3: "title.class", + 5: "keyword", + 7: "title.class.inherited" + } + }, + // class Car + { + match: [ + /class/, + /\s+/, + IDENT_RE$1 + ], + scope: { + 1: "keyword", + 3: "title.class" + } + } + ] + }; + const CLASS_REFERENCE = { + relevance: 0, + match: regex.either( + // Hard coded exceptions + /\bJSON/, + // Float32Array, OutT + /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, + // CSSFactory, CSSFactoryT + /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, + // FPs, FPsT + /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/ + // P + // single letters are not highlighted + // BLAH + // this will be flagged as a UPPER_CASE_CONSTANT instead + ), + className: "title.class", + keywords: { + _: [ + // se we still get relevance credit for JS library classes + ...TYPES2, + ...ERROR_TYPES2 + ] + } + }; + const USE_STRICT = { + label: "use_strict", + className: "meta", + relevance: 10, + begin: /^\s*['"]use (strict|asm)['"]/ + }; + const FUNCTION_DEFINITION = { + variants: [ + { + match: [ + /function/, + /\s+/, + IDENT_RE$1, + /(?=\s*\()/ + ] + }, + // anonymous function + { + match: [ + /function/, + /\s*(?=\()/ + ] + } + ], + className: { + 1: "keyword", + 3: "title.function" + }, + label: "func.def", + contains: [PARAMS], + illegal: /%/ + }; + const UPPER_CASE_CONSTANT = { + relevance: 0, + match: /\b[A-Z][A-Z_0-9]+\b/, + className: "variable.constant" + }; + function noneOf(list2) { + return regex.concat("(?!", list2.join("|"), ")"); + } + const FUNCTION_CALL = { + match: regex.concat( + /\b/, + noneOf([ + ...BUILT_IN_GLOBALS2, + "super", + "import", + "await" + ].map((x) => `${x}\\s*\\(`)), + IDENT_RE$1, + regex.lookahead(/\s*\(/) + ), + className: "title.function", + relevance: 0 + }; + const PROPERTY_ACCESS = { + begin: regex.concat(/\./, regex.lookahead( + regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) + )), + end: IDENT_RE$1, + excludeBegin: true, + keywords: "prototype", + className: "property", + relevance: 0 + }; + const GETTER_OR_SETTER = { + match: [ + /get|set/, + /\s+/, + IDENT_RE$1, + /(?=\()/ + ], + className: { + 1: "keyword", + 3: "title.function" + }, + contains: [ + { + // eat to avoid empty params + begin: /\(\)/ + }, + PARAMS + ] + }; + const FUNC_LEAD_IN_RE = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + hljs.UNDERSCORE_IDENT_RE + ")\\s*=>"; + const FUNCTION_VARIABLE = { + match: [ + /const|var|let/, + /\s+/, + IDENT_RE$1, + /\s*/, + /=\s*/, + /(async\s*)?/, + // async is optional + regex.lookahead(FUNC_LEAD_IN_RE) + ], + keywords: "async", + className: { + 1: "keyword", + 3: "title.function" + }, + contains: [ + PARAMS + ] + }; + return { + name: "JavaScript", + aliases: ["js", "jsx", "mjs", "cjs"], + keywords: KEYWORDS$1, + // this will be extended by TypeScript + exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, + illegal: /#(?![$_A-Za-z])/, + contains: [ + hljs.SHEBANG({ + label: "shebang", + binary: "node", + relevance: 5 + }), + USE_STRICT, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + HTML_TEMPLATE, + CSS_TEMPLATE, + GRAPHQL_TEMPLATE, + TEMPLATE_STRING, + COMMENT, + // Skip numbers when they are part of a variable name + { match: /\$\d+/ }, + NUMBER, + CLASS_REFERENCE, + { + scope: "attr", + match: IDENT_RE$1 + regex.lookahead(":"), + relevance: 0 + }, + FUNCTION_VARIABLE, + { + // "value" container + begin: "(" + hljs.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*", + keywords: "return throw case", + relevance: 0, + contains: [ + COMMENT, + hljs.REGEXP_MODE, + { + className: "function", + // we have to count the parens to make sure we actually have the + // correct bounding ( ) before the =>. There could be any number of + // sub-expressions inside also surrounded by parens. + begin: FUNC_LEAD_IN_RE, + returnBegin: true, + end: "\\s*=>", + contains: [ + { + className: "params", + variants: [ + { + begin: hljs.UNDERSCORE_IDENT_RE, + relevance: 0 + }, + { + className: null, + begin: /\(\s*\)/, + skip: true + }, + { + begin: /(\s*)\(/, + end: /\)/, + excludeBegin: true, + excludeEnd: true, + keywords: KEYWORDS$1, + contains: PARAMS_CONTAINS + } + ] + } + ] + }, + { + // could be a comma delimited list of params to a function call + begin: /,/, + relevance: 0 + }, + { + match: /\s+/, + relevance: 0 + }, + { + // JSX + variants: [ + { begin: FRAGMENT.begin, end: FRAGMENT.end }, + { match: XML_SELF_CLOSING }, + { + begin: XML_TAG.begin, + // we carefully check the opening tag to see if it truly + // is a tag and not a false positive + "on:begin": XML_TAG.isTrulyOpeningTag, + end: XML_TAG.end + } + ], + subLanguage: "xml", + contains: [ + { + begin: XML_TAG.begin, + end: XML_TAG.end, + skip: true, + contains: ["self"] + } + ] + } + ] + }, + FUNCTION_DEFINITION, + { + // prevent this from getting swallowed up by function + // since they appear "function like" + beginKeywords: "while if switch catch for" + }, + { + // we have to count the parens to make sure we actually have the correct + // bounding ( ). There could be any number of sub-expressions inside + // also surrounded by parens. + begin: "\\b(?!function)" + hljs.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{", + // end parens + returnBegin: true, + label: "func.def", + contains: [ + PARAMS, + hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: "title.function" }) + ] + }, + // catch ... so it won't trigger the property rule below + { + match: /\.\.\./, + relevance: 0 + }, + PROPERTY_ACCESS, + // hack: prevents detection of keywords in some circumstances + // .keyword() + // $keyword = x + { + match: "\\$" + IDENT_RE$1, + relevance: 0 + }, + { + match: [/\bconstructor(?=\s*\()/], + className: { 1: "title.function" }, + contains: [PARAMS] + }, + FUNCTION_CALL, + UPPER_CASE_CONSTANT, + CLASS_OR_EXTENDS, + GETTER_OR_SETTER, + { + match: /\$[(.]/ + // relevance booster for a pattern common to JS libs: `$(something)` and `$.something` + } + ] + }; +} + +// node_modules/highlight.js/es/languages/css.js +var MODES = (hljs) => { + return { + IMPORTANT: { + scope: "meta", + begin: "!important" + }, + BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, + HEXCOLOR: { + scope: "number", + begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ + }, + UNICODE_RANGE: { + scope: "number", + begin: /\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/ + }, + FUNCTION_DISPATCH: { + className: "built_in", + begin: /[\w-]+(?=\()/ + }, + ATTRIBUTE_SELECTOR_MODE: { + scope: "selector-attr", + begin: /\[/, + end: /\]/, + illegal: "$", + contains: [ + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE + ] + }, + CSS_NUMBER_MODE: { + scope: "number", + begin: hljs.NUMBER_RE + "(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?", + relevance: 0 + }, + CSS_VARIABLE: { + className: "attr", + begin: /--[A-Za-z_][A-Za-z0-9_-]*/ + } + }; +}; +var HTML_TAGS = [ + "a", + "abbr", + "address", + "article", + "aside", + "audio", + "b", + "blockquote", + "body", + "button", + "canvas", + "caption", + "cite", + "code", + "dd", + "del", + "details", + "dfn", + "div", + "dl", + "dt", + "em", + "fieldset", + "figcaption", + "figure", + "footer", + "form", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "header", + "hgroup", + "html", + "i", + "iframe", + "img", + "input", + "ins", + "kbd", + "label", + "legend", + "li", + "main", + "mark", + "menu", + "nav", + "object", + "ol", + "optgroup", + "option", + "p", + "picture", + "q", + "quote", + "samp", + "section", + "select", + "source", + "span", + "strong", + "summary", + "sup", + "table", + "tbody", + "td", + "textarea", + "tfoot", + "th", + "thead", + "time", + "tr", + "ul", + "var", + "video" +]; +var SVG_TAGS = [ + "defs", + "g", + "marker", + "mask", + "pattern", + "svg", + "switch", + "symbol", + "feBlend", + "feColorMatrix", + "feComponentTransfer", + "feComposite", + "feConvolveMatrix", + "feDiffuseLighting", + "feDisplacementMap", + "feFlood", + "feGaussianBlur", + "feImage", + "feMerge", + "feMorphology", + "feOffset", + "feSpecularLighting", + "feTile", + "feTurbulence", + "linearGradient", + "radialGradient", + "stop", + "circle", + "ellipse", + "image", + "line", + "path", + "polygon", + "polyline", + "rect", + "text", + "use", + "textPath", + "tspan", + "foreignObject", + "clipPath" +]; +var TAGS = [ + ...HTML_TAGS, + ...SVG_TAGS +]; +var MEDIA_FEATURES = [ + "any-hover", + "any-pointer", + "aspect-ratio", + "color", + "color-gamut", + "color-index", + "device-aspect-ratio", + "device-height", + "device-width", + "display-mode", + "forced-colors", + "grid", + "height", + "hover", + "inverted-colors", + "monochrome", + "orientation", + "overflow-block", + "overflow-inline", + "pointer", + "prefers-color-scheme", + "prefers-contrast", + "prefers-reduced-motion", + "prefers-reduced-transparency", + "resolution", + "scan", + "scripting", + "update", + "width", + // TODO: find a better solution? + "min-width", + "max-width", + "min-height", + "max-height" +].sort().reverse(); +var PSEUDO_CLASSES = [ + "active", + "any-link", + "blank", + "checked", + "current", + "default", + "defined", + "dir", + // dir() + "disabled", + "drop", + "empty", + "enabled", + "first", + "first-child", + "first-of-type", + "fullscreen", + "future", + "focus", + "focus-visible", + "focus-within", + "has", + // has() + "host", + // host or host() + "host-context", + // host-context() + "hover", + "indeterminate", + "in-range", + "invalid", + "is", + // is() + "lang", + // lang() + "last-child", + "last-of-type", + "left", + "link", + "local-link", + "not", + // not() + "nth-child", + // nth-child() + "nth-col", + // nth-col() + "nth-last-child", + // nth-last-child() + "nth-last-col", + // nth-last-col() + "nth-last-of-type", + //nth-last-of-type() + "nth-of-type", + //nth-of-type() + "only-child", + "only-of-type", + "optional", + "out-of-range", + "past", + "placeholder-shown", + "read-only", + "read-write", + "required", + "right", + "root", + "scope", + "target", + "target-within", + "user-invalid", + "valid", + "visited", + "where" + // where() +].sort().reverse(); +var PSEUDO_ELEMENTS = [ + "after", + "backdrop", + "before", + "cue", + "cue-region", + "first-letter", + "first-line", + "grammar-error", + "marker", + "part", + "placeholder", + "selection", + "slotted", + "spelling-error" +].sort().reverse(); +var ATTRIBUTES = [ + "accent-color", + "align-content", + "align-items", + "align-self", + "alignment-baseline", + "all", + "anchor-name", + "animation", + "animation-composition", + "animation-delay", + "animation-direction", + "animation-duration", + "animation-fill-mode", + "animation-iteration-count", + "animation-name", + "animation-play-state", + "animation-range", + "animation-range-end", + "animation-range-start", + "animation-timeline", + "animation-timing-function", + "appearance", + "aspect-ratio", + "backdrop-filter", + "backface-visibility", + "background", + "background-attachment", + "background-blend-mode", + "background-clip", + "background-color", + "background-image", + "background-origin", + "background-position", + "background-position-x", + "background-position-y", + "background-repeat", + "background-size", + "baseline-shift", + "block-size", + "border", + "border-block", + "border-block-color", + "border-block-end", + "border-block-end-color", + "border-block-end-style", + "border-block-end-width", + "border-block-start", + "border-block-start-color", + "border-block-start-style", + "border-block-start-width", + "border-block-style", + "border-block-width", + "border-bottom", + "border-bottom-color", + "border-bottom-left-radius", + "border-bottom-right-radius", + "border-bottom-style", + "border-bottom-width", + "border-collapse", + "border-color", + "border-end-end-radius", + "border-end-start-radius", + "border-image", + "border-image-outset", + "border-image-repeat", + "border-image-slice", + "border-image-source", + "border-image-width", + "border-inline", + "border-inline-color", + "border-inline-end", + "border-inline-end-color", + "border-inline-end-style", + "border-inline-end-width", + "border-inline-start", + "border-inline-start-color", + "border-inline-start-style", + "border-inline-start-width", + "border-inline-style", + "border-inline-width", + "border-left", + "border-left-color", + "border-left-style", + "border-left-width", + "border-radius", + "border-right", + "border-right-color", + "border-right-style", + "border-right-width", + "border-spacing", + "border-start-end-radius", + "border-start-start-radius", + "border-style", + "border-top", + "border-top-color", + "border-top-left-radius", + "border-top-right-radius", + "border-top-style", + "border-top-width", + "border-width", + "bottom", + "box-align", + "box-decoration-break", + "box-direction", + "box-flex", + "box-flex-group", + "box-lines", + "box-ordinal-group", + "box-orient", + "box-pack", + "box-shadow", + "box-sizing", + "break-after", + "break-before", + "break-inside", + "caption-side", + "caret-color", + "clear", + "clip", + "clip-path", + "clip-rule", + "color", + "color-interpolation", + "color-interpolation-filters", + "color-profile", + "color-rendering", + "color-scheme", + "column-count", + "column-fill", + "column-gap", + "column-rule", + "column-rule-color", + "column-rule-style", + "column-rule-width", + "column-span", + "column-width", + "columns", + "contain", + "contain-intrinsic-block-size", + "contain-intrinsic-height", + "contain-intrinsic-inline-size", + "contain-intrinsic-size", + "contain-intrinsic-width", + "container", + "container-name", + "container-type", + "content", + "content-visibility", + "corner-bottom-left-shape", + "corner-bottom-right-shape", + "corner-shape", + "corner-top-left-shape", + "corner-top-right-shape", + "counter-increment", + "counter-reset", + "counter-set", + "cue", + "cue-after", + "cue-before", + "cursor", + "cx", + "cy", + "direction", + "display", + "dominant-baseline", + "empty-cells", + "enable-background", + "field-sizing", + "fill", + "fill-opacity", + "fill-rule", + "filter", + "flex", + "flex-basis", + "flex-direction", + "flex-flow", + "flex-grow", + "flex-shrink", + "flex-wrap", + "float", + "flood-color", + "flood-opacity", + "flow", + "font", + "font-display", + "font-family", + "font-feature-settings", + "font-kerning", + "font-language-override", + "font-optical-sizing", + "font-palette", + "font-size", + "font-size-adjust", + "font-smooth", + "font-smoothing", + "font-stretch", + "font-style", + "font-synthesis", + "font-synthesis-position", + "font-synthesis-small-caps", + "font-synthesis-style", + "font-synthesis-weight", + "font-variant", + "font-variant-alternates", + "font-variant-caps", + "font-variant-east-asian", + "font-variant-emoji", + "font-variant-ligatures", + "font-variant-numeric", + "font-variant-position", + "font-variation-settings", + "font-weight", + "forced-color-adjust", + "gap", + "glyph-orientation-horizontal", + "glyph-orientation-vertical", + "grid", + "grid-area", + "grid-auto-columns", + "grid-auto-flow", + "grid-auto-rows", + "grid-column", + "grid-column-end", + "grid-column-start", + "grid-gap", + "grid-row", + "grid-row-end", + "grid-row-start", + "grid-template", + "grid-template-areas", + "grid-template-columns", + "grid-template-rows", + "hanging-punctuation", + "height", + "hyphenate-character", + "hyphenate-limit-chars", + "hyphens", + "icon", + "image-orientation", + "image-rendering", + "image-resolution", + "ime-mode", + "initial-letter", + "initial-letter-align", + "inline-size", + "inset", + "inset-area", + "inset-block", + "inset-block-end", + "inset-block-start", + "inset-inline", + "inset-inline-end", + "inset-inline-start", + "isolation", + "justify-content", + "justify-items", + "justify-self", + "kerning", + "left", + "letter-spacing", + "lighting-color", + "line-break", + "line-height", + "line-height-step", + "list-style", + "list-style-image", + "list-style-position", + "list-style-type", + "margin", + "margin-block", + "margin-block-end", + "margin-block-start", + "margin-bottom", + "margin-inline", + "margin-inline-end", + "margin-inline-start", + "margin-left", + "margin-right", + "margin-top", + "margin-trim", + "marker", + "marker-end", + "marker-mid", + "marker-start", + "marks", + "mask", + "mask-border", + "mask-border-mode", + "mask-border-outset", + "mask-border-repeat", + "mask-border-slice", + "mask-border-source", + "mask-border-width", + "mask-clip", + "mask-composite", + "mask-image", + "mask-mode", + "mask-origin", + "mask-position", + "mask-repeat", + "mask-size", + "mask-type", + "masonry-auto-flow", + "math-depth", + "math-shift", + "math-style", + "max-block-size", + "max-height", + "max-inline-size", + "max-width", + "min-block-size", + "min-height", + "min-inline-size", + "min-width", + "mix-blend-mode", + "nav-down", + "nav-index", + "nav-left", + "nav-right", + "nav-up", + "none", + "normal", + "object-fit", + "object-position", + "offset", + "offset-anchor", + "offset-distance", + "offset-path", + "offset-position", + "offset-rotate", + "opacity", + "order", + "orphans", + "outline", + "outline-color", + "outline-offset", + "outline-style", + "outline-width", + "overflow", + "overflow-anchor", + "overflow-block", + "overflow-clip-margin", + "overflow-inline", + "overflow-wrap", + "overflow-x", + "overflow-y", + "overlay", + "overscroll-behavior", + "overscroll-behavior-block", + "overscroll-behavior-inline", + "overscroll-behavior-x", + "overscroll-behavior-y", + "padding", + "padding-block", + "padding-block-end", + "padding-block-start", + "padding-bottom", + "padding-inline", + "padding-inline-end", + "padding-inline-start", + "padding-left", + "padding-right", + "padding-top", + "page", + "page-break-after", + "page-break-before", + "page-break-inside", + "paint-order", + "pause", + "pause-after", + "pause-before", + "perspective", + "perspective-origin", + "place-content", + "place-items", + "place-self", + "pointer-events", + "position", + "position-anchor", + "position-visibility", + "print-color-adjust", + "quotes", + "r", + "resize", + "rest", + "rest-after", + "rest-before", + "right", + "rotate", + "row-gap", + "ruby-align", + "ruby-position", + "scale", + "scroll-behavior", + "scroll-margin", + "scroll-margin-block", + "scroll-margin-block-end", + "scroll-margin-block-start", + "scroll-margin-bottom", + "scroll-margin-inline", + "scroll-margin-inline-end", + "scroll-margin-inline-start", + "scroll-margin-left", + "scroll-margin-right", + "scroll-margin-top", + "scroll-padding", + "scroll-padding-block", + "scroll-padding-block-end", + "scroll-padding-block-start", + "scroll-padding-bottom", + "scroll-padding-inline", + "scroll-padding-inline-end", + "scroll-padding-inline-start", + "scroll-padding-left", + "scroll-padding-right", + "scroll-padding-top", + "scroll-snap-align", + "scroll-snap-stop", + "scroll-snap-type", + "scroll-timeline", + "scroll-timeline-axis", + "scroll-timeline-name", + "scrollbar-color", + "scrollbar-gutter", + "scrollbar-width", + "shape-image-threshold", + "shape-margin", + "shape-outside", + "shape-rendering", + "speak", + "speak-as", + "src", + // @font-face + "stop-color", + "stop-opacity", + "stroke", + "stroke-dasharray", + "stroke-dashoffset", + "stroke-linecap", + "stroke-linejoin", + "stroke-miterlimit", + "stroke-opacity", + "stroke-width", + "tab-size", + "table-layout", + "text-align", + "text-align-all", + "text-align-last", + "text-anchor", + "text-combine-upright", + "text-decoration", + "text-decoration-color", + "text-decoration-line", + "text-decoration-skip", + "text-decoration-skip-ink", + "text-decoration-style", + "text-decoration-thickness", + "text-emphasis", + "text-emphasis-color", + "text-emphasis-position", + "text-emphasis-style", + "text-indent", + "text-justify", + "text-orientation", + "text-overflow", + "text-rendering", + "text-shadow", + "text-size-adjust", + "text-transform", + "text-underline-offset", + "text-underline-position", + "text-wrap", + "text-wrap-mode", + "text-wrap-style", + "timeline-scope", + "top", + "touch-action", + "transform", + "transform-box", + "transform-origin", + "transform-style", + "transition", + "transition-behavior", + "transition-delay", + "transition-duration", + "transition-property", + "transition-timing-function", + "translate", + "unicode-bidi", + "unicode-range", + "user-modify", + "user-select", + "vector-effect", + "vertical-align", + "view-timeline", + "view-timeline-axis", + "view-timeline-inset", + "view-timeline-name", + "view-transition-name", + "visibility", + "voice-balance", + "voice-duration", + "voice-family", + "voice-pitch", + "voice-range", + "voice-rate", + "voice-stress", + "voice-volume", + "white-space", + "white-space-collapse", + "widows", + "width", + "will-change", + "word-break", + "word-spacing", + "word-wrap", + "writing-mode", + "x", + "y", + "z-index", + "zoom" +].sort().reverse(); +function css2(hljs) { + const regex = hljs.regex; + const modes = MODES(hljs); + const VENDOR_PREFIX = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ }; + const AT_MODIFIERS = "and or not only"; + const AT_PROPERTY_RE = /@-?\w[\w]*(-\w+)*/; + const IDENT_RE3 = "[a-zA-Z-][a-zA-Z0-9_-]*"; + const STRINGS = [ + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE + ]; + return { + name: "CSS", + case_insensitive: true, + illegal: /[=|'\$]/, + keywords: { keyframePosition: "from to" }, + classNameAliases: { + // for visual continuity with `tag {}` and because we + // don't have a great class for this? + keyframePosition: "selector-tag" + }, + contains: [ + modes.BLOCK_COMMENT, + VENDOR_PREFIX, + // to recognize keyframe 40% etc which are outside the scope of our + // attribute value mode + modes.CSS_NUMBER_MODE, + { + className: "selector-id", + begin: /#[A-Za-z0-9_-]+/, + relevance: 0 + }, + { + className: "selector-class", + begin: "\\." + IDENT_RE3, + relevance: 0 + }, + modes.ATTRIBUTE_SELECTOR_MODE, + { + className: "selector-pseudo", + variants: [ + { begin: ":(" + PSEUDO_CLASSES.join("|") + ")" }, + { begin: ":(:)?(" + PSEUDO_ELEMENTS.join("|") + ")" } + ] + }, + // we may actually need this (12/2020) + // { // pseudo-selector params + // begin: /\(/, + // end: /\)/, + // contains: [ hljs.CSS_NUMBER_MODE ] + // }, + modes.CSS_VARIABLE, + { + className: "attribute", + begin: "\\b(" + ATTRIBUTES.join("|") + ")\\b" + }, + // attribute values + { + begin: /:/, + end: /[;}{]/, + contains: [ + modes.BLOCK_COMMENT, + modes.HEXCOLOR, + modes.IMPORTANT, + modes.CSS_NUMBER_MODE, + modes.UNICODE_RANGE, + ...STRINGS, + // needed to highlight these as strings and to avoid issues with + // illegal characters that might be inside urls that would trigger the + // languages illegal stack + { + begin: /(url|data-uri)\(/, + end: /\)/, + relevance: 0, + // from keywords + keywords: { built_in: "url data-uri" }, + contains: [ + ...STRINGS, + { + className: "string", + // any character other than `)` as in `url()` will be the start + // of a string, which ends with `)` (from the parent mode) + begin: /[^)]/, + endsWithParent: true, + excludeEnd: true + } + ] + }, + modes.FUNCTION_DISPATCH + ] + }, + { + begin: regex.lookahead(/@/), + end: "[{;]", + relevance: 0, + illegal: /:/, + // break on Less variables @var: ... + contains: [ + { + className: "keyword", + begin: AT_PROPERTY_RE + }, + { + begin: /\s/, + endsWithParent: true, + excludeEnd: true, + relevance: 0, + keywords: { + $pattern: /[a-z-]+/, + keyword: AT_MODIFIERS, + attribute: MEDIA_FEATURES.join(" ") + }, + contains: [ + { + begin: /[a-z-]+(?=:)/, + className: "attribute" + }, + ...STRINGS, + modes.CSS_NUMBER_MODE + ] + } + ] + }, + { + className: "selector-tag", + begin: "\\b(" + TAGS.join("|") + ")\\b" + } + ] + }; +} + +// node_modules/highlight.js/es/languages/json.js +var EXTENDED_NUMBER_RE = "([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity"; +var EXTENDED_NUMBER_MODE = { + scope: "number", + match: EXTENDED_NUMBER_RE, + relevance: 0 +}; +function json(hljs) { + const ATTRIBUTE = { + className: "attr", + begin: /(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/, + relevance: 1.01 + }; + const PUNCTUATION = { + match: /[{}[\],:]/, + className: "punctuation", + relevance: 0 + }; + const LITERALS3 = [ + "true", + "false", + "null" + ]; + const LITERALS_MODE = { + scope: "literal", + beginKeywords: LITERALS3.join(" ") + }; + return { + name: "JSON", + aliases: ["jsonc", "json5"], + keywords: { + literal: LITERALS3 + }, + contains: [ + ATTRIBUTE, + PUNCTUATION, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + LITERALS_MODE, + EXTENDED_NUMBER_MODE, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE + ], + illegal: "\\S" + }; +} + +// src/client/split.tsx +var import_jsx_runtime = require("react/jsx-runtime"); +core_default.registerLanguage("typescript", typescript); +core_default.registerLanguage("javascript", javascript2); +core_default.registerLanguage("css", css2); +core_default.registerLanguage("json", json); +var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi); +var DIVIDER = 4; +var BAR_H = 26; +var PERSIST_KEY = "dsh.worktable.split.v2"; +var BUILTIN_ICONS = { + browser: "\u{1F310}", + anim: "\u{1F3AC}", + explorer: "\u{1F4C1}", + scm: "\u{1F500}", + tasks: "\u2705", + terminal: "\u25B8_", + custom: "\u2728", + console: "\u{1F5A5}\uFE0F" +}; +var BUILTIN_LABEL_KEYS = { + browser: "pane.browser", + anim: "pane.anim", + explorer: "pane.explorer", + scm: "pane.scm", + tasks: "pane.tasks", + terminal: "pane.terminal", + custom: "pane.custom", + console: "pane.console" +}; +function tabTitleOf(content) { + if (content.kind === "builtin") return T(BUILTIN_LABEL_KEYS[content.type]); + if (content.kind === "file") return basenameOf(content.path); + if (content.kind === "iframe" && content.title) return content.title; + try { + const u = new URL(content.url); + return u.hostname || content.url; + } catch { + return content.url; + } +} +function basenameOf(p) { + const parts = String(p).replace(/[\\/]+$/, "").split(/[\\/]/); + return parts[parts.length - 1] || String(p); +} +function sameContent(a, b) { + if (a.kind === "iframe" && b.kind === "iframe") return a.url === b.url; + if (a.kind === "file" && b.kind === "file") return a.path === b.path; + if (a.kind === "builtin" && b.kind === "builtin") return a.type === b.type; + return false; +} +var uiT = null; +function setSplitT(fn) { + uiT = fn; +} +var T = (key, params) => uiT ? uiT(key, params) : key; +var splitEnv = null; +function setSplitEnv(env) { + splitEnv = env; +} +async function postJson(url, body) { + const res = await fetch(url, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify(body) + }); + if (!res.ok) throw new Error("HTTP " + res.status); + return res.json(); +} +function parentPathOf(p) { + const idx = Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\")); + if (idx <= 0) return p; + let parent = p.slice(0, idx); + if (/^[A-Za-z]:$/.test(parent)) parent += "\\"; + return parent; +} +var dragPane = null; +var dragTab = null; +var dropTarget = null; +var dropTargetListeners = /* @__PURE__ */ new Set(); +function setDropTarget(t) { + if (dropTarget === t) return; + dropTarget = t; + for (const fn of dropTargetListeners) fn(); +} +function findConversationRoot() { + const candidates = Array.from(document.querySelectorAll("[data-phase]")); + const ok = (el) => el.tagName !== "TEXTAREA" && el.tagName !== "INPUT" && el.children.length >= 2; + return candidates.find((el) => ok(el) && el.dataset.phase === "active") ?? candidates.find(ok) ?? null; +} +function loadSaved(layoutId) { + try { + const raw = localStorage.getItem(PERSIST_KEY); + if (!raw) return null; + const s = JSON.parse(raw)?.[layoutId]; + if (!s || typeof s !== "object") return null; + return { + chatW: Number.isFinite(s.chatW) ? s.chatW : -1, + topH: Number.isFinite(s.topH) ? s.topH : -1, + leftW: Number.isFinite(s.leftW) ? s.leftW : -1, + paneWs: Array.isArray(s.paneWs) ? s.paneWs : [], + topWs: Array.isArray(s.topWs) ? s.topWs : [], + leftWs: Array.isArray(s.leftWs) ? s.leftWs : [] + }; + } catch { + return null; + } +} +function persistSaved(layoutId, s) { + try { + const raw = localStorage.getItem(PERSIST_KEY); + const all = raw ? JSON.parse(raw) : {}; + all[layoutId] = s; + localStorage.setItem(PERSIST_KEY, JSON.stringify(all)); + } catch { + } +} +window.addEventListener("dsh:split-claim", ((e) => { + const id = e?.detail?.id; + if (splitStore.active && id && id !== splitStore.spec?.id) splitStore.close(); +})); +var splitStore = { + active: false, + spec: null, + geom: null, + chatW: 320, + topH: 200, + leftW: 260, + paneWs: [], + topWs: [], + leftWs: [], + root: null, + header: null, + viewArea: null, + savedMarginLeft: "", + savedMarginRight: "", + savedMarginTop: "", + observer: null, + fallback: null, + yieldObserver: null, + lastMarginLeft: "", + lastMarginRight: "", + lastMarginTop: "", + onSpecMutated: null, + listeners: /* @__PURE__ */ new Set(), + open(spec) { + if (this.active) { + if (this.spec?.id === spec.id) { + this.close(); + return true; + } + this.close(); + } + try { + const taClose = document.querySelector(".ta_splitClose"); + taClose?.click(); + } catch { + } + try { + window.dispatchEvent(new CustomEvent("dsh:split-claim", { detail: { id: spec.id } })); + } catch { + } + const root = findConversationRoot(); + if (!root) return false; + const header = root.children[0]; + const viewArea = root.children[1]; + if (!header || !viewArea) return false; + this.spec = { ...spec, chatSide: spec.chatSide === "left" ? "left" : "right" }; + const normalize2 = (p) => { + if (p.tabs && p.tabs.length > 0) return p; + if (p.content) { + return { ...p, content: null, tabs: [{ id: "t1", title: tabTitleOf(p.content), content: p.content }], active: 0 }; + } + return { ...p, content: null, tabs: [], active: 0 }; + }; + if (spec.top) this.spec.top = spec.top.map(normalize2); + if (spec.left) this.spec.left = normalize2(spec.left); + this.spec.main = (spec.main ?? []).map(normalize2); + const main = this.spec.main ?? []; + const top = spec.top ?? []; + const left = spec.left ?? null; + const saved = loadSaved(spec.id); + const hasChatW = !!saved && saved.chatW >= 0; + const hasTopH = !!saved && saved.topH >= 0; + const hasLeftW = !!saved && saved.leftW >= 0; + const hasPaneWs = !!saved && saved.paneWs.length === main.length; + const hasTopWs = !!saved && saved.topWs.length === top.length; + const hasLeftWs = !!saved && saved.leftWs.length === (left ? 1 : 0); + this.chatW = hasChatW ? saved.chatW : spec.chatWidth.default; + this.topH = hasTopH ? saved.topH : spec.topHeight?.default ?? 200; + this.leftW = hasLeftW ? saved.leftW : spec.leftWidth?.default ?? 260; + this.paneWs = hasPaneWs ? [...saved.paneWs] : main.map((p) => p.min); + this.topWs = hasTopWs ? [...saved.topWs] : top.map((p) => p.min); + this.leftWs = hasLeftWs ? [...saved.leftWs] : left ? [left.min] : []; + this.root = root; + this.header = header; + this.viewArea = viewArea; + this.savedMarginLeft = viewArea.style.marginLeft; + this.savedMarginRight = viewArea.style.marginRight; + this.savedMarginTop = viewArea.style.marginTop; + this.refreshGeom(); + const g0 = this.geom; + if (g0) { + const colW0 = g0.right - g0.left; + const rowH0 = g0.bottom - g0.top; + if (!hasChatW) { + const hi = Math.max(spec.chatWidth.min, colW0 - 60); + this.chatW = clamp(Math.round(colW0 * 0.3), spec.chatWidth.min, hi); + } + if (left && !hasLeftW) { + const lo = spec.leftWidth?.min ?? 160; + this.leftW = clamp(Math.round(colW0 * 0.38), lo, Math.max(lo, colW0 - 260)); + } + if (top.length > 0 && !hasTopH) { + const lo = spec.topHeight?.min ?? 80; + const ratio = spec.topHeightRatio ?? 0.35; + this.topH = clamp(Math.round((rowH0 - BAR_H) * ratio), lo, Math.max(lo, rowH0 - BAR_H - 80)); + } + if (!hasPaneWs) { + const contentW = Math.max(0, colW0 - this.chatW); + const avail = Math.max(main.length * 120, contentW - Math.max(0, main.length - 1) * DIVIDER); + const share = Math.round(avail / main.length); + this.paneWs = main.map((p) => Math.max(p.min, share)); + } + if (!hasTopWs) { + const chatW0 = spec.chatFullHeight === true ? this.chatW : 0; + const rowW = Math.max(0, colW0 - chatW0 - (left ? this.leftW : 0)); + const avail = Math.max(top.length * 120, rowW - Math.max(0, top.length - 1) * DIVIDER); + const share = Math.round(avail / top.length); + this.topWs = top.map((p) => Math.max(p.min, share)); + } + if (left && !hasLeftWs) this.leftWs = [Math.max(left.min, this.leftW)]; + } + this.applyMargin(); + this.observer = new ResizeObserver(() => { + const r = this.root; + if (!(r && r.isConnected && r.dataset.phase === "active")) { + this.syncAnchor(); + return; + } + this.refreshGeom(); + this.applyMargin(); + this.notify(); + }); + this.observer.observe(root); + this.fallback = new MutationObserver(() => { + const r = this.root; + if (r && r.isConnected && r.dataset.phase === "active") return; + this.syncAnchor(); + }); + this.fallback.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-phase"] }); + this.yieldObserver = new MutationObserver(() => { + if (!this.active || !this.viewArea) return; + if (this.viewArea.style.marginLeft !== this.lastMarginLeft || this.viewArea.style.marginRight !== this.lastMarginRight || this.viewArea.style.marginTop !== this.lastMarginTop) { + this.close(); + } + }); + this.yieldObserver.observe(viewArea, { attributes: true, attributeFilter: ["style"] }); + this.active = true; + this.notify(); + return true; + }, + /** 会话根失效(切换会话)时重新锚定:左侧内容保持不关闭;无会话才关闭 */ + syncAnchor() { + if (!this.active) return; + const next = findConversationRoot(); + if (!next) { + this.close(); + return; + } + if (next.dataset.phase !== "active") return; + if (next === this.root) { + this.refreshGeom(); + this.applyMargin(); + this.notify(); + return; + } + const header = next.children[0]; + const viewArea = next.children[1]; + if (!header || !viewArea) { + this.close(); + return; + } + if (this.viewArea && this.viewArea.isConnected && this.viewArea !== viewArea) { + this.viewArea.style.marginLeft = this.savedMarginLeft; + this.viewArea.style.marginRight = this.savedMarginRight; + this.viewArea.style.marginTop = this.savedMarginTop; + } + this.root = next; + this.header = header; + this.viewArea = viewArea; + this.savedMarginLeft = viewArea.style.marginLeft; + this.savedMarginRight = viewArea.style.marginRight; + this.savedMarginTop = viewArea.style.marginTop; + this.observer?.disconnect(); + this.observer.observe(next); + this.refreshGeom(); + this.applyMargin(); + this.notify(); + }, + refreshGeom() { + const root = this.root; + const header = this.header; + if (!root || !header) return; + const rr = root.getBoundingClientRect(); + const hr2 = header.getBoundingClientRect(); + this.geom = { left: rr.left, top: hr2.bottom, right: rr.right, bottom: rr.bottom }; + }, + applyMargin() { + const viewArea = this.viewArea; + const g = this.geom; + const spec = this.spec; + if (!viewArea || !g || !spec) return; + const colW = g.right - g.left; + const rowH = g.bottom - g.top; + const hasLeft = !!spec.left; + const hasTop = !!(spec.top && spec.top.length > 0); + const chatW = clamp(this.chatW, spec.chatWidth.min, Math.max(spec.chatWidth.min, colW - 60)); + const topH = hasTop ? clamp(this.topH, spec.topHeight?.min ?? 80, Math.max(spec.topHeight?.min ?? 80, rowH - BAR_H - 80)) : 0; + const leftW = hasLeft ? clamp(this.leftW, spec.leftWidth?.min ?? 160, Math.max(spec.leftWidth?.min ?? 160, colW - 260)) : 0; + const chatFull = spec.chatFullHeight === true; + const gap = Math.max(0, colW - chatW) + "px"; + const mt = BAR_H + (hasTop && !chatFull ? topH : 0) + "px"; + const chatLeft = !hasLeft && spec.chatSide === "left"; + this.lastMarginLeft = hasLeft ? leftW + "px" : chatLeft ? "" : gap; + this.lastMarginRight = hasLeft ? "" : chatLeft ? gap : ""; + this.lastMarginTop = mt; + viewArea.style.marginLeft = this.lastMarginLeft; + viewArea.style.marginRight = this.lastMarginRight; + viewArea.style.marginTop = mt; + }, + setChatW(w) { + const g = this.geom; + const spec = this.spec; + if (!g || !spec) return; + const colW = g.right - g.left; + const main = spec.main ?? []; + const minContent = main.reduce((a, p) => a + p.min, 0) + Math.max(0, main.length - 1) * DIVIDER; + const hi = Math.max(spec.chatWidth.min, colW - minContent); + this.chatW = clamp(Math.round(w), spec.chatWidth.min, hi); + this.applyMargin(); + this.persist(); + this.notify(); + }, + setTopH(h) { + const g = this.geom; + const spec = this.spec; + if (!g || !spec) return; + const rowH = g.bottom - g.top; + const lo = spec.topHeight?.min ?? 80; + const hi = Math.max(lo, rowH - BAR_H - 80); + this.topH = clamp(Math.round(h), lo, hi); + this.applyMargin(); + this.persist(); + this.notify(); + }, + setLeftW(w) { + const g = this.geom; + const spec = this.spec; + if (!g || !spec || !spec.left) return; + const colW = g.right - g.left; + const lo = spec.leftWidth?.min ?? 160; + const hi = Math.max(lo, colW - 260); + this.leftW = clamp(Math.round(w), lo, hi); + this.applyMargin(); + this.persist(); + this.notify(); + }, + setPaneW(i, w) { + const g = this.geom; + const spec = this.spec; + if (!g || !spec) return; + const main = spec.main ?? []; + if (i < 0 || i >= main.length) return; + const colW = g.right - g.left; + const chatW = clamp(this.chatW, spec.chatWidth.min, Math.max(spec.chatWidth.min, colW - 60)); + const contentW = Math.max(0, colW - chatW); + const othersMin = main.reduce((a, p, k) => a + (k === i ? 0 : p.min), 0); + const lo = main[i].min; + const hi = Math.max(lo, contentW - othersMin - Math.max(0, main.length - 1) * DIVIDER); + const next = this.paneWs.slice(); + next[i] = clamp(Math.round(w), lo, hi); + this.paneWs = next; + this.persist(); + this.notify(); + }, + setTopW(i, w) { + const g = this.geom; + const spec = this.spec; + if (!g || !spec) return; + const top = spec.top ?? []; + if (i < 0 || i >= top.length) return; + const colW = g.right - g.left; + const othersMin = top.reduce((a, p, k) => a + (k === i ? 0 : p.min), 0); + const lo = top[i].min; + const hi = Math.max(lo, colW - othersMin - Math.max(0, top.length - 1) * DIVIDER); + const next = this.topWs.slice(); + next[i] = clamp(Math.round(w), lo, hi); + this.topWs = next; + this.persist(); + this.notify(); + }, + setPaneContent(row, i, content) { + if (content) this.openTab(row, i, content); + }, + lockPane(row, i, content) { + const spec = this.spec; + if (!spec) return; + const tab = { id: "t" + Date.now().toString(36), title: tabTitleOf(content), content, active: 0 }; + const mutate = (pane) => ({ ...pane, content: null, tabs: [tab], active: 0 }); + if (row === "left") { + if (!spec.left || i !== 0) return; + this.spec = { ...spec, left: mutate(spec.left) }; + } else if (row === "top") { + const top = [...spec.top ?? []]; + if (!top[i]) return; + top[i] = mutate(top[i]); + this.spec = { ...spec, top }; + } else { + const main = [...spec.main]; + if (!main[i]) return; + main[i] = mutate(main[i]); + this.spec = { ...spec, main }; + } + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + /** 更新指定标签页的内容(浏览器/动画窗地址栏回车时回写),并持久化到布局条目 */ + setTabContent(row, index, tabId, content) { + const spec = this.spec; + if (!spec) return; + const mutate = (pane) => { + const tabs = (pane.tabs ?? []).map((t) => t.id === tabId ? { ...t, content, title: tabTitleOf(content) } : t); + return { ...pane, tabs }; + }; + if (row === "left") { + if (spec.left && index === 0) this.spec = { ...spec, left: mutate(spec.left) }; + } else if (row === "top") { + const top = [...spec.top ?? []]; + if (top[index]) { + top[index] = mutate(top[index]); + this.spec = { ...spec, top }; + } + } else { + const main = [...spec.main]; + if (main[index]) { + main[index] = mutate(main[index]); + this.spec = { ...spec, main }; + } + } + this.onSpecMutated?.(this.spec); + this.notify(); + }, + openTab(row, i, content) { + const spec = this.spec; + if (!spec) return; + const mutate = (pane) => { + const tabs = [...pane.tabs ?? []]; + const existing = tabs.findIndex((t) => sameContent(t.content, content)); + if (existing >= 0) return { ...pane, content: null, tabs, active: existing }; + const tab = { id: "t" + Date.now().toString(36), title: tabTitleOf(content), content }; + tabs.push(tab); + return { ...pane, content: null, tabs, active: tabs.length - 1 }; + }; + if (row === "left") { + if (!spec.left || i !== 0) return; + this.spec = { ...spec, left: mutate(spec.left) }; + } else if (row === "top") { + const top = [...spec.top ?? []]; + if (!top[i]) return; + top[i] = mutate(top[i]); + this.spec = { ...spec, top }; + } else { + const main = [...spec.main]; + if (!main[i]) return; + main[i] = mutate(main[i]); + this.spec = { ...spec, main }; + } + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + closeTab(row, i, tabId) { + const spec = this.spec; + if (!spec) return; + const mutate = (pane) => { + const tabs = (pane.tabs ?? []).filter((t) => t.id !== tabId); + return { ...pane, tabs, active: 0 }; + }; + if (row === "left") { + if (!spec.left || i !== 0) return; + this.spec = { ...spec, left: mutate(spec.left) }; + } else if (row === "top") { + const top = [...spec.top ?? []]; + if (!top[i]) return; + top[i] = mutate(top[i]); + this.spec = { ...spec, top }; + } else { + const main = [...spec.main]; + if (!main[i]) return; + main[i] = mutate(main[i]); + this.spec = { ...spec, main }; + } + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + moveTab(fromRow, fromI, tabId, toRow, toI) { + const spec = this.spec; + if (!spec) return; + if (fromRow === toRow && fromI === toI) return; + const top = [...spec.top ?? []]; + const main = [...spec.main]; + const left = spec.left ? { ...spec.left } : null; + const arrOf = (row) => row === "left" ? left ? [left] : [] : row === "top" ? top : main; + const fromArr = arrOf(fromRow); + const toArr = arrOf(toRow); + const fromPane = fromArr[fromI]; + const toPane = toArr[toI]; + if (!fromPane || !toPane) return; + const tab = (fromPane.tabs ?? []).find((t) => t.id === tabId); + if (!tab) return; + const fromTabs = (fromPane.tabs ?? []).filter((t) => t.id !== tabId); + const toTabs = [...toPane.tabs ?? [], tab]; + const setPane = (row, i, pane) => { + if (row === "left") spec.left = pane; + else if (row === "top") top[i] = pane; + else main[i] = pane; + }; + setPane(fromRow, fromI, { ...fromPane, tabs: fromTabs, active: 0 }); + setPane(toRow, toI, { ...toPane, tabs: toTabs, active: toTabs.length - 1 }); + this.spec = { ...spec, left: left ?? null, top: top.length > 0 ? top : null, main }; + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + setActiveTab(row, i, tabId) { + const spec = this.spec; + if (!spec) return; + const mutate = (pane) => { + const idx = (pane.tabs ?? []).findIndex((t) => t.id === tabId); + if (idx < 0) return pane; + return { ...pane, active: idx }; + }; + if (row === "left") { + if (!spec.left || i !== 0) return; + this.spec = { ...spec, left: mutate(spec.left) }; + } else if (row === "top") { + const top = [...spec.top ?? []]; + if (!top[i]) return; + top[i] = mutate(top[i]); + this.spec = { ...spec, top }; + } else { + const main = [...spec.main]; + if (!main[i]) return; + main[i] = mutate(main[i]); + this.spec = { ...spec, main }; + } + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + swapPanes(aRow, aI, bRow, bI) { + const spec = this.spec; + if (!spec) return; + const top = [...spec.top ?? []]; + const main = [...spec.main]; + const left = spec.left ? { ...spec.left } : null; + const arrOf = (row) => row === "left" ? left ? [left] : [] : row === "top" ? top : main; + const setOf = (row, i, pane) => { + if (row === "left") spec.left = pane; + else if (row === "top") top[i] = pane; + else main[i] = pane; + }; + const a = arrOf(aRow)[aI]; + const b = arrOf(bRow)[bI]; + if (!a || !b) return; + setOf(aRow, aI, b); + setOf(bRow, bI, a); + const wsOf = (row) => row === "left" ? this.leftWs : row === "top" ? this.topWs : this.paneWs; + const setWs = (row, i, v) => { + if (row === "left") { + const n = this.leftWs.slice(); + n[i] = v; + this.leftWs = n; + } else if (row === "top") { + const n = this.topWs.slice(); + n[i] = v; + this.topWs = n; + } else { + const n = this.paneWs.slice(); + n[i] = v; + this.paneWs = n; + } + }; + const aW = wsOf(aRow)[aI]; + const bW = wsOf(bRow)[bI]; + setWs(aRow, aI, bW); + setWs(bRow, bI, aW); + this.spec = { ...spec, left: left ?? null, top: top.length > 0 ? top : null, main }; + this.onSpecMutated?.(this.spec); + this.persist(); + this.notify(); + }, + setChatSide(side) { + const spec = this.spec; + if (!spec) return; + if (spec.left) return; + this.spec = { ...spec, chatSide: side }; + this.onSpecMutated?.(this.spec); + this.applyMargin(); + this.persist(); + this.notify(); + }, + persist() { + if (!this.spec) return; + persistSaved(this.spec.id, { chatW: this.chatW, topH: this.topH, leftW: this.leftW, paneWs: this.paneWs, topWs: this.topWs, leftWs: this.leftWs }); + }, + close() { + if (this.viewArea) { + this.viewArea.style.marginLeft = this.savedMarginLeft; + this.viewArea.style.marginRight = this.savedMarginRight; + this.viewArea.style.marginTop = this.savedMarginTop; + } + this.observer?.disconnect(); + this.observer = null; + this.fallback?.disconnect(); + this.fallback = null; + this.yieldObserver?.disconnect(); + this.yieldObserver = null; + this.root = null; + this.header = null; + this.viewArea = null; + this.geom = null; + this.spec = null; + this.active = false; + this.notify(); + }, + subscribe(fn) { + this.listeners.add(fn); + return () => this.listeners.delete(fn); + }, + notify() { + for (const fn of this.listeners) fn(); + } +}; +if (typeof document !== "undefined" && document.body) { + const taObserver = new MutationObserver(() => { + if (!splitStore.active) return; + if (document.querySelector(".ta_split")) splitStore.close(); + }); + taObserver.observe(document.body, { childList: true, subtree: true }); +} +function allocate(panes, ws, total) { + const out = []; + const gapTotal = Math.max(0, panes.length - 1) * DIVIDER; + const avail = Math.max(0, total - gapTotal); + let x = 0; + panes.forEach((p, i) => { + const w = i === panes.length - 1 ? Math.max(0, avail - x) : ws[i]; + out.push({ pane: p, left: x, width: w }); + x += w + DIVIDER; + }); + return out; +} +function makeDividerHandler(kind, index) { + return (e) => { + e.preventDefault(); + const target = e.currentTarget; + try { + target.setPointerCapture(e.pointerId); + } catch { + } + const onMove = (ev) => { + const g = splitStore.geom; + if (!g) return; + if (kind === "left") { + splitStore.setLeftW(ev.clientX - g.left); + } else if (kind === "chat") { + splitStore.setChatW(g.right - ev.clientX); + } else if (kind === "top") { + splitStore.setTopH(ev.clientY - g.top - BAR_H); + } else if (kind === "pane" && index != null) { + const prefix = splitStore.paneWs.slice(0, index).reduce((a, b) => a + b, 0) + index * DIVIDER; + splitStore.setPaneW(index, ev.clientX - (g.left + prefix)); + } else if (kind === "topPane" && index != null) { + const prefix = splitStore.topWs.slice(0, index).reduce((a, b) => a + b, 0) + index * DIVIDER; + splitStore.setTopW(index, ev.clientX - (g.left + prefix)); + } + }; + const onUp = () => { + target.removeEventListener("pointermove", onMove); + target.removeEventListener("pointerup", onUp); + target.removeEventListener("pointercancel", onUp); + }; + target.addEventListener("pointermove", onMove); + target.addEventListener("pointerup", onUp); + target.addEventListener("pointercancel", onUp); + }; +} +function BrowserPane(props) { + const initial = props.content?.url || "https://example.com"; + const [url, setUrl] = (0, import_react.useState)(initial); + const [src, setSrc] = (0, import_react.useState)(initial); + const go = () => { + const u = url.trim(); + const ok = /^(\/|https?:\/\/)/i.test(u) ? u : "about:blank"; + setSrc(ok); + if (ok !== "about:blank") { + splitStore.setTabContent(props.row, props.index, props.tabId, { kind: "builtin", type: "browser", url: ok }); + } + }; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_browserBar", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "input", + { + className: "dsh-wt_browserInput", + value: url, + placeholder: "https://", + onChange: (e) => setUrl(e.target.value), + onKeyDown: (e) => { + if (e.key === "Enter") go(); + } + } + ), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_browserGo", onClick: go, children: "\u2197" }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { className: "dsh-wt_paneFrame", src, title: "browser" }, props.reloadKey) + ] }); +} +function IframePane(props) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { className: "dsh-wt_paneFrame", src: props.url, title: props.title ?? "" }, props.reloadKey); +} +function AnimPane(props) { + const initial = props.content?.url || ""; + const [url, setUrl] = (0, import_react.useState)(initial); + const [src, setSrc] = (0, import_react.useState)(initial || "about:blank"); + const go = () => { + const u = url.trim(); + const ok = /^(\/|https?:\/\/)/i.test(u) ? u : "about:blank"; + setSrc(ok); + if (ok !== "about:blank") { + splitStore.setTabContent(props.row, props.index, props.tabId, { kind: "builtin", type: "anim", url: ok }); + } + }; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_browserBar", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "input", + { + className: "dsh-wt_browserInput", + value: url, + placeholder: T("pane.animUrlPh"), + onChange: (e) => setUrl(e.target.value), + onKeyDown: (e) => { + if (e.key === "Enter") go(); + } + } + ), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_browserGo", onClick: go, children: "\u2197" }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { className: "dsh-wt_paneFrame", src, title: "anim" }, props.reloadKey) + ] }); +} +function ConsolePane() { + const [, setTick] = (0, import_react.useState)(0); + const [now, setNow] = (0, import_react.useState)(() => Date.now()); + const [themeMode, setThemeMode] = (0, import_react.useState)(() => splitEnv?.console?.getTheme?.() ?? "system"); + const [sysDark, setSysDark] = (0, import_react.useState)(() => { + try { + return window.matchMedia("(prefers-color-scheme: dark)").matches; + } catch { + return true; + } + }); + (0, import_react.useEffect)(() => { + const env2 = splitEnv?.console; + if (!env2) return; + const bump = () => { + setTick((t) => t + 1); + setThemeMode(env2.getTheme?.() ?? "system"); + }; + const un = env2.subscribe(bump); + bump(); + return un; + }, []); + (0, import_react.useEffect)(() => { + let mq = null; + try { + mq = window.matchMedia("(prefers-color-scheme: dark)"); + } catch { + } + if (!mq) return; + const f = (e) => setSysDark(!!e?.matches); + try { + mq.addEventListener("change", f); + } catch { + try { + mq.addListener(f); + } catch { + } + } + return () => { + try { + mq.removeEventListener("change", f); + } catch { + try { + mq.removeListener(f); + } catch { + } + } + }; + }, []); + (0, import_react.useEffect)(() => { + splitEnv?.console?.refreshPreviews?.(); + }, []); + (0, import_react.useEffect)(() => { + const iv = window.setInterval(() => setNow(Date.now()), 1e3); + return () => window.clearInterval(iv); + }, []); + void now; + const env = splitEnv?.console; + const cards = env ? env.getCards() : []; + const resolvedTheme = (() => { + if (themeMode !== "system") return themeMode; + try { + const cs = getComputedStyle(document.documentElement).colorScheme || ""; + if (cs.includes("dark") && !cs.includes("light")) return "dark"; + if (cs.includes("light") && !cs.includes("dark")) return "light"; + } catch { + } + return sysDark ? "dark" : "light"; + })(); + const setTheme = (th) => { + setThemeMode(th); + env?.setTheme?.(th); + }; + const fmtDur = (ms) => { + const s = Math.max(0, Math.floor(ms / 1e3)); + const h = Math.floor(s / 3600); + const m = Math.floor(s % 3600 / 60); + const ss = s % 60; + return h > 0 ? h + ":" + String(m).padStart(2, "0") + ":" + String(ss).padStart(2, "0") : m + ":" + String(ss).padStart(2, "0"); + }; + const statusLabel = { idle: T("console.idle"), busy: T("console.busy"), need: T("console.need"), done: T("console.done") }; + const themeOpts = [ + { mode: "dark", icon: "\u{1F319}", key: "console.themeDark" }, + { mode: "light", icon: "\u2600\uFE0F", key: "console.themeLight" }, + { mode: "system", icon: "\u{1F5A5}\uFE0F", key: "console.themeSystem" } + ]; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_console", "data-wt-theme": resolvedTheme, children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_consoleHead", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_consoleTheme", role: "group", "aria-label": T("console.themeLabel"), children: themeOpts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "button", + { + type: "button", + className: "dsh-wt_consoleThemeBtn" + (themeMode === o.mode ? " dsh-wt_consoleThemeBtnOn" : ""), + title: T(o.key), + "aria-label": T(o.key), + onClick: () => setTheme(o.mode), + children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: o.icon }) + }, + o.mode + )) }) }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_consoleGrid", children: [ + cards.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "div", + { + role: c.self ? void 0 : "button", + tabIndex: c.self ? -1 : 0, + className: "dsh-wt_consoleCard" + (c.self ? " dsh-wt_consoleCardSelf" : "") + (c.status === "busy" ? " dsh-wt_consoleCard-busy" : "") + (c.glow && c.status === "done" ? " dsh-wt_consoleCard-glowDone" : "") + (c.glow && c.status === "need" ? " dsh-wt_consoleCard-glowNeed" : ""), + title: c.name, + onClick: () => { + if (c.self || !env) return; + if (c.glow) env.onAck?.(c.id); + env.onOpen(c.id); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_consoleCardHead", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleIcon", "aria-hidden": true, children: c.icon }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleName", children: c.name }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_consoleDivider", "aria-hidden": true }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_consoleStatusRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleStatus dsh-wt_consoleStatus-" + c.status, children: statusLabel[c.status] }), + c.runtimeMs != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleRuntime", children: fmtDur(c.runtimeMs) }) + ] }), + c.status === "busy" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleSweep", "aria-hidden": true }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_consolePreview" + (c.preview ? "" : " dsh-wt_consolePreviewNone"), title: c.preview, children: c.preview || (c.bound ? T("console.noPreview") : T("console.unboundShort")) }) + ] + }, + c.id + )), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "div", + { + role: "button", + tabIndex: 0, + className: "dsh-wt_consoleCard dsh-wt_consoleAdd", + title: T("console.addProject"), + onClick: () => env?.onAdd?.(), + children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleAddPlus", "aria-hidden": true, children: "\uFF0B" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_consoleAddLabel", children: T("console.addProject") }) + ] + } + ) + ] }), + cards.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_consoleEmpty", children: T("console.empty") }) + ] }); +} +function FolderIcon() { + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "dsh-wt_treeIcon", width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M1.75 3.25A1.75 1.75 0 0 1 3.5 1.5h2.63a1.75 1.75 0 0 1 1.34.66l.62.79a1.75 1.75 0 0 0 1.34.66H12.5a1.75 1.75 0 0 1 1.75 1.75v7.39A1.75 1.75 0 0 1 12.5 14.5h-9a1.75 1.75 0 0 1-1.75-1.75V3.25Z", fill: "var(--dsw-alias-state-accent-primary,#4f8ef7)", opacity: "0.9" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M1.75 5.75h12.5v7a1.75 1.75 0 0 1-1.75 1.75h-9a1.75 1.75 0 0 1-1.75-1.75v-7Z", fill: "var(--dsw-alias-state-accent-primary,#4f8ef7)", opacity: "0.4" }) + ] }); +} +function FileIcon() { + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "dsh-wt_treeIcon", width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 1.5h5.25a1 1 0 0 1 .71.29l3.25 3.25a1 1 0 0 1 .29.71V13.5a1 1 0 0 1-1 1h-8.5a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1Z", fill: "var(--dsw-alias-fill-l1,rgba(255,255,255,.06))", stroke: "var(--dsw-alias-label-secondary,#9aa4b2)", strokeWidth: "1.1" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9.25 1.5V4.75h3.25", fill: "none", stroke: "var(--dsw-alias-label-secondary,#9aa4b2)", strokeWidth: "1.1" }) + ] }); +} +function ExplorerPane(props) { + const cacheRef = (0, import_react.useRef)({}); + const expandedRef = (0, import_react.useRef)(/* @__PURE__ */ new Set()); + const [rootPath, setRootPath] = (0, import_react.useState)(""); + const [error2, setError] = (0, import_react.useState)(""); + const [, setTick] = (0, import_react.useState)(0); + const rerender = () => setTick((t) => t + 1); + const fetchDir = (0, import_react.useCallback)(async (path, force = false) => { + if (!force && cacheRef.current[path]) return { path, entries: cacheRef.current[path] }; + try { + const d = await postJson("/api/worktable/fs", { + path, + sessionId: splitEnv?.getScope()?.sessionId ?? "", + cwd: splitEnv?.getScope()?.cwd ?? "" + }); + const entries = d.entries ?? []; + cacheRef.current[d.path] = entries; + setError(d.error ? String(d.error) : ""); + return { path: d.path, entries }; + } catch (e) { + setError(String(e)); + return { path, entries: [] }; + } finally { + rerender(); + } + }, []); + const initRoot = (0, import_react.useCallback)(async () => { + const r = await fetchDir(splitEnv?.getScope()?.cwd ?? ""); + setRootPath(r.path); + rerender(); + }, [fetchDir]); + (0, import_react.useEffect)(() => { + initRoot(); + }, [initRoot]); + const toggle = (path) => { + if (expandedRef.current.has(path)) expandedRef.current.delete(path); + else { + expandedRef.current.add(path); + fetchDir(path); + } + rerender(); + }; + const refresh = () => { + cacheRef.current = {}; + expandedRef.current.clear(); + setError(""); + initRoot(); + }; + const goUp = () => { + if (!rootPath) return; + const parent = parentPathOf(rootPath); + if (parent === rootPath) return; + cacheRef.current = {}; + expandedRef.current.clear(); + setError(""); + fetchDir(parent).then((r) => { + setRootPath(r.path); + rerender(); + }); + }; + const renderLevel = (path, depth) => { + const entries = cacheRef.current[path]; + if (!entries) return []; + const nodes = []; + for (const e of entries) { + const isOpen = expandedRef.current.has(e.path); + nodes.push( + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_treeRow", + style: { paddingLeft: 8 + depth * 14 }, + onClick: () => { + if (e.isDir) { + toggle(e.path); + return; + } + if (/\.html?$/i.test(e.name)) { + const dir = parentPathOf(e.path); + splitStore.openTab(props.row, props.index, { + kind: "iframe", + url: "/api/worktable/site/" + encodeURIComponent(dir) + "/" + encodeURIComponent(e.name), + title: e.name + }); + } else if (/\.(md|markdown|mdown|txt|log|tsx|ts|jsx|js|css|json|pdf|png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(e.name)) { + splitStore.openTab(props.row, props.index, { kind: "file", path: e.path }); + } else { + setError(T("pane.openLater")); + } + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_treeArrow" + (e.isDir && isOpen ? " dsh-wt_treeArrowOpen" : ""), "aria-hidden": true, children: e.isDir ? "\u25B8" : "" }), + e.isDir ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileIcon, {}), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_treeName", children: e.name }) + ] + } + ), + e.isDir && isOpen && renderLevel(e.path, depth + 1) + ] }, e.path) + ); + } + return nodes; + }; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subBar", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_subBtn", title: "\u4E0A\u4E00\u7EA7", onClick: goUp, children: "\u2B06" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_subBtn", title: "\u5237\u65B0", onClick: refresh, children: "\u21BB" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subPath", children: rootPath || "\u2026" }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subList", children: [ + error2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: error2 }), + !error2 && cacheRef.current[rootPath]?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: "\u2014" }), + renderLevel(rootPath, 0) + ] }) + ] }); +} +function GitPane() { + const [snap, setSnap] = (0, import_react.useState)(null); + const [error2, setError] = (0, import_react.useState)(""); + const load = (0, import_react.useCallback)(() => { + postJson("/api/worktable/git", { + sessionId: splitEnv?.getScope()?.sessionId ?? "", + cwd: splitEnv?.getScope()?.cwd ?? "" + }).then(setSnap).catch((e) => setError(String(e))); + }, []); + (0, import_react.useEffect)(() => { + load(); + }, [load]); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subBar", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_subBtn", title: "\u5237\u65B0", onClick: load, children: "\u21BB" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subPath", children: snap?.isRepo ? "\u2387 " + snap.branch : "" }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subList", children: [ + error2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: error2 }), + !error2 && snap && !snap.isRepo && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: T("pane.gitNotRepo") }), + !error2 && snap?.isRepo && snap.entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: T("pane.gitClean") }), + !error2 && snap?.isRepo && snap.entries.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subRow dsh-wt_subRowStatic", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_gitXY dsh-wt_gitXY" + (e.xy.includes("A") || e.xy.includes("M") ? "Mod" : "New"), children: e.xy.trim() }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subName", children: e.path }) + ] }, i)) + ] }) + ] }); +} +function JobsPane() { + const [, setTick] = (0, import_react.useState)(0); + (0, import_react.useEffect)(() => { + const timer = window.setInterval(() => setTick((t) => t + 1), 2e3); + return () => window.clearInterval(timer); + }, []); + const jobs = splitEnv?.getJobs?.() ?? []; + const subagents = splitEnv?.getSubagents?.() ?? []; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subList", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subSection", children: T("pane.jobsTitle") }), + jobs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: T("pane.jobsEmpty") }), + jobs.map((j) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subRow dsh-wt_subRowStatic", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_jobDot dsh-wt_jobDot-" + j.status, "aria-hidden": true, children: "\u25CF" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subName", children: j.label }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subTag", children: j.kind }) + ] }, j.id)), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subSection", children: T("pane.subagents") }), + subagents.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_subEmpty", children: T("pane.subagentsEmpty") }), + subagents.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_subRow dsh-wt_subRowStatic", style: { paddingLeft: 8 + (s?.depth ?? 0) * 12 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_jobDot dsh-wt_jobDot-" + (s?.status ?? "stopping"), "aria-hidden": true, children: "\u25CF" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subName", children: s?.label ?? s?.title ?? s?.name ?? "\u2014" }), + s?.status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_subTag", children: s.status }) + ] }, s?.id ?? i)) + ] }); +} +function TerminalPane() { + const hostRef = (0, import_react.useRef)(null); + const [failed, setFailed] = (0, import_react.useState)(""); + (0, import_react.useEffect)(() => { + const el = hostRef.current; + if (!el) return; + let term = null; + let ws = null; + let disposed = false; + try { + term = new import_xterm2.Terminal({ + cursorBlink: true, + fontFamily: "Cascadia Code, Cascadia Mono, Consolas, Menlo, monospace", + fontSize: 12, + convertEol: true, + theme: { background: "#010409" } + }); + } catch { + setFailed(T("pane.termFail")); + return; + } + term.open(el); + try { + term.write("\x1B[?7h"); + } catch { + } + const focusTerm = () => { + try { + term.focus(); + } catch { + } + }; + focusTerm(); + el.addEventListener("pointerdown", focusTerm); + const scope = splitEnv?.getScope?.(); + const proto = location.protocol === "https:" ? "wss:" : "ws:"; + const url = proto + "//" + location.host + "/api/worktable/term?sessionId=" + encodeURIComponent(scope?.sessionId ?? "") + "&cwd=" + encodeURIComponent(scope?.cwd ?? "") + "&cols=80&rows=24"; + try { + ws = new WebSocket(url); + } catch { + term.dispose(); + setFailed(T("pane.termFail")); + return; + } + ws.onopen = () => { + focusTerm(); + try { + term.write("\x1B[?7h"); + } catch { + } + }; + ws.onmessage = (ev) => { + try { + term.write(String(ev.data)); + } catch { + } + }; + ws.onclose = () => { + if (!disposed) { + try { + term.write("\r\n[\u8FDE\u63A5\u5DF2\u5173\u95ED]"); + } catch { + } + } + }; + ws.onerror = () => { + if (!disposed) setFailed(T("pane.termFail")); + }; + term.onData((d) => { + if (ws && ws.readyState === 1) ws.send(d); + }); + const ro = new ResizeObserver(() => { + if (typeof term.fit === "function") { + try { + term.fit(); + } catch { + } + if (ws && ws.readyState === 1) ws.send(JSON.stringify({ type: "resize", cols: term.cols, rows: term.rows })); + } + }); + ro.observe(el); + return () => { + disposed = true; + ro.disconnect(); + try { + ws?.close(); + } catch { + } + try { + term.dispose(); + } catch { + } + }; + }, []); + if (failed) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_paneWip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneWipText", children: failed }) }); + } + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: hostRef, className: "dsh-wt_termHost" }); +} +var mdRenderer = new MarkdownItCallable({ linkify: true }); +var IMAGE_EXTS = /[.](png|jpe?g|gif|webp|svg|bmp|ico)$/i; +var MD_EXTS = /[.](md|markdown|mdown)$/i; +function FileViewer(props) { + const ext = (props.path.split(".").pop() || "").toLowerCase(); + const fileUrl = "/api/worktable/file?path=" + encodeURIComponent(props.path); + if (ext === "pdf") { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { className: "dsh-wt_paneFrame", src: fileUrl, title: basenameOf(props.path) }); + } + if (IMAGE_EXTS.test("." + ext)) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_imgView", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: fileUrl, alt: basenameOf(props.path) }) }); + } + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextViewer, { path: props.path, fileUrl, isMd: MD_EXTS.test("." + ext) }); +} +var CODE_LANGS = { ts: "typescript", tsx: "typescript", js: "javascript", jsx: "javascript", css: "css", json: "json" }; +var CODE_EXTS = /[.](tsx|ts|jsx|js|css|json)$/i; +function escapeHtml2(s) { + return s.replace(/&/g, "&").replace(//g, ">"); +} +function codeHtml(text2, ext) { + const lang = CODE_LANGS[ext] ?? ""; + if (lang) { + try { + return core_default.highlight(text2, { language: lang }).value; + } catch { + return escapeHtml2(text2); + } + } + return escapeHtml2(text2); +} +function TextViewer(props) { + const [text2, setText] = (0, import_react.useState)(null); + const [error2, setError] = (0, import_react.useState)(""); + const [mode, setMode] = (0, import_react.useState)("preview"); + const [draft, setDraft] = (0, import_react.useState)(""); + const [saving, setSaving] = (0, import_react.useState)(false); + const [saveFail, setSaveFail] = (0, import_react.useState)(false); + (0, import_react.useEffect)(() => { + let dead = false; + setText(null); + setError(""); + fetch(props.fileUrl).then((r) => { + if (!r.ok) throw new Error("HTTP " + r.status); + return r.text(); + }).then((t) => { + if (!dead) setText(t); + }).catch((e) => { + if (!dead) setError(String(e)); + }); + return () => { + dead = true; + }; + }, [props.fileUrl]); + const enterEdit = () => { + setDraft(text2 ?? ""); + setSaveFail(false); + setMode("edit"); + }; + const save = async () => { + setSaving(true); + setSaveFail(false); + try { + const r = await fetch("/api/worktable/write", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ path: props.path, content: draft }) + }); + if (!r.ok) throw new Error("HTTP " + r.status); + setText(draft); + setMode("preview"); + } catch { + setSaveFail(true); + } finally { + setSaving(false); + } + }; + if (error2) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_paneWip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-wt_paneWipText", children: [ + T("file.fail"), + "\uFF1A", + error2 + ] }) }); + } + if (text2 == null) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_paneWip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneWipText", children: T("file.loading") }) }); + } + const ext = (props.path.split(".").pop() || "").toLowerCase(); + const isCode = CODE_EXTS.test("." + ext); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_mdBar", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_mdBtn" + (mode === "preview" ? " dsh-wt_mdBtnOn" : ""), onClick: () => setMode("preview"), children: T("file.preview") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_mdBtn" + (mode === "edit" ? " dsh-wt_mdBtnOn" : ""), onClick: enterEdit, children: T("file.edit") }), + mode === "edit" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_mdSave", disabled: saving, onClick: save, children: saving ? "\u2026" : T("file.save") }), + saveFail && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_mdMsg", children: T("file.saveFail") }) + ] }), + mode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dsh-wt_mdEdit", value: draft, spellCheck: false, onChange: (e) => setDraft(e.target.value) }) : props.isMd ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_fileView", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_md", + dangerouslySetInnerHTML: { __html: mdRenderer.render(text2) }, + onClick: (e) => { + const a = e.target && e.target.closest ? e.target.closest("a") : null; + if (!a) return; + e.preventDefault(); + const href = a.getAttribute("href") || ""; + if (/^(https?:|mailto:)/i.test(href)) window.open(href, "_blank", "noopener"); + } + } + ) }) : isCode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_fileView", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dsh-wt_code", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { dangerouslySetInnerHTML: { __html: codeHtml(text2, ext) } }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_fileView", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dsh-wt_txt", children: text2 }) }) + ] }); +} +function SelectPop(props) { + const [open, setOpen] = (0, import_react.useState)(false); + const flat = props.groups.flatMap((g) => g.items); + const selected = flat.find((i) => i.id === props.value); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_select", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_selectBtn", onClick: () => setOpen((v) => !v), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_selectVal" + (selected ? "" : " dsh-wt_selectPh"), children: selected?.label ?? props.placeholder ?? "" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_selectCaret", "aria-hidden": true, children: "\u25BE" }) + ] }), + open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_selectList", children: props.groups.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [ + g.title && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_selectDivider" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_selectGroup", children: [ + "\u{1F4C1} ", + g.title + ] }) + ] }), + g.items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_selectItem" + (it.id === props.value ? " dsh-wt_selectItemOn" : ""), + onClick: () => { + props.onChange(it.id); + setOpen(false); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_selectItemTitle", children: it.label }), + it.isCurrent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_selectCurrent", children: T("custom.sessionCurrent") }) + ] + }, + it.id + )) + ] }, g.title || "g" + gi)) }) + ] }); +} +function CustomPane(props) { + const paneTitle = props.paneTitle ?? ""; + try { + window.__dshLastCustomPaneTitle = paneTitle; + } catch { + } + const custom = splitEnv?.custom; + const [requirement, setRequirement] = (0, import_react.useState)(""); + const [projectId, setProjectId] = (0, import_react.useState)(null); + const [projects, setProjects] = (0, import_react.useState)(() => custom?.getProjects?.() ?? []); + const [mode, setMode] = (0, import_react.useState)("existing"); + const [sessionGroups, setSessionGroups] = (0, import_react.useState)([]); + const [sessionId, setSessionId] = (0, import_react.useState)(null); + const [wsGroups, setWsGroups] = (0, import_react.useState)([]); + const [groupMode, setGroupMode] = (0, import_react.useState)("none"); + const [groupId, setGroupId] = (0, import_react.useState)(null); + const [newGroupParent, setNewGroupParent] = (0, import_react.useState)(""); + const [newGroupName, setNewGroupName] = (0, import_react.useState)(""); + const [busy, setBusy] = (0, import_react.useState)(false); + const [done, setDone] = (0, import_react.useState)(false); + const [fail, setFail] = (0, import_react.useState)(""); + const [bindNote, setBindNote] = (0, import_react.useState)("none"); + (0, import_react.useEffect)(() => { + const list2 = custom?.getProjects?.() ?? []; + setProjects(list2); + const cur = custom?.currentProjectId?.() ?? null; + setProjectId(cur && list2.some((p) => p.id === cur) ? cur : list2[0]?.id ?? null); + setWsGroups((custom?.getWorkspaces?.() ?? []).map((w) => ({ id: w.id, title: w.title, path: w.path }))); + custom?.getSessions?.().then((res) => { + setSessionGroups(res.groups); + const flat = res.groups.flatMap((g) => g.sessions); + setSessionId(flat.find((s) => s.isCurrent)?.id ?? flat[0]?.id ?? null); + const curId = flat.find((s) => s.isCurrent)?.id; + const home = curId ? (custom?.getWorkspaces?.() ?? []).find((w) => (w.sessionIds ?? []).includes(curId)) : null; + if (home) { + setGroupMode("existing"); + setGroupId(home.id); + } + }).catch(() => { + setSessionGroups([]); + }); + }, [custom]); + const submit = async () => { + const text2 = requirement.trim(); + if (!text2 || !projectId || !custom) return; + setBusy(true); + setFail(""); + try { + const proj = projects.find((p) => p.id === projectId); + const pname = proj?.name ?? projectId; + if (mode === "new") { + let group = { kind: "none" }; + if (groupMode === "existing" && groupId) group = { kind: "existing", workspaceId: groupId }; + else if (groupMode === "new") { + if (!newGroupParent.trim() || !newGroupName.trim()) { + setFail(T("custom.groupNeedPath")); + return; + } + group = { kind: "new", parent: newGroupParent.trim(), name: newGroupName.trim() }; + } + const sid = await custom.submit(projectId, pname, text2, group, paneTitle); + setBindNote(custom.autoBind?.(sid) ?? "none"); + } else { + if (!sessionId) return; + await custom.sendToSession(sessionId, projectId, pname, text2, paneTitle); + setBindNote(custom.autoBind?.(sessionId) ?? "none"); + } + setDone(true); + } catch (e) { + setFail(String(e)); + } finally { + setBusy(false); + } + }; + if (!custom) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_paneWip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneWipText", children: T("pane.wip") }) }); + } + if (done) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customBox", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customDone", "aria-hidden": true, children: "\u2705" }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-wt_customDoneText", children: mode === "new" ? T("custom.done") : T("custom.sent") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-wt_customDoneHint", children: T("custom.doneHint") }), + bindNote !== "none" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-wt_customDoneBind", children: bindNote === "auto" ? T("custom.autoBound") : T("custom.keptBinding") }) + ] }); + } + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_customBox", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customCard", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-wt_customTitle", children: [ + "\u2728 ", + T("custom.title") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customModes", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_customModeBtn" + (mode === "existing" ? " dsh-wt_customModeBtnOn" : ""), onClick: () => setMode("existing"), children: T("custom.modeSend") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_customModeBtn" + (mode === "new" ? " dsh-wt_customModeBtnOn" : ""), onClick: () => setMode("new"), children: T("custom.modeNew") }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-wt_customHint", children: mode === "new" ? T("custom.hint") : T("custom.hintSend") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "textarea", + { + className: "dsh-wt_customInput", + autoFocus: true, + placeholder: T("custom.placeholder"), + value: requirement, + onChange: (e) => setRequirement(e.target.value) + } + ), + mode === "existing" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customLabel", children: T("custom.session") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + SelectPop, + { + value: sessionId, + groups: sessionGroups.map((g) => ({ + title: g.title, + items: g.sessions.map((s) => ({ id: s.id, label: s.title, isCurrent: s.isCurrent })) + })), + placeholder: T("custom.session"), + onChange: setSessionId + } + ) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customLabel", children: T("custom.project") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + SelectPop, + { + value: projectId, + groups: [{ title: "", items: projects.map((p) => ({ id: p.id, label: p.name })) }], + placeholder: T("custom.project"), + onChange: setProjectId + } + ) + ] }), + mode === "new" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customLabel", children: T("custom.group") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + SelectPop, + { + value: groupMode === "none" ? "__none" : groupMode === "new" ? "__new" : groupId, + groups: [{ + title: "", + items: [ + { id: "__none", label: T("custom.groupNone") }, + ...wsGroups.map((w) => ({ id: w.id, label: w.title })), + { id: "__new", label: T("custom.groupNew") } + ] + }], + placeholder: T("custom.group"), + onChange: (id) => { + if (id === "__none") setGroupMode("none"); + else if (id === "__new") setGroupMode("new"); + else { + setGroupMode("existing"); + setGroupId(id); + } + } + } + ) + ] }), + mode === "new" && groupMode === "new" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customLabel", children: T("custom.groupNewParent") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "input", + { + className: "dsh-wt_customPathInput", + placeholder: T("custom.groupNewParentPh"), + value: newGroupParent, + onChange: (e) => setNewGroupParent(e.target.value) + } + ) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_customRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_customLabel", children: T("custom.groupNewName") }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "input", + { + className: "dsh-wt_customPathInput", + placeholder: T("custom.groupNewNamePh"), + value: newGroupName, + onChange: (e) => setNewGroupName(e.target.value) + } + ) + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "button", + { + type: "button", + className: "dsh-wt_customSend", + disabled: busy || !requirement.trim() || !projectId || mode === "existing" && !sessionId || mode === "new" && groupMode === "new" && (!newGroupParent.trim() || !newGroupName.trim()), + onClick: submit, + children: busy ? "\u2026" : mode === "new" ? T("custom.send") : T("custom.sendToSession") + } + ), + fail && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-wt_customFail", children: [ + T("custom.fail"), + "\uFF1A", + fail + ] }) + ] }) }); +} +function PaneTabBody(props) { + const content = props.tab.content; + if (content.kind === "iframe") { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IframePane, { url: content.url, title: content.title ?? props.tab.title, reloadKey: props.reloadKey }); + } + if (content.kind === "file") { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileViewer, { path: content.path }); + } + if (content.type === "browser") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrowserPane, { row: props.row, index: props.index, tabId: props.tab.id, content, reloadKey: props.reloadKey }); + if (content.type === "anim") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimPane, { row: props.row, index: props.index, tabId: props.tab.id, content, reloadKey: props.reloadKey }); + if (content.type === "console") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConsolePane, {}); + if (content.type === "explorer") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExplorerPane, { row: props.row, index: props.index }); + if (content.type === "scm") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitPane, {}); + if (content.type === "tasks") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(JobsPane, {}); + if (content.type === "terminal") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalPane, {}); + if (content.type === "custom") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomPane, { paneTitle: props.paneTitle ?? "" }); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_paneWip", children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneWipIcon", "aria-hidden": true, children: BUILTIN_ICONS[content.type] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneWipText", children: T("pane.wip") }) + ] }); +} +function refreshableTab(t) { + const c = t.content; + return c.kind === "iframe" || c.kind === "builtin" && (c.type === "browser" || c.type === "anim"); +} +function PaneBody(props) { + const { pane, row, index } = props; + const tabs = pane.tabs ?? []; + const active = Math.min(pane.active ?? 0, Math.max(0, tabs.length - 1)); + const [reloadKeys, setReloadKeys] = (0, import_react.useState)({}); + if (tabs.length === 0) { + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PanePicker, { row, index }); + } + const refreshTab = (t) => { + setReloadKeys((m) => ({ ...m, [t.id]: (m[t.id] ?? 0) + 1 })); + splitStore.setActiveTab(row, index, t.id); + }; + const singleConsole = tabs.length === 1 && tabs[0].content?.kind === "builtin" && tabs[0].content.type === "console"; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + !singleConsole && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-wt_tabBar", children: tabs.map((t, i) => { + const locked = t.content?.kind === "builtin" && t.content.type === "console"; + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "span", + { + className: "dsh-wt_tab" + (i === active ? " dsh-wt_tabOn" : ""), + title: t.title, + draggable: !locked, + onDragStart: (e) => { + dragTab = { row, index, tabId: t.id }; + try { + e.dataTransfer.effectAllowed = "move"; + } catch { + } + }, + onDragEnd: () => { + dragTab = null; + setDropTarget(null); + }, + onClick: () => splitStore.setActiveTab(row, index, t.id), + children: [ + refreshableTab(t) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "button", + { + type: "button", + className: "dsh-wt_tabRefresh", + title: T("pane.refresh"), + "aria-label": T("pane.refresh"), + onClick: (e) => { + e.stopPropagation(); + refreshTab(t); + }, + children: "\u21BB" + } + ), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_tabTitle", children: t.title }), + !locked && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "button", + { + type: "button", + className: "dsh-wt_tabClose", + title: T("pane.closeTab"), + onClick: (e) => { + e.stopPropagation(); + splitStore.closeTab(row, index, t.id); + }, + children: "\u2715" + } + ) + ] + }, + t.id + ); + }) }), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaneTabBody, { tab: tabs[active], row, index, paneTitle: pane.title, reloadKey: reloadKeys[tabs[active].id] ?? 0 }) + ] }); +} +function PanePicker(props) { + const [mode, setMode] = (0, import_react.useState)("grid"); + const hostRef = (0, import_react.useRef)(null); + (0, import_react.useEffect)(() => { + const el = hostRef.current; + if (!el) return; + const update = () => { + const w = el.clientWidth; + const h = el.clientHeight; + const aspect = h > 0 ? w / h : 1; + setMode(aspect > 1.4 ? "row" : aspect > 0.72 ? "grid" : "col"); + }; + update(); + const ro = new ResizeObserver(update); + ro.observe(el); + return () => ro.disconnect(); + }, []); + const pick = (content) => splitStore.openTab(props.row, props.index, content); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: hostRef, className: "dsh-wt_panePicker dsh-wt_panePicker-" + mode, children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_panePick", onClick: () => pick({ kind: "builtin", type: "browser" }), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: "\u{1F310}" }), + T("pane.browser") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_panePick", onClick: () => pick({ kind: "builtin", type: "anim" }), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: "\u{1F3AC}" }), + T("pane.anim") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_panePick", onClick: () => pick({ kind: "builtin", type: "explorer" }), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: "\u{1F4C1}" }), + T("pane.explorer") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_panePick", onClick: () => pick({ kind: "builtin", type: "terminal" }), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: "\u25B8_" }), + T("pane.terminal") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-wt_panePick", onClick: () => pick({ kind: "builtin", type: "custom" }), children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, children: "\u2728" }), + T("pane.custom") + ] }) + ] }); +} +function WorkspaceLayer(props) { + const g = props.geom ?? { left: 0, top: 0, right: 0, bottom: 0 }; + const spec = props.spec; + const top = spec.top ?? []; + const main = spec.main ?? []; + const hasLeft = !!spec.left; + const hasTop = top.length > 0; + const chatLeft = !hasLeft && spec.chatSide === "left"; + const colW = g.right - g.left; + const rowH = g.bottom - g.top; + const chatW = clamp(props.chatW, spec.chatWidth.min, Math.max(spec.chatWidth.min, colW - 60)); + const topH = hasTop ? clamp(props.topH, spec.topHeight?.min ?? 80, Math.max(spec.topHeight?.min ?? 80, rowH - BAR_H - 80)) : 0; + const leftW = hasLeft ? clamp(props.leftW, spec.leftWidth?.min ?? 160, Math.max(spec.leftWidth?.min ?? 160, colW - 260)) : 0; + const chatFull = spec.chatFullHeight === true; + const contentW = Math.max(0, colW - chatW); + const contentX = hasLeft ? g.left + leftW : chatLeft ? g.left + chatW : g.left; + const topRowX = hasLeft ? g.left + leftW : contentX; + const topRowW = hasLeft ? Math.max(0, colW - leftW) : chatFull ? contentW : colW; + const topItems = allocate(top, props.topWs, topRowW); + const mainItems = allocate(main, props.paneWs, contentW); + const leftItem = spec.left ? { pane: spec.left, left: 0, width: leftW } : null; + const barTop = g.top; + const bodyTop = barTop + BAR_H + topH; + const paneBottom = g.bottom; + const mainH = paneBottom - bodyTop; + const topY = barTop + BAR_H; + const renderPane = (it, row, index, x, y, h) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( + "div", + { + className: "dsh-wt_pane", + "data-drop-hover": dropTarget && dropTarget.row === row && dropTarget.index === index ? "true" : void 0, + style: { position: "fixed", left: x + it.left, top: y, width: it.width, height: h, zIndex: 68 }, + onDragOver: (e) => { + if (!dragTab) return; + e.preventDefault(); + setDropTarget({ row, index }); + }, + onDragLeave: (e) => { + if (e.currentTarget && !e.currentTarget.contains(e.relatedTarget)) setDropTarget(null); + }, + onDrop: (e) => { + e.preventDefault(); + const s = dragTab; + dragTab = null; + setDropTarget(null); + if (s && (s.row !== row || s.index !== index)) { + splitStore.moveTab(s.row, s.index, s.tabId, row, index); + } + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_paneBar", + title: T("split.dragSwap"), + draggable: true, + onDragStart: (e) => { + dragPane = { row, index }; + try { + e.dataTransfer.effectAllowed = "move"; + } catch { + } + }, + onDragOver: (e) => e.preventDefault(), + onDrop: (e) => { + e.preventDefault(); + const s = dragPane; + if (s && (s.row !== row || s.index !== index)) splitStore.swapPanes(s.row, s.index, row, index); + dragPane = null; + }, + onDragEnd: () => { + dragPane = null; + }, + children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_paneTitle", children: it.pane.title }) + } + ), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaneBody, { pane: it.pane, row, index }) + ] + }, + it.pane.id + ); + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-wt_splitBar", style: { position: "fixed", left: g.left, top: barTop, width: hasLeft || chatFull ? contentW : hasTop ? colW : contentW, zIndex: 70 }, children: [ + spec.id !== "wt-console" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-wt_splitTitle", children: spec.title }), + !hasLeft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "button", + { + type: "button", + className: "dsh-wt_splitFlip", + title: T("split.flip"), + onClick: () => splitStore.setChatSide(chatLeft ? "right" : "left"), + children: "\u21C4" + } + ), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-wt_splitClose", "aria-label": "\u9000\u51FA\u5206\u680F\uFF08Esc\uFF09", onClick: () => splitStore.close(), children: "\u2715" }) + ] }), + leftItem && renderPane(leftItem, "left", 0, g.left, barTop + BAR_H, g.bottom - barTop - BAR_H), + hasTop && topItems.map((it, i) => renderPane(it, "top", i, topRowX, topY, topH)), + mainItems.map((it, i) => renderPane(it, "main", i, contentX, bodyTop, mainH)), + hasTop && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_splitDivider dsh-wt_splitDividerH", + role: "separator", + title: "\u62D6\u52A8\u8C03\u6574\u4E0A\u4E0B\u5206\u533A", + style: { position: "fixed", left: topRowX, top: bodyTop - DIVIDER / 2, width: topRowW, height: DIVIDER, zIndex: 72 }, + onPointerDown: makeDividerHandler("top") + } + ), + hasTop && topItems.slice(0, -1).map((it, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_splitDivider", + role: "separator", + title: "\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6", + style: { position: "fixed", left: topRowX + it.left + it.width, top: topY, width: DIVIDER, height: topH, zIndex: 72 }, + onPointerDown: makeDividerHandler("topPane", i) + }, + "tv" + it.pane.id + )), + mainItems.slice(0, -1).map((it, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_splitDivider", + role: "separator", + title: "\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6", + style: { position: "fixed", left: contentX + it.left + it.width, top: bodyTop, width: DIVIDER, height: mainH, zIndex: 72 }, + onPointerDown: makeDividerHandler("pane", i) + }, + "v" + it.pane.id + )), + /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + "div", + { + className: "dsh-wt_splitDivider", + role: "separator", + title: hasLeft ? "\u62D6\u52A8\u8C03\u6574\u5DE6\u53F3\u5217\u5BBD" : "\u62D6\u52A8\u8C03\u6574\u804A\u5929\u5BBD\u5EA6", + style: { + position: "fixed", + left: (hasLeft ? g.left + leftW : chatLeft ? g.left + chatW : g.right - chatW) - DIVIDER / 2, + top: hasLeft || chatFull ? barTop + BAR_H : bodyTop, + width: DIVIDER, + height: hasLeft || chatFull ? g.bottom - barTop - BAR_H : mainH, + zIndex: 72 + }, + onPointerDown: makeDividerHandler(hasLeft ? "left" : "chat") + } + ) + ] }); +} +function SplitWorkspace() { + const [snap, setSnap] = (0, import_react.useState)({ + active: splitStore.active, + spec: splitStore.spec, + geom: splitStore.geom, + chatW: splitStore.chatW, + topH: splitStore.topH, + leftW: splitStore.leftW, + paneWs: [...splitStore.paneWs], + topWs: [...splitStore.topWs] + }); + const poolRef = (0, import_react.useRef)(/* @__PURE__ */ new Map()); + const [, setPoolTick] = (0, import_react.useState)(0); + (0, import_react.useEffect)(() => splitStore.subscribe(() => { + const spec = splitStore.spec; + if (splitStore.active && spec) { + poolRef.current.set(spec.id, { + spec, + chatW: splitStore.chatW, + topH: splitStore.topH, + leftW: splitStore.leftW, + paneWs: [...splitStore.paneWs], + topWs: [...splitStore.topWs] + }); + while (poolRef.current.size > 6) { + const first = poolRef.current.keys().next().value; + if (first != null) poolRef.current.delete(first); + } + } + setSnap({ + active: splitStore.active, + spec: splitStore.spec, + geom: splitStore.geom, + chatW: splitStore.chatW, + topH: splitStore.topH, + leftW: splitStore.leftW, + paneWs: [...splitStore.paneWs], + topWs: [...splitStore.topWs] + }); + setPoolTick((t) => t + 1); + }), []); + (0, import_react.useEffect)(() => { + if (!snap.active) return; + const onKey = (event) => { + if (event.key === "Escape") splitStore.close(); + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [snap.active]); + const [, setDropTick] = (0, import_react.useState)(0); + (0, import_react.useEffect)(() => { + const fn = () => setDropTick((t) => t + 1); + dropTargetListeners.add(fn); + return () => { + dropTargetListeners.delete(fn); + }; + }, []); + const activeId = snap.active && snap.spec ? snap.spec.id : null; + const entries = Array.from(poolRef.current.entries()); + if (entries.length === 0) return null; + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: entries.map(([id, item]) => { + const isActive = id === activeId; + return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: isActive ? void 0 : { visibility: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( + WorkspaceLayer, + { + spec: item.spec, + geom: isActive ? snap.geom : null, + chatW: isActive ? snap.chatW : item.chatW, + topH: isActive ? snap.topH : item.topH, + leftW: isActive ? snap.leftW : item.leftW, + paneWs: isActive ? snap.paneWs : item.paneWs, + topWs: isActive ? snap.topWs : item.topWs + } + ) }, id); + }) }); +} +try { + window.__dshWorktable = { splitStore }; +} catch { +} + +// src/client/index.tsx +var import_jsx_runtime2 = require("react/jsx-runtime"); +var PERSIST_KEY2 = "dsh.worktable.view.v1"; +var PROJECTS_KEY = "dsh.worktable.projects.v1"; +var MIN_TOP = 56; +var SNAP_PX = 32; +var LEGACY_BUMP_COOLDOWN = 15e3; +var OVER_BOTTOM_PX = 24; +var OVER_TOP_PX = 24; +var OVER_SIDE_PX = 80; +var PRESET_DEFS = [ + { id: "2h", leftCount: 0, topCount: 0, contentCount: 1, chatFull: false }, + { id: "3h", leftCount: 0, topCount: 0, contentCount: 2, chatFull: false }, + { id: "l2", leftCount: 0, topCount: 1, contentCount: 1, chatFull: true }, + { id: "grid", leftCount: 0, topCount: 2, contentCount: 1, chatFull: false }, + { id: "t3", leftCount: 0, topCount: 1, contentCount: 2, chatFull: true }, + { id: "l13", leftCount: 0, topCount: 1, contentCount: 3, chatFull: true, topHeightDefault: 420, topHeightRatio: 0.55 }, + { id: "g4", leftCount: 0, topCount: 2, contentCount: 2, chatFull: true, topHeightRatio: 0.5 }, + { id: "l23", leftCount: 0, topCount: 2, contentCount: 3, chatFull: true, topHeightRatio: 0.5 } +]; +var EMOJI_SET = ["\u{1F9F1}", "\u{1F3E0}", "\u{1F393}", "\u{1F697}", "\u2708\uFE0F", "\u{1F30D}", "\u{1F3E5}", "\u{1F4DA}", "\u270F\uFE0F", "\u2699\uFE0F", "\u{1F3A8}", "\u{1F3AE}", "\u{1F30F}", "\u{1F4D0}", "\u{1F9EA}", "\u{1F916}", "\u{1F4E6}", "\u{1F4AC}"]; +var ICON_SEARCH = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M11.894845 6.647401C11.894845 3.725463 9.534486 1.356779 6.623219 1.35657C3.711786 1.35657 1.351635 3.725338 1.351635 6.647401C1.351843 9.569296 3.711911 11.938273 6.623219 11.938273C9.534361 11.938064 11.894637 9.569171 11.894845 6.647401ZM13.245462 6.647401C13.245254 10.317935 10.280401 13.293613 6.623219 13.293821C2.965871 13.293821 0.000204 10.31806 0 6.647401C0 2.976574 2.965746 0 6.623219 0C10.280526 0.000205 13.245462 2.9767 13.245462 6.647401Z", fill: "currentColor" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M16.000417 15.041079L15.044449 16.000433L11.530434 12.473588L12.486298 11.514234L16.000417 15.041079Z", fill: "currentColor" }) +] }); +var ICON_VIEW_OPTIONS = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { transform: "translate(1.292 1.3)", d: "M10.3232 9.18164C11.2868 9.18164 12.0985 9.82833 12.3506 10.7109L13.415 10.7109L13.415 11.8711L12.3496 11.8711C12.0971 12.7532 11.2864 13.3994 10.3232 13.3994C9.36031 13.3992 8.55012 12.7531 8.29785 11.8711L0 11.8711L0 10.7109L8.29688 10.7109C8.54876 9.82845 9.35988 9.18186 10.3232 9.18164ZM10.3232 10.3418C9.7999 10.3421 9.37534 10.7667 9.375 11.29C9.375 11.8137 9.79969 12.239 10.3232 12.2393C10.847 12.2393 11.2725 11.8138 11.2725 11.29C11.2721 10.7666 10.8468 10.3418 10.3232 10.3418ZM12.4326 11.291C12.4326 11.3549 12.4284 11.418 12.4229 11.4805C12.4287 11.4181 12.4326 11.355 12.4326 11.291ZM8.21484 11.2832C8.21484 11.2856 8.21484 11.2886 8.21484 11.291L8.21484 11.29C8.21484 11.2878 8.21484 11.2855 8.21484 11.2832ZM3.08301 4.59082C4.04605 4.59095 4.85696 5.23717 5.10938 6.11914L13.415 6.11914L13.415 7.2793L5.11035 7.2793C4.85833 8.16202 4.04648 8.80846 3.08301 8.80859C2.11972 8.80843 1.30963 8.16179 1.05762 7.2793L0 7.2793L0 6.11914L1.05762 6.11914C1.30994 5.23728 2.12006 4.59098 3.08301 4.59082ZM3.08301 5.75098C2.55962 5.75117 2.13512 6.17587 2.13477 6.69922C2.13477 7.22287 2.5594 7.64824 3.08301 7.64844C3.60665 7.64828 4.03223 7.2229 4.03223 6.69922C4.03187 6.17585 3.60643 5.75113 3.08301 5.75098ZM5.19238 6.69922C5.19238 6.763 5.18816 6.82633 5.18262 6.88867C5.18846 6.82629 5.19238 6.76313 5.19238 6.69922C5.19236 6.63495 5.18853 6.57152 5.18262 6.50879C5.18826 6.57154 5.19236 6.635 5.19238 6.69922ZM0.982422 6.52344C0.977382 6.58136 0.97463 6.63999 0.974609 6.69922C0.974609 6.75775 0.977496 6.81579 0.982422 6.87305C0.977758 6.81579 0.974609 6.75767 0.974609 6.69922C0.974628 6.64 0.977618 6.58142 0.982422 6.52344ZM10.3232 0C11.2869 0 12.0986 0.646596 12.3506 1.5293L13.415 1.5293L13.415 2.68945L12.3496 2.68945C12.363 2.64266 12.3754 2.59488 12.3857 2.54688C12.1838 3.50118 11.3376 4.21777 10.3232 4.21777C9.36037 4.21756 8.55018 3.57139 8.29785 2.68945L0 2.68945L0 1.5293L8.29688 1.5293C8.5487 0.646717 9.35981 0.00021854 10.3232 0ZM10.3232 1.16016C9.79984 1.16042 9.37524 1.58499 9.375 2.1084C9.375 2.63201 9.79969 3.05735 10.3232 3.05762C10.847 3.05762 11.2725 2.63217 11.2725 2.1084C11.2722 1.58483 10.8469 1.16016 10.3232 1.16016ZM12.4229 2.29883C12.4287 2.23641 12.4326 2.17331 12.4326 2.10938C12.4326 2.17327 12.4284 2.23638 12.4229 2.29883ZM8.21484 2.10938L8.21484 2.1084L8.21484 2.10938ZM8.22266 1.93359C8.21785 1.98897 8.21506 2.04499 8.21484 2.10156C8.21503 2.04501 8.2181 1.98902 8.22266 1.93359ZM8.22266 11.1162C8.2179 11.1713 8.21507 11.227 8.21484 11.2832C8.21504 11.227 8.21814 11.1713 8.22266 11.1162Z", fill: "currentColor" }) }); +var ICON_ADD = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { transform: "translate(9.52 2.52)", d: "M3.55246 0L3.55246 2.44252L6 2.44252L6 3.55748L3.55246 3.55748L3.55246 6L2.43834 6L2.43834 3.55748L0 3.55748L0 2.44252L2.43834 2.44252L2.43834 0L3.55246 0Z", fill: "currentColor" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { transform: "translate(0.3496 2.35)", d: "M4.76367 0C5.36861 1.80598e-05 5.93113 0.310294 6.25488 0.821289L6.78027 1.64941C6.79685 1.67558 6.81791 1.69775 6.83887 1.71973C6.72186 2.15521 6.65702 2.61192 6.65137 3.08301C6.25601 2.96045 5.90909 2.70478 5.68164 2.3457L5.15723 1.5166C5.07183 1.38189 4.92318 1.3008 4.76367 1.30078L2.32422 1.30078C1.7589 1.30078 1.30078 1.7589 1.30078 2.32422L1.30078 10.1338C1.30078 10.6991 1.7589 11.1572 2.32422 11.1572L11.9766 11.1572C12.5419 11.1572 13 10.6991 13 10.1338L13 8.58398C13.4545 8.5135 13.8903 8.38748 14.3008 8.21289L14.3008 10.1338C14.3008 11.4171 13.2598 12.458 11.9766 12.458L2.32422 12.458C1.04093 12.458 0 11.4171 0 10.1338L0 2.32422C0 1.04093 1.04093 0 2.32422 0L4.76367 0Z", fill: "currentColor" }) +] }); +function buildLayout(presetId, name) { + const def = PRESET_DEFS.find((d) => d.id === presetId) ?? PRESET_DEFS[0]; + const mk = (i) => ({ + id: "p" + (i + 1), + title: "\u7A97\u53E3" + (i + 1), + min: 200, + content: null + }); + const left = def.leftCount > 0 ? mk(0) : null; + const top = Array.from({ length: def.topCount }, (_, i) => mk(def.leftCount + i)); + const main = Array.from({ length: def.contentCount }, (_, i) => mk(def.leftCount + def.topCount + i)); + return { + id: "layout-" + Date.now().toString(36), + title: name, + left: left ?? null, + top: top.length > 0 ? top : null, + main, + leftWidth: { default: 260, min: 160, max: 480 }, + chatWidth: { default: 360, min: 240, max: 600 }, + topHeight: { default: def.topHeightDefault ?? 200, min: 120, max: 480 }, + topHeightRatio: def.topHeightRatio ?? 0.35, + chatSide: "right", + chatFullHeight: def.chatFull === true + }; +} +function presetThumb(defId) { + const cell = (chat, key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCell" + (chat ? " dsh-wt_thumbChat" : ""), children: chat ? "\u{1F4AC}" : "" }, key); + if (defId === "2h") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumb", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "a"), + cell(true, "b") + ] }) }); + } + if (defId === "3h") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumb", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "a"), + cell(false, "b"), + cell(true, "c") + ] }) }); + } + if (defId === "g4") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb dsh-wt_thumbCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "a"), + cell(false, "b") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "c"), + cell(false, "d") + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCol", children: cell(true, "e") }) + ] }); + } + if (defId === "l23") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb dsh-wt_thumbCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "a"), + cell(false, "b") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "c"), + cell(false, "d"), + cell(false, "e") + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCol", children: cell(true, "f") }) + ] }); + } + if (defId === "l13") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb dsh-wt_thumbCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbRow", children: cell(false, "a") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "b"), + cell(false, "c"), + cell(false, "d") + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCol", children: cell(true, "e") }) + ] }); + } + if (defId === "grid") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "a"), + cell(false, "b") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "c"), + cell(true, "d") + ] }) + ] }); + } + if (defId === "l2") { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb dsh-wt_thumbCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbRow", children: cell(false, "a") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbRow", children: cell(false, "b") }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCol", children: cell(true, "c") }) + ] }); + } + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumb dsh-wt_thumbCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbRow", children: cell(false, "a") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_thumbRow", children: [ + cell(false, "b"), + cell(false, "c") + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_thumbCol", children: cell(true, "d") }) + ] }); +} +var DEFAULT_VIEW = { + query: "", + searchOpen: false, + orderBy: "manual", + dock: "footer", + floatTop: null +}; +var DEFAULT_PROJECTS = { + order: [], + lastUsed: {}, + hidden: [], + nameOverrides: {}, + iconOverrides: {}, + removed: [], + views: {}, + shortcuts: [], + layouts: [], + bindings: {}, + folders: {} +}; +function loadView() { + try { + const raw = localStorage.getItem(PERSIST_KEY2); + if (!raw) return { ...DEFAULT_VIEW }; + const p = JSON.parse(raw); + const orderBy = p.sortMigratedV2 === true ? p.orderBy === "recent" ? "recent" : "manual" : "manual"; + return { + query: typeof p.query === "string" ? p.query : "", + searchOpen: p.searchOpen === true, + orderBy, + dock: p.dock === "float" ? "float" : "footer", + floatTop: typeof p.floatTop === "number" ? p.floatTop : null, + consoleTheme: p.consoleTheme === "dark" || p.consoleTheme === "light" || p.consoleTheme === "system" ? p.consoleTheme : "system" + }; + } catch { + return { ...DEFAULT_VIEW }; + } +} +function loadProjects() { + try { + const raw = localStorage.getItem(PROJECTS_KEY); + if (!raw) return { ...DEFAULT_PROJECTS }; + const p = JSON.parse(raw); + return { + order: Array.isArray(p.order) ? p.order.filter((x) => typeof x === "string") : [], + lastUsed: p.lastUsed && typeof p.lastUsed === "object" ? p.lastUsed : {}, + hidden: Array.isArray(p.hidden) ? p.hidden.filter((x) => typeof x === "string") : [], + nameOverrides: p.nameOverrides && typeof p.nameOverrides === "object" ? p.nameOverrides : {}, + iconOverrides: p.iconOverrides && typeof p.iconOverrides === "object" ? p.iconOverrides : {}, + removed: Array.isArray(p.removed) ? p.removed.filter((x) => typeof x === "string") : [], + views: p.views && typeof p.views === "object" ? p.views : {}, + shortcuts: Array.isArray(p.shortcuts) ? p.shortcuts.filter((s) => s && typeof s.id === "string" && typeof s.name === "string" && typeof s.href === "string") : [], + layouts: Array.isArray(p.layouts) ? p.layouts.filter((l) => l && typeof l.id === "string" && typeof l.title === "string" && Array.isArray(l.main)) : [], + bindings: p.bindings && typeof p.bindings === "object" ? p.bindings : {}, + folders: p.folders && typeof p.folders === "object" ? p.folders : {} + }; + } catch { + return { ...DEFAULT_PROJECTS }; + } +} +var clamp2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi); +function findSidebar(start) { + let el = start; + while (el && el !== document.body) { + const tag = el.tagName.toLowerCase(); + if (tag === "aside" || tag === "nav") return el; + if (typeof el.className === "string" && /SidebarRoot|sidebar/i.test(el.className)) return el; + el = el.parentElement; + } + return null; +} +var registryStore = { ids: [], listeners: /* @__PURE__ */ new Set() }; +var sessionBridge = null; +var hostApi = null; +async function ensureSessionPreset(sessionId) { + const api = hostApi?.agentPresets; + if (!api || typeof api.list !== "function" || typeof api.select !== "function") return; + try { + const listRes = await api.list({}); + const presets = listRes?.result?.ok ? listRes?.result?.value?.presets : null; + if (!Array.isArray(presets) || presets.length === 0) return; + const ordered = [...presets]; + const defIdx = ordered.findIndex((p) => p?.isDefault); + if (defIdx > 0) ordered.unshift(ordered.splice(defIdx, 1)[0]); + for (const preset of ordered) { + const pid = preset?.id; + if (!pid) continue; + try { + const selRes = await api.select({ sessionId, agentPreset: pid }); + if (selRes?.result?.ok) { + try { + sessionBridge?.sessions?.noteAgentPreset?.(sessionId, pid); + } catch { + } + return; + } + try { + if (typeof console !== "undefined" && console.warn) console.warn("[worktable] preset select failed:", pid, selRes?.result?.error?.message ?? ""); + } catch { + } + } catch (err) { + try { + if (typeof console !== "undefined" && console.warn) console.warn("[worktable] preset select threw:", pid, String(err)); + } catch { + } + } + } + } catch { + } +} +function pickInheritedModel(groups, baseModel) { + if (!Array.isArray(groups) || groups.length === 0) return null; + const flat = []; + for (const g of groups) { + if (!g?.id || !Array.isArray(g.models)) continue; + for (const m of g.models) if (m?.id) flat.push({ provider: g.id, model: m.id, name: String(m.name ?? "") }); + } + if (flat.length === 0) return null; + const base2 = String(baseModel ?? "").toLowerCase(); + if (base2) { + const exact = flat.find((f) => f.model.toLowerCase() === base2); + if (exact) return { provider: exact.provider, model: exact.model }; + const tokens = base2.split(/[-_.]/).filter((t) => t && (/^(pro|max|mini|flash|lite|ultra|plus|sonnet|opus|haiku|turbo)$/i.test(t) || t.length >= 4)); + for (const tok of tokens) { + const hit = flat.find((f) => f.model.toLowerCase().includes(tok) || f.name.toLowerCase().includes(tok)); + if (hit) return { provider: hit.provider, model: hit.model }; + } + } + return { provider: flat[0].provider, model: flat[0].model }; +} +async function ensureSessionModel(sessionId) { + const api = hostApi?.sessions; + if (!api || typeof api.models !== "function" || typeof api.selectModel !== "function") return; + try { + const mRes = await api.models({ sessionId }); + if (!mRes?.result?.ok) return; + const val = mRes.result.value; + const groups = val?.groups; + let target = null; + let effort; + try { + const cur = sessionBridge?.list?.getSnapshot?.()?.current; + if (cur && cur !== sessionId) { + const cRes = await api.models({ sessionId: cur }); + if (cRes?.result?.ok) { + const cval = cRes.result.value; + if (cval?.routable === true && cval?.current?.provider && cval?.current?.model) { + const same = val?.current?.provider === cval.current.provider && val?.current?.model === cval.current.model; + if (!same) { + target = { provider: cval.current.provider, model: cval.current.model }; + effort = typeof cval.current.reasoningEffort === "string" ? cval.current.reasoningEffort : void 0; + } + } + } + } + } catch { + } + if (!target && val?.routable !== true) { + try { + const snap = sessionBridge?.list?.getSnapshot?.(); + const byId = snap?.byId ?? {}; + const ids = (snap?.ids ?? []).filter((x) => x !== sessionId); + const scored = []; + await Promise.all(ids.slice(0, 6).map(async (sid) => { + const row = byId[sid]; + if (row?.blank === true) return; + try { + const r2 = await api.models({ sessionId: sid }); + if (!r2?.result?.ok) return; + const cv = r2.result.value; + if (cv?.routable !== true || !cv?.current?.provider || !cv?.current?.model) return; + const key = cv.current.provider + "|" + cv.current.model; + const found = scored.find((s) => s.key === key); + if (found) found.count++; + else scored.push({ key, provider: cv.current.provider, model: cv.current.model, effort: typeof cv.current.reasoningEffort === "string" ? cv.current.reasoningEffort : void 0, count: 1 }); + } catch { + } + })); + scored.sort((a, b) => b.count - a.count); + if (scored[0]) { + target = { provider: scored[0].provider, model: scored[0].model }; + effort = scored[0].effort; + } + } catch { + } + } + if (!target && val?.routable !== true) target = pickInheritedModel(groups, val?.current?.model); + if (!target) return; + await api.selectModel({ sessionId, provider: target.provider, model: target.model, ...effort !== void 0 ? { reasoningEffort: effort } : {} }); + } catch { + } +} +var CONSOLE_ID = "wt-console"; +var CONSOLE_ICON = "\u{1F5A5}\uFE0F"; +function specHasConsoleTab(spec) { + return !!spec?.main?.[0]?.tabs?.some((t) => t.content?.kind === "builtin" && t.content.type === "console"); +} +function buildConsoleSpec(t) { + return { + id: CONSOLE_ID, + title: t("console.name"), + icon: CONSOLE_ICON, + top: null, + main: [{ + id: "console", + title: "\u63A7\u5236\u5BA4", + min: 240, + tabs: [{ id: "c1", title: "\u63A7\u5236\u5BA4", content: { kind: "builtin", type: "console" } }], + active: 0 + }], + chatWidth: { default: 340, min: 280, max: 600 }, + topHeight: { default: 200, min: 120, max: 480 }, + chatSide: "right" + }; +} +var consoleListeners = /* @__PURE__ */ new Set(); +var notifyConsole = () => consoleListeners.forEach((l) => { + try { + l(); + } catch { + } +}); +function listWorkspaces() { + try { + const snap = sessionBridge?.workspaces?.list?.getSnapshot?.(); + const items = snap?.items ?? []; + return items.map((w) => ({ + id: w.workspaceId ?? w.id, + title: w.title ?? "", + path: w.path ?? "" + })); + } catch { + return []; + } +} +function cleanPreviewText(raw) { + let s = String(raw ?? ""); + s = s.replace(/```[a-zA-Z0-9_+-]*[\s\S]*?```/g, " "); + s = s.replace(/```[a-zA-Z0-9_+-]*[\s\S]*$/g, " "); + s = s.replace(/`[^`\n]{1,200}`/g, " "); + s = s.replace(/```/g, " "); + s = s.replace(/\s+/g, " ").trim(); + return s; +} +var previewCache = /* @__PURE__ */ new Map(); +var previewFetching = /* @__PURE__ */ new Set(); +var previewSweepBusy = false; +var previewTimer = null; +async function coldPreviewOf(face) { + if (!face || typeof face.history !== "function") return ""; + const r1 = await face.history({ maxMessages: 6 }); + const evs = r1?.result?.value?.events; + if (!Array.isArray(evs)) return ""; + const textOf = (blocks) => { + let fallback = ""; + if (!Array.isArray(blocks)) return ""; + for (const b of blocks) { + const s = typeof b?.text === "string" ? b.text.trim() : ""; + if (!s) continue; + if (b?.type === "text") return s; + if (!fallback) fallback = s; + } + return fallback; + }; + for (let i = evs.length - 1; i >= 0; i--) { + const ev = evs[i]?.event; + if (!ev) continue; + const d = ev.data ?? {}; + let raw = ""; + if (ev.type === "user/message") raw = textOf(d.content ?? d.blocks); + else if (ev.type === "assistant/message") { + const m = d.message ?? d; + raw = textOf(m.content ?? m.blocks); + } + if (!raw) continue; + const clean = cleanPreviewText(raw); + if (clean.length >= 8) return clean.slice(0, 220); + } + return ""; +} +async function sweepPreviews() { + if (previewSweepBusy) return; + previewSweepBusy = true; + try { + const sids = Array.from(new Set(Object.values(projectBindingsRef.current).filter((x) => !!x))); + for (const sid of sids) { + if (previewFetching.has(sid)) continue; + previewFetching.add(sid); + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session; + const txt = await coldPreviewOf(face); + if (txt) { + previewCache.set(sid, txt); + notifyConsole(); + } + } catch { + } finally { + previewFetching.delete(sid); + } + } + } finally { + previewSweepBusy = false; + } +} +function schedulePreviewSweep() { + if (previewTimer != null) return; + previewTimer = window.setTimeout(() => { + previewTimer = null; + sweepPreviews(); + }, 6e3); +} +function lastTextOf(sid) { + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session?.getSnapshot?.(); + const nodes = face?.nodes ?? []; + for (let i = nodes.length - 1; i >= 0; i--) { + const n = nodes[i]; + const blocks = Array.isArray(n?.blocks) ? n.blocks : Array.isArray(n?.content) ? n.content : []; + let raw = ""; + for (const b of blocks) { + const s = typeof b?.text === "string" ? b.text.trim() : ""; + if (!s) continue; + if (b?.type === "text") { + raw = s; + break; + } + if (!raw) raw = s; + } + if (!raw) continue; + const clean = cleanPreviewText(raw); + if (clean.length >= 8) return clean.slice(0, 220); + } + } catch { + } + return ""; +} +async function fetchSessionGroups() { + try { + const snap = sessionBridge?.list?.getSnapshot?.(); + const byId = snap?.byId ?? {}; + const current = snap?.current ?? ""; + const subKids = /* @__PURE__ */ new Set(); + try { + const map2 = snap?.subagentsByParent ?? {}; + for (const k of Object.keys(map2)) { + const v = map2[k]; + const arr = Array.isArray(v) ? v : v?.entries ?? v?.items ?? []; + if (Array.isArray(arr)) arr.forEach((c) => { + const cid = c?.sessionId ?? c?.id; + if (typeof cid === "string") subKids.add(cid); + }); + } + } catch { + } + const titleOf = (sid) => byId[sid]?.title ?? byId[sid]?.displayTitle ?? sid; + const mk = (sid) => ({ id: sid, title: titleOf(sid), isCurrent: sid === current }); + try { + const r = await fetch("/api/worktable/workspaces"); + const d = await r.json(); + const order = Array.isArray(d?.global?.workspaceIds) ? d.global.workspaceIds : []; + const archived = Array.isArray(d?.global?.archivedSessionIds) ? d.global.archivedSessionIds : []; + const table2 = d?.tables?.workspaces ?? {}; + const accounted = /* @__PURE__ */ new Set(); + const groups = order.map((wid) => { + const sessIds = table2[wid]?.sessionIds ?? []; + sessIds.forEach((sid) => accounted.add(sid)); + return { + title: table2[wid]?.title ?? wid, + sessions: sessIds.filter((sid) => !archived.includes(sid) && !subKids.has(sid)).map(mk) + }; + }).filter((g) => g.sessions.length > 0); + const allIds = Array.isArray(snap?.ids) ? snap.ids : []; + const ungrouped = allIds.filter((sid) => !accounted.has(sid) && !archived.includes(sid) && !subKids.has(sid)); + const withUngrouped = ungrouped.length > 0 ? [{ title: "\u672A\u5206\u7EC4", sessions: ungrouped.map(mk) }, ...groups] : groups; + if (withUngrouped.length > 0) return { groups: withUngrouped, current }; + } catch { + } + const ids = Array.isArray(snap?.ids) ? snap.ids : []; + return { groups: [{ title: "", sessions: ids.filter((x) => !subKids.has(x)).map(mk) }], current }; + } catch { + return { groups: [], current: "" }; + } +} +var bindTipEl = null; +function showBindTip(btn) { + const tip = btn.getAttribute("data-tip"); + if (!tip) return; + if (!bindTipEl) { + bindTipEl = document.createElement("div"); + bindTipEl.className = "dsh-wt_bindTip"; + document.body.appendChild(bindTipEl); + } + bindTipEl.textContent = tip; + const r = btn.getBoundingClientRect(); + bindTipEl.style.left = r.right + 8 + "px"; + bindTipEl.style.top = r.top + r.height / 2 + "px"; + bindTipEl.style.display = "block"; + const tw = bindTipEl.offsetWidth; + const x = r.right + 8 + tw > window.innerWidth - 8 ? Math.max(8, r.left - 8 - tw) : r.right + 8; + bindTipEl.style.left = x + "px"; +} +function hideBindTip() { + if (bindTipEl) bindTipEl.style.display = "none"; +} +async function promptIntoSession(sessionId, text2) { + const b = sessionBridge; + if (!b) throw new Error("bridge unavailable"); + const sessions = b.sessions; + let session = null; + for (let i = 0; i < 10; i++) { + try { + session = sessions?.binding?.(sessionId)?.session ?? null; + } catch { + session = null; + } + if (session) break; + await new Promise((r) => setTimeout(r, 200)); + } + if (session) { + if (typeof b.conversation?.sendSession === "function") { + try { + await b.conversation.sendSession(session, text2, [], "queue"); + return; + } catch { + } + } + if (typeof session.prompt === "function") { + const result = await session.prompt([{ type: "text", text: text2 }], "queue"); + if (result && result.ok) return; + if (result && !result.ok) throw new Error("session.prompt: " + (result.error?.code ?? "rejected") + (result.error?.message ? ": " + result.error.message : "")); + } + } + try { + const scoped = sessions?.scope?.(sessionId); + const conv = scoped?.get?.("conversation"); + if (conv && typeof conv.send === "function") { + await conv.send(text2); + return; + } + } catch { + } + throw new Error("no send path: session face unavailable"); +} +var KNOWLEDGE_PACK = [ + "\u3010\u63D2\u4EF6\u77E5\u8BC6\u5305\xB7\u8BF7\u76F4\u63A5\u91C7\u7528\uFF0C\u4E0D\u8981\u91CD\u65B0\u4FA6\u5BDF\u63D2\u4EF6\u6E90\u7801\u3011", + "- dsh-worktable \u662F\u672C\u673A DeepSeek Harness \u7684\u81EA\u5EFA\u5BB9\u5668\u63D2\u4EF6\uFF08\u4ED3\u5E93 E:\\AI_Workspace\\DeepseekHarness\\Projects\\dsh-worktable\uFF0C\u63D2\u4EF6\u5305\u6839\u76EE\u5F55 01_content/\uFF09\u3002", + "- \u7A97\u53E3\uFF08\u5185\u5BB9\u7A97\uFF09\u6A21\u578B\uFF1A\u6BCF\u4E2A\u7A97 = \u4E00\u4E2A\u6807\u7B7E\u9875\uFF1B\u672A\u6307\u6D3E\u65F6\u663E\u793A\u9009\u62E9\u5668\uFF08\u6D4F\u89C8\u5668/\u52A8\u753B/\u8D44\u6E90\u7BA1\u7406\u5668/\u7EC8\u7AEF/\u2728\u81EA\u5B9A\u4E49\uFF09\uFF1B", + " \u7A97\u5185\u5BB9\u8FD8\u53EF\u653E iframe \u7F51\u9875\u4E0E\u6587\u4EF6\u9884\u89C8\uFF08.md/.txt/.tsx/.css/.html \u7B49\uFF09\u3002", + "- \u7A97\u53E3\u53EF\u88C5\u8F7D\u7684\u5F62\u5F0F\uFF1AHTML \u5355\u6587\u4EF6\uFF08\u4EA4\u4E92 UI\uFF0C\u653E\u9879\u76EE\u6587\u4EF6\u5939\u540E\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u70B9\u51FB\u6E32\u67D3\uFF09\u3001\u7F51\u9875 URL\u3001", + " \u6587\u4EF6\u9884\u89C8\uFF08.md/.txt/.tsx/.css/.html/\u56FE\u7247/.mp4 \u7B49\uFF09\uFF1B\u4EA7\u51FA\u5F62\u5F0F\u6309\u4EFB\u52A1\u7C7B\u578B\u9009\uFF0C\u4E0D\u8981\u4E00\u5F8B HTML\u3002", + '- \u4EA7\u51FA HTML \u5FC5\u987B\u7528\u5DE5\u4F5C\u53F0\u539F\u751F\u76AE\u80A4\uFF1A\u5728\u9875\u9762 \u52A0 \uFF0C', + " \u7EC4\u4EF6\u7C7B\u53C2\u8003 /api/worktable/template/dshell.html\uFF08\u5361\u7247/\u6309\u94AE/\u72B6\u6001\u5FBD\u6807/\u6807\u7B7E\u9875/\u5217\u8868/\u7EDF\u8BA1/\u8FDB\u5EA6/\u8868\u683C\u7B49\uFF09\uFF0C", + " \u754C\u9762\u5373\u53EF\u4E0E DSH \u539F\u751F\u98CE\u683C\u4E00\u81F4\uFF1B\u81EA\u9020\u6837\u5F0F\u63A7\u5236\u5728\u6700\u5C0F\u8303\u56F4\u3002", + "- \u670D\u52A1\u7AEF\u80FD\u529B\uFF1A/api/worktable/fs\uFF08\u5217\u76EE\u5F55\uFF09\u3001/api/worktable/write\uFF08\u5199\u6587\u4EF6\uFF09\u3001/api/worktable/mkdir\uFF08\u5EFA\u76EE\u5F55\uFF09\u3001", + " /api/worktable/git\uFF08git \u72B6\u6001\uFF09\u3001/api/worktable/site\uFF08\u9759\u6001\u6258\u7BA1\uFF09\u3002", + "- \u6539\u5B8C\u63D2\u4EF6\u5728 01_content \u76EE\u5F55\u6267\u884C npm run build\uFF1B\u91CD\u542F dsh web \u6216\u6D4F\u89C8\u5668 F5 \u751F\u6548\u3002", + "- \u6240\u6709\u4EA7\u51FA\u6587\u4EF6\u4E00\u5F8B\u653E\u8FDB\u672C\u4EFB\u52A1\u6807\u6CE8\u7684\u9879\u76EE\u6587\u4EF6\u5939\uFF0C\u4FDD\u6301\u7528\u6237\u76EE\u5F55\u5E72\u51C0\u3002" +].join("\n"); +function buildWindowTaskText(projectId, projectName, windowLabel, requirement, folder, mode) { + const win = windowLabel || "\u4E00\u4E2A\u5185\u5BB9\u7A97"; + const folderLine = folder ? "\u9879\u76EE\u6587\u4EF6\u5939\uFF1A" + folder + "\uFF08\u672C\u9879\u76EE\u6240\u6709\u4EA7\u51FA\u6587\u4EF6\u4E00\u5F8B\u653E\u8FDB\u8FD9\u4E2A\u6587\u4EF6\u5939\uFF1B\u4E0D\u8981\u5199\u5230\u522B\u7684\u9ED8\u8BA4\u4F4D\u7F6E\uFF09\u3002" : "\u672C\u9879\u76EE\u6682\u672A\u8BBE\u7F6E\u4E13\u5C5E\u6587\u4EF6\u5939\uFF1A\u4EA7\u51FA\u6587\u4EF6\u5148\u5411\u7528\u6237\u786E\u8BA4\u5B58\u653E\u4F4D\u7F6E\uFF0C\u4E0D\u8981\u968F\u4FBF\u5199\u3002"; + const lines = [ + "\u3010\u5DE5\u4F5C\u53F0\u81EA\u5B9A\u4E49\u7A97\u53E3\u4EFB\u52A1\u3011", + "\u4EE5\u4E0B\u5185\u5BB9\u7531 dsh-worktable\uFF08\u5DE5\u4F5C\u53F0\uFF09\u63D2\u4EF6" + (mode === "new" ? "\u81EA\u52A8\u53D1\u9001" : "\u53D1\u9001") + "\uFF1A\u7528\u6237\u60F3\u628A\u300C" + projectName + "\u300D\u9879\u76EE\u4E2D\u7684\u300C" + win + "\u300D\u7A97\u53E3\u6253\u9020\u6210\u4ED6\u60F3\u8981\u7684\u5185\u5BB9\u3002", + "1. dsh-worktable \u662F\u4FA7\u8FB9\u680F\u5E95\u90E8\u7684\u81EA\u5EFA\u300C\u5DE5\u4F5C\u53F0\u300D\u63D2\u4EF6\uFF08\u5B98\u65B9\u6587\u6863\u6CA1\u6709\u5B83\u7684\u8BF4\u660E\uFF0C\u4E0D\u4E86\u89E3\u4E4B\u5904\u53EF\u76F4\u63A5\u5411\u7528\u6237\u63D0\u95EE\uFF09\u3002", + "2. \u7528\u6237\u9700\u6C42\uFF1A" + requirement, + "3. " + folderLine, + "4. \u4EA7\u51FA\u5F62\u5F0F\u8BF7\u6309\u4EFB\u52A1\u7C7B\u578B\u9009\u62E9\uFF08\u4E0D\u8981\u4E00\u5F8B\u7528 HTML\uFF09\uFF1A", + " - \u4EA4\u4E92\u5C0F\u5DE5\u5177 / \u770B\u677F / \u8868\u5355 / \u56FE\u8868\uFF08\u5982\u8BA1\u7B97\u5668\u3001\u4E92\u52A8\u6309\u94AE\u3001\u6570\u636E\u770B\u677F\uFF09\u2192 \u5355\u6587\u4EF6 HTML\uFF0C\u653E\u8FDB\u9879\u76EE\u6587\u4EF6\u5939\uFF1B", + " - \u6587\u6863 / \u6F14\u793A\uFF08PPT\u3001\u62A5\u544A\u3001\u8868\u683C\uFF09\u2192 \u751F\u6210\u771F\u5B9E\u6587\u4EF6\uFF08.pptx / .md / .xlsx\uFF09\u653E\u8FDB\u9879\u76EE\u6587\u4EF6\u5939\uFF0C\u7528\u6237\u7528\u672C\u673A\u8F6F\u4EF6\u6253\u5F00\u7F16\u8F91\uFF1B", + " - \u89C6\u9891 / \u52A8\u753B \u2192 \u751F\u6210 .mp4 / .gif\uFF08\u6216 Lottie JSON\uFF09\u6587\u4EF6\u653E\u8FDB\u9879\u76EE\u6587\u4EF6\u5939\uFF1B", + " - \u5DE5\u4F5C\u53F0\u5DF2\u6709\u5185\u7F6E\u7A97\u80FD\u529B\uFF08\u8D44\u6E90\u7BA1\u7406\u5668 / \u7EC8\u7AEF / \u6D4F\u89C8\u5668 / \u52A8\u753B\u7AD9\uFF09\u2192 \u4E0D\u8981\u91CD\u590D\u9020\u8F6E\u5B50\uFF0C\u76F4\u63A5\u5EFA\u8BAE\u7528\u6237\u6539\u7528\u5185\u7F6E\u7A97\u3002", + "5. \u5B8C\u6210\u5185\u5BB9\u540E\uFF0C\u7528\u4E00\u4E24\u53E5\u8BDD\u8BF4\u660E\u7528\u6237\u628A\u5B83\u653E\u8FDB\u7A97\u53E3\u7684\u6B65\u9AA4\u3002\u8BE5\u7A97\u53E3\u4F4D\u4E8E\u300C" + projectName + "\u300D\u9879\u76EE\u5185\uFF0C\u5982\u9700\u8981\u4E5F\u53EF\u534F\u52A9\u8BE5\u9879\u76EE\u540E\u7EED\u7684\u5176\u4ED6\u81EA\u5B9A\u4E49\u5DE5\u4F5C\u3002", + '6. \u5B8C\u6210\u540E\u5199\u5165\u300C\u4EA7\u7269\u6E05\u5355\u300D\u6587\u4EF6\uFF1A\u5728\u9879\u76EE\u6587\u4EF6\u5939\u91CC\u521B\u5EFA widget-result.json\u3002\u6302\u8F7D\u5355\u4E2A\u7A97\u53E3\u65F6\u5199\u5355\u5BF9\u8C61 {"window":"' + win + '","path":"\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84","kind":"html"}\uFF1B\u4E00\u6B21\u6302\u8F7D\u591A\u4E2A\u7A97\u53E3\uFF08\u5982\u7A97\u53E31 + \u7A97\u53E32\uFF09\u65F6\u5199 JSON \u6570\u7EC4\uFF0C\u6BCF\u4E2A\u5143\u7D20\u4E3A\u4E0A\u8FF0\u5355\u5BF9\u8C61\uFF08\u53EF\u5F15\u7528\u591A\u4E2A\u4EA7\u7269\u6587\u4EF6\uFF09\u3002kind \u53EF\u9009 html\uFF08\u672C\u5730\u9875\u9762\uFF0Cpath \u76F8\u5BF9\u9879\u76EE\u6587\u4EF6\u5939\uFF09/ url\uFF08\u5916\u90E8\u94FE\u63A5\uFF0Cpath \u4E3A\u5B8C\u6574 URL\uFF09/ file\uFF08\u5176\u4ED6\u6587\u4EF6\uFF0Cpath \u76F8\u5BF9\u9879\u76EE\u6587\u4EF6\u5939\uFF09\u3002\u5199\u5B8C\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u5DE5\u4F5C\u53F0\u4F1A\u81EA\u52A8\u628A\u4EA7\u7269\u6302\u8F7D\u8FDB\u6E05\u5355\u5BF9\u5E94\u7684\u5404\u4E2A\u7A97\u53E3\u5E76\u9501\u5B9A\u4FDD\u5B58\uFF0C\u7528\u6237\u65E0\u9700\u624B\u52A8\u64CD\u4F5C\uFF1B\u7528\u6237\u4E0B\u6B21\u6253\u5F00\u5DE5\u4F5C\u53F0\u65F6\u5404\u7A97\u53E3\u76F4\u63A5\u663E\u793A\u4EA7\u7269\uFF0C\u4E0D\u4F1A\u4E22\u5931\u6216\u91CD\u7F6E\u3002', + KNOWLEDGE_PACK + ]; + return lines.join("\n"); +} +async function createCustomSession(projectId, projectName, requirement, group, windowLabel = "", folder = null) { + const b = sessionBridge; + if (!b || typeof b.sessions?.create !== "function") throw new Error("sessions unavailable"); + const text2 = buildWindowTaskText(projectId, projectName, windowLabel, requirement, folder, "new"); + let workspaceId = null; + const g = group ?? { kind: "none" }; + if (g.kind === "existing") { + workspaceId = g.workspaceId; + } else if (g.kind === "new") { + const ws = b.workspaces; + if (!ws || typeof ws.create !== "function") throw new Error("workspaces unavailable"); + const parent = g.parent.replace(/[\\/]+$/, ""); + const name = g.name.replace(/^[\\/]+/, "").replace(/[\\/]+$/, ""); + if (!parent || !name) throw new Error("invalid group path"); + const full = parent + "\\" + name; + try { + await ws.createDirectory?.(parent, name); + } catch { + } + try { + const r = await fetch("/api/worktable/mkdir", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: full }) }); + const d = await r.json(); + if (!r.ok || !d?.ok) throw new Error(d?.error ?? "mkdir failed"); + } catch { + } + const view = await ws.create({ path: full }); + workspaceId = view?.workspaceId ?? view?.id ?? null; + if (!workspaceId) throw new Error("workspace create failed"); + } + let createOpts = {}; + if (workspaceId) createOpts = { workspaceId }; + else if (folder) createOpts = { cwd: folder }; + const sessionId = await b.sessions.create(createOpts); + await ensureSessionPreset(sessionId); + await ensureSessionModel(sessionId); + markPluginSessionOpen(sessionId); + try { + await b.sessions.open?.(sessionId); + } catch { + } + await promptIntoSession(sessionId, text2); + return sessionId; +} +async function sendCustomToSession(sessionId, projectId, projectName, requirement, windowLabel = "", folder = null) { + const b = sessionBridge; + if (!b) throw new Error("bridge unavailable"); + const text2 = buildWindowTaskText(projectId, projectName, windowLabel, requirement, folder, "send"); + markPluginSessionOpen(sessionId); + try { + await b.sessions.open?.(sessionId); + } catch { + } + await promptIntoSession(sessionId, text2); +} +var projectAttachRef = { sessionId: null, attached: null }; +var suppressRestoreRef = { current: false }; +var projectBindingsRef = { current: {} }; +var pluginOpenedSessionsRef = { current: /* @__PURE__ */ new Set() }; +function markPluginSessionOpen(sessionId) { + if (sessionId) { + const s = pluginOpenedSessionsRef.current; + if (s.size > 50) s.clear(); + s.add(sessionId); + } +} +var lastSessionScopeId = ""; +var sessionScopeStore = { snapshot: null }; +var sessionsSnapshotStore = { snapshot: null, listeners: /* @__PURE__ */ new Set() }; +function loadNotifyAck() { + try { + const raw = localStorage.getItem("dsh.worktable.notifyAck.v1"); + const p = raw ? JSON.parse(raw) : {}; + return p && typeof p === "object" ? p : {}; + } catch { + return {}; + } +} +function saveNotifyAck(sid, state) { + try { + const ack = loadNotifyAck(); + ack[sid] = state; + localStorage.setItem("dsh.worktable.notifyAck.v1", JSON.stringify(ack)); + } catch { + } +} +var mountConsumedRef = { current: /* @__PURE__ */ new Set() }; +var pendingMountRef = { current: (() => { + try { + return JSON.parse(localStorage.getItem("dsh.worktable.pendingMount.v1") ?? "{}") ?? {}; + } catch { + return {}; + } +})() }; +var mountedWidgetRef = { current: (() => { + try { + return JSON.parse(localStorage.getItem("dsh.worktable.mountedWidget.v1") ?? "{}") ?? {}; + } catch { + return {}; + } +})() }; +function recordMountedWidget(projectId, raw) { + if (!projectId || !raw) return; + mountedWidgetRef.current[projectId] = raw; + try { + localStorage.setItem("dsh.worktable.mountedWidget.v1", JSON.stringify(mountedWidgetRef.current)); + } catch { + } +} +function windowLabelToPane(spec, label) { + const m = /^窗口(\d+)$/.exec(String(label ?? "").trim()); + if (!m) return null; + const n = parseInt(m[1], 10); + if (!Number.isFinite(n) || n < 1) return null; + let idx = n - 1; + if (spec?.left) { + if (idx === 0) return { row: "left", index: 0 }; + idx -= 1; + } + const top = spec?.top ?? []; + if (idx < top.length) return { row: "top", index: idx }; + idx -= top.length; + const main = spec?.main ?? []; + if (idx < main.length) return { row: "main", index: idx }; + return null; +} +function paneExists(spec, row, index) { + if (!spec) return false; + if (row === "left") return !!spec.left && index === 0; + if (row === "top") return !!spec.top && !!spec.top[index]; + return !!spec.main && !!spec.main[index]; +} +function buildMountContent(folder, d) { + const p = String(d?.path ?? "").trim(); + if (!p) return null; + if (d?.kind === "url") return { kind: "iframe", url: p, title: p }; + const full = p.indexOf(":") >= 0 ? p : folder + "\\" + p.replace(/^[\\/]+/, ""); + if (d?.kind === "file") return { kind: "file", path: full }; + const dir = full.replace(/[\\/][^\\/]*$/, ""); + const name = full.split(/[\\/]/).pop() ?? full; + return { kind: "iframe", url: "/api/worktable/site/" + encodeURIComponent(dir) + "/" + encodeURIComponent(name), title: name }; +} +var notifyStateSeenRef = { current: {} }; +function clearNotifyAck(sid) { + try { + const all = loadNotifyAck(); + if (all[sid]) { + delete all[sid]; + localStorage.setItem("dsh.worktable.notifyAck.v1", JSON.stringify(all)); + } + } catch { + } +} +function sessionNotifyState(entry) { + if (!entry) return null; + if (entry.pendingInteraction != null) return "need"; + if (entry.completed === true) return "done"; + return null; +} +function syncSessionScope(list2) { + try { + const snap = list2.getSnapshot(); + const current = snap?.current ?? ""; + const entry = snap?.byId?.[current] ?? snap?.items?.find((it) => it.sessionId === current) ?? null ?? null; + const cat = snap?.subagentsByParent?.[current]; + let subagents = []; + if (Array.isArray(cat)) subagents = cat; + else if (cat && Array.isArray(cat.entries)) subagents = cat.entries; + else if (cat && Array.isArray(cat.items)) subagents = cat.items; + else if (cat && Array.isArray(cat.children)) subagents = cat.children; + sessionScopeStore.snapshot = { + sessionId: current, + cwd: entry?.cwd ?? "", + jobs: snap?.jobsBySession?.[current] ?? [], + subagents + }; + try { + sessionsSnapshotStore.snapshot = snap; + sessionsSnapshotStore.listeners.forEach((l) => { + try { + l(); + } catch { + } + }); + } catch { + } + try { + if (current !== lastSessionScopeId) { + lastSessionScopeId = current; + if (current && splitStore.active && splitStore.spec) { + const attached = projectAttachRef.attached; + if (attached && current !== attached) { + const pluginSwitch = pluginOpenedSessionsRef.current.has(current); + pluginOpenedSessionsRef.current.delete(current); + if (!pluginSwitch) { + suppressRestoreRef.current = true; + splitStore.close(); + } + } + } + } + } catch { + } + } catch { + sessionScopeStore.snapshot = { sessionId: "", cwd: "", jobs: [], subagents: [] }; + } +} +function EyeIcon(props) { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, children: props.closed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1.8 8s2.6-3.1 6.2-3.1S14.2 8 14.2 8s-2.6 3.1-6.2 3.1S1.8 8 1.8 8Z", stroke: "currentColor", strokeWidth: "1.2", strokeLinejoin: "round" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3.6 8h8.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }) + ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1.8 8s2.6-3.1 6.2-3.1S14.2 8 14.2 8s-2.6 3.1-6.2 3.1S1.8 8 1.8 8Z", stroke: "currentColor", strokeWidth: "1.2", strokeLinejoin: "round" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "8", cy: "8", r: "1.7", fill: "currentColor" }) + ] }) }); +} +function RenameInput(props) { + const [val, setVal] = (0, import_react2.useState)(props.initial); + (0, import_react2.useEffect)(() => { + setVal(props.initial); + }, [props.initial]); + const commit = () => { + const v = val; + props.onCommit(v); + if (!v.trim()) setVal(props.initial); + }; + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "input", + { + className: "dsh-wt_manageInput", + value: val, + placeholder: props.placeholder, + onChange: (e) => setVal(e.target.value), + onBlur: commit, + onKeyDown: (e) => { + if (e.key === "Enter") { + commit(); + e.target.blur(); + } + } + } + ); +} +function WorktableSection(props) { + const wide = props.wide !== false; + const renderProjectSlot = typeof props.renderSlot === "function" ? props.renderSlot : null; + const t = (key, params) => { + if (typeof props.t === "function") { + try { + return props.t(key, params); + } catch { + } + } + let s = zh[key] ?? key; + if (params) for (const [k, v] of Object.entries(params)) s = s.replace("{" + k + "}", v); + return s; + }; + const [view, setView] = (0, import_react2.useState)(loadView); + const [notifyTick, setNotifyTick] = (0, import_react2.useState)(0); + const [projects, setProjects] = (0, import_react2.useState)(loadProjects); + const [metas, setMetas] = (0, import_react2.useState)({}); + const [registeredIds, setRegisteredIds] = (0, import_react2.useState)(() => [...registryStore.ids]); + const [addOpen, setAddOpen] = (0, import_react2.useState)(false); + const [viewOptionsOpen, setViewOptionsOpen] = (0, import_react2.useState)(false); + const [wsPreset, setWsPreset] = (0, import_react2.useState)("2h"); + const [wsName, setWsName] = (0, import_react2.useState)(""); + const [wsError, setWsError] = (0, import_react2.useState)(false); + const [wsFolderParent, setWsFolderParent] = (0, import_react2.useState)(""); + const [wsFolderError, setWsFolderError] = (0, import_react2.useState)(false); + const [iconPick, setIconPick] = (0, import_react2.useState)(null); + const [bindPick, setBindPick] = (0, import_react2.useState)(null); + const [bindGroups, setBindGroups] = (0, import_react2.useState)([]); + const [bindListOpen, setBindListOpen] = (0, import_react2.useState)(false); + const [consoleBind, setConsoleBind] = (0, import_react2.useState)(null); + const [consoleGroups, setConsoleGroups] = (0, import_react2.useState)([]); + const [consoleMode, setConsoleMode] = (0, import_react2.useState)("none"); + const [consoleWsId, setConsoleWsId] = (0, import_react2.useState)(""); + const [consoleParent, setConsoleParent] = (0, import_react2.useState)(""); + const [consoleName, setConsoleName] = (0, import_react2.useState)(""); + const [consoleErr, setConsoleErr] = (0, import_react2.useState)(false); + const [consoleBusy, setConsoleBusy] = (0, import_react2.useState)(false); + const [customOpen, setCustomOpen] = (0, import_react2.useState)(false); + const [customLayoutText, setCustomLayoutText] = (0, import_react2.useState)(""); + const [copiedToast, setCopiedToast] = (0, import_react2.useState)(null); + const copyToastTimerRef = (0, import_react2.useRef)(null); + const [requestDelete, setRequestDelete] = (0, import_react2.useState)(null); + const [viewPickFor, setViewPickFor] = (0, import_react2.useState)(null); + const [float, setFloat] = (0, import_react2.useState)( + () => view.dock === "float" && view.floatTop != null ? { top: view.floatTop } : null + ); + const rootRef = (0, import_react2.useRef)(null); + const dragRef = (0, import_react2.useRef)(null); + const dragIdRef = (0, import_react2.useRef)(null); + const [railRect, setRailRect] = (0, import_react2.useState)(null); + const [bottomInset, setBottomInset] = (0, import_react2.useState)(0); + const bottomInsetRef = (0, import_react2.useRef)(0); + const [floatGeo, setFloatGeo] = (0, import_react2.useState)(null); + const [sidebarRight, setSidebarRight] = (0, import_react2.useState)(null); + const [activeSplitId, setActiveSplitId] = (0, import_react2.useState)( + () => splitStore.active && splitStore.spec ? splitStore.spec.id : null + ); + const projectsRef = (0, import_react2.useRef)( + { projects, metas, aliveRegisteredIds: registeredIds } + ); + const actionsRef = (0, import_react2.useRef)(null); + const ackRef = (0, import_react2.useRef)(null); + const viewRef = (0, import_react2.useRef)(view); + viewRef.current = view; + const getConsoleCards = () => { + const pr = projectsRef.current; + const snap = sessionsSnapshotStore.snapshot; + const byId = snap?.byId ?? {}; + const jobsMap = snap?.jobsBySession ?? {}; + const now = Date.now(); + const kidsSetOf = (sid) => { + const set = /* @__PURE__ */ new Set(); + for (const [cid, ce] of Object.entries(byId)) if (ce?.parentId === sid) set.add(cid); + const v = (snap?.subagentsByParent ?? {})[sid]; + const arr = Array.isArray(v) ? v : v?.entries ?? v?.items ?? []; + if (Array.isArray(arr)) arr.forEach((c) => { + const cid = c?.sessionId ?? c?.id; + if (typeof cid === "string") set.add(cid); + }); + return set; + }; + const statusOf = (sid) => { + if (!sid) return "idle"; + const e = byId[sid]; + if (!e) return "idle"; + if (sessionNotifyState(e) === "need") return "need"; + for (const cid of kidsSetOf(sid)) { + if (byId[cid] && sessionNotifyState(byId[cid]) === "need") return "need"; + } + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session?.getSnapshot?.(); + if (Array.isArray(face?.pending) && face.pending.length > 0) return "need"; + } catch { + } + if (e.completed === true) return "done"; + if (e.running === true) return "busy"; + return "idle"; + }; + const runtimeOf = (sid) => { + if (!sid) return null; + const e = byId[sid]; + if (!e || e.running !== true) return null; + let start = null; + const jobs = jobsMap[sid] ?? []; + for (const j of jobs) { + if (j?.status === "running" && typeof j.startedAt === "number" && (start == null || j.startedAt < start)) start = j.startedAt; + } + if (start != null) return Math.max(0, now - start); + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session?.getSnapshot?.(); + const timings = face?.turnTimings; + if (timings instanceof Map) { + for (const t2 of Array.from(timings.values()).reverse()) { + if (t2 && typeof t2.startTime === "number" && t2.endTime == null) return Math.max(0, now - t2.startTime); + } + } else if (timings && typeof timings === "object") { + for (const k of Object.keys(timings).reverse()) { + const t2 = timings[k]; + if (t2 && typeof t2.startTime === "number" && t2.endTime == null) return Math.max(0, now - t2.startTime); + } + } + } catch { + } + return null; + }; + const ackMap = loadNotifyAck(); + const make = (id, name, icon, self2) => { + const sid = pr.projects.bindings[id]; + const status = statusOf(sid); + const glow = !!sid && (status === "done" && ackMap[sid] !== "done" || status === "need" && ackMap[sid] !== "need"); + return { + id, + name, + icon, + status, + runtimeMs: runtimeOf(sid), + kids: sid ? kidsSetOf(sid).size : 0, + preview: sid ? previewCache.get(sid) ?? lastTextOf(sid) : "", + bound: !!sid, + self: self2, + glow + }; + }; + const cards = []; + cards.push(make(CONSOLE_ID, t("console.name"), CONSOLE_ICON, true)); + const ids = [...pr.aliveRegisteredIds, ...pr.projects.layouts.map((l) => l.id)]; + const known = new Set(ids); + const stored = pr.projects.order.filter((id) => known.has(id)); + const ordered = [...stored, ...ids.filter((id) => !stored.includes(id))].filter((id) => id !== CONSOLE_ID); + for (const id of ordered) { + const meta = pr.metas[id]; + const layout = pr.projects.layouts.find((l) => l.id === id); + if (!meta && !layout) continue; + const name = pr.projects.nameOverrides[id] ?? meta?.name ?? layout?.title ?? id; + const icon = meta?.icon ?? layout?.icon ?? "\u{1F9F1}"; + cards.push(make(id, name, icon, false)); + } + return cards; + }; + const openAddPanel = () => { + setAddOpen(true); + setViewOptionsOpen(false); + if (!wsFolderParent) { + const cwd = sessionScopeStore.snapshot?.cwd ?? ""; + if (cwd) setWsFolderParent(cwd); + } + }; + (0, import_react2.useEffect)(() => { + const env = { + getScope: () => { + const s = sessionScopeStore.snapshot; + return s ? { sessionId: s.sessionId, cwd: s.cwd } : null; + }, + getJobs: () => sessionScopeStore.snapshot?.jobs ?? [], + getSubagents: () => sessionScopeStore.snapshot?.subagents ?? [], + custom: { + getProjects: () => { + const p = projectsRef.current; + return [ + ...p.aliveRegisteredIds.map((id) => ({ id, name: p.projects.nameOverrides[id] ?? p.metas[id]?.name ?? id })), + ...p.projects.layouts.map((l) => ({ id: l.id, name: p.projects.nameOverrides[l.id] ?? l.title })) + ]; + }, + currentProjectId: () => splitStore.active && splitStore.spec ? splitStore.spec.id : null, + getSessions: () => fetchSessionGroups(), + getProjectFolder: (id) => projectsRef.current.projects.folders[id] ?? null, + sendToSession: (sessionId, projectId, projectName, requirement, windowLabel) => sendCustomToSession(sessionId, projectId, projectName, requirement, windowLabel, projectsRef.current.projects.folders[projectId] ?? null), + submit: (projectId, projectName, requirement, group, windowLabel) => createCustomSession(projectId, projectName, requirement, group, windowLabel, projectsRef.current.projects.folders[projectId] ?? null), + // 分组(宿主工作区)数据源:读 ctx.workspaces 快照,供新建对话选分组 + getWorkspaces: () => { + try { + const snap = sessionBridge?.workspaces?.list?.getSnapshot?.(); + const items = snap?.items ?? []; + return items.map((w) => ({ + id: w.workspaceId ?? w.id, + title: w.title ?? "", + path: w.path ?? "", + sessionIds: Array.isArray(w.sessionIds) ? w.sessionIds : [] + })); + } catch { + return []; + } + }, + createWorkspace: (path) => sessionBridge?.workspaces?.create?.({ path }), + createWorkspaceDir: (parent, name) => sessionBridge?.workspaces?.createDirectory?.(parent, name), + // 自动绑定规则:当前项目未绑定 → 绑定到刚新建/发送的会话;已绑定 → 不改(返回 'kept') + autoBind: (sessionId) => { + const pid = splitStore.active && splitStore.spec ? splitStore.spec.id : null; + if (!pid || typeof sessionId !== "string" || !sessionId) return "none"; + const already = projectsRef.current.projects.bindings[pid]; + if (already) return "kept"; + persistProjects((prev) => prev.bindings[pid] ? prev : { ...prev, bindings: { ...prev.bindings, [pid]: sessionId } }); + return "auto"; + } + }, + // 控制室:卡片数据订阅 + 打开项目 / 跳绑定对话 + console: { + subscribe: (fn) => { + consoleListeners.add(fn); + return () => { + consoleListeners.delete(fn); + }; + }, + getCards: () => getConsoleCards(), + getTheme: () => viewRef.current.consoleTheme ?? "system", + setTheme: (th) => persistView({ consoleTheme: th }), + onAck: (id) => { + ackRef.current?.(id); + setNotifyTick((t2) => t2 + 1); + notifyConsole(); + }, + refreshPreviews: () => { + if (previewTimer != null) { + window.clearTimeout(previewTimer); + previewTimer = null; + } + sweepPreviews(); + }, + onAdd: () => openAddPanel(), + onOpen: (id) => { + if (id === CONSOLE_ID) return; + const pr = projectsRef.current.projects; + const layout = pr.layouts.find((l) => l.id === id); + const view2 = pr.views[id]; + if (view2 || layout) actionsRef.current?.openSplit(view2 ?? layout); + else { + const bound = pr.bindings[id]; + if (bound) { + try { + sessionBridge?.sessions?.open?.(bound); + } catch { + } + } + } + }, + onJump: (id) => { + const sid = projectsRef.current.projects.bindings[id]; + if (!sid) return; + markPluginSessionOpen(sid); + try { + sessionBridge?.sessions?.open?.(sid); + } catch { + } + } + } + }; + setSplitEnv(env); + try { + window.__dshCustomEnv = env; + } catch { + } + return () => { + setSplitEnv(null); + try { + window.__dshCustomEnv = null; + } catch { + } + }; + }, []); + const floatRef = (0, import_react2.useRef)(null); + const persistView = (patch) => { + setView((prev) => { + const next = { ...prev, ...patch }; + try { + localStorage.setItem(PERSIST_KEY2, JSON.stringify({ ...next, sortMigratedV2: true })); + } catch { + } + return next; + }); + }; + const persistProjects = (patch) => { + setProjects((prev) => { + const next = typeof patch === "function" ? patch(prev) : { ...prev, ...patch }; + try { + localStorage.setItem(PROJECTS_KEY, JSON.stringify(next)); + } catch { + } + return next; + }); + }; + (0, import_react2.useEffect)(() => { + const saved = projects.views[CONSOLE_ID]; + if (!specHasConsoleTab(saved)) { + const spec = buildConsoleSpec((k) => t(k)); + persistProjects((prev) => ({ ...prev, views: { ...prev.views, [CONSOLE_ID]: spec } })); + } + }, [projects.views[CONSOLE_ID]]); + (0, import_react2.useEffect)(() => { + const sync = () => setRegisteredIds([...registryStore.ids]); + registryStore.listeners.add(sync); + return () => { + registryStore.listeners.delete(sync); + }; + }, []); + (0, import_react2.useEffect)(() => splitStore.subscribe(() => { + setActiveSplitId(splitStore.active && splitStore.spec ? splitStore.spec.id : null); + if (!splitStore.active) { + if (!suppressRestoreRef.current) { + const prev = projectAttachRef.sessionId; + if (prev) { + try { + sessionBridge?.sessions?.open?.(prev); + } catch { + } + } + } + projectAttachRef.sessionId = null; + projectAttachRef.attached = null; + } + suppressRestoreRef.current = false; + }), []); + (0, import_react2.useEffect)(() => { + splitStore.onSpecMutated = (spec) => { + persistProjects((prev) => { + if (prev.layouts.some((l) => l.id === spec.id)) { + return { ...prev, layouts: prev.layouts.map((l) => l.id === spec.id ? spec : l) }; + } + return { ...prev, views: { ...prev.views, [spec.id]: spec } }; + }); + }; + return () => { + splitStore.onSpecMutated = null; + }; + }, []); + (0, import_react2.useEffect)(() => { + setSplitT((k, p) => t(k, p)); + return () => setSplitT(null); + }, [t]); + const measureRailRect = (0, import_react2.useCallback)(() => { + const el = rootRef.current; + if (!el) return; + const r = el.getBoundingClientRect(); + if (r.width > 0) { + setRailRect((prev) => prev && Math.abs(prev.left - r.left) < 1 && Math.abs(prev.width - r.width) < 1 ? prev : { left: r.left, width: r.width }); + } + }, []); + (0, import_react2.useLayoutEffect)(() => { + if (!wide) { + const t1 = window.setTimeout(measureRailRect, 320); + const t2 = window.setTimeout(measureRailRect, 750); + return () => { + window.clearTimeout(t1); + window.clearTimeout(t2); + }; + } + }, [wide, measureRailRect]); + const measureFloatGeo = (0, import_react2.useCallback)(() => { + const sidebar = findSidebar(rootRef.current); + if (!sidebar) { + setFloatGeo({ left: 14, width: null }); + return; + } + const rect = sidebar.getBoundingClientRect(); + const cs = getComputedStyle(sidebar); + const padLeft = parseFloat(cs.paddingLeft) || 0; + const padRight = parseFloat(cs.paddingRight) || 0; + const margin = 20; + const width = rect.width - padLeft - padRight - margin * 2; + setSidebarRight(Math.round(rect.right)); + if (width > 0) { + setFloatGeo({ left: Math.round(rect.left + padLeft + margin), width: Math.round(width) }); + } else { + setFloatGeo({ left: 14, width: null }); + } + }, []); + (0, import_react2.useLayoutEffect)(() => { + measureFloatGeo(); + const sidebar = findSidebar(rootRef.current); + if (!sidebar) return; + const ro = new ResizeObserver(() => measureFloatGeo()); + ro.observe(sidebar); + return () => ro.disconnect(); + }, [measureFloatGeo]); + (0, import_react2.useEffect)(() => { + const onResize = () => { + setFloat(null); + persistView({ dock: "footer" }); + }; + window.addEventListener("resize", onResize); + return () => window.removeEventListener("resize", onResize); + }, []); + const reportMeta = (0, import_react2.useCallback)((meta) => { + if (!meta || typeof meta.id !== "string" || !meta.id) return; + setMetas((prev) => { + const cur = prev[meta.id]; + if (cur && cur.name === meta.name && cur.icon === meta.icon) return prev; + return { ...prev, [meta.id]: { id: meta.id, name: typeof meta.name === "string" ? meta.name : meta.id, icon: meta.icon } }; + }); + }, []); + const engineIdsRef = (0, import_react2.useRef)(/* @__PURE__ */ new Set()); + const lastLegacyBumpRef = (0, import_react2.useRef)({}); + const reportUsed = (0, import_react2.useCallback)((id) => { + if (typeof id !== "string" || !id) return; + const now = Date.now(); + const bump = () => { + persistProjects((prev) => { + if (prev.lastUsed[id] === now) return prev; + return { ...prev, lastUsed: { ...prev.lastUsed, [id]: now } }; + }); + }; + const engineOpen = splitStore.active && splitStore.spec?.id === id; + const knownEngine = engineIdsRef.current.has(id); + if (engineOpen) { + bump(); + } else if (knownEngine) { + return; + } else { + if (now - (lastLegacyBumpRef.current[id] ?? 0) > LEGACY_BUMP_COOLDOWN) { + lastLegacyBumpRef.current[id] = now; + bump(); + } + } + }, []); + function boundSessionTitle(sid) { + try { + const snap = sessionBridge?.list?.getSnapshot?.(); + const e = snap?.byId?.[sid]; + if (e) return e.displayTitle ?? e.title ?? sid; + } catch { + } + return sid; + } + function bindInfoOf(groups, sid) { + for (const g of groups) { + const s = g.sessions.find((x) => x.id === sid); + if (s) return { folder: g.title || "\u672A\u5206\u7EC4", title: s.title }; + } + return { folder: "", title: sid }; + } + function buildCustomLayoutPrompt(req) { + return [ + "\u3010\u4E3A dsh-worktable\uFF08\u5DE5\u4F5C\u53F0\uFF09\u63D2\u4EF6\u589E\u52A0\u4E00\u4E2A\u65B0\u7684\u5E03\u5C40\u9884\u8BBE\u3011", + "", + "\u80CC\u666F\uFF1Adsh-worktable \u662F DeepSeek Harness \u7684\u81EA\u5EFA\u5BB9\u5668\u63D2\u4EF6\uFF08\u672C\u673A\u4ED3\u5E93 dsh-worktable\uFF0C\u63D2\u4EF6\u5305\u6839\u76EE\u5F55 01_content/\uFF09\u3002", + "\u4FA7\u8FB9\u680F\u300C\u5DE5\u4F5C\u53F0\u300D\u533A\u5757\u7BA1\u7406\u9879\u76EE\uFF0C\u6BCF\u4E2A\u9879\u76EE\u6253\u5F00\u540E\u662F\u4E00\u4E2A\u5E73\u94FA\u5DE5\u4F5C\u533A\uFF08\u82E5\u5E72\u5185\u5BB9\u7A97 + \u53F3\u4FA7\u5BF9\u8BDD\u7A97\uFF09\u3002", + "\u5E03\u5C40\u9884\u8BBE\u5B9A\u4E49\u5728 01_content/src/client/index.tsx \u7684 PRESET_DEFS \u6570\u7EC4\uFF0C\u9009\u62E9\u5668\u7F29\u7565\u56FE\u5728 presetThumb() \u51FD\u6570\u3002", + "", + "\u4EFB\u52A1\uFF1A\u6309\u4E0B\u65B9\u300C\u7528\u6237\u9700\u6C42\u300D\u65B0\u589E\u4E00\u4E2A\u5E03\u5C40\u9884\u8BBE\u3002", + "", + "\u89C4\u5219\uFF08\u5FC5\u987B\u9075\u5B88\uFF09\uFF1A", + "1. \u65B0\u9884\u8BBE\u8FFD\u52A0\u5230 PRESET_DEFS \u6570\u7EC4\u672B\u5C3E\uFF1B\u9884\u8BBE\u9009\u62E9\u5668\u6309\u6570\u7EC4\u987A\u5E8F\u663E\u793A\uFF0C\u672B\u5C3E\u7684\u300C\uFF0B\u300D\u81EA\u5B9A\u4E49\u78C1\u8D34\u6C38\u8FDC\u662F\u6700\u540E\u4E00\u4E2A\uFF0C\u65B0\u9884\u8BBE\u81EA\u52A8\u51FA\u73B0\u5728\u5B83\u524D\u9762\u3002", + "2. \u9884\u8BBE\u5B57\u6BB5\uFF1Aid\uFF08kebab-case \u552F\u4E00\uFF09\uFF1BleftCount = \u5DE6\u4FA7\u6574\u5217\u5185\u5BB9\u7A97\u6570\uFF080/1\uFF09\uFF1BtopCount = \u9876\u90E8\u901A\u680F\u884C\u7A97\u6570\uFF1BcontentCount = \u4E3B\u884C\u7A97\u6570\uFF1BchatFull = \u5BF9\u8BDD\u7A97\u662F\u5426\u901A\u9AD8\u6574\u5217\uFF08true/false\uFF09\uFF1B\u53EF\u9009 topHeightDefault = \u9876\u884C\u56FA\u5B9A\u9ED8\u8BA4\u9AD8\uFF08px\uFF09\uFF1B\u53EF\u9009 topHeightRatio = \u9996\u6B21\u6253\u5F00\u65F6\u9876\u884C\u9AD8\u5EA6\u5360\u53EF\u7528\u9AD8\u5EA6\u6BD4\u4F8B\uFF080~1\uFF0C0.5 = \u4E0A\u4E0B\u7B49\u5206\uFF1B\u7F3A\u7701 0.35\uFF09\u3002", + "3. \u786C\u7EA6\u675F\uFF1A\u5BF9\u8BDD\u7A97\u6052\u5728\u53F3\u4FA7\uFF08chatSide \u56FA\u5B9A right\uFF09\uFF1B\u804A\u5929 \u21C4 \u7FFB\u8F6C\u8D34\u5DE6\u7531\u5F15\u64CE\u81EA\u5E26\uFF0C\u4E0D\u8981\u6539\u3002", + "4. \u60F3\u8981\u300C\u4E0A\u4E0B\u7B49\u5927\u300D\u7684\u7F51\u683C\u5C31\u7528 topHeightRatio: 0.5\uFF1B\u6BCF\u884C\u5185\u7684\u7A97\u683C\u5BBD\u5EA6\u7531\u5F15\u64CE\u6309\u53EF\u7528\u5BBD\u5EA6\u81EA\u52A8\u5747\u5206\uFF0C\u65E0\u9700\u914D\u7F6E\u3002", + "5. \u7A97\u683C\u6700\u5C0F\u5BBD 200\u3001\u804A\u5929\u7A97\u6700\u5C0F\u5BBD 240\uFF0C\u5F15\u64CE\u6709\u94B3\u5236\uFF0C\u65E0\u9700\u914D\u7F6E\u3002", + "6. \u5728 presetThumb(defId) \u91CC\u4E3A\u65B0 id \u589E\u52A0\u4E00\u4E2A\u7F29\u7565\u56FE\u5206\u652F\uFF08\u7528 dsh-wt_thumb / dsh-wt_thumbCol / dsh-wt_thumbRow / cell()\uFF1B\u804A\u5929\u7A97\u7528 cell(true) \u7684\u84DD\u8272 \u{1F4AC} \u683C\uFF09\u3002", + "7. \u73B0\u6709\u9884\u8BBE\u7684\u987A\u5E8F\u4E0E\u5185\u5BB9\u4E0D\u8981\u6539\u52A8\uFF1A2h / 3h / l2 / grid / t3 / l13 / g4 / l23\u3002", + "8. \u6539\u5B8C\u5728 01_content \u76EE\u5F55\u6267\u884C npm run build \u91CD\u65B0\u6253\u5305\uFF0C\u6D4F\u89C8\u5668 F5 \u5373\u751F\u6548\u3002", + "9. \u9700\u6C42\u82E5\u8D85\u51FA\u4EE5\u4E0A\u5B57\u6BB5\u7684\u8868\u8FBE\u80FD\u529B\uFF08\u4F8B\u5982\u4E09\u884C\u3001\u5D4C\u5957\u5206\u680F\uFF09\uFF0C\u6309\u73B0\u6709\u5F15\u64CE\u6A21\u578B\u505A\u6700\u63A5\u8FD1\u7684\u5B9E\u73B0\uFF0C\u5E76\u5728\u56DE\u590D\u91CC\u8BF4\u660E\u53D6\u820D\u3002", + "", + "\u7528\u6237\u9700\u6C42\uFF1A", + req + ].join("\n"); + } + const openSplit = (0, import_react2.useCallback)((spec) => { + engineIdsRef.current.add(spec.id); + splitStore.open(projects.views[spec.id] ?? spec); + if (splitStore.active && splitStore.spec?.id === spec.id) { + let prev = null; + try { + prev = sessionBridge?.list?.getSnapshot?.()?.current ?? null; + } catch { + } + projectAttachRef.sessionId = prev; + projectAttachRef.attached = projectsRef.current.projects.bindings[spec.id] ?? prev; + const bound = projectsRef.current.projects.bindings[spec.id]; + if (bound) { + try { + sessionBridge?.sessions?.open?.(bound); + } catch { + } + } + ackProjectNotify(spec.id); + const pending = pendingMountRef.current[spec.id]; + if (pending) { + try { + const entries = Array.isArray(pending.entries) ? pending.entries : pending.content ? [{ content: pending.content, row: pending.row, index: pending.index ?? 0 }] : []; + let allOk = entries.length > 0; + for (const e of entries) { + splitStore.lockPane(e.row, e.index ?? 0, e.content); + if (!paneExists(splitStore.spec, e.row, e.index ?? 0)) allOk = false; + } + if (allOk && pending.fingerprint) recordMountedWidget(spec.id, pending.fingerprint); + } catch { + } + delete pendingMountRef.current[spec.id]; + try { + localStorage.setItem("dsh.worktable.pendingMount.v1", JSON.stringify(pendingMountRef.current)); + } catch { + } + } + } + }, [projects.views]); + const openConsole = (0, import_react2.useCallback)((explicitBound) => { + const saved = projects.views[CONSOLE_ID]; + const broken = !specHasConsoleTab(saved); + const spec = broken ? buildConsoleSpec((k) => t(k)) : saved; + if (broken) persistProjects((prev) => ({ ...prev, views: { ...prev.views, [CONSOLE_ID]: spec } })); + engineIdsRef.current.add(CONSOLE_ID); + splitStore.open(spec); + if (splitStore.active && splitStore.spec?.id === CONSOLE_ID) { + let prev = null; + try { + prev = sessionBridge?.list?.getSnapshot?.()?.current ?? null; + } catch { + } + projectAttachRef.sessionId = prev; + const bound = explicitBound !== void 0 ? explicitBound : projectsRef.current.projects.bindings[CONSOLE_ID]; + projectAttachRef.attached = bound ?? prev; + if (bound) { + try { + sessionBridge?.sessions?.open?.(bound); + } catch { + } + } + ackProjectNotify(CONSOLE_ID); + try { + notifyConsole(); + } catch { + } + try { + sweepPreviews(); + } catch { + } + } + }, [projects.views, t]); + const clickConsoleCard = (anchor) => { + if (projectsRef.current.projects.bindings[CONSOLE_ID]) { + openConsole(); + return; + } + const r = anchor.getBoundingClientRect(); + setConsoleBind({ + x: clamp2(Math.round(r.right + 8), 8, window.innerWidth - 640), + y: clamp2(Math.round(r.top), 8, window.innerHeight - 460) + }); + setConsoleGroups([]); + fetchSessionGroups().then((res) => setConsoleGroups(res.groups)).catch(() => setConsoleGroups([])); + }; + const bindConsoleExisting = (sid) => { + persistProjects((prev) => ({ ...prev, bindings: { ...prev.bindings, [CONSOLE_ID]: sid } })); + setConsoleBind(null); + openConsole(sid); + }; + const bindConsoleNew = async () => { + const b = sessionBridge; + if (!b || typeof b.sessions?.create !== "function") { + setConsoleErr(true); + return; + } + if (consoleMode === "new" && (!consoleParent.trim() || !consoleName.trim())) { + setConsoleErr(true); + return; + } + setConsoleBusy(true); + setConsoleErr(false); + try { + let workspaceId = null; + if (consoleMode === "existing" && consoleWsId) workspaceId = consoleWsId; + else if (consoleMode === "new") { + const ws = b.workspaces; + const parent = consoleParent.replace(/[\\/]+$/, ""); + const name = consoleName.replace(/^[\\/]+/, "").replace(/[\\/]+$/, ""); + const full = parent + "\\" + name; + try { + await ws?.createDirectory?.(parent, name); + } catch { + } + try { + const r = await fetch("/api/worktable/mkdir", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ parent, name }) }); + const d = await r.json(); + if (!r.ok || !d?.ok) throw new Error(d?.error ?? "mkdir failed"); + } catch { + } + const view2 = await ws.create({ path: full }); + workspaceId = view2?.workspaceId ?? view2?.id ?? null; + if (!workspaceId) throw new Error("workspace create failed"); + } + const folder = projectsRef.current.projects.folders[CONSOLE_ID] ?? null; + let createOpts = {}; + if (workspaceId) createOpts = { workspaceId }; + else if (folder) createOpts = { cwd: folder }; + const sessionId = await b.sessions.create(createOpts); + await ensureSessionPreset(sessionId); + await ensureSessionModel(sessionId); + markPluginSessionOpen(sessionId); + persistProjects((prev) => ({ ...prev, bindings: { ...prev.bindings, [CONSOLE_ID]: sessionId } })); + setConsoleBind(null); + openConsole(sessionId); + } catch { + setConsoleErr(true); + } finally { + setConsoleBusy(false); + } + }; + actionsRef.current = { openSplit, openConsole }; + const openBindPick = (0, import_react2.useCallback)((id, anchor) => { + const r = anchor.getBoundingClientRect(); + const x = clamp2(Math.round(r.right + 8), 8, window.innerWidth - 300); + const y = clamp2(Math.round(r.top), 8, window.innerHeight - 420); + setBindPick({ id, x, y }); + setBindListOpen(false); + setBindGroups([]); + fetchSessionGroups().then((res) => setBindGroups(res.groups)).catch(() => setBindGroups([])); + }, []); + const pickFolder = async (apply2) => { + try { + const ws = sessionBridge?.workspaces; + if (ws && typeof ws.pickDirectory === "function") { + const p = await ws.pickDirectory(); + if (p && typeof p === "string") apply2(p); + } + } catch { + } + }; + const changeBindFolder = () => { + if (!bindPick) return; + pickFolder((p) => { + persistProjects((prev) => ({ ...prev, folders: { ...prev.folders, [bindPick.id]: p } })); + }); + }; + const setProjectBinding = (id, sessionId) => { + persistProjects((prev) => { + const next = { ...prev.bindings }; + if (sessionId) next[id] = sessionId; + else delete next[id]; + return { ...prev, bindings: next }; + }); + setBindListOpen(false); + }; + const copyCustomLayout = async () => { + const text2 = customLayoutText.trim(); + if (!text2) { + setCopiedToast("fail"); + return; + } + const prompt = buildCustomLayoutPrompt(text2); + try { + window.__dshLastPrompt = prompt; + } catch { + } + let ok = false; + try { + await navigator.clipboard.writeText(prompt); + ok = true; + } catch { + } + if (!ok) { + try { + const tmp = document.createElement("textarea"); + tmp.value = prompt; + tmp.style.position = "fixed"; + tmp.style.opacity = "0"; + document.body.appendChild(tmp); + tmp.focus(); + tmp.select(); + ok = document.execCommand("copy"); + tmp.remove(); + } catch { + } + } + setCopiedToast(ok ? "ok" : "fail"); + if (copyToastTimerRef.current != null) window.clearTimeout(copyToastTimerRef.current); + copyToastTimerRef.current = window.setTimeout(() => setCopiedToast(null), 6e3); + }; + (0, import_react2.useEffect)(() => { + const l = () => { + setNotifyTick((t2) => t2 + 1); + notifyConsole(); + if (splitStore.active && splitStore.spec?.id === CONSOLE_ID) schedulePreviewSweep(); + }; + sessionsSnapshotStore.listeners.add(l); + return () => { + sessionsSnapshotStore.listeners.delete(l); + }; + }, []); + (0, import_react2.useEffect)(() => { + notifyConsole(); + }, [projects]); + const applyWidgetManifest = (0, import_react2.useCallback)(async (projectId, rawManifest) => { + const folder = projectsRef.current.projects.folders[projectId]; + if (!folder) return; + try { + let raw = rawManifest; + if (raw == null) { + const r = await fetch("/api/worktable/file?path=" + encodeURIComponent(folder + "\\widget-result.json"), { cache: "no-store" }); + if (!r.ok) return; + raw = (await r.text()).trim(); + } + if (!raw) return; + let d = null; + try { + d = JSON.parse(raw); + } catch { + } + if (!d) return; + const items = Array.isArray(d) ? d : [d]; + const open = splitStore.active && splitStore.spec?.id === projectId; + const saved = open ? splitStore.spec : projectsRef.current.projects.views[projectId] ?? projectsRef.current.projects.layouts.find((l) => l.id === projectId); + const targets = []; + for (const it of items) { + if (!it) continue; + const content = buildMountContent(folder, it); + if (!content) continue; + const pane = windowLabelToPane(saved, it.window); + const row = pane?.row ?? "main"; + const index = pane?.index ?? 0; + if (targets.some((t2) => t2.row === row && t2.index === index)) continue; + targets.push({ row, index, content }); + } + if (!targets.length) return; + if (open) { + let allOk = true; + for (const t2 of targets) { + splitStore.lockPane(t2.row, t2.index, t2.content); + if (!paneExists(splitStore.spec, t2.row, t2.index)) allOk = false; + } + if (allOk) recordMountedWidget(projectId, raw); + } else { + pendingMountRef.current[projectId] = { entries: targets, fingerprint: raw }; + try { + localStorage.setItem("dsh.worktable.pendingMount.v1", JSON.stringify(pendingMountRef.current)); + } catch { + } + } + } catch { + } + }, []); + const tryAutoMount = (0, import_react2.useCallback)(async (projectId, sid) => { + void sid; + await applyWidgetManifest(projectId, null); + }, [applyWidgetManifest]); + (0, import_react2.useEffect)(() => { + const byId = sessionsSnapshotStore.snapshot?.byId ?? {}; + for (const [pid, sid] of Object.entries(projects.bindings)) { + const e = byId[sid]; + if (!e) continue; + if (e.completed === true) { + if (!mountConsumedRef.current.has(sid)) { + mountConsumedRef.current.add(sid); + tryAutoMount(pid, sid); + } + } else { + mountConsumedRef.current.delete(sid); + } + } + }, [notifyTick, projects.bindings, tryAutoMount]); + (0, import_react2.useEffect)(() => { + let cancelled = false; + const folders = projects.folders ?? {}; + (async () => { + for (const pid of Object.keys(folders)) { + if (cancelled) return; + const folder = folders[pid]; + if (!folder) continue; + try { + const r = await fetch("/api/worktable/file?path=" + encodeURIComponent(folder + "\\widget-result.json"), { cache: "no-store" }); + if (!r.ok) continue; + const raw = (await r.text()).trim(); + if (!raw) continue; + if (mountedWidgetRef.current[pid] === raw) continue; + await applyWidgetManifest(pid, raw); + } catch { + } + } + })(); + return () => { + cancelled = true; + }; + }, [projects.folders, applyWidgetManifest]); + const collectKids = (0, import_react2.useCallback)((sid) => { + const kids = /* @__PURE__ */ new Set(); + const snap = sessionsSnapshotStore.snapshot; + const byId = snap?.byId ?? {}; + for (const [cid, ce] of Object.entries(byId)) { + if (ce?.parentId === sid) kids.add(cid); + } + const subMap = snap?.subagentsByParent ?? {}; + const v = subMap[sid]; + const arr = Array.isArray(v) ? v : v?.entries ?? v?.items ?? []; + if (Array.isArray(arr)) arr.forEach((c) => { + const cid = c?.sessionId ?? c?.id; + if (typeof cid === "string") kids.add(cid); + }); + return kids; + }, []); + const bindNotifyMap = (0, import_react2.useMemo)(() => { + const map2 = {}; + const byId = sessionsSnapshotStore.snapshot?.byId ?? {}; + const ack = loadNotifyAck(); + const seen = notifyStateSeenRef.current; + for (const [pid, sid] of Object.entries(projects.bindings)) { + const e = byId[sid]; + if (!e) continue; + let needNow = sessionNotifyState(e) === "need"; + if (!needNow) { + for (const cid of collectKids(sid)) { + const ce = byId[cid]; + if (ce && sessionNotifyState(ce) === "need") { + needNow = true; + break; + } + } + } + if (!needNow) { + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session?.getSnapshot?.(); + if (Array.isArray(face?.pending) && face.pending.length > 0) needNow = true; + } catch { + } + } + if (needNow !== seen[sid]) { + if (seen[sid] !== void 0) clearNotifyAck(sid); + seen[sid] = needNow; + } + if (needNow) { + if (ack[sid] !== "need") map2[pid] = "need"; + continue; + } + if (sessionNotifyState(e) === "done" && ack[sid] !== "done") { + map2[pid] = "done"; + continue; + } + if (e.running === true) map2[pid] = "busy"; + } + return map2; + }, [projects.bindings, notifyTick, collectKids]); + const ackProjectNotify = (projectId) => { + const sid = projectsRef.current.projects.bindings[projectId]; + if (!sid) return; + const byId = sessionsSnapshotStore.snapshot?.byId ?? {}; + let needNow = sessionNotifyState(byId[sid]) === "need"; + for (const cid of collectKids(sid)) { + if (sessionNotifyState(byId[cid]) === "need") { + needNow = true; + saveNotifyAck(cid, "need"); + } + } + if (!needNow) { + try { + const face = sessionBridge?.sessions?.binding?.(sid)?.session?.getSnapshot?.(); + if (Array.isArray(face?.pending) && face.pending.length > 0) needNow = true; + } catch { + } + } + if (needNow) saveNotifyAck(sid, "need"); + else { + const st = sessionNotifyState(byId[sid]); + if (st === "done") saveNotifyAck(sid, "done"); + } + }; + ackRef.current = ackProjectNotify; + const layoutIds = (0, import_react2.useMemo)(() => projects.layouts.map((l) => l.id), [projects.layouts]); + const aliveRegisteredIds = (0, import_react2.useMemo)( + () => registeredIds.filter((id) => !projects.removed.includes(id)), + [registeredIds, projects.removed] + ); + projectsRef.current = { projects, metas, aliveRegisteredIds }; + projectBindingsRef.current = projects.bindings; + const allIds = (0, import_react2.useMemo)(() => [...aliveRegisteredIds, ...layoutIds], [aliveRegisteredIds, layoutIds]); + const effectiveOrder = (0, import_react2.useMemo)(() => { + const known = new Set(allIds); + const stored = projects.order.filter((id) => known.has(id)); + const rest = allIds.filter((id) => !stored.includes(id)); + let list2 = [...stored, ...rest]; + if (view.orderBy === "recent") { + const hot = list2.filter((id) => projects.lastUsed[id] != null); + const cold = list2.filter((id) => projects.lastUsed[id] == null); + hot.sort((a, b) => (projects.lastUsed[b] ?? 0) - (projects.lastUsed[a] ?? 0)); + list2 = [...hot, ...cold]; + } + return list2; + }, [allIds, projects.order, projects.lastUsed, view.orderBy]); + const ownerProps = { + query: view.query.trim(), + wide, + managing: viewOptionsOpen, + order: effectiveOrder, + hidden: [...projects.hidden, ...projects.removed], + nameOverrides: projects.nameOverrides, + iconOverrides: projects.iconOverrides, + reportMeta, + reportUsed, + openSplit, + activeSplitId + }; + const onHandlePointerDown = (e) => { + const root = rootRef.current; + if (!root) return; + const startRect = root.getBoundingClientRect(); + dragRef.current = { startY: e.clientY, startX: e.clientX, startRect, dragging: false, prevFloat: float }; + try { + e.currentTarget.setPointerCapture(e.pointerId); + } catch { + } + setViewOptionsOpen(false); + setAddOpen(false); + }; + const onHandlePointerMove = (e) => { + const d = dragRef.current; + if (!d) return; + const dy = e.clientY - d.startY; + if (!d.dragging && Math.abs(dy) < 6) return; + d.dragging = true; + const maxTop = Math.max(MIN_TOP, window.innerHeight - d.startRect.height - 12); + setFloat({ top: clamp2(d.startRect.top + dy, MIN_TOP, maxTop) }); + }; + const onHandlePointerUp = (e) => { + const d = dragRef.current; + dragRef.current = null; + if (!d || !d.dragging) return; + const maxTop = Math.max(MIN_TOP, window.innerHeight - d.startRect.height - 12); + const rawTop = d.startRect.top + (e.clientY - d.startY); + const outOfRange = rawTop > maxTop + OVER_BOTTOM_PX || rawTop < MIN_TOP - OVER_TOP_PX || e.clientX < d.startRect.left - OVER_SIDE_PX || e.clientX > d.startRect.right + OVER_SIDE_PX; + if (outOfRange) { + setFloat(d.prevFloat); + return; + } + setFloat((cur) => { + if (!cur) return null; + if (Math.abs(cur.top - d.startRect.top) < SNAP_PX) { + persistView({ dock: "footer", floatTop: null }); + return null; + } + persistView({ dock: "float", floatTop: cur.top }); + return cur; + }); + }; + const resetDock = () => { + setFloat(null); + persistView({ dock: "footer", floatTop: null }); + }; + const onSearchKeyDown = (e) => { + if (e.key === "Escape") { + persistView({ searchOpen: false, query: "" }); + } + }; + const moveTo = (id, targetId) => { + if (id === targetId) return; + const list2 = [...effectiveOrder]; + const from = list2.indexOf(id); + const to = list2.indexOf(targetId); + if (from < 0 || to < 0) return; + list2.splice(from, 1); + list2.splice(to, 0, id); + persistProjects({ order: list2 }); + }; + const toggleHidden = (id) => { + persistProjects((prev) => { + const hidden = prev.hidden.includes(id) ? prev.hidden.filter((x) => x !== id) : [...prev.hidden, id]; + return { ...prev, hidden }; + }); + }; + const renameProject = (id, name) => { + persistProjects((prev) => { + const next = { ...prev.nameOverrides }; + if (name.trim()) next[id] = name; + else delete next[id]; + return { ...prev, nameOverrides: next }; + }); + }; + const removeShortcut = (id) => { + persistProjects((prev) => ({ ...prev, shortcuts: prev.shortcuts.filter((s) => s.id !== id) })); + }; + const saveLayout = async () => { + const name = wsName.trim(); + if (!name) { + setWsError(true); + return; + } + const folderPath = wsFolderParent.trim(); + if (!folderPath) { + setWsFolderError(true); + return; + } + try { + await fetch("/api/worktable/mkdir", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: folderPath }) }); + } catch { + } + const layout = buildLayout(wsPreset, name); + persistProjects((prev) => ({ ...prev, layouts: [...prev.layouts, layout], folders: { ...prev.folders, [layout.id]: folderPath } })); + setWsName(""); + setWsFolderParent(""); + setWsError(false); + setWsFolderError(false); + setAddOpen(false); + openSplit(layout); + reportUsed(layout.id); + }; + const removeLayout = (id) => { + persistProjects((prev) => ({ ...prev, layouts: prev.layouts.filter((l) => l.id !== id) })); + }; + const applyLayoutChange = (id, presetId) => { + const layout = projects.layouts.find((l) => l.id === id); + const meta = metas[id]; + const current = layout ?? projects.views[id]; + const sources = current ? [...current.top ?? [], ...current.main].map((pp) => pp.tabs ?? []).filter((tabs) => tabs.length > 0) : []; + const next = buildLayout(presetId, layout ? layout.title : meta?.name ?? id); + next.id = id; + next.icon = layout ? layout.icon : projects.iconOverrides[id] ?? meta?.icon; + const targets = [...next.left ? [next.left] : [], ...next.top ?? [], ...next.main]; + let si = 0; + for (const pane of targets) { + if (si < sources.length) { + pane.tabs = sources[si]; + pane.active = 0; + pane.content = null; + si++; + } + } + const overflow = sources.slice(si).flat(); + if (overflow.length > 0 && targets.length > 0) { + const last = targets[targets.length - 1]; + last.tabs = [...last.tabs ?? [], ...overflow]; + last.active = 0; + } + persistProjects((prev) => layout ? { ...prev, layouts: prev.layouts.map((l) => l.id === id ? next : l) } : { ...prev, views: { ...prev.views, [id]: next } }); + const wasOpen = splitStore.active && splitStore.spec?.id === id; + if (wasOpen) { + splitStore.close(); + openSplit(next); + } + setViewPickFor(null); + }; + const presetOf = (l) => { + const leftCount = l.left ? 1 : 0; + const topCount = (l.top ?? []).length; + const contentCount = l.main.length; + const chatFull = l.chatFullHeight === true; + const def = PRESET_DEFS.find( + (d) => d.leftCount === leftCount && d.topCount === topCount && d.contentCount === contentCount && d.chatFull === chatFull + ); + return def ? def.id : "2h"; + }; + const removeProject = (id) => { + if (id === CONSOLE_ID) return; + persistProjects((prev) => { + const next = { + ...prev, + removed: prev.removed.includes(id) ? prev.removed : [...prev.removed, id], + hidden: prev.hidden.filter((x) => x !== id), + order: prev.order.filter((x) => x !== id) + }; + if (next.bindings[id]) { + next.bindings = { ...next.bindings }; + delete next.bindings[id]; + } + if (next.folders[id]) { + next.folders = { ...next.folders }; + delete next.folders[id]; + } + if (next.views[id]) { + next.views = { ...next.views }; + delete next.views[id]; + } + return next; + }); + }; + const askDelete = (kind, id, name) => { + setRequestDelete({ kind, id, name }); + }; + const doDelete = () => { + const r = requestDelete; + if (!r) return; + if (r.kind === "layout") removeLayout(r.id); + else if (r.kind === "shortcut") removeShortcut(r.id); + else removeProject(r.id); + setRequestDelete(null); + }; + const openIconPick = (kind, id, anchor) => { + const r = anchor.getBoundingClientRect(); + const x = Math.min(r.right + 8, Math.max(16, window.innerWidth - 284)); + const y = Math.max(MIN_TOP, Math.min(r.top - 4, window.innerHeight - 316)); + setIconPick({ kind, id, x, y }); + }; + const setLayoutIcon = (id, icon) => { + persistProjects((prev) => ({ + ...prev, + layouts: prev.layouts.map((l) => l.id === id ? { ...l, icon } : l) + })); + }; + const setShortcutIcon = (id, icon) => { + persistProjects((prev) => ({ + ...prev, + shortcuts: prev.shortcuts.map((s) => s.id === id ? { ...s, icon } : s) + })); + }; + const setProjectIcon = (id, icon) => { + persistProjects((prev) => ({ ...prev, iconOverrides: { ...prev.iconOverrides, [id]: icon } })); + }; + (0, import_react2.useEffect)(() => { + const sync = () => { + const box = document.querySelector(".dsh-wt_projects"); + if (!box) return; + const cards = Array.from(box.querySelectorAll("button:not(.dsh-wt_layout)")); + cards.forEach((el, i) => { + const id = aliveRegisteredIds[i]; + if (id) { + el.setAttribute("data-wt-id", id); + let bindBtn = el.querySelector(".dsh-wt_bindBtn"); + if (!bindBtn) { + bindBtn = document.createElement("span"); + bindBtn.className = "dsh-wt_bindBtn"; + bindBtn.setAttribute("role", "button"); + const circles = document.createElement("span"); + circles.className = "dsh-wt_bindCircles"; + circles.setAttribute("aria-hidden", "true"); + bindBtn.appendChild(circles); + el.appendChild(bindBtn); + const cs = getComputedStyle(el); + if (cs.position === "static") el.style.position = "relative"; + } + bindBtn.setAttribute("data-wt-bind", id); + const bound = projects.bindings[id]; + bindBtn.setAttribute("data-bound", bindNotifyMap[id] ?? (bound ? "true" : "false")); + const kids = Array.from(el.children); + const arrow = kids.find((k) => k.tagName === "SPAN" && String(k.textContent ?? "").trim() === "\u203A"); + if (arrow) arrow.classList.add("dsh-wt_resArrow"); + const tip = bound ? t("bind.tipBound", { name: boundSessionTitle(bound) }) + (bindNotifyMap[id] === "busy" ? t("bind.tipBusy") : bindNotifyMap[id] === "done" ? t("bind.tipDone") : bindNotifyMap[id] === "need" ? t("bind.tipNeed") : "") : t("bind.tipUnbound"); + bindBtn.setAttribute("data-tip", tip); + bindBtn.setAttribute("aria-label", tip); + const icon = el.children[0]; + if (icon) { + const ovr = projects.iconOverrides[id]; + if (ovr) icon.setAttribute("data-wt-icon", ovr); + else icon.removeAttribute("data-wt-icon"); + } + if (projects.views[id]) { + el.setAttribute("data-on", activeSplitId === id ? "true" : "false"); + } else if (activeSplitId === id) { + el.setAttribute("data-on", "true"); + } else if (activeSplitId != null) { + el.setAttribute("data-on", "false"); + } + } else { + el.removeAttribute("data-wt-id"); + } + }); + }; + sync(); + const mo = new MutationObserver(sync); + mo.observe(document.body, { childList: true, subtree: true }); + return () => mo.disconnect(); + }, [aliveRegisteredIds, projects.iconOverrides, projects.views, activeSplitId, projects.bindings, bindNotifyMap]); + (0, import_react2.useEffect)(() => { + const onDocClick = (e) => { + const target = e.target; + const card = target && target.closest ? target.closest(".dsh-wt_projects [data-wt-id]") : null; + if (!card) return; + const pid = card.getAttribute("data-wt-id"); + if (!pid) return; + const bindBtn = target && target.closest ? target.closest(".dsh-wt_bindBtn") : null; + if (bindBtn) { + e.stopPropagation(); + e.preventDefault(); + openBindPick(pid, bindBtn); + return; + } + const first = card.children[0]; + if (first && target && first.contains(target)) { + e.stopPropagation(); + e.preventDefault(); + openIconPick("project", pid, first); + return; + } + const view2 = projects.views[pid]; + if (view2) { + e.stopPropagation(); + e.preventDefault(); + openSplit(view2); + reportUsed(pid); + return; + } + const bound = projectsRef.current.projects.bindings[pid]; + if (bound) { + try { + sessionBridge?.sessions?.open?.(bound); + } catch { + } + } + ackProjectNotify(pid); + }; + document.addEventListener("click", onDocClick, true); + return () => document.removeEventListener("click", onDocClick, true); + }, [projects.views, openSplit, reportUsed, openBindPick]); + const query = view.query.trim(); + const queryLower = query.toLowerCase(); + const visibleShortcuts = projects.shortcuts.filter( + (s) => !queryLower || (s.name + " " + s.href).toLowerCase().includes(queryLower) + ); + const visibleLayouts = projects.layouts.filter((l) => { + if (projects.hidden.includes(l.id)) return false; + if (!queryLower) return true; + const paneTitles = [...l.top ?? [], ...l.main].map((p) => p.title).join(" "); + return (l.title + " " + paneTitles).toLowerCase().includes(queryLower); + }); + const isFloat = float != null; + const floatStyle = isFloat ? { + position: "fixed", + top: float.top, + left: floatGeo?.left ?? 14, + ...floatGeo?.width != null ? { width: floatGeo.width } : {}, + zIndex: 70 + } : void 0; + (0, import_react2.useEffect)(() => { + bottomInsetRef.current = bottomInset; + }, [bottomInset]); + (0, import_react2.useEffect)(() => { + floatRef.current = float; + }, [float]); + const measureBottomOverlay = (0, import_react2.useCallback)(() => { + if (isFloat) return; + const root = rootRef.current; + if (!root) return; + const self2 = root.getBoundingClientRect(); + if (self2.width < 10) return; + const naturalBottom = self2.bottom + bottomInsetRef.current; + const loX = self2.left - 8; + const hiX = self2.right + 8; + const regionTop = window.innerHeight - 300; + let needed = 0; + const nodes = document.querySelectorAll("body *"); + for (const el of nodes) { + const r = el.getBoundingClientRect(); + if (r.width < 40 || r.height < 16) continue; + if (r.top < regionTop) continue; + if (r.left > 80) continue; + if (r.right < loX || r.left > hiX) continue; + const cs = getComputedStyle(el); + if (cs.position !== "fixed") continue; + if (cs.visibility === "hidden" || Number(cs.opacity) === 0) continue; + if (r.top >= naturalBottom + 4) continue; + const overlap = Math.min(r.bottom, naturalBottom + 400) - r.top; + if (overlap > 8) { + needed = Math.max(needed, Math.min(naturalBottom - r.top + 8, 340)); + } + } + setBottomInset((prev) => Math.abs(prev - needed) < 2 ? prev : needed); + }, [isFloat]); + (0, import_react2.useEffect)(() => { + if (!isFloat) measureBottomOverlay(); + }, [isFloat, wide, measureBottomOverlay]); + (0, import_react2.useEffect)(() => { + const timer = window.setInterval(() => { + if (!floatRef.current) measureBottomOverlay(); + }, 2e3); + return () => window.clearInterval(timer); + }, [measureBottomOverlay]); + const dockedStyle = !isFloat && bottomInset > 0 ? { marginBottom: bottomInset } : void 0; + const sectionTop = rootRef.current?.getBoundingClientRect().top ?? 100; + const popLeft = sidebarRight != null ? Math.min(sidebarRight + 8, Math.max(16, window.innerWidth - 344)) : 16; + const popTop = clamp2(sectionTop, MIN_TOP, Math.max(MIN_TOP, window.innerHeight - 540)); + const openRailProject = (id) => { + const pr = projectsRef.current.projects; + const layout = pr.layouts.find((l) => l.id === id); + const view2 = pr.views[id]; + if (view2 || layout) openSplit(view2 ?? layout); + else { + const bound = pr.bindings[id]; + if (bound) { + try { + sessionBridge?.sessions?.open?.(bound); + } catch { + } + } + } + }; + if (!wide) { + const railItems = [ + { icon: CONSOLE_ICON, name: t("console.name"), onClick: (e) => clickConsoleCard(e.currentTarget) }, + ...aliveRegisteredIds.map((id) => ({ + icon: projects.iconOverrides[id] ?? metas[id]?.icon ?? "\u{1F4E6}", + name: projects.nameOverrides[id] ?? metas[id]?.name ?? id, + onClick: () => openRailProject(id) + })), + ...projects.shortcuts.map((s) => ({ + icon: s.icon, + name: s.name, + onClick: () => { + try { + window.open(s.href, "_blank", "noopener"); + } catch { + } + } + })), + ...projects.layouts.map((l) => ({ + icon: l.icon ?? "\u{1F9F1}", + name: projects.nameOverrides[l.id] ?? l.title, + onClick: () => openSplit(l) + })) + ]; + const railStyle = isFloat && railRect ? { position: "fixed", top: float.top, left: railRect.left, width: railRect.width, zIndex: 70 } : bottomInset > 0 ? { marginBottom: bottomInset } : void 0; + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: rootRef, className: "dsh-wt_section dsh-wt_rail", style: railStyle, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_divider" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_railBox", children: railItems.length > 0 ? railItems.map((it, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_railBtn", title: it.name, "aria-label": it.name, onClick: it.onClick, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": true, children: it.icon }) }, i)) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_railIcon", children: "\u2261" }) }) + ] }); + } + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: rootRef, className: "dsh-wt_section" + (isFloat ? " dsh-wt_float" : ""), style: isFloat ? floatStyle : dockedStyle, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_divider" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_header", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_handle", + "data-float": isFloat ? "true" : "false", + title: t("handle.title"), + "aria-label": t("handle.aria"), + onPointerDown: onHandlePointerDown, + onPointerMove: onHandlePointerMove, + onPointerUp: onHandlePointerUp, + onPointerCancel: onHandlePointerUp, + onDoubleClick: resetDock, + children: "\u2261" + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_title", + title: t("handle.title"), + onPointerDown: onHandlePointerDown, + onPointerMove: onHandlePointerMove, + onPointerUp: onHandlePointerUp, + onPointerCancel: onHandlePointerUp, + onDoubleClick: resetDock, + children: t("title") + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_actions", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_iconBtn", + "aria-label": t("menu.search"), + title: t("menu.search"), + onClick: () => persistView({ searchOpen: !view.searchOpen, query: view.searchOpen ? "" : view.query }), + children: ICON_SEARCH + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_iconBtn", + "aria-label": t("menu.viewOptions"), + title: t("menu.viewOptions"), + onClick: () => { + setViewOptionsOpen((v) => !v); + setAddOpen(false); + }, + children: ICON_VIEW_OPTIONS + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_iconBtn", + "aria-label": t("menu.add"), + title: t("menu.add"), + onClick: () => { + setAddOpen((v) => !v); + setViewOptionsOpen(false); + if (!wsFolderParent) { + const cwd = sessionScopeStore.snapshot?.cwd ?? ""; + if (cwd) setWsFolderParent(cwd); + } + }, + children: ICON_ADD + } + ) + ] }) + ] }), + view.searchOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_search", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "input", + { + autoFocus: true, + type: "text", + placeholder: t("search.placeholder"), + value: view.query, + onChange: (e) => persistView({ query: e.target.value }), + onKeyDown: onSearchKeyDown + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_searchClear", + "aria-label": t("search.close"), + onClick: () => persistView({ searchOpen: false, query: "" }), + children: "\u2715" + } + ) + ] }), + addOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", onClick: () => setAddOpen(false) }), + addOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_menu dsh-wt_add dsh-wt_pop", style: { position: "fixed", left: popLeft, top: popTop, width: 360, zIndex: 80 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_menuLabel", children: t("add.chooseLayout") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_presets", children: [ + PRESET_DEFS.map((def) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_preset", + "data-on": wsPreset === def.id ? "true" : "false", + onClick: () => { + setWsPreset(def.id); + setWsError(false); + }, + children: presetThumb(def.id) + }, + def.id + )), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_preset dsh-wt_presetAdd", + title: t("customLayout.addTitle"), + onClick: () => { + setAddOpen(false); + setCustomOpen(true); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_presetAddIcon", "aria-hidden": true, children: "\uFF0B" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_presetAddText", children: t("customLayout.add") }) + ] + } + ) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_addForm", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "input", + { + type: "text", + placeholder: t("add.layoutNamePh"), + value: wsName, + onChange: (e) => { + setWsName(e.target.value); + setWsError(false); + } + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_addFolderRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_customLabel", children: t("add.folderParent") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_addFolderPath" + (wsFolderParent ? "" : " dsh-wt_addFolderPathNone"), title: wsFolderParent || "", children: wsFolderParent || t("add.folderNone") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_bindFolderChange", onClick: () => { + pickFolder((p) => { + setWsFolderParent(p); + setWsFolderError(false); + }); + setWsError(false); + }, children: t("add.folderPick") }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_addBtn", onClick: saveLayout, children: t("add.layoutSave") }) + ] }), + wsError && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-wt_addError", children: t("add.layoutInvalid") }), + wsFolderError && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-wt_addError", children: t("add.folderRequired") }) + ] }), + iconPick && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", onClick: () => setIconPick(null) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_iconPop", style: { left: iconPick.x, top: iconPick.y }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_iconPopTitle", children: t("icons.title") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_iconGrid", children: EMOJI_SET.map((em) => { + const cur = iconPick.kind === "layout" ? projects.layouts.find((l) => l.id === iconPick.id)?.icon ?? "\u{1F9F1}" : iconPick.kind === "shortcut" ? projects.shortcuts.find((s) => s.id === iconPick.id)?.icon ?? "\u{1F517}" : projects.iconOverrides[iconPick.id] ?? metas[iconPick.id]?.icon ?? "\u{1F4E6}"; + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_iconCell", + "data-on": cur === em ? "true" : "false", + onClick: () => { + if (iconPick.kind === "layout") setLayoutIcon(iconPick.id, em); + else if (iconPick.kind === "shortcut") setShortcutIcon(iconPick.id, em); + else setProjectIcon(iconPick.id, em); + setIconPick(null); + }, + children: em + }, + em + ); + }) }) + ] }) + ] }), + viewOptionsOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", onClick: () => setViewOptionsOpen(false) }), + viewOptionsOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_manage dsh-wt_pop dsh-wt_settings", style: { position: "fixed", left: popLeft, top: popTop, width: 280, zIndex: 80 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_manageHead", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_manageTitle", children: t("sort.label") }) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_sortRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_sortBtn", + "data-on": view.orderBy === "manual", + onClick: () => persistView({ orderBy: "manual" }), + children: t("sort.manual") + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_sortBtn", + "data-on": view.orderBy === "recent", + onClick: () => persistView({ orderBy: "recent" }), + children: t("sort.recent") + } + ) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_menuSep" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_manageHead", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_manageTitle", children: t("manage.title") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_manageDone", onClick: () => setViewOptionsOpen(false), children: t("manage.done") }) + ] }), + effectiveOrder.map((id) => { + const meta = metas[id]; + const layout = projects.layouts.find((l) => l.id === id); + const display = projects.nameOverrides[id] ?? layout?.title ?? meta?.name ?? id; + const isHidden = projects.hidden.includes(id); + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "div", + { + className: "dsh-wt_manageRow" + (isHidden ? " dsh-wt_manageRowOff" : ""), + draggable: true, + onDragStart: (e) => { + dragIdRef.current = id; + try { + e.dataTransfer.effectAllowed = "move"; + } catch { + } + }, + onDragOver: (e) => { + e.preventDefault(); + const dragId = dragIdRef.current; + if (dragId && dragId !== id) moveTo(dragId, id); + }, + onDrop: (e) => e.preventDefault(), + onDragEnd: () => { + dragIdRef.current = null; + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_manageGrip", "aria-hidden": true, children: "\u2261" }), + layout ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_manageIcon dsh-wt_iconPick", + role: "button", + tabIndex: 0, + title: t("icons.change"), + onClick: (e) => { + e.stopPropagation(); + openIconPick("layout", id, e.currentTarget); + }, + children: layout.icon ?? "\u{1F9F1}" + } + ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_manageIcon dsh-wt_iconPick", + role: "button", + tabIndex: 0, + title: t("icons.change"), + onClick: (e) => { + e.stopPropagation(); + openIconPick("project", id, e.currentTarget); + }, + children: projects.iconOverrides[id] ?? meta?.icon ?? "\u{1F4E6}" + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenameInput, { initial: display, placeholder: t("manage.renamePh"), onCommit: (v) => renameProject(id, v) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_manageBtn", title: isHidden ? t("manage.show") : t("manage.hide"), onClick: () => toggleHidden(id), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EyeIcon, { closed: isHidden }) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_manageBtn", title: t("manage.changeView"), onClick: () => setViewPickFor(id), children: "\u{1F9E9}" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_manageBtn", + title: layout ? t("manage.deleteLayout") : t("manage.deleteProject"), + onClick: () => askDelete(layout ? "layout" : "project", id, display), + children: "\u2715" + } + ) + ] + }, + id + ); + }), + projects.shortcuts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_manageRow dsh-wt_manageRowSc", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_manageGrip", "aria-hidden": true, children: "\u{1F517}" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_manageIcon dsh-wt_iconPick", + role: "button", + tabIndex: 0, + title: t("icons.change"), + onClick: (e) => { + e.stopPropagation(); + openIconPick("shortcut", s.id, e.currentTarget); + }, + children: s.icon + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_manageScName", children: s.name }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_manageBtn", title: t("manage.deleteShortcut"), onClick: () => askDelete("shortcut", s.id, s.name), children: "\u2715" }) + ] }, s.id)) + ] }), + viewPickFor && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", style: { zIndex: 81 }, onClick: () => setViewPickFor(null) }), + viewPickFor && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_menu dsh-wt_pop", style: { position: "fixed", left: popLeft, top: popTop, width: 320, zIndex: 82 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_menuLabel", children: t("viewPick.title") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_presets", children: [ + PRESET_DEFS.map((def) => { + const cur = projects.layouts.find((l) => l.id === viewPickFor) ?? projects.views[viewPickFor]; + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "button", + { + type: "button", + className: "dsh-wt_preset", + "data-on": cur && presetOf(cur) === def.id ? "true" : "false", + onClick: () => applyLayoutChange(viewPickFor, def.id), + children: presetThumb(def.id) + }, + def.id + ); + }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_preset dsh-wt_presetAdd", + title: t("customLayout.addTitle"), + onClick: () => { + setViewPickFor(null); + setCustomOpen(true); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_presetAddIcon", "aria-hidden": true, children: "\uFF0B" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_presetAddText", children: t("customLayout.add") }) + ] + } + ) + ] }) + ] }), + bindPick && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", style: { zIndex: 83 }, onClick: () => { + setBindPick(null); + setBindListOpen(false); + } }), + bindPick && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_menu dsh-wt_pop dsh-wt_bindPop", style: { position: "fixed", left: bindPick.x, top: bindPick.y, width: 280, zIndex: 84 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_bindFolderBox", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_bindFolderRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_bindFolderLabel", children: [ + "\u{1F4C1} ", + t("bind.folder") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-wt_bindFolderChange", onClick: changeBindFolder, children: [ + t("bind.folderChange"), + " \u21BB" + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_bindFolderPath" + (projects.folders[bindPick.id] ? "" : " dsh-wt_bindFolderPathNone"), title: projects.folders[bindPick.id] ?? "", children: projects.folders[bindPick.id] ?? t("bind.folderNone") }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_bindFolderBox", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_bindFolderRow", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_bindFolderLabel", children: [ + "\u{1F4AC} ", + t("bind.title") + ] }), + projects.bindings[bindPick.id] && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-wt_bindUnbind", onClick: () => setProjectBinding(bindPick.id, null), children: [ + t("bind.unbind"), + " \u2715" + ] }) + ] }), + (() => { + const sid = projects.bindings[bindPick.id]; + if (!sid) { + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_bindConvRow dsh-wt_bindConvRowNone", title: t("bind.tipUnbound"), onClick: () => setBindListOpen((v) => !v), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_bindNoneText", children: [ + t("bind.unbound"), + " \xB7 ", + t("bind.clickPick") + ] }) }); + } + const info = bindInfoOf(bindGroups, sid); + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-wt_bindConvRow", title: t("bind.tipBound", { name: info.title }), onClick: () => setBindListOpen((v) => !v), children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_bindFolder", title: info.folder, children: [ + "\u{1F4C2} ", + info.folder + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_bindSep", "aria-hidden": true, children: "|" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_bindConvName", title: info.title, children: info.title }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_bindConvChevron", "aria-hidden": true, children: "\u25BE" }) + ] }); + })(), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-wt_bindHint", children: t("bind.hint") }) + ] }) + ] }), + bindPick && bindListOpen && (() => { + const rightFits = bindPick.x + 300 + 260 <= window.innerWidth - 8; + const listLeft = rightFits ? bindPick.x + 300 : Math.max(8, bindPick.x - 268); + return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_menu dsh-wt_pop dsh-wt_bindListPop", style: { position: "fixed", left: listLeft, top: clamp2(bindPick.y, 8, window.innerHeight - 348), width: 260, zIndex: 86 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_selectList dsh-wt_bindList", children: bindGroups.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [ + g.title && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_selectDivider" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_selectGroup", children: [ + "\u{1F4C1} ", + g.title + ] }) + ] }), + g.sessions.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_selectItem" + (projects.bindings[bindPick.id] === s.id ? " dsh-wt_selectItemOn" : ""), + onClick: () => { + setProjectBinding(bindPick.id, s.id); + setBindListOpen(false); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_selectItemTitle", children: s.title }), + s.isCurrent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_selectCurrent", children: t("custom.sessionCurrent") }) + ] + }, + s.id + )) + ] }, g.title || "g" + gi)) }) }); + })(), + consoleBind && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", style: { zIndex: 85 }, onClick: () => setConsoleBind(null) }), + consoleBind && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_menu dsh-wt_pop dsh-wt_consoleBindPop", style: { position: "fixed", left: consoleBind.x, top: consoleBind.y, width: 560, zIndex: 86 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_consoleBindCols", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_consoleBindCol", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_consoleBindLabel", children: [ + "\u2795 ", + t("console.joinExisting") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_selectList dsh-wt_consoleBindList", children: [ + consoleGroups.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [ + g.title && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_selectDivider" }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_selectGroup", children: [ + "\u{1F4C1} ", + g.title + ] }) + ] }), + g.sessions.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_selectItem" + (projects.bindings[CONSOLE_ID] === s.id ? " dsh-wt_selectItemOn" : ""), + onClick: () => bindConsoleExisting(s.id), + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_selectItemTitle", children: s.title }), + s.isCurrent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_selectCurrent", children: t("custom.sessionCurrent") }) + ] + }, + s.id + )) + ] }, g.title || "g" + gi)), + consoleGroups.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_consoleBindEmpty", children: t("console.noSessions") }) + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_consoleBindCol dsh-wt_consoleBindColNew", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_consoleBindLabel", children: [ + "\u2728 ", + t("console.newConv") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { className: "dsh-wt_consoleSelect", value: consoleMode, onChange: (e) => setConsoleMode(e.target.value), children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "none", children: t("console.groupNone") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "existing", children: t("console.groupExisting") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "new", children: t("console.groupNew") }) + ] }), + consoleMode === "existing" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { className: "dsh-wt_consoleSelect", value: consoleWsId, onChange: (e) => setConsoleWsId(e.target.value), children: listWorkspaces().map((w) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: w.id, children: w.title }, w.id)) }), + consoleMode === "new" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "dsh-wt_consoleInput", placeholder: t("console.newParentPh"), value: consoleParent, onChange: (e) => setConsoleParent(e.target.value) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "dsh-wt_consoleInput", placeholder: t("console.newNamePh"), value: consoleName, onChange: (e) => setConsoleName(e.target.value) }) + ] }), + consoleErr && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-wt_consoleErr", children: t("console.bindFail") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_consoleCreateBtn", disabled: consoleBusy, onClick: bindConsoleNew, children: consoleBusy ? "\u2026" : t("console.createBind") }) + ] }) + ] }) }), + customOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_popBackdrop", style: { zIndex: 83 }, onClick: () => setCustomOpen(false) }), + customOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_menu dsh-wt_pop", style: { position: "fixed", left: popLeft, top: popTop, width: 340, zIndex: 84 }, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-wt_menuLabel", children: [ + "\u2728 ", + t("customLayout.title") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "textarea", + { + className: "dsh-wt_customLayoutInput", + autoFocus: true, + rows: 6, + placeholder: t("customLayout.placeholder"), + value: customLayoutText, + onChange: (e) => setCustomLayoutText(e.target.value) + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_customLayoutBtn", onClick: copyCustomLayout, children: t("customLayout.copy") }), + copiedToast && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-wt_customLayoutToast" + (copiedToast === "fail" ? " dsh-wt_customLayoutToastFail" : ""), children: copiedToast === "ok" ? "\u2705 " + t("customLayout.copied") : "\u26A0\uFE0F " + t("customLayout.copyFail") }) + ] }), + requestDelete && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_confirmBackdrop", onClick: () => setRequestDelete(null) }), + requestDelete && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_confirm", role: "alertdialog", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_confirmTitle", children: [ + "\u26A0\uFE0F ", + t("confirm.title") + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_confirmBody", children: requestDelete.kind === "layout" ? t("confirm.layoutBody", { name: requestDelete.name }) : requestDelete.kind === "shortcut" ? t("confirm.shortcutBody", { name: requestDelete.name }) : t("confirm.projectBody", { name: requestDelete.name }) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_confirmActions", children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_confirmCancel", onClick: () => setRequestDelete(null), children: t("confirm.cancel") }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-wt_confirmDelete", onClick: doDelete, children: t("confirm.delete") }) + ] }) + ] }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-wt_projects", "data-managing": viewOptionsOpen ? "true" : void 0, children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_layout dsh-wt_consoleEntry", + "data-on": activeSplitId === CONSOLE_ID ? "true" : "false", + style: { order: 0, position: "relative" }, + title: t("console.name"), + onClick: (e) => clickConsoleCard(e.currentTarget), + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutIcon", children: CONSOLE_ICON }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutText", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutName", children: t("console.name") }) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_bindBtn", + role: "button", + tabIndex: 0, + "data-bound": bindNotifyMap[CONSOLE_ID] ?? (projects.bindings[CONSOLE_ID] ? "true" : "false"), + "data-tip": projects.bindings[CONSOLE_ID] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[CONSOLE_ID]) }) : t("bind.tipUnbound"), + "aria-label": projects.bindings[CONSOLE_ID] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[CONSOLE_ID]) }) : t("bind.tipUnbound"), + onClick: (e) => { + e.stopPropagation(); + openBindPick(CONSOLE_ID, e.currentTarget); + }, + children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_bindCircles", "aria-hidden": true }) + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutArrow", "aria-hidden": true, children: "\u203A" }) + ] + } + ), + renderProjectSlot ? renderProjectSlot("sidebar.worktable.project", ownerProps) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_empty", children: t("empty") }), + visibleLayouts.map((l) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "button", + { + type: "button", + className: "dsh-wt_layout", + "data-on": activeSplitId === l.id ? "true" : "false", + style: { order: effectiveOrder.indexOf(l.id) + 1e3, position: "relative" }, + onClick: () => { + openSplit(l); + reportUsed(l.id); + }, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_layoutIcon dsh-wt_iconPick", + role: "button", + tabIndex: 0, + title: t("icons.change"), + onClick: (e) => { + e.stopPropagation(); + openIconPick("layout", l.id, e.currentTarget); + }, + children: l.icon ?? "\u{1F9F1}" + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutText", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutName", children: projects.nameOverrides[l.id] ?? l.title }) }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_bindBtn", + role: "button", + tabIndex: 0, + "data-bound": bindNotifyMap[l.id] ?? (projects.bindings[l.id] ? "true" : "false"), + "data-tip": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) + (bindNotifyMap[l.id] === "busy" ? t("bind.tipBusy") : bindNotifyMap[l.id] === "done" ? t("bind.tipDone") : bindNotifyMap[l.id] === "need" ? t("bind.tipNeed") : "") : t("bind.tipUnbound"), + "aria-label": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) : t("bind.tipUnbound"), + onClick: (e) => { + e.stopPropagation(); + openBindPick(l.id, e.currentTarget); + }, + children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_bindCircles", "aria-hidden": true }) + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_layoutArrow", "aria-hidden": true, children: "\u203A" }) + ] + }, + l.id + )) + ] }), + visibleShortcuts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_shortcuts", children: visibleShortcuts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( + "a", + { + className: "dsh-wt_shortcut", + href: s.href, + target: "_blank", + rel: "noreferrer noopener", + title: s.href, + children: [ + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( + "span", + { + className: "dsh-wt_shortcutIcon dsh-wt_iconPick", + role: "button", + tabIndex: 0, + title: t("icons.change"), + onClick: (e) => { + e.stopPropagation(); + e.preventDefault(); + openIconPick("shortcut", s.id, e.currentTarget); + }, + children: s.icon + } + ), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_shortcutName", children: s.name }), + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-wt_shortcutBadge", children: t("shortcut.badge") }) + ] + }, + s.id + )) }) + ] }); +} +var inject = ["slots", "locale", "sessions", "conversation", "workspaces"]; +function apply(ctx) { + sessionBridge = { sessions: ctx.sessions ?? null, conversation: ctx.conversation ?? null, list: ctx.sessions?.list ?? null, workspaces: ctx.workspaces ?? null }; + try { + hostApi = ctx.get?.("connection")?.api ?? null; + } catch { + hostApi = null; + } + try { + window.__dshHostApi = hostApi; + } catch { + } + try { + window.__dshOpenSession = (id) => ctx.sessions?.open?.(id); + window.__dshSessions = ctx.sessions; + window.__dshPromptIntoSession = (id, text2) => promptIntoSession(id, text2); + window.__dshWorkspaces = ctx.workspaces; + window.__dshBuildWindowTaskText = buildWindowTaskText; + window.__dshSyncSessionScope = () => syncSessionScope(sessionBridge?.list); + } catch { + } + ctx.effect(() => { + const style = document.createElement("style"); + style.setAttribute("data-dsh-plugin", "dsh-worktable"); + style.textContent = css; + document.head.appendChild(style); + return () => { + style.remove(); + }; + }, "dsh-worktable: styles"); + ctx.effect(() => { + const over = (e) => { + const t = e.target; + const btn = t && t.closest ? t.closest(".dsh-wt_bindBtn") : null; + if (btn) showBindTip(btn); + }; + const out = (e) => { + const t = e.target; + if (t && t.closest && t.closest(".dsh-wt_bindBtn")) hideBindTip(); + }; + const hide = () => hideBindTip(); + document.addEventListener("mouseover", over, true); + document.addEventListener("mouseout", out, true); + document.addEventListener("scroll", hide, true); + document.addEventListener("click", hide, true); + return () => { + document.removeEventListener("mouseover", over, true); + document.removeEventListener("mouseout", out, true); + document.removeEventListener("scroll", hide, true); + document.removeEventListener("click", hide, true); + if (bindTipEl) { + bindTipEl.remove(); + bindTipEl = null; + } + }; + }, "dsh-worktable: bind tip"); + ctx.effect(() => { + if (ctx.locale?.register) return ctx.locale.register(NS, { zh, en }); + }, "dsh-worktable: dictionaries"); + const syncIds = () => { + const entries = ctx.slots.entries("sidebar.worktable.project"); + const ids = []; + for (const entry of entries) { + const id = entry?.options?.id; + if (typeof id === "string" && id && !ids.includes(id)) ids.push(id); + } + registryStore.ids = ids; + for (const fn of registryStore.listeners) fn(); + }; + const disposeSubscribe = ctx.slots.subscribe("sidebar.worktable.project", syncIds); + syncIds(); + ctx.effect(() => disposeSubscribe, "dsh-worktable: project registry watch"); + const sessionsList = ctx.sessions?.list; + if (sessionsList && typeof sessionsList.getSnapshot === "function") { + syncSessionScope(sessionsList); + const disposeScope = sessionsList.subscribe(() => syncSessionScope(sessionsList)); + ctx.effect(() => disposeScope, "dsh-worktable: session scope watch"); + } + ctx.slots.inject("shell.overlay", () => ctx.slots.register({ + name: "shell.overlay", + id: "dsh-worktable-split", + order: 100 + }, SplitWorkspace), "dsh-worktable: split workspace overlay"); + ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({ + name: "sidebar.footer.action", + id: "dsh-worktable", + order: 20, + children: { + "sidebar.worktable.project": { + kind: "list", + scope: "root" + } + } + }, WorktableSection), "dsh-worktable: worktable section"); +} +/*! Bundled license information: + +markdown-it/dist/markdown-it.mjs: + (*! markdown-it 15.0.0 https://github.com/markdown-it/markdown-it @license MIT *) +*/ +return module.exports; } }); +//# sourceMappingURL=client.js.map diff --git a/01_content/lib/index.js b/01_content/lib/index.js new file mode 100644 index 0000000..940dad2 --- /dev/null +++ b/01_content/lib/index.js @@ -0,0 +1,535 @@ +// src/index.ts +import { execFile } from "node:child_process"; +import { readdirSync, realpathSync } from "node:fs"; +import { readdir, readFile } from "node:fs/promises"; +import { dirname, resolve as pathResolve, sep } from "node:path"; +import { createRequire } from "node:module"; +import { homedir } from "node:os"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +// template/dshell.css +var dshell_default = `/* dsh-worktable \u539F\u751F\u76AE\u80A4 \xB7 DSH \u8BBE\u8BA1\u7CFB\u7EDF\u7EC4\u4EF6\u5E93 + \u7528\u6CD5\uFF1A + \u6240\u6709\u989C\u8272\u8D70 DSH \u4E3B\u9898\u53D8\u91CF\uFF08--dsw-alias-*\uFF09\uFF0C\u81EA\u52A8\u9002\u914D\u660E\u6697\u4E3B\u9898\u3002 */ +:root { color-scheme: dark; } +* { box-sizing: border-box; } +html, body { margin: 0; padding: 0; } +body { + background: var(--dsw-alias-bg-base, #0b0e14); + color: var(--dsw-alias-label-primary, #e6e8eb); + font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; + font-size: 13px; + line-height: 1.6; +} +.dshell { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; min-height: 100%; } +/* \u6587\u5B57\u5C42\u7EA7 */ +.dshell-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); } +.dshell-sub { margin: 0; font-size: 12px; color: var(--dsw-alias-label-secondary, #9aa4b2); } +.dshell-muted { color: var(--dsw-alias-label-tertiary, #6b7280); font-size: 11.5px; } +/* \u5361\u7247 */ +.dshell-card { border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); padding: 12px 14px; } +.dshell-card + .dshell-card { margin-top: 10px; } +/* \u6309\u94AE\uFF08\u7EFF\u8272\u4E3B\u6309\u94AE / \u5E7D\u7075\u6309\u94AE / \u5371\u9669\uFF09 */ +.dshell-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid transparent; background: #3fb950; color: #0b0e14; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; } +.dshell-btn:hover { filter: brightness(1.08); } +.dshell-btnGhost { background: transparent; border-color: var(--dsw-alias-border-l1, #262b36); color: var(--dsw-alias-label-secondary, #9aa4b2); } +.dshell-btnGhost:hover { color: var(--dsw-alias-label-primary, #e6e8eb); border-color: var(--dsw-alias-border-l2, #3a4150); } +.dshell-btnDanger { background: transparent; border-color: #f85149; color: #f85149; } +/* \u72B6\u6001\u5FBD\u6807\uFF08\u5706\u70B9 + \u6587\u5B57\uFF1B\u7EFF=\u5DF2\u5B8C\u6210 \u9EC4=\u5F85\u529E/\u5F85\u53D1\u5E03 \u7070=\u672A\u5F00\u59CB\uFF09 */ +.dshell-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, #262b36); font-size: 11.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); } +.dshell-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); } +.dshell-badgeDone { color: #3fb950; border-color: rgba(63,185,80,.4); } +.dshell-badgeDone::before { background: #3fb950; box-shadow: 0 0 5px #3fb950; } +.dshell-badgeWait { color: #d29922; border-color: rgba(210,153,34,.4); } +.dshell-badgeWait::before { background: #d29922; box-shadow: 0 0 5px #d29922; } +.dshell-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); } +.dshell-dotDone { background: #3fb950; box-shadow: 0 0 5px #3fb950; } +.dshell-dotWait { background: #d29922; box-shadow: 0 0 5px #d29922; } +/* \u6807\u7B7E\u9875 */ +.dshell-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); } +.dshell-tab { padding: 7px 12px; font-size: 12.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); cursor: pointer; border: none; background: none; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; } +.dshell-tabOn { color: var(--dsw-alias-label-primary, #e6e8eb); border-bottom-color: var(--dsw-alias-state-accent-primary, #4f8ef7); } +/* \u5217\u8868 */ +.dshell-list { display: flex; flex-direction: column; gap: 6px; } +.dshell-listItem { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); cursor: pointer; } +.dshell-listItem:hover { border-color: var(--dsw-alias-border-l2, #3a4150); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.05)); } +.dshell-listItemTitle { font-size: 12.5px; color: var(--dsw-alias-label-primary, #e6e8eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.dshell-listItemMeta { flex: none; font-size: 11px; color: var(--dsw-alias-label-tertiary, #6b7280); } +/* \u7F51\u683C / \u7EDF\u8BA1 */ +.dshell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; } +.dshell-stat { padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); } +.dshell-statLabel { font-size: 11px; color: var(--dsw-alias-label-secondary, #9aa4b2); } +.dshell-statValue { font-size: 20px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); } +.dshell-statDelta { font-size: 11px; color: #3fb950; } +/* \u8FDB\u5EA6\u6761 */ +.dshell-progress { height: 6px; border-radius: 3px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.06)); overflow: hidden; } +.dshell-progressBar { height: 100%; border-radius: 3px; background: #3fb950; } +/* \u8F93\u5165 */ +.dshell-input, .dshell-textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); color: var(--dsw-alias-label-primary, #e6e8eb); font: inherit; font-size: 12.5px; outline: none; } +.dshell-input:focus, .dshell-textarea:focus { border-color: var(--dsw-alias-state-accent-primary, #4f8ef7); } +/* \u8868\u683C */ +.dshell-table { width: 100%; border-collapse: collapse; font-size: 12px; } +.dshell-table th, .dshell-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); } +.dshell-table th { color: var(--dsw-alias-label-secondary, #9aa4b2); font-weight: 500; } +/* \u952E\u503C\u5BF9 */ +.dshell-kv { display: flex; flex-direction: column; gap: 6px; } +.dshell-kvRow { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; } +.dshell-kvKey { color: var(--dsw-alias-label-secondary, #9aa4b2); } +.dshell-kvValue { color: var(--dsw-alias-label-primary, #e6e8eb); text-align: right; } +/* \u5206\u5272\u7EBF */ +.dshell-divider { height: 1px; background: var(--dsw-alias-border-l1, #262b36); margin: 6px 0; } +/* \u6EDA\u52A8\u6761 */ +::-webkit-scrollbar { width: 10px; height: 10px; } +::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 5px; } +::-webkit-scrollbar-track { background: transparent; } +`; + +// template/dshell.html +var dshell_default2 = '\n\n\n\n \n \n \u6211\u7684\u7A97\u53E3\n \n\n\n

\n \n

\u7A97\u53E3\u6807\u9898

\n

\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u4E2A\u7A97\u53E3\u505A\u4EC0\u4E48\u3002

\n\n \n
\n \u5DF2\u5B8C\u6210\n \u8FDB\u884C\u4E2D\n \u672A\u5F00\u59CB\n
\n\n \n
\n \n \n \n
\n\n \n
\n
\n
\u603B\u6570
\n
128
\n
+12.4%
\n
\n
\n
\u8FDB\u884C\u4E2D
\n
7
\n
\n
\n
\u5DF2\u5B8C\u6210
\n
121
\n
\n
\n\n \n
\n
\n \u6761\u76EE\u4E00\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898\n \u6628\u5929\n
\n
\n \u6761\u76EE\u4E8C\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898\n \u5DF2\u53D1\u5E03\n
\n
\n\n \n
\n

\u8BE6\u60C5

\n
\n
\u5B57\u6BB5 A\u503C A
\n
\u5B57\u6BB5 B\u503C B
\n
\n
\n
\n
\n\n \n
\n \n \n
\n
\n\n\n'; + +// src/index.ts +var name = "dsh-worktable"; +var inject = ["webServer", "sessions"]; +var HEALTH_PATH = "/api/worktable/health"; +var MAX_ENTRIES = 500; +var FILE_TYPES = { + html: "text/html; charset=utf-8", + htm: "text/html; charset=utf-8", + css: "text/css; charset=utf-8", + js: "text/javascript; charset=utf-8", + mjs: "text/javascript; charset=utf-8", + json: "application/json; charset=utf-8", + map: "application/json; charset=utf-8", + md: "text/markdown; charset=utf-8", + markdown: "text/markdown; charset=utf-8", + txt: "text/plain; charset=utf-8", + log: "text/plain; charset=utf-8", + pdf: "application/pdf", + svg: "image/svg+xml", + png: "image/png", + jpg: "image/jpeg", + jpeg: "image/jpeg", + gif: "image/gif", + webp: "image/webp", + bmp: "image/bmp", + ico: "image/x-icon", + avif: "image/avif", + woff: "font/woff", + woff2: "font/woff2", + ttf: "font/ttf", + otf: "font/otf", + wasm: "application/wasm", + mp3: "audio/mpeg", + mp4: "video/mp4", + webm: "video/webm" +}; +var SITE_PREFIX = "/api/worktable/site"; +var TEMPLATE_PREFIX = "/api/worktable/template"; +function loadPkg(pkg) { + const starts = /* @__PURE__ */ new Set(); + try { + starts.add(dirname(fileURLToPath(import.meta.url))); + } catch { + } + try { + starts.add(realpathSync(dirname(fileURLToPath(import.meta.url)))); + } catch { + } + for (const start of starts) { + let dir = start; + while (dir && dir !== pathResolve(dir, "..")) { + try { + const req = createRequire(pathToFileURL(pathResolve(dir, "__wt_probe__.js")).href); + return req(pkg); + } catch { + } + dir = pathResolve(dir, ".."); + } + } + try { + const profilesDir = pathResolve(homedir(), ".dsh", "profiles"); + for (const profile of readdirSync(profilesDir, { withFileTypes: true })) { + if (!profile.isDirectory() && !profile.isSymbolicLink()) continue; + const nm = pathResolve(profilesDir, profile.name, "node_modules"); + try { + const req = createRequire(pathToFileURL(pathResolve(nm, "__wt_probe__.js")).href); + return req(pkg); + } catch { + } + } + } catch { + } + return null; +} +function serverCwd(ctx, sessionId, clientCwd) { + if (sessionId) { + try { + const headerCwd = ctx.sessions?.get?.(sessionId)?.header?.cwd; + if (typeof headerCwd === "string" && headerCwd) return headerCwd; + } catch { + } + } + if (typeof clientCwd === "string" && clientCwd) return clientCwd; + return process.cwd(); +} +function json(res, status, body) { + res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" }); + res.end(JSON.stringify(body)); +} +async function readJsonBody(req) { + const chunks = []; + for await (const chunk of req) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk); + const text = Buffer.concat(chunks).toString("utf8"); + if (!text) return {}; + try { + return JSON.parse(text); + } catch { + return {}; + } +} +async function listDirectory(path) { + const abs = pathResolve(path); + const dirents = await readdir(abs, { withFileTypes: true }); + const entries = dirents.map((d) => ({ name: d.name, path: abs + sep + d.name, isDir: d.isDirectory(), hidden: d.name.startsWith(".") })).sort((a, b) => { + if (a.isDir !== b.isDir) return a.isDir ? -1 : 1; + return a.name.localeCompare(b.name, void 0, { sensitivity: "base" }); + }); + const truncated = entries.length > MAX_ENTRIES; + return { path: abs, entries: truncated ? entries.slice(0, MAX_ENTRIES) : entries, truncated }; +} +function gitExec(args, cwd) { + return new Promise((resolvePromise, reject) => { + execFile("git", args, { cwd, windowsHide: true, maxBuffer: 4 * 1024 * 1024 }, (err, stdout) => { + if (err) reject(err); + else resolvePromise(stdout); + }); + }); +} +async function gitStatus(cwd) { + try { + const branchRaw = await gitExec(["rev-parse", "--abbrev-ref", "HEAD"], cwd); + const porcelain = await gitExec(["status", "--porcelain=v1", "-z"], cwd); + const entries = porcelain.split("\0").filter((s) => s.length > 2).map((s) => ({ xy: s.slice(0, 2), path: s.slice(3) })); + return { isRepo: true, branch: branchRaw.trim() || "HEAD", entries }; + } catch { + return { isRepo: false, branch: void 0, entries: [] }; + } +} +function setupTerminal(webServer, ctx) { + if (typeof webServer.registerUpgrade !== "function") return; + const wsMod = loadPkg("ws"); + const ptyMod = loadPkg("node-pty"); + ctx.logger?.info?.("[dsh-worktable] term deps: ws=" + (wsMod ? "ok" : "MISSING") + " node-pty=" + (ptyMod ? "ok" : "MISSING")); + if (!wsMod || !ptyMod) { + ctx.logger?.warn("[dsh-worktable] \u7EC8\u7AEF\u8DEF\u7531\u672A\u6CE8\u518C\uFF1Aws/node-pty \u4E0D\u53EF\u7528"); + return; + } + const WebSocketServer = wsMod.WebSocketServer ?? wsMod.default?.WebSocketServer; + if (!WebSocketServer) return; + const pty = ptyMod.default ?? ptyMod; + const wss = new WebSocketServer({ noServer: true }); + const spawnShell = () => process.platform === "win32" ? { cmd: "powershell.exe", args: ["-NoLogo", "-NoProfile"] } : { cmd: process.env.SHELL || "/bin/bash", args: [] }; + const clampDim = (v, fallback) => Math.min(1024, Math.max(2, Number.isFinite(v) ? v : fallback)); + ctx.effect(() => webServer.registerUpgrade({ + path: "/api/worktable/term", + handler: (req, socket, head) => { + wss.handleUpgrade(req, socket, head, (ws) => { + const u = new URL(req.url ?? "/", "http://dsh.internal"); + const cwd = serverCwd(ctx, u.searchParams.get("sessionId") || void 0, u.searchParams.get("cwd") || void 0); + const cols = clampDim(Number(u.searchParams.get("cols")), 80); + const rows = clampDim(Number(u.searchParams.get("rows")), 24); + let term = null; + try { + const shell = spawnShell(); + term = pty.spawn(shell.cmd, shell.args, { name: "xterm-256color", cols, rows, cwd, env: process.env }); + } catch (err) { + try { + ws.send("\r\n[worktable] \u7EC8\u7AEF\u542F\u52A8\u5931\u8D25\uFF1A" + String(err)); + } catch { + } + try { + ws.close(); + } catch { + } + return; + } + term.onData((d) => { + try { + ws.send(d); + } catch { + } + }); + term.onExit(() => { + try { + ws.close(); + } catch { + } + }); + ws.on("message", (raw) => { + const text = String(raw); + try { + const msg = JSON.parse(text); + if (msg && msg.type === "resize" && Number.isFinite(msg.cols) && Number.isFinite(msg.rows)) { + term.resize(clampDim(msg.cols, cols), clampDim(msg.rows, rows)); + return; + } + } catch { + } + try { + term.write(text); + } catch { + } + }); + ws.on("close", () => { + try { + term.kill(); + } catch { + } + }); + }); + } + }), "dsh-worktable: terminal upgrade"); +} +function apply(ctx) { + const webServer = ctx.webServer; + if (!webServer) { + ctx.logger?.warn("[dsh-worktable] ctx.webServer \u4E0D\u53EF\u7528\uFF08headless profile\uFF1F\uFF09\uFF0C\u8DF3\u8FC7\u670D\u52A1\u7AEF\u8DEF\u7531"); + return; + } + webServer.register({ + kind: "exact", + path: HEALTH_PATH, + handler: (_req, res) => { + json(res, 200, { plugin: "dsh-worktable", version: "0.2.0", ok: true }); + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/file", + handler: async (req, res) => { + try { + const u = new URL(req.url ?? "/", "http://dsh.internal"); + const p = u.searchParams.get("path") || ""; + if (!p) { + json(res, 400, { error: "missing path" }); + return; + } + const abs = pathResolve(p); + const stat = await import("node:fs/promises").then((m) => m.stat(abs)); + if (stat.size > 20 * 1024 * 1024) { + json(res, 413, { error: "file too large" }); + return; + } + const data = await readFile(abs); + const ext = (abs.split(".").pop() || "").toLowerCase(); + const types = { + html: "text/html; charset=utf-8", + htm: "text/html; charset=utf-8", + css: "text/css; charset=utf-8", + js: "text/javascript; charset=utf-8", + mjs: "text/javascript; charset=utf-8", + json: "application/json; charset=utf-8", + md: "text/markdown; charset=utf-8", + markdown: "text/markdown; charset=utf-8", + txt: "text/plain; charset=utf-8", + log: "text/plain; charset=utf-8", + pdf: "application/pdf", + svg: "image/svg+xml", + png: "image/png", + jpg: "image/jpeg", + jpeg: "image/jpeg", + gif: "image/gif", + webp: "image/webp", + bmp: "image/bmp", + ico: "image/x-icon" + }; + res.writeHead(200, { "content-type": FILE_TYPES[ext] ?? "application/octet-stream", "cache-control": "no-store" }); + res.end(data); + } catch (err) { + json(res, 404, { error: String(err) }); + } + } + }); + webServer.register({ + kind: "prefix", + path: TEMPLATE_PREFIX, + handler: (req, res) => { + try { + if (req.method !== "GET") { + res.writeHead(405); + res.end(); + return; + } + const pathname = new URL(req.url ?? "/", "http://dsh.internal").pathname; + const rel = pathname.slice(TEMPLATE_PREFIX.length); + if (rel === "/dshell.css") { + res.writeHead(200, { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" }); + res.end(dshell_default); + } else { + res.writeHead(200, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" }); + res.end(dshell_default2); + } + } catch (err) { + res.writeHead(404); + res.end(String(err)); + } + } + }); + webServer.register({ + kind: "prefix", + path: SITE_PREFIX, + handler: async (req, res) => { + try { + if (req.method !== "GET") { + res.writeHead(405); + res.end(); + return; + } + const pathname = new URL(req.url ?? "/", "http://dsh.internal").pathname; + const segs = pathname.slice(SITE_PREFIX.length).split("/").filter(Boolean); + const rootToken = decodeURIComponent(segs.shift() ?? ""); + const rel = segs.map((s) => { + try { + return decodeURIComponent(s); + } catch { + return s; + } + }).join("/"); + if (!rootToken) { + json(res, 400, { error: "missing root" }); + return; + } + const root = pathResolve(rootToken); + let abs = pathResolve(root, rel); + if (abs !== root && !abs.startsWith(root + sep)) { + json(res, 403, { error: "outside root" }); + return; + } + const statMod = await import("node:fs/promises"); + let info = await statMod.stat(abs).catch(() => null); + if (info && info.isDirectory()) { + abs = pathResolve(abs, "index.html"); + info = await statMod.stat(abs).catch(() => null); + } + if (!info || !info.isFile()) { + json(res, 404, { error: "not found" }); + return; + } + if (info.size > 40 * 1024 * 1024) { + json(res, 413, { error: "file too large" }); + return; + } + const data = await readFile(abs); + const ext = (abs.split(".").pop() || "").toLowerCase(); + res.writeHead(200, { "content-type": FILE_TYPES[ext] ?? "application/octet-stream", "cache-control": "no-store" }); + res.end(data); + } catch (err) { + json(res, 404, { error: String(err) }); + } + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/fs", + handler: async (req, res) => { + try { + const body = await readJsonBody(req); + const path = typeof body.path === "string" && body.path ? body.path : serverCwd(ctx, body.sessionId, body.cwd); + json(res, 200, await listDirectory(path)); + } catch (err) { + json(res, 500, { path: "", entries: [], truncated: false, error: String(err) }); + } + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/workspaces", + handler: async (_req, res) => { + try { + const file = pathResolve(homedir(), ".dsh", "storages", "workspace.json"); + const raw = await readFile(file, "utf8"); + json(res, 200, JSON.parse(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw)); + } catch (err) { + json(res, 404, { error: String(err) }); + } + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/write", + handler: async (req, res) => { + try { + if (req.method !== "POST") { + res.writeHead(405); + res.end(); + return; + } + const body = await readJsonBody(req); + const p = typeof body.path === "string" ? body.path : ""; + const content = typeof body.content === "string" ? body.content : ""; + if (!p) { + json(res, 400, { error: "missing path" }); + return; + } + if (content.length > 20 * 1024 * 1024) { + json(res, 413, { error: "content too large" }); + return; + } + const abs = pathResolve(p); + await import("node:fs/promises").then((m) => m.writeFile(abs, content, "utf8")); + json(res, 200, { ok: true }); + } catch (err) { + json(res, 500, { error: String(err) }); + } + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/mkdir", + handler: async (req, res) => { + try { + if (req.method !== "POST") { + res.writeHead(405); + res.end(); + return; + } + const body = await readJsonBody(req); + const p = typeof body.path === "string" ? body.path.trim() : ""; + if (!p) { + json(res, 400, { error: "missing path" }); + return; + } + const abs = pathResolve(p); + const fsx = await import("node:fs/promises"); + const parent = abs.split(/[\\/]/).slice(0, -1).join("\\") || "\\"; + try { + await fsx.access(parent); + } catch { + json(res, 400, { error: "parent not found" }); + return; + } + await fsx.mkdir(abs); + json(res, 200, { ok: true, path: abs }); + } catch (err) { + json(res, err?.code === "EEXIST" ? 200 : 500, err?.code === "EEXIST" ? { ok: true, exists: true } : { error: String(err) }); + } + } + }); + webServer.register({ + kind: "exact", + path: "/api/worktable/git", + handler: async (req, res) => { + const body = await readJsonBody(req); + const cwd = serverCwd(ctx, body.sessionId, body.cwd); + json(res, 200, await gitStatus(cwd)); + } + }); + setupTerminal(webServer, ctx); +} +export { + HEALTH_PATH, + apply, + inject, + name +}; +//# sourceMappingURL=index.js.map