"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncodedFieldBatchGeneric = 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 EncodedFieldBatchBase = typebox_1.Type.Object({
    version: typebox_1.Type.Number(),
    identifiers: typebox_1.Type.Array(typebox_1.Type.String()),
    /**
     * Top level array is list of field from batch.
     * Inner are TreeValues mixed with indexes into "shapes" and nested arrays where lengths are needed.
     */
    data: typebox_1.Type.Array(typebox_1.Type.Array(typebox_1.Type.Any())),
}, { additionalProperties: false });
/**
 * Format for encoding a tree chunk.
 * @param version - format version.
 * Must be changed if the previously existing decode logic will not correctly handle the new encoding.
 * If adding a new encoding version which does not use this format,
 * this parameter should be retyped to be a union of the subset of FieldBatchFormatVersion values which this supports.
 * @param shape - schema for union of shape format, see {@link DiscriminatedUnionDispatcher}.
 */
const EncodedFieldBatchGeneric = (version, shape) => typebox_1.Type.Composite([
    EncodedFieldBatchBase,
    typebox_1.Type.Object({
        version: typebox_1.Type.Literal(version),
        shapes: typebox_1.Type.Array(shape),
    }),
], { additionalProperties: false });
exports.EncodedFieldBatchGeneric = EncodedFieldBatchGeneric;
//# sourceMappingURL=formatGeneric.js.map