/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { AllowedUpdateType, ITreeCursorSynchronous } from "../core/index.js";
import { FlexTreeSchema, FlexFieldSchema, ViewSchema, InsertableFlexField } from "../feature-libraries/index.js";
import { ITreeCheckout } from "./treeCheckout.js";
/**
 * Modify `storedSchema` and invoke `setInitialTree` when it's time to set the tree content.
 *
 * Requires `storedSchema` to be in its default/empty state.
 *
 * This is done in such a way that if the content (implicitly assumed to start empty)
 * is never out of schema.
 * This means that if the root field of the new schema requires content (like a value field),
 * a temporary intermediate schema is used so the initial empty state is not out of schema.
 *
 * Since this makes multiple changes, callers may want to wrap it in a transaction.
 */
export declare function initializeContent(schemaRepository: {
    storedSchema: ITreeCheckout["storedSchema"];
    updateSchema: ITreeCheckout["updateSchema"];
}, newSchema: FlexTreeSchema, setInitialTree: () => void): void;
export declare enum UpdateType {
    /**
     * Already compatible, no update needed.
     */
    None = 0,
    /**
     * Empty: needs initializing.
     */
    Initialize = 1,
    /**
     * Schema can be upgraded leaving tree as is.
     */
    SchemaCompatible = 2,
    /**
     * No update currently supported.
     */
    Incompatible = 3
}
export declare function evaluateUpdate(viewSchema: ViewSchema, allowedSchemaModifications: AllowedUpdateType, checkout: ITreeCheckout): UpdateType;
export declare function canInitialize(checkout: ITreeCheckout): boolean;
/**
 * Ensure a {@link ITreeCheckout} can be used with a given {@link ViewSchema}.
 *
 * @remarks
 * It is up to the caller to ensure that compatibility is reevaluated if the checkout's stored schema is edited in the future.
 *
 * @param viewSchema - View schema that `checkout` should be made compatible with.
 * @param allowedSchemaModifications - Flags enum describing the ways this is allowed to modify `checkout`.
 * @param checkout - To be modified as needed to be compatible with `viewSchema`.
 * @param treeContent - Content to be used to initialize `checkout`'s the tree if needed and allowed.
 * @returns true iff checkout now is compatible with `viewSchema`.
 */
export declare function ensureSchema(viewSchema: ViewSchema, allowedSchemaModifications: AllowedUpdateType, checkout: ITreeCheckout, treeContent: TreeContent | undefined): boolean;
/**
 * View Schema for a `SharedTree`.
 *
 * @internal
 */
export interface SchemaConfiguration<TRoot extends FlexFieldSchema = FlexFieldSchema> {
    /**
     * The schema which the application wants to view the tree with.
     */
    readonly schema: FlexTreeSchema<TRoot>;
}
/**
 * Content that can populate a `SharedTree`.
 *
 * @internal
 */
export interface TreeContent<TRoot extends FlexFieldSchema = FlexFieldSchema> extends SchemaConfiguration<TRoot> {
    /**
     * Default tree content to initialize the tree with iff the tree is uninitialized
     * (meaning it does not even have any schema set at all).
     */
    readonly initialTree: InsertableFlexField<TRoot> | readonly ITreeCursorSynchronous[] | ITreeCursorSynchronous;
}
/**
 * Options used to schematize a `SharedTree`.
 *
 * @internal
 */
export interface SchematizeConfiguration<TRoot extends FlexFieldSchema = FlexFieldSchema> extends SchemaConfiguration<TRoot> {
    /**
     * Controls if and how schema from existing documents can be updated to accommodate the view schema.
     */
    readonly allowedSchemaModifications: AllowedUpdateType;
}
/**
 * Options used to initialize (if needed) and schematize a `SharedTree`.
 *
 * @internal
 */
export interface InitializeAndSchematizeConfiguration<TRoot extends FlexFieldSchema = FlexFieldSchema> extends TreeContent<TRoot>, SchematizeConfiguration<TRoot> {
}
/**
 * Options used to initialize (if needed) and schematize a `SharedTree`.
 * @remarks
 * Using this builder improves type safety and error quality over just constructing the configuration as a object.
 * @internal
 */
export declare function buildTreeConfiguration<T extends FlexFieldSchema>(config: InitializeAndSchematizeConfiguration<T>): InitializeAndSchematizeConfiguration<T>;
//# sourceMappingURL=schematizeTree.d.ts.map