/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Type } from "@sinclair/typebox";
import { RevisionTagSchema, SessionIdSchema, } from "../core/index.js";
import { brandedNumberType } from "../util/index.js";
const noAdditionalProps = { additionalProperties: false };
const CommitBase = (tChange) => Type.Object({
    revision: RevisionTagSchema,
    change: tChange,
    sessionId: SessionIdSchema,
});
/**
 * @privateRemarks Commits are generally encoded from `GraphCommit`s, which often contain extra data.
 * This `noAdditionalProps` is especially important in that light.
 */
const Commit = (tChange) => Type.Composite([CommitBase(tChange)], noAdditionalProps);
const SeqNumber = brandedNumberType({ multipleOf: 1 });
const SequenceId = Type.Object({
    sequenceNumber: SeqNumber,
    indexInBatch: Type.Optional(Type.Number({ multipleOf: 1, minimum: 0 })),
});
const SequencedCommit = (tChange) => Type.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);
const SummarySessionBranch = (tChange) => Type.Object({
    base: RevisionTagSchema,
    commits: Type.Array(Commit(tChange)),
}, noAdditionalProps);
export const EncodedEditManager = (tChange) => Type.Object({
    version: Type.Union([Type.Literal(1), Type.Literal(2)]),
    trunk: Type.Array(SequencedCommit(tChange)),
    branches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
}, noAdditionalProps);
//# sourceMappingURL=editManagerFormat.js.map