/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import type { SupportedTransportsBitmap } from "#common/SupportedTransportsBitmap.js";
import { AsyncObservable, Bytes, Channel, Duration, Lifetime, ObservableValue, Timestamp } from "#general";
import { MessageChannel } from "#protocol/MessageChannel.js";
import type { MessageExchange } from "#protocol/MessageExchange.js";
import { SessionIntervals } from "#session/SessionIntervals.js";
import type { NodeId, TypeFromPartialBitSchema } from "#types";
import type { DecodedMessage, DecodedPacket, Message, Packet, PacketHeader, SessionType } from "../codec/MessageCodec.js";
import type { Fabric } from "../fabric/Fabric.js";
import type { MessageCounter } from "../protocol/MessageCounter.js";
import type { MessageReceptionState } from "../protocol/MessageReceptionState.js";
import type { SessionManager } from "./SessionManager.js";
import { SessionParameters } from "./SessionParameters.js";
export declare abstract class Session {
    #private;
    abstract get via(): string;
    timestamp: Timestamp;
    readonly createdAt: Timestamp;
    activeTimestamp: Timestamp;
    abstract type: SessionType;
    protected deferredClose: boolean;
    protected idleInterval: Duration;
    protected activeInterval: Duration;
    protected activeThreshold: Duration;
    protected readonly dataModelRevision: number;
    protected readonly interactionModelRevision: number;
    protected readonly specificationVersion: number;
    protected readonly maxPathsPerInvoke: number;
    protected readonly messageCounter: MessageCounter;
    protected readonly messageReceptionState?: MessageReceptionState;
    protected readonly supportedTransports: TypeFromPartialBitSchema<typeof SupportedTransportsBitmap>;
    protected readonly maxTcpMessageSize?: number;
    constructor(config: Session.Configuration);
    get exchanges(): Set<MessageExchange>;
    addExchange(exchange: MessageExchange): void;
    deleteExchange(exchange: MessageExchange): void;
    get closing(): ObservableValue<[any, ...any[]], void>;
    notifyActivity(messageReceived: boolean): void;
    get isPeerActive(): boolean;
    getIncrementedMessageCounter(): Promise<number>;
    updateMessageCounter(messageCounter: number, _sourceNodeId?: NodeId, _operationalKey?: Bytes): void;
    /**
     * Emits on graceful close.
     *
     * During normal operation this should trigger a close message to notify the peer of closure.
     */
    get gracefulClose(): AsyncObservable<[], void>;
    /**
     * Once set this flag prevents establishment of new exchanges.
     */
    get isClosing(): boolean;
    protected static generateNonce(securityFlags: number, messageId: number, nodeId: NodeId): Uint8Array<ArrayBufferLike>;
    /**
     * The peer's session parameters.
     */
    get parameters(): SessionParameters;
    /**
     * Allows updating the Session timing parameters based on received information from the peer during PASE/CASE initialization
     */
    set timingParameters(intervals: Partial<SessionIntervals>);
    abstract isSecure: boolean;
    abstract id: number;
    abstract peerSessionId: number;
    abstract nodeId: NodeId | undefined;
    abstract peerNodeId: NodeId | undefined;
    abstract associatedFabric: Fabric;
    abstract supportsMRP: boolean;
    abstract decode(packet: DecodedPacket, aad?: Bytes): DecodedMessage;
    abstract encode(message: Message): Packet;
    static idStrOf(source: Packet | PacketHeader | number): string;
    /**
     * Close the session.
     *
     * This begins the close process.  {@link shutdownLogic} is logic that should run once the session no longer accepts
     * new exchanges.  It may set {@link deferredClose} to prevent the close from proceeding until all exchanges are
     * finished.  Otherwise, the close will proceed immediately.
     */
    initiateClose(shutdownLogic?: () => Promise<void>): Promise<void>;
    /**
     * Force-close the session.
     *
     * This terminates (potentially) subscriptions and exchanges without notifying peers.  It places the session in a
     * closing state so no further exchanges are accepted.
     *
     * @param except an exchange that should not be forced close; this allows the current exchange to remain open
     * @param keepSubscriptions whether to keep the subscriptions open after force-closing the session.
     *  TODO refactor when moving subscriptions away from sessions
     */
    initiateForceClose(except?: MessageExchange, keepSubscriptions?: boolean): Promise<void>;
    get isClosed(): boolean;
    /**
     * The {@link MessageChannel} other components use for session communication.
     */
    get channel(): MessageChannel;
    get usesMrp(): boolean;
    get supportsLargeMessages(): boolean;
    get hasActiveExchanges(): boolean;
    closeSubscriptions(_cancelledByPeer?: boolean): Promise<number>;
    detachChannel(): MessageChannel | undefined;
    protected close(): Promise<void>;
    protected get manager(): SessionManager | undefined;
    protected set channel(channel: MessageChannel);
    join(...name: unknown[]): Lifetime;
    /**
     * Invoked by the manager when the session is "live".
     *
     * This is separate from construction because we sometimes discard sessions without installing in a manager or
     * closing.
     */
    activate(): Lifetime;
    protected set lifetime(lifetime: Lifetime);
}
export declare namespace Session {
    interface CommonConfig {
        manager?: SessionManager;
        /**
         * When setting this to true the session is not automatically registered to a provided session manager.
         * You need to do this yourself.
         */
        delayManagerRegistration?: true;
        channel?: Channel<Bytes>;
    }
    interface Configuration extends CommonConfig {
        messageCounter: MessageCounter;
        messageReceptionState?: MessageReceptionState;
        sessionParameters?: SessionParameters.Config;
        setActiveTimestamp: boolean;
    }
}
//# sourceMappingURL=Session.d.ts.map