import { type ProviderInstrumentationPort } from "../providers/instrumentation.js";
import { type ChannelDefinition, type InferChannelEvent, type InferChannelParams } from "./index.js";
export type BroadcastClientStatus = "connecting" | "connected" | "reconnecting" | "blocked" | "closed";
/** Why this physical connection was opened, or why it is reconnecting. */
export interface BroadcastConnectionInfo {
    readonly reason: "initial" | "planned-renewal" | "subscription-change" | "interruption" | "unknown";
}
/** Safe connection/protocol failure; application callback errors are reported separately. */
export declare class BroadcastClientError extends Error {
    readonly retryable: boolean;
    readonly status?: number | undefined;
    constructor(message: string, retryable: boolean, status?: number | undefined);
}
export interface BroadcastClientSubscription {
    unsubscribe(): void;
    getStatus(): BroadcastClientStatus;
}
export interface BroadcastClient {
    subscribe<C extends ChannelDefinition>(channel: C, options: {
        params: InferChannelParams<C>;
        onEvent: (event: InferChannelEvent<C>) => void | Promise<void>;
        /** Refetch authoritative state after initial readiness and every recovered connection. */
        onSync: (info: BroadcastConnectionInfo) => void | Promise<void>;
        onError?: (error: unknown) => void;
        onStatusChange?: (status: BroadcastClientStatus, info: BroadcastConnectionInfo) => void;
    }): BroadcastClientSubscription;
    /** Merge these optional headers into the app's typed HTTP client to opt into exclusion. */
    getRequestHeaders(): Record<string, string>;
    getStatus(): BroadcastClientStatus;
    /** Explicit app action after credentials/access change. Renewals never unblock denied subscriptions. */
    resume(): void;
    close(): void;
}
export interface BroadcastClientOptions {
    url: string;
    /** Optional existing instrumentation sink; records causes and counts, never credentials or channel params. */
    instrumentation?: ProviderInstrumentationPort;
    /** Resolved afresh for every request. Never place credentials in the URL. */
    headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
    credentials?: RequestCredentials;
    fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
}
/** One multiplexed streaming Fetch connection per instance. Create an instance per app auth session. */
export declare function createBroadcastClient(options: BroadcastClientOptions): BroadcastClient;
//# sourceMappingURL=client.d.ts.map