"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.makeEditManagerCodecBuilder = exports.editManagerCodecName = void 0;
const internal_1 = require("@fluidframework/runtime-utils/internal");
const index_js_1 = require("../codec/index.js");
const editManagerCodecsV1toV4_js_1 = require("./editManagerCodecsV1toV4.js");
const editManagerCodecsVSharedBranches_js_1 = require("./editManagerCodecsVSharedBranches.js");
const editManagerFormatCommons_js_1 = require("./editManagerFormatCommons.js");
/**
 * Codec name used to identify the {@link EditManager} codec, see {@link makeEditManagerCodecBuilder}.
 */
exports.editManagerCodecName = "EditManager";
/**
 * Creates a {@link ClientVersionDispatchingCodecBuilder} encoding for {@link SummaryData}.
 */
function makeEditManagerCodecBuilder() {
    // See EditManagerFormatVersion and its members for documentation on what changed in each version.
    const versions = [
        (0, index_js_1.makeDiscontinuedCodecAndSchema)(editManagerFormatCommons_js_1.EditManagerFormatVersion.v1, "2.73.0"),
        (0, index_js_1.makeDiscontinuedCodecAndSchema)(editManagerFormatCommons_js_1.EditManagerFormatVersion.v2, "2.73.0"),
        {
            minVersionForCollab: internal_1.lowestMinVersionForCollab,
            formatVersion: editManagerFormatCommons_js_1.EditManagerFormatVersion.v3,
            codec: (options) => (0, editManagerCodecsV1toV4_js_1.makeV1toV4andV6CodecWithVersion)(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(editManagerFormatCommons_js_1.EditManagerFormatVersion.v3)), options.revisionTagCodec, editManagerFormatCommons_js_1.EditManagerFormatVersion.v3),
        },
        {
            minVersionForCollab: index_js_1.FluidClientVersion.v2_43,
            formatVersion: editManagerFormatCommons_js_1.EditManagerFormatVersion.v4,
            codec: (options) => (0, editManagerCodecsV1toV4_js_1.makeV1toV4andV6CodecWithVersion)(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(editManagerFormatCommons_js_1.EditManagerFormatVersion.v4)), options.revisionTagCodec, editManagerFormatCommons_js_1.EditManagerFormatVersion.v4),
        },
        (0, index_js_1.makeDiscontinuedCodecAndSchema)(editManagerFormatCommons_js_1.EditManagerFormatVersion.v5, "2.74.0"),
        {
            minVersionForCollab: index_js_1.FluidClientVersion.v2_80,
            formatVersion: editManagerFormatCommons_js_1.EditManagerFormatVersion.v6,
            codec: (options) => (0, editManagerCodecsV1toV4_js_1.makeV1toV4andV6CodecWithVersion)(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(editManagerFormatCommons_js_1.EditManagerFormatVersion.v6)), options.revisionTagCodec, editManagerFormatCommons_js_1.EditManagerFormatVersion.v6),
        },
        {
            minVersionForCollab: undefined,
            formatVersion: editManagerFormatCommons_js_1.EditManagerFormatVersion.vSharedBranches,
            codec: (options) => (0, editManagerCodecsVSharedBranches_js_1.makeSharedBranchesCodecWithVersion)(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(editManagerFormatCommons_js_1.EditManagerFormatVersion.vSharedBranches)), options.revisionTagCodec, editManagerFormatCommons_js_1.EditManagerFormatVersion.vSharedBranches),
        },
    ];
    return index_js_1.ClientVersionDispatchingCodecBuilder.build(exports.editManagerCodecName, versions);
}
exports.makeEditManagerCodecBuilder = makeEditManagerCodecBuilder;
/**
 * Returns a {@link CodecTree} for the EditManager format at the given client version,
 * with the provided change codec tree as a child.
 */
function getCodecTreeForEditManagerFormatWithChange(clientVersion, changeFormat) {
    const builder = makeEditManagerCodecBuilder();
    return {
        ...builder.getCodecTree(clientVersion),
        children: [changeFormat],
    };
}
exports.getCodecTreeForEditManagerFormatWithChange = getCodecTreeForEditManagerFormatWithChange;
//# sourceMappingURL=editManagerCodecs.js.map