/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { unreachableCase } from "@fluidframework/core-utils/internal";
import { makeCodecFamily, } from "../codec/index.js";
import { makeVersionDispatchingCodec } from "../codec/index.js";
import { brand } from "../util/index.js";
import { makeV1CodecWithVersion } from "./editManagerCodecsV1toV4.js";
import { makeV5CodecWithVersion } from "./editManagerCodecsV5.js";
export function makeEditManagerCodec(changeCodecs, dependentChangeFormatVersion, revisionTagCodec, options, writeVersion) {
    const family = makeEditManagerCodecs(changeCodecs, dependentChangeFormatVersion, revisionTagCodec, options);
    return makeVersionDispatchingCodec(family, { ...options, writeVersion });
}
export function makeEditManagerCodecs(changeCodecs, dependentChangeFormatVersion, revisionTagCodec, options) {
    const registry = Array.from(editManagerFormatVersions, (version) => {
        const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
        switch (version) {
            case 1:
            case 2:
            case 3:
            case 4:
                return [
                    version,
                    makeV1CodecWithVersion(changeCodec, revisionTagCodec, options, version),
                ];
            case 5:
                return [
                    version,
                    makeV5CodecWithVersion(changeCodec, revisionTagCodec, options, version),
                ];
            default:
                unreachableCase(version);
        }
    });
    return makeCodecFamily(registry);
}
export const editManagerFormatVersions = new Set([
    brand(1),
    brand(2),
    brand(3),
    brand(4),
    brand(5),
]);
export function getCodecTreeForEditManagerFormatWithChange(version, changeFormat) {
    return {
        name: "EditManager",
        version,
        children: [changeFormat],
    };
}
//# sourceMappingURL=editManagerCodecs.js.map