import type { CommandClass } from "@zwave-js/cc";
import type { CommandRequest, ContainsCC } from "@zwave-js/serial/serialapi";
import { type Timer } from "@zwave-js/shared";
/** A partial CC session and the segments received for it so far */
export interface PartialCCSession {
    nodeId: number;
    /** The received segments, keyed by their remaining segments count */
    segments: Map<number, CommandClass>;
    /** The message which contained the final segment, if it was already received */
    finalMsg?: CommandRequest & ContainsCC;
    /** The message which contained the most recent segment */
    lastSegmentMsg: CommandRequest & ContainsCC;
    /** The request this session is the response to, if known */
    requestCC?: CommandClass;
    /** How many times the response may still be re-requested when segments are missing */
    attemptsLeft: number;
    timeout?: Timer;
}
export type PartialCCUpdate = {
    type: "segment";
    duplicate: boolean;
} | {
    type: "complete";
    /** The final segment, which the partials are merged into */
    command: CommandClass;
    /** The other segments, ordered like they were transmitted by the node */
    partials: CommandClass[];
    /** The message which contained the final segment */
    finalMsg: CommandRequest & ContainsCC;
};
export interface PartialCCSessionManagerHost {
    /** How long to wait for the next segment of a session */
    getSegmentTimeout(): number;
    /** How many times the response of a session with missing segments may be re-requested */
    getMaxReRequestAttempts(): number;
    /** Determines the request CC a newly created session is the response to, if any */
    findRequestCC(command: CommandClass): CommandClass | undefined;
    /** Re-requests the response a session belongs to because segments are missing */
    rerequestSession(session: PartialCCSession): void;
    /** Called when an incomplete session is dropped */
    onSessionLost(session: PartialCCSession): void;
}
/**
 * Tracks the state of partial CC sessions, i.e. commands which are split into
 * multiple segments that need to be reassembled before they can be handled.
 *
 * Segments are identified by their "remaining segments" counter (e.g. a
 * "reports to follow" field), which decreases towards 0 for the final segment.
 * Since Z-Wave commands from a node are received in order, this allows detecting
 * duplicated and missing segments.
 */
export declare class PartialCCSessionManager {
    constructor(host: PartialCCSessionManagerHost);
    private host;
    private sessions;
    private drains;
    /**
     * Determines if the given command belongs to a partial CC session and tracks it if so.
     * Returns `undefined` for commands that do not support partial sessions.
     */
    handleCommand(command: CommandClass, msg: CommandRequest & ContainsCC): PartialCCUpdate | undefined;
    /** Re-requests the response a session belongs to, or drops the session when that is not possible */
    private recoverOrDrop;
    private deleteSession;
    private deleteDrain;
    /** Drops all sessions and stops all timers */
    clear(): void;
}
//# sourceMappingURL=PartialCCSessionManager.d.ts.map