/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { FieldKind, getDefaultProvider, createFieldSchema } from "../fieldSchema.js";
import { stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema, } from "../leafNodeSchema.js";
const defaultOptionalProvider = getDefaultProvider(() => []);
function optional(t, props) {
    return createFieldSchema(FieldKind.Optional, t, {
        defaultProvider: defaultOptionalProvider,
        ...props,
    });
}
function required(t, props) {
    return createFieldSchema(FieldKind.Required, t, props);
}
// #endregion
/**
 * Implementation of {@link SchemaStatics}.
 * @remarks
 * Entries can use more specific types than {@link SchemaStatics} requires to be more useful for non-public consumers.
 * Additional non-public members are in {@link schemaStatics}.
 */
export const schemaStaticsStable = {
    string: stringSchema,
    number: numberSchema,
    boolean: booleanSchema,
    null: nullSchema,
    handle: handleSchema,
    leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
    optional,
    required,
    optionalRecursive: (t, props) => {
        return createFieldSchemaUnsafe(FieldKind.Optional, t, {
            defaultProvider: defaultOptionalProvider,
            ...props,
        });
    },
    requiredRecursive: (t, props) => {
        return createFieldSchemaUnsafe(FieldKind.Required, t, props);
    },
};
/**
 * Unstable extensions to {@link schemaStaticsStable}.
 */
export const schemaStatics = {
    ...schemaStaticsStable,
    identifier: (props) => {
        return createFieldSchema(FieldKind.Identifier, stringSchema, props);
    },
};
function createFieldSchemaUnsafe(kind, allowedTypes, props) {
    // At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe
    return createFieldSchema(kind, allowedTypes, props);
}
//# sourceMappingURL=schemaStatics.js.map