import PQueue from 'p-queue';
import { type HeavyQueueOperation, type RecoverQueueOperation, type SignQueueOperation } from './types.js';
/**
 * Queue manager for wallet operations.
 * Manages heavy operation queues (refresh/reshare/recover) and sign queues per wallet.
 */
export declare class WalletQueueManager {
    /** Heavy operation queues per wallet address. These run with concurrency=1. */
    private static readonly heavyOpQueues;
    /** Sign queues per wallet address. These allow concurrent operations. */
    private static readonly signQueues;
    /** Track pending recovery promises for deduplication */
    private static readonly pendingRecoveryPromises;
    /** Track which wallets are currently executing inside a heavy operation.
     * Used to prevent deadlocks when recovery is called from within a heavy op. */
    private static readonly walletsWithActiveHeavyOp;
    /** Track which wallets are currently executing inside a sign operation.
     * Used to prevent deadlocks when recovery is called from within a sign op. */
    private static readonly walletsWithActiveSignOp;
    /**
     * Get or create the heavy operation queue for a wallet.
     * Heavy operations (refresh/reshare/recover) run with concurrency=1.
     */
    static getHeavyOpQueue(accountAddress: string): PQueue;
    /**
     * Get or create the sign queue for a wallet.
     * Sign operations run with unlimited concurrency (they're read-only on key shares).
     */
    static getSignQueue(accountAddress: string): PQueue;
    /**
     * Check if wallet has heavy operations in progress
     */
    static isHeavyOpInProgress(accountAddress: string): boolean;
    /**
     * Check if wallet has operations in any queue (heavy or sign)
     */
    static isWalletBusy(accountAddress: string): boolean;
    /**
     * Check if recovery is in progress for a wallet
     */
    static isRecoveryInProgress(accountAddress: string): boolean;
    /**
     * Get existing pending recovery promise if one exists
     */
    static getPendingRecoveryPromise<T>(accountAddress: string): Promise<T> | undefined;
    /**
     * Track a pending recovery promise
     */
    static setPendingRecoveryPromise<T>(accountAddress: string, promise: Promise<T>): void;
    /**
     * Clear pending recovery promise for a wallet
     */
    static clearPendingRecoveryPromise(accountAddress: string): void;
    /**
     * Queue a heavy operation with type validation.
     * Ensures only valid heavy operations (REFRESH, RESHARE, RECOVER) can be queued.
     * Waits for sign operations to complete before executing.
     *
     * @param accountAddress - The wallet address
     * @param operation - The operation type (must be a valid HeavyQueueOperation)
     * @param callback - The operation to execute
     * @throws Error if operation is not a valid heavy queue operation
     */
    static queueHeavyOperation<T>(accountAddress: string, operation: HeavyQueueOperation, callback: () => Promise<T>): Promise<T>;
    /**
     * Queue a sign operation with type validation.
     * Ensures only valid sign operations (SIGN_MESSAGE, SIGN_TRANSACTION) can be queued.
     * Waits for heavy operations to complete before executing.
     * Allows concurrent sign operations.
     *
     * @param accountAddress - The wallet address
     * @param operation - The operation type (must be a valid SignQueueOperation)
     * @param callback - The sign operation to execute
     * @throws Error if operation is not a valid sign queue operation
     * @returns Promise resolving to the sign result
     */
    static queueSignOperation<T>(accountAddress: string, operation: SignQueueOperation, callback: () => Promise<T>): Promise<T>;
    /**
     * Queue a recovery operation with deduplication and type validation.
     * If a recovery is already in progress for the wallet, returns that promise.
     * If called from within a heavy operation, executes directly to avoid deadlock.
     *
     * @param accountAddress - The wallet address
     * @param operation - The operation type (must be RECOVER)
     * @param callback - The recovery operation to execute
     * @throws Error if operation is not a valid recover queue operation
     * @returns Promise resolving to the recovery result
     */
    static queueRecoverOperation<T>(accountAddress: string, operation: RecoverQueueOperation, callback: () => Promise<T>): Promise<T>;
    /**
     * Reset static state for testing purposes.
     * This clears all wallet queues and pending recovery promises.
     */
    static resetForTesting(): void;
}
//# sourceMappingURL=queue.d.ts.map