"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncodedOptionalChangeset = void 0;
const typebox_1 = require("@sinclair/typebox");
const index_js_1 = require("../modular-schema/index.js");
const noAdditionalProps = { additionalProperties: false };
// Type is intentionally derived.
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const EncodedOptionalChangeset = (tNodeChange) => typebox_1.Type.Object({
    // Nested changes
    c: typebox_1.Type.Optional(tNodeChange),
    // How to replace the current value of the field.
    r: typebox_1.Type.Optional(EncodedReplace),
    // Node detach
    d: typebox_1.Type.Optional(index_js_1.EncodedChangeAtomId),
}, noAdditionalProps);
exports.EncodedOptionalChangeset = EncodedOptionalChangeset;
const EncodedReplace = typebox_1.Type.Object({
    // Whether the field is empty in the input context of this change.
    e: typebox_1.Type.Boolean(),
    // The ID for the node to put in this field, or undefined if the field should be emptied.
    // Will be "self" when the intention is to keep the current node in this field.
    s: typebox_1.Type.Optional(index_js_1.EncodedChangeAtomId),
    // An ID to associate with the node (if any) which is detached by this edit.
    d: index_js_1.EncodedChangeAtomId,
}, noAdditionalProps);
//# sourceMappingURL=optionalFieldChangeFormatV3.js.map