import type { ConnectionClient } from './ConnectionClient';
import type { Observable } from 'rxjs';
import type { ConnectedToBranchMessage, DisconnectedFromBranchMessage, WatchBranchMessage, WatchBranchResultMessage, WebsocketErrorInfo } from './WebsocketEvents';
import type { DeviceAction, DeviceActionResult, DeviceActionError, RemoteActions } from '../common/RemoteActions';
import type { TimeSample } from '@casual-simulation/timesync';
export declare const DEFAULT_BRANCH_NAME = "default";
/**
 * Defines a client for inst records.
 */
export declare class InstRecordsClient {
    private _client;
    private _sentUpdates;
    private _updateCounter;
    private _watchedBranches;
    private _connectedBranches;
    private _connectedDevices;
    private _connectedDeviceBranches;
    private _forcedOffline;
    private _timeSyncCounter;
    private _resendUpdatesAfter;
    private _resendUpdatesInterval;
    private _resendUpdatesIntervalId;
    private _onSyncUpdatesEvent;
    get onSyncUpdatesEvent(): Observable<SyncUpdatesEvent>;
    /**
     * Gets the amount of time in miliseconds that the client should wait before resending updates that were never acknowledged.
     * If null, then the client will never resend updates based on time.
     */
    get resendUpdatesAfterMs(): number | null;
    /**
     * Sets the amount of time in miliseconds that the client should wait before resending updates that were never acknowledged.
     * If null, then the client will never resend updates based on time.
     */
    set resendUpdatesAfterMs(value: number | null);
    get resendUpdatesIntervalMs(): number | null;
    set resendUpdatesIntervalMs(value: number | null);
    private _stopResendUpdatesInterval;
    private _startResendUpdatesInterval;
    private _resendUpdates;
    constructor(connection: ConnectionClient);
    /**
     * Gets the connection that this client is using.
     */
    get connection(): ConnectionClient;
    get onError(): Observable<WebsocketErrorInfo>;
    /**
     * Gets whether the client is forcing the connection to be offline or not.
     */
    get forcedOffline(): boolean;
    /**
     * Sets whether the client is forcing the connection to be offline or not.
     */
    set forcedOffline(value: boolean);
    /**
     * Starts watching the given branch.
     * @param name The name of the branch to watch.
     */
    watchBranchUpdates(nameOrEvent: string | WatchBranchMessage): Observable<ClientUpdatesOrEvent>;
    /**
     * Watches for rate limit exceeded events.
     */
    watchRateLimitExceeded(): Observable<import("./WebsocketEvents").RateLimitExceededMessage>;
    /**
     * Gets the updates stored on the given branch.
     * @param recordName The name of the record.
     * @param inst The name of the inst.
     * @param name The name of the branch to get.
     */
    getBranchUpdates(recordName: string | null, inst: string, branch: string): Observable<{
        updates: string[];
        timestamps?: number[];
    }>;
    /**
     * Watches for device connection/disconnection events on the given branch.
     * @param branch The branch to watch.
     */
    watchBranchDevices(recordName: string | null, inst: string, branch: string): Observable<ConnectedToBranchMessage | DisconnectedFromBranchMessage>;
    private _disconnectDevices;
    private _watchConnectedDevices;
    /**
     * Adds the given updates to the given branch.
     * @param recordName The name of the record.
     * @param inst The name of the inst.
     * @param branch The name of the branch.
     * @param updates The updates.
     */
    addUpdates(recordName: string | null, inst: string, branch: string, updates: string[]): void;
    /**
     * Sends the given action to devices on the given branch.
     * @param branch The branch.
     * @param action The action.
     */
    sendAction(recordName: string | null, inst: string, branch: string, action: RemoteActions): void;
    /**
     * Sends a SyncTimeRequest to the server.
     */
    sampleServerTime(): Promise<TimeSample>;
    /**
     * Requests the number of devices that are currently connected.
     * @param branch The branch that the devices should be counted on.
     */
    connectionCount(recordName?: string, inst?: string, branch?: string): Observable<number>;
    private _whenConnected;
    private _sendAddUpdates;
    private _getSentUpdates;
    private _getConnectedDevices;
    private _isDeviceConnected;
}
export interface ClientUpdates {
    type: 'updates';
    updates: string[];
}
export interface ClientUpdatesReceived {
    type: 'updates_received';
}
export interface ClientAtomsReceived {
    type: 'atoms_received';
}
export interface ClientEvent {
    type: 'event';
    action: DeviceAction | DeviceActionResult | DeviceActionError;
}
export interface BaseClientError {
    type: 'error';
    kind: string;
}
export type ClientError = MaxInstSizeReachedClientError | WebsocketClientError;
export interface MaxInstSizeReachedClientError extends BaseClientError {
    kind: 'max_size_reached';
    maxBranchSizeInBytes: number;
    neededBranchSizeInBytes: number;
}
export interface WebsocketClientError extends BaseClientError {
    kind: 'error';
    info: WebsocketErrorInfo;
}
export type ClientWatchBranchMessages = ClientAtomsReceived | ClientEvent;
export type ClientWatchBranchUpdatesEvents = ClientUpdates | ClientUpdatesReceived | ClientEvent | ClientError | WatchBranchResultMessage;
export type ClientUpdatesOrEvent = ClientUpdates | ClientEvent | ClientError | WatchBranchResultMessage;
export declare function isClientEvent(event: ClientWatchBranchMessages | ClientWatchBranchUpdatesEvents): event is ClientEvent;
export declare function isClientUpdates(event: ClientWatchBranchUpdatesEvents): event is ClientUpdates;
export declare function isClientUpdatesOrEvents(event: ClientWatchBranchUpdatesEvents): event is ClientUpdatesOrEvent;
export declare function isClientError(event: ClientWatchBranchUpdatesEvents): event is ClientError;
export declare function isWatchBranchResult(event: ClientWatchBranchUpdatesEvents): event is WatchBranchResultMessage;
export type SyncUpdatesEvent = SyncingUpdatesEvent | SyncedUpdatesEvent;
export interface SyncingUpdatesEvent {
    type: 'syncing';
    recordName: string | null;
    inst: string;
    branch: string;
}
export interface SyncedUpdatesEvent {
    type: 'synced';
    recordName: string | null;
    inst: string;
    branch: string;
}
//# sourceMappingURL=InstRecordsClient.d.ts.map