/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { List, ListNode } from "./collections";
import { ISegment } from "./mergeTreeNodes";
import { TrackingGroupCollection } from "./mergeTreeTracking";
import { ICombiningOp, ReferenceType } from "./ops";
import { PropertySet } from "./properties";
import { ReferencePosition } from "./referencePositions";
/**
 * Dictates the preferential direction for a {@link ReferencePosition} to slide
 * in a merge-tree
 */
export declare const SlidingPreference: {
    /**
     * Prefer sliding towards the start of the tree
     */
    readonly BACKWARD: 0;
    /**
     * Prefer sliding towards the end of the tree
     */
    readonly FORWARD: 1;
};
/**
 * Dictates the preferential direction for a {@link ReferencePosition} to slide
 * in a merge-tree
 */
export declare type SlidingPreference = typeof SlidingPreference[keyof typeof SlidingPreference];
/**
 * @sealed
 */
export interface LocalReferencePosition extends ReferencePosition {
    callbacks?: Partial<Record<"beforeSlide" | "afterSlide", (ref: LocalReferencePosition) => void>>;
    readonly trackingCollection: TrackingGroupCollection;
}
/**
 * @privateRemarks This should not be exported outside merge tree.
 * @internal
 */
declare class LocalReference implements LocalReferencePosition {
    refType: ReferenceType;
    readonly slidingPreference: SlidingPreference;
    properties: PropertySet | undefined;
    private segment;
    private offset;
    private listNode;
    callbacks?: Partial<Record<"beforeSlide" | "afterSlide", (ref: LocalReferencePosition) => void>> | undefined;
    private _trackingCollection?;
    get trackingCollection(): TrackingGroupCollection;
    constructor(refType?: ReferenceType, properties?: PropertySet, slidingPreference?: SlidingPreference);
    link(segment: ISegment | undefined, offset: number, listNode: ListNode<LocalReference> | undefined): void;
    isLeaf(): boolean;
    addProperties(newProps: PropertySet, op?: ICombiningOp): void;
    getSegment(): ISegment | undefined;
    getOffset(): number;
    getListNode(): ListNode<LocalReference> | undefined;
    getProperties(): PropertySet | undefined;
}
export declare function createDetachedLocalReferencePosition(refType?: ReferenceType): LocalReferencePosition;
interface IRefsAtOffset {
    before?: List<LocalReference>;
    at?: List<LocalReference>;
    after?: List<LocalReference>;
}
/**
 * @returns true if `func` returns true for any position within the collection
 */
export declare function anyLocalReferencePosition(collection: LocalReferenceCollection, func: (pos: LocalReferencePosition) => boolean): boolean;
/**
 * @returns only the local reference positions for which the `predicate` returns
 * true
 */
export declare function filterLocalReferencePositions(collection: LocalReferenceCollection, predicate: (pos: LocalReferencePosition) => boolean): Generator<LocalReferencePosition>;
/**
 * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.
 */
export declare class LocalReferenceCollection {
    /** Segment this `LocalReferenceCollection` is associated to. */
    private readonly segment;
    static append(seg1: ISegment, seg2: ISegment): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    hierRefCount: number;
    private readonly refsByOffset;
    private refCount;
    /**
     *
     * @internal
     */
    constructor(
    /** Segment this `LocalReferenceCollection` is associated to. */
    segment: ISegment, initialRefsByfOffset?: (IRefsAtOffset | undefined)[]);
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    [Symbol.iterator](): {
        next(): IteratorResult<LocalReferencePosition>;
        [Symbol.iterator](): any;
    };
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    clear(): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    get empty(): boolean;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    createLocalRef(offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference): LocalReferencePosition;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    addLocalRef(lref: LocalReferencePosition, offset: number): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined;
    /**
     *
     * Called by 'append()' implementations to append local refs from the given 'other' segment to the
     * end of 'this' segment.
     *
     * Note: This method should be invoked after the caller has ensured that segments can be merged,
     * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs
     * will be incorrect.
     *
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    append(other: LocalReferenceCollection): void;
    /**
     * Returns true of the local reference is in the collection, otherwise false.
     *
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    has(lref: ReferencePosition): boolean;
    /**
     * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).
     * Local references in the former half of this split will remain associated with the segment used on construction.
     * Local references in the latter half of this split will be transferred to `splitSeg`,
     * and its `localRefs` field will be set.
     * @param offset - Offset into the original segment at which the collection should be split
     * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)
     * before splitting.
     *
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    split(offset: number, splitSeg: ISegment): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    isAfterTombstone(lref: LocalReferencePosition): boolean;
    /**
     * @remarks This method should only be called by mergeTree.
     * @internal
     */
    walkReferences(visitor: (lref: LocalReferencePosition) => boolean | void | undefined, start?: LocalReferencePosition, forward?: boolean): boolean;
}
export {};
//# sourceMappingURL=localReference.d.ts.map