/**
 * NodePropSet — canonical node property operation (internal only).
 * Lowered to PropSet on the wire.
 */
import Op from "./Op.js";
import { OP_SCOPE_CANONICAL } from "./OpScope.js";
import { assertNonEmptyString, assertNoReservedBytes } from "./validate.js";
import { encodePropKey } from "../../services/KeyCodec.js";
import { mutateProp, snapshotProp, accumulatePropDiff } from "./propHelpers.js";
import ReceiptBuilder from "../../services/ReceiptBuilder.js";
export default class NodePropSet extends Op {
    receiptName = 'NodePropSet';
    node;
    key;
    value; // nosemgrep: ts-no-unknown-outside-adapters -- 0025B
    constructor(node, key, value) {
        super('NodePropSet', OP_SCOPE_CANONICAL);
        assertNonEmptyString(node, 'NodePropSet', 'node');
        assertNonEmptyString(key, 'NodePropSet', 'key');
        assertNoReservedBytes(node, 'NodePropSet', 'node');
        assertNoReservedBytes(key, 'NodePropSet', 'key');
        this.node = node;
        this.key = key;
        this.value = value;
        Object.freeze(this);
    }
    validate() { }
    mutate(state, eventId) {
        mutateProp(state, encodePropKey(this.node, this.key), eventId, this.value);
    }
    outcome(state, eventId) {
        return ReceiptBuilder.propSetOutcome(state, { node: this.node, key: this.key }, eventId);
    }
    snapshot(state) {
        return snapshotProp(state, encodePropKey(this.node, this.key));
    }
    accumulate(diff, state, before) {
        accumulatePropDiff(diff, state, this.node, this.key, before);
    }
}
