/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { FieldKey, TreeNodeSchemaIdentifier, CursorLocationType, FieldUpPath, UpPath, TreeValue, Value, TreeType, PathRootPrefix } from "../../core";
import { ReferenceCountedBase } from "../../util";
import { SynchronousCursor } from "../treeCursorUtils";
import { ChunkedCursor, cursorChunk, TreeChunk } from "./chunk";
/**
 * General purpose one node chunk.
 */
export declare class BasicChunk extends ReferenceCountedBase implements TreeChunk {
    type: TreeNodeSchemaIdentifier;
    fields: Map<FieldKey, TreeChunk[]>;
    value?: TreeValue | undefined;
    readonly topLevelLength: number;
    /**
     * Create a tree chunk with ref count 1.
     *
     * @param fields - provides exclusive deep ownership of this map to this object (which might mutate it in the future).
     * The caller must have already accounted for this reference to the children in this map (via `referenceAdded`),
     * and any edits to this must update child reference counts.
     * @param value - the value on this node, if any.
     */
    constructor(type: TreeNodeSchemaIdentifier, fields: Map<FieldKey, TreeChunk[]>, value?: TreeValue | undefined);
    clone(): BasicChunk;
    cursor(): ChunkedCursor;
    protected dispose(): void;
}
export type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];
/**
 * Cursor over basic chunks.
 *
 * @remarks This implementation is similar to StackCursor, however it is distinct because:
 * 1. The children are chunks, which might have a top level length that greater than 1.
 * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).
 *
 * TODO:
 * This cursor currently only handles child chunks which are BasicChunks:
 * BasicChunks should be an optimized fast path, and arbitrary chunk formats,
 * like UniformChunk, should be supported by delegating to their cursor implementations.
 */
export declare class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {
    protected root: readonly TreeChunk[];
    protected readonly siblingStack: SiblingsOrKey[];
    protected readonly indexStack: number[];
    protected readonly indexOfChunkStack: number[];
    protected readonly indexWithinChunkStack: number[];
    protected siblings: SiblingsOrKey;
    protected index: number;
    protected indexOfChunk: number;
    protected indexWithinChunk: number;
    protected nestedCursor: ChunkedCursor | undefined;
    /**
     * Starts at root field which might be a detached sequence.
     *
     * @param root - sequence of BasicChunk which make up the contents of the root sequence.
     * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,
     * this is needed to get the actual root nodes when entering nodes of the root field.
     * @param siblingStack - Stack of collections of siblings along the path through the tree:
     * does not include current level (which is stored in `siblings`).
     * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.
     * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.
     * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.
     * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.
     * @param siblings - Siblings at the current level (not included in `siblingStack`).
     * @param index - Index into `siblings`.
     * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.
     * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.
     * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)
     * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)
     * it creates the `nestedCursor` over that chunk, and delegates all operations to it.
     */
    constructor(root: readonly TreeChunk[], siblingStack: SiblingsOrKey[], indexStack: number[], indexOfChunkStack: number[], indexWithinChunkStack: number[], siblings: SiblingsOrKey, index: number, indexOfChunk: number, indexWithinChunk: number, nestedCursor: ChunkedCursor | undefined);
    get [cursorChunk](): TreeChunk | undefined;
    atChunkRoot(): boolean;
    fork(): BasicChunkCursor;
    get mode(): CursorLocationType;
    getFieldKey(): FieldKey;
    private getStackedFieldKey;
    private getStackedNodeIndex;
    private getStackedNode;
    getFieldLength(): number;
    enterNode(index: number): void;
    getPath(prefix?: PathRootPrefix): UpPath;
    private nestedPathPrefix;
    getFieldPath(prefix?: PathRootPrefix): FieldUpPath;
    private getOffsetPath;
    enterField(key: FieldKey): void;
    nextField(): boolean;
    firstField(): boolean;
    seekNodes(offset: number): boolean;
    firstNode(): boolean;
    nextNode(): boolean;
    private initNestedCursor;
    exitField(): void;
    exitNode(): void;
    private getNode;
    private getField;
    get value(): Value;
    get type(): TreeType;
    get fieldIndex(): number;
    /**
     * Within the field that `nestedCursor` is nested in:
     * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.
     */
    private nestedOffset;
    get chunkStart(): number;
    get chunkLength(): number;
}
//# sourceMappingURL=basicChunk.d.ts.map