"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncodedChunkGeneric = exports.Count = exports.ShapeIndex = exports.IdentifierOrIndex = void 0;
const typebox_1 = require("@sinclair/typebox");
/**
 * Identifier OR Index of an identifier in the identifier list.
 */
exports.IdentifierOrIndex = typebox_1.Type.Union([
    typebox_1.Type.String(),
    typebox_1.Type.Number({ multipleOf: 1, minimum: 0 }),
]);
/**
 * Reference to a shape, by index.
 *
 * Shapes use a dictionary encoding where they are referenced by their index in a shape array.
 */
exports.ShapeIndex = typebox_1.Type.Number({ multipleOf: 1, minimum: 0 });
exports.Count = typebox_1.Type.Number({ multipleOf: 1, minimum: 0 });
const EncodedChunkBase = typebox_1.Type.Object({
    version: typebox_1.Type.Number(),
    identifiers: typebox_1.Type.Array(typebox_1.Type.String()),
    // TreeValues mixed with indexes into "shapes" and occasional lengths (for specific shapes that require them).
    data: typebox_1.Type.Array(typebox_1.Type.Any()),
}, { additionalProperties: false });
/**
 * Format for encoding a tree chunk.
 * @param version - format version. Must be changed if there is any change to the generic schema, or the `shape` schema.
 * @param shape - schema for union of shape format, see {@link DiscriminatedUnionDispatcher}.
 */
const EncodedChunkGeneric = (version, shape) => typebox_1.Type.Composite([
    EncodedChunkBase,
    typebox_1.Type.Object({
        version: typebox_1.Type.Literal(version),
        shapes: typebox_1.Type.Array(shape),
    }),
], { additionalProperties: false });
exports.EncodedChunkGeneric = EncodedChunkGeneric;
//# sourceMappingURL=formatGeneric.js.map