import type { FastifyRequest } from 'fastify';
import type { SSERoomBroadcaster } from '../rooms/SSERoomBroadcaster.js';
import type { SSERoomManager } from '../rooms/SSERoomManager.js';
import type { SSEMessage } from '../sseTypes.js';
import type { IncomingEvent, PublishResult, SSESubscriptionManagerConfig, SubscriptionContext } from './types.js';
type SSESession = {
    id: string;
    request: FastifyRequest;
};
export declare class SSESubscriptionManager<TUserContext, TMetadata extends Record<string, unknown> = Record<string, unknown>> {
    private readonly config;
    private readonly connectionStates;
    private readonly userConnections;
    private readonly deps;
    constructor(config: SSESubscriptionManagerConfig<TUserContext, TMetadata>, deps: {
        sseRoomManager: SSERoomManager;
        sseRoomBroadcaster: SSERoomBroadcaster;
    });
    handleConnect(session: SSESession): Promise<void>;
    handleDisconnect(session: SSESession): void;
    publish(event: IncomingEvent<TMetadata>): Promise<PublishResult>;
    /**
     * Pre-delivery filter registered with the broadcaster.
     * Evaluates the resolver pipeline for a connection and returns whether
     * the message should be delivered.
     *
     * Returns `true` for connections not managed by this subscription manager,
     * so non-subscription SSE streams are unaffected.
     *
     * @param connectionId - The connection to evaluate
     * @param message - The SSE message being delivered
     * @param metadata - Optional metadata (cast to TMetadata — callers must ensure shape matches)
     * @returns Whether the message should be delivered to this connection
     */
    shouldDeliver(connectionId: string, message: SSEMessage, metadata?: Record<string, unknown>): Promise<boolean> | boolean;
    refreshConnection(connectionId: string): Promise<void>;
    private rekeyUserConnection;
    refreshUser(userId: string): Promise<void>;
    getConnectionContext(connectionId: string): SubscriptionContext<TUserContext> | undefined;
    private runRefreshChain;
    private computeRoomUnion;
    private applyRoomDiff;
    private evaluatePipeline;
    private evaluate;
    private publishToAllConnections;
}
export {};
