@bastani/atomic-tui 0.9.90 → 0.10.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-command-names.d.ts +1 -1
- package/dist/builtin-command-names.d.ts.map +1 -1
- package/dist/builtin-command-names.js +0 -2
- package/dist/builtin-command-names.js.map +1 -1
- package/dist/clickable-hints.d.ts.map +1 -1
- package/dist/clickable-hints.js +75 -19
- package/dist/clickable-hints.js.map +1 -1
- package/dist/components/editor.d.ts +39 -0
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +110 -0
- package/dist/components/editor.js.map +1 -1
- package/dist/components/scroll-view.d.ts +17 -0
- package/dist/components/scroll-view.d.ts.map +1 -1
- package/dist/components/scroll-view.js +40 -0
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/windowed-container.d.ts +87 -0
- package/dist/components/windowed-container.d.ts.map +1 -1
- package/dist/components/windowed-container.js +212 -3
- package/dist/components/windowed-container.js.map +1 -1
- package/dist/editor-component.d.ts +9 -0
- package/dist/editor-component.d.ts.map +1 -1
- package/dist/editor-component.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kill-ring.d.ts +2 -0
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js +6 -0
- package/dist/kill-ring.js.map +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +6 -1
- package/dist/layout.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +45 -1
- package/dist/tui-alt-screen.d.ts.map +1 -1
- package/dist/tui-alt-screen.js +550 -48
- package/dist/tui-alt-screen.js.map +1 -1
- package/dist/tui-main-screen.d.ts +27 -1
- package/dist/tui-main-screen.d.ts.map +1 -1
- package/dist/tui-main-screen.js +216 -15
- package/dist/tui-main-screen.js.map +1 -1
- package/dist/tui.d.ts +56 -4
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +58 -7
- package/dist/tui.js.map +1 -1
- package/dist/undo-stack.d.ts +2 -0
- package/dist/undo-stack.d.ts.map +1 -1
- package/dist/undo-stack.js +6 -0
- package/dist/undo-stack.js.map +1 -1
- package/package.json +1 -1
package/dist/tui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAmB,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EACN,qBAAqB,EACrB,8BAA8B,GAI9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACN,eAAe,EACf,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,YAAY,GACZ,MAAM,YAAY,CAAC;AAqEpB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAoB,EAAE,KAAoB;IAC5E,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACxB,gGAAgG;QAChG,iGAAiG;QACjG,0FAA0F;QAC1F,MAAM,SAAS,GAAG,MAAgC,CAAC;QACnD,OAAO,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxG,C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AAC;QAClG,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,mBAAmB,CAAC,EACnB,SAAS,EACT,WAAW,GAIX;QACA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,KAAK,GAA8B;gBACxC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC;gBACvE,OAAO,EAAE,IAAI,GAAG,EAAE;gBAClB,OAAO,EAAE,OAAO;gBAChB,KAAK,EAAE,SAAS;aAChB,CAAC;YACF,uFAAuF;YACvF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/C,CAAC,EAAE,SAAS,CAAC,CAAC;YACd,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/**\n * Minimal TUI implementation with differential rendering\n */\n\nimport { performance } from \"node:perf_hooks\";\nimport { type HintAction, hintKeyInput, runAsHintActivation, stripHintMarkers } from \"./clickable-hints.ts\";\nimport { isKeyRelease, matchesKey } from \"./keys.ts\";\nimport type { Terminal } from \"./terminal.ts\";\nimport {\n\tparseOscColorResponse,\n\tparseTerminalColorSchemeReport,\n\ttype RgbColor,\n\ttype TerminalColorScheme,\n\ttype TerminalColors,\n} from \"./terminal-colors.ts\";\nimport { getCapabilities, isImageLine, setCellDimensions } from \"./terminal-image.ts\";\nimport {\n\textractSegments,\n\tHINT_CLOSE,\n\tHINT_OPEN,\n\tnormalizeTerminalOutput,\n\tsliceByColumn,\n\tsliceWithWidth,\n\tvisibleWidth,\n} from \"./utils.ts\";\n\n/**\n * Component interface - all components must implement this\n */\nexport type TuiMouseEventType = \"press\" | \"release\" | \"move\" | \"drag\" | \"click\" | \"wheel\";\nexport type TuiMouseButton = \"left\" | \"middle\" | \"right\" | \"none\";\n\n/** Normalized cell-based mouse event. Coordinates are zero-based. */\nexport interface TuiMouseEvent {\n\ttype: TuiMouseEventType;\n\tbutton: TuiMouseButton;\n\t/** Coordinates local to the receiving component. */\n\tx: number;\n\ty: number;\n\t/** Absolute terminal coordinates. */\n\tscreenX: number;\n\tscreenY: number;\n\t/** Current component bounds. */\n\twidth: number;\n\theight: number;\n\tshift: boolean;\n\talt: boolean;\n\tctrl: boolean;\n\t/** Logical lines. Negative values scroll up. */\n\twheelDelta?: number;\n\t/** Consecutive click count when type is click. */\n\tclickCount?: number;\n}\n\nexport interface TuiMouseEventResult {\n\t/** Stop propagation and suppress renderer-level fallback behavior. */\n\thandled?: boolean;\n\t/** Route subsequent drag/release events to this component. Implies handled. */\n\tcapture?: boolean;\n\t/** Give keyboard focus to this component. Implies handled. */\n\tfocus?: boolean;\n\t/**\n\t * Explicitly request or suppress a render. Move and release default to false;\n\t * press, click, drag, and wheel default to true.\n\t */\n\trender?: boolean;\n\t/**\n\t * For a single click: what it does once it is known not to start a double- or triple-click. It runs when the\n\t * multi-click interval since the press passes with no second press on the same spot, then the screen repaints. A\n\t * second press there makes the click part of a double- or triple-click, which selects text, and cancels it.\n\t */\n\twhenSingleClick?: () => void;\n\t/** Release anything reserved for `whenSingleClick` if the renderer cancels it instead. */\n\tonSingleClickCancel?: () => void;\n}\n\n/** Internal target metadata used by containers and alternate-screen dispatch. */\nexport interface TuiMouseDispatchTarget {\n\tcomponent: Component;\n\toriginX: number;\n\toriginY: number;\n\twidth: number;\n\theight: number;\n}\n\n/** Result of dispatching to a concrete component. */\nexport interface TuiMouseDispatchResult extends TuiMouseEventResult {\n\thandled: true;\n\ttarget: TuiMouseDispatchTarget;\n\t/** Keyboard focus target, which may be a delegating parent container. */\n\tfocusTarget?: Component;\n}\n\n/**\n * Dispatch an event to a component and retain the exact target and coordinate\n * transform. Containers use this when forwarding events to nested children.\n */\nexport function dispatchMouseEvent(component: Component, event: TuiMouseEvent): TuiMouseDispatchResult | undefined {\n\tconst result = component.handleMouse?.(event);\n\tif (!result) return undefined;\n\tif (\"target\" in result) {\n\t\t// The component forwarded the event to a child it hosts. Like a delegating container, it routes\n\t\t// keys to that child itself, so it keeps keyboard focus. Focusing the child directly would leave\n\t\t// focus on a detached component once the host removes it, e.g. a closed settings submenu.\n\t\tconst forwarded = result as TuiMouseDispatchResult;\n\t\treturn forwarded.focus && component.handleInput ? { ...forwarded, focusTarget: component } : forwarded;\n\t}\n\tif (!result.handled && !result.capture && !result.focus) return undefined;\n\treturn {\n\t\t...result,\n\t\thandled: true,\n\t\t...(result.focus ? { focusTarget: component } : {}),\n\t\ttarget: {\n\t\t\tcomponent,\n\t\t\toriginX: event.screenX - event.x,\n\t\t\toriginY: event.screenY - event.y,\n\t\t\twidth: event.width,\n\t\t\theight: event.height,\n\t\t},\n\t};\n}\n\n/** Recreate local coordinates for a previously dispatched mouse target. */\nexport function retargetMouseEvent(event: TuiMouseEvent, target: TuiMouseDispatchTarget): TuiMouseEvent {\n\treturn {\n\t\t...event,\n\t\tx: event.screenX - target.originX,\n\t\ty: event.screenY - target.originY,\n\t\twidth: target.width,\n\t\theight: target.height,\n\t};\n}\n\nexport interface Component {\n\t/**\n\t * Render the component to lines for the given viewport width\n\t * @param width - Current viewport width\n\t * @returns Array of strings, each representing a line\n\t */\n\trender(width: number): string[];\n\n\t/** Optional handler for keyboard input when component has focus. */\n\thandleInput?(data: string): void;\n\n\t/** Optional normalized mouse handler. */\n\thandleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;\n\n\t/**\n\t * An identity for what the last render drew on `row`, such as the id of the item shown there. The fullscreen\n\t * renderer turns a press and release into a click only when it is the same at both, so a repaint that swaps in\n\t * another item with the same text is not clicked by mistake.\n\t */\n\tpaintedRowKey?(row: number): string | undefined;\n\n\t/**\n\t * If true, component receives key release events (Kitty protocol).\n\t * Default is false - release events are filtered out.\n\t */\n\twantsKeyRelease?: boolean;\n\n\t/**\n\t * If true while focused, fullscreen viewport keys (`tui.altScreen.*` scrolling and prompt jumps) go to this\n\t * component instead of scrolling the transcript, as they do for a focused overlay. Default is false.\n\t */\n\tcapturesViewportInput?: boolean;\n\n\t/**\n\t * Invalidate any cached rendering state.\n\t * Called when theme changes or when component needs to re-render from scratch.\n\t */\n\tinvalidate(): void;\n}\n\nexport type TuiInputListenerResult = { consume?: boolean; data?: string } | undefined;\nexport type TuiInputListener = (data: string) => TuiInputListenerResult;\ntype PendingTerminalColorQuery = {\n\tforeground?: RgbColor;\n\tbackground?: RgbColor;\n\tpalette: Array<RgbColor | undefined>;\n\t/** Targets that already replied, so duplicates do not count twice. */\n\treplied: Set<string>;\n\t/**\n\t * Receives the result: the promise's resolve until the timeout, then `onLateReply`. Unset once the\n\t * query completed (on the DA1 reply or once every color replied); later replies are ignored.\n\t */\n\tdeliver: ((colors: TerminalColors) => void) | undefined;\n\ttimer: NodeJS.Timeout | undefined;\n};\n\nconst TERMINAL_PALETTE_SIZE = 16;\n/** OSC 10 and 11 plus OSC 4 for every palette color. */\nconst TERMINAL_COLOR_REPLY_COUNT = 2 + TERMINAL_PALETTE_SIZE;\n/**\n * Default colors, palette colors 0-15, and a trailing primary device attributes (DA1) request.\n * Every terminal answers DA1 and terminals answer in order, so the DA1 reply marks the end of\n * the color replies, including for terminals that ignore the color queries.\n */\nconst TERMINAL_COLOR_QUERY = `\\x1b]10;?\\x07\\x1b]11;?\\x07${Array.from(\n\t{ length: TERMINAL_PALETTE_SIZE },\n\t(_, index) => `\\x1b]4;${index};?\\x07`,\n).join(\"\")}\\x1b[c`;\nconst DEVICE_ATTRIBUTES_RESPONSE_PATTERN = /^\\x1b\\[\\?[\\d;]*c$/;\n\n/**\n * Interface for components that can receive focus and display a hardware cursor.\n * When focused, the component should emit CURSOR_MARKER at the cursor position\n * in its render output. TUI will find this marker and position the hardware\n * cursor there for proper IME candidate window positioning.\n */\nexport interface Focusable {\n\t/** Set by TUI when focus changes. Component should emit CURSOR_MARKER when true. */\n\tfocused: boolean;\n}\n\n/** Type guard to check if a component implements Focusable */\nexport function isFocusable(component: Component | null): component is Component & Focusable {\n\treturn component !== null && \"focused\" in component;\n}\n\n/**\n * Cursor position marker - APC (Application Program Command) sequence.\n * This is a zero-width escape sequence that terminals ignore.\n * Components emit this at the cursor position when focused.\n * TUI finds and strips this marker, then positions the hardware cursor there.\n */\nexport const CURSOR_MARKER = \"\\x1b_pi:c\\x07\";\n\n/** Fake cursor markers - zero-width APC sequences around the text drawn as the cursor. See resolveFakeCursors(). */\nexport const FAKE_CURSOR_START = \"\\x1b_pi:fc\\x07\";\nexport const FAKE_CURSOR_END = \"\\x1b_pi:/fc\\x07\";\n// CURSOR_MARKER + FAKE_CURSOR_START + text + FAKE_CURSOR_END. Truncating the line right after the cursor cell drops the end.\nconst FOCUSED_FAKE_CURSOR = /(\\x1b_pi:c\\x07)\\x1b_pi:fc\\x07(.*?)(?:\\x1b_pi:\\/fc\\x07|$)/s;\n\n/** Wrap text in fake cursor markers. */\nexport function renderFakeCursor(text: string): string {\n\treturn `${FAKE_CURSOR_START}${text}${FAKE_CURSOR_END}`;\n}\n\nexport { visibleWidth };\n\n/**\n * Anchor position for overlays\n */\nexport type OverlayAnchor =\n\t| \"center\"\n\t| \"top-left\"\n\t| \"top-right\"\n\t| \"bottom-left\"\n\t| \"bottom-right\"\n\t| \"top-center\"\n\t| \"bottom-center\"\n\t| \"left-center\"\n\t| \"right-center\";\n\n/**\n * Margin configuration for overlays\n */\nexport interface OverlayMargin {\n\ttop?: number;\n\tright?: number;\n\tbottom?: number;\n\tleft?: number;\n}\n\n/** Value that can be absolute (number) or percentage (string like \"50%\") */\nexport type SizeValue = number | `${number}%`;\n\n/** Parse a SizeValue into absolute value given a reference size */\nfunction parseSizeValue(value: SizeValue | undefined, referenceSize: number): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"number\") return value;\n\t// Parse percentage string like \"50%\"\n\tconst match = value.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\tif (match) {\n\t\treturn Math.floor((referenceSize * parseFloat(match[1])) / 100);\n\t}\n\treturn undefined;\n}\n\n/**\n * Options for overlay positioning and sizing.\n * Values can be absolute numbers or percentage strings (e.g., \"50%\").\n */\nexport interface OverlayOptions {\n\t// === Sizing ===\n\t/** Width in columns, or percentage of terminal width (e.g., \"50%\") */\n\twidth?: SizeValue;\n\t/** Minimum width in columns */\n\tminWidth?: number;\n\t/** Maximum height in rows, or percentage of terminal height (e.g., \"50%\") */\n\tmaxHeight?: SizeValue;\n\n\t// === Positioning - anchor-based ===\n\t/** Anchor point for positioning (default: 'center') */\n\tanchor?: OverlayAnchor;\n\t/** Horizontal offset from anchor position (positive = right) */\n\toffsetX?: number;\n\t/** Vertical offset from anchor position (positive = down) */\n\toffsetY?: number;\n\n\t// === Positioning - percentage or absolute ===\n\t/** Row position: absolute number, or percentage (e.g., \"25%\" = 25% from top) */\n\trow?: SizeValue;\n\t/** Column position: absolute number, or percentage (e.g., \"50%\" = centered horizontally) */\n\tcol?: SizeValue;\n\n\t// === Margin from terminal edges ===\n\t/** Margin from terminal edges. Number applies to all sides. */\n\tmargin?: OverlayMargin | number;\n\n\t// === Visibility ===\n\t/**\n\t * Control overlay visibility based on terminal dimensions.\n\t * If provided, overlay is only rendered when this returns true.\n\t * Called each render cycle with current terminal dimensions.\n\t */\n\tvisible?: (termWidth: number, termHeight: number) => boolean;\n\t/** If true, don't capture keyboard focus when shown */\n\tnonCapturing?: boolean;\n}\n\n/** Options for {@link OverlayHandle.unfocus}. */\nexport interface OverlayUnfocusOptions {\n\t/** Explicit target to focus after releasing this overlay. */\n\ttarget: Component | null;\n}\n\n/** Last rendered terminal-relative overlay rectangle. */\nexport interface OverlayBounds {\n\trow: number;\n\tcol: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Handle returned by showOverlay for controlling the overlay\n */\nexport interface OverlayHandle {\n\t/** Permanently remove the overlay (cannot be shown again) */\n\thide(): void;\n\t/** Temporarily hide or show the overlay */\n\tsetHidden(hidden: boolean): void;\n\t/** Check if overlay is temporarily hidden */\n\tisHidden(): boolean;\n\t/** Focus this overlay and bring it to the visual front */\n\tfocus(): void;\n\t/** Release focus to the next visible capturing overlay or previous target, or to an explicit target when provided */\n\tunfocus(options?: OverlayUnfocusOptions): void;\n\t/** Check if this overlay currently has focus */\n\tisFocused(): boolean;\n\t/** Get the most recent rendered bounds for a visible overlay. */\n\tgetBounds(): OverlayBounds | undefined;\n}\n\ntype OverlayStackEntry = {\n\tcomponent: Component;\n\toptions?: OverlayOptions;\n\tpreFocus: Component | null;\n\thidden: boolean;\n\tfocusOrder: number;\n\tbounds?: OverlayBounds;\n};\n\ntype RenderedOverlayLayout = {\n\tentry: OverlayStackEntry;\n\trow: number;\n\tcol: number;\n\twidth: number;\n\theight: number;\n};\n\ntype OverlayBlockedFocusResume = { status: \"restore-overlay\" } | { status: \"focus-target\"; target: Component | null };\ntype EligibleOverlayFocusRestoreState = { status: \"eligible\"; overlay: OverlayStackEntry };\ntype BlockedOverlayFocusRestoreState = {\n\tstatus: \"blocked\";\n\toverlay: OverlayStackEntry;\n\tblockedBy: Component;\n\tresume: OverlayBlockedFocusResume;\n};\ntype ActiveOverlayFocusRestoreState = EligibleOverlayFocusRestoreState | BlockedOverlayFocusRestoreState;\ntype OverlayFocusRestoreState = { status: \"inactive\" } | ActiveOverlayFocusRestoreState;\ntype OverlayFocusRestorePolicy = \"clear\" | \"preserve\";\n\n/**\n * Container - a component that contains other components\n */\nexport class Container implements Component {\n\tchildren: Component[] = [];\n\tprivate mouseLayout?: { width: number; children: Array<{ component: Component; height: number }> };\n\n\taddChild(component: Component): void {\n\t\tthis.children.push(component);\n\t}\n\n\tremoveChild(component: Component): void {\n\t\tconst index = this.children.indexOf(component);\n\t\tif (index !== -1) {\n\t\t\tthis.children.splice(index, 1);\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.children = [];\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const child of this.children) {\n\t\t\tchild.invalidate?.();\n\t\t}\n\t}\n\n\t/**\n\t * The child drawn at `row` of this container at `width`, with the row inside that child and the child's height.\n\t * Reads the row heights of the last render at `width`; another width renders the children to measure them.\n\t */\n\tchildAtRow(width: number, row: number): { component: Component; row: number; height: number } | undefined {\n\t\tif (row < 0) return undefined;\n\t\tconst mouseChildren =\n\t\t\tthis.mouseLayout?.width === width\n\t\t\t\t? this.mouseLayout.children\n\t\t\t\t: this.children.map((component) => ({ component, height: component.render(width).length }));\n\t\tlet childY = 0;\n\t\tfor (const { component, height } of mouseChildren) {\n\t\t\tif (row >= childY && row < childY + height) return { component, row: row - childY, height };\n\t\t\tchildY += height;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined {\n\t\tif (event.y < 0 || event.y >= event.height) return undefined;\n\t\tconst hit = this.childAtRow(event.width, event.y);\n\t\tif (!hit) return undefined;\n\t\tconst result = dispatchMouseEvent(hit.component, { ...event, y: hit.row, height: hit.height });\n\t\tif (result?.focus && (this as Component).handleInput) return { ...result, focusTarget: this };\n\t\treturn result;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst mouseChildren: Array<{ component: Component; height: number }> = [];\n\t\tfor (const child of this.children) {\n\t\t\tconst childLines = child.render(width);\n\t\t\tmouseChildren.push({ component: child, height: childLines.length });\n\t\t\tfor (const line of childLines) {\n\t\t\t\tlines.push(line);\n\t\t\t}\n\t\t}\n\t\tthis.mouseLayout = { width, children: mouseChildren };\n\t\treturn lines;\n\t}\n}\n\n/**\n * TUI - Main class for managing terminal UI with differential rendering\n */\nconst SEGMENT_RESET = \"\\x1b[0m\\x1b]8;;\\x07\";\n/**\n * Between the segments of a composited line that holds key hints: styles end there, and so does a hint, whose part\n * beyond a box drawn over it is re-opened with the rest of its styles. The renderer removes the hint marker before\n * writing the line.\n */\nconst HINT_SEGMENT_RESET = SEGMENT_RESET + HINT_CLOSE;\n\n/** Composite overlay content into a terminal line at a fixed column. */\nexport function compositeTuiLine(\n\tbaseLine: string,\n\toverlayLine: string,\n\tstartCol: number,\n\toverlayWidth: number,\n\ttotalWidth: number,\n): string {\n\tif (isImageLine(baseLine)) return baseLine;\n\n\tconst afterStart = startCol + overlayWidth;\n\tconst base = extractSegments(baseLine, startCol, afterStart, totalWidth - afterStart, true);\n\tconst boundary =\n\t\tbaseLine.includes(HINT_OPEN) || overlayLine.includes(HINT_OPEN) ? HINT_SEGMENT_RESET : SEGMENT_RESET;\n\tconst overlay = sliceWithWidth(overlayLine, 0, overlayWidth, true);\n\tconst beforePad = Math.max(0, startCol - base.beforeWidth);\n\tconst overlayPad = Math.max(0, overlayWidth - overlay.width);\n\tconst actualBeforeWidth = Math.max(startCol, base.beforeWidth);\n\tconst actualOverlayWidth = Math.max(overlayWidth, overlay.width);\n\tconst afterTarget = Math.max(0, totalWidth - actualBeforeWidth - actualOverlayWidth);\n\tconst afterPad = Math.max(0, afterTarget - base.afterWidth);\n\tconst result =\n\t\tbase.before +\n\t\t\" \".repeat(beforePad) +\n\t\tboundary +\n\t\toverlay.text +\n\t\t\" \".repeat(overlayPad) +\n\t\tboundary +\n\t\tbase.after +\n\t\t\" \".repeat(afterPad);\n\n\treturn visibleWidth(result) <= totalWidth ? result : sliceByColumn(result, 0, totalWidth, true);\n}\n\nexport type TuiMode = \"regular\" | \"fullscreen\";\n\nexport interface TuiStopOptions {\n\t/** Leave renderer output in place for another TUI taking over the same terminal. */\n\tpreserveScreen?: boolean;\n\twriteInSlices?: boolean;\n}\n\nexport interface TUI extends Component {\n\treadonly mode: TuiMode;\n\tchildren: Component[];\n\tterminal: Terminal;\n\tonDebug?: () => void;\n\treadonly fullRedraws: number;\n\taddChild(component: Component): void;\n\tremoveChild(component: Component): void;\n\tclear(): void;\n\tgetShowHardwareCursor(): boolean;\n\tsetShowHardwareCursor(enabled: boolean): void;\n\tgetClearOnShrink(): boolean;\n\tsetClearOnShrink(enabled: boolean): void;\n\tsetFocus(component: Component | null): void;\n\tshowOverlay(component: Component, options?: OverlayOptions): OverlayHandle;\n\thideOverlay(): void;\n\thasOverlay(): boolean;\n\tstart(): void;\n\tstop(options?: TuiStopOptions): void;\n\twhenStopped(): Promise<void>;\n\trenderNow(force?: boolean): void;\n\trequestRender(force?: boolean): void;\n\t/**\n\t * Render on the next tick, ahead of the frame pacing `requestRender` applies: for a frame that answers the user's own\n\t * keystroke, as the renderer does after it routes a key.\n\t */\n\trequestImmediateRender(): void;\n\taddInputListener(listener: TuiInputListener): () => void;\n\tremoveInputListener(listener: TuiInputListener): void;\n\t/** Run the slash command a clicked hint names, such as `/tasks` in `/tasks to manage`. */\n\tsetHintCommandHandler?(handler: ((command: string) => void) | undefined): void;\n\tonTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;\n\tsetTerminalColorSchemeNotifications(enabled: boolean): void;\n\tqueryTerminalColors(options: {\n\t\ttimeoutMs: number;\n\t\tonLateReply?: (colors: TerminalColors) => void;\n\t}): Promise<TerminalColors>;\n}\n\nexport const VIEWPORT_TUI = Symbol.for(\"@bastani/atomic-tui/viewport\");\n\nexport interface ViewportTUI extends TUI {\n\treadonly [VIEWPORT_TUI]: true;\n\tsetLayoutRoot(component: Component | undefined): void;\n}\n\nexport function isViewportTUI(tui: TUI): tui is ViewportTUI {\n\treturn (tui as Partial<ViewportTUI>)[VIEWPORT_TUI] === true;\n}\n\nexport abstract class TuiBase extends Container implements TUI {\n\tabstract readonly mode: TuiMode;\n\tpublic terminal: Terminal;\n\tprivate focusedComponent: Component | null = null;\n\tprivate inputListeners = new Set<TuiInputListener>();\n\tprivate hintCommandHandler: ((command: string) => void) | undefined;\n\n\t/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */\n\tpublic onDebug?: () => void;\n\tprivate renderRequested = false;\n\tprivate immediateRenderScheduled = false;\n\tprivate renderTimer: NodeJS.Timeout | undefined;\n\tprivate lastRenderAt = 0;\n\tprivate static readonly MIN_RENDER_INTERVAL_MS = 16;\n\tprivate showHardwareCursor = false;\n\tprivate clearOnShrink = false;\n\tprotected fullRedrawCount = 0;\n\tprotected stopped = false;\n\tprotected stopOutput: Promise<void> = Promise.resolve();\n\t/**\n\t * Color queries waiting for their DA1 reply, oldest first. Terminals answer in order, so color\n\t * replies belong to the oldest one. Queries stay here after a timeout to collect late replies.\n\t */\n\tprivate pendingTerminalColorQueries: PendingTerminalColorQuery[] = [];\n\tprivate terminalColorSchemeListeners = new Set<(scheme: TerminalColorScheme) => void>();\n\tprivate terminalColorSchemeNotificationsEnabled = false;\n\t/** Directory for debug/crash logs. When undefined, debug logging is disabled and crash dumps fall back to the OS temp directory. */\n\tprotected readonly logDirectory: string | undefined;\n\n\t// Overlay stack for modal components rendered on top of base content\n\tprivate focusOrderCounter = 0;\n\tprivate overlayStack: OverlayStackEntry[] = [];\n\tprivate renderedOverlayLayouts: RenderedOverlayLayout[] = [];\n\n\tget hasOverlayEntries(): boolean {\n\t\treturn this.overlayStack.length > 0;\n\t}\n\tprivate overlayFocusRestore: OverlayFocusRestoreState = { status: \"inactive\" };\n\n\tconstructor(terminal: Terminal, showHardwareCursor?: boolean, logDirectory?: string) {\n\t\tsuper();\n\t\tthis.terminal = terminal;\n\t\tthis.logDirectory = logDirectory;\n\t\tif (showHardwareCursor !== undefined) {\n\t\t\tthis.showHardwareCursor = showHardwareCursor;\n\t\t}\n\t}\n\n\tprotected abstract doRender(): void;\n\n\tprotected resetRenderState(): void {}\n\n\tprotected beforeTerminalStart(): void {}\n\n\tprotected afterTerminalStart(): void {}\n\n\tprotected beforeTerminalStop(_options: TuiStopOptions): void {}\n\n\tprotected afterTerminalStop(_options: TuiStopOptions): void {}\n\n\t/** Mode resets written before the terminal's own resets when the process exits without stop(). */\n\tprotected getExitRestorePrefix(): string {\n\t\treturn `${this.terminalColorSchemeNotificationsEnabled ? \"\\x1b[?2031l\" : \"\"}\\x1b[?25h`;\n\t}\n\n\t/** Mode resets written after the terminal's own resets when the process exits without stop(). */\n\tprotected getExitRestoreSuffix(): string {\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Last-resort restore for exit paths that skip stop(), e.g. a direct process.exit() (#11170).\n\t * Hard kills and native aborts run no JavaScript and cannot be covered.\n\t */\n\tprivate readonly exitRestoreHandler = (): void => {\n\t\tif (this.stopped) return;\n\t\ttry {\n\t\t\tthis.terminal.restoreOnExit?.(this.getExitRestorePrefix(), this.getExitRestoreSuffix());\n\t\t} catch {\n\t\t\t// Never throw from an exit handler.\n\t\t}\n\t};\n\n\tget fullRedraws(): number {\n\t\treturn this.fullRedrawCount;\n\t}\n\n\tgetShowHardwareCursor(): boolean {\n\t\treturn this.showHardwareCursor;\n\t}\n\n\tsetShowHardwareCursor(enabled: boolean): void {\n\t\tif (this.showHardwareCursor === enabled) return;\n\t\tthis.showHardwareCursor = enabled;\n\t\tif (!enabled) {\n\t\t\tthis.hideTerminalCursor();\n\t\t}\n\t\tthis.requestRender();\n\t}\n\n\tgetClearOnShrink(): boolean {\n\t\treturn this.clearOnShrink;\n\t}\n\n\t/**\n\t * Set whether to trigger full re-render when content shrinks.\n\t * When true, empty rows are cleared when content shrinks.\n\t * When false (default), empty rows remain (reduces redraws on slower terminals).\n\t */\n\tsetClearOnShrink(enabled: boolean): void {\n\t\tthis.clearOnShrink = enabled;\n\t}\n\n\tgetFocusedComponent(): Component | null {\n\t\treturn this.focusedComponent;\n\t}\n\n\tsetFocus(component: Component | null): void {\n\t\tthis.setFocusInternal({ component, overlayFocusRestore: \"clear\" });\n\t}\n\n\tprivate setFocusInternal({\n\t\tcomponent,\n\t\toverlayFocusRestore,\n\t}: {\n\t\tcomponent: Component | null;\n\t\toverlayFocusRestore: OverlayFocusRestorePolicy;\n\t}): void {\n\t\tconst previousFocus = this.focusedComponent;\n\t\tlet nextFocus = component;\n\t\tconst previousFocusedOverlay = previousFocus\n\t\t\t? this.overlayStack.find((entry) => entry.component === previousFocus && this.isOverlayVisible(entry))\n\t\t\t: undefined;\n\t\tconst nextFocusIsOverlay = nextFocus ? this.overlayStack.some((entry) => entry.component === nextFocus) : false;\n\t\tconst restoreState = this.getVisibleOverlayFocusRestore();\n\t\tif (nextFocus && !nextFocusIsOverlay) {\n\t\t\tif (restoreState.status === \"blocked\" && restoreState.blockedBy === previousFocus) {\n\t\t\t\tif (restoreState.resume.status === \"focus-target\" || !this.isComponentMounted(restoreState.blockedBy)) {\n\t\t\t\t\tnextFocus = this.resolveBlockedOverlayFocusResume(restoreState);\n\t\t\t\t} else {\n\t\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\t\toverlay: restoreState.overlay,\n\t\t\t\t\t\tblockedBy: nextFocus,\n\t\t\t\t\t\tresume: restoreState.resume,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tpreviousFocusedOverlay &&\n\t\t\t\trestoreState.status !== \"inactive\" &&\n\t\t\t\trestoreState.overlay === previousFocusedOverlay &&\n\t\t\t\t!this.isOverlayFocusAncestor(previousFocusedOverlay, nextFocus)\n\t\t\t) {\n\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\toverlay: previousFocusedOverlay,\n\t\t\t\t\tblockedBy: nextFocus,\n\t\t\t\t\tresume: { status: \"restore-overlay\" },\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (nextFocus === null) {\n\t\t\tif (restoreState.status === \"blocked\" && restoreState.blockedBy === previousFocus) {\n\t\t\t\tnextFocus = this.resolveBlockedOverlayFocusResume(restoreState);\n\t\t\t} else if (overlayFocusRestore === \"clear\") {\n\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t}\n\t\t}\n\n\t\tif (isFocusable(this.focusedComponent)) {\n\t\t\tthis.focusedComponent.focused = false;\n\t\t}\n\n\t\tthis.focusedComponent = nextFocus;\n\n\t\tif (isFocusable(nextFocus)) {\n\t\t\tnextFocus.focused = true;\n\t\t}\n\n\t\tconst focusedOverlay = nextFocus\n\t\t\t? this.overlayStack.find((entry) => entry.component === nextFocus && this.isOverlayVisible(entry))\n\t\t\t: undefined;\n\t\tif (focusedOverlay) {\n\t\t\tthis.overlayFocusRestore = { status: \"eligible\", overlay: focusedOverlay };\n\t\t}\n\t}\n\n\tprivate clearOverlayFocusRestore(): void {\n\t\tthis.overlayFocusRestore = { status: \"inactive\" };\n\t}\n\n\tprivate clearOverlayFocusRestoreFor(overlay: OverlayStackEntry): void {\n\t\tif (this.overlayFocusRestore.status !== \"inactive\" && this.overlayFocusRestore.overlay === overlay) {\n\t\t\tthis.clearOverlayFocusRestore();\n\t\t}\n\t}\n\n\tprivate resolveBlockedOverlayFocusResume(restoreState: BlockedOverlayFocusRestoreState): Component | null {\n\t\tif (restoreState.resume.status === \"restore-overlay\") return restoreState.overlay.component;\n\t\tthis.clearOverlayFocusRestore();\n\t\treturn restoreState.resume.target;\n\t}\n\n\tprivate getVisibleOverlayFocusRestore(): OverlayFocusRestoreState {\n\t\tconst restoreState = this.overlayFocusRestore;\n\t\tif (restoreState.status === \"inactive\") return restoreState;\n\t\tif (!this.overlayStack.includes(restoreState.overlay) || !this.isOverlayVisible(restoreState.overlay)) {\n\t\t\treturn { status: \"inactive\" };\n\t\t}\n\t\treturn restoreState;\n\t}\n\n\tprivate isOverlayFocusAncestor(entry: OverlayStackEntry, component: Component): boolean {\n\t\tconst visited = new Set<Component>();\n\t\tlet current = entry.preFocus;\n\t\twhile (current && !visited.has(current)) {\n\t\t\tvisited.add(current);\n\t\t\tif (current === component) return true;\n\t\t\tcurrent = this.overlayStack.find((overlay) => overlay.component === current)?.preFocus ?? null;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate retargetOverlayPreFocus(removed: OverlayStackEntry): void {\n\t\tfor (const overlay of this.overlayStack) {\n\t\t\tif (overlay !== removed && overlay.preFocus === removed.component) {\n\t\t\t\toverlay.preFocus = removed.preFocus;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getMountedRoots(): readonly Component[] {\n\t\treturn this.children;\n\t}\n\n\tprivate isComponentMounted(component: Component): boolean {\n\t\treturn this.getMountedRoots().some((child) => this.containsComponent(child, component));\n\t}\n\n\tprivate containsComponent(root: Component, target: Component): boolean {\n\t\tif (root === target) return true;\n\t\tif (!(root instanceof Container)) return false;\n\t\treturn root.children.some((child) => this.containsComponent(child, target));\n\t}\n\n\t/**\n\t * Show an overlay component with configurable positioning and sizing.\n\t * Returns a handle to control the overlay's visibility.\n\t */\n\tshowOverlay(component: Component, options?: OverlayOptions): OverlayHandle {\n\t\tconst entry: OverlayStackEntry = {\n\t\t\tcomponent,\n\t\t\t...(options === undefined ? {} : { options }),\n\t\t\tpreFocus: this.focusedComponent,\n\t\t\thidden: false,\n\t\t\tfocusOrder: ++this.focusOrderCounter,\n\t\t};\n\t\tthis.overlayStack.push(entry);\n\t\t// Only focus if overlay is actually visible\n\t\tif (!options?.nonCapturing && this.isOverlayVisible(entry)) {\n\t\t\tthis.setFocus(component);\n\t\t}\n\t\tthis.hideTerminalCursor();\n\t\tthis.requestRender();\n\n\t\t// Return handle for controlling this overlay\n\t\treturn {\n\t\t\thide: () => {\n\t\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\t\tthis.retargetOverlayPreFocus(entry);\n\t\t\t\t\tthis.overlayStack.splice(index, 1);\n\t\t\t\t\t// Restore focus if this overlay had focus\n\t\t\t\t\tif (this.focusedComponent === component) {\n\t\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\t\tthis.setFocus(topVisible?.component ?? entry.preFocus);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.overlayStack.length === 0) this.hideTerminalCursor();\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetHidden: (hidden: boolean) => {\n\t\t\t\tif (entry.hidden === hidden) return;\n\t\t\t\tentry.hidden = hidden;\n\t\t\t\t// Update focus when hiding/showing\n\t\t\t\tif (hidden) {\n\t\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\t\t// If this overlay had focus, move focus to next visible or preFocus\n\t\t\t\t\tif (this.focusedComponent === component) {\n\t\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\t\tthis.setFocus(topVisible?.component ?? entry.preFocus);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Restore focus to this overlay when showing (if it's actually visible)\n\t\t\t\t\tif (!options?.nonCapturing && this.isOverlayVisible(entry)) {\n\t\t\t\t\t\tentry.focusOrder = ++this.focusOrderCounter;\n\t\t\t\t\t\tthis.setFocus(component);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tisHidden: () => entry.hidden,\n\t\t\tfocus: () => {\n\t\t\t\tif (!this.overlayStack.includes(entry) || !this.isOverlayVisible(entry)) return;\n\t\t\t\tentry.focusOrder = ++this.focusOrderCounter;\n\t\t\t\tthis.setFocus(component);\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tunfocus: (unfocusOptions) => {\n\t\t\t\tconst isFocused = this.focusedComponent === component;\n\t\t\t\tconst restoreState = this.overlayFocusRestore;\n\t\t\t\tconst hasPendingRestore = restoreState.status !== \"inactive\" && restoreState.overlay === entry;\n\t\t\t\tif (!isFocused && !hasPendingRestore) return;\n\t\t\t\tif (\n\t\t\t\t\trestoreState.status === \"blocked\" &&\n\t\t\t\t\trestoreState.overlay === entry &&\n\t\t\t\t\tthis.focusedComponent === restoreState.blockedBy\n\t\t\t\t) {\n\t\t\t\t\tif (unfocusOptions) {\n\t\t\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\t\t\toverlay: entry,\n\t\t\t\t\t\t\tblockedBy: restoreState.blockedBy,\n\t\t\t\t\t\t\tresume: { status: \"focus-target\", target: unfocusOptions.target },\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t\t\t}\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\tif (isFocused || unfocusOptions) {\n\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\tconst fallbackTarget = topVisible && topVisible !== entry ? topVisible.component : entry.preFocus;\n\t\t\t\t\tthis.setFocus(unfocusOptions ? unfocusOptions.target : fallbackTarget);\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tisFocused: () => this.focusedComponent === component,\n\t\t\tgetBounds: () => {\n\t\t\t\tif (!this.overlayStack.includes(entry) || !this.isOverlayVisible(entry) || !entry.bounds) return undefined;\n\t\t\t\treturn { ...entry.bounds };\n\t\t\t},\n\t\t};\n\t}\n\n\t/** Hide the topmost overlay and restore previous focus. */\n\thideOverlay(): void {\n\t\tconst overlay = this.overlayStack[this.overlayStack.length - 1];\n\t\tif (!overlay) return;\n\t\tthis.clearOverlayFocusRestoreFor(overlay);\n\t\tthis.retargetOverlayPreFocus(overlay);\n\t\tthis.overlayStack.pop();\n\t\tif (this.focusedComponent === overlay.component) {\n\t\t\t// Find topmost visible overlay, or fall back to preFocus\n\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\tthis.setFocus(topVisible?.component ?? overlay.preFocus);\n\t\t}\n\t\tif (this.overlayStack.length === 0) this.hideTerminalCursor();\n\t\tthis.requestRender();\n\t}\n\n\t/** Hide the cursor while running. After stop(), the shell owns the cursor and it must stay visible. */\n\tprivate hideTerminalCursor(): void {\n\t\tif (!this.stopped) this.terminal.hideCursor();\n\t}\n\n\t/** Check if there are any visible overlays */\n\thasOverlay(): boolean {\n\t\treturn this.overlayStack.some((o) => this.isOverlayVisible(o));\n\t}\n\n\t/** Check if the focused component is a visible overlay */\n\tprotected isOverlayFocused(): boolean {\n\t\treturn this.overlayStack.some(\n\t\t\t(entry) => entry.component === this.focusedComponent && this.isOverlayVisible(entry),\n\t\t);\n\t}\n\n\t/** Keep overlay containers as keyboard focus owners when a nested control is clicked. */\n\tprotected resolveMouseFocusTarget(component: Component): Component {\n\t\tfor (let index = this.overlayStack.length - 1; index >= 0; index--) {\n\t\t\tconst overlay = this.overlayStack[index]!;\n\t\t\tif (this.isOverlayVisible(overlay) && this.containsComponent(overlay.component, component)) {\n\t\t\t\treturn overlay.component;\n\t\t\t}\n\t\t}\n\t\treturn component;\n\t}\n\n\t/** Dispatch to the visually topmost overlay under the pointer. */\n\t/** The topmost overlay the last frame drew at screen cell `x`, `y`, and the rectangle it was drawn in. */\n\tprotected overlayAt(\n\t\tx: number,\n\t\ty: number,\n\t): { component: Component; row: number; col: number; width: number; height: number } | undefined {\n\t\tfor (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {\n\t\t\tconst layout = this.renderedOverlayLayouts[index]!;\n\t\t\tif (x >= layout.col && x < layout.col + layout.width && y >= layout.row && y < layout.row + layout.height) {\n\t\t\t\tconst { row, col, width, height } = layout;\n\t\t\t\treturn { component: layout.entry.component, row, col, width, height };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprotected dispatchMouseToOverlay(event: TuiMouseEvent): { hit: boolean; result?: TuiMouseDispatchResult } {\n\t\tfor (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {\n\t\t\tconst layout = this.renderedOverlayLayouts[index]!;\n\t\t\tif (\n\t\t\t\tevent.screenX < layout.col ||\n\t\t\t\tevent.screenX >= layout.col + layout.width ||\n\t\t\t\tevent.screenY < layout.row ||\n\t\t\t\tevent.screenY >= layout.row + layout.height\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst result = dispatchMouseEvent(layout.entry.component, {\n\t\t\t\t...event,\n\t\t\t\tx: event.screenX - layout.col,\n\t\t\t\ty: event.screenY - layout.row,\n\t\t\t\twidth: layout.width,\n\t\t\t\theight: layout.height,\n\t\t\t});\n\t\t\treturn result\n\t\t\t\t? {\n\t\t\t\t\t\thit: true,\n\t\t\t\t\t\tresult: result.focus ? { ...result, focusTarget: layout.entry.component } : result,\n\t\t\t\t\t}\n\t\t\t\t: { hit: true };\n\t\t}\n\t\treturn { hit: false };\n\t}\n\n\t/** Check if an overlay entry is currently visible */\n\tprivate isOverlayVisible(entry: OverlayStackEntry): boolean {\n\t\tif (entry.hidden) return false;\n\t\tif (entry.options?.visible) {\n\t\t\treturn entry.options.visible(this.terminal.columns, this.terminal.rows);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Find the visual-frontmost visible capturing overlay, if any */\n\tprivate getTopmostVisibleOverlay(): OverlayStackEntry | undefined {\n\t\tlet topmost: OverlayStackEntry | undefined;\n\t\tfor (const overlay of this.overlayStack) {\n\t\t\tif (overlay.options?.nonCapturing || !this.isOverlayVisible(overlay)) continue;\n\t\t\tif (!topmost || overlay.focusOrder > topmost.focusOrder) {\n\t\t\t\ttopmost = overlay;\n\t\t\t}\n\t\t}\n\t\treturn topmost;\n\t}\n\n\toverride invalidate(): void {\n\t\tfor (const root of this.getMountedRoots()) root.invalidate();\n\t\tfor (const overlay of this.overlayStack) overlay.component.invalidate();\n\t}\n\n\tstart(): void {\n\t\tthis.stopped = false;\n\t\tprocess.off(\"exit\", this.exitRestoreHandler);\n\t\tprocess.on(\"exit\", this.exitRestoreHandler);\n\t\tthis.beforeTerminalStart();\n\t\tthis.terminal.start(\n\t\t\t(data) => this.handleTerminalInput(data),\n\t\t\t() => this.requestRender(),\n\t\t);\n\t\tthis.afterTerminalStart();\n\t\tthis.terminal.hideCursor();\n\t\tif (this.terminalColorSchemeNotificationsEnabled) {\n\t\t\tthis.terminal.write(\"\\x1b[?2031h\");\n\t\t}\n\t\tthis.queryCellSize();\n\t\tthis.requestRender();\n\t}\n\n\taddInputListener(listener: TuiInputListener): () => void {\n\t\tthis.inputListeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.inputListeners.delete(listener);\n\t\t};\n\t}\n\n\tremoveInputListener(listener: TuiInputListener): void {\n\t\tthis.inputListeners.delete(listener);\n\t}\n\n\tsetHintCommandHandler(handler: ((command: string) => void) | undefined): void {\n\t\tthis.hintCommandHandler = handler;\n\t}\n\n\t/**\n\t * Run what a clicked key hint names: its key goes through the input path as if it were pressed, so it acts exactly\n\t * as the key does, confirmations included; a slash command goes to the command handler.\n\t */\n\tprotected runHintAction(action: HintAction): void {\n\t\tif (action.kind === \"command\") {\n\t\t\tthis.hintCommandHandler?.(action.command);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tconst data = hintKeyInput(action);\n\t\tif (data !== undefined) runAsHintActivation(() => this.handleTerminalInput(data));\n\t}\n\n\t/**\n\t * Whether keys reach what is drawn at screen cell `x`, `y`: the overlay that holds the keyboard when one does, and\n\t * otherwise what is drawn outside the overlays.\n\t */\n\tprotected takesKeysAt(x: number, y: number): boolean {\n\t\tconst focused = this.focusedComponent;\n\t\tlet keyOverlay = focused\n\t\t\t? this.overlayStack.find((entry) => entry.component === focused && this.isOverlayVisible(entry))?.component\n\t\t\t: undefined;\n\t\tif (keyOverlay === undefined) {\n\t\t\tconst restore = this.getVisibleOverlayFocusRestore();\n\t\t\tif (restore.status === \"eligible\") keyOverlay = restore.overlay.component;\n\t\t}\n\t\tconst drawn = this.overlayAt(x, y);\n\t\treturn drawn === undefined ? keyOverlay === undefined : drawn.component === keyOverlay;\n\t}\n\n\tonTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void {\n\t\tthis.terminalColorSchemeListeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.terminalColorSchemeListeners.delete(listener);\n\t\t};\n\t}\n\n\tsetTerminalColorSchemeNotifications(enabled: boolean): void {\n\t\tif (this.terminalColorSchemeNotificationsEnabled === enabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis.terminalColorSchemeNotificationsEnabled = enabled;\n\t\tif (!this.stopped) {\n\t\t\tthis.terminal.write(enabled ? \"\\x1b[?2031h\" : \"\\x1b[?2031l\");\n\t\t}\n\t}\n\n\tprivate queryCellSize(): void {\n\t\t// Only query if terminal supports images (cell size is only used for image rendering)\n\t\tif (!getCapabilities().images) {\n\t\t\treturn;\n\t\t}\n\t\t// Query terminal for cell size in pixels: CSI 16 t\n\t\t// Response format: CSI 6 ; height ; width t\n\t\tthis.terminal.write(\"\\x1b[16t\");\n\t}\n\n\tstop(options: TuiStopOptions = {}): void {\n\t\tthis.stopped = true;\n\t\tprocess.off(\"exit\", this.exitRestoreHandler);\n\t\tthis.cancelRenderTimer();\n\t\tif (this.terminalColorSchemeNotificationsEnabled) {\n\t\t\tthis.terminal.write(\"\\x1b[?2031l\");\n\t\t}\n\t\tthis.beforeTerminalStop(options);\n\t\tthis.terminal.showCursor();\n\t\tthis.terminal.stop();\n\t\tthis.afterTerminalStop(options);\n\t}\n\n\twhenStopped(): Promise<void> {\n\t\treturn this.stopOutput;\n\t}\n\n\trenderNow(force = false): void {\n\t\tif (force) this.resetRenderState();\n\t\tthis.renderRequested = false;\n\t\tthis.cancelRenderTimer();\n\t\tthis.lastRenderAt = performance.now();\n\t\tthis.doRender();\n\t}\n\n\trequestRender(force = false): void {\n\t\tif (force) {\n\t\t\tthis.resetRenderState();\n\t\t\tthis.requestImmediateRender();\n\t\t\treturn;\n\t\t}\n\t\tif (this.renderRequested) return;\n\t\tthis.renderRequested = true;\n\t\tprocess.nextTick(() => this.scheduleRender());\n\t}\n\n\trequestImmediateRender(): void {\n\t\tthis.cancelRenderTimer();\n\t\tthis.renderRequested = true;\n\t\tif (this.immediateRenderScheduled) return;\n\t\tthis.immediateRenderScheduled = true;\n\t\tprocess.nextTick(() => {\n\t\t\tthis.immediateRenderScheduled = false;\n\t\t\tif (this.stopped || !this.renderRequested) return;\n\t\t\t// A previously queued scheduleRender() can create a timer before this\n\t\t\t// callback runs. User input must preempt that throttled frame.\n\t\t\tthis.cancelRenderTimer();\n\t\t\tthis.renderRequested = false;\n\t\t\tthis.lastRenderAt = performance.now();\n\t\t\tthis.doRender();\n\t\t});\n\t}\n\n\tprivate cancelRenderTimer(): void {\n\t\tif (!this.renderTimer) return;\n\t\tclearTimeout(this.renderTimer);\n\t\tthis.renderTimer = undefined;\n\t}\n\n\tprivate scheduleRender(): void {\n\t\tif (this.stopped || this.renderTimer || !this.renderRequested) {\n\t\t\treturn;\n\t\t}\n\t\tconst elapsed = performance.now() - this.lastRenderAt;\n\t\tconst delay = Math.max(0, TuiBase.MIN_RENDER_INTERVAL_MS - elapsed);\n\t\tthis.renderTimer = setTimeout(() => {\n\t\t\tthis.renderTimer = undefined;\n\t\t\tif (this.stopped || !this.renderRequested) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.renderRequested = false;\n\t\t\tthis.lastRenderAt = performance.now();\n\t\t\tthis.doRender();\n\t\t\tif (this.renderRequested) {\n\t\t\t\tthis.scheduleRender();\n\t\t\t}\n\t\t}, delay);\n\t}\n\n\tprivate handleTerminalInput(data: string): void {\n\t\tif (this.consumeTerminalColorResponse(data)) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.consumeTerminalColorSchemeReport(data)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.inputListeners.size > 0) {\n\t\t\tlet current = data;\n\t\t\tfor (const listener of this.inputListeners) {\n\t\t\t\tconst result = listener(current);\n\t\t\t\tif (result?.consume) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (result?.data !== undefined) {\n\t\t\t\t\tcurrent = result.data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (current.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdata = current;\n\t\t}\n\n\t\t// Consume terminal cell size responses without blocking unrelated input.\n\t\tif (this.consumeCellSizeResponse(data)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Global debug key handler (Shift+Ctrl+D)\n\t\tif (matchesKey(data, \"shift+ctrl+d\") && this.onDebug) {\n\t\t\tthis.onDebug();\n\t\t\treturn;\n\t\t}\n\n\t\t// If focused component is an overlay, verify it's still visible\n\t\t// (visibility can change due to terminal resize or visible() callback)\n\t\tconst focusedOverlay = this.overlayStack.find((o) => o.component === this.focusedComponent);\n\t\tif (focusedOverlay && !this.isOverlayVisible(focusedOverlay)) {\n\t\t\t// Focused overlay is no longer visible, redirect to topmost visible overlay\n\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\tif (topVisible) {\n\t\t\t\tthis.setFocus(topVisible.component);\n\t\t\t} else {\n\t\t\t\tthis.setFocusInternal({ component: focusedOverlay.preFocus, overlayFocusRestore: \"preserve\" });\n\t\t\t}\n\t\t}\n\n\t\tconst focusIsOverlay = this.overlayStack.some((o) => o.component === this.focusedComponent);\n\t\tif (!focusIsOverlay) {\n\t\t\tconst restoreState = this.getVisibleOverlayFocusRestore();\n\t\t\tif (restoreState.status === \"eligible\") {\n\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t} else if (restoreState.status === \"blocked\" && restoreState.blockedBy !== this.focusedComponent) {\n\t\t\t\tif (restoreState.resume.status === \"restore-overlay\") {\n\t\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t\t} else {\n\t\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t\t\tthis.setFocus(restoreState.resume.target);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Pass input to focused component (including Ctrl+C)\n\t\t// The focused component can decide how to handle Ctrl+C\n\t\tif (this.focusedComponent?.handleInput) {\n\t\t\t// Filter out key release events unless component opts in\n\t\t\tif (isKeyRelease(data) && !this.focusedComponent.wantsKeyRelease) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst answer: unknown = this.focusedComponent.handleInput(data);\n\t\t\t// Keyboard input is latency-sensitive. Avoid the throttled timer path,\n\t\t\t// where even setTimeout(0) can take a full 16 ms tick on Windows.\n\t\t\t// A component that answers asynchronously, such as a view another process draws, shows the key only once\n\t\t\t// its answer arrives: painting before then would repaint the frame the key has not reached yet.\n\t\t\tif (answer instanceof Promise) {\n\t\t\t\tconst repaint = (): void => this.requestImmediateRender();\n\t\t\t\tvoid answer.then(repaint, repaint);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.requestImmediateRender();\n\t\t}\n\t}\n\n\tprivate consumeTerminalColorResponse(data: string): boolean {\n\t\tconst query = this.pendingTerminalColorQueries[0];\n\t\tif (!query) {\n\t\t\treturn false;\n\t\t}\n\t\tif (DEVICE_ATTRIBUTES_RESPONSE_PATTERN.test(data)) {\n\t\t\tthis.pendingTerminalColorQueries.shift();\n\t\t\tthis.completeTerminalColorQuery(query);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst response = parseOscColorResponse(data);\n\t\tif (!response) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { target, rgb } = response;\n\t\tconst key = String(target);\n\t\tif (!query.deliver || query.replied.has(key)) {\n\t\t\treturn true;\n\t\t}\n\t\tquery.replied.add(key);\n\t\tif (target === \"foreground\") {\n\t\t\tquery.foreground = rgb;\n\t\t} else if (target === \"background\") {\n\t\t\tquery.background = rgb;\n\t\t} else if (target < TERMINAL_PALETTE_SIZE) {\n\t\t\tquery.palette[target] = rgb;\n\t\t}\n\t\tif (query.replied.size === TERMINAL_COLOR_REPLY_COUNT) {\n\t\t\tthis.completeTerminalColorQuery(query);\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate terminalColorQueryResult(query: PendingTerminalColorQuery): TerminalColors {\n\t\tconst palette = query.palette.every((color) => color !== undefined) ? (query.palette as RgbColor[]) : undefined;\n\t\treturn { foreground: query.foreground, background: query.background, palette };\n\t}\n\n\tprivate completeTerminalColorQuery(query: PendingTerminalColorQuery): void {\n\t\tconst deliver = query.deliver;\n\t\tquery.deliver = undefined;\n\t\tclearTimeout(query.timer);\n\t\tdeliver?.(this.terminalColorQueryResult(query));\n\t}\n\n\tprivate consumeTerminalColorSchemeReport(data: string): boolean {\n\t\tconst scheme = parseTerminalColorSchemeReport(data);\n\t\tif (!scheme) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const listener of this.terminalColorSchemeListeners) {\n\t\t\tlistener(scheme);\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate consumeCellSizeResponse(data: string): boolean {\n\t\t// Response format: ESC [ 6 ; height ; width t\n\t\tconst match = data.match(/^\\x1b\\[6;(\\d+);(\\d+)t$/);\n\t\tif (!match) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst heightPx = parseInt(match[1], 10);\n\t\tconst widthPx = parseInt(match[2], 10);\n\t\tif (heightPx <= 0 || widthPx <= 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tsetCellDimensions({ widthPx, heightPx });\n\t\t// Invalidate all components so images re-render with correct dimensions.\n\t\tthis.invalidate();\n\t\tthis.requestRender();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve overlay layout from options.\n\t * Returns { width, row, col, maxHeight } for rendering.\n\t */\n\tprivate resolveOverlayLayout(\n\t\toptions: OverlayOptions | undefined,\n\t\toverlayHeight: number,\n\t\ttermWidth: number,\n\t\ttermHeight: number,\n\t): { width: number; row: number; col: number; maxHeight: number | undefined } {\n\t\tconst opt = options ?? {};\n\n\t\t// Parse margin (clamp to non-negative)\n\t\tconst margin =\n\t\t\ttypeof opt.margin === \"number\"\n\t\t\t\t? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }\n\t\t\t\t: (opt.margin ?? {});\n\t\tconst marginTop = Math.max(0, margin.top ?? 0);\n\t\tconst marginRight = Math.max(0, margin.right ?? 0);\n\t\tconst marginBottom = Math.max(0, margin.bottom ?? 0);\n\t\tconst marginLeft = Math.max(0, margin.left ?? 0);\n\n\t\t// Available space after margins\n\t\tconst availWidth = Math.max(1, termWidth - marginLeft - marginRight);\n\t\tconst availHeight = Math.max(1, termHeight - marginTop - marginBottom);\n\n\t\t// === Resolve width ===\n\t\tlet width = parseSizeValue(opt.width, termWidth) ?? Math.min(80, availWidth);\n\t\t// Apply minWidth\n\t\tif (opt.minWidth !== undefined) {\n\t\t\twidth = Math.max(width, opt.minWidth);\n\t\t}\n\t\t// Clamp to available space\n\t\twidth = Math.max(1, Math.min(width, availWidth));\n\n\t\t// === Resolve maxHeight ===\n\t\tlet maxHeight = parseSizeValue(opt.maxHeight, termHeight);\n\t\t// Clamp to available space\n\t\tif (maxHeight !== undefined) {\n\t\t\tmaxHeight = Math.max(1, Math.min(maxHeight, availHeight));\n\t\t}\n\n\t\t// Effective overlay height (may be clamped by maxHeight)\n\t\tconst effectiveHeight = maxHeight !== undefined ? Math.min(overlayHeight, maxHeight) : overlayHeight;\n\n\t\t// === Resolve position ===\n\t\tlet row: number;\n\t\tlet col: number;\n\n\t\tif (opt.row !== undefined) {\n\t\t\tif (typeof opt.row === \"string\") {\n\t\t\t\t// Percentage: 0% = top, 100% = bottom (overlay stays within bounds)\n\t\t\t\tconst match = opt.row.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst maxRow = Math.max(0, availHeight - effectiveHeight);\n\t\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\t\trow = marginTop + Math.floor(maxRow * percent);\n\t\t\t\t} else {\n\t\t\t\t\t// Invalid format, fall back to center\n\t\t\t\t\trow = this.resolveAnchorRow(\"center\", effectiveHeight, availHeight, marginTop);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Absolute row position\n\t\t\t\trow = opt.row;\n\t\t\t}\n\t\t} else {\n\t\t\t// Anchor-based (default: center)\n\t\t\tconst anchor = opt.anchor ?? \"center\";\n\t\t\trow = this.resolveAnchorRow(anchor, effectiveHeight, availHeight, marginTop);\n\t\t}\n\n\t\tif (opt.col !== undefined) {\n\t\t\tif (typeof opt.col === \"string\") {\n\t\t\t\t// Percentage: 0% = left, 100% = right (overlay stays within bounds)\n\t\t\t\tconst match = opt.col.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst maxCol = Math.max(0, availWidth - width);\n\t\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\t\tcol = marginLeft + Math.floor(maxCol * percent);\n\t\t\t\t} else {\n\t\t\t\t\t// Invalid format, fall back to center\n\t\t\t\t\tcol = this.resolveAnchorCol(\"center\", width, availWidth, marginLeft);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Absolute column position\n\t\t\t\tcol = opt.col;\n\t\t\t}\n\t\t} else {\n\t\t\t// Anchor-based (default: center)\n\t\t\tconst anchor = opt.anchor ?? \"center\";\n\t\t\tcol = this.resolveAnchorCol(anchor, width, availWidth, marginLeft);\n\t\t}\n\n\t\t// Apply offsets\n\t\tif (opt.offsetY !== undefined) row += opt.offsetY;\n\t\tif (opt.offsetX !== undefined) col += opt.offsetX;\n\n\t\t// Clamp to terminal bounds (respecting margins)\n\t\trow = Math.max(marginTop, Math.min(row, termHeight - marginBottom - effectiveHeight));\n\t\tcol = Math.max(marginLeft, Math.min(col, termWidth - marginRight - width));\n\n\t\treturn { width, row, col, maxHeight };\n\t}\n\n\tprivate resolveAnchorRow(anchor: OverlayAnchor, height: number, availHeight: number, marginTop: number): number {\n\t\tswitch (anchor) {\n\t\t\tcase \"top-left\":\n\t\t\tcase \"top-center\":\n\t\t\tcase \"top-right\":\n\t\t\t\treturn marginTop;\n\t\t\tcase \"bottom-left\":\n\t\t\tcase \"bottom-center\":\n\t\t\tcase \"bottom-right\":\n\t\t\t\treturn marginTop + availHeight - height;\n\t\t\tcase \"left-center\":\n\t\t\tcase \"center\":\n\t\t\tcase \"right-center\":\n\t\t\t\treturn marginTop + Math.floor((availHeight - height) / 2);\n\t\t}\n\t}\n\n\tprivate resolveAnchorCol(anchor: OverlayAnchor, width: number, availWidth: number, marginLeft: number): number {\n\t\tswitch (anchor) {\n\t\t\tcase \"top-left\":\n\t\t\tcase \"left-center\":\n\t\t\tcase \"bottom-left\":\n\t\t\t\treturn marginLeft;\n\t\t\tcase \"top-right\":\n\t\t\tcase \"right-center\":\n\t\t\tcase \"bottom-right\":\n\t\t\t\treturn marginLeft + availWidth - width;\n\t\t\tcase \"top-center\":\n\t\t\tcase \"center\":\n\t\t\tcase \"bottom-center\":\n\t\t\t\treturn marginLeft + Math.floor((availWidth - width) / 2);\n\t\t}\n\t}\n\n\t/** Composite all overlays into content lines (sorted by focusOrder, higher = on top). */\n\t/**\n\t * Whether the overlays composited in the last frame covered every cell of a `termWidth` x `termHeight` screen\n\t * and are still shown: content under them cannot show through until one of them changes.\n\t */\n\tprotected overlaysCoverScreen(termWidth: number, termHeight: number): boolean {\n\t\treturn this.renderedOverlayLayouts.some(\n\t\t\t(layout) =>\n\t\t\t\tlayout.row === 0 &&\n\t\t\t\tlayout.col === 0 &&\n\t\t\t\tlayout.width >= termWidth &&\n\t\t\t\tlayout.height >= termHeight &&\n\t\t\t\tthis.overlayStack.includes(layout.entry) &&\n\t\t\t\tthis.isOverlayVisible(layout.entry),\n\t\t);\n\t}\n\n\tprotected compositeOverlays(lines: string[], termWidth: number, termHeight: number): string[] {\n\t\tif (this.overlayStack.length === 0) {\n\t\t\tthis.renderedOverlayLayouts = [];\n\t\t\treturn lines;\n\t\t}\n\t\tconst result = [...lines];\n\n\t\tfor (const entry of this.overlayStack) entry.bounds = undefined;\n\n\t\t// Pre-render all visible overlays and calculate positions\n\t\tconst rendered: { entry: OverlayStackEntry; overlayLines: string[]; row: number; col: number; w: number }[] = [];\n\t\tlet minLinesNeeded = result.length;\n\n\t\tconst visibleEntries = this.overlayStack.filter((e) => this.isOverlayVisible(e));\n\t\tvisibleEntries.sort((a, b) => a.focusOrder - b.focusOrder);\n\t\tfor (const entry of visibleEntries) {\n\t\t\tconst { component, options } = entry;\n\n\t\t\t// Get layout with height=0 first to determine width and maxHeight\n\t\t\t// (width and maxHeight don't depend on overlay height)\n\t\t\tconst { width, maxHeight } = this.resolveOverlayLayout(options, 0, termWidth, termHeight);\n\n\t\t\t// Render component at calculated width\n\t\t\tlet overlayLines = this.resolveFakeCursors(component.render(width));\n\n\t\t\t// Apply maxHeight if specified\n\t\t\tif (maxHeight !== undefined && overlayLines.length > maxHeight) {\n\t\t\t\toverlayLines = overlayLines.slice(0, maxHeight);\n\t\t\t}\n\n\t\t\t// Get final row/col with actual overlay height\n\t\t\tconst { row, col } = this.resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);\n\t\t\tentry.bounds = { row, col, width, height: overlayLines.length };\n\n\t\t\trendered.push({ entry, overlayLines, row, col, w: width });\n\t\t\tminLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);\n\t\t}\n\t\tthis.renderedOverlayLayouts = rendered.map(({ entry, row, col, w, overlayLines }) => ({\n\t\t\tentry,\n\t\t\trow,\n\t\t\tcol,\n\t\t\twidth: w,\n\t\t\theight: overlayLines.length,\n\t\t}));\n\n\t\t// Pad to at least terminal height so overlays have screen-relative positions.\n\t\t// Excludes maxLinesRendered: the historical high-water mark caused self-reinforcing\n\t\t// inflation that pushed content into scrollback on terminal widen.\n\t\tconst workingHeight = Math.max(result.length, termHeight, minLinesNeeded);\n\n\t\t// Extend result with empty lines if content is too short for overlay placement or working area\n\t\twhile (result.length < workingHeight) {\n\t\t\tresult.push(\"\");\n\t\t}\n\n\t\tconst viewportStart = Math.max(0, workingHeight - termHeight);\n\n\t\t// Composite each overlay\n\t\tfor (const { overlayLines, row, col, w } of rendered) {\n\t\t\tfor (let i = 0; i < overlayLines.length; i++) {\n\t\t\t\tconst idx = viewportStart + row + i;\n\t\t\t\tif (idx >= 0 && idx < result.length) {\n\t\t\t\t\t// Defensive: truncate overlay line to declared width before compositing\n\t\t\t\t\t// (components should already respect width, but this ensures it)\n\t\t\t\t\tconst truncatedOverlayLine =\n\t\t\t\t\t\tvisibleWidth(overlayLines[i]) > w ? sliceByColumn(overlayLines[i], 0, w, true) : overlayLines[i];\n\t\t\t\t\tresult[idx] = this.compositeLineAt(result[idx], truncatedOverlayLine, col, w, termWidth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprotected applyLineResets(lines: string[]): string[] {\n\t\tconst reset = SEGMENT_RESET;\n\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\tconst line = lines[i];\n\t\t\tif (!isImageLine(line)) {\n\t\t\t\t// Cursor and hint markers are internal render metadata and must never reach terminal output.\n\t\t\t\tlines[i] = normalizeTerminalOutput(stripHintMarkers(line.replaceAll(CURSOR_MARKER, \"\"))) + reset;\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate compositeLineAt(\n\t\tbaseLine: string,\n\t\toverlayLine: string,\n\t\tstartCol: number,\n\t\toverlayWidth: number,\n\t\ttotalWidth: number,\n\t): string {\n\t\treturn compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);\n\t}\n\n\t/**\n\t * Find and extract cursor position from rendered lines.\n\t * Searches for CURSOR_MARKER, calculates its position, and strips it from the output.\n\t * Only scans the bottom terminal height lines (visible viewport).\n\t * @param lines - Rendered lines to search\n\t * @param height - Terminal height (visible viewport size)\n\t * @returns Cursor position { row, col } or null if no marker found\n\t */\n\tprotected extractCursorPosition(lines: string[], height: number): { row: number; col: number } | null {\n\t\t// Only scan the bottom `height` lines (visible viewport)\n\t\tconst viewportTop = Math.max(0, lines.length - height);\n\t\tfor (let row = lines.length - 1; row >= viewportTop; row--) {\n\t\t\tconst line = lines[row];\n\t\t\tconst markerIndex = line.indexOf(CURSOR_MARKER);\n\t\t\tif (markerIndex !== -1) {\n\t\t\t\t// Calculate visual column (width of text before marker)\n\t\t\t\tconst beforeMarker = line.slice(0, markerIndex);\n\t\t\t\tconst col = visibleWidth(beforeMarker);\n\n\t\t\t\t// Strip all markers from the selected line. The first marker determines the\n\t\t\t\t// hardware cursor position; any others are stale internal sentinels.\n\t\t\t\tlines[row] = line.replaceAll(CURSOR_MARKER, \"\");\n\n\t\t\t\treturn { row, col };\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Resolve fake cursor markers to reverse video. When the hardware cursor is shown, a fake cursor\n\t * directly after CURSOR_MARKER is dropped because the terminal cursor is drawn there. Fake cursors\n\t * of components without focus have no CURSOR_MARKER and stay visible.\n\t */\n\tprotected resolveFakeCursors(lines: string[]): string[] {\n\t\treturn lines.map((line) => {\n\t\t\tif (!line.includes(FAKE_CURSOR_START)) return line;\n\t\t\tconst resolved = this.showHardwareCursor ? line.replace(FOCUSED_FAKE_CURSOR, \"$1$2\") : line;\n\t\t\treturn resolved.replaceAll(FAKE_CURSOR_START, \"\\x1b[7m\").replaceAll(FAKE_CURSOR_END, \"\\x1b[27m\");\n\t\t});\n\t}\n\n\t/**\n\t * Query the terminal's theme colors: the default foreground (OSC 10), the default background\n\t * (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the\n\t * replies. Resolves when the DA1 reply or all color replies arrive, or when the timeout expires.\n\t * Colors the terminal did not report are undefined; the palette is only set when all 16 arrived.\n\t * @param timeoutMs Query timeout in milliseconds, for terminals that do not answer DA1 either.\n\t * @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.\n\t */\n\tqueryTerminalColors({\n\t\ttimeoutMs,\n\t\tonLateReply,\n\t}: {\n\t\ttimeoutMs: number;\n\t\tonLateReply?: (colors: TerminalColors) => void;\n\t}): Promise<TerminalColors> {\n\t\treturn new Promise((resolve) => {\n\t\t\tconst query: PendingTerminalColorQuery = {\n\t\t\t\tpalette: Array.from({ length: TERMINAL_PALETTE_SIZE }, () => undefined),\n\t\t\t\treplied: new Set(),\n\t\t\t\tdeliver: resolve,\n\t\t\t\ttimer: undefined,\n\t\t\t};\n\t\t\t// Resolve with the replies so far, and keep collecting late replies for `onLateReply`.\n\t\t\tquery.timer = setTimeout(() => {\n\t\t\t\tquery.deliver = onLateReply;\n\t\t\t\tresolve(this.terminalColorQueryResult(query));\n\t\t\t}, timeoutMs);\n\t\t\tthis.pendingTerminalColorQueries.push(query);\n\t\t\tthis.terminal.write(TERMINAL_COLOR_QUERY);\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAmB,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EACN,qBAAqB,EACrB,8BAA8B,GAI9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EACN,eAAe,EACf,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,YAAY,GACZ,MAAM,YAAY,CAAC;AAqEpB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAoB,EAAE,KAAoB;IAC5E,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACxB,gGAAgG;QAChG,iGAAiG;QACjG,0FAA0F;QAC1F,MAAM,SAAS,GAAG,MAAgC,CAAC;QACnD,OAAO,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,C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,EAAE,SAAS;aAChB,CAAC;YACF,uFAAuF;YACvF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/C,CAAC,EAAE,SAAS,CAAC,CAAC;YACd,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/**\n * Minimal TUI implementation with differential rendering\n */\n\nimport { performance } from \"node:perf_hooks\";\nimport { type HintAction, hintKeyInput, runAsHintActivation, stripHintMarkers } from \"./clickable-hints.ts\";\nimport { isKeyRelease, matchesKey } from \"./keys.ts\";\nimport type { Terminal } from \"./terminal.ts\";\nimport {\n\tparseOscColorResponse,\n\tparseTerminalColorSchemeReport,\n\ttype RgbColor,\n\ttype TerminalColorScheme,\n\ttype TerminalColors,\n} from \"./terminal-colors.ts\";\nimport { getCapabilities, isImageLine, setCellDimensions } from \"./terminal-image.ts\";\nimport {\n\textractSegments,\n\tHINT_CLOSE,\n\tHINT_OPEN,\n\tnormalizeTerminalOutput,\n\tsliceByColumn,\n\tsliceWithWidth,\n\tvisibleWidth,\n} from \"./utils.ts\";\n\n/**\n * Component interface - all components must implement this\n */\nexport type TuiMouseEventType = \"press\" | \"release\" | \"move\" | \"drag\" | \"click\" | \"wheel\";\nexport type TuiMouseButton = \"left\" | \"middle\" | \"right\" | \"none\";\n\n/** Normalized cell-based mouse event. Coordinates are zero-based. */\nexport interface TuiMouseEvent {\n\ttype: TuiMouseEventType;\n\tbutton: TuiMouseButton;\n\t/** Coordinates local to the receiving component. */\n\tx: number;\n\ty: number;\n\t/** Absolute terminal coordinates. */\n\tscreenX: number;\n\tscreenY: number;\n\t/** Current component bounds. */\n\twidth: number;\n\theight: number;\n\tshift: boolean;\n\talt: boolean;\n\tctrl: boolean;\n\t/** Logical lines. Negative values scroll up. */\n\twheelDelta?: number;\n\t/** Consecutive click count when type is click. */\n\tclickCount?: number;\n}\n\nexport interface TuiMouseEventResult {\n\t/** Stop propagation and suppress renderer-level fallback behavior. */\n\thandled?: boolean;\n\t/** Route subsequent drag/release events to this component. Implies handled. */\n\tcapture?: boolean;\n\t/** Give keyboard focus to this component. Implies handled. */\n\tfocus?: boolean;\n\t/**\n\t * Explicitly request or suppress a render. Move and release default to false;\n\t * press, click, drag, and wheel default to true.\n\t */\n\trender?: boolean;\n\t/**\n\t * For a single click: what it does once it is known not to start a double- or triple-click. It runs when the\n\t * multi-click interval since the press passes with no second press on the same spot, then the screen repaints. A\n\t * second press there makes the click part of a double- or triple-click, which selects text, and cancels it.\n\t */\n\twhenSingleClick?: () => void;\n\t/** Release anything reserved for `whenSingleClick` if the renderer cancels it instead. */\n\tonSingleClickCancel?: () => void;\n}\n\n/** Internal target metadata used by containers and alternate-screen dispatch. */\nexport interface TuiMouseDispatchTarget {\n\tcomponent: Component;\n\toriginX: number;\n\toriginY: number;\n\twidth: number;\n\theight: number;\n}\n\n/** Result of dispatching to a concrete component. */\nexport interface TuiMouseDispatchResult extends TuiMouseEventResult {\n\thandled: true;\n\ttarget: TuiMouseDispatchTarget;\n\t/** Keyboard focus target, which may be a delegating parent container. */\n\tfocusTarget?: Component;\n}\n\n/**\n * Dispatch an event to a component and retain the exact target and coordinate\n * transform. Containers use this when forwarding events to nested children.\n */\nexport function dispatchMouseEvent(component: Component, event: TuiMouseEvent): TuiMouseDispatchResult | undefined {\n\tconst result = component.handleMouse?.(event);\n\tif (!result) return undefined;\n\tif (\"target\" in result) {\n\t\t// The component forwarded the event to a child it hosts. Like a delegating container, it routes\n\t\t// keys to that child itself, so it keeps keyboard focus. Focusing the child directly would leave\n\t\t// focus on a detached component once the host removes it, e.g. a closed settings submenu.\n\t\tconst forwarded = result as TuiMouseDispatchResult;\n\t\treturn forwarded.focus && component.handleInput ? { ...forwarded, focusTarget: component } : forwarded;\n\t}\n\tif (!result.handled && !result.capture && !result.focus) return undefined;\n\treturn {\n\t\t...result,\n\t\thandled: true,\n\t\t...(result.focus ? { focusTarget: component } : {}),\n\t\ttarget: {\n\t\t\tcomponent,\n\t\t\toriginX: event.screenX - event.x,\n\t\t\toriginY: event.screenY - event.y,\n\t\t\twidth: event.width,\n\t\t\theight: event.height,\n\t\t},\n\t};\n}\n\n/** Recreate local coordinates for a previously dispatched mouse target. */\nexport function retargetMouseEvent(event: TuiMouseEvent, target: TuiMouseDispatchTarget): TuiMouseEvent {\n\treturn {\n\t\t...event,\n\t\tx: event.screenX - target.originX,\n\t\ty: event.screenY - target.originY,\n\t\twidth: target.width,\n\t\theight: target.height,\n\t};\n}\n\nexport interface Component {\n\t/**\n\t * Render the component to lines for the given viewport width\n\t * @param width - Current viewport width\n\t * @returns Array of strings, each representing a line\n\t */\n\trender(width: number): string[];\n\n\t/**\n\t * Render for a stack slot of `height` rows. A layout that allocates the component a height calls this instead of\n\t * `render`, so the component can fill exactly what it was given; elsewhere `render` is used.\n\t */\n\trenderSized?(width: number, height: number): string[];\n\n\t/** Optional handler for keyboard input when component has focus. */\n\thandleInput?(data: string): void;\n\n\t/** Optional normalized mouse handler. */\n\thandleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;\n\n\t/**\n\t * An identity for what the last render drew on `row`, such as the id of the item shown there. The fullscreen\n\t * renderer turns a press and release into a click only when it is the same at both, so a repaint that swaps in\n\t * another item with the same text is not clicked by mistake.\n\t */\n\tpaintedRowKey?(row: number): string | undefined;\n\t/** Its rendered text depends on private renderer state, so selected fragments cannot be recreated from history. */\n\treadonly selectionTextMayChangeOnReplay?: boolean;\n\t/** Set to true on a component returned by a chat renderer if recreating it from the saved input loses no state. */\n\treadonly historyReplayable?: boolean;\n\n\t/**\n\t * If true, component receives key release events (Kitty protocol).\n\t * Default is false - release events are filtered out.\n\t */\n\twantsKeyRelease?: boolean;\n\n\t/**\n\t * If true while focused, fullscreen viewport keys (`tui.altScreen.*` scrolling and prompt jumps) go to this\n\t * component instead of scrolling the transcript, as they do for a focused overlay. Default is false.\n\t */\n\tcapturesViewportInput?: boolean;\n\n\t/**\n\t * Invalidate any cached rendering state.\n\t * Called when theme changes or when component needs to re-render from scratch.\n\t */\n\tinvalidate(): void;\n}\n\nexport type TuiInputListenerResult = { consume?: boolean; data?: string } | undefined;\nexport type TuiInputListener = (data: string) => TuiInputListenerResult;\ntype PendingTerminalColorQuery = {\n\tforeground?: RgbColor;\n\tbackground?: RgbColor;\n\tpalette: Array<RgbColor | undefined>;\n\t/** Targets that already replied, so duplicates do not count twice. */\n\treplied: Set<string>;\n\t/**\n\t * Receives the result: the promise's resolve until the timeout, then `onLateReply`. Unset once the\n\t * query completed (on the DA1 reply or once every color replied); later replies are ignored.\n\t */\n\tdeliver: ((colors: TerminalColors) => void) | undefined;\n\ttimer: NodeJS.Timeout | undefined;\n};\n\nconst TERMINAL_PALETTE_SIZE = 16;\n/** OSC 10 and 11 plus OSC 4 for every palette color. */\nconst TERMINAL_COLOR_REPLY_COUNT = 2 + TERMINAL_PALETTE_SIZE;\n/**\n * Default colors, palette colors 0-15, and a trailing primary device attributes (DA1) request.\n * Every terminal answers DA1 and terminals answer in order, so the DA1 reply marks the end of\n * the color replies, including for terminals that ignore the color queries.\n */\nconst TERMINAL_COLOR_QUERY = `\\x1b]10;?\\x07\\x1b]11;?\\x07${Array.from(\n\t{ length: TERMINAL_PALETTE_SIZE },\n\t(_, index) => `\\x1b]4;${index};?\\x07`,\n).join(\"\")}\\x1b[c`;\nconst DEVICE_ATTRIBUTES_RESPONSE_PATTERN = /^\\x1b\\[\\?[\\d;]*c$/;\n\n/**\n * Interface for components that can receive focus and display a hardware cursor.\n * When focused, the component should emit CURSOR_MARKER at the cursor position\n * in its render output. TUI will find this marker and position the hardware\n * cursor there for proper IME candidate window positioning.\n */\nexport interface Focusable {\n\t/** Set by TUI when focus changes. Component should emit CURSOR_MARKER when true. */\n\tfocused: boolean;\n}\n\n/** Type guard to check if a component implements Focusable */\nexport function isFocusable(component: Component | null): component is Component & Focusable {\n\treturn component !== null && \"focused\" in component;\n}\n\n/**\n * Cursor position marker - APC (Application Program Command) sequence.\n * This is a zero-width escape sequence that terminals ignore.\n * Components emit this at the cursor position when focused.\n * TUI finds and strips this marker, then positions the hardware cursor there.\n */\nexport const CURSOR_MARKER = \"\\x1b_pi:c\\x07\";\n\n/** Fake cursor markers - zero-width APC sequences around the text drawn as the cursor. See resolveFakeCursors(). */\nexport const FAKE_CURSOR_START = \"\\x1b_pi:fc\\x07\";\nexport const FAKE_CURSOR_END = \"\\x1b_pi:/fc\\x07\";\n// CURSOR_MARKER + FAKE_CURSOR_START + text + FAKE_CURSOR_END. Truncating the line right after the cursor cell drops the end.\nconst FOCUSED_FAKE_CURSOR = /(\\x1b_pi:c\\x07)\\x1b_pi:fc\\x07(.*?)(?:\\x1b_pi:\\/fc\\x07|$)/s;\n\n/** Wrap text in fake cursor markers. */\nexport function renderFakeCursor(text: string): string {\n\treturn `${FAKE_CURSOR_START}${text}${FAKE_CURSOR_END}`;\n}\n\nexport { visibleWidth };\n\n/**\n * Anchor position for overlays\n */\nexport type OverlayAnchor =\n\t| \"center\"\n\t| \"top-left\"\n\t| \"top-right\"\n\t| \"bottom-left\"\n\t| \"bottom-right\"\n\t| \"top-center\"\n\t| \"bottom-center\"\n\t| \"left-center\"\n\t| \"right-center\";\n\n/**\n * Margin configuration for overlays\n */\nexport interface OverlayMargin {\n\ttop?: number;\n\tright?: number;\n\tbottom?: number;\n\tleft?: number;\n}\n\n/** Value that can be absolute (number) or percentage (string like \"50%\") */\nexport type SizeValue = number | `${number}%`;\n\n/** Parse a SizeValue into absolute value given a reference size */\nfunction parseSizeValue(value: SizeValue | undefined, referenceSize: number): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"number\") return value;\n\t// Parse percentage string like \"50%\"\n\tconst match = value.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\tif (match) {\n\t\treturn Math.floor((referenceSize * parseFloat(match[1])) / 100);\n\t}\n\treturn undefined;\n}\n\n/**\n * Options for overlay positioning and sizing.\n * Values can be absolute numbers or percentage strings (e.g., \"50%\").\n */\nexport interface OverlayOptions {\n\t// === Sizing ===\n\t/** Width in columns, or percentage of terminal width (e.g., \"50%\") */\n\twidth?: SizeValue;\n\t/** Minimum width in columns */\n\tminWidth?: number;\n\t/** Maximum height in rows, or percentage of terminal height (e.g., \"50%\") */\n\tmaxHeight?: SizeValue;\n\n\t// === Positioning - anchor-based ===\n\t/** Anchor point for positioning (default: 'center') */\n\tanchor?: OverlayAnchor;\n\t/** Horizontal offset from anchor position (positive = right) */\n\toffsetX?: number;\n\t/** Vertical offset from anchor position (positive = down) */\n\toffsetY?: number;\n\n\t// === Positioning - percentage or absolute ===\n\t/** Row position: absolute number, or percentage (e.g., \"25%\" = 25% from top) */\n\trow?: SizeValue;\n\t/** Column position: absolute number, or percentage (e.g., \"50%\" = centered horizontally) */\n\tcol?: SizeValue;\n\n\t// === Margin from terminal edges ===\n\t/** Margin from terminal edges. Number applies to all sides. */\n\tmargin?: OverlayMargin | number;\n\n\t// === Visibility ===\n\t/**\n\t * Control overlay visibility based on terminal dimensions.\n\t * If provided, overlay is only rendered when this returns true.\n\t * Called each render cycle with current terminal dimensions.\n\t */\n\tvisible?: (termWidth: number, termHeight: number) => boolean;\n\t/** If true, don't capture keyboard focus when shown */\n\tnonCapturing?: boolean;\n}\n\n/** Options for {@link OverlayHandle.unfocus}. */\nexport interface OverlayUnfocusOptions {\n\t/** Explicit target to focus after releasing this overlay. */\n\ttarget: Component | null;\n}\n\n/** Last rendered terminal-relative overlay rectangle. */\nexport interface OverlayBounds {\n\trow: number;\n\tcol: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Handle returned by showOverlay for controlling the overlay\n */\nexport interface OverlayHandle {\n\t/** Permanently remove the overlay (cannot be shown again) */\n\thide(): void;\n\t/** Temporarily hide or show the overlay */\n\tsetHidden(hidden: boolean): void;\n\t/** Check if overlay is temporarily hidden */\n\tisHidden(): boolean;\n\t/** Focus this overlay and bring it to the visual front */\n\tfocus(): void;\n\t/** Release focus to the next visible capturing overlay or previous target, or to an explicit target when provided */\n\tunfocus(options?: OverlayUnfocusOptions): void;\n\t/** Check if this overlay currently has focus */\n\tisFocused(): boolean;\n\t/** Get the most recent rendered bounds for a visible overlay. */\n\tgetBounds(): OverlayBounds | undefined;\n}\n\ntype OverlayStackEntry = {\n\tcomponent: Component;\n\toptions?: OverlayOptions;\n\tpreFocus: Component | null;\n\thidden: boolean;\n\tfocusOrder: number;\n\tbounds?: OverlayBounds;\n\t/** Shared by presses during this visible occurrence. Holds no reference to the overlay or its component. */\n\tpress?: { revoked: boolean };\n\tlastHiddenAt?: number;\n};\n\nconst REVOKED_OVERLAY_PRESS = { revoked: true };\n\nfunction endOverlayPresses(entry: OverlayStackEntry, version: number): void {\n\tentry.lastHiddenAt = version;\n\tif (entry.press) entry.press.revoked = true;\n\t// The previous paint may still hit this entry before another frame is drawn.\n\tentry.press = REVOKED_OVERLAY_PRESS;\n}\n\ninterface OverlayMouseHit {\n\thit: boolean;\n\tresult?: TuiMouseDispatchResult;\n\tpress?: { readonly revoked: boolean };\n}\n\ntype RenderedOverlayLayout = {\n\tentry: OverlayStackEntry;\n\trow: number;\n\tcol: number;\n\twidth: number;\n\theight: number;\n};\n\ntype OverlayBlockedFocusResume = { status: \"restore-overlay\" } | { status: \"focus-target\"; target: Component | null };\ntype EligibleOverlayFocusRestoreState = { status: \"eligible\"; overlay: OverlayStackEntry };\ntype BlockedOverlayFocusRestoreState = {\n\tstatus: \"blocked\";\n\toverlay: OverlayStackEntry;\n\tblockedBy: Component;\n\tresume: OverlayBlockedFocusResume;\n};\ntype ActiveOverlayFocusRestoreState = EligibleOverlayFocusRestoreState | BlockedOverlayFocusRestoreState;\ntype OverlayFocusRestoreState = { status: \"inactive\" } | ActiveOverlayFocusRestoreState;\ntype OverlayFocusRestorePolicy = \"clear\" | \"preserve\";\n\n/**\n * Container - a component that contains other components\n */\nexport class Container implements Component {\n\tchildren: Component[] = [];\n\tprivate mouseLayout?: { width: number; children: Array<{ component: Component; height: number }> };\n\n\taddChild(component: Component): void {\n\t\tthis.children.push(component);\n\t}\n\n\tremoveChild(component: Component): void {\n\t\tconst index = this.children.indexOf(component);\n\t\tif (index !== -1) {\n\t\t\tthis.children.splice(index, 1);\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.children = [];\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const child of this.children) {\n\t\t\tchild.invalidate?.();\n\t\t}\n\t}\n\n\t/**\n\t * The child drawn at `row` of this container at `width`, with the row inside that child and the child's height.\n\t * Reads the row heights of the last render at `width`; another width renders the children to measure them.\n\t */\n\tchildAtRow(width: number, row: number): { component: Component; row: number; height: number } | undefined {\n\t\tif (row < 0) return undefined;\n\t\tconst mouseChildren =\n\t\t\tthis.mouseLayout?.width === width\n\t\t\t\t? this.mouseLayout.children\n\t\t\t\t: this.children.map((component) => ({ component, height: component.render(width).length }));\n\t\tlet childY = 0;\n\t\tfor (const { component, height } of mouseChildren) {\n\t\t\tif (row >= childY && row < childY + height) return { component, row: row - childY, height };\n\t\t\tchildY += height;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined {\n\t\tif (event.y < 0 || event.y >= event.height) return undefined;\n\t\tconst hit = this.childAtRow(event.width, event.y);\n\t\tif (!hit) return undefined;\n\t\tconst result = dispatchMouseEvent(hit.component, { ...event, y: hit.row, height: hit.height });\n\t\tif (result?.focus && (this as Component).handleInput) return { ...result, focusTarget: this };\n\t\treturn result;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst mouseChildren: Array<{ component: Component; height: number }> = [];\n\t\tfor (const child of this.children) {\n\t\t\tconst childLines = child.render(width);\n\t\t\tmouseChildren.push({ component: child, height: childLines.length });\n\t\t\tfor (const line of childLines) {\n\t\t\t\tlines.push(line);\n\t\t\t}\n\t\t}\n\t\tthis.mouseLayout = { width, children: mouseChildren };\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Where this container's last render at `width` drew `target`, searched through nested containers: the first row and\n\t * the rows each of the target's own children drew. Undefined when that render did not draw it.\n\t */\n\tdrawnRowsOf(\n\t\ttarget: Container,\n\t\twidth: number,\n\t): { row: number; children: ReadonlyArray<{ component: Component; height: number }> } | undefined {\n\t\tconst visit = (container: Container, row: number, height?: number): ReturnType<Container[\"drawnRowsOf\"]> => {\n\t\t\tconst layout = container.mouseLayout;\n\t\t\tif (layout?.width !== width) return undefined;\n\t\t\tlet drawn = 0;\n\t\t\tfor (const child of layout.children) drawn += child.height;\n\t\t\t// A container whose own render skipped Container.render keeps an older layout.\n\t\t\tif (height !== undefined && drawn !== height) return undefined;\n\t\t\tif (container === target) return { row, children: layout.children };\n\t\t\tlet at = row;\n\t\t\tfor (const child of layout.children) {\n\t\t\t\tif (child.height > 0 && child.component instanceof Container) {\n\t\t\t\t\tconst found = visit(child.component, at, child.height);\n\t\t\t\t\tif (found) return found;\n\t\t\t\t}\n\t\t\t\tat += child.height;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\t\treturn visit(this, 0);\n\t}\n}\n\n/**\n * TUI - Main class for managing terminal UI with differential rendering\n */\nconst SEGMENT_RESET = \"\\x1b[0m\\x1b]8;;\\x07\";\n/**\n * Between the segments of a composited line that holds key hints: styles end there, and so does a hint, whose part\n * beyond a box drawn over it is re-opened with the rest of its styles. The renderer removes the hint marker before\n * writing the line.\n */\nconst HINT_SEGMENT_RESET = SEGMENT_RESET + HINT_CLOSE;\n\n/** Composite overlay content into a terminal line at a fixed column. */\nexport function compositeTuiLine(\n\tbaseLine: string,\n\toverlayLine: string,\n\tstartCol: number,\n\toverlayWidth: number,\n\ttotalWidth: number,\n): string {\n\tif (isImageLine(baseLine)) return baseLine;\n\n\tconst afterStart = startCol + overlayWidth;\n\tconst base = extractSegments(baseLine, startCol, afterStart, totalWidth - afterStart, true);\n\tconst boundary =\n\t\tbaseLine.includes(HINT_OPEN) || overlayLine.includes(HINT_OPEN) ? HINT_SEGMENT_RESET : SEGMENT_RESET;\n\tconst overlay = sliceWithWidth(overlayLine, 0, overlayWidth, true);\n\tconst beforePad = Math.max(0, startCol - base.beforeWidth);\n\tconst overlayPad = Math.max(0, overlayWidth - overlay.width);\n\tconst actualBeforeWidth = Math.max(startCol, base.beforeWidth);\n\tconst actualOverlayWidth = Math.max(overlayWidth, overlay.width);\n\tconst afterTarget = Math.max(0, totalWidth - actualBeforeWidth - actualOverlayWidth);\n\tconst afterPad = Math.max(0, afterTarget - base.afterWidth);\n\tconst result =\n\t\tbase.before +\n\t\t\" \".repeat(beforePad) +\n\t\tboundary +\n\t\toverlay.text +\n\t\t\" \".repeat(overlayPad) +\n\t\tboundary +\n\t\tbase.after +\n\t\t\" \".repeat(afterPad);\n\n\treturn visibleWidth(result) <= totalWidth ? result : sliceByColumn(result, 0, totalWidth, true);\n}\n\nexport type TuiMode = \"regular\" | \"fullscreen\";\n\nexport interface TuiStopOptions {\n\t/** Leave renderer output in place for another TUI taking over the same terminal. */\n\tpreserveScreen?: boolean;\n\twriteInSlices?: boolean;\n}\n\n/**\n * A side lookup that adds rows to a container which the main-screen renderer may already have drawn. The renderer can\n * only append to terminal scrollback, so it holds at most one rendered frame while the lookup is outstanding. It never\n * delays or repeats a component's render.\n */\nexport interface ScrollbackFrameGate {\n\t/**\n\t * The lookup answered. `update` may change the container's children. A held frame is written with the rows it\n\t * already drew for the children that remain; only children that `update` added are rendered. If no frame has drawn\n\t * the container yet, `update` runs and the next frame draws its result. Once the gate has released, `update` never runs.\n\t */\n\tsettle(update?: () => void): void;\n\t/** End the lookup without an answer: a held frame is written exactly as it was rendered. */\n\trelease(): void;\n}\n\nexport interface ScrollbackFrameGateOptions {\n\t/** The longest a rendered frame is held, counted from when the gate holds it. */\n\treadonly timeoutMs: number;\n\t/** Runs once, whatever releases the gate, so its owner can drop the lookup. */\n\treadonly onRelease?: () => void;\n}\n\nexport interface TUI extends Component {\n\treadonly mode: TuiMode;\n\tchildren: Component[];\n\tterminal: Terminal;\n\tonDebug?: () => void;\n\treadonly fullRedraws: number;\n\taddChild(component: Component): void;\n\tremoveChild(component: Component): void;\n\tclear(): void;\n\tgetShowHardwareCursor(): boolean;\n\tsetShowHardwareCursor(enabled: boolean): void;\n\tgetClearOnShrink(): boolean;\n\tsetClearOnShrink(enabled: boolean): void;\n\tsetFocus(component: Component | null): void;\n\tshowOverlay(component: Component, options?: OverlayOptions): OverlayHandle;\n\thideOverlay(): void;\n\thasOverlay(): boolean;\n\tstart(): void;\n\tstop(options?: TuiStopOptions): void;\n\twhenStopped(): Promise<void>;\n\trenderNow(force?: boolean): void;\n\trequestRender(force?: boolean): void;\n\t/**\n\t * Render on the next tick, ahead of the frame pacing `requestRender` applies: for a frame that answers the user's own\n\t * keystroke, as the renderer does after it routes a key.\n\t */\n\trequestImmediateRender(): void;\n\t/**\n\t * Main-screen renderers only: gate the frames that draw `container` while a side lookup for its rows is outstanding.\n\t * A newer gate releases an older one.\n\t */\n\tgateScrollbackFrame?(container: Container, options: ScrollbackFrameGateOptions): ScrollbackFrameGate | undefined;\n\taddInputListener(listener: TuiInputListener): () => void;\n\tremoveInputListener(listener: TuiInputListener): void;\n\t/** Run the slash command a clicked hint names, such as `/tasks` in `/tasks to manage`. */\n\tsetHintCommandHandler?(handler: ((command: string) => void) | undefined): void;\n\tonTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;\n\tsetTerminalColorSchemeNotifications(enabled: boolean): void;\n\tqueryTerminalColors(options: {\n\t\ttimeoutMs: number;\n\t\tonLateReply?: (colors: TerminalColors) => void;\n\t}): Promise<TerminalColors>;\n}\n\nexport const VIEWPORT_TUI = Symbol.for(\"@bastani/atomic-tui/viewport\");\n\nexport interface ViewportTUI extends TUI {\n\treadonly [VIEWPORT_TUI]: true;\n\tsetLayoutRoot(component: Component | undefined): void;\n}\n\nexport function isViewportTUI(tui: TUI): tui is ViewportTUI {\n\treturn (tui as Partial<ViewportTUI>)[VIEWPORT_TUI] === true;\n}\n\nexport abstract class TuiBase extends Container implements TUI {\n\tabstract readonly mode: TuiMode;\n\tpublic terminal: Terminal;\n\tprivate focusedComponent: Component | null = null;\n\tprivate inputListeners = new Set<TuiInputListener>();\n\tprivate hintCommandHandler: ((command: string) => void) | undefined;\n\n\t/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */\n\tpublic onDebug?: () => void;\n\tprivate renderRequested = false;\n\tprivate immediateRenderScheduled = false;\n\tprivate renderTimer: NodeJS.Timeout | undefined;\n\tprivate lastRenderAt = 0;\n\tprivate static readonly MIN_RENDER_INTERVAL_MS = 16;\n\tprivate showHardwareCursor = false;\n\tprivate clearOnShrink = false;\n\tprotected fullRedrawCount = 0;\n\tprotected stopped = false;\n\tprotected stopOutput: Promise<void> = Promise.resolve();\n\t/**\n\t * Color queries waiting for their DA1 reply, oldest first. Terminals answer in order, so color\n\t * replies belong to the oldest one. Queries stay here after a timeout to collect late replies.\n\t */\n\tprivate pendingTerminalColorQueries: PendingTerminalColorQuery[] = [];\n\tprivate terminalColorSchemeListeners = new Set<(scheme: TerminalColorScheme) => void>();\n\tprivate terminalColorSchemeNotificationsEnabled = false;\n\t/** Directory for debug/crash logs. When undefined, debug logging is disabled and crash dumps fall back to the OS temp directory. */\n\tprotected readonly logDirectory: string | undefined;\n\n\t// Overlay stack for modal components rendered on top of base content\n\tprivate focusOrderCounter = 0;\n\t/** A host offering raw mouse input to a dialog can remember when that input arrived, before its reply. */\n\tprotected overlayVisibilityVersion = 0;\n\tprivate overlayStack: OverlayStackEntry[] = [];\n\tprivate renderedOverlayLayouts: RenderedOverlayLayout[] = [];\n\n\tget hasOverlayEntries(): boolean {\n\t\treturn this.overlayStack.length > 0;\n\t}\n\tprivate overlayFocusRestore: OverlayFocusRestoreState = { status: \"inactive\" };\n\n\tconstructor(terminal: Terminal, showHardwareCursor?: boolean, logDirectory?: string) {\n\t\tsuper();\n\t\tthis.terminal = terminal;\n\t\tthis.logDirectory = logDirectory;\n\t\tif (showHardwareCursor !== undefined) {\n\t\t\tthis.showHardwareCursor = showHardwareCursor;\n\t\t}\n\t}\n\n\tprotected abstract doRender(): void;\n\n\tprotected resetRenderState(): void {}\n\n\tprotected beforeTerminalStart(): void {}\n\n\tprotected afterTerminalStart(): void {}\n\n\tprotected beforeTerminalStop(_options: TuiStopOptions): void {}\n\n\tprotected afterTerminalStop(_options: TuiStopOptions): void {}\n\n\t/** Mode resets written before the terminal's own resets when the process exits without stop(). */\n\tprotected getExitRestorePrefix(): string {\n\t\treturn `${this.terminalColorSchemeNotificationsEnabled ? \"\\x1b[?2031l\" : \"\"}\\x1b[?25h`;\n\t}\n\n\t/** Mode resets written after the terminal's own resets when the process exits without stop(). */\n\tprotected getExitRestoreSuffix(): string {\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Last-resort restore for exit paths that skip stop(), e.g. a direct process.exit() (#11170).\n\t * Hard kills and native aborts run no JavaScript and cannot be covered.\n\t */\n\tprivate readonly exitRestoreHandler = (): void => {\n\t\tif (this.stopped) return;\n\t\ttry {\n\t\t\tthis.terminal.restoreOnExit?.(this.getExitRestorePrefix(), this.getExitRestoreSuffix());\n\t\t} catch {\n\t\t\t// Never throw from an exit handler.\n\t\t}\n\t};\n\n\tget fullRedraws(): number {\n\t\treturn this.fullRedrawCount;\n\t}\n\n\tgetShowHardwareCursor(): boolean {\n\t\treturn this.showHardwareCursor;\n\t}\n\n\tsetShowHardwareCursor(enabled: boolean): void {\n\t\tif (this.showHardwareCursor === enabled) return;\n\t\tthis.showHardwareCursor = enabled;\n\t\tif (!enabled) {\n\t\t\tthis.hideTerminalCursor();\n\t\t}\n\t\tthis.requestRender();\n\t}\n\n\tgetClearOnShrink(): boolean {\n\t\treturn this.clearOnShrink;\n\t}\n\n\t/**\n\t * Set whether to trigger full re-render when content shrinks.\n\t * When true, empty rows are cleared when content shrinks.\n\t * When false (default), empty rows remain (reduces redraws on slower terminals).\n\t */\n\tsetClearOnShrink(enabled: boolean): void {\n\t\tthis.clearOnShrink = enabled;\n\t}\n\n\tgetFocusedComponent(): Component | null {\n\t\treturn this.focusedComponent;\n\t}\n\n\tsetFocus(component: Component | null): void {\n\t\tthis.setFocusInternal({ component, overlayFocusRestore: \"clear\" });\n\t}\n\n\tprivate setFocusInternal({\n\t\tcomponent,\n\t\toverlayFocusRestore,\n\t}: {\n\t\tcomponent: Component | null;\n\t\toverlayFocusRestore: OverlayFocusRestorePolicy;\n\t}): void {\n\t\tconst previousFocus = this.focusedComponent;\n\t\tlet nextFocus = component;\n\t\tconst previousFocusedOverlay = previousFocus\n\t\t\t? this.overlayStack.find((entry) => entry.component === previousFocus && this.isOverlayVisible(entry))\n\t\t\t: undefined;\n\t\tconst nextFocusIsOverlay = nextFocus ? this.overlayStack.some((entry) => entry.component === nextFocus) : false;\n\t\tconst restoreState = this.getVisibleOverlayFocusRestore();\n\t\tif (nextFocus && !nextFocusIsOverlay) {\n\t\t\tif (restoreState.status === \"blocked\" && restoreState.blockedBy === previousFocus) {\n\t\t\t\tif (restoreState.resume.status === \"focus-target\" || !this.isComponentMounted(restoreState.blockedBy)) {\n\t\t\t\t\tnextFocus = this.resolveBlockedOverlayFocusResume(restoreState);\n\t\t\t\t} else {\n\t\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\t\toverlay: restoreState.overlay,\n\t\t\t\t\t\tblockedBy: nextFocus,\n\t\t\t\t\t\tresume: restoreState.resume,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tpreviousFocusedOverlay &&\n\t\t\t\trestoreState.status !== \"inactive\" &&\n\t\t\t\trestoreState.overlay === previousFocusedOverlay &&\n\t\t\t\t!this.isOverlayFocusAncestor(previousFocusedOverlay, nextFocus)\n\t\t\t) {\n\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\toverlay: previousFocusedOverlay,\n\t\t\t\t\tblockedBy: nextFocus,\n\t\t\t\t\tresume: { status: \"restore-overlay\" },\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (nextFocus === null) {\n\t\t\tif (restoreState.status === \"blocked\" && restoreState.blockedBy === previousFocus) {\n\t\t\t\tnextFocus = this.resolveBlockedOverlayFocusResume(restoreState);\n\t\t\t} else if (overlayFocusRestore === \"clear\") {\n\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t}\n\t\t}\n\n\t\tif (isFocusable(this.focusedComponent)) {\n\t\t\tthis.focusedComponent.focused = false;\n\t\t}\n\n\t\tthis.focusedComponent = nextFocus;\n\n\t\tif (isFocusable(nextFocus)) {\n\t\t\tnextFocus.focused = true;\n\t\t}\n\n\t\tconst focusedOverlay = nextFocus\n\t\t\t? this.overlayStack.find((entry) => entry.component === nextFocus && this.isOverlayVisible(entry))\n\t\t\t: undefined;\n\t\tif (focusedOverlay) {\n\t\t\tthis.overlayFocusRestore = { status: \"eligible\", overlay: focusedOverlay };\n\t\t}\n\t}\n\n\tprivate clearOverlayFocusRestore(): void {\n\t\tthis.overlayFocusRestore = { status: \"inactive\" };\n\t}\n\n\tprivate clearOverlayFocusRestoreFor(overlay: OverlayStackEntry): void {\n\t\tif (this.overlayFocusRestore.status !== \"inactive\" && this.overlayFocusRestore.overlay === overlay) {\n\t\t\tthis.clearOverlayFocusRestore();\n\t\t}\n\t}\n\n\tprivate resolveBlockedOverlayFocusResume(restoreState: BlockedOverlayFocusRestoreState): Component | null {\n\t\tif (restoreState.resume.status === \"restore-overlay\") return restoreState.overlay.component;\n\t\tthis.clearOverlayFocusRestore();\n\t\treturn restoreState.resume.target;\n\t}\n\n\tprivate getVisibleOverlayFocusRestore(): OverlayFocusRestoreState {\n\t\tconst restoreState = this.overlayFocusRestore;\n\t\tif (restoreState.status === \"inactive\") return restoreState;\n\t\tif (!this.overlayStack.includes(restoreState.overlay) || !this.isOverlayVisible(restoreState.overlay)) {\n\t\t\treturn { status: \"inactive\" };\n\t\t}\n\t\treturn restoreState;\n\t}\n\n\tprivate isOverlayFocusAncestor(entry: OverlayStackEntry, component: Component): boolean {\n\t\tconst visited = new Set<Component>();\n\t\tlet current = entry.preFocus;\n\t\twhile (current && !visited.has(current)) {\n\t\t\tvisited.add(current);\n\t\t\tif (current === component) return true;\n\t\t\tcurrent = this.overlayStack.find((overlay) => overlay.component === current)?.preFocus ?? null;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate retargetOverlayPreFocus(removed: OverlayStackEntry): void {\n\t\tfor (const overlay of this.overlayStack) {\n\t\t\tif (overlay !== removed && overlay.preFocus === removed.component) {\n\t\t\t\toverlay.preFocus = removed.preFocus;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getMountedRoots(): readonly Component[] {\n\t\treturn this.children;\n\t}\n\n\tprivate isComponentMounted(component: Component): boolean {\n\t\treturn this.getMountedRoots().some((child) => this.containsComponent(child, component));\n\t}\n\n\tprivate containsComponent(root: Component, target: Component): boolean {\n\t\tif (root === target) return true;\n\t\tif (!(root instanceof Container)) return false;\n\t\treturn root.children.some((child) => this.containsComponent(child, target));\n\t}\n\n\t/**\n\t * Show an overlay component with configurable positioning and sizing.\n\t * Returns a handle to control the overlay's visibility.\n\t */\n\tshowOverlay(component: Component, options?: OverlayOptions): OverlayHandle {\n\t\tconst entry: OverlayStackEntry = {\n\t\t\tcomponent,\n\t\t\t...(options === undefined ? {} : { options }),\n\t\t\tpreFocus: this.focusedComponent,\n\t\t\thidden: false,\n\t\t\tfocusOrder: ++this.focusOrderCounter,\n\t\t};\n\t\tthis.overlayStack.push(entry);\n\t\t// Only focus if overlay is actually visible\n\t\tif (!options?.nonCapturing && this.isOverlayVisible(entry)) {\n\t\t\tthis.setFocus(component);\n\t\t}\n\t\tthis.hideTerminalCursor();\n\t\tthis.requestRender();\n\n\t\t// Return handle for controlling this overlay\n\t\treturn {\n\t\t\thide: () => {\n\t\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tendOverlayPresses(entry, ++this.overlayVisibilityVersion);\n\t\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\t\tthis.retargetOverlayPreFocus(entry);\n\t\t\t\t\tthis.overlayStack.splice(index, 1);\n\t\t\t\t\t// Restore focus if this overlay had focus\n\t\t\t\t\tif (this.focusedComponent === component) {\n\t\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\t\tthis.setFocus(topVisible?.component ?? entry.preFocus);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.overlayStack.length === 0) this.hideTerminalCursor();\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetHidden: (hidden: boolean) => {\n\t\t\t\tif (entry.hidden === hidden) return;\n\t\t\t\tentry.hidden = hidden;\n\t\t\t\t// Update focus when hiding/showing\n\t\t\t\tif (hidden) {\n\t\t\t\t\tendOverlayPresses(entry, ++this.overlayVisibilityVersion);\n\t\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\t\t// If this overlay had focus, move focus to next visible or preFocus\n\t\t\t\t\tif (this.focusedComponent === component) {\n\t\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\t\tthis.setFocus(topVisible?.component ?? entry.preFocus);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdelete entry.press;\n\t\t\t\t\t// Restore focus to this overlay when showing (if it's actually visible)\n\t\t\t\t\tif (!options?.nonCapturing && this.isOverlayVisible(entry)) {\n\t\t\t\t\t\tentry.focusOrder = ++this.focusOrderCounter;\n\t\t\t\t\t\tthis.setFocus(component);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tisHidden: () => entry.hidden,\n\t\t\tfocus: () => {\n\t\t\t\tif (!this.overlayStack.includes(entry) || !this.isOverlayVisible(entry)) return;\n\t\t\t\tentry.focusOrder = ++this.focusOrderCounter;\n\t\t\t\tthis.setFocus(component);\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tunfocus: (unfocusOptions) => {\n\t\t\t\tconst isFocused = this.focusedComponent === component;\n\t\t\t\tconst restoreState = this.overlayFocusRestore;\n\t\t\t\tconst hasPendingRestore = restoreState.status !== \"inactive\" && restoreState.overlay === entry;\n\t\t\t\tif (!isFocused && !hasPendingRestore) return;\n\t\t\t\tif (\n\t\t\t\t\trestoreState.status === \"blocked\" &&\n\t\t\t\t\trestoreState.overlay === entry &&\n\t\t\t\t\tthis.focusedComponent === restoreState.blockedBy\n\t\t\t\t) {\n\t\t\t\t\tif (unfocusOptions) {\n\t\t\t\t\t\tthis.overlayFocusRestore = {\n\t\t\t\t\t\t\tstatus: \"blocked\",\n\t\t\t\t\t\t\toverlay: entry,\n\t\t\t\t\t\t\tblockedBy: restoreState.blockedBy,\n\t\t\t\t\t\t\tresume: { status: \"focus-target\", target: unfocusOptions.target },\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t\t\t}\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.clearOverlayFocusRestoreFor(entry);\n\t\t\t\tif (isFocused || unfocusOptions) {\n\t\t\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\t\t\tconst fallbackTarget = topVisible && topVisible !== entry ? topVisible.component : entry.preFocus;\n\t\t\t\t\tthis.setFocus(unfocusOptions ? unfocusOptions.target : fallbackTarget);\n\t\t\t\t}\n\t\t\t\tthis.requestRender();\n\t\t\t},\n\t\t\tisFocused: () => this.focusedComponent === component,\n\t\t\tgetBounds: () => {\n\t\t\t\tif (!this.overlayStack.includes(entry) || !this.isOverlayVisible(entry) || !entry.bounds) return undefined;\n\t\t\t\treturn { ...entry.bounds };\n\t\t\t},\n\t\t};\n\t}\n\n\t/** Hide the topmost overlay and restore previous focus. */\n\thideOverlay(): void {\n\t\tconst overlay = this.overlayStack[this.overlayStack.length - 1];\n\t\tif (!overlay) return;\n\t\tendOverlayPresses(overlay, ++this.overlayVisibilityVersion);\n\t\tthis.clearOverlayFocusRestoreFor(overlay);\n\t\tthis.retargetOverlayPreFocus(overlay);\n\t\tthis.overlayStack.pop();\n\t\tif (this.focusedComponent === overlay.component) {\n\t\t\t// Find topmost visible overlay, or fall back to preFocus\n\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\tthis.setFocus(topVisible?.component ?? overlay.preFocus);\n\t\t}\n\t\tif (this.overlayStack.length === 0) this.hideTerminalCursor();\n\t\tthis.requestRender();\n\t}\n\n\t/** Hide the cursor while running. After stop(), the shell owns the cursor and it must stay visible. */\n\tprivate hideTerminalCursor(): void {\n\t\tif (!this.stopped) this.terminal.hideCursor();\n\t}\n\n\t/** Check if there are any visible overlays */\n\thasOverlay(): boolean {\n\t\treturn this.overlayStack.some((o) => this.isOverlayVisible(o));\n\t}\n\n\t/** Check if the focused component is a visible overlay */\n\tprotected isOverlayFocused(): boolean {\n\t\treturn this.overlayStack.some(\n\t\t\t(entry) => entry.component === this.focusedComponent && this.isOverlayVisible(entry),\n\t\t);\n\t}\n\n\t/** Keep overlay containers as keyboard focus owners when a nested control is clicked. */\n\tprotected resolveMouseFocusTarget(component: Component): Component {\n\t\tfor (let index = this.overlayStack.length - 1; index >= 0; index--) {\n\t\t\tconst overlay = this.overlayStack[index]!;\n\t\t\tif (this.isOverlayVisible(overlay) && this.containsComponent(overlay.component, component)) {\n\t\t\t\treturn overlay.component;\n\t\t\t}\n\t\t}\n\t\treturn component;\n\t}\n\n\t/** Dispatch to the visually topmost overlay under the pointer. */\n\t/** The topmost overlay the last frame drew at screen cell `x`, `y`, and the rectangle it was drawn in. */\n\tprotected overlayAt(\n\t\tx: number,\n\t\ty: number,\n\t): { component: Component; row: number; col: number; width: number; height: number } | undefined {\n\t\tfor (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {\n\t\t\tconst layout = this.renderedOverlayLayouts[index]!;\n\t\t\tif (x >= layout.col && x < layout.col + layout.width && y >= layout.row && y < layout.row + layout.height) {\n\t\t\t\tconst { row, col, width, height } = layout;\n\t\t\t\treturn { component: layout.entry.component, row, col, width, height };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprotected dispatchMouseToOverlay(event: TuiMouseEvent, pressAt?: number): OverlayMouseHit {\n\t\tfor (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {\n\t\t\tconst layout = this.renderedOverlayLayouts[index]!;\n\t\t\tif (\n\t\t\t\tevent.screenX < layout.col ||\n\t\t\t\tevent.screenX >= layout.col + layout.width ||\n\t\t\t\tevent.screenY < layout.row ||\n\t\t\t\tevent.screenY >= layout.row + layout.height\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Snapshot before dispatch: the component can hide and show its own overlay inside the handler.\n\t\t\tconst hit: OverlayMouseHit = { hit: true };\n\t\t\tif (pressAt !== undefined) {\n\t\t\t\tif ((layout.entry.lastHiddenAt ?? 0) > pressAt) hit.press = REVOKED_OVERLAY_PRESS;\n\t\t\t\telse {\n\t\t\t\t\tlayout.entry.press ??= { revoked: false };\n\t\t\t\t\thit.press = layout.entry.press;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst result = dispatchMouseEvent(layout.entry.component, {\n\t\t\t\t...event,\n\t\t\t\tx: event.screenX - layout.col,\n\t\t\t\ty: event.screenY - layout.row,\n\t\t\t\twidth: layout.width,\n\t\t\t\theight: layout.height,\n\t\t\t});\n\t\t\tif (result) hit.result = result.focus ? { ...result, focusTarget: layout.entry.component } : result;\n\t\t\treturn hit;\n\t\t}\n\t\treturn { hit: false };\n\t}\n\n\t/** Check if an overlay entry is currently visible */\n\tprivate isOverlayVisible(entry: OverlayStackEntry): boolean {\n\t\tif (entry.hidden) return false;\n\t\tif (entry.options?.visible) {\n\t\t\treturn entry.options.visible(this.terminal.columns, this.terminal.rows);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Find the visual-frontmost visible capturing overlay, if any */\n\tprivate getTopmostVisibleOverlay(): OverlayStackEntry | undefined {\n\t\tlet topmost: OverlayStackEntry | undefined;\n\t\tfor (const overlay of this.overlayStack) {\n\t\t\tif (overlay.options?.nonCapturing || !this.isOverlayVisible(overlay)) continue;\n\t\t\tif (!topmost || overlay.focusOrder > topmost.focusOrder) {\n\t\t\t\ttopmost = overlay;\n\t\t\t}\n\t\t}\n\t\treturn topmost;\n\t}\n\n\toverride invalidate(): void {\n\t\tfor (const root of this.getMountedRoots()) root.invalidate();\n\t\tfor (const overlay of this.overlayStack) overlay.component.invalidate();\n\t}\n\n\tstart(): void {\n\t\tthis.stopped = false;\n\t\tprocess.off(\"exit\", this.exitRestoreHandler);\n\t\tprocess.on(\"exit\", this.exitRestoreHandler);\n\t\tthis.beforeTerminalStart();\n\t\tthis.terminal.start(\n\t\t\t(data) => this.handleTerminalInput(data),\n\t\t\t() => this.requestRender(),\n\t\t);\n\t\tthis.afterTerminalStart();\n\t\tthis.terminal.hideCursor();\n\t\tif (this.terminalColorSchemeNotificationsEnabled) {\n\t\t\tthis.terminal.write(\"\\x1b[?2031h\");\n\t\t}\n\t\tthis.queryCellSize();\n\t\tthis.requestRender();\n\t}\n\n\taddInputListener(listener: TuiInputListener): () => void {\n\t\tthis.inputListeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.inputListeners.delete(listener);\n\t\t};\n\t}\n\n\tremoveInputListener(listener: TuiInputListener): void {\n\t\tthis.inputListeners.delete(listener);\n\t}\n\n\tsetHintCommandHandler(handler: ((command: string) => void) | undefined): void {\n\t\tthis.hintCommandHandler = handler;\n\t}\n\n\t/**\n\t * Run what a clicked key hint names: its key goes through the input path as if it were pressed, so it acts exactly\n\t * as the key does, confirmations included; a slash command goes to the command handler.\n\t */\n\tprotected runHintAction(action: HintAction): void {\n\t\tif (action.kind === \"command\") {\n\t\t\tthis.hintCommandHandler?.(action.command);\n\t\t\tthis.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tconst data = hintKeyInput(action);\n\t\tif (data !== undefined) runAsHintActivation(() => this.handleTerminalInput(data));\n\t}\n\n\t/**\n\t * Whether keys reach what is drawn at screen cell `x`, `y`: the overlay that holds the keyboard when one does, and\n\t * otherwise what is drawn outside the overlays.\n\t */\n\tprotected takesKeysAt(x: number, y: number): boolean {\n\t\tconst focused = this.focusedComponent;\n\t\tlet keyOverlay = focused\n\t\t\t? this.overlayStack.find((entry) => entry.component === focused && this.isOverlayVisible(entry))?.component\n\t\t\t: undefined;\n\t\tif (keyOverlay === undefined) {\n\t\t\tconst restore = this.getVisibleOverlayFocusRestore();\n\t\t\tif (restore.status === \"eligible\") keyOverlay = restore.overlay.component;\n\t\t}\n\t\tconst drawn = this.overlayAt(x, y);\n\t\treturn drawn === undefined ? keyOverlay === undefined : drawn.component === keyOverlay;\n\t}\n\n\tonTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void {\n\t\tthis.terminalColorSchemeListeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.terminalColorSchemeListeners.delete(listener);\n\t\t};\n\t}\n\n\tsetTerminalColorSchemeNotifications(enabled: boolean): void {\n\t\tif (this.terminalColorSchemeNotificationsEnabled === enabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis.terminalColorSchemeNotificationsEnabled = enabled;\n\t\tif (!this.stopped) {\n\t\t\tthis.terminal.write(enabled ? \"\\x1b[?2031h\" : \"\\x1b[?2031l\");\n\t\t}\n\t}\n\n\tprivate queryCellSize(): void {\n\t\t// Only query if terminal supports images (cell size is only used for image rendering)\n\t\tif (!getCapabilities().images) {\n\t\t\treturn;\n\t\t}\n\t\t// Query terminal for cell size in pixels: CSI 16 t\n\t\t// Response format: CSI 6 ; height ; width t\n\t\tthis.terminal.write(\"\\x1b[16t\");\n\t}\n\n\tstop(options: TuiStopOptions = {}): void {\n\t\tthis.stopped = true;\n\t\tprocess.off(\"exit\", this.exitRestoreHandler);\n\t\tthis.cancelRenderTimer();\n\t\tif (this.terminalColorSchemeNotificationsEnabled) {\n\t\t\tthis.terminal.write(\"\\x1b[?2031l\");\n\t\t}\n\t\tthis.beforeTerminalStop(options);\n\t\tthis.terminal.showCursor();\n\t\tthis.terminal.stop();\n\t\tthis.afterTerminalStop(options);\n\t}\n\n\twhenStopped(): Promise<void> {\n\t\treturn this.stopOutput;\n\t}\n\n\trenderNow(force = false): void {\n\t\tif (force) this.resetRenderState();\n\t\tthis.renderRequested = false;\n\t\tthis.cancelRenderTimer();\n\t\tthis.lastRenderAt = performance.now();\n\t\tthis.doRender();\n\t}\n\n\trequestRender(force = false): void {\n\t\tif (force) {\n\t\t\tthis.resetRenderState();\n\t\t\tthis.requestImmediateRender();\n\t\t\treturn;\n\t\t}\n\t\tif (this.renderRequested) return;\n\t\tthis.renderRequested = true;\n\t\tprocess.nextTick(() => this.scheduleRender());\n\t}\n\n\trequestImmediateRender(): void {\n\t\tthis.cancelRenderTimer();\n\t\tthis.renderRequested = true;\n\t\tif (this.immediateRenderScheduled) return;\n\t\tthis.immediateRenderScheduled = true;\n\t\tprocess.nextTick(() => {\n\t\t\tthis.immediateRenderScheduled = false;\n\t\t\tif (this.stopped || !this.renderRequested) return;\n\t\t\t// A previously queued scheduleRender() can create a timer before this\n\t\t\t// callback runs. User input must preempt that throttled frame.\n\t\t\tthis.cancelRenderTimer();\n\t\t\tthis.renderRequested = false;\n\t\t\tthis.lastRenderAt = performance.now();\n\t\t\tthis.doRender();\n\t\t});\n\t}\n\n\tprivate cancelRenderTimer(): void {\n\t\tif (!this.renderTimer) return;\n\t\tclearTimeout(this.renderTimer);\n\t\tthis.renderTimer = undefined;\n\t}\n\n\tprivate scheduleRender(): void {\n\t\tif (this.stopped || this.renderTimer || !this.renderRequested) {\n\t\t\treturn;\n\t\t}\n\t\tconst elapsed = performance.now() - this.lastRenderAt;\n\t\tconst delay = Math.max(0, TuiBase.MIN_RENDER_INTERVAL_MS - elapsed);\n\t\tthis.renderTimer = setTimeout(() => {\n\t\t\tthis.renderTimer = undefined;\n\t\t\tif (this.stopped || !this.renderRequested) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.renderRequested = false;\n\t\t\tthis.lastRenderAt = performance.now();\n\t\t\tthis.doRender();\n\t\t\tif (this.renderRequested) {\n\t\t\t\tthis.scheduleRender();\n\t\t\t}\n\t\t}, delay);\n\t}\n\n\tprivate handleTerminalInput(data: string): void {\n\t\tif (this.consumeTerminalColorResponse(data)) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.consumeTerminalColorSchemeReport(data)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.inputListeners.size > 0) {\n\t\t\tlet current = data;\n\t\t\tfor (const listener of this.inputListeners) {\n\t\t\t\tconst result = listener(current);\n\t\t\t\tif (result?.consume) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (result?.data !== undefined) {\n\t\t\t\t\tcurrent = result.data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (current.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdata = current;\n\t\t}\n\n\t\t// Consume terminal cell size responses without blocking unrelated input.\n\t\tif (this.consumeCellSizeResponse(data)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Global debug key handler (Shift+Ctrl+D)\n\t\tif (matchesKey(data, \"shift+ctrl+d\") && this.onDebug) {\n\t\t\tthis.onDebug();\n\t\t\treturn;\n\t\t}\n\n\t\t// If focused component is an overlay, verify it's still visible\n\t\t// (visibility can change due to terminal resize or visible() callback)\n\t\tconst focusedOverlay = this.overlayStack.find((o) => o.component === this.focusedComponent);\n\t\tif (focusedOverlay && !this.isOverlayVisible(focusedOverlay)) {\n\t\t\t// Focused overlay is no longer visible, redirect to topmost visible overlay\n\t\t\tconst topVisible = this.getTopmostVisibleOverlay();\n\t\t\tif (topVisible) {\n\t\t\t\tthis.setFocus(topVisible.component);\n\t\t\t} else {\n\t\t\t\tthis.setFocusInternal({ component: focusedOverlay.preFocus, overlayFocusRestore: \"preserve\" });\n\t\t\t}\n\t\t}\n\n\t\tconst focusIsOverlay = this.overlayStack.some((o) => o.component === this.focusedComponent);\n\t\tif (!focusIsOverlay) {\n\t\t\tconst restoreState = this.getVisibleOverlayFocusRestore();\n\t\t\tif (restoreState.status === \"eligible\") {\n\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t} else if (restoreState.status === \"blocked\" && restoreState.blockedBy !== this.focusedComponent) {\n\t\t\t\tif (restoreState.resume.status === \"restore-overlay\") {\n\t\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t\t} else {\n\t\t\t\t\tthis.clearOverlayFocusRestore();\n\t\t\t\t\tthis.setFocus(restoreState.resume.target);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Pass input to focused component (including Ctrl+C)\n\t\t// The focused component can decide how to handle Ctrl+C\n\t\tif (this.focusedComponent?.handleInput) {\n\t\t\t// Filter out key release events unless component opts in\n\t\t\tif (isKeyRelease(data) && !this.focusedComponent.wantsKeyRelease) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst answer: unknown = this.focusedComponent.handleInput(data);\n\t\t\t// Keyboard input is latency-sensitive. Avoid the throttled timer path,\n\t\t\t// where even setTimeout(0) can take a full 16 ms tick on Windows.\n\t\t\t// A component that answers asynchronously, such as a view another process draws, shows the key only once\n\t\t\t// its answer arrives: painting before then would repaint the frame the key has not reached yet.\n\t\t\tif (answer instanceof Promise) {\n\t\t\t\tconst repaint = (): void => this.requestImmediateRender();\n\t\t\t\tvoid answer.then(repaint, repaint);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.requestImmediateRender();\n\t\t}\n\t}\n\n\tprivate consumeTerminalColorResponse(data: string): boolean {\n\t\tconst query = this.pendingTerminalColorQueries[0];\n\t\tif (!query) {\n\t\t\treturn false;\n\t\t}\n\t\tif (DEVICE_ATTRIBUTES_RESPONSE_PATTERN.test(data)) {\n\t\t\tthis.pendingTerminalColorQueries.shift();\n\t\t\tthis.completeTerminalColorQuery(query);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst response = parseOscColorResponse(data);\n\t\tif (!response) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { target, rgb } = response;\n\t\tconst key = String(target);\n\t\tif (!query.deliver || query.replied.has(key)) {\n\t\t\treturn true;\n\t\t}\n\t\tquery.replied.add(key);\n\t\tif (target === \"foreground\") {\n\t\t\tquery.foreground = rgb;\n\t\t} else if (target === \"background\") {\n\t\t\tquery.background = rgb;\n\t\t} else if (target < TERMINAL_PALETTE_SIZE) {\n\t\t\tquery.palette[target] = rgb;\n\t\t}\n\t\tif (query.replied.size === TERMINAL_COLOR_REPLY_COUNT) {\n\t\t\tthis.completeTerminalColorQuery(query);\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate terminalColorQueryResult(query: PendingTerminalColorQuery): TerminalColors {\n\t\tconst palette = query.palette.every((color) => color !== undefined) ? (query.palette as RgbColor[]) : undefined;\n\t\treturn { foreground: query.foreground, background: query.background, palette };\n\t}\n\n\tprivate completeTerminalColorQuery(query: PendingTerminalColorQuery): void {\n\t\tconst deliver = query.deliver;\n\t\tquery.deliver = undefined;\n\t\tclearTimeout(query.timer);\n\t\tdeliver?.(this.terminalColorQueryResult(query));\n\t}\n\n\tprivate consumeTerminalColorSchemeReport(data: string): boolean {\n\t\tconst scheme = parseTerminalColorSchemeReport(data);\n\t\tif (!scheme) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const listener of this.terminalColorSchemeListeners) {\n\t\t\tlistener(scheme);\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate consumeCellSizeResponse(data: string): boolean {\n\t\t// Response format: ESC [ 6 ; height ; width t\n\t\tconst match = data.match(/^\\x1b\\[6;(\\d+);(\\d+)t$/);\n\t\tif (!match) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst heightPx = parseInt(match[1], 10);\n\t\tconst widthPx = parseInt(match[2], 10);\n\t\tif (heightPx <= 0 || widthPx <= 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tsetCellDimensions({ widthPx, heightPx });\n\t\t// Invalidate all components so images re-render with correct dimensions.\n\t\tthis.invalidate();\n\t\tthis.requestRender();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve overlay layout from options.\n\t * Returns { width, row, col, maxHeight } for rendering.\n\t */\n\tprivate resolveOverlayLayout(\n\t\toptions: OverlayOptions | undefined,\n\t\toverlayHeight: number,\n\t\ttermWidth: number,\n\t\ttermHeight: number,\n\t): { width: number; row: number; col: number; maxHeight: number | undefined } {\n\t\tconst opt = options ?? {};\n\n\t\t// Parse margin (clamp to non-negative)\n\t\tconst margin =\n\t\t\ttypeof opt.margin === \"number\"\n\t\t\t\t? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }\n\t\t\t\t: (opt.margin ?? {});\n\t\tconst marginTop = Math.max(0, margin.top ?? 0);\n\t\tconst marginRight = Math.max(0, margin.right ?? 0);\n\t\tconst marginBottom = Math.max(0, margin.bottom ?? 0);\n\t\tconst marginLeft = Math.max(0, margin.left ?? 0);\n\n\t\t// Available space after margins\n\t\tconst availWidth = Math.max(1, termWidth - marginLeft - marginRight);\n\t\tconst availHeight = Math.max(1, termHeight - marginTop - marginBottom);\n\n\t\t// === Resolve width ===\n\t\tlet width = parseSizeValue(opt.width, termWidth) ?? Math.min(80, availWidth);\n\t\t// Apply minWidth\n\t\tif (opt.minWidth !== undefined) {\n\t\t\twidth = Math.max(width, opt.minWidth);\n\t\t}\n\t\t// Clamp to available space\n\t\twidth = Math.max(1, Math.min(width, availWidth));\n\n\t\t// === Resolve maxHeight ===\n\t\tlet maxHeight = parseSizeValue(opt.maxHeight, termHeight);\n\t\t// Clamp to available space\n\t\tif (maxHeight !== undefined) {\n\t\t\tmaxHeight = Math.max(1, Math.min(maxHeight, availHeight));\n\t\t}\n\n\t\t// Effective overlay height (may be clamped by maxHeight)\n\t\tconst effectiveHeight = maxHeight !== undefined ? Math.min(overlayHeight, maxHeight) : overlayHeight;\n\n\t\t// === Resolve position ===\n\t\tlet row: number;\n\t\tlet col: number;\n\n\t\tif (opt.row !== undefined) {\n\t\t\tif (typeof opt.row === \"string\") {\n\t\t\t\t// Percentage: 0% = top, 100% = bottom (overlay stays within bounds)\n\t\t\t\tconst match = opt.row.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst maxRow = Math.max(0, availHeight - effectiveHeight);\n\t\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\t\trow = marginTop + Math.floor(maxRow * percent);\n\t\t\t\t} else {\n\t\t\t\t\t// Invalid format, fall back to center\n\t\t\t\t\trow = this.resolveAnchorRow(\"center\", effectiveHeight, availHeight, marginTop);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Absolute row position\n\t\t\t\trow = opt.row;\n\t\t\t}\n\t\t} else {\n\t\t\t// Anchor-based (default: center)\n\t\t\tconst anchor = opt.anchor ?? \"center\";\n\t\t\trow = this.resolveAnchorRow(anchor, effectiveHeight, availHeight, marginTop);\n\t\t}\n\n\t\tif (opt.col !== undefined) {\n\t\t\tif (typeof opt.col === \"string\") {\n\t\t\t\t// Percentage: 0% = left, 100% = right (overlay stays within bounds)\n\t\t\t\tconst match = opt.col.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst maxCol = Math.max(0, availWidth - width);\n\t\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\t\tcol = marginLeft + Math.floor(maxCol * percent);\n\t\t\t\t} else {\n\t\t\t\t\t// Invalid format, fall back to center\n\t\t\t\t\tcol = this.resolveAnchorCol(\"center\", width, availWidth, marginLeft);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Absolute column position\n\t\t\t\tcol = opt.col;\n\t\t\t}\n\t\t} else {\n\t\t\t// Anchor-based (default: center)\n\t\t\tconst anchor = opt.anchor ?? \"center\";\n\t\t\tcol = this.resolveAnchorCol(anchor, width, availWidth, marginLeft);\n\t\t}\n\n\t\t// Apply offsets\n\t\tif (opt.offsetY !== undefined) row += opt.offsetY;\n\t\tif (opt.offsetX !== undefined) col += opt.offsetX;\n\n\t\t// Clamp to terminal bounds (respecting margins)\n\t\trow = Math.max(marginTop, Math.min(row, termHeight - marginBottom - effectiveHeight));\n\t\tcol = Math.max(marginLeft, Math.min(col, termWidth - marginRight - width));\n\n\t\treturn { width, row, col, maxHeight };\n\t}\n\n\tprivate resolveAnchorRow(anchor: OverlayAnchor, height: number, availHeight: number, marginTop: number): number {\n\t\tswitch (anchor) {\n\t\t\tcase \"top-left\":\n\t\t\tcase \"top-center\":\n\t\t\tcase \"top-right\":\n\t\t\t\treturn marginTop;\n\t\t\tcase \"bottom-left\":\n\t\t\tcase \"bottom-center\":\n\t\t\tcase \"bottom-right\":\n\t\t\t\treturn marginTop + availHeight - height;\n\t\t\tcase \"left-center\":\n\t\t\tcase \"center\":\n\t\t\tcase \"right-center\":\n\t\t\t\treturn marginTop + Math.floor((availHeight - height) / 2);\n\t\t}\n\t}\n\n\tprivate resolveAnchorCol(anchor: OverlayAnchor, width: number, availWidth: number, marginLeft: number): number {\n\t\tswitch (anchor) {\n\t\t\tcase \"top-left\":\n\t\t\tcase \"left-center\":\n\t\t\tcase \"bottom-left\":\n\t\t\t\treturn marginLeft;\n\t\t\tcase \"top-right\":\n\t\t\tcase \"right-center\":\n\t\t\tcase \"bottom-right\":\n\t\t\t\treturn marginLeft + availWidth - width;\n\t\t\tcase \"top-center\":\n\t\t\tcase \"center\":\n\t\t\tcase \"bottom-center\":\n\t\t\t\treturn marginLeft + Math.floor((availWidth - width) / 2);\n\t\t}\n\t}\n\n\t/** Composite all overlays into content lines (sorted by focusOrder, higher = on top). */\n\t/**\n\t * Whether the overlays composited in the last frame covered every cell of a `termWidth` x `termHeight` screen\n\t * and are still shown: content under them cannot show through until one of them changes.\n\t */\n\tprotected overlaysCoverScreen(termWidth: number, termHeight: number): boolean {\n\t\treturn this.renderedOverlayLayouts.some(\n\t\t\t(layout) =>\n\t\t\t\tlayout.row === 0 &&\n\t\t\t\tlayout.col === 0 &&\n\t\t\t\tlayout.width >= termWidth &&\n\t\t\t\tlayout.height >= termHeight &&\n\t\t\t\tthis.overlayStack.includes(layout.entry) &&\n\t\t\t\tthis.isOverlayVisible(layout.entry),\n\t\t);\n\t}\n\n\tprotected compositeOverlays(lines: string[], termWidth: number, termHeight: number): string[] {\n\t\tif (this.overlayStack.length === 0) {\n\t\t\tthis.renderedOverlayLayouts = [];\n\t\t\treturn lines;\n\t\t}\n\t\tconst result = [...lines];\n\n\t\tfor (const entry of this.overlayStack) entry.bounds = undefined;\n\n\t\t// Pre-render all visible overlays and calculate positions\n\t\tconst rendered: { entry: OverlayStackEntry; overlayLines: string[]; row: number; col: number; w: number }[] = [];\n\t\tlet minLinesNeeded = result.length;\n\n\t\tconst visibleEntries = this.overlayStack.filter((e) => this.isOverlayVisible(e));\n\t\tvisibleEntries.sort((a, b) => a.focusOrder - b.focusOrder);\n\t\tfor (const entry of visibleEntries) {\n\t\t\tconst { component, options } = entry;\n\n\t\t\t// Get layout with height=0 first to determine width and maxHeight\n\t\t\t// (width and maxHeight don't depend on overlay height)\n\t\t\tconst { width, maxHeight } = this.resolveOverlayLayout(options, 0, termWidth, termHeight);\n\n\t\t\t// Render component at calculated width\n\t\t\tlet overlayLines = this.resolveFakeCursors(component.render(width));\n\n\t\t\t// Apply maxHeight if specified\n\t\t\tif (maxHeight !== undefined && overlayLines.length > maxHeight) {\n\t\t\t\toverlayLines = overlayLines.slice(0, maxHeight);\n\t\t\t}\n\n\t\t\t// Get final row/col with actual overlay height\n\t\t\tconst { row, col } = this.resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);\n\t\t\tentry.bounds = { row, col, width, height: overlayLines.length };\n\n\t\t\trendered.push({ entry, overlayLines, row, col, w: width });\n\t\t\tminLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);\n\t\t}\n\t\tthis.renderedOverlayLayouts = rendered.map(({ entry, row, col, w, overlayLines }) => ({\n\t\t\tentry,\n\t\t\trow,\n\t\t\tcol,\n\t\t\twidth: w,\n\t\t\theight: overlayLines.length,\n\t\t}));\n\n\t\t// Pad to at least terminal height so overlays have screen-relative positions.\n\t\t// Excludes maxLinesRendered: the historical high-water mark caused self-reinforcing\n\t\t// inflation that pushed content into scrollback on terminal widen.\n\t\tconst workingHeight = Math.max(result.length, termHeight, minLinesNeeded);\n\n\t\t// Extend result with empty lines if content is too short for overlay placement or working area\n\t\twhile (result.length < workingHeight) {\n\t\t\tresult.push(\"\");\n\t\t}\n\n\t\tconst viewportStart = Math.max(0, workingHeight - termHeight);\n\n\t\t// Composite each overlay\n\t\tfor (const { overlayLines, row, col, w } of rendered) {\n\t\t\tfor (let i = 0; i < overlayLines.length; i++) {\n\t\t\t\tconst idx = viewportStart + row + i;\n\t\t\t\tif (idx >= 0 && idx < result.length) {\n\t\t\t\t\t// Defensive: truncate overlay line to declared width before compositing\n\t\t\t\t\t// (components should already respect width, but this ensures it)\n\t\t\t\t\tconst truncatedOverlayLine =\n\t\t\t\t\t\tvisibleWidth(overlayLines[i]) > w ? sliceByColumn(overlayLines[i], 0, w, true) : overlayLines[i];\n\t\t\t\t\tresult[idx] = this.compositeLineAt(result[idx], truncatedOverlayLine, col, w, termWidth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprotected applyLineResets(lines: string[]): string[] {\n\t\tconst reset = SEGMENT_RESET;\n\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\tconst line = lines[i];\n\t\t\tif (!isImageLine(line)) {\n\t\t\t\t// Cursor and hint markers are internal render metadata and must never reach terminal output.\n\t\t\t\tlines[i] = normalizeTerminalOutput(stripHintMarkers(line.replaceAll(CURSOR_MARKER, \"\"))) + reset;\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate compositeLineAt(\n\t\tbaseLine: string,\n\t\toverlayLine: string,\n\t\tstartCol: number,\n\t\toverlayWidth: number,\n\t\ttotalWidth: number,\n\t): string {\n\t\treturn compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);\n\t}\n\n\t/**\n\t * Find and extract cursor position from rendered lines.\n\t * Searches for CURSOR_MARKER, calculates its position, and strips it from the output.\n\t * Only scans the bottom terminal height lines (visible viewport).\n\t * @param lines - Rendered lines to search\n\t * @param height - Terminal height (visible viewport size)\n\t * @returns Cursor position { row, col } or null if no marker found\n\t */\n\tprotected extractCursorPosition(lines: string[], height: number): { row: number; col: number } | null {\n\t\t// Only scan the bottom `height` lines (visible viewport)\n\t\tconst viewportTop = Math.max(0, lines.length - height);\n\t\tfor (let row = lines.length - 1; row >= viewportTop; row--) {\n\t\t\tconst line = lines[row];\n\t\t\tconst markerIndex = line.indexOf(CURSOR_MARKER);\n\t\t\tif (markerIndex !== -1) {\n\t\t\t\t// Calculate visual column (width of text before marker)\n\t\t\t\tconst beforeMarker = line.slice(0, markerIndex);\n\t\t\t\tconst col = visibleWidth(beforeMarker);\n\n\t\t\t\t// Strip all markers from the selected line. The first marker determines the\n\t\t\t\t// hardware cursor position; any others are stale internal sentinels.\n\t\t\t\tlines[row] = line.replaceAll(CURSOR_MARKER, \"\");\n\n\t\t\t\treturn { row, col };\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Resolve fake cursor markers to reverse video. When the hardware cursor is shown, a fake cursor\n\t * directly after CURSOR_MARKER is dropped because the terminal cursor is drawn there. Fake cursors\n\t * of components without focus have no CURSOR_MARKER and stay visible.\n\t */\n\tprotected resolveFakeCursors(lines: string[]): string[] {\n\t\treturn lines.map((line) => {\n\t\t\tif (!line.includes(FAKE_CURSOR_START)) return line;\n\t\t\tconst resolved = this.showHardwareCursor ? line.replace(FOCUSED_FAKE_CURSOR, \"$1$2\") : line;\n\t\t\treturn resolved.replaceAll(FAKE_CURSOR_START, \"\\x1b[7m\").replaceAll(FAKE_CURSOR_END, \"\\x1b[27m\");\n\t\t});\n\t}\n\n\t/**\n\t * Query the terminal's theme colors: the default foreground (OSC 10), the default background\n\t * (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the\n\t * replies. Resolves when the DA1 reply or all color replies arrive, or when the timeout expires.\n\t * Colors the terminal did not report are undefined; the palette is only set when all 16 arrived.\n\t * @param timeoutMs Query timeout in milliseconds, for terminals that do not answer DA1 either.\n\t * @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.\n\t */\n\tqueryTerminalColors({\n\t\ttimeoutMs,\n\t\tonLateReply,\n\t}: {\n\t\ttimeoutMs: number;\n\t\tonLateReply?: (colors: TerminalColors) => void;\n\t}): Promise<TerminalColors> {\n\t\treturn new Promise((resolve) => {\n\t\t\tconst query: PendingTerminalColorQuery = {\n\t\t\t\tpalette: Array.from({ length: TERMINAL_PALETTE_SIZE }, () => undefined),\n\t\t\t\treplied: new Set(),\n\t\t\t\tdeliver: resolve,\n\t\t\t\ttimer: undefined,\n\t\t\t};\n\t\t\t// Resolve with the replies so far, and keep collecting late replies for `onLateReply`.\n\t\t\tquery.timer = setTimeout(() => {\n\t\t\t\tquery.deliver = onLateReply;\n\t\t\t\tresolve(this.terminalColorQueryResult(query));\n\t\t\t}, timeoutMs);\n\t\t\tthis.pendingTerminalColorQueries.push(query);\n\t\t\tthis.terminal.write(TERMINAL_COLOR_QUERY);\n\t\t});\n\t}\n}\n"]}
|
package/dist/undo-stack.d.ts
CHANGED
|
@@ -13,5 +13,7 @@ export declare class UndoStack<S> {
|
|
|
13
13
|
/** Remove all snapshots. */
|
|
14
14
|
clear(): void;
|
|
15
15
|
get length(): number;
|
|
16
|
+
/** A detached copy: later pushes and pops on either stack leave the other unchanged. */
|
|
17
|
+
clone(): UndoStack<S>;
|
|
16
18
|
}
|
|
17
19
|
//# sourceMappingURL=undo-stack.d.ts.map
|
package/dist/undo-stack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undo-stack.d.ts","sourceRoot":"","sources":["../src/undo-stack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,SAAS,CAAC,CAAC;IACvB,OAAO,CAAC,KAAK,CAAW;IAExB,2DAA2D;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAEnB;IAED,sEAAsE;IACtE,GAAG,IAAI,CAAC,GAAG,SAAS,CAEnB;IAED,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAEZ;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;CACD"}
|
|
1
|
+
{"version":3,"file":"undo-stack.d.ts","sourceRoot":"","sources":["../src/undo-stack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,SAAS,CAAC,CAAC;IACvB,OAAO,CAAC,KAAK,CAAW;IAExB,2DAA2D;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAEnB;IAED,sEAAsE;IACtE,GAAG,IAAI,CAAC,GAAG,SAAS,CAEnB;IAED,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAEZ;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,wFAAwF;IACxF,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAIpB;CACD"}
|
package/dist/undo-stack.js
CHANGED
|
@@ -21,5 +21,11 @@ export class UndoStack {
|
|
|
21
21
|
get length() {
|
|
22
22
|
return this.stack.length;
|
|
23
23
|
}
|
|
24
|
+
/** A detached copy: later pushes and pops on either stack leave the other unchanged. */
|
|
25
|
+
clone() {
|
|
26
|
+
const copy = new UndoStack();
|
|
27
|
+
copy.stack = structuredClone(this.stack);
|
|
28
|
+
return copy;
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
//# sourceMappingURL=undo-stack.js.map
|
package/dist/undo-stack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undo-stack.js","sourceRoot":"","sources":["../src/undo-stack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACb,KAAK,GAAQ,EAAE,CAAC;IAExB,2DAA2D;IAC3D,IAAI,CAAC,KAAQ;QACZ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,sEAAsE;IACtE,GAAG;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,4BAA4B;IAC5B,KAAK;QACJ,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/**\n * Generic undo stack with clone-on-push semantics.\n *\n * Stores deep clones of state snapshots. Popped snapshots are returned\n * directly (no re-cloning) since they are already detached.\n */\nexport class UndoStack<S> {\n\tprivate stack: S[] = [];\n\n\t/** Push a deep clone of the given state onto the stack. */\n\tpush(state: S): void {\n\t\tthis.stack.push(structuredClone(state));\n\t}\n\n\t/** Pop and return the most recent snapshot, or undefined if empty. */\n\tpop(): S | undefined {\n\t\treturn this.stack.pop();\n\t}\n\n\t/** Remove all snapshots. */\n\tclear(): void {\n\t\tthis.stack.length = 0;\n\t}\n\n\tget length(): number {\n\t\treturn this.stack.length;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"undo-stack.js","sourceRoot":"","sources":["../src/undo-stack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACb,KAAK,GAAQ,EAAE,CAAC;IAExB,2DAA2D;IAC3D,IAAI,CAAC,KAAQ;QACZ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,sEAAsE;IACtE,GAAG;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,4BAA4B;IAC5B,KAAK;QACJ,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,wFAAwF;IACxF,KAAK;QACJ,MAAM,IAAI,GAAG,IAAI,SAAS,EAAK,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/**\n * Generic undo stack with clone-on-push semantics.\n *\n * Stores deep clones of state snapshots. Popped snapshots are returned\n * directly (no re-cloning) since they are already detached.\n */\nexport class UndoStack<S> {\n\tprivate stack: S[] = [];\n\n\t/** Push a deep clone of the given state onto the stack. */\n\tpush(state: S): void {\n\t\tthis.stack.push(structuredClone(state));\n\t}\n\n\t/** Pop and return the most recent snapshot, or undefined if empty. */\n\tpop(): S | undefined {\n\t\treturn this.stack.pop();\n\t}\n\n\t/** Remove all snapshots. */\n\tclear(): void {\n\t\tthis.stack.length = 0;\n\t}\n\n\tget length(): number {\n\t\treturn this.stack.length;\n\t}\n\n\t/** A detached copy: later pushes and pops on either stack leave the other unchanged. */\n\tclone(): UndoStack<S> {\n\t\tconst copy = new UndoStack<S>();\n\t\tcopy.stack = structuredClone(this.stack);\n\t\treturn copy;\n\t}\n}\n"]}
|
package/package.json
CHANGED