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