import { FetchOptions } from 'ofetch';
import { DocumentNode } from 'graphql';
import { ClientOptions, ExecutionResult } from 'graphql-ws';
export { c as GqlError, G as GqlOperation, b as GqlResponse, a as GraphQLError } from './types-5ff68c30.js';

type GqlMiddleware = {
    onRequest?: FetchOptions['onRequest'];
    onResponse?: FetchOptions['onResponse'];
    onRequestError?: FetchOptions['onRequestError'];
    onResponseError?: FetchOptions['onResponseError'];
};
type WSClientOptions = Partial<Omit<ClientOptions, 'url'>>;
type WSNextHandler<T = any> = (result: ExecutionResult<T>) => void;
type WSErrorHandler = (err: Error) => void;
type WSOutput<T = any> = {
    /**
     * Restart the WebSocket connection.
     */
    restart: () => void;
    /**
     * Initiate the WebSocket connection and listens for events.
     */
    subscribe: () => void;
    /**
     * Destroy the WebSocket connection.
     */
    unsubscribe: () => void;
    /**
     * onResult is called with the result of the subscription.
     *
     * Must be called before `subscribe`.
     *
     * @param {WSNextHandler<T>} cb - The callback to be called when a new result is received.
     */
    onResult: (cb: WSNextHandler<T>) => void;
    /**
     * onError accepts a callback that is triggered when an error occurs.
     *
     * Must be called before `subscribe`.
     */
    onError: (cb: WSErrorHandler) => void;
    /**
     * Triggers when the WebSocket connection has completed.
     */
    onComplete: (cb: () => void) => void;
};
declare const GqlClient: (input: string | {
    host: string;
    wsHost?: string;
    wsOptions?: WSClientOptions;
    middleware?: GqlMiddleware;
    useGETForQueries?: boolean;
    headers?: Record<string, string>;
}) => {
    execute: {
        <T = any>(opts: {
            query: string | DocumentNode;
            variables?: any | Record<string, any>;
            headers?: HeadersInit;
        }): Promise<T>;
        <T_1 = any>(query: string | DocumentNode, variables?: any | Record<string, any>, headers?: HeadersInit): Promise<T_1>;
    };
    subscribe: {
        <T_2 = any>(opts: {
            query: string | DocumentNode;
            variables?: Record<string, any> | null;
            options?: WSClientOptions;
        }): WSOutput<T_2>;
        <T_3 = any>(query: string | DocumentNode, variables?: Record<string, any> | null, options?: WSClientOptions): WSOutput<T_3>;
    };
    setHost: (host: string) => void;
    setOptions: (opts?: null | Pick<FetchOptions<'json'>, 'retry' | 'headers' | 'mode' | 'cache' | 'credentials'>) => void;
    setHeaders: (headers?: FetchOptions['headers']) => void;
    setMiddleware: (mw: GqlMiddleware) => void;
};
type GqlClient = ReturnType<typeof GqlClient>;

export { GqlClient, GqlMiddleware, WSClientOptions, WSOutput };
