/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ICodecFamily, ICodecOptions } from "../../codec/index.js";
import { ChangeFamily, ChangeRebaser, UpPath, ChangeFamilyEditor, FieldUpPath, TaggedChange, DeltaRoot, DeltaDetachedNodeId, ChangeEncodingContext, RevisionTagCodec, ITreeCursorSynchronous } from "../../core/index.js";
import { ModularChangeset } from "../modular-schema/index.js";
import { FieldBatchCodec } from "../chunked-forest/index.js";
import { TreeCompressionStrategy } from "../treeCompressionUtils.js";
export type DefaultChangeset = ModularChangeset;
/**
 * Implementation of {@link ChangeFamily} based on the default set of supported field kinds.
 *
 * @sealed
 */
export declare class DefaultChangeFamily implements ChangeFamily<DefaultEditBuilder, DefaultChangeset> {
    private readonly modularFamily;
    constructor(revisionTagCodec: RevisionTagCodec, fieldBatchCodec: FieldBatchCodec, codecOptions: ICodecOptions, chunkCompressionStrategy?: TreeCompressionStrategy);
    get rebaser(): ChangeRebaser<DefaultChangeset>;
    get codecs(): ICodecFamily<DefaultChangeset, ChangeEncodingContext>;
    buildEditor(changeReceiver: (change: DefaultChangeset) => void): DefaultEditBuilder;
}
/**
 * @param change - The change to convert into a delta.
 */
export declare function intoDelta(taggedChange: TaggedChange<ModularChangeset>): DeltaRoot;
/**
 * Returns the set of removed roots that should be in memory for the given change to be applied.
 * A removed root is relevant if any of the following is true:
 * - It is being inserted
 * - It is being restored
 * - It is being edited
 * - The ID it is associated with is being changed
 *
 * May be conservative by returning more removed roots than strictly necessary.
 *
 * Will never return IDs for non-root trees, even if they are removed.
 *
 * @param change - The change to be applied.
 */
export declare function relevantRemovedRoots(taggedChange: TaggedChange<ModularChangeset>): Iterable<DeltaDetachedNodeId>;
/**
 * Default editor for transactional tree data changes.
 * @privateRemarks
 * When taking into account not just the content of the tree,
 * but also how the merge identities (and thus anchors, flex-tree and simple-tree nodes) of nodes before and after the edits correspond,
 * some edits are currently impossible to express.
 * Examples of these non-expressible edits include:
 *
 * - Changing the type of a node while keeping its merge identity.
 * - Changing the value of a leaf while keeping its merge identity.
 * - Swapping subtrees between two value fields.
 * - Replacing a node in the middle of a tree while reusing some of the old nodes decedents that were under value fields.
 *
 * At some point it will likely be worth supporting at least some of these, possibly using a mechanism that could support all of them if desired.
 * If/when such a mechanism becomes available, an evaluation should be done to determine if any existing editing operations should be changed to leverage it
 * (Possibly by adding opt ins at the view schema layer).
 *
 * @internal
 */
export interface IDefaultEditBuilder {
    /**
     * @param field - the value field which is being edited under the parent node
     * @returns An object with methods to edit the given field of the given parent.
     * The returned object can be used (i.e., have its methods called) multiple times but its lifetime
     * is bounded by the lifetime of this edit builder.
     */
    valueField(field: FieldUpPath): ValueFieldEditBuilder;
    /**
     * @param field - the optional field which is being edited under the parent node
     * @returns An object with methods to edit the given field of the given parent.
     * The returned object can be used (i.e., have its methods called) multiple times but its lifetime
     * is bounded by the lifetime of this edit builder.
     */
    optionalField(field: FieldUpPath): OptionalFieldEditBuilder;
    /**
     * @param field - the sequence field which is being edited under the parent node
     *
     * @returns An object with methods to edit the given field of the given parent.
     * The returned object can be used (i.e., have its methods called) multiple times but its lifetime
     * is bounded by the lifetime of this edit builder.
     */
    sequenceField(field: FieldUpPath): SequenceFieldEditBuilder;
    /**
     * Moves a subsequence from one sequence field to another sequence field.
     *
     * Note that the `destinationIndex` is interpreted based on the state of the sequence *before* the move operation.
     * For example, `move(field, 0, 1, field, 2)` changes `[A, B, C]` to `[B, A, C]`.
     */
    move(sourceField: FieldUpPath, sourceIndex: number, count: number, destinationField: FieldUpPath, destinationIndex: number): void;
    addNodeExistsConstraint(path: UpPath): void;
}
/**
 * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.
 * @sealed
 */
export declare class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuilder {
    private readonly modularBuilder;
    constructor(family: ChangeFamily<ChangeFamilyEditor, DefaultChangeset>, changeReceiver: (change: DefaultChangeset) => void);
    enterTransaction(): void;
    exitTransaction(): void;
    addNodeExistsConstraint(path: UpPath): void;
    valueField(field: FieldUpPath): ValueFieldEditBuilder;
    optionalField(field: FieldUpPath): OptionalFieldEditBuilder;
    move(sourceField: FieldUpPath, sourceIndex: number, count: number, destinationField: FieldUpPath, destIndex: number): void;
    sequenceField(field: FieldUpPath): SequenceFieldEditBuilder;
}
/**
 * @internal
 */
export interface ValueFieldEditBuilder {
    /**
     * Issues a change which replaces the current newContent of the field with `newContent`.
     * @param newContent - the new content for the field.
     * The cursor can be in either Field or Node mode and must represent exactly one node.
     */
    set(newContent: ITreeCursorSynchronous): void;
}
/**
 * @internal
 */
export interface OptionalFieldEditBuilder {
    /**
     * Issues a change which replaces the current newContent of the field with `newContent`
     * @param newContent - the new content for the field.
     * If provided, the cursor can be in either Field or Node mode and must represent exactly one node.
     * @param wasEmpty - whether the field is empty when creating this change
     */
    set(newContent: ITreeCursorSynchronous | undefined, wasEmpty: boolean): void;
}
/**
 * @internal
 */
export interface SequenceFieldEditBuilder {
    /**
     * Issues a change which inserts the `newContent` at the given `index`.
     * @param index - the index at which to insert the `newContent`.
     * @param newContent - the new content to be inserted in the field. Cursor can be in either Field or Node mode.
     */
    insert(index: number, newContent: ITreeCursorSynchronous): void;
    /**
     * Issues a change which removes `count` elements starting at the given `index`.
     * @param index - The index of the first removed element.
     * @param count - The number of elements to remove.
     */
    remove(index: number, count: number): void;
    /**
     * Issues a change which moves `count` elements starting at `sourceIndex` to `destIndex`.
     * @param sourceIndex - the index of the first moved element.
     * @param count - the number of elements to move.
     * @param destIndex - the index the elements are moved to, interpreted before detaching the moved elements.
     */
    move(sourceIndex: number, count: number, destIndex: number): void;
}
//# sourceMappingURL=defaultEditBuilder.d.ts.map