/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { ChangeAtomId, ChangeAtomIdRangeMap, ChangesetLocalId, RevisionTag } from "../../core/index.js";
import type { RangeQueryResult } from "../../util/index.js";
import type { NodeId } from "./modularChangeTypes.js";
export type CrossFieldMap<T> = ChangeAtomIdRangeMap<T>;
export type CrossFieldQuerySet = CrossFieldMap<boolean>;
export declare function setInCrossFieldMap<T>(map: CrossFieldMap<T>, id: ChangeAtomId, count: number, value: T): void;
export declare function getFirstFromCrossFieldMap<T>(map: CrossFieldMap<T>, revision: RevisionTag | undefined, id: ChangesetLocalId, count: number): RangeQueryResult<T | undefined>;
export declare enum CrossFieldTarget {
    Source = 0,
    Destination = 1
}
export interface InvertNodeManager {
    /**
     * Transfers the given node changes from the input context of the field changeset being inverted to the input context of the detached space (from which it may be further moved).
     *
     * This must be called for each detach in the field kind when rolling-back or undoing an detach.
     * This implies that all detaches in the field must be inverted.
     * @param detachId - The ID of the detach to invert.
     * @param count - The number of nodes being detached.
     * @param nodeChanges - The node changes to transfer.
     * @param newAttachId - The ID that the nodes will be attached with in the inverted changeset of this field.
     */
    invertDetach(detachId: ChangeAtomId, count: number, nodeChanges: NodeId | undefined, newAttachId: ChangeAtomId): void;
    /**
     * Gets the node changes associated with the node being attached in input changeset.
     *
     * This must be called for each attach in the field kind when rolling-back or undoing an attach.
     * This implies that all attaches in the field must be inverted.
     * @param attachId - The ID of the attach to invert.
     * @param count - The number of nodes being attached.
     */
    invertAttach(attachId: ChangeAtomId, count: number): RangeQueryResult<DetachedNodeEntry | undefined>;
}
export interface ComposeNodeManager {
    /**
     * Allows a field kind to query nested changes associated with a node in the input context of the new changeset.
     * This should be called for every detach in the base changeset.
     * @param baseDetachId - The ID of the detach in the base changeset.
     * @param count - The number of nodes being detached.
     */
    getNewChangesForBaseDetach(baseDetachId: ChangeAtomId, count: number): RangeQueryResult<DetachedNodeEntry | undefined>;
    /**
     * Must be called by a field kind when composing an attach in the base changeset with a detach in the new changeset.
     * This allows Modular Change Family to keep track of how a given node is being renamed.
     * @param baseAttachId - The ID of the attach in the base changeset.
     * @param newDetachId - The ID of the detach in the new changeset.
     * @param count - The number of nodes being attached then detached.
     */
    composeAttachDetach(baseAttachId: ChangeAtomId, newDetachId: ChangeAtomId, count: number): void;
    /**
     * Must be called by a field kind when composing an attach in the base changeset with nested changes the new changeset.
     *
     * This is needed because child changes are represented at the location of the node they impact in the input context of a changeset.
     * So if the later of the two changes being composed carries nested changes for a node,
     * then in the composed changeset, these nested changes must to be represented at the location of that node in the input context of the composed changeset.
     *
     * @param baseAttachId - The ID of the attach in the base changeset.
     * @param newChanges - The ID of the nested changes associated with this node in the new changeset.
     */
    sendNewChangesToBaseSourceLocation(baseAttachId: ChangeAtomId, newChanges: NodeId): void;
    /**
     * Must be called by a field kind when composing a detach in the base changeset with an attach of the same nodes in the new changeset.
     * @param baseDetachId - The ID of the detach in the base changeset.
     * @param newAttachId - The ID of the attach in the new changeset.
     * @param count - The number of nodes being detached then attached.
     * @param convertToPin - Should be set to true if the composed change will include a detach and attach with `newAttachId`.
     * Otherwise the composed change should not include either `baseDetachId` or `newAttachId`.
     */
    composeDetachAttach(baseDetachId: ChangeAtomId, newAttachId: ChangeAtomId, count: number, convertToPin: boolean): void;
}
export interface RebaseNodeManager {
    /**
     * Must be called by a field kind when rebasing over an attach.
     * The returned child changes and detach intentions must be represented in the output changeset.
     * @param baseAttachId - The ID of the attach that is being rebased over.
     * @param count - The number of nodes attached by the base attach.
     * @returns The new nested changes and detach intentions associated with the node in the changeset being rebased.
     */
    getNewChangesForBaseAttach(baseAttachId: ChangeAtomId, count: number): RangeQueryResult<RebaseDetachedNodeEntry | undefined>;
    /**
     * Must be called by a field kind when rebasing over a detach.
     * The field kind must provide the nested changes and detach intentions associated with the node in the changeset being rebased.
     * @param baseDetachId - The ID of the detach that is being rebased over.
     * @param count - The number of nodes detached by the base detach.
     * @param newDetachId - The ID associated the detach intention (if any) for these nodes in the rebased changeset.
     * @param nodeChange - The nested changes (if any) associated with this node in the rebased changeset.
     * @param newDetachCellId - An additional ID to associate with this node.
     * This ID will be included in the result of {@link getNewChangesForBaseAttach}.
     * This is only used by sequence field for compatibility with earlier client versions.
     */
    rebaseOverDetach(baseDetachId: ChangeAtomId, count: number, newDetachId: ChangeAtomId | undefined, nodeChange: NodeId | undefined, newDetachCellId?: ChangeAtomId): void;
    addDetach(id: ChangeAtomId, count: number): void;
    removeDetach(id: ChangeAtomId, count: number): void;
    /**
     * Returns whether nodes which were either previously detached by `id` or the base changeset is now detaching with `id`
     * are also reattached by the base changeset.
     */
    doesBaseAttachNodes(id: ChangeAtomId, count: number): RangeQueryResult<boolean>;
    /**
     * Returns the root ID the base change renames `id` to, if any.
     */
    getBaseRename(id: ChangeAtomId, count: number): RangeQueryResult<ChangeAtomId | undefined>;
    /**
     * Given a detached node ID in the base changeset's output context,
     * returns the ID the rebased changeset renames that ID to, if any.
     */
    getNewRenameForBaseRename(baseRenameTo: ChangeAtomId, count: number): RangeQueryResult<ChangeAtomId | undefined>;
}
export interface DetachedNodeEntry {
    nodeChange?: NodeId;
    detachId?: ChangeAtomId;
}
export interface RebaseDetachedNodeEntry extends DetachedNodeEntry {
    cellRename?: ChangeAtomId;
}
//# sourceMappingURL=crossFieldQueries.d.ts.map