import type { KeyEvent, InputSource } from "./types.js";
export declare function parseKeypress(data: string): KeyEvent;
/**
 * Try to read text bracketed by `open ... close` markers starting at
 * `pos` in `str`. Three outcomes:
 *
 *  - `null`            — `str` doesn't begin the `open` marker at `pos`.
 *  - `{ kind: "partial", body }` — the `open` marker was found but
 *    `close` hasn't arrived yet. Caller should buffer `body` and
 *    re-attempt with the next chunk prepended (or simply stash it
 *    until the close marker turns up).
 *  - `{ kind: "complete", body, end }` — both markers found. `body`
 *    is the text between them; `end` is the index in `str` just past
 *    `close`, ready to resume scanning from.
 *
 * Used for bracketed-paste payloads (`\x1b[200~ ... \x1b[201~`) but
 * deliberately marker-agnostic — any future `open/close` framing can
 * reuse this.
 */
type BracketedRead = null | {
    kind: "partial";
    body: string;
} | {
    kind: "complete";
    body: string;
    end: number;
};
export declare function readBracketed(str: string, pos: number, open: string, close: string): BracketedRead;
/**
 * Longest-prefix match against the known escape-sequence table at
 * `pos`. Returns the mapped `KeyEvent` plus the byte count consumed,
 * or `null` if either `str[pos] !== ESC` or no entry matches.
 */
export declare function readEscapeSequence(str: string, pos: number): {
    event: KeyEvent;
    consumed: number;
} | null;
export declare class TerminalInput implements InputSource {
    private keyWaiters;
    private keyQueue;
    private dataHandler;
    private sigcontHandler;
    private wasRaw;
    private initialized;
    private inLineMode;
    private suspended;
    private pasteBuffer;
    private ensureInitialized;
    init(): void;
    private handleSuspendKeypress;
    private suspendForSigtstp;
    private resumeFromSuspend;
    nextKey(): Promise<KeyEvent>;
    /**
     * Synchronously deliver a synthetic key, exactly as if the user had
     * pressed it. If a `nextKey()` waiter is registered, the key resolves
     * that waiter; otherwise it queues. Mirrors `ScriptedInput.feedKey`
     * so cross-input code (notably the std::ui bridge's `_triggerRender`)
     * can poke a running event loop without knowing which input source
     * is installed.
     */
    feedKey(key: KeyEvent): void;
    /**
     * Internal: route a parsed `KeyEvent` to the next waiter or queue.
     * Shared by `feedKey` and the per-keystroke emissions in
     * `parseAndEmit`.
     */
    private emitKey;
    /**
     * Parse one stdin chunk into zero or more `KeyEvent`s and emit
     * them in order. Owns the side-band state machine across chunks:
     * an unfinished bracketed paste is parked in `this.pasteBuffer`
     * and resumed on the next call.
     *
     * Recognized units, tried in this order at each position:
     *   1. Continuation of a paste opened by a prior chunk
     *   2. A complete bracketed paste (`PASTE_START ... PASTE_END`)
     *   3. Ctrl+Z (0x1a) — raises SIGTSTP and stops parsing
     *   4. Ctrl+C (0x03) — raises SIGINT, emits, keeps parsing
     *   5. A known escape sequence (longest-prefix match)
     *   6. A single character (printable or ctrl+letter)
     */
    private parseAndEmit;
    nextLine(prompt: string): Promise<string>;
    destroy(): void;
}
export {};
