import type { JsMsg, MsgHdrs as NatsHeaders, Msg, Subscription } from 'nats.ws';
export type { JsMsg, Msg, Subscription } from 'nats.ws';
export type JetStreamDeliverPolicy = 'new' | 'byStartSequence';
export interface JetStreamOrderedSubscribeOptions {
    streamName: string;
    filterSubject: string;
    deliverPolicy: JetStreamDeliverPolicy;
    /** Required when deliverPolicy === 'byStartSequence'. */
    optStartSeq?: number;
    /** Auto-cleanup the ephemeral consumer after this idle time. Default: 5 minutes. */
    inactiveThresholdMs?: number;
    /** AbortSignal to tear down the consumer. */
    signal?: AbortSignal;
}
export interface JetStreamSubscriptionHandle {
    unsubscribe(): void;
}
export interface NatsClientOptions {
    /**
     * NATS server URL(s), for example:
     * - "wss://nats.example.com:443"
     * - ["wss://nats-1.example.com:443", "wss://nats-2.example.com:443"]
     */
    servers: string | string[];
    /**
     * Connection name (shows up in NATS monitoring).
     */
    name?: string;
    /**
     * Auth options (pick one: token or user/pass).
     */
    token?: string;
    user?: string;
    pass?: string;
    /**
     * Reconnect behavior.
     */
    reconnect?: boolean;
    maxReconnectAttempts?: number;
    reconnectTimeWaitMs?: number;
    /**
     * Exponential backoff for reconnect delays.
     * When set, uses `reconnectDelayHandler` from nats.ws under the hood,
     * overriding `reconnectTimeWaitMs`.
     */
    exponentialBackoff?: {
        /** Initial delay in ms (default: 1000) */
        initialDelayMs?: number;
        /** Maximum delay cap in ms (default: 30000) */
        maxDelayMs?: number;
        /** Multiplier per attempt (default: 2) */
        multiplier?: number;
        /** Add random jitter 0-50% of delay to prevent thundering herd (default: true) */
        jitter?: boolean;
    };
    /**
     * Ping behavior (keep-alive).
     */
    pingIntervalMs?: number;
    maxPingOut?: number;
    /**
     * Optional inbox prefix (useful if you want to isolate request/reply inboxes).
     */
    inboxPrefix?: string;
    /**
     * Connection timeout in milliseconds (maps to `nats.ws` connect option `timeout`).
     * If you see `NatsError: TIMEOUT` during connect, increase this.
     */
    connectTimeoutMs?: number;
}
export interface NatsSubscribeOptions {
    /**
     * Queue group for load-balancing messages across subscribers.
     */
    queue?: string;
    /**
     * Auto-unsubscribe after receiving this many messages.
     */
    max?: number;
    /**
     * Abort signal to stop message iteration and unsubscribe.
     */
    signal?: AbortSignal;
}
export type NatsHeadersInit = Record<string, string> | NatsHeaders | undefined;
export interface NatsPublishOptions {
    headers?: NatsHeadersInit;
}
export interface NatsRequestOptions {
    timeoutMs?: number;
    headers?: NatsHeadersInit;
}
export interface NatsSubscriptionHandle {
    readonly subscription: Subscription;
    unsubscribe(): void;
}
export type NatsStatus = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'closed' | 'error';
export interface NatsStatusEvent {
    status: NatsStatus;
    data?: unknown;
}
export interface NatsClient {
    connect(): Promise<void>;
    close(): Promise<void>;
    isConnected(): boolean;
    publishBytes(subject: string, payload: Uint8Array, options?: NatsPublishOptions): void;
    publishString(subject: string, payload: string, options?: NatsPublishOptions): void;
    publishJson<T>(subject: string, payload: T, options?: NatsPublishOptions): void;
    requestBytes(subject: string, payload: Uint8Array, options?: NatsRequestOptions): Promise<Msg>;
    requestString(subject: string, payload: string, options?: NatsRequestOptions): Promise<string>;
    requestJson<TResponse, TRequest = unknown>(subject: string, payload: TRequest, options?: NatsRequestOptions): Promise<TResponse>;
    subscribeBytes(subject: string, onMessage: (msg: Msg) => void | Promise<void>, options?: NatsSubscribeOptions): NatsSubscriptionHandle;
    subscribeString(subject: string, onMessage: (payload: string, msg: Msg) => void | Promise<void>, options?: NatsSubscribeOptions): NatsSubscriptionHandle;
    subscribeJson<T>(subject: string, onMessage: (payload: T, msg: Msg) => void | Promise<void>, options?: NatsSubscribeOptions): NatsSubscriptionHandle;
    /**
     * Subscribe to a JetStream subject via an ephemeral OrderedConsumer (no acks).
     * Use `optStartSeq` with `deliverPolicy: 'byStartSequence'` to resume from a known offset,
     * or `deliverPolicy: 'new'` to live-tail.
     */
    subscribeJetStreamOrdered(onMessage: (msg: JsMsg) => void | Promise<void>, options: JetStreamOrderedSubscribeOptions): Promise<JetStreamSubscriptionHandle>;
    onStatus(listener: (event: NatsStatusEvent) => void): () => void;
}
export declare function createNatsClient(options: NatsClientOptions): NatsClient;
//# sourceMappingURL=nats.d.ts.map