import { L as LineSource, R as Result } from './types-Cgumy1N4.js';
import { EventEmitter } from 'node:events';
import { d as DicomInstance } from './DicomInstance-CQEIuF_x.js';
import './dcmodify-B-_uUIKB.js';

/**
 * Base class for long-lived DCMTK processes (servers).
 *
 * Manages spawning, line-by-line output buffering, typed event emission,
 * lifecycle (start/stop), mandatory timeouts, and graceful shutdown.
 *
 * Implements `Disposable` for deterministic cleanup (Rule 5.1).
 *
 * @module DcmtkProcess
 */

/** Events emitted by a DcmtkProcess. */
interface DcmtkProcessEventMap {
    started: [];
    stopped: [{
        readonly reason: string;
    }];
    error: [{
        readonly error: Error;
        readonly fatal: boolean;
    }];
    line: [{
        readonly source: LineSource;
        readonly text: string;
    }];
}
/** Configuration for a DcmtkProcess instance. */
interface DcmtkProcessConfig {
    /** Full path to the DCMTK binary. */
    readonly binary: string;
    /** Command-line arguments. */
    readonly args: readonly string[];
    /** Working directory. */
    readonly cwd?: string | undefined;
    /** Timeout for start() to resolve, in milliseconds. */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop(), in milliseconds. */
    readonly drainTimeoutMs?: number | undefined;
    /**
     * A function that inspects each output line and returns `true` when
     * the process is considered "started" (e.g., "listening on port X").
     * If not provided, start() resolves immediately after spawn.
     */
    readonly isStartedPredicate?: ((line: string) => boolean) | undefined;
}
declare const ProcessState: {
    readonly IDLE: "IDLE";
    readonly STARTING: "STARTING";
    readonly RUNNING: "RUNNING";
    readonly STOPPING: "STOPPING";
    readonly STOPPED: "STOPPED";
};
type ProcessStateValue = (typeof ProcessState)[keyof typeof ProcessState];
/**
 * Base class for persistent DCMTK processes (e.g., dcmrecv, storescp).
 *
 * @example
 * ```ts
 * const proc = new DcmtkProcess({
 *     binary: '/usr/local/bin/dcmrecv',
 *     args: ['--config', 'storescp.cfg', '11112'],
 *     isStartedPredicate: line => line.includes('listening'),
 * });
 *
 * const result = await proc.start();
 * if (result.ok) {
 *     // Process is running
 *     proc.on('line', ({ source, text }) => console.log(`[${source}] ${text}`));
 * }
 *
 * await proc.stop();
 * ```
 */
declare class DcmtkProcess extends EventEmitter<DcmtkProcessEventMap> {
    private state;
    private child;
    private stdoutBuffer;
    private stderrBuffer;
    private readonly config;
    constructor(config: DcmtkProcessConfig);
    /** Whether the process is currently running. */
    get isRunning(): boolean;
    /** Current process state. */
    get currentState(): ProcessStateValue;
    /**
     * Starts the DCMTK process.
     *
     * Single-use enforcement: returns an error if called more than once.
     * Waits for the `isStartedPredicate` to match an output line, or resolves
     * immediately after spawn if no predicate is configured.
     *
     * @returns A Result indicating success or failure
     */
    start(): Promise<Result<void>>;
    /**
     * Stops the process gracefully.
     *
     * Waits up to `drainTimeoutMs` for the process to exit, then force-kills.
     */
    stop(): Promise<void>;
    /**
     * Implements Disposable for deterministic cleanup (Rule 5.1).
     */
    [Symbol.dispose](): void;
    private killChild;
    /**
     * Wires all child process event handlers for startup.
     */
    private wireChildEvents;
    /**
     * Wires a line listener that resolves start() when the predicate matches.
     */
    private wireStartedPredicate;
    private handleData;
    private processLines;
}

/**
 * Event pattern definitions for DCMTK output parsing.
 *
 * An EventPattern describes a regex that matches a specific DCMTK output pattern,
 * along with a processor function that extracts structured data from the match.
 *
 * Supports both single-line and multi-line block matching.
 *
 * @module parsers/EventPattern
 */
/**
 * Configuration for multi-line block matching.
 *
 * When a line matches the header, the parser accumulates subsequent lines
 * until the footer is matched or limits are reached.
 */
interface MultiLineConfig {
    /** Regex that identifies the start of a multi-line block. */
    readonly header: RegExp;
    /** Regex that identifies the end of a multi-line block. */
    readonly footer: RegExp;
    /** Maximum lines to accumulate (Rule 8.1: bounded). */
    readonly maxLines: number;
    /** Timeout in ms for block completion (Rule 4.2: mandatory timeout). */
    readonly timeoutMs: number;
}
/**
 * Defines a pattern that can be matched against DCMTK process output lines.
 *
 * @typeParam T - The type of data extracted by the processor function
 */
interface EventPattern<T = unknown> {
    /** The event name emitted when this pattern matches. */
    readonly event: string;
    /** The regex pattern to match against individual lines. */
    readonly pattern: RegExp;
    /** Extracts structured data from the regex match. */
    readonly processor: (match: RegExpMatchArray) => T;
    /** Optional multi-line block configuration. */
    readonly multiLine?: MultiLineConfig | undefined;
}

/**
 * Line-by-line parser for DCMTK process output.
 *
 * Matches output lines against registered EventPattern objects and emits
 * structured events. Supports both single-line and multi-line block matching.
 *
 * All algorithms are iterative (Rule 8.2: no recursion).
 * All buffers are bounded (Rule 8.1).
 *
 * @module parsers/LineParser
 */

/** Events emitted by the LineParser. */
interface LineParserEventMap {
    /** Emitted when a pattern matches. Carries the event name and extracted data. */
    match: [{
        readonly event: string;
        readonly data: unknown;
    }];
    /** Emitted when a multi-line block times out before the footer is matched. Consumers should listen for this event to detect and handle incomplete blocks. */
    blockTimeout: [{
        readonly event: string;
        readonly lines: readonly string[];
    }];
    /** Emitted when a pattern processor throws. */
    error: [Error];
}
/**
 * Parses DCMTK output lines against registered event patterns.
 *
 * @example
 * ```ts
 * const parser = new LineParser();
 * parser.addPattern({
 *     event: 'LISTENING',
 *     pattern: /listening on port (\d+)/i,
 *     processor: match => ({ port: Number(match[1]) }),
 * });
 *
 * parser.on('match', ({ event, data }) => {
 *     console.log(`${event}:`, data);
 * });
 *
 * parser.feed('I: listening on port 11112');
 * // Emits: match { event: 'LISTENING', data: { port: 11112 } }
 * ```
 */
