/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { IChannelAttributes, IChannelFactory, IChannelServices, IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { ISharedObject } from "@fluidframework/shared-object-base";
import { ICodecOptions } from "../codec/index.js";
import { JsonableTree, TreeStoredSchema, TreeStoredSchemaRepository } from "../core/index.js";
import { FlexFieldSchema, TreeCompressionStrategy } from "../feature-libraries/index.js";
import { SharedTreeCore } from "../shared-tree-core/index.js";
import { ITree, ImplicitFieldSchema, TreeConfiguration, TreeView } from "../simple-tree/index.js";
import { InitializeAndSchematizeConfiguration } from "./schematizeTree.js";
import { SharedTreeChange } from "./sharedTreeChangeTypes.js";
import { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
import { TreeCheckout } from "./treeCheckout.js";
import { CheckoutFlexTreeView, FlexTreeView } from "./treeView.js";
/**
 * Copy of data from an {@link ISharedTree} at some point in time.
 * @remarks
 * This is unrelated to Fluids concept of "snapshots".
 * @internal
 */
export interface SharedTreeContentSnapshot {
    /**
     * The schema stored in the document.
     *
     * @remarks
     * Edits to the schema can mutate the schema stored of the tree which took this snapshot (but this snapshot will remain the same)
     * This is mainly useful for debugging cases where schematize reports an incompatible view schema.
     */
    readonly schema: TreeStoredSchema;
    /**
     * All {@link TreeStatus#InDocument} content.
     */
    readonly tree: JsonableTree[];
    /**
     * All {@link TreeStatus#Removed} content.
     */
    readonly removed: [string | number | undefined, number, JsonableTree][];
}
/**
 * Collaboratively editable tree distributed data-structure,
 * powered by {@link @fluidframework/shared-object-base#ISharedObject}.
 *
 * See [the README](../../README.md) for details.
 * @internal
 */
export interface ISharedTree extends ISharedObject, ITree {
    /**
     * Provides a copy of the current content of the tree.
     * This can be useful for inspecting the tree when no suitable view schema is available.
     * This is only intended for use in testing and exceptional code paths: it is not performant.
     *
     * This does not include everything that is included in a tree summary, since information about how to merge future edits is omitted.
     */
    contentSnapshot(): SharedTreeContentSnapshot;
    /**
     * Like {@link ITree.schematize}, but uses the flex-tree schema system and exposes the tree as a flex-tree.
     *
     * Returned view is disposed when the stored schema becomes incompatible with the view schema.
     * Undefined is returned if the stored data could not be made compatible with the view schema.
     */
    schematizeFlexTree<TRoot extends FlexFieldSchema>(config: InitializeAndSchematizeConfiguration<TRoot>, onDispose: () => void): FlexTreeView<TRoot> | undefined;
}
/**
 * Shared tree, configured with a good set of indexes and field kinds which will maintain compatibility over time.
 *
 * TODO: detail compatibility requirements.
 */
export declare class SharedTree extends SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange> implements ISharedTree {
    private readonly _events;
    readonly checkout: TreeCheckout;
    get storedSchema(): TreeStoredSchemaRepository;
    constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, optionsParam: SharedTreeOptions, telemetryContextPrefix: string);
    contentSnapshot(): SharedTreeContentSnapshot;
    schematizeFlexTree<TRoot extends FlexFieldSchema>(config: InitializeAndSchematizeConfiguration<TRoot>, onDispose: () => void): CheckoutFlexTreeView<TRoot> | undefined;
    schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
    protected loadCore(services: IChannelStorageService): Promise<void>;
}
/**
 * Format versions supported by SharedTree.
 *
 * Each version documents a required minimum version of the \@fluidframework/tree package.
 * @internal
 */
export declare const SharedTreeFormatVersion: {
    /**
     * Requires \@fluidframework/tree \>= 2.0.0.
     *
     * @deprecated - FF does not currently plan on supporting this format long-term.
     * Do not write production documents using this format, as they may not be loadable in the future.
     */
    readonly v1: 1;
    /**
     * Requires \@fluidframework/tree \>= 2.0.0.
     */
    readonly v2: 2;
};
/**
 * Format versions supported by SharedTree.
 *
 * Each version documents a required minimum version of the \@fluidframework/tree package.
 * @internal
 * @privateRemarks
 * See packages/dds/tree/docs/main/compatibility.md for information on how to add support for a new format.
 */
export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
/**
 * @internal
 */
export type SharedTreeOptions = Partial<ICodecOptions> & Partial<SharedTreeFormatOptions> & {
    /**
     * The {@link ForestType} indicating which forest type should be created for the SharedTree.
     */
    forest?: ForestType;
};
/**
 * Options for configuring the persisted format SharedTree uses.
 * @internal
 */
export interface SharedTreeFormatOptions {
    /**
     * See {@link TreeCompressionStrategy}.
     * default: TreeCompressionStrategy.Compressed
     */
    treeEncodeType: TreeCompressionStrategy;
    /**
     * The format version SharedTree should use to persist documents.
     *
     * This option has compatibility implications for applications using SharedTree.
     * Each version documents a required minimum version of \@fluidframework/tree.
     * If this minimum version fails to be met, the SharedTree may fail to load.
     * To be safe, application authors should verify that they have saturated this version
     * of \@fluidframework/tree in their ecosystem before changing the format version.
     *
     * This option defaults to SharedTreeFormatVersion.v2.
     */
    formatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];
}
/**
 * Used to distinguish between different forest types.
 * @internal
 */
export declare enum ForestType {
    /**
     * The "ObjectForest" forest type.
     */
    Reference = 0,
    /**
     * The "ChunkedForest" forest type.
     */
    Optimized = 1
}
export declare const defaultSharedTreeOptions: Required<SharedTreeOptions>;
/**
 * A channel factory that creates {@link ISharedTree}s.
 * @internal
 */
export declare class SharedTreeFactory implements IChannelFactory<ISharedTree> {
    private readonly options;
    readonly type: string;
    readonly attributes: IChannelAttributes;
    constructor(options?: SharedTreeOptions);
    load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<ISharedTree>;
    create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree;
}
//# sourceMappingURL=sharedTree.d.ts.map