/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ForestEvents, TreeFieldStoredSchema, FieldKey, IForestSubscription } from "../../core";
import { ISubscribable } from "../../events";
import { IDefaultEditBuilder } from "../default-schema";
import { NodeKeyManager } from "../node-key";
import { FieldGenerator } from "../fieldGenerator";
import { TreeSchema } from "../typed-schema";
import { disposeSymbol, IDisposable } from "../../util";
import { FlexTreeField } from "./flexTreeTypes";
import { LazyEntity } from "./lazyEntity";
import { NodeKeys } from "./nodeKeys";
/**
 * A common context of a "forest" of EditableTrees.
 * It handles group operations like transforming cursors into anchors for edits.
 * @alpha
 */
export interface FlexTreeContext extends ISubscribable<ForestEvents> {
    /**
     * Gets the root field of the tree.
     */
    get root(): FlexTreeField;
    /**
     * Schema used within this context.
     * All data must conform to these schema.
     */
    readonly schema: TreeSchema;
    readonly nodeKeys: NodeKeys;
}
/**
 * Implementation of `EditableTreeContext`.
 *
 * @remarks An editor is required to edit the EditableTrees.
 */
export declare class Context implements FlexTreeContext, IDisposable {
    readonly schema: TreeSchema;
    readonly forest: IForestSubscription;
    readonly editor: IDefaultEditBuilder;
    readonly nodeKeys: NodeKeys;
    readonly nodeKeyFieldKey: FieldKey;
    readonly withCursors: Set<LazyEntity>;
    readonly withAnchors: Set<LazyEntity>;
    private readonly eventUnregister;
    private disposed;
    /**
     * @param forest - the Forest
     * @param editor - an editor that makes changes to the forest.
     * @param nodeKeys - an object which handles node key generation and conversion
     * @param nodeKeyFieldKey - an optional field key under which node keys are stored in this tree.
     * If present, clients may query the {@link LocalNodeKey} of a node directly via the {@link localNodeKeySymbol}.
     */
    constructor(schema: TreeSchema, forest: IForestSubscription, editor: IDefaultEditBuilder, nodeKeys: NodeKeys, nodeKeyFieldKey: FieldKey);
    /**
     * Called before editing.
     * Clears all cursors so editing can proceed.
     */
    private prepareForEdit;
    [disposeSymbol](): void;
    /**
     * Release any cursors and anchors held by tree entities created in this context.
     * Ensures the cashed references to those entities on the Anchors are also cleared.
     * The tree entities are invalid to use after this, but the context may still be used
     * to create new trees starting from the root.
     */
    clear(): void;
    get root(): FlexTreeField;
    on<K extends keyof ForestEvents>(eventName: K, listener: ForestEvents[K]): () => void;
    /**
     * FieldSource used to get a FieldGenerator to populate required fields during procedural contextual data generation.
     */
    fieldSource?(key: FieldKey, schema: TreeFieldStoredSchema): undefined | FieldGenerator;
}
/**
 * A simple API for a Forest to interact with the tree.
 *
 * @param forest - the Forest
 * @param editor - an editor that makes changes to the forest.
 * @param nodeKeyManager - an object which handles node key generation and conversion.
 * @param nodeKeyFieldKey - an optional field key under which node keys are stored in this tree.
 * If present, clients may query the {@link LocalNodeKey} of a node directly via the {@link localNodeKeySymbol}.
 * @returns {@link EditableTreeContext} which is used to manage the cursors and anchors within the EditableTrees:
 * This is necessary for supporting using this tree across edits to the forest, and not leaking memory.
 */
export declare function getTreeContext(schema: TreeSchema, forest: IForestSubscription, editor: IDefaultEditBuilder, nodeKeyManager: NodeKeyManager, nodeKeyFieldKey: FieldKey): Context;
//# sourceMappingURL=context.d.ts.map