/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { IFluidHandle } from "@fluidframework/core-interfaces";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import { IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
import { ITelemetryLogger } from "@fluidframework/common-definitions";
import { LocalReference } from "./localReference";
import { CollaborationWindow, ISegment, ISegmentAction, Marker, MergeTree, SegmentGroup } from "./mergeTree";
import { MergeTreeDeltaCallback } from "./mergeTreeDeltaCallback";
import { ICombiningOp, IJSONSegment, IMergeTreeAnnotateMsg, IMergeTreeDeltaOp, IMergeTreeGroupMsg, IMergeTreeInsertMsg, IMergeTreeRemoveMsg, IMergeTreeOp, IRelativePosition, ReferenceType } from "./ops";
import { PropertySet } from "./properties";
import { MergeTreeTextHelper } from "./textSegment";
import { ReferencePosition, RangeStackMap } from "./referencePositions";
import { MergeTreeMaintenanceCallback } from "./index";
export declare class Client {
    readonly specToSegment: (spec: IJSONSegment) => ISegment;
    readonly logger: ITelemetryLogger;
    measureOps: boolean;
    accumTime: number;
    localTime: number;
    localOps: number;
    accumWindowTime: number;
    accumWindow: number;
    accumOps: number;
    maxWindowTime: number;
    longClientId: string | undefined;
    get mergeTreeDeltaCallback(): MergeTreeDeltaCallback | undefined;
    set mergeTreeDeltaCallback(callback: MergeTreeDeltaCallback | undefined);
    get mergeTreeMaintenanceCallback(): MergeTreeMaintenanceCallback | undefined;
    set mergeTreeMaintenanceCallback(callback: MergeTreeMaintenanceCallback | undefined);
    protected readonly mergeTree: MergeTree;
    private readonly clientNameToIds;
    private readonly shortClientIdMap;
    private readonly pendingConsensus;
    constructor(specToSegment: (spec: IJSONSegment) => ISegment, logger: ITelemetryLogger, options?: PropertySet);
    /**
     * The merge tree maintains a queue of segment groups for each local operation.
     * These segment groups track segments modified by an operation.
     * This method peeks the tail of that queue, and returns the segments groups there.
     * It is used to get the segment group(s) for the previous operations.
     * @param count - The number segment groups to get peek from the tail of the queue. Default 1.
     */
    peekPendingSegmentGroups(count?: number): SegmentGroup | SegmentGroup[] | undefined;
    /**
     * Annotate a marker and call the callback on consensus.
     * @param marker - The marker to annotate
     * @param props - The properties to annotate the marker with
     * @param consensusCallback - The callback called when consensus is reached
     * @returns The annotate op if valid, otherwise undefined
     */
    annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, consensusCallback: (m: Marker) => void): IMergeTreeAnnotateMsg | undefined;
    /**
     * Annotates the markers with the provided properties
     * @param marker - The marker to annotate
     * @param props - The properties to annotate the marker with
     * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
     * @returns The annotate op if valid, otherwise undefined
     */
    annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): IMergeTreeAnnotateMsg | undefined;
    /**
     * Annotates the range with the provided properties
     * @param start - The inclusive start position of the range to annotate
     * @param end - The exclusive end position of the range to annotate
     * @param props - The properties to annotate the range with
     * @param combiningOp - Specifies how to combine values for the property, such as "incr" for increment.
     * @returns The annotate op if valid, otherwise undefined
     */
    annotateRangeLocal(start: number, end: number, props: PropertySet, combiningOp: ICombiningOp | undefined): IMergeTreeAnnotateMsg | undefined;
    /**
     * Removes the range
     *
     * @param start - The inclusive start of the range to remove
     * @param end - The exclusive end of the range to remove
     */
    removeRangeLocal(start: number, end: number): IMergeTreeRemoveMsg | undefined;
    /**
     * @param pos - The position to insert the segment at
     * @param segment - The segment to insert
     */
    insertSegmentLocal(pos: number, segment: ISegment): IMergeTreeInsertMsg | undefined;
    /**
     * @param refPos - The reference position to insert the segment at
     * @param segment - The segment to insert
     */
    insertAtReferencePositionLocal(refPos: ReferencePosition, segment: ISegment): IMergeTreeInsertMsg | undefined;
    walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start: number | undefined, end: number | undefined, accum: TClientData, splitRange?: boolean): void;
    walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
    /**
     * Serializes the data required for garbage collection. The IFluidHandles stored in all segments that haven't
     * been removed represent routes to other objects. We serialize the data in these segments using the passed in
     * serializer which keeps track of all serialized handles.
     */
    serializeGCData(handle: IFluidHandle, handleCollectingSerializer: IFluidSerializer): void;
    getCollabWindow(): CollaborationWindow;
    /**
     * Returns the current position of a segment, and -1 if the segment
     * does not exist in this merge tree
     * @param segment - The segment to get the position of
     */
    getPosition(segment: ISegment): number;
    /**
     * @deprecated - use createReferencePosition instead
     */
    addLocalReference(lref: LocalReference): void;
    /**
     * @deprecated - use removeReferencePosition instead
     */
    removeLocalReference(lref: LocalReference): ReferencePosition | undefined;
    createLocalReferencePosition(segment: ISegment, offset: number, refType: ReferenceType, properties: PropertySet | undefined): ReferencePosition;
    removeLocalReferencePosition(lref: ReferencePosition): ReferencePosition | undefined;
    localReferencePositionToPosition(lref: ReferencePosition): number;
    /**
     * Given a position specified relative to a marker id, lookup the marker
     * and convert the position to a character position.
     * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
     */
    posFromRelativePos(relativePos: IRelativePosition): number;
    getMarkerFromId(id: string): ISegment | undefined;
    /**
     * Performs the remove based on the provided op
     * @param opArgs - The ops args for the op
     * @returns True if the remove was applied. False if it could not be.
     */
    private applyRemoveRangeOp;
    /**
     * Performs the annotate based on the provided op
     * @param opArgs - The ops args for the op
     * @returns True if the annotate was applied. False if it could not be.
     */
    private applyAnnotateRangeOp;
    /**
     * Performs the insert based on the provided op
     * @param opArgs - The ops args for the op
     * @returns True if the insert was applied. False if it could not be.
     */
    private applyInsertOp;
    /**
     *
     * @param opArgs - The op args of the op to complete
     * @param clientArgs - The client args for the op
     * @param range - The range the op applied to
     * @param clockStart - Optional. The clock start if timing data should be updated.
     */
    private completeAndLogOp;
    /**
     * Returns a valid range for the op, or undefined
     * @param op - The op to generate the range for
     * @param clientArgs - The client args for the op
     */
    private getValidOpRange;
    /**
     * Gets the client args from the op if remote, otherwise uses the local clients info
     * @param sequencedMessage - The sequencedMessage to get the client sequence args for
     */
    private getClientSequenceArgsForMessage;
    /**
     * Gets the client args from the op if remote, otherwise uses the local clients info
     * @param opArgs - The op arg to get the client sequence args for
     */
    private getClientSequenceArgs;
    private ackPendingSegment;
    cloneFromSegments(): Client;
    getOrAddShortClientId(longClientId: string): number;
    getShortClientId(longClientId: string): number;
    getLongClientId(shortClientId: number): string;
    addLongClientId(longClientId: string): void;
    /**
     * During reconnect, we must find the positions to pending segments
     * relative to other pending segments. This methods computes that
     * position relative to a localSeq. Pending segments above the localSeq
     * will be ignored.
     *
     * @param segment - The segment to find the position for
     * @param localSeq - The localSeq to find the position of the segment at
     */
    protected findReconnectionPosition(segment: ISegment, localSeq: number): number;
    private resetPendingDeltaToOps;
    private applyRemoteOp;
    applyStashedOp(op: IMergeTreeDeltaOp): SegmentGroup;
    applyStashedOp(op: IMergeTreeGroupMsg): SegmentGroup[];
    applyStashedOp(op: IMergeTreeOp): SegmentGroup | SegmentGroup[];
    applyMsg(msg: ISequencedDocumentMessage, local?: boolean): void;
    updateSeqNumbers(min: number, seq: number): void;
    /**
     * Resolves a remote client's position against the local sequence
     * and returns the remote client's position relative to the local
     * sequence
     * @param remoteClientPosition - The remote client's position to resolve
     * @param remoteClientRefSeq - The reference sequence number of the remote client
     * @param remoteClientId - The client id of the remote client
     */
    resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
    /**
     *  Given an pending operation and segment group, regenerate the op, so it
     *  can be resubmitted
     * @param resetOp - The op to reset
     * @param segmentGroup - The segment group associated with the op
     */
    regeneratePendingOp(resetOp: IMergeTreeOp, segmentGroup: SegmentGroup | SegmentGroup[]): IMergeTreeOp;
    createTextHelper(): MergeTreeTextHelper;
    summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer, catchUpMsgs: ISequencedDocumentMessage[]): ISummaryTreeWithStats;
    load(runtime: IFluidDataStoreRuntime, storage: IChannelStorageService, serializer: IFluidSerializer): Promise<{
        catchupOpsP: Promise<ISequencedDocumentMessage[]>;
    }>;
    getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
    private getLocalSequenceNumber;
    localTransaction(groupOp: IMergeTreeGroupMsg): void;
    updateConsensusProperty(op: IMergeTreeAnnotateMsg, msg: ISequencedDocumentMessage): void;
    updateMinSeq(minSeq: number): void;
    getContainingSegment<T extends ISegment>(pos: number, op?: ISequencedDocumentMessage): {
        segment: T | undefined;
        offset: number | undefined;
    };
    /**
     * Returns the position to slide a reference to if a slide is required.
     * @param segoff - The segment and offset to slide from
     * @returns - segment and offset to slide the reference to
     */
    getSlideToSegment(segoff: {
        segment: ISegment | undefined;
        offset: number | undefined;
    }): {
        segment: ISegment | undefined;
        offset: number | undefined;
    };
    getPropertiesAtPosition(pos: number): PropertySet | undefined;
    getRangeExtentsOfPosition(pos: number): {
        posStart: number | undefined;
        posAfterEnd: number | undefined;
    };
    getCurrentSeq(): number;
    getClientId(): number;
    getLength(): number;
    startOrUpdateCollaboration(longClientId: string | undefined, minSeq?: number, currentSeq?: number): void;
    findTile(startPos: number, tileLabel: string, preceding?: boolean): {
        tile: ReferencePosition;
        pos: number;
    } | undefined;
}
//# sourceMappingURL=client.d.ts.map