import type { SyncOperation } from '../types.js';
import type { RealtimeServerConfig, RealtimeConnection } from './types.js';
import { EventEmitter } from './event-emitter.js';
/**
 * Server-side realtime connection manager.
 * Manages SSE connections and broadcasts operations to connected clients.
 */
export declare class RealtimeServer extends EventEmitter {
    private config;
    private connections;
    private userConnections;
    private channelSubscriptions;
    private heartbeatInterval;
    private encoder;
    private presenceStore;
    private ephemeralStore;
    constructor(config?: RealtimeServerConfig);
    private resolveConfig;
    /**
     * Update configuration at runtime
     */
    configure(config: Partial<RealtimeServerConfig>): void;
    /**
     * Get active connection count
     */
    getConnectionCount(): number;
    /**
     * Get connections for a specific user
     */
    getUserConnections(userId: string): RealtimeConnection[];
    /**
     * Create an SSE response for a client connection.
     * Use this in your API route handler.
     */
    createConnection(connectionId: string, userId: string, clientId: string, tables?: string[]): Response;
    /**
     * Broadcast operations to all relevant connected clients.
     * Call this after processing push operations.
     */
    broadcast(operations: SyncOperation[], excludeClientId?: string): void;
    /**
     * Send operations to a specific user's connections
     */
    sendToUser(userId: string, operations: SyncOperation[]): void;
    /**
     * Send a custom event to all connections
     */
    sendtoAll<T>(type: string, data: T): void;
    /**
     * Disconenct all clients
     */
    disconnectAll(): void;
    /**
     * Handle incoming client message (from POST requests)
     */
    handleClientMessage(message: any, userId: string, clientId: string): void;
    /**
     * Clean up resources
     */
    destroy(): void;
    private setupPresenceHandlers;
    private setupEphemeralHandlers;
    private handlePresenceUpdate;
    private handlePresenceLeave;
    private handlePresenceExpire;
    private handleEphemeralData;
    private handleChannelJoin;
    private handleChannelLeave;
    private sendPresenceSync;
    private broadcastToChannel;
    private findConnectionId;
    private addConnection;
    private removeConnection;
    private sendToConnection;
    private formatSSEMessage;
    private startHeartbeat;
    private stopHeartbeat;
}
/**
 * Create a realtime server with the given configuration
 */
export declare function createRealtimeServer(config?: RealtimeServerConfig): RealtimeServer;