declare class LineParser extends EventEmitter<LineParserEventMap> {
    private readonly patterns;
    private activeBlock;
    constructor();
    /**
     * Registers an event pattern.
     *
     * @param pattern - The pattern to register
     * @returns Result indicating success or failure if pattern limit exceeded
     */
    addPattern(pattern: EventPattern): Result<void>;
    /**
     * Feeds a single line of output to the parser.
     *
     * The line is matched against all registered patterns (iteratively, Rule 8.2).
     * If a multi-line block is active, the line is accumulated until the footer matches.
     *
     * @param line - A single line of DCMTK output (without trailing newline)
     */
    feed(line: string): void;
    /**
     * Feeds multiple lines of output (e.g., from a chunk split by newlines).
     *
     * @param lines - Array of lines to process
     */
    feedLines(lines: readonly string[]): void;
    /**
     * Resets the parser state, clearing any active multi-line block.
     */
    reset(): void;
    /**
     * Implements Disposable for cleanup (Rule 5.1).
     */
    [Symbol.dispose](): void;
    private matchSingleLine;
    private startBlock;
    private feedToBlock;
}

/**
 * Event patterns and types for dcmrecv output parsing.
 *
 * Defines regex patterns that match DCMTK dcmrecv verbose output,
 * along with typed event data interfaces for each event.
 *
 * @module events/dcmrecv
 */

/** Events emitted by dcmrecv process output. */
declare const DcmrecvEvent: {
    readonly LISTENING: "LISTENING";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly C_STORE_REQUEST: "C_STORE_REQUEST";
    readonly STORED_FILE: "STORED_FILE";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly ECHO_REQUEST: "ECHO_REQUEST";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
    readonly REFUSING_ASSOCIATION: "REFUSING_ASSOCIATION";
    /** Synthetic: STORED_FILE enriched with association context. */
    readonly FILE_RECEIVED: "FILE_RECEIVED";
    /** Synthetic: emitted on association release/abort with summary. */
    readonly ASSOCIATION_COMPLETE: "ASSOCIATION_COMPLETE";
};
type DcmrecvEventValue = (typeof DcmrecvEvent)[keyof typeof DcmrecvEvent];
/** Data for ASSOCIATION_RECEIVED event. */
interface AssociationReceivedData {
    readonly source: string;
    readonly callingAE: string;
    readonly calledAE: string;
}
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
interface AssociationAcknowledgedData {
    readonly maxSendPDV: number;
}
/** Data for C_STORE_REQUEST event. */
interface CStoreRequestData {
    readonly raw: string;
}
/** Data for STORED_FILE event. */
interface StoredFileData {
    readonly filePath: string;
}
/** Data for REFUSING_ASSOCIATION event. */
interface RefusingAssociationData {
    readonly reason: string;
}
/** Data for CANNOT_START_LISTENER event. */
interface CannotStartListenerData {
    readonly message: string;
}
/** Data for FILE_RECEIVED synthetic event. */
interface FileReceivedData {
    readonly filePath: string;
    readonly associationId: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
}
/** Data for ASSOCIATION_COMPLETE synthetic event. */
interface AssociationCompleteData {
    readonly associationId: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
    readonly files: readonly string[];
    readonly durationMs: number;
    readonly endReason: 'release' | 'abort';
}
/** Event patterns for parsing dcmrecv verbose output. */
declare const DCMRECV_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const DCMRECV_FATAL_EVENTS: ReadonlySet<string>;

/**
 * Event patterns and types for storescp output parsing.
 *
 * Extends dcmrecv patterns with storescp-specific events like
 * file storage progress and subdirectory creation.
 *
 * @module events/storescp
 */

/** Events emitted by storescp process output. */
declare const StorescpEvent: {
    readonly STORING_FILE: "STORING_FILE";
    readonly SUBDIRECTORY_CREATED: "SUBDIRECTORY_CREATED";
    readonly LISTENING: "LISTENING";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly C_STORE_REQUEST: "C_STORE_REQUEST";
    readonly STORED_FILE: "STORED_FILE";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly ECHO_REQUEST: "ECHO_REQUEST";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
    readonly REFUSING_ASSOCIATION: "REFUSING_ASSOCIATION";
    readonly FILE_RECEIVED: "FILE_RECEIVED";
    readonly ASSOCIATION_COMPLETE: "ASSOCIATION_COMPLETE";
};
type StorescpEventValue = (typeof StorescpEvent)[keyof typeof StorescpEvent];
/** Data for STORING_FILE event. */
interface StoringFileData {
    readonly filePath: string;
}
/** Data for SUBDIRECTORY_CREATED event. */
interface SubdirectoryCreatedData {
    readonly directory: string;
}
/** Combined event patterns for parsing storescp verbose output. */
declare const STORESCP_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const STORESCP_FATAL_EVENTS: ReadonlySet<string>;

/**
 * Event patterns and types for dcmprscp output parsing.
 *
 * Defines regex patterns that match DCMTK dcmprscp (print management SCP)
 * verbose output, along with typed event data interfaces for each event.
 *
 * @module events/dcmprscp
 */

/** Events emitted by dcmprscp process output. */
declare const DcmprscpEvent: {
    readonly DATABASE_READY: "DATABASE_READY";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
    readonly CONFIG_ERROR: "CONFIG_ERROR";
};
type DcmprscpEventValue = (typeof DcmprscpEvent)[keyof typeof DcmprscpEvent];
/** Data for DATABASE_READY event. */
interface DatabaseReadyData {
    readonly directory: string;
}
/** Data for ASSOCIATION_RECEIVED event. */
interface PrintAssociationReceivedData {
    readonly peerInfo: string;
}
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
interface PrintAssociationAcknowledgedData {
    readonly maxSendPDV: number;
}
/** Data for CANNOT_START_LISTENER event. */
interface PrintCannotStartListenerData {
    readonly message: string;
}
/** Data for CONFIG_ERROR event. */
interface ConfigErrorData {
    readonly message: string;
}
/** Event patterns for parsing dcmprscp verbose output. */
declare const DCMPRSCP_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const DCMPRSCP_FATAL_EVENTS: ReadonlySet<string>;

/**
 * Event patterns and types for dcmpsrcv output parsing.
 *
 * Defines regex patterns that match DCMTK dcmpsrcv (viewer network receiver)
 * verbose output. Shares several patterns with dcmrecv/storescp since
 * dcmpsrcv handles incoming DICOM associations and C-STORE operations.
 *
 * @module events/dcmpsrcv
 */

/** Events emitted by dcmpsrcv process output. */
declare const DcmpsrcvEvent: {
    readonly LISTENING: "LISTENING";
    readonly DATABASE_READY: "DATABASE_READY";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly ECHO_REQUEST: "ECHO_REQUEST";
    readonly C_STORE_REQUEST: "C_STORE_REQUEST";
    readonly FILE_DELETED: "FILE_DELETED";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
    readonly CONFIG_ERROR: "CONFIG_ERROR";
    readonly TERMINATING: "TERMINATING";
};
type DcmpsrcvEventValue = (typeof DcmpsrcvEvent)[keyof typeof DcmpsrcvEvent];
/** Data for LISTENING event. */
interface ReceiverListeningData {
    readonly receiverId: string;
    readonly port: number;
}
/** Data for DATABASE_READY event. */
interface ReceiverDatabaseReadyData {
    readonly directory: string;
}
/** Data for ASSOCIATION_RECEIVED event. */
interface ReceiverAssociationReceivedData {
    readonly peerInfo: string;
}
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
interface ReceiverAssociationAcknowledgedData {
    readonly maxSendPDV: number;
}
/** Data for ECHO_REQUEST event. */
interface ReceiverEchoRequestData {
    readonly messageId: number;
}
/** Data for C_STORE_REQUEST event. */
interface ReceiverCStoreRequestData {
    readonly raw: string;
}
/** Data for FILE_DELETED event. */
interface FileDeletedData {
    readonly filePath: string;
}
/** Data for CANNOT_START_LISTENER event. */
interface ReceiverCannotStartListenerData {
    readonly message: string;
}
/** Data for CONFIG_ERROR event. */
interface ReceiverConfigErrorData {
    readonly message: string;
}
/** Event patterns for parsing dcmpsrcv verbose output. */
declare const DCMPSRCV_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const DCMPSRCV_FATAL_EVENTS: ReadonlySet<string>;

