/**
 * Cancelation Handler
 *
 * Graceful Ctrl+C handling with state persistence and resume capability.
 * Atomic file writes ensure state integrity even during abrupt termination.
 *
 * @module cli/helpers/cancelation-handler
 */
import { Logger } from '../../utils/logger.js';
/**
 * Cancelation handler options
 */
export interface CancelationOptions {
    stateFile: string;
    logger?: Logger;
}
/**
 * Cancelation state (persisted to disk)
 */
export interface CancelationState {
    operation: string;
    provider: string;
    domain?: string;
    timestamp: string;
    version: string;
    total: number;
    completed: number;
    succeeded: number;
    failed: number;
    skipped: number;
    remaining: Array<{
        key: string;
        name: string;
    }>;
    errors: Array<{
        projectKey: string;
        error: string;
        timestamp: string;
    }>;
}
/**
 * Cancelation Handler
 *
 * Handles SIGINT (Ctrl+C) signals during long-running operations:
 * - Registers signal handler
 * - Saves partial state to disk (atomic writes)
 * - Provides resume capability
 * - TTL validation (24-hour expiration)
 *
 * @example
 * ```typescript
 * const handler = new CancelationHandler({
 *   stateFile: '.specweave/cache/import-state.json'
 * });
 *
 * handler.onCleanup(async () => {
 *   await savePartialState(projects, total, errors);
 * });
 *
 * for (const project of projects) {
 *   if (handler.shouldCancel()) {
 *     break; // Exit gracefully
 *   }
 *   // ... process project ...
 * }
 * ```
 */
export declare class CancelationHandler {
    private stateFile;
    private logger;
    private canceled;
    private cleanupCallback;
    private sigintHandler;
    private ctrlCCount;
    constructor(options: CancelationOptions);
    /**
     * Register SIGINT (Ctrl+C) handler
     */
    private registerSigintHandler;
    /**
     * Check if cancelation was requested
     *
     * @returns True if Ctrl+C was pressed
     */
    shouldCancel(): boolean;
    /**
     * Register cleanup callback (executed on Ctrl+C)
     *
     * @param callback - Async cleanup function
     */
    onCleanup(callback: () => Promise<void>): void;
    /**
     * Save cancelation state to disk (atomic write)
     *
     * Uses temp file → rename pattern to ensure atomicity.
     *
     * @param state - Cancelation state to persist
     */
    saveState(state: CancelationState): Promise<void>;
    /**
     * Load cancelation state from disk
     *
     * Validates TTL (24-hour expiration) and version compatibility.
     *
     * @returns Cancelation state or null if not found/expired
     */
    loadState(): Promise<CancelationState | null>;
    /**
     * Clear saved state (delete file)
     */
    clearState(): Promise<void>;
    /**
     * Unregister SIGINT handler (cleanup)
     */
    dispose(): void;
    /**
     * Show resume suggestion to user
     *
     * @param resumeCommand - Command to resume operation (e.g., "sw:jira-import-projects --resume")
     */
    suggestResume(resumeCommand: string): void;
}
//# sourceMappingURL=cancelation-handler.d.ts.map