import type { ApolloQueryResult, ObservableQuery, OperationVariables, WatchQueryOptions } from "../../core/index.js";
import type { PromiseWithState } from "../../utilities/index.js";
import type { QueryKey } from "./types.js";
/** @internal */
export type QueryRefPromise<TData> = PromiseWithState<ApolloQueryResult<TData>>;
type Listener<TData> = (promise: QueryRefPromise<TData>) => void;
type DisposeFn = () => void;
type FetchMoreOptions<TData> = Parameters<ObservableQuery<TData>["fetchMore"]>[0];
declare const QUERY_REFERENCE_SYMBOL: unique symbol;
declare const PROMISE_SYMBOL: unique symbol;
/**
 * A `QueryReference` is an opaque object returned by {@link useBackgroundQuery}.
 * A child component reading the `QueryReference` via {@link useReadQuery} will
 * suspend until the promise resolves.
 */
export interface QueryReference<TData = unknown, TVariables = unknown> {
    readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
    [PROMISE_SYMBOL]: QueryRefPromise<TData>;
    retain: () => DisposeFn;
    toPromise(): Promise<ApolloQueryResult<TData>>;
}
interface InternalQueryReferenceOptions {
    onDispose?: () => void;
    autoDisposeTimeoutMs?: number;
}
export declare function wrapQueryRef<TData, TVariables extends OperationVariables>(internalQueryRef: InternalQueryReference<TData>): QueryReference<TData, TVariables>;
export declare function getWrappedPromise<TData>(queryRef: QueryReference<TData>): QueryRefPromise<TData>;
export declare function unwrapQueryRef<TData>(queryRef: QueryReference<TData>): InternalQueryReference<TData>;
export declare function updateWrappedQueryRef<TData>(queryRef: QueryReference<TData>, promise: QueryRefPromise<TData>): void;
declare const OBSERVED_CHANGED_OPTIONS: readonly ["canonizeResults", "context", "errorPolicy", "fetchPolicy", "refetchWritePolicy", "returnPartialData"];
type ObservedOptions = Pick<WatchQueryOptions, (typeof OBSERVED_CHANGED_OPTIONS)[number]>;
export declare class InternalQueryReference<TData = unknown> {
    result: ApolloQueryResult<TData>;
    readonly key: QueryKey;
    readonly observable: ObservableQuery<TData>;
    promise: QueryRefPromise<TData>;
    private subscription;
    private listeners;
    private autoDisposeTimeoutId?;
    private status;
    private __disposed;
    private resolve;
    private reject;
    private references;
    constructor(observable: ObservableQuery<TData, any>, options: InternalQueryReferenceOptions);
    get watchQueryOptions(): WatchQueryOptions<OperationVariables, TData>;
    get disposed(): boolean;
    retain(): () => void;
    didChangeOptions(watchQueryOptions: ObservedOptions): boolean;
    applyOptions(watchQueryOptions: ObservedOptions): QueryRefPromise<TData>;
    listen(listener: Listener<TData>): () => void;
    refetch(variables: OperationVariables | undefined): Promise<ApolloQueryResult<TData>>;
    fetchMore(options: FetchMoreOptions<TData>): Promise<ApolloQueryResult<TData>>;
    private dispose;
    private onDispose;
    private handleNext;
    private handleError;
    private deliver;
    private initiateFetch;
}
export {};
//# sourceMappingURL=QueryReference.d.ts.map