/**
 * Fingerprint of an indexed element for validation
 */
export interface ElementFingerprint {
    tagName: string;
    id: string | null;
    textContent: string | null;
    type: string | null;
    role: string | null;
    ariaLabel: string | null;
    name: string | null;
    href: string | null;
    selector: string;
    indexVersion: number;
}
/**
 * Result of validating an element at a given index
 */
export interface ValidationResult {
    isValid: boolean;
    mismatchReason?: 'element_removed' | 'element_changed' | 'index_shifted';
    recoveredElement?: HTMLElement;
    recoveredIndex?: number;
    requiresReindex?: boolean;
}
export declare class DOMService {
    private static instance;
    private elementMap;
    private elementToSequence;
    private selectorMap;
    private fingerprintMap;
    private isIndexed;
    private indexingInProgress;
    private indexVersion;
    private constructor();
    static getInstance(): DOMService;
    /**
     * Generate a unique CSS selector for an element
     */
    private generateSelector;
    /**
     * Generate a fingerprint for an element to enable validation later
     */
    private generateFingerprint;
    /**
     * Calculate similarity between two strings using word-based Jaccard similarity
     * Returns a value between 0 and 1
     */
    private calculateSimilarity;
    /**
     * Check if an element matches a stored fingerprint
     * Uses various heuristics to determine identity
     */
    private matchesFingerprint;
    /**
     * Search the entire DOM for an element matching the fingerprint
     * This is a last-resort recovery method
     */
    private searchDomForMatch;
    /**
     * Attempt to recover an element that doesn't match at its expected index
     */
    private attemptRecovery;
    /**
     * Get the current DOM position of an element by re-traversing interactable elements
     * Uses the same TreeWalker approach as indexInteractableElements for consistency
     * Returns -1 if element is not found in current interactable elements
     */
    private getCurrentDomPosition;
    /**
     * Validate that the element at a given index still matches its fingerprint
     */
    private validateElementAtIndex;
    /**
     * Export state for external persistence (selectors and fingerprints)
     */
    exportState(): {
        selectors: Array<[number, string]>;
        fingerprints: Array<[number, ElementFingerprint]>;
    };
    /**
     * Import state from external persistence (selectors and fingerprints)
     */
    importState(state: {
        selectors?: Array<[number, string]>;
        fingerprints?: Array<[number, ElementFingerprint]>;
    }): void;
    /**
     * Index all interactable elements in the live DOM.
     * Always clears previous index first.
     */
    indexInteractableElements(): Array<[number, Element]>;
    /**
     * Get element coordinates using getBoundingClientRect()
     * Returns viewport-relative coordinates
     */
    private getElementCoordinates;
    /**
     * Check if an element creates a stacking context
     * Based on CSS stacking context rules
     */
    private isStackingContext;
    /**
     * Calculate global z-order for an element
     * Traverses up the DOM tree to identify stacking contexts and calculate z-order
     */
    private calculateGlobalZOrder;
    /**
     * Get HTML snapshot with data-id attributes injected.
     * This re-indexes the live DOM and then produces a corresponding HTML string.
     */
    getSnapshotHtml(): string;
    getElementByDataId(id: number): Element | undefined;
    getSequenceForElement(element: Element): number | undefined;
    isIndexActive(): boolean;
    clearIndex(): void;
    /**
     * Get an interactive element by its index.
     * Preferentially uses the current index.
     */
    getElementByIndex(index: number): HTMLElement | null;
    /**
     * Get an element by index with validation.
     * This is the main entry point for ToolService to use.
     * It validates the element matches its fingerprint and attempts recovery if not.
     */
    getValidatedElement(index: number): {
        element: HTMLElement | null;
        validation: ValidationResult;
    };
    /**
     * Get fingerprint for a given index (for debugging/testing)
     */
    getFingerprint(index: number): ElementFingerprint | undefined;
    /**
     * Get all fingerprints (for debugging/testing)
     */
    getAllFingerprints(): Array<[number, ElementFingerprint]>;
    /**
     * Get current index version
     */
    getIndexVersion(): number;
}
export declare const domService: DOMService;
//# sourceMappingURL=DomService.d.ts.map