"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncodedFieldBatchGeneric = exports.Count = exports.ShapeIndex = exports.IdentifierOrIndex = void 0;
const Type = __importStar(require("@sinclair/typebox"));
/**
 * Identifier OR Index of an identifier in the identifier list.
 */
exports.IdentifierOrIndex = Type.Union([
    Type.String(),
    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 = Type.Number({ multipleOf: 1, minimum: 0 });
exports.Count = Type.Number({ multipleOf: 1, minimum: 0 });
const EncodedFieldBatchBase = Type.Object({
    identifiers: Type.Array(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: Type.Array(Type.Array(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) => Type.Composite([
    EncodedFieldBatchBase,
    Type.Object({
        version: Type.Literal(version),
        shapes: Type.Array(shape),
    }),
], { additionalProperties: false });
exports.EncodedFieldBatchGeneric = EncodedFieldBatchGeneric;
//# sourceMappingURL=formatGeneric.js.map