/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { makeCodecFamily } from "../../codec/index.js";
import { EncodedGenericChangeset } from "./genericFieldKindFormat.js";
import { newGenericChangeset } from "./genericFieldKindTypes.js";
import { EncodedNodeChangeset } from "./modularChangeFormatV1.js";
export function makeGenericChangeCodec() {
    return makeCodecFamily([[1, makeV1Codec()]]);
}
function makeV1Codec() {
    return {
        encode: (change, context) => {
            const encoded = change
                .toArray()
                .map(([index, nodeChange]) => [index, context.encodeNode(nodeChange)]);
            return encoded;
        },
        decode: (encoded, context) => {
            return newGenericChangeset(encoded.map(([index, nodeChange]) => [index, context.decodeNode(nodeChange)]));
        },
        encodedSchema: EncodedGenericChangeset(EncodedNodeChangeset),
    };
}
//# sourceMappingURL=genericFieldKindCodecs.js.map