import { Terminal as TermTerminal } from '@teaui/term';
import type { Rect, Point } from './geometry.js';
import { type Program } from './types.js';
import { View } from './View.js';
import type { HotKeyDef, KeyEvent, MouseEventListenerName, SystemEvent, SystemMouseEvent } from './events/index.js';
import type { Modal } from './components/Modal.js';
import { Window } from './components/Window.js';
/**
 * Wraps @teaui/term's Terminal for use by Screen and the public API.
 * Translates low-level terminal input into SystemEvents that Screen can consume.
 */
export declare class TerminalProgram implements Program {
    #private;
    constructor();
    get terminal(): TermTerminal;
    get cols(): number;
    get rows(): number;
    move(x: number, y: number): void;
    write(str: string): void;
    flush(): void;
    setup(): void;
    teardown(): void;
    /**
     * Subscribe to translated system events from terminal input.
     * Returns an unsubscribe function.
     */
    onEvents(listener: (event: SystemEvent) => void): () => void;
    /**
     * Subscribe to terminal resize events.
     * Returns an unsubscribe function.
     */
    onResize(listener: () => void): () => void;
    /**
     * Listen for raw data once (for iTerm2 proprietary escape sequences, etc.)
     */
    onceRawData(fn: (...args: any[]) => void): void;
}
type ViewConstructor<T extends View> = (program: TerminalProgram) => T | Promise<T>;
/**
 * A ViewConstructor that receives a Program (for use with Screen constructor directly).
 */
export type ProgramViewConstructor<T extends View> = (program: Program) => T | Promise<T>;
type ScreenKeyListener = (char: string, key: KeyEvent) => void;
export interface ScreenOptions {
    quitChar?: 'C-c' | 'C-q' | '' | undefined | false;
    emoji?: boolean;
}
export type ScreenEventUnsubscribe = () => void;
interface ScreenEventMap {
    focusChange: (view: View | undefined) => void;
}
export declare class Screen {
    #private;
    rootView: View;
    static start(): Promise<[Screen, TerminalProgram, Window]>;
    static start<T extends View>(viewConstructor: T | ViewConstructor<T>, opts?: Partial<ScreenOptions>): Promise<[Screen, TerminalProgram, T]>;
    constructor(program: Program, rootView: View, { isFocused }?: {
        isFocused?: boolean;
    });
    onExit(callback: () => void): void;
    /**
     * Register a key binding on the screen.
     * Pattern: 'escape', 'C-c', 'C-q', 'return', etc.
     */
    key(pattern: string | string[], fn: ScreenKeyListener): void;
    /**
     * Called from Screen.start(). Don't call this yourself unless you wanted
     * to construct your own 'program'. I recommend starting with a
     * copy of the implementation of Screen.start.
     */
    start(): void;
    /**
     * Puts the screen back in normal terminal mode, restores the normal buffer
     */
    stop(): void;
    /**
     * Stops (putting the screen back in normal mode and buffer) and exits by emitting
     * process.exit(0)
     */
    exit(): void;
    trigger(event: SystemEvent): void;
    /**
     * Requests a modal to be presented. The modal is pushed onto a stack and
     * rendered after the main view tree. Multiple modals can be stacked.
     */
    requestModal(modal: Modal, rect: Rect): boolean;
    /**
     * @return boolean Whether the current view has focus
     */
    registerFocus(view: View, isDefault: boolean): boolean;
    registerHotKey(view: View, key: HotKeyDef): void;
    registerKeyboard(view: View): void;
    requestFocus(view: View): boolean;
    get currentFocusView(): View | undefined;
    get hotKeyViews(): [View, HotKeyDef][];
    /**
     * Subscribe to a screen event. Returns an unsubscribe function.
     */
    on<K extends keyof ScreenEventMap>(event: K, listener: ScreenEventMap[K]): ScreenEventUnsubscribe;
    triggerKeyboard(event: KeyEvent): void;
    triggerPaste(text: string): void;
    /**
     * @see MouseManager.registerMouse
     */
    registerMouse(view: View, offset: Point, point: Point, eventNames: MouseEventListenerName[]): void;
    checkMouse(view: View, x: number, y: number): void;
    triggerMouse(systemEvent: SystemMouseEvent): void;
    registerTick(view: View): void;
    /**
     * Manually advance tick animations by `dt` milliseconds.
     * Useful for testing animations without real timers.
     */
    tick(dt: number): void;
    preRender(view: View): void;
    /**
     * @return boolean Whether or not to rerender the view due to focus or mouse change
     */
    commit(): boolean;
    needsRender(): void;
    render(): void;
}
export {};
