/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ICompressionRuntimeOptions } from "../compressionDefinitions.js";
import type { IPendingMessage } from "../pendingStateManager.js";
import { LocalBatchMessage, IBatchCheckpoint, type LocalBatch } from "./definitions.js";
import type { BatchStartInfo } from "./remoteMessageProcessor.js";
export interface IBatchManagerOptions {
    readonly compressionOptions?: ICompressionRuntimeOptions;
    /**
     * If true, the outbox is allowed to rebase the batch during flushing.
     */
    readonly canRebase: boolean;
    /**
     * If true, don't compare batchID of incoming batches to this. e.g. ID Allocation Batch IDs should be ignored
     */
    readonly ignoreBatchId?: boolean;
}
export interface BatchSequenceNumbers {
    referenceSequenceNumber?: number;
    clientSequenceNumber?: number;
}
/**
 * Type alias for the batchId stored in batch metadata
 */
export type BatchId = string;
/**
 * Compose original client ID and client sequence number into BatchId to stamp on the message during reconnect
 */
export declare function generateBatchId(originalClientId: string, batchStartCsn: number): BatchId;
/**
 * Get the effective batch ID for the input argument.
 * Supports either an IPendingMessage or BatchStartInfo.
 * If the batch ID is explicitly present, return it.
 * Otherwise, generate a new batch ID using the client ID and batch start CSN.
 */
export declare function getEffectiveBatchId(pendingMessageOrBatchStartInfo: IPendingMessage | BatchStartInfo): string;
/**
 * Helper class that manages partial batch & rollback.
 */
export declare class BatchManager {
    readonly options: IBatchManagerOptions;
    private pendingBatch;
    private hasReentrantOps;
    get length(): number;
    get sequenceNumbers(): BatchSequenceNumbers;
    private get referenceSequenceNumber();
    /**
     * The last-processed CSN when this batch started.
     * This is used to ensure that while the batch is open, no incoming ops are processed.
     */
    private clientSequenceNumber;
    constructor(options: IBatchManagerOptions);
    push(message: LocalBatchMessage, reentrant: boolean, currentClientSequenceNumber?: number): void;
    get empty(): boolean;
    /**
     * Gets the pending batch and clears state for the next batch.
     */
    popBatch(batchId?: BatchId): LocalBatch;
    /**
     * Capture the pending state at this point
     */
    checkpoint(): IBatchCheckpoint;
    /**
     * Does this batch current contain user changes ("dirtyable" ops)?
     */
    containsUserChanges(): boolean;
}
export declare const addBatchMetadata: (batch: LocalBatch, batchId?: BatchId) => LocalBatch;
export declare const sequenceNumbersMatch: (seqNums: BatchSequenceNumbers, otherSeqNums: BatchSequenceNumbers) => boolean;
//# sourceMappingURL=batchManager.d.ts.map