/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Type } from "@sinclair/typebox";
/**
 * Identifier OR Index of an identifier in the identifier list.
 */
export const 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.
 */
export const ShapeIndex = Type.Number({ multipleOf: 1, minimum: 0 });
export const Count = Type.Number({ multipleOf: 1, minimum: 0 });
/**
 * Options to configure a TypeBox schema as a discriminated union that is simple to validate data against.
 *
 * See DiscriminatedUnionDispatcher for more information on this pattern.
 */
export const unionOptions = {
    additionalProperties: false,
    minProperties: 1,
    maxProperties: 1,
};
const EncodedChunkBase = Type.Object({
    version: Type.Number(),
    identifiers: Type.Array(Type.String()),
    // TreeValues mixed with indexes into "shapes" and occasional lengths (for specific shapes that require them).
    data: Type.Array(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}.
 */
export const EncodedChunkGeneric = (version, shape) => Type.Composite([
    EncodedChunkBase,
    Type.Object({
        version: Type.Literal(version),
        shapes: Type.Array(shape),
    }),
], { additionalProperties: false });
//# sourceMappingURL=formatGeneric.js.map