/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ReadResult } from "#action/response/ReadResult.js";
import { Bytes, Duration } from "@matter/general";
import { Status, TlvDataReport, TlvDataReportForSend, TlvInvokeRequest, TlvInvokeResponse, TlvInvokeResponseForSend, TlvReadRequest, TlvStream, TlvSubscribeRequest, TlvSubscribeResponse, TlvTimedRequest, TlvWriteRequest, TlvWriteResponse, TypeFromSchema } from "@matter/types";
import { Message } from "../codec/MessageCodec.js";
import { ExchangeProvider, NewExchangeOptions } from "../protocol/ExchangeProvider.js";
import { ExchangeReceiveOptions, ExchangeSendOptions, MessageExchange } from "../protocol/MessageExchange.js";
import { AttributeReportPayload, BaseDataReport, DataReportPayloadIterator, EventReportPayload } from "./AttributeDataEncoder.js";
export declare enum MessageType {
    StatusResponse = 1,
    ReadRequest = 2,
    SubscribeRequest = 3,
    SubscribeResponse = 4,
    ReportData = 5,
    WriteRequest = 6,
    WriteResponse = 7,
    InvokeRequest = 8,
    InvokeResponse = 9,
    TimedRequest = 10
}
export type ReadRequest = TypeFromSchema<typeof TlvReadRequest>;
export type DataReport = TypeFromSchema<typeof TlvDataReport>;
export type SubscribeRequest = TypeFromSchema<typeof TlvSubscribeRequest>;
export type SubscribeResponse = TypeFromSchema<typeof TlvSubscribeResponse>;
export type InvokeRequest = TypeFromSchema<typeof TlvInvokeRequest>;
export type InvokeResponse = TypeFromSchema<typeof TlvInvokeResponse>;
export type InvokeResponseForSend = TypeFromSchema<typeof TlvInvokeResponseForSend>;
export type TimedRequest = TypeFromSchema<typeof TlvTimedRequest>;
export type WriteRequest = TypeFromSchema<typeof TlvWriteRequest>;
export type WriteResponse = TypeFromSchema<typeof TlvWriteResponse>;
declare class InteractionMessenger {
    #private;
    constructor(exchange: MessageExchange);
    get exchange(): MessageExchange;
    protected set exchange(value: MessageExchange);
    send(messageType: number, payload: Bytes, options?: ExchangeSendOptions): Promise<void>;
    protected trackEndMessage(promise: Promise<unknown>, errorMessage: string): void;
    sendStatus(status: Status, options?: ExchangeSendOptions): Promise<void>;
    waitForSuccess(expectedMessageInfo: string, options?: {
        expectedProcessingTime?: Duration;
        timeout?: Duration;
    }): Promise<void>;
    nextMessage(expectedMessageType: number, options?: ExchangeReceiveOptions, expectedMessageInfo?: string): Promise<Message>;
    anyNextMessage(expectedMessageInfo: string, options?: ExchangeReceiveOptions): Promise<Message>;
    close(): Promise<void>;
    protected throwIfErrorStatusMessage(message: Message, logHint?: string): void;
    get session(): import("../index.js").Session;
}
export interface InteractionRecipient {
    handleReadRequest(exchange: MessageExchange, request: ReadRequest, message: Message): Promise<{
        dataReport: DataReport;
        payload?: DataReportPayloadIterator;
    }>;
    handleWriteRequest(exchange: MessageExchange, request: WriteRequest, messenger: InteractionServerMessenger, message: Message): Promise<void>;
    handleSubscribeRequest(exchange: MessageExchange, request: SubscribeRequest, messenger: InteractionServerMessenger, message: Message): Promise<void>;
    handleInvokeRequest(exchange: MessageExchange, request: InvokeRequest, messenger: InteractionServerMessenger, message: Message): Promise<void>;
    handleTimedRequest(exchange: MessageExchange, request: TimedRequest, message: Message): void;
}
export declare class InteractionServerMessenger extends InteractionMessenger {
    handleRequest(recipient: InteractionRecipient): Promise<void>;
    /**
     * Handle a DataReport with a Payload Iterator for a DataReport to send, split them into multiple DataReport
     * messages and send them out based on the size.
     */
    sendDataReport(options: {
        baseDataReport: BaseDataReport;
        forFabricFilteredRead: boolean;
        payload?: DataReportPayloadIterator;
        waitForAck?: boolean;
        suppressEmptyReport?: boolean;
    }): Promise<void>;
    sendDataReportMessage(dataReport: TypeFromSchema<typeof TlvDataReportForSend>, waitForAck?: boolean): Promise<void>;
    /**
     * Convert a server interaction report to a DataReport entry
     * TODO remove when anything is migrated completely
     */
    static convertServerInteractionReport(report: ReadResult.Report): AttributeReportPayload | EventReportPayload;
    /**
     * Send a WriteResponse message.
     */
    sendWriteResponse(response: WriteResponse, options?: {
        logContext?: string;
    }): Promise<void>;
    /**
     * Wait for and decode the next WriteRequest message (for chunked writes).
     */
    readNextWriteRequest(): Promise<{
        writeRequest: WriteRequest;
        message: Message;
    }>;
    /**
     * Send an intermediate InvokeResponse chunk with moreChunkedMessages=true and wait for Status.Success.
     * Returns true if a client acknowledged, and we should continue, false if a client terminated the chunked series.
     */
    sendInvokeResponseChunk(response: InvokeResponseForSend): Promise<boolean>;
    /**
     * Send the final InvokeResponse (without moreChunkedMessages flag).
     */
    sendInvokeResponse(response: InvokeResponseForSend): Promise<void>;
}
export declare class IncomingInteractionClientMessenger extends InteractionMessenger {
    #private;
    waitFor(expectedMessageInfo: string, messageType: number, options?: ExchangeReceiveOptions): Promise<Message>;
    /**
     * Read data reports as they come in on the wire.
     *
     * Data reports payloads are decoded but list attributes may be split across messages; these will require reassembly.
     */
    readDataReports(options?: ExchangeReceiveOptions): AsyncGenerator<import("@matter/types").TypeFromFields<{
        subscriptionId: import("@matter/types").OptionalFieldType<number>;
        attributeReports: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
            attributeStatus: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
                path: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    enableTagCompression: import("@matter/types").OptionalFieldType<boolean>;
                    nodeId: import("@matter/types").OptionalFieldType<import("@matter/types").NodeId>;
                    endpointId: import("@matter/types").OptionalFieldType<import("@matter/types").EndpointNumber>;
                    clusterId: import("@matter/types").OptionalFieldType<import("@matter/types").ClusterId>;
                    attributeId: import("@matter/types").OptionalFieldType<import("@matter/types").AttributeId>;
                    listIndex: import("@matter/types").OptionalFieldType<number | null>;
                    wildcardPathFlags: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromPartialBitSchema<{
                        skipRootNode: import("@matter/types").BitFlag;
                        skipGlobalAttributes: import("@matter/types").BitFlag;
                        skipAttributeList: import("@matter/types").BitFlag;
                        reserved1: import("@matter/types").BitFlag;
                        skipCommandLists: import("@matter/types").BitFlag;
                        skipCustomElements: import("@matter/types").BitFlag;
                        skipFixedAttributes: import("@matter/types").BitFlag;
                        skipChangesOmittedAttributes: import("@matter/types").BitFlag;
                        skipDiagnosticsClusters: import("@matter/types").BitFlag;
                    }>>;
                }>>;
                status: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    status: import("@matter/types").FieldType<import("@matter/types").Status>;
                    clusterStatus: import("@matter/types").OptionalFieldType<import("@matter/types").Status>;
                }>>;
            }>>;
            attributeData: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
                dataVersion: import("@matter/types").OptionalFieldType<number>;
                path: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    enableTagCompression: import("@matter/types").OptionalFieldType<boolean>;
                    nodeId: import("@matter/types").OptionalFieldType<import("@matter/types").NodeId>;
                    endpointId: import("@matter/types").OptionalFieldType<import("@matter/types").EndpointNumber>;
                    clusterId: import("@matter/types").OptionalFieldType<import("@matter/types").ClusterId>;
                    attributeId: import("@matter/types").OptionalFieldType<import("@matter/types").AttributeId>;
                    listIndex: import("@matter/types").OptionalFieldType<number | null>;
                    wildcardPathFlags: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromPartialBitSchema<{
                        skipRootNode: import("@matter/types").BitFlag;
                        skipGlobalAttributes: import("@matter/types").BitFlag;
                        skipAttributeList: import("@matter/types").BitFlag;
                        reserved1: import("@matter/types").BitFlag;
                        skipCommandLists: import("@matter/types").BitFlag;
                        skipCustomElements: import("@matter/types").BitFlag;
                        skipFixedAttributes: import("@matter/types").BitFlag;
                        skipChangesOmittedAttributes: import("@matter/types").BitFlag;
                        skipDiagnosticsClusters: import("@matter/types").BitFlag;
                    }>>;
                }>>;
                data: import("@matter/types").FieldType<TlvStream>;
            }>>;
        }>[]>;
        eventReports: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
            eventStatus: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
                path: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    nodeId: import("@matter/types").OptionalFieldType<import("@matter/types").NodeId>;
                    endpointId: import("@matter/types").OptionalFieldType<import("@matter/types").EndpointNumber>;
                    clusterId: import("@matter/types").OptionalFieldType<import("@matter/types").ClusterId>;
                    eventId: import("@matter/types").OptionalFieldType<import("@matter/types").EventId>;
                    isUrgent: import("@matter/types").OptionalFieldType<boolean>;
                }>>;
                status: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    status: import("@matter/types").FieldType<import("@matter/types").Status>;
                    clusterStatus: import("@matter/types").OptionalFieldType<import("@matter/types").Status>;
                }>>;
            }>>;
            eventData: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromFields<{
                path: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                    nodeId: import("@matter/types").OptionalFieldType<import("@matter/types").NodeId>;
                    endpointId: import("@matter/types").OptionalFieldType<import("@matter/types").EndpointNumber>;
                    clusterId: import("@matter/types").OptionalFieldType<import("@matter/types").ClusterId>;
                    eventId: import("@matter/types").OptionalFieldType<import("@matter/types").EventId>;
                    isUrgent: import("@matter/types").OptionalFieldType<boolean>;
                }>>;
                eventNumber: import("@matter/types").FieldType<import("@matter/types").EventNumber>;
                priority: import("@matter/types").FieldType<import("@matter/types").Priority>;
                epochTimestamp: import("@matter/types").OptionalFieldType<number | bigint>;
                systemTimestamp: import("@matter/types").OptionalFieldType<number | bigint>;
                deltaEpochTimestamp: import("@matter/types").OptionalFieldType<number | bigint>;
                deltaSystemTimestamp: import("@matter/types").OptionalFieldType<number | bigint>;
                data: import("@matter/types").OptionalFieldType<TlvStream>;
            }>>;
        }>[]>;
        moreChunkedMessages: import("@matter/types").OptionalFieldType<boolean>;
        suppressResponse: import("@matter/types").OptionalFieldType<boolean>;
        interactionModelRevision: import("@matter/types").FieldType<number>;
    }>, void, unknown>;
}
export declare class InteractionClientMessenger extends IncomingInteractionClientMessenger {
    #private;
    static create(exchangeProvider: ExchangeProvider, options?: NewExchangeOptions): Promise<InteractionClientMessenger>;
    sendReadRequest(readRequest: ReadRequest, options?: ExchangeSendOptions): Promise<void>;
    sendSubscribeRequest(subscribeRequest: SubscribeRequest, options?: ExchangeSendOptions): Promise<void>;
    /**
     * Send an invoke command and handle chunked responses.
     * Returns a combined InvokeResponse with all responses from all chunks, or undefined if suppressResponse
     */
    sendInvokeCommand(invokeRequest: InvokeRequest, options?: ExchangeSendOptions): Promise<InvokeResponse | undefined>;
    sendWriteCommand(writeRequest: WriteRequest, options?: ExchangeSendOptions): Promise<import("@matter/types").TypeFromFields<{
        writeResponses: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
            path: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                enableTagCompression: import("@matter/types").OptionalFieldType<boolean>;
                nodeId: import("@matter/types").OptionalFieldType<import("@matter/types").NodeId>;
                endpointId: import("@matter/types").OptionalFieldType<import("@matter/types").EndpointNumber>;
                clusterId: import("@matter/types").OptionalFieldType<import("@matter/types").ClusterId>;
                attributeId: import("@matter/types").OptionalFieldType<import("@matter/types").AttributeId>;
                listIndex: import("@matter/types").OptionalFieldType<number | null>;
                wildcardPathFlags: import("@matter/types").OptionalFieldType<import("@matter/types").TypeFromPartialBitSchema<{
                    skipRootNode: import("@matter/types").BitFlag;
                    skipGlobalAttributes: import("@matter/types").BitFlag;
                    skipAttributeList: import("@matter/types").BitFlag;
                    reserved1: import("@matter/types").BitFlag;
                    skipCommandLists: import("@matter/types").BitFlag;
                    skipCustomElements: import("@matter/types").BitFlag;
                    skipFixedAttributes: import("@matter/types").BitFlag;
                    skipChangesOmittedAttributes: import("@matter/types").BitFlag;
                    skipDiagnosticsClusters: import("@matter/types").BitFlag;
                }>>;
            }>>;
            status: import("@matter/types").FieldType<import("@matter/types").TypeFromFields<{
                status: import("@matter/types").FieldType<import("@matter/types").Status>;
                clusterStatus: import("@matter/types").OptionalFieldType<import("@matter/types").Status>;
            }>>;
        }>[]>;
        interactionModelRevision: import("@matter/types").FieldType<number>;
    }> | undefined>;
    sendTimedRequest(timeout: Duration, options?: ExchangeSendOptions): Promise<import("@matter/types").TypeFromFields<{
        status: import("@matter/types").FieldType<import("@matter/types").Status>;
        interactionModelRevision: import("@matter/types").FieldType<number>;
    }>>;
    private requestWithSuppressedResponse;
    private request;
}
export {};
//# sourceMappingURL=InteractionMessenger.d.ts.map