/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { HasListeners, IEmitter, Listenable } from "@fluidframework/core-interfaces/internal";
import { type NodeKeyManager, type FullSchemaPolicy } from "../feature-libraries/index.js";
import { type ImplicitFieldSchema, type SchemaCompatibilityStatus, type TreeView, type TreeViewEvents, ViewSchema, type TreeViewConfiguration, type TreeViewAlpha, type InsertableField, type ReadableField, type ReadSchema, type UnsafeUnknownSchema, type TreeBranch, type TreeBranchEvents } from "../simple-tree/index.js";
import { Breakable, type WithBreakable } from "../util/index.js";
import type { ITreeCheckout, TreeCheckout } from "./treeCheckout.js";
import { CheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
import type { VoidTransactionCallbackStatus, TransactionCallbackStatus, TransactionResult, TransactionResultExt, RunTransactionParams } from "./transactionTypes.js";
/**
 * Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already
 * exists and error if creating a second.
 */
export declare const ViewSlot: import("../core/index.js").AnchorSlot<TreeView<ImplicitFieldSchema>>;
/**
 * Implementation of TreeView wrapping a FlexTreeView.
 */
export declare class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> implements TreeBranch, TreeViewAlpha<TRootSchema>, WithBreakable {
    readonly checkout: TreeCheckout;
    readonly config: TreeViewConfiguration<ReadSchema<TRootSchema>>;
    readonly nodeKeyManager: NodeKeyManager;
    readonly breaker: Breakable;
    private readonly onDispose?;
    /**
     * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.
     *
     * The view schema may be incompatible with the stored schema. Use `compatibility` to check.
     */
    private view;
    /**
     * Undefined iff uninitialized or disposed.
     */
    private currentCompatibility;
    private readonly schemaPolicy;
    readonly events: Listenable<TreeViewEvents & TreeBranchEvents> & IEmitter<TreeViewEvents & TreeBranchEvents> & HasListeners<TreeViewEvents & TreeBranchEvents>;
    private readonly viewSchema;
    private readonly unregisterCallbacks;
    disposed: boolean;
    /**
     * This is set to true while an edit impacting the document schema is in progress.
     * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.
     * This is useful especially for some initialization edits, since document initialization can involve transient schemas
     * which are implementation details and should not be exposed to the user.
     */
    private midUpgrade;
    private readonly rootFieldSchema;
    constructor(checkout: TreeCheckout, config: TreeViewConfiguration<ReadSchema<TRootSchema>>, nodeKeyManager: NodeKeyManager, breaker?: Breakable, onDispose?: (() => void) | undefined);
    hasRootSchema<TSchema extends ImplicitFieldSchema>(schema: TSchema): this is TreeViewAlpha<TSchema>;
    get schema(): ReadSchema<TRootSchema>;
    initialize(content: InsertableField<TRootSchema>): void;
    upgradeSchema(): void;
    /**
     * Gets the view. Throws when disposed.
     */
    getView(): CheckoutFlexTreeView;
    /**
     * {@inheritDoc @fluidframework/shared-tree#TreeViewAlpha.runTransaction}
     */
    runTransaction<TSuccessValue, TFailureValue>(transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>, params?: RunTransactionParams): TransactionResultExt<TSuccessValue, TFailureValue>;
    /**
     * {@inheritDoc @fluidframework/shared-tree#TreeViewAlpha.runTransaction}
     */
    runTransaction(transaction: () => VoidTransactionCallbackStatus | void, params?: RunTransactionParams): TransactionResult;
    private ensureUndisposed;
    private failDisposed;
    /**
     * Updates `this.view` and the current compatibility status.
     * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.
     * Handles re-registering for events to call update in the future.
     * @remarks
     * This does not check if the view needs to be replaced, it replaces it unconditionally:
     * callers should do any checking to detect if it's really needed before calling `update`.
     * @privateRemarks
     * This implementation avoids making any edits, which prevents it from being invoked reentrantly.
     * If implicit initialization (or some other edit) is desired, it should be done outside of this method.
     */
    private update;
    private runSchemaEdit;
    private disposeView;
    get compatibility(): SchemaCompatibilityStatus;
    dispose(): void;
    get root(): ReadableField<TRootSchema>;
    set root(newRoot: InsertableField<TRootSchema>);
    fork(): ReturnType<TreeBranch["fork"]> & SchematizingSimpleTreeView<TRootSchema>;
    merge(context: TreeBranch, disposeMerged?: boolean): void;
    rebaseOnto(context: TreeBranch): void;
}
/**
 * Get the {@link TreeCheckout} associated with a given {@link TreeBranch}.
 * @remarks Currently, all contexts are also {@link SchematizingSimpleTreeView}s.
 * Other checkout implementations (e.g. not associated with a view) may be supported in the future.
 */
export declare function getCheckout(context: TreeBranch): TreeCheckout;
/**
 * Creates a view that self-disposes whenenever the stored schema changes.
 * This may only be called when the schema is already known to be compatible (typically via ensureSchema).
 */
export declare function requireSchema(checkout: ITreeCheckout, viewSchema: ViewSchema, onDispose: () => void, nodeKeyManager: NodeKeyManager, schemaPolicy: FullSchemaPolicy): CheckoutFlexTreeView;
//# sourceMappingURL=schematizingTreeView.d.ts.map