/**
 * Error Recovery Mechanisms (Phase 3.2.3)
 *
 * Advanced error recovery strategies and retry logic for TachUI.
 * Provides intelligent error handling, circuit breakers, and recovery patterns.
 */
import { type TachUIError } from './error-boundary';
/**
 * Circuit breaker states
 */
export type CircuitBreakerState = 'closed' | 'open' | 'half-open';
/**
 * Circuit breaker configuration
 */
export interface CircuitBreakerConfig {
    failureThreshold: number;
    resetTimeout: number;
    monitoringPeriod: number;
    minimumThroughput: number;
}
/**
 * Retry policy configuration
 */
export interface RetryPolicyConfig {
    maxAttempts: number;
    baseDelay: number;
    maxDelay: number;
    backoffMultiplier: number;
    jitter: boolean;
    retryableErrors: string[];
    nonRetryableErrors: string[];
}
/**
 * Fallback configuration
 */
export interface FallbackConfig<T> {
    value?: T;
    factory?: () => T | Promise<T>;
    timeout?: number;
    cache?: boolean;
    cacheKey?: string;
    cacheTimeout?: number;
}
/**
 * Circuit breaker implementation
 */
export declare class CircuitBreaker {
    private state;
    private failureCount;
    private lastFailureTime;
    private successCount;
    private requestCount;
    private lastRequestTime;
    private config;
    private stateSignal;
    private setState;
    constructor(config?: Partial<CircuitBreakerConfig>);
    /**
     * Execute function with circuit breaker protection
     */
    execute<R>(fn: () => Promise<R>): Promise<R>;
    /**
     * Handle successful execution
     */
    private onSuccess;
    /**
     * Handle failed execution
     */
    private onFailure;
    /**
     * Check if circuit breaker should trip to open state
     */
    private shouldTrip;
    /**
     * Trip circuit breaker to open state
     */
    private trip;
    /**
     * Check if should attempt reset from open state
     */
    private shouldAttemptReset;
    /**
     * Reset circuit breaker to closed state
     */
    private reset;
    /**
     * Update request count for monitoring period
     */
    private updateRequestCount;
    /**
     * Get current state
     */
    getState(): CircuitBreakerState;
    /**
     * Get state signal
     */
    getStateSignal(): () => CircuitBreakerState;
    /**
     * Get metrics
     */
    getMetrics(): {
        state: CircuitBreakerState;
        failureCount: number;
        successCount: number;
        requestCount: number;
        failureRate: number;
    };
}
/**
 * Retry policy implementation
 */
export declare class RetryPolicy {
    private config;
    constructor(config?: Partial<RetryPolicyConfig>);
    /**
     * Execute function with retry policy
     */
    execute<T>(fn: () => Promise<T>): Promise<T>;
    /**
     * Check if error should be retried
     */
    private shouldRetry;
    /**
     * Calculate delay for next retry
     */
    private calculateDelay;
    /**
     * Sleep for specified duration
     */
    private sleep;
    /**
     * Get configuration
     */
    getConfig(): RetryPolicyConfig;
}
/**
 * Fallback manager
 */
export declare class FallbackManager<T> {
    private cache;
    /**
     * Execute with fallback
     */
    executeWithFallback<R>(fn: () => Promise<R>, fallbackConfig: FallbackConfig<R>): Promise<R>;
    /**
     * Get fallback value
     */
    private getFallbackValue;
    /**
     * Execute with timeout
     */
    private withTimeout;
    /**
     * Get cached value
     */
    private getCachedValue;
    /**
     * Set cached value
     */
    private setCachedValue;
    /**
     * Clear cache
     */
    clearCache(): void;
}
/**
 * Composite recovery strategy
 */
export declare class RecoveryOrchestrator {
    private circuitBreaker?;
    private retryPolicy?;
    private fallbackManager;
    constructor(circuitBreakerConfig?: Partial<CircuitBreakerConfig>, retryPolicyConfig?: Partial<RetryPolicyConfig>);
    /**
     * Execute with all recovery mechanisms
     */
    execute<T>(fn: () => Promise<T>, fallbackConfig?: FallbackConfig<T>): Promise<T>;
    /**
     * Wrap function with recovery mechanisms
     */
    private wrapWithRecovery;
    /**
     * Get circuit breaker metrics
     */
    getCircuitBreakerMetrics(): {
        state: CircuitBreakerState;
        failureCount: number;
        successCount: number;
        requestCount: number;
        failureRate: number;
    } | undefined;
    /**
     * Get retry policy configuration
     */
    getRetryPolicyConfig(): RetryPolicyConfig | undefined;
}
/**
 * Error recovery utilities
 */
export declare const recoveryUtils: {
    /**
     * Create a robust function wrapper with all recovery mechanisms
     */
    createRobustFunction<T extends (...args: any[]) => Promise<any>>(fn: T, options?: {
        circuitBreaker?: Partial<CircuitBreakerConfig>;
        retryPolicy?: Partial<RetryPolicyConfig>;
        fallback?: FallbackConfig<Awaited<ReturnType<T>>>;
        onError?: (error: TachUIError) => void;
    }): T;
    /**
     * Create simple retry wrapper
     */
    withRetry<T extends (...args: any[]) => Promise<any>>(fn: T, maxAttempts?: number, baseDelay?: number): T;
    /**
     * Create circuit breaker wrapper
     */
    withCircuitBreaker<T extends (...args: any[]) => Promise<any>>(fn: T, config?: Partial<CircuitBreakerConfig>): T;
    /**
     * Create fallback wrapper
     */
    withFallback<T extends (...args: any[]) => Promise<any>>(fn: T, fallbackValue: Awaited<ReturnType<T>> | (() => Awaited<ReturnType<T>>)): T;
};
/**
 * Global recovery configurations
 */
export declare const recoveryPresets: {
    /**
     * Configuration for network requests
     */
    network: {
        circuitBreaker: {
            failureThreshold: number;
            resetTimeout: number;
            monitoringPeriod: number;
        };
        retryPolicy: {
            maxAttempts: number;
            baseDelay: number;
            backoffMultiplier: number;
            jitter: boolean;
            retryableErrors: string[];
        };
    };
    /**
     * Configuration for component rendering
     */
    component: {
        retryPolicy: {
            maxAttempts: number;
            baseDelay: number;
            backoffMultiplier: number;
            jitter: boolean;
            retryableErrors: string[];
        };
    };
    /**
     * Configuration for reactive operations
     */
    reactive: {
        retryPolicy: {
            maxAttempts: number;
            baseDelay: number;
            retryableErrors: never[];
        };
    };
};
//# sourceMappingURL=error-recovery.d.ts.map