/**
 * USearch Vector Index
 *
 * High-performance vector search using USearch library.
 * Provides O(log n) approximate nearest neighbor search with HNSW algorithm.
 *
 * Features:
 * - SIMD-optimized distance calculations
 * - Support for f32, f16, i8 quantization
 * - Memory-mapped indexes for large datasets
 * - Batch operations for efficient bulk indexing
 *
 * @see https://github.com/unum-cloud/usearch
 */
import { EventEmitter } from 'events';
/**
 * Metric types supported by USearch
 */
export type USearchMetric = 'cos' | 'l2sq' | 'ip' | 'hamming' | 'tanimoto';
/**
 * Data types for vector storage
 */
export type USearchDType = 'f64' | 'f32' | 'f16' | 'i8' | 'b1';
/**
 * USearch index configuration
 */
export interface USearchIndexConfig {
    /** Vector dimensions */
    dimensions: number;
    /** Distance metric (default: 'cos' for cosine similarity) */
    metric?: USearchMetric;
    /** Data type for storage (default: 'f32') */
    dtype?: USearchDType;
    /** Number of connections per node in HNSW graph (default: 16) */
    connectivity?: number;
    /** Size of dynamic candidate list during construction (default: 128) */
    expansionAdd?: number;
    /** Size of dynamic candidate list during search (default: 64) */
    expansionSearch?: number;
    /** Path for persistence (optional) */
    persistPath?: string;
    /** Whether to use memory-mapped index (default: false) */
    memoryMapped?: boolean;
}
/**
 * Default configuration
 */
export declare const DEFAULT_USEARCH_CONFIG: Required<Omit<USearchIndexConfig, 'persistPath'>>;
/**
 * Search result from USearch
 */
export interface USearchResult {
    /** Key/ID of the vector */
    key: number;
    /** Distance to query vector (lower is better for most metrics) */
    distance: number;
}
/**
 * Vector with metadata for indexing
 */
export interface IndexableVector {
    /** Unique ID (will be converted to numeric key) */
    id: string;
    /** Vector embedding */
    embedding: number[] | Float32Array;
    /** Optional metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Search result with resolved metadata
 */
export interface VectorSearchResult {
    /** Original string ID */
    id: string;
    /** Similarity score (0-1, higher is better) */
    score: number;
    /** Distance from query */
    distance: number;
    /** Associated metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Index statistics
 */
export interface USearchStats {
    /** Total vectors in index */
    size: number;
    /** Index capacity */
    capacity: number;
    /** Vector dimensions */
    dimensions: number;
    /** Connectivity (M) parameter */
    connectivity: number;
    /** Memory usage estimate in bytes */
    memoryUsage: number;
    /** Whether index is memory-mapped */
    memoryMapped: boolean;
}
/**
 * USearch index events
 */
export interface USearchEvents {
    'index:created': {
        dimensions: number;
        metric: USearchMetric;
    };
    'vectors:added': {
        count: number;
        totalSize: number;
    };
    'vectors:removed': {
        count: number;
    };
    'search:completed': {
        queryCount: number;
        resultCount: number;
        durationMs: number;
    };
    'index:saved': {
        path: string;
        size: number;
    };
    'index:loaded': {
        path: string;
        size: number;
    };
    'error': {
        operation: string;
        error: Error;
    };
}
/**
 * High-performance vector index using USearch
 */
export declare class USearchVectorIndex extends EventEmitter {
    private config;
    private index;
    private idToKey;
    private keyToId;
    private metadata;
    private nextKey;
    private initialized;
    constructor(config: USearchIndexConfig);
    /**
     * Initialize the index
     */
    initialize(): Promise<void>;
    /**
     * Load USearch module dynamically
     */
    private loadUSearch;
    /**
     * Add a single vector to the index
     */
    add(vector: IndexableVector): Promise<void>;
    /**
     * Add multiple vectors to the index (batch operation)
     */
    addBatch(vectors: IndexableVector[]): Promise<void>;
    /**
     * Remove a vector from the index
     */
    remove(id: string): boolean;
    /**
     * Search for nearest neighbors
     */
    search(query: number[] | Float32Array, k?: number): Promise<VectorSearchResult[]>;
    /**
     * Batch search for multiple queries
     */
    searchBatch(queries: Array<number[] | Float32Array>, k?: number): Promise<VectorSearchResult[][]>;
    /**
     * Save index to disk
     */
    save(path?: string): Promise<void>;
    /**
     * Load index from disk
     */
    load(path: string): Promise<void>;
    /**
     * Get index statistics
     */
    getStats(): USearchStats;
    /**
     * Get the number of vectors in the index
     */
    size(): number;
    /**
     * Check if index contains a vector
     */
    has(id: string): boolean;
    /**
     * Clear all vectors from the index
     */
    clear(): void;
    /**
     * Dispose the index
     */
    dispose(): void;
    private getOrCreateKey;
    private normalizeEmbedding;
    private distanceToScore;
    private estimateMemoryUsage;
    private getDTypeBytes;
}
/**
 * Get or create a USearch vector index
 */
export declare function getUSearchIndex(name: string, config?: USearchIndexConfig): USearchVectorIndex;
/**
 * Remove a USearch index
 */
export declare function removeUSearchIndex(name: string): boolean;
/**
 * Clear all USearch indexes
 */
export declare function clearAllUSearchIndexes(): void;
