/**
 * Thin HTTP transport wrapper around Node 18+'s built-in `fetch`. Centralises:
 *   - URL construction for the Bot API
 *   - x-www-form-urlencoded vs multipart/form-data body building
 *   - response parsing into Telegram's `{ ok, result, description, error_code }` envelope
 *   - error mapping into our error hierarchy
 */
import { type PreparedFile } from "./utils.js";
export interface RequestOptions {
    /** Scalar / structured fields. Sent as multipart when `formData` is present, else x-www-form-urlencoded. */
    form?: Record<string, unknown>;
    /** Multipart form data (file uploads) */
    formData?: Record<string, PreparedFile>;
    /** Per-call abort signal */
    signal?: AbortSignal;
    /** Per-call timeout in ms */
    timeoutMs?: number;
}
export interface TelegramApiOk<T> {
    ok: true;
    result: T;
}
export interface TelegramApiErr {
    ok: false;
    description?: string;
    error_code?: number;
    parameters?: {
        migrate_to_chat_id?: number;
        retry_after?: number;
    };
}
export type TelegramApiResponse<T> = TelegramApiOk<T> | TelegramApiErr;
export interface HttpClientOptions {
    baseApiUrl?: string;
    testEnvironment?: boolean;
    request?: {
        timeoutMs?: number;
        headers?: Record<string, string>;
        /**
         * On `429 Too Many Requests`, sleep for `retry_after` seconds (as
         * advertised by Telegram) and retry up to this many times. Set to `0`
         * to opt out. Defaults to `2`.
         */
        maxRetriesOn429?: number;
    };
}
export declare class HttpClient {
    private readonly token;
    private readonly options;
    constructor(token: string, options?: HttpClientOptions);
    buildURL(method: string): string;
    request<T>(method: string, opts?: RequestOptions): Promise<T>;
    /**
     * Perform a single HTTP attempt: fire the request (honoring the per-call
     * timeout and abort signal) and parse Telegram's envelope. Throws
     * {@link FatalError} on a transport failure and {@link ParseError} on an
     * unparseable body; otherwise returns the HTTP status and parsed envelope
     * (ok or not) for the caller's retry/throw decision.
     */
    private _attempt;
}
//# sourceMappingURL=http.d.ts.map