/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { FlexListToUnion, Unenforced } from "../feature-libraries/index.js";
import type { RestrictiveReadonlyRecord, _InlineTrick } from "../util/index.js";
import type { AllowedTypes, ApplyKind, FieldKind, FieldSchema, ImplicitAllowedTypes, ImplicitFieldSchema, NodeFromSchema, NodeKind, TreeNodeFromImplicitAllowedTypes, TreeNodeSchema, WithType } from "./schemaTypes.js";
import type { TreeArrayNodeBase, TreeArrayNode } from "./arrayNode.js";
import type { TreeNode, Unhydrated } from "./types.js";
/**
 * {@link Unenforced} version of `ObjectFromSchemaRecord`.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>> = {
    -readonly [Property in keyof T]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
};
/**
 * {@link Unenforced} version of {@link TreeObjectNode}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type TreeObjectNodeUnsafe<T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecordUnsafe<T> & WithType<TypeName>;
/**
 * {@link Unenforced} version of {@link TreeFieldFromImplicitField}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
/**
 * {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
/**
 * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
/**
 * {@link Unenforced} version of {@link InsertableTypedNode}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = [
    Unhydrated<NodeFromSchemaUnsafe<T>> | (T extends {
        implicitlyConstructable: true;
    } ? NodeBuilderDataUnsafe<T> : never)
][_InlineTrick];
/**
 * {@link Unenforced} version of {@link NodeFromSchema}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
/**
 * {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
/**
 * {@link Unenforced} version of {@link (TreeArrayNode:interface)}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @sealed @public
 */
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
}
/**
 * {@link Unenforced} version of {@link TreeMapNode}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @sealed @public
 */
export interface TreeMapNodeUnsafe<T extends Unenforced<ImplicitAllowedTypes>> extends ReadonlyMap<string, TreeNodeFromImplicitAllowedTypesUnsafe<T>>, TreeNode {
    /**
     * {@inheritdoc TreeMapNode.set}
     */
    set(key: string, value: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T> | undefined): void;
    /**
     * {@inheritdoc TreeMapNode.delete}
     */
    delete(key: string): void;
}
/**
 * {@link Unenforced} version of `FieldHasDefault`.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @sealed @public
 */
export type FieldHasDefaultUnsafe<T extends Unenforced<ImplicitFieldSchema>> = T extends FieldSchemaUnsafe<FieldKind.Optional | FieldKind.Identifier, Unenforced<ImplicitAllowedTypes>> ? true : false;
/**
 * {@link Unenforced} version of `InsertableObjectFromSchemaRecord`.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>> = {
    readonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property]> extends false ? Property : never]: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property]>;
} & {
    readonly [Property in keyof T as FieldHasDefaultUnsafe<T[Property]> extends true ? Property : never]?: InsertableTreeFieldFromImplicitFieldUnsafe<T[Property]>;
};
/**
 * {@link Unenforced} version of {@link InsertableTreeFieldFromImplicitField}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
/**
 * {@link Unenforced} version of {@link FieldSchema}.
 * @remarks
 * Do note use this type directly: its only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
 * @public
 */
export interface FieldSchemaUnsafe<out Kind extends FieldKind, out Types extends Unenforced<ImplicitAllowedTypes>> extends FieldSchema<Kind, any> {
    /**
     * {@inheritDoc FieldSchema.kind}
     */
    readonly kind: Kind;
    /**
     * {@inheritDoc FieldSchema.allowedTypes}
     */
    readonly allowedTypes: Types;
    /**
     * {@inheritDoc FieldSchema.allowedTypeSet}
     */
    readonly allowedTypeSet: ReadonlySet<TreeNodeSchema>;
}
//# sourceMappingURL=typesUnsafe.d.ts.map