import { EventEmitter } from 'node:events';
import { type EmailProcessingMode } from '../routing/classes.email.config.js';
import type { IEmailRoute } from '../routing/interfaces.js';
/**
 * Queue item status
 */
export type QueueItemStatus = 'pending' | 'processing' | 'delivered' | 'failed' | 'deferred';
/**
 * Queue item interface
 */
export interface IQueueItem {
    id: string;
    processingMode: EmailProcessingMode;
    processingResult: any;
    route: IEmailRoute;
    status: QueueItemStatus;
    attempts: number;
    nextAttempt: Date;
    lastError?: string;
    createdAt: Date;
    updatedAt: Date;
    deliveredAt?: Date;
}
/**
 * Queue options interface
 */
export interface IQueueOptions {
    storageType?: 'memory' | 'disk';
    persistentPath?: string;
    checkInterval?: number;
    maxQueueSize?: number;
    maxPerDestination?: number;
    maxRetries?: number;
    baseRetryDelay?: number;
    maxRetryDelay?: number;
}
/**
 * Queue statistics interface
 */
export interface IQueueStats {
    queueSize: number;
    status: {
        pending: number;
        processing: number;
        delivered: number;
        failed: number;
        deferred: number;
    };
    modes: {
        forward: number;
        mta: number;
        process: number;
    };
    oldestItem?: Date;
    newestItem?: Date;
    averageAttempts: number;
    totalProcessed: number;
    processingActive: boolean;
}
/**
 * A unified queue for all email modes
 */
export declare class UnifiedDeliveryQueue extends EventEmitter {
    private options;
    private queue;
    private checkTimer?;
    private stats;
    private processing;
    private totalProcessed;
    /**
     * Create a new unified delivery queue
     * @param options Queue options
     */
    constructor(options: IQueueOptions);
    /**
     * Initialize the queue
     */
    initialize(): Promise<void>;
    /**
     * Start queue processing
     */
    private startProcessing;
    /**
     * Stop queue processing
     */
    private stopProcessing;
    /**
     * Check for items that need to be processed
     */
    private processQueue;
    /**
     * Add an item to the queue
     * @param processingResult Processing result to queue
     * @param mode Processing mode
     * @param route Email route
     */
    enqueue(processingResult: any, mode: EmailProcessingMode, route: IEmailRoute): Promise<string>;
    /**
     * Get an item from the queue
     * @param id Item ID
     */
    getItem(id: string): IQueueItem | undefined;
    /**
     * Mark an item as being processed
     * @param id Item ID
     */
    markProcessing(id: string): Promise<boolean>;
    /**
     * Mark an item as delivered
     * @param id Item ID
     */
    markDelivered(id: string): Promise<boolean>;
    /**
     * Mark an item as failed
     * @param id Item ID
     * @param error Error message
     */
    markFailed(id: string, error: string): Promise<boolean>;
    /**
     * Remove an item from the queue
     * @param id Item ID
     */
    removeItem(id: string): Promise<boolean>;
    /**
     * Persist an item to disk
     * @param item Item to persist
     */
    private persistItem;
    /**
     * Remove an item from disk
     * @param id Item ID
     */
    private removeItemFromDisk;
    /**
     * Load queue items from disk
     */
    private loadFromDisk;
    /**
     * Update queue statistics
     */
    private updateStats;
    /**
     * Get queue statistics
     */
    getStats(): IQueueStats;
    /**
     * Pause queue processing
     */
    pause(): void;
    /**
     * Resume queue processing
     */
    resume(): void;
    /**
     * Clean up old delivered and failed items
     * @param maxAge Maximum age in milliseconds (default: 7 days)
     */
    cleanupOldItems(maxAge?: number): Promise<number>;
    /**
     * Shutdown the queue
     */
    shutdown(): Promise<void>;
}
