/**
 * Smart Snapshot System
 *
 * OpenClaw-inspired UI element referencing system.
 * Assigns numeric references [1], [2], [3] to interactive elements
 * instead of using brittle CSS selectors or coordinates.
 *
 * Features:
 * - Element detection via accessibility APIs or OCR
 * - Numeric reference assignment for AI agents
 * - Ephemeral snapshots (must refresh before each action sequence)
 * - Cross-platform support (Linux AT-SPI, macOS AX, Windows UIAutomation)
 * - Visual annotation rendering
 */
import { EventEmitter } from 'events';
import { Point, Rect } from './types.js';
export type ElementRole = 'button' | 'link' | 'text-field' | 'checkbox' | 'radio' | 'dropdown' | 'menu' | 'menu-item' | 'tab' | 'list-item' | 'image' | 'text' | 'container' | 'window' | 'unknown';
export interface UIElement {
    /** Numeric reference [1], [2], etc. */
    ref: number;
    /** Element role */
    role: ElementRole;
    /** Display name/label */
    name: string;
    /** Accessibility description */
    description?: string;
    /** Bounding rectangle */
    bounds: Rect;
    /** Center point for clicking */
    center: Point;
    /** Is element interactive */
    interactive: boolean;
    /** Is element focused */
    focused: boolean;
    /** Is element enabled */
    enabled: boolean;
    /** Is element visible */
    visible: boolean;
    /** Current value (for inputs) */
    value?: string;
    /** Placeholder text */
    placeholder?: string;
    /** Parent element ref */
    parent?: number;
    /** Child element refs */
    children?: number[];
    /** Raw accessibility attributes */
    attributes?: Record<string, unknown>;
}
export interface Snapshot {
    /** Snapshot ID */
    id: string;
    /** Timestamp */
    timestamp: Date;
    /** Window/app name */
    source: string;
    /** All detected elements */
    elements: UIElement[];
    /** Element lookup by ref */
    elementMap: Map<number, UIElement>;
    /** Screen dimensions */
    screenSize: {
        width: number;
        height: number;
    };
    /** Is snapshot still valid */
    valid: boolean;
    /** Time-to-live in ms */
    ttl: number;
}
export interface SnapshotOptions {
    /** Window title to capture (default: focused window) */
    window?: string;
    /** Only include interactive elements */
    interactiveOnly?: boolean;
    /** Maximum depth of element tree */
    maxDepth?: number;
    /** Filter by element roles */
    roles?: ElementRole[];
    /** Include hidden elements */
    includeHidden?: boolean;
    /** Time-to-live for snapshot (default: 5000ms) */
    ttl?: number;
}
export interface AnnotatedScreenshot {
    /** Base64 encoded image with annotations */
    image: string;
    /** Image format */
    format: 'png' | 'jpeg';
    /** Width */
    width: number;
    /** Height */
    height: number;
    /** Associated snapshot */
    snapshot: Snapshot;
}
export interface SmartSnapshotConfig {
    /** Preferred detection method */
    method: 'accessibility' | 'ocr' | 'hybrid';
    /** Default TTL for snapshots */
    defaultTtl: number;
    /** Maximum elements per snapshot */
    maxElements: number;
    /** Enable visual annotations */
    enableAnnotations: boolean;
    /** Annotation style */
    annotationStyle: {
        fontSize: number;
        backgroundColor: string;
        textColor: string;
        borderColor: string;
    };
}
export interface ScreenDiff {
    hasChanges: boolean;
    changedRegions: Rect[];
    newElements: UIElement[];
    removedElements: UIElement[];
    similarity: number;
}
export declare class SmartSnapshotManager extends EventEmitter {
    private config;
    private currentSnapshot;
    private snapshotCache;
    private static readonly MAX_CACHE_SIZE;
    private nextRef;
    constructor(config?: Partial<SmartSnapshotConfig>);
    /**
     * Take a snapshot of the current screen/window
     */
    takeSnapshot(options?: SnapshotOptions): Promise<Snapshot>;
    /**
     * Get element by reference number
     */
    getElement(ref: number): UIElement | undefined;
    /**
     * Get current snapshot
     */
    getCurrentSnapshot(): Snapshot | null;
    /**
     * Get a snapshot by ID from the cache
     */
    getSnapshotById(id: string): Snapshot | undefined;
    /**
     * Find elements matching criteria
     */
    findElements(criteria: {
        role?: ElementRole | ElementRole[];
        name?: string | RegExp;
        interactive?: boolean;
        visible?: boolean;
    }): UIElement[];
    /**
     * Generate text representation for AI
     */
    toTextRepresentation(snapshot?: Snapshot): string;
    /**
     * Compare this snapshot to a previous one and return differences
     */
    compareTo(previous: Snapshot): ScreenDiff;
    /**
     * Generate annotated screenshot with ref badges overlaid on each element
     */
    toAnnotatedScreenshot(): Promise<AnnotatedScreenshot | null>;
    private annotateWithSharp;
    private annotateWithFFmpeg;
    private detectAccessibilityElements;
    private detectMacOSElements;
    /**
     * Detect if running inside WSL2
     */
    private isWSL;
    private detectLinuxElements;
    /**
     * Detect elements on WSL2 via PowerShell UIAutomation (same script as detectWindowsElements)
     */
    private detectWSLElements;
    /**
     * Detect elements on native Linux via AT-SPI
     */
    private detectLinuxATSPIElements;
    private detectWindowsElements;
    private detectOCRElements;
    private filterElements;
    private mapRole;
    private mapWindowsRole;
    private isInteractiveRole;
    private getScreenSize;
    private createMockElement;
    private getMockElements;
}
export declare function getSmartSnapshotManager(config?: Partial<SmartSnapshotConfig>): SmartSnapshotManager;
export declare function resetSmartSnapshotManager(): void;
export default SmartSnapshotManager;
