/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ActionContext, Behavior, type ClusterState, ValueSupervisor } from "#behavior/index.js";
import { Thermostat } from "#clusters/thermostat";
import { Endpoint } from "#endpoint/Endpoint.js";
import { Environment, Environmental } from "#general";
import { FabricManager } from "#protocol";
import { AttributeId } from "#types";
/**
 * Handles atomic write handling according to Matter definitions.
 * The implementation tries to be generic, but is currently only used by the Thermostat cluster, so the atomic write
 * types are imported from there.
 *
 * The logic requires that the cluster behavior implements the following additional events as "pure Observable()" events,
 * because the current implementation logic requires error thrown by the event handlers to signal validation failures to
 * be thrown back to te emitter. This is not the case for official state events.
 * * `${attributeName}$AtomicChanging` - emitted when an attribute is changed as part of an atomic write, before the value
 *   is actually changed. Receives the new value, the old value and the action context as parameters.
 * * `${attributeName}$AtomicChanged` - emitted when an attribute is changed as part of an atomic write, after the value
 *   is actually changed. Receives the new value, the old value and the action context as parameters.
 *
 * TODO: Move out of thermostat behavior into a more generic behavior handler once used by other clusters too. Then we
 *  also need to adjust how it is handled.
 *  Proper solution might be to add the handling of the atomic Request command on interaction level and leave the
 *  transaction open until it is rolled back or committed. This might have side effects on other parts of the system though.
 *  So lets do that later when we have more clusters using it.
 */
export declare class AtomicWriteHandler {
    #private;
    constructor(fabricManager: FabricManager);
    static [Environmental.create](env: Environment): AtomicWriteHandler;
    close(): void;
    /**
     * Implements the begin write logic for an atomic write.
     */
    beginWrite(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: Behavior.Type): Thermostat.AtomicResponse;
    /**
     * Handles writing a value for an attribute as part of an ongoing atomic write.
     * It uses the *$AtomicChanging* event to trigger validation of the partial write.
     */
    writeAttribute(context: ValueSupervisor.Session, endpoint: Endpoint, cluster: Behavior.Type, attribute: AttributeId, value: unknown): void;
    /**
     * Implements the commit logic for an atomic write.
     */
    commitWrite<B extends Behavior.Type>(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: B, clusterState: ClusterState.Type<any, B>): Promise<Thermostat.AtomicResponse>;
    /**
     * Implements the rollback logic for an atomic write.
     */
    rollbackWrite(request: Thermostat.AtomicRequest, context: ActionContext, endpoint: Endpoint, cluster: Behavior.Type): Thermostat.AtomicResponse;
    /**
     * Returns the pending value for the given attribute and peer, if any.
     */
    pendingValueForAttributeAndPeer(context: ValueSupervisor.Session, endpoint: Endpoint, cluster: Behavior.Type, attribute: AttributeId): unknown;
}
//# sourceMappingURL=AtomicWriteHandler.d.ts.map