import type { Surface, SurfaceStartInput, SurfaceState, SurfaceStopInput, SurfaceSnapshot } from "./contracts.js";
export interface BrowserInteractiveElement {
    role?: string;
    name?: string;
    text?: string;
    selector?: string;
    selectors?: BrowserSelectorSuggestion[];
    tagName?: string;
    placeholder?: string;
    testId?: string;
    id?: string;
    disabled?: boolean;
    selected?: boolean;
    active?: boolean;
    value?: string;
}
export interface BrowserSelectorSuggestion {
    kind: "role" | "name" | "placeholder" | "testId" | "id" | "css";
    value: string;
    selector: string;
}
export interface BrowserActiveElement extends BrowserInteractiveElement {
    type?: string;
    readOnly?: boolean;
    isContentEditable?: boolean;
}
export interface BrowserDialogPresence extends BrowserInteractiveElement {
    title?: string;
    ariaModal?: boolean;
    open?: boolean;
}
export interface BrowserObstructionElement {
    role?: string;
    tagName?: string;
    text?: string;
    selector?: string;
    selectors?: BrowserSelectorSuggestion[];
    reason: string;
    zIndex?: number;
}
export interface BrowserObstructionDiagnostics {
    hasModal: boolean;
    dialogCount: number;
    activeDialogTitle?: string | null;
    topLayer: BrowserObstructionElement[];
    notes: string[];
}
export interface BrowserTargetDiagnostics extends BrowserInteractiveElement {
    selector: string;
    found: boolean;
    offscreen?: boolean;
    obscured?: boolean;
    obstructionReason?: string;
    interceptedBy?: BrowserObstructionElement | null;
    inDialog?: boolean;
    dialogTitle?: string | null;
}
export interface BrowserPageSnapshot {
    url: string;
    title: string;
    text: string;
    elements: BrowserInteractiveElement[];
    activeElement?: BrowserActiveElement | null;
    dialogs?: BrowserDialogPresence[];
    obstruction?: BrowserObstructionDiagnostics;
}
export interface BrowserRuntimeEvent {
    id: number;
    timestamp: string;
    type: "console" | "pageerror" | "requestfailed" | "response";
    level?: string;
    text?: string;
    url?: string;
    method?: string;
    status?: number;
}
export interface BrowserPerformanceMetrics {
    sampledAt: string;
    url: string;
    title: string;
    navigation?: {
        type?: string;
        domContentLoadedMs?: number | null;
        loadMs?: number | null;
        transferSize?: number | null;
        encodedBodySize?: number | null;
        decodedBodySize?: number | null;
    } | null;
    paint?: {
        firstPaintMs?: number | null;
        firstContentfulPaintMs?: number | null;
    } | null;
    webVitals?: {
        lcpMs?: number | null;
        cls?: number | null;
        inpMs?: number | null;
    } | null;
    resources?: {
        total?: number;
        scripts?: number;
        stylesheets?: number;
        images?: number;
        fonts?: number;
        largestTransferSize?: number | null;
    } | null;
    memory?: {
        usedJsHeapSize?: number | null;
        totalJsHeapSize?: number | null;
        jsHeapSizeLimit?: number | null;
    } | null;
}
export interface BrowserDriver {
    navigate(url: string, signal?: AbortSignal): Promise<void>;
    click(selector: string, signal?: AbortSignal): Promise<void>;
    typeText(selector: string, text: string, signal?: AbortSignal): Promise<void>;
    scroll(x: number, y: number, signal?: AbortSignal): Promise<void>;
    select(selector: string, value: string, signal?: AbortSignal): Promise<void>;
    waitFor(selector: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
    screenshot(path?: string, signal?: AbortSignal): Promise<string>;
    snapshot(signal?: AbortSignal): Promise<BrowserPageSnapshot>;
    diagnose(selector: string, signal?: AbortSignal): Promise<BrowserTargetDiagnostics>;
    getMetrics(signal?: AbortSignal): Promise<BrowserPerformanceMetrics>;
    getEvents(): BrowserRuntimeEvent[];
    close(): Promise<void>;
    liveView?: {
        display: string;
        vncPort: number;
        websockifyPort: number;
        novncUrl: string;
        containerName?: string;
    };
}
export interface BrowserSurfaceOptions {
    driverFactory?: (input: SurfaceStartInput) => Promise<BrowserDriver>;
}
export declare class BrowserSurface implements Surface {
    readonly id: string;
    private readonly options;
    readonly type: "browser";
    private _state;
    private _sessionId;
    private _startedAt;
    private _lastUrl;
    private _lastTitle;
    private _actionCount;
    private _lastActivityAt;
    private driver;
    onOutput?: (data: string) => void;
    onStateChange?: (state: SurfaceState) => void;
    constructor(id: string, options?: BrowserSurfaceOptions);
    get state(): SurfaceState;
    get sessionId(): string | null;
    get idleMs(): number;
    start(input: SurfaceStartInput): Promise<void>;
    stop(_input?: SurfaceStopInput): Promise<void>;
    getLiveViewInfo(): {
        display: string;
        vncPort: number;
        websockifyPort: number;
        novncUrl: string;
        containerName?: string;
    } | null;
    snapshot(): SurfaceSnapshot;
    navigate(url: string, signal?: AbortSignal): Promise<BrowserPageSnapshot>;
    describe(signal?: AbortSignal): Promise<string>;
    inspect(selector?: string, signal?: AbortSignal): Promise<{
        snapshot: BrowserPageSnapshot;
        target?: BrowserTargetDiagnostics;
        metrics: BrowserPerformanceMetrics;
    }>;
    click(selector: string, signal?: AbortSignal): Promise<void>;
    typeText(selector: string, text: string, signal?: AbortSignal): Promise<void>;
    scroll(x: number, y: number, signal?: AbortSignal): Promise<void>;
    select(selector: string, value: string, signal?: AbortSignal): Promise<void>;
    waitFor(selector: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
    screenshot(path?: string, signal?: AbortSignal): Promise<string>;
    getMetrics(signal?: AbortSignal): Promise<BrowserPerformanceMetrics>;
    getEvents(): BrowserRuntimeEvent[];
    private captureSnapshotMeta;
    private requireDriver;
    private touch;
    private tryDiagnose;
    private _setState;
}
export declare class BrowserSurfaceFactory {
    private readonly options;
    readonly type: "browser";
    constructor(options?: BrowserSurfaceOptions);
    create(id: string): BrowserSurface;
}
type BrowserRuntimeMode = "auto" | "in-process" | "node-bridge";
export declare function resolveBrowserRuntimeMode(): BrowserRuntimeMode;
export declare function selectInitialBrowserPage<T extends {
    isClosed?: () => boolean;
    url?: () => string;
}>(context: {
    pages?: () => T[];
    newPage: () => Promise<T>;
}): Promise<T>;
export {};
//# sourceMappingURL=browser.d.ts.map