/**
 * Event patterns and types for dcmqrscp output parsing.
 *
 * Defines regex patterns that match DCMTK dcmqrscp (Query/Retrieve SCP)
 * verbose output, along with typed event data interfaces for each event.
 *
 * @module events/dcmqrscp
 */

/** Events emitted by dcmqrscp process output. */
declare const DcmqrscpEvent: {
    readonly LISTENING: "LISTENING";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly C_FIND_REQUEST: "C_FIND_REQUEST";
    readonly C_MOVE_REQUEST: "C_MOVE_REQUEST";
    readonly C_GET_REQUEST: "C_GET_REQUEST";
    readonly C_STORE_REQUEST: "C_STORE_REQUEST";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
};
type DcmqrscpEventValue = (typeof DcmqrscpEvent)[keyof typeof DcmqrscpEvent];
/** Data for LISTENING event. */
interface QRListeningData {
    readonly port: number;
}
/** Data for ASSOCIATION_RECEIVED event. */
interface QRAssociationReceivedData {
    readonly peerInfo: string;
}
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
interface QRAssociationAcknowledgedData {
    readonly maxSendPDV: number;
}
/** Data for C_FIND_REQUEST event. */
interface QRCFindRequestData {
    readonly raw: string;
}
/** Data for C_MOVE_REQUEST event. */
interface QRCMoveRequestData {
    readonly raw: string;
}
/** Data for C_GET_REQUEST event. */
interface QRCGetRequestData {
    readonly raw: string;
}
/** Data for C_STORE_REQUEST event. */
interface QRCStoreRequestData {
    readonly raw: string;
}
/** Data for CANNOT_START_LISTENER event. */
interface QRCannotStartListenerData {
    readonly message: string;
}
/** Event patterns for parsing dcmqrscp verbose output. */
declare const DCMQRSCP_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const DCMQRSCP_FATAL_EVENTS: ReadonlySet<string>;

/**
 * Event patterns and types for wlmscpfs output parsing.
 *
 * Defines regex patterns that match DCMTK wlmscpfs (Worklist Management SCP)
 * verbose output, along with typed event data interfaces for each event.
 *
 * @module events/wlmscpfs
 */

/** Events emitted by wlmscpfs process output. */
declare const WlmscpfsEvent: {
    readonly LISTENING: "LISTENING";
    readonly ASSOCIATION_RECEIVED: "ASSOCIATION_RECEIVED";
    readonly ASSOCIATION_ACKNOWLEDGED: "ASSOCIATION_ACKNOWLEDGED";
    readonly C_FIND_REQUEST: "C_FIND_REQUEST";
    readonly ASSOCIATION_RELEASE: "ASSOCIATION_RELEASE";
    readonly ASSOCIATION_ABORTED: "ASSOCIATION_ABORTED";
    readonly ECHO_REQUEST: "ECHO_REQUEST";
    readonly CANNOT_START_LISTENER: "CANNOT_START_LISTENER";
};
type WlmscpfsEventValue = (typeof WlmscpfsEvent)[keyof typeof WlmscpfsEvent];
/** Data for LISTENING event. */
interface WlmListeningData {
    readonly port: number;
}
/** Data for ASSOCIATION_RECEIVED event. */
interface WlmAssociationReceivedData {
    readonly peerInfo: string;
}
/** Data for ASSOCIATION_ACKNOWLEDGED event. */
interface WlmAssociationAcknowledgedData {
    readonly maxSendPDV: number;
}
/** Data for C_FIND_REQUEST event. */
interface WlmCFindRequestData {
    readonly raw: string;
}
/** Data for CANNOT_START_LISTENER event. */
interface WlmCannotStartListenerData {
    readonly message: string;
}
/** Event patterns for parsing wlmscpfs verbose output. */
declare const WLMSCPFS_PATTERNS: readonly EventPattern[];
/** Events that indicate fatal errors (process should be stopped). */
declare const WLMSCPFS_FATAL_EVENTS: ReadonlySet<string>;

/**
 * DICOM receiver server wrapping the dcmrecv binary.
 *
 * Provides a type-safe, event-driven API for receiving DICOM objects
 * via C-STORE. Uses a static factory pattern because binary resolution
 * must happen before the constructor call.
 *
 * @module servers/Dcmrecv
 */

