import { CallEventListener, EventTypes } from '../coordinator/connection/types';
import type { SfuEvent } from '../gen/video/sfu/event/events';
export type SfuEventKinds = NonNullable<SfuEvent['eventPayload']['oneofKind']>;
export type AllSfuEvents = {
    [K in SfuEventKinds]: K extends keyof Extract<SfuEvent['eventPayload'], {
        oneofKind: K;
    }> ? Extract<SfuEvent['eventPayload'], {
        oneofKind: K;
    }>[K] : never;
};
export type DispatchableMessage<K extends SfuEventKinds> = {
    eventPayload: {
        oneofKind: K;
    } & {
        [Key in K]: AllSfuEvents[Key];
    };
};
/**
 * Determines if a given event name belongs to the category of SFU events.
 *
 * @param eventName the name of the event to check.
 * @returns true if the event name is an SFU event, otherwise false.
 */
export declare const isSfuEvent: (eventName: SfuEventKinds | EventTypes) => eventName is SfuEventKinds;
export type ListenerTag = string | (() => string);
type AnyListener = CallEventListener<keyof AllSfuEvents>;
type DynamicHandler = {
    tagSelector: () => string;
    listener: AnyListener;
};
export declare class Dispatcher {
    private readonly logger;
    private subscribers;
    /**
     * Dispatch an event to all subscribers.
     *
     * @param message the event payload to dispatch.
     * @param tag for scoping events to a specific tag. Use `*` dispatch to every tag.
     */
    dispatch: <K extends SfuEventKinds>(message: DispatchableMessage<K>, tag?: string) => void;
    /**
     * Emit an event to a list of listeners.
     *
     * @param payload the event payload to emit.
     * @param listeners the list of listeners to emit the event to.
     */
    emit: (payload: any, listeners?: AnyListener[]) => void;
    /**
     * Emit an event to a list of listeners.
     *
     */
    emitDynamic: (payload: any, tag: string, dynamic: DynamicHandler[]) => void;
    /**
     * Emit an event to a single listener.
     * @param payload the event payload to emit.
     * @param listener the listener to emit the event to.
     */
    private emitOne;
    /**
     * Subscribe to an event.
     *
     * @param eventName the name of the event to subscribe to.
     * @param tag for scoping events to a specific tag. Can be a static tag
     * string or a function that resolves the tag dynamically.
     * @param fn the callback function to invoke when the event is emitted.
     * @returns a function that can be called to unsubscribe from the event.
     */
    on: <E extends keyof AllSfuEvents>(eventName: E, tag: ListenerTag, fn: CallEventListener<E>) => () => void;
    /**
     * Unsubscribe from an event.
     *
     * @param eventName the name of the event to unsubscribe from.
     * @param tag the original static/dynamic tag selector used during subscription.
     * @param fn the callback function to remove from the event listeners.
     */
    off: <E extends keyof AllSfuEvents>(eventName: E, tag: ListenerTag, fn: CallEventListener<E>) => void;
    private getHandlers;
}
export {};
