/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/core-utils/internal";
import { schemaCodecBuilder } from "../schema-index/index.js";
import { EncodedSchemaChange } from "./schemaChangeFormat.js";
/**
 * Creates a codec for schema changes.
 * @param options - The codec options.
 * @returns The composed schema change codec part.
 */
export function makeSchemaChangeCodec(options) {
    const schemaCodec = schemaCodecBuilder.build(options);
    return {
        encode: (schemaChange) => {
            assert(!schemaChange.isInverse, 0x933 /* Inverse schema changes should never be transmitted */);
            return {
                new: schemaCodec.encode(schemaChange.schema.new),
                old: schemaCodec.encode(schemaChange.schema.old),
            };
        },
        decode: (encoded) => {
            return {
                schema: {
                    new: schemaCodec.decode(encoded.new),
                    old: schemaCodec.decode(encoded.old),
                },
                isInverse: false,
            };
        },
        encodedSchema: EncodedSchemaChange,
    };
}
//# sourceMappingURL=schemaChangeCodecs.js.map