/** Typed event map for the Dcmrecv server. */
interface DcmrecvEventMap {
    LISTENING: [];
    ASSOCIATION_RECEIVED: [AssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [AssociationAcknowledgedData];
    C_STORE_REQUEST: [CStoreRequestData];
    STORED_FILE: [StoredFileData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    ECHO_REQUEST: [];
    CANNOT_START_LISTENER: [CannotStartListenerData];
    REFUSING_ASSOCIATION: [RefusingAssociationData];
    FILE_RECEIVED: [FileReceivedData];
    ASSOCIATION_COMPLETE: [AssociationCompleteData];
}
/** Subdirectory generation mode for received files. */
declare const SubdirectoryMode: {
    readonly NONE: "none";
    readonly SERIES_DATE: "series-date";
};
type SubdirectoryModeValue = (typeof SubdirectoryMode)[keyof typeof SubdirectoryMode];
/** Filename generation mode for received files. */
declare const FilenameMode: {
    readonly DEFAULT: "default";
    readonly UNIQUE: "unique";
    readonly SHORT_UNIQUE: "short-unique";
    readonly SYSTEM_TIME: "system-time";
};
type FilenameModeValue = (typeof FilenameMode)[keyof typeof FilenameMode];
/** Storage mode for received DICOM objects. */
declare const StorageMode: {
    readonly NORMAL: "normal";
    readonly BIT_PRESERVING: "bit-preserving";
    readonly IGNORE: "ignore";
};
type StorageModeValue = (typeof StorageMode)[keyof typeof StorageMode];
/** Options for creating a Dcmrecv server instance. */
interface DcmrecvOptions {
    /** Port to listen on (required). */
    readonly port: number;
    /** Application Entity Title. */
    readonly aeTitle?: string | undefined;
    /** Output directory for received files. */
    readonly outputDirectory?: string | undefined;
    /** Path to an association negotiation configuration file. */
    readonly configFile?: string | undefined;
    /** Profile name within the configuration file. */
    readonly configProfile?: string | undefined;
    /** Subdirectory generation mode. */
    readonly subdirectory?: SubdirectoryModeValue | undefined;
    /** Filename generation mode. */
    readonly filenameMode?: FilenameModeValue | undefined;
    /** File extension for received files. */
    readonly filenameExtension?: string | undefined;
    /** Storage mode for received DICOM objects. */
    readonly storageMode?: StorageModeValue | undefined;
    /** ACSE timeout in seconds (passed to DCMTK as-is). */
    readonly acseTimeout?: number | undefined;
    /** DIMSE timeout in seconds (passed to DCMTK as-is). */
    readonly dimseTimeout?: number | undefined;
    /** Maximum PDU receive size. */
    readonly maxPdu?: number | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * DICOM receiver server wrapping the dcmrecv binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * Server-specific events (LISTENING, STORED_FILE, etc.) are emitted dynamically
 * via the LineParser. Use `onEvent()` for typed listeners on server events.
 *
 * @example
 * ```ts
 * const result = Dcmrecv.create({ port: 11112, outputDirectory: '/tmp/received' });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('STORED_FILE', (data) => console.log('Stored:', data.filePath));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class Dcmrecv extends DcmtkProcess {
    private readonly parser;
    private readonly tracker;
    private abortSignal;
    private abortHandler;
    private constructor();
    /**
     * Registers a typed listener for a dcmrecv-specific event.
     *
     * @param event - The event name from DcmrecvEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    onEvent<K extends keyof DcmrecvEventMap>(event: K, listener: (...args: DcmrecvEventMap[K]) => void): this;
    /**
     * Registers a listener for incoming associations.
     *
     * @param listener - Callback receiving association data
     * @returns this for chaining
     */
    onAssociationReceived(listener: (...args: DcmrecvEventMap['ASSOCIATION_RECEIVED']) => void): this;
    /**
     * Registers a listener for stored files.
     *
     * @param listener - Callback receiving stored file data
     * @returns this for chaining
     */
    onStoredFile(listener: (...args: DcmrecvEventMap['STORED_FILE']) => void): this;
    /**
     * Registers a listener for received files enriched with association context.
     *
     * @param listener - Callback receiving tracked file data
     * @returns this for chaining
     */
    onFileReceived(listener: (...args: DcmrecvEventMap['FILE_RECEIVED']) => void): this;
    /**
     * Registers a listener for completed associations.
     *
     * @param listener - Callback receiving association summary
     * @returns this for chaining
     */
    onAssociationComplete(listener: (...args: DcmrecvEventMap['ASSOCIATION_COMPLETE']) => void): this;
    /**
     * Creates a new Dcmrecv server instance.
     *
     * @param options - Configuration options for the dcmrecv server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: DcmrecvOptions): Result<Dcmrecv>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires the AssociationTracker to server events. */
    private wireTracker;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * DICOM Storage SCP server wrapping the storescp binary.
 *
 * Provides a type-safe, event-driven API for receiving DICOM objects
 * via the storescp command-line tool. Supports sorting, exec hooks,
 * custom transfer syntaxes, and all standard storescp options.
 *
 * @module servers/StoreSCP
 */

/** Typed event map for the StoreSCP server. */
interface StoreSCPEventMap {
    LISTENING: [];
    ASSOCIATION_RECEIVED: [AssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [AssociationAcknowledgedData];
    C_STORE_REQUEST: [CStoreRequestData];
    STORED_FILE: [StoredFileData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    ECHO_REQUEST: [];
    CANNOT_START_LISTENER: [CannotStartListenerData];
    REFUSING_ASSOCIATION: [RefusingAssociationData];
    STORING_FILE: [StoringFileData];
    SUBDIRECTORY_CREATED: [SubdirectoryCreatedData];
    FILE_RECEIVED: [FileReceivedData];
    ASSOCIATION_COMPLETE: [AssociationCompleteData];
}
/** Preferred transfer syntax for incoming associations. */
declare const PreferredTransferSyntax: {
    readonly LITTLE_ENDIAN: "little-endian";
    readonly BIG_ENDIAN: "big-endian";
    readonly IMPLICIT: "implicit";
    readonly ACCEPT_ALL: "accept-all";
};
type PreferredTransferSyntaxValue = (typeof PreferredTransferSyntax)[keyof typeof PreferredTransferSyntax];
/** Options for creating a StoreSCP server instance. */
interface StoreSCPOptions {
    /** Port to listen on (required). */
    readonly port: number;
    /** Application Entity Title. */
    readonly aeTitle?: string | undefined;
    /** Output directory for received files. */
    readonly outputDirectory?: string | undefined;
    /** Path to an association negotiation configuration file. */
    readonly configFile?: string | undefined;
    /** Profile name within the configuration file. */
    readonly configProfile?: string | undefined;
    /** Preferred transfer syntax (not valid with configFile). */
    readonly preferredTransferSyntax?: PreferredTransferSyntaxValue | undefined;
    /** Sort studies into subdirectories. */
    readonly sortByStudy?: boolean | undefined;
    /** Sort by Study Instance UID. */
    readonly sortByStudyUID?: boolean | undefined;
    /** Sort by patient name. */
    readonly sortByPatientName?: boolean | undefined;
    /** Generate unique filenames. */
    readonly uniqueFilenames?: boolean | undefined;
    /** Use bit-preserving mode. */
    readonly bitPreserving?: boolean | undefined;
    /** Execute command on each received file. */
    readonly execOnReception?: string | undefined;
    /** Execute command at end of study. */
    readonly execOnEndOfStudy?: string | undefined;
    /** Timeout for end-of-study detection in seconds (passed to DCMTK as-is). */
    readonly endOfStudyTimeout?: number | undefined;
    /** Rename files at end of study. */
    readonly renameOnEndOfStudy?: boolean | undefined;
    /** Socket timeout in seconds (passed to DCMTK as-is). */
    readonly socketTimeout?: number | undefined;
    /** ACSE timeout in seconds (passed to DCMTK as-is). */
    readonly acseTimeout?: number | undefined;
    /** DIMSE timeout in seconds (passed to DCMTK as-is). */
    readonly dimseTimeout?: number | undefined;
    /** Maximum PDU receive size. */
    readonly maxPdu?: number | undefined;
    /** Filename extension for received files. */
    readonly filenameExtension?: string | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * Pre-configured option sets for common StoreSCP deployment patterns.
 * Spread a preset into your options to avoid specifying boilerplate.
 *
 * @example
 * ```ts
 * StoreSCP.create({ ...StoreSCPPreset.PRODUCTION, port: 11112, outputDirectory: '/data' });
 * ```
 */
declare const StoreSCPPreset: {
    /** Basic storage: unique filenames to avoid collisions. */
    readonly BASIC_STORAGE: {
        readonly uniqueFilenames: true;
    };
    /** Testing: unique filenames, preserving raw transfer syntax. */
    readonly TESTING: {
        readonly uniqueFilenames: true;
        readonly bitPreserving: true;
    };
    /** Production: unique filenames with reasonable timeouts. */
    readonly PRODUCTION: {
        readonly uniqueFilenames: true;
        readonly acseTimeout: 30;
        readonly dimseTimeout: 60;
    };
};
/** Names of the available StoreSCP configuration presets. */
type StoreSCPPresetName = keyof typeof StoreSCPPreset;
/**
 * DICOM Storage SCP server wrapping the storescp binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * Note: storescp does not print a "listening" message, so `start()` resolves
 * on spawn. If the port is busy, storescp exits immediately and `start()`
 * returns an error via the close handler.
 *
 * Server-specific events are emitted dynamically via the LineParser.
 * Use `onEvent()` for typed listeners on server events.
 *
 * @example
 * ```ts
 * const result = StoreSCP.create({ port: 11112, outputDirectory: '/tmp/received' });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('STORED_FILE', (data) => console.log('Stored:', data.filePath));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class StoreSCP extends DcmtkProcess {
    private readonly parser;
    private readonly tracker;
    private abortSignal;
    private abortHandler;
    private constructor();
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    /**
     * Registers a typed listener for a storescp-specific event.
     *
     * @param event - The event name from StoreSCPEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    onEvent<K extends keyof StoreSCPEventMap>(event: K, listener: (...args: StoreSCPEventMap[K]) => void): this;
    /**
     * Registers a listener for incoming associations.
     *
     * @param listener - Callback receiving association data
     * @returns this for chaining
     */
    onAssociationReceived(listener: (...args: StoreSCPEventMap['ASSOCIATION_RECEIVED']) => void): this;
    /**
     * Registers a listener for files being stored to disk.
     *
     * @param listener - Callback receiving storing file data
     * @returns this for chaining
     */
    onStoringFile(listener: (...args: StoreSCPEventMap['STORING_FILE']) => void): this;
    /**
     * Registers a listener for received files enriched with association context.
     *
     * @param listener - Callback receiving tracked file data
     * @returns this for chaining
     */
    onFileReceived(listener: (...args: StoreSCPEventMap['FILE_RECEIVED']) => void): this;
    /**
     * Registers a listener for completed associations.
     *
     * @param listener - Callback receiving association summary
     * @returns this for chaining
     */
    onAssociationComplete(listener: (...args: StoreSCPEventMap['ASSOCIATION_COMPLETE']) => void): this;
    /**
     * Creates a new StoreSCP server instance.
     *
     * @param options - Configuration options for the storescp server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: StoreSCPOptions): Result<StoreSCP>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires the AssociationTracker to server events. */
    private wireTracker;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * DICOM Print Management SCP server wrapping the dcmprscp binary.
 *
 * Provides a type-safe, event-driven API for the Basic Grayscale Print
 * Management SCP. Uses a static factory pattern because binary resolution
 * and validation must happen before the constructor call.
 *
 * @module servers/DcmprsCP
 */

/** Typed event map for the DcmprsCP server. */
interface DcmprsCPEventMap {
    DATABASE_READY: [DatabaseReadyData];
    ASSOCIATION_RECEIVED: [PrintAssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [PrintAssociationAcknowledgedData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    CANNOT_START_LISTENER: [PrintCannotStartListenerData];
    CONFIG_ERROR: [ConfigErrorData];
}
/** Options for creating a DcmprsCP server instance. */
interface DcmprsCPOptions {
    /** Path to the dcmpstat configuration file (required). */
    readonly configFile: string;
    /** Printer identifier from the config file (optional, defaults to first printer). */
    readonly printer?: string | undefined;
    /** Enable DIMSE message dumping. */
    readonly dump?: boolean | undefined;
    /** Log level override. */
    readonly logLevel?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | undefined;
    /** Path to a log configuration file. */
    readonly logConfig?: string | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * DICOM Print Management SCP server wrapping the dcmprscp binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * Note: dcmprscp does not print a "listening" message. The `start()` method
 * resolves either when the DATABASE_READY event is detected or on spawn.
 *
 * @example
 * ```ts
 * const result = DcmprsCP.create({ configFile: '/etc/dcmpstat.cfg' });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('DATABASE_READY', (data) => console.log('DB:', data.directory));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class DcmprsCP extends DcmtkProcess {
    private readonly parser;
    private abortSignal;
    private abortHandler;
    private constructor();
    /**
     * Registers a typed listener for a dcmprscp-specific event.
     *
     * @param event - The event name from DcmprsCPEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    onEvent<K extends keyof DcmprsCPEventMap>(event: K, listener: (...args: DcmprsCPEventMap[K]) => void): this;
    /**
     * Registers a listener for when the database is ready.
     *
     * @param listener - Callback receiving database ready data
     * @returns this for chaining
     */
    onDatabaseReady(listener: (...args: DcmprsCPEventMap['DATABASE_READY']) => void): this;
    /**
     * Registers a listener for incoming associations.
     *
     * @param listener - Callback receiving association data
     * @returns this for chaining
     */
    onAssociationReceived(listener: (...args: DcmprsCPEventMap['ASSOCIATION_RECEIVED']) => void): this;
    /**
     * Creates a new DcmprsCP server instance.
     *
     * @param options - Configuration options for the dcmprscp server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: DcmprsCPOptions): Result<DcmprsCP>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * DICOM Viewer Network Receiver wrapping the dcmpsrcv binary.
 *
 * Provides a type-safe, event-driven API for the DICOMscope network
 * receiver component. Accepts incoming DICOM associations for storage
 * and C-ECHO verification.
 *
 * @module servers/Dcmpsrcv
 */

/** Typed event map for the Dcmpsrcv server. */
interface DcmpsrcvEventMap {
    LISTENING: [ReceiverListeningData];
    DATABASE_READY: [ReceiverDatabaseReadyData];
    ASSOCIATION_RECEIVED: [ReceiverAssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [ReceiverAssociationAcknowledgedData];
    ECHO_REQUEST: [ReceiverEchoRequestData];
    C_STORE_REQUEST: [ReceiverCStoreRequestData];
    FILE_DELETED: [FileDeletedData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    CANNOT_START_LISTENER: [ReceiverCannotStartListenerData];
    CONFIG_ERROR: [ReceiverConfigErrorData];
    TERMINATING: [];
}
/** Options for creating a Dcmpsrcv server instance. */
interface DcmpsrcvOptions {
    /** Path to the dcmpstat configuration file (required). */
    readonly configFile: string;
    /** Receiver identifier from the config file (optional, defaults to first receiver). */
    readonly receiverId?: string | undefined;
    /** Log level override. */
    readonly logLevel?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | undefined;
    /** Path to a log configuration file. */
    readonly logConfig?: string | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * DICOM Viewer Network Receiver wrapping the dcmpsrcv binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * The `start()` method resolves when the LISTENING event is detected
 * (i.e., "Receiver <id> on port <port>").
 *
 * @example
 * ```ts
 * const result = Dcmpsrcv.create({ configFile: '/etc/dcmpstat.cfg', receiverId: 'RECEIVE_1' });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('LISTENING', (data) => console.log(`Listening on port ${data.port}`));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class Dcmpsrcv extends DcmtkProcess {
    private readonly parser;
    private abortSignal;
    private abortHandler;
    private constructor();
    /**
     * Registers a typed listener for a dcmpsrcv-specific event.
     *
     * @param event - The event name from DcmpsrcvEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    onEvent<K extends keyof DcmpsrcvEventMap>(event: K, listener: (...args: DcmpsrcvEventMap[K]) => void): this;
    /**
     * Registers a listener for when the receiver starts listening.
     *
     * @param listener - Callback receiving listening data (receiver ID and port)
     * @returns this for chaining
     */
    onListening(listener: (...args: DcmpsrcvEventMap['LISTENING']) => void): this;
    /**
     * Registers a listener for incoming C-STORE requests.
     *
     * @param listener - Callback receiving C-STORE request data
     * @returns this for chaining
     */
    onCStoreRequest(listener: (...args: DcmpsrcvEventMap['C_STORE_REQUEST']) => void): this;
    /**
     * Creates a new Dcmpsrcv server instance.
     *
     * @param options - Configuration options for the dcmpsrcv server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: DcmpsrcvOptions): Result<Dcmpsrcv>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * DICOM Query/Retrieve SCP server wrapping the dcmqrscp binary.
 *
 * Provides a type-safe, event-driven API for the Q/R SCP that supports
 * C-FIND, C-MOVE, C-GET, and C-STORE operations. Uses a static factory
 * pattern because binary resolution and validation must happen before
 * the constructor call.
 *
 * @module servers/DcmQRSCP
 */

/** Typed event map for the DcmQRSCP server. */
interface DcmQRSCPEventMap {
    LISTENING: [QRListeningData];
    ASSOCIATION_RECEIVED: [QRAssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [QRAssociationAcknowledgedData];
    C_FIND_REQUEST: [QRCFindRequestData];
    C_MOVE_REQUEST: [QRCMoveRequestData];
    C_GET_REQUEST: [QRCGetRequestData];
    C_STORE_REQUEST: [QRCStoreRequestData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    CANNOT_START_LISTENER: [QRCannotStartListenerData];
}
/** Options for creating a DcmQRSCP server instance. */
interface DcmQRSCPOptions {
    /** Path to the dcmqrscp configuration file (required). */
    readonly configFile: string;
    /** Override port from config (positional arg). */
    readonly port?: number | undefined;
    /** Single-process mode (-s flag, recommended on Windows). */
    readonly singleProcess?: boolean | undefined;
    /** Check Find responses (-XF). */
    readonly checkFind?: boolean | undefined;
    /** Check Move responses (-XM). */
    readonly checkMove?: boolean | undefined;
    /** Disable C-GET support (--disable-get). */
    readonly disableGet?: boolean | undefined;
    /** Maximum PDU receive size. */
    readonly maxPdu?: number | undefined;
    /** ACSE timeout in seconds (passed to DCMTK as-is). */
    readonly acseTimeout?: number | undefined;
    /** DIMSE timeout in seconds (passed to DCMTK as-is). */
    readonly dimseTimeout?: number | undefined;
    /** Enable verbose mode (default true for event detection). */
    readonly verbose?: boolean | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * DICOM Query/Retrieve SCP server wrapping the dcmqrscp binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * @example
 * ```ts
 * const result = DcmQRSCP.create({ configFile: '/etc/dcmqrscp.cfg', port: 11112 });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('C_FIND_REQUEST', (data) => console.log('Find:', data.raw));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class DcmQRSCP extends DcmtkProcess {
    private readonly parser;
    private abortSignal;
    private abortHandler;
    private constructor();
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    /**
     * Registers a typed listener for a dcmqrscp-specific event.
     *
     * @param event - The event name from DcmQRSCPEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    onEvent<K extends keyof DcmQRSCPEventMap>(event: K, listener: (...args: DcmQRSCPEventMap[K]) => void): this;
    /**
     * Registers a listener for incoming C-FIND requests.
     *
     * @param listener - Callback receiving C-FIND request data
     * @returns this for chaining
     */
    onCFindRequest(listener: (...args: DcmQRSCPEventMap['C_FIND_REQUEST']) => void): this;
    /**
     * Registers a listener for incoming C-MOVE requests.
     *
     * @param listener - Callback receiving C-MOVE request data
     * @returns this for chaining
     */
    onCMoveRequest(listener: (...args: DcmQRSCPEventMap['C_MOVE_REQUEST']) => void): this;
    /**
     * Creates a new DcmQRSCP server instance.
     *
     * @param options - Configuration options for the dcmqrscp server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: DcmQRSCPOptions): Result<DcmQRSCP>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * DICOM Worklist Management SCP server wrapping the wlmscpfs binary.
 *
 * Provides a type-safe, event-driven API for serving worklist data
 * from a file-system based database. Uses a static factory pattern
 * because binary resolution and validation must happen before the
 * constructor call.
 *
 * @module servers/Wlmscpfs
 */

/** Typed event map for the Wlmscpfs server. */
interface WlmscpfsEventMap {
    LISTENING: [WlmListeningData];
    ASSOCIATION_RECEIVED: [WlmAssociationReceivedData];
    ASSOCIATION_ACKNOWLEDGED: [WlmAssociationAcknowledgedData];
    C_FIND_REQUEST: [WlmCFindRequestData];
    ASSOCIATION_RELEASE: [];
    ASSOCIATION_ABORTED: [];
    ECHO_REQUEST: [];
    CANNOT_START_LISTENER: [WlmCannotStartListenerData];
}
/** Options for creating a Wlmscpfs server instance. */
interface WlmscpfsOptions {
    /** Port to listen on (required, positional arg). */
    readonly port: number;
    /** Worklist data directory (required, -dfp flag). */
    readonly worklistDirectory: string;
    /** Enable file rejection (default true). Maps to -efr / -dfr. */
    readonly enableFileRejection?: boolean | undefined;
    /** Maximum PDU receive size. */
    readonly maxPdu?: number | undefined;
    /** ACSE timeout in seconds (passed to DCMTK as-is). */
    readonly acseTimeout?: number | undefined;
    /** DIMSE timeout in seconds (passed to DCMTK as-is). */
    readonly dimseTimeout?: number | undefined;
    /** Maximum simultaneous associations. */
    readonly maxAssociations?: number | undefined;
    /** Enable verbose mode (default true for event detection). */
    readonly verbose?: boolean | undefined;
    /** Timeout for start() to resolve (milliseconds). */
    readonly startTimeoutMs?: number | undefined;
    /** Timeout for graceful drain during stop() (milliseconds). */
    readonly drainTimeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * DICOM Worklist Management SCP server wrapping the wlmscpfs binary.
 *
 * Uses a static `create()` factory because binary resolution is fallible
 * and must complete before the constructor runs.
 *
 * Note: wlmscpfs does not print a reliable "listening" message in all
 * DCMTK versions, so `start()` resolves on spawn (like StoreSCP).
 *
 * @example
 * ```ts
 * const result = Wlmscpfs.create({ port: 2005, worklistDirectory: '/var/worklists' });
 * if (result.ok) {
 *     const server = result.value;
 *     server.onEvent('C_FIND_REQUEST', (data) => console.log('Find:', data.raw));
 *     const startResult = await server.start();
 * }
 * ```
 */
declare class Wlmscpfs extends DcmtkProcess {
    private readonly parser;
    private abortSignal;
    private abortHandler;
    private constructor();
    /** Disposes the server and its parser, preventing listener leaks. */
    [Symbol.dispose](): void;
    /**
     * Registers a typed listener for a wlmscpfs-specific event.
     *
     * @param event - The event name from WlmscpfsEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    onEvent<K extends keyof WlmscpfsEventMap>(event: K, listener: (...args: WlmscpfsEventMap[K]) => void): this;
    /**
     * Registers a listener for incoming C-FIND requests.
     *
     * @param listener - Callback receiving C-FIND request data
     * @returns this for chaining
     */
    onCFindRequest(listener: (...args: WlmscpfsEventMap['C_FIND_REQUEST']) => void): this;
    /**
     * Registers a listener for when the server starts listening.
     *
     * @param listener - Callback receiving listening data (port)
     * @returns this for chaining
     */
    onListening(listener: (...args: WlmscpfsEventMap['LISTENING']) => void): this;
    /**
     * Creates a new Wlmscpfs server instance.
     *
     * @param options - Configuration options for the wlmscpfs server
     * @returns A Result containing the server instance or a validation/resolution error
     */
    static create(options: WlmscpfsOptions): Result<Wlmscpfs>;
    /** Wires the line parser to the process output. */
    private wireParser;
    /** Wires an AbortSignal to stop the server. */
    private wireAbortSignal;
}

/**
 * Pure state machine tracking DICOM association lifecycle.
 *
 * No I/O, no async, no EventEmitter — just state transitions.
 * Used by Dcmrecv and StoreSCP to correlate files to associations.
 *
 * State machine:
 * ```
 * IDLE -> [beginAssociation] -> ACTIVE -> [trackFile]* -> [endAssociation] -> IDLE
 * ```
 *
 * This single-slot design is safe because all DCMTK server binaries
 * (dcmrecv, storescp, etc.) are single-threaded and handle one
 * association at a time. Concurrent connections queue at the TCP level,
 * so associations never interleave in the output stream.
 *
 * @module servers/AssociationTracker
 */
/** Context for the currently active association. */
interface AssociationContext {
    readonly associationId: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
    readonly startTime: number;
    readonly files: string[];
}
/** A file enriched with association context. */
interface TrackedFile {
    readonly filePath: string;
    readonly associationId: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
}
/** Summary emitted when an association completes. */
interface AssociationSummary {
    readonly associationId: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
    readonly files: readonly string[];
    readonly durationMs: number;
    readonly endReason: 'release' | 'abort';
}
/**
 * Tracks DICOM association lifecycle for file-to-source correlation.
 *
 * Maintains a simple IDLE/ACTIVE state machine. While active, all tracked
 * files are enriched with the current association context. Only one
 * association can be active at a time — this is safe because DCMTK
 * servers are single-threaded and process associations sequentially.
 *
 * @example
 * ```ts
 * const tracker = new AssociationTracker();
 * const id = tracker.beginAssociation({ callingAE: 'SCU', calledAE: 'SCP', source: 'db' });
 * const file = tracker.trackFile('/path/to/received.dcm');
 * const summary = tracker.endAssociation('release');
 * ```
 */
declare class AssociationTracker {
    private association;
    private counter;
    /**
     * Begins a new association, transitioning from IDLE to ACTIVE.
     *
     * If an association is already active, it is silently ended (abort)
     * and the new one begins.
     *
     * @param data - Association metadata
     * @returns The unique association ID
     */
    beginAssociation(data: {
        readonly callingAE: string;
        readonly calledAE: string;
        readonly source: string;
    }): string;
    /**
     * Tracks a file received during the current association.
     *
     * If no association is active, returns a TrackedFile with empty context.
     *
     * @param filePath - Path to the received file
     * @returns A TrackedFile enriched with association context
     */
    trackFile(filePath: string): TrackedFile;
    /**
     * Ends the current association, transitioning from ACTIVE to IDLE.
     *
     * @param reason - Why the association ended
     * @returns An AssociationSummary, or undefined if no association was active
     */
    endAssociation(reason: 'release' | 'abort'): AssociationSummary | undefined;
    /** The currently active association context, or undefined. */
    get current(): AssociationContext | undefined;
    /** Whether an association is currently active. */
    get isActive(): boolean;
    /** Resets the tracker to IDLE, discarding any active association. */
    reset(): void;
}

/**
 * Pooled DICOM receiver with auto-scaling.
 *
 * Manages a pool of long-lived `Dcmrecv` workers behind a TCP proxy,
 * routing incoming connections to idle workers. Workers are reused
 * across associations — they are only stopped during scale-down or
 * shutdown.
 *
 * @module servers/DicomReceiver
 */

/** Snapshot of the worker pool state. */
interface PoolStatus {
    /** Number of idle workers ready for connections. */
    readonly idle: number;
    /** Number of workers currently handling associations. */
    readonly busy: number;
    /** Total number of workers (idle + busy). */
    readonly total: number;
}
/** Data emitted with FILE_RECEIVED events. */
interface ReceiverFileData {
    readonly filePath: string;
    readonly associationId: string;
    readonly associationDir: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
    readonly instance: DicomInstance;
}
/** Data emitted with ASSOCIATION_COMPLETE events. */
interface ReceiverAssociationData {
    readonly associationId: string;
    readonly associationDir: string;
    readonly callingAE: string;
    readonly calledAE: string;
    readonly source: string;
    readonly files: readonly string[];
    readonly durationMs: number;
    readonly endReason: 'release' | 'abort';
    readonly totalBytes: number;
    readonly bytesPerSecond: number;
    readonly startAt: number;
    readonly endAt: number;
}
/** Data emitted with error events. */
interface ReceiverErrorData {
    readonly error: Error;
    readonly filePath?: string;
    readonly associationId?: string;
    readonly associationDir?: string;
    readonly callingAE?: string;
    readonly calledAE?: string;
    readonly source?: string;
}
/** Typed event map for DicomReceiver. */
interface DicomReceiverEventMap {
    FILE_RECEIVED: [ReceiverFileData];
    ASSOCIATION_COMPLETE: [ReceiverAssociationData];
    error: [ReceiverErrorData];
}
/** Options for creating a DicomReceiver instance. */
interface DicomReceiverOptions {
    /** External port to listen on (required). */
    readonly port: number;
    /** Root directory for association subdirectories (required). */
    readonly storageDir: string;
    /** Application Entity Title for workers. */
    readonly aeTitle?: string | undefined;
    /** Minimum number of idle workers to maintain. */
    readonly minPoolSize?: number | undefined;
    /** Maximum total workers allowed. */
    readonly maxPoolSize?: number | undefined;
    /** Timeout for waiting for an idle worker (milliseconds). */
    readonly connectionTimeoutMs?: number | undefined;
    /** Path to a dcmrecv association negotiation configuration file. */
    readonly configFile?: string | undefined;
    /** Profile name within the configuration file. */
    readonly configProfile?: string | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}
/**
 * Pooled DICOM receiver with auto-scaling.
 *
 * Manages a pool of long-lived `Dcmrecv` workers behind a TCP proxy.
 * Incoming connections are routed to idle workers. Workers are reused
 * across associations and only stopped during scale-down or shutdown.
 *
 * @example
 * ```ts
 * const result = DicomReceiver.create({
 *     port: 4242,
 *     storageDir: '/data/received',
 *     minPoolSize: 2,
 *     maxPoolSize: 8,
 * });
 * if (!result.ok) { console.error(result.error.message); return; }
 * const receiver = result.value;
 *
 * receiver.onFileReceived(data => console.log('File:', data.filePath));
 * receiver.onAssociationComplete(data => console.log('Done:', data.associationDir));
 *
 * await receiver.start();
 * ```
 */
declare class DicomReceiver extends EventEmitter<DicomReceiverEventMap> {
    private readonly options;
    private readonly minPoolSize;
    private readonly maxPoolSize;
    private readonly connectionTimeoutMs;
    private readonly workers;
    private tcpServer;
    private associationCounter;
    private started;
    private stopping;
    private abortHandler;
    private constructor();
    /**
     * Creates a new DicomReceiver instance.
     *
     * @param options - Configuration options
     * @returns A Result containing the instance or a validation error
     */
    static create(options: DicomReceiverOptions): Result<DicomReceiver>;
    /**
     * Starts the TCP proxy and spawns the initial worker pool.
     *
     * @returns A Result indicating success or failure
     */
    start(): Promise<Result<void>>;
    /**
     * Stops the TCP proxy and all workers.
     */
    stop(): Promise<void>;
    /**
     * Registers a typed listener for a DicomReceiver-specific event.
     *
     * @param event - The event name from DicomReceiverEventMap
     * @param listener - Callback receiving typed event data
     * @returns this for chaining
     */
    onEvent<K extends keyof DicomReceiverEventMap>(event: K, listener: (...args: DicomReceiverEventMap[K]) => void): this;
    /**
     * Registers a listener for received files.
     *
     * @param listener - Callback receiving file data
     * @returns this for chaining
     */
    onFileReceived(listener: (data: ReceiverFileData) => void): this;
    /**
     * Registers a listener for completed associations.
     *
     * @param listener - Callback receiving association data
     * @returns this for chaining
     */
    onAssociationComplete(listener: (data: ReceiverAssociationData) => void): this;
    /** Current pool status. */
    get poolStatus(): PoolStatus;
    /** Starts the TCP proxy on the configured port. */
    private startTcpProxy;
    /** Closes the TCP proxy server. */
    private closeTcpProxy;
    /** Routes an incoming connection to an idle worker. */
    private handleConnection;
    /** Finds an idle worker, retrying up to connectionTimeoutMs. */
    private findIdleWorker;
    /** Returns the first idle worker, or undefined. */
    private getIdleWorker;
    /** Pipes remote socket bidirectionally to the worker's port. */
    private pipeConnection;
    /** Spawns `count` new workers and adds them to the pool. */
    private spawnWorkers;
    /** Spawns a single Dcmrecv worker with an ephemeral port. */
    private spawnWorker;
    /** Stops a single worker: stop process, clean temp dir, remove from pool. */
    private stopWorker;
    /** Pre-emptively spawns workers to keep idle count >= minPoolSize. */
    private replenishPool;
    /** Stops excess idle workers when idle count > minPoolSize + 2. */
    private scaleDown;
    /** Wires FILE_RECEIVED and ASSOCIATION_COMPLETE events on a worker. */
    private wireWorkerEvents;
    /** Wires FILE_RECEIVED from dcmrecv worker to handleFileReceived. */
    private wireFileReceived;
    /** Moves a received file, opens it as DicomInstance, and emits FILE_RECEIVED. */
    private handleFileReceived;
    /** Returns worker to idle pool on association complete, emits summary. */
    private wireAssociationComplete;
    /** Wires an AbortSignal to stop the receiver. */
    private wireAbortSignal;
}

export { type AssociationAcknowledgedData, type AssociationCompleteData, type AssociationContext, type AssociationReceivedData, type AssociationSummary, AssociationTracker, type CStoreRequestData, type CannotStartListenerData, type ConfigErrorData, DCMPRSCP_FATAL_EVENTS, DCMPRSCP_PATTERNS, DCMPSRCV_FATAL_EVENTS, DCMPSRCV_PATTERNS, DCMQRSCP_FATAL_EVENTS, DCMQRSCP_PATTERNS, DCMRECV_FATAL_EVENTS, DCMRECV_PATTERNS, type DatabaseReadyData, DcmQRSCP, type DcmQRSCPEventMap, type DcmQRSCPOptions, DcmprsCP, type DcmprsCPEventMap, type DcmprsCPOptions, DcmprscpEvent, type DcmprscpEventValue, Dcmpsrcv, DcmpsrcvEvent, type DcmpsrcvEventMap, type DcmpsrcvEventValue, type DcmpsrcvOptions, DcmqrscpEvent, type DcmqrscpEventValue, Dcmrecv, DcmrecvEvent, type DcmrecvEventMap, type DcmrecvEventValue, type DcmrecvOptions, DcmtkProcess, type DcmtkProcessConfig, type DcmtkProcessEventMap, DicomReceiver, type DicomReceiverEventMap, type DicomReceiverOptions, type EventPattern, type FileDeletedData, type FileReceivedData, FilenameMode, type FilenameModeValue, LineParser, type LineParserEventMap, type MultiLineConfig, type PoolStatus, PreferredTransferSyntax, type PreferredTransferSyntaxValue, type PrintAssociationAcknowledgedData, type PrintAssociationReceivedData, type PrintCannotStartListenerData, ProcessState, type ProcessStateValue, type QRAssociationAcknowledgedData, type QRAssociationReceivedData, type QRCFindRequestData, type QRCGetRequestData, type QRCMoveRequestData, type QRCStoreRequestData, type QRCannotStartListenerData, type QRListeningData, type ReceiverAssociationAcknowledgedData, type ReceiverAssociationData, type ReceiverAssociationReceivedData, type ReceiverCStoreRequestData, type ReceiverCannotStartListenerData, type ReceiverConfigErrorData, type ReceiverDatabaseReadyData, type ReceiverEchoRequestData, type ReceiverErrorData, type ReceiverFileData, type ReceiverListeningData, type RefusingAssociationData, STORESCP_FATAL_EVENTS, STORESCP_PATTERNS, StorageMode, type StorageModeValue, StoreSCP, type StoreSCPEventMap, type StoreSCPOptions, StoreSCPPreset, type StoreSCPPresetName, type StoredFileData, StorescpEvent, type StorescpEventValue, type StoringFileData, type SubdirectoryCreatedData, SubdirectoryMode, type SubdirectoryModeValue, type TrackedFile, WLMSCPFS_FATAL_EVENTS, WLMSCPFS_PATTERNS, type WlmAssociationAcknowledgedData, type WlmAssociationReceivedData, type WlmCFindRequestData, type WlmCannotStartListenerData, type WlmListeningData, Wlmscpfs, WlmscpfsEvent, type WlmscpfsEventMap, type WlmscpfsEventValue, type WlmscpfsOptions };
