import { O as CombinedDataTransformer, n as HttpClientError } from "./http-types-zsMHb_QN.js";
import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";

//#region src/crpc/http-client.d.ts
/** Form value types (matches Hono's FormValue) */
type HttpFormValue = string | Blob;
/**
 * Hybrid input args: JSON body fields at root, explicit params/searchParams/form.
 * - JSON body: spread at root level (tRPC-style)
 * - Path params: { params: { id: '123' } }
 * - Query params: { searchParams: { limit: '10' } }
 * - Form data: { form: { file: blob } } - typed via .form() builder
 * - Client options: { headers, fetch, init } - for per-call customization
 */
type HttpInputArgs = {
  /** Path parameters (e.g., :id in /users/:id) */params?: Record<string, string>; /** Query string parameters */
  searchParams?: Record<string, string | string[]>; /** Form data body (Content-Type: multipart/form-data) - typed via .form() builder */
  form?: Record<string, HttpFormValue | HttpFormValue[]>; /** Custom fetch function (per-call override) */
  fetch?: typeof fetch; /** Standard RequestInit (per-call override) */
  init?: RequestInit; /** Additional headers (per-call override) */
  headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>); /** Any other properties are JSON body fields */
  [key: string]: unknown;
};
/**
 * Client request options (matches Hono's ClientRequestOptions).
 * Standard RequestInit in `init` takes highest priority and can override
 * things that are set automatically like body, method, headers.
 */
type HttpClientOptions = {
  /** Custom fetch function */fetch?: typeof fetch;
  /**
   * Standard RequestInit - takes highest priority.
   * Can override body, method, headers if needed.
   */
  init?: RequestInit; /** Additional headers (or async function returning headers) */
  headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
};
/** HTTP proxy options (framework-agnostic parts) */
interface HttpProxyBaseOptions {
  /** Base URL for the Convex HTTP API (e.g., https://your-site.convex.site) */
  convexSiteUrl: string;
  /** Custom fetch function (defaults to global fetch) */
  fetch?: typeof fetch;
  /** Default headers or async function returning headers (for auth tokens) */
  headers?: {
    [key: string]: string | undefined;
  } | (() => {
    [key: string]: string | undefined;
  } | Promise<{
    [key: string]: string | undefined;
  }>);
  /** Error handler called on HTTP errors */
  onError?: (error: HttpClientError) => void;
}
/** Reserved keys that are not part of JSON body */
declare const RESERVED_KEYS: Set<string>;
/**
 * Replace URL path parameters with actual values.
 * e.g., '/users/:id' with { id: '123' } -> '/users/123'
 */
declare function replaceUrlParam(url: string, params: Record<string, string>): string;
/**
 * Build URLSearchParams from query object.
 * Handles array values as multiple params with same key (like Hono).
 */
declare function buildSearchParams(query: Record<string, string | string[]>): URLSearchParams;
/**
 * Hono-style HTTP request executor.
 * Processes args in the same way as Hono's ClientRequestImpl.fetch().
 */
declare function executeHttpRequest(opts: {
  convexSiteUrl: string;
  route: {
    path: string;
    method: string;
  };
  procedureName: string; /** Hono-style input args */
  args?: HttpInputArgs; /** Per-request client options */
  clientOpts?: HttpClientOptions; /** Base headers from proxy config */
  baseHeaders?: {
    [key: string]: string | undefined;
  } | (() => {
    [key: string]: string | undefined;
  } | Promise<{
    [key: string]: string | undefined;
  }>); /** Base fetch from proxy config */
  baseFetch?: typeof fetch; /** Wire transformer for payload serialization. */
  transformer: CombinedDataTransformer;
}): Promise<unknown>;
//#endregion
//#region src/crpc/types.d.ts
/** Symbol key for attaching FunctionReference to options (non-serializable) */
declare const FUNC_REF_SYMBOL: unique symbol;
/** Options controlled by convexQuery/convexAction factories */
type ReservedQueryOptions = 'queryKey' | 'queryFn' | 'staleTime';
/** Options controlled by mutation factories */
type ReservedMutationOptions = 'mutationFn';
/** Reserved options controlled by infinite query factories */
type ReservedInfiniteQueryOptions = 'queryKey' | 'queryFn' | 'staleTime' | 'refetchInterval' | 'refetchOnMount' | 'refetchOnReconnect' | 'refetchOnWindowFocus' | 'persister' | 'placeholderData';
/** Metadata for a single Convex function */
type FnMeta = {
  auth?: 'required' | 'optional';
  role?: string;
  ratelimit?: string;
  type?: 'query' | 'mutation' | 'action';
  limit?: number;
  [key: string]: unknown;
};
/** Metadata for paginated functions (limit is required) */
type PaginatedFnMeta = Omit<FnMeta, 'limit'> & {
  limit: number;
};
/** Metadata for all Convex functions by namespace.fnName, with _http for HTTP routes */
type Meta = Record<string, Record<string, FnMeta>> & {
  _http?: Record<string, {
    path: string;
    method: string;
  }>;
};
/** Authentication requirement for a Convex function */
type AuthType = 'required' | 'optional' | undefined;
/** Query key structure for Convex queries */
type ConvexQueryKey<T extends FunctionReference<'query'>> = readonly ['convexQuery', string, FunctionArgs<T>];
/** Query key structure for Convex actions */
type ConvexActionKey<T extends FunctionReference<'action'>> = readonly ['convexAction', string, FunctionArgs<T>];
/** Mutation key structure for Convex mutations/actions */
type ConvexMutationKey = ['convexMutation', string];
/**
 * Meta passed to TanStack Query for auth and subscription control.
 * Set by convexQuery, read by ConvexQueryClient.queryFn() and subscribeInner().
 */
type ConvexQueryMeta = {
  /** Auth type from generated Convex metadata via getMeta() */authType?: 'required' | 'optional'; /** Skip query silently when unauthenticated (returns null) */
  skipUnauth?: boolean; /** Whether to create WebSocket subscription (default: true) */
  subscribe?: boolean;
};
/** Hook options for Convex queries */
type ConvexQueryHookOptions = {
  /** Skip query silently when unauthenticated (default: false, calls onQueryUnauthorized) */skipUnauth?: boolean; /** Set to false to fetch once without subscribing (default: true) */
  subscribe?: boolean;
};
/** Internal Convex pagination options (used by .paginate()) */
type PaginationOpts = {
  cursor: string | null;
  numItems: number;
  endCursor?: string | null;
  id?: number;
  maximumRowsRead?: number;
  maximumBytesRead?: number;
};
/** Extract input args without cursor/limit (user's filter args only) */
type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'limit'>;
/** Extract item type from PaginationResult<T> */
type ExtractPaginatedItem<TOutput> = TOutput extends {
  page: (infer T)[];
} ? T : never;
/** Metadata for infinite query (extends ConvexQueryMeta) */
type ConvexInfiniteQueryMeta = ConvexQueryMeta & {
  /** The query function name (serializable for RSC) */queryName: string; /** Query args without cursor/limit (user's filter args only) */
  args: Record<string, unknown>; /** Items per page (optional - server uses .paginated() default) */
  limit?: number;
};
type EmptyObject = Record<string, never>;
/** Static query options parameter type (non-hook, for event handlers) */
type StaticQueryOptsParam = {
  skipUnauth?: boolean;
};
/** Check if a type has cursor key (pagination detection) */
type IsPaginated<T> = 'cursor' extends keyof T ? true : false;
/** Mutation variables type - undefined when no args required (allows mutateAsync() without args) */
type MutationVariables<T extends FunctionReference<'mutation' | 'action'>> = keyof FunctionArgs<T> extends never ? void : EmptyObject extends FunctionArgs<T> ? FunctionArgs<T> | undefined : FunctionArgs<T>;
/** Base query options shape returned by convexQuery factory */
type BaseConvexQueryOptions<T extends FunctionReference<'query'>> = {
  queryKey: ConvexQueryKey<T>;
  staleTime?: number;
  enabled?: unknown;
};
/** Base action options shape returned by convexAction factory */
type BaseConvexActionOptions<T extends FunctionReference<'action'>> = {
  queryKey: ConvexActionKey<T>;
  staleTime?: number;
  enabled?: unknown;
};
/** Base infinite query options parameter */
type BaseInfiniteQueryOptsParam<T extends FunctionReference<'query'> = FunctionReference<'query'>> = {
  /** Items per page. Optional - server uses .paginated() default if not provided. */limit?: number; /** Skip query silently when unauthenticated */
  skipUnauth?: boolean; /** Placeholder data shown while loading (item array, not pagination result) */
  placeholderData?: ExtractPaginatedItem<FunctionReturnType<T>>[]; /** Whether the query is enabled */
  enabled?: unknown;
};
/** Base infinite query options shape */
type BaseConvexInfiniteQueryOptions<T extends FunctionReference<'query'>> = {
  queryKey: ConvexQueryKey<T>;
  staleTime?: number;
  enabled?: unknown;
  meta: ConvexInfiniteQueryMeta;
  refetchInterval: false;
  refetchOnMount: false;
  refetchOnReconnect: false;
  refetchOnWindowFocus: false; /** Placeholder data shown while loading (item array, not pagination result) */
  placeholderData?: ExtractPaginatedItem<FunctionReturnType<T>>[];
};
/** Vanilla mutation - direct .mutate() call without TanStack Query */
type VanillaMutation<T extends FunctionReference<'mutation'>> = {
  mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
};
/** Vanilla action - both .query() and .mutate() for direct calls */
type VanillaAction<T extends FunctionReference<'action'>> = {
  query: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
  mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
};
//#endregion
export { HttpInputArgs as A, ReservedMutationOptions as C, VanillaMutation as D, VanillaAction as E, replaceUrlParam as F, RESERVED_KEYS as M, buildSearchParams as N, HttpClientOptions as O, executeHttpRequest as P, ReservedInfiniteQueryOptions as S, StaticQueryOptsParam as T, IsPaginated as _, BaseInfiniteQueryOptsParam as a, PaginatedFnMeta as b, ConvexMutationKey as c, ConvexQueryMeta as d, EmptyObject as f, InfiniteQueryInput as g, FnMeta as h, BaseConvexQueryOptions as i, HttpProxyBaseOptions as j, HttpFormValue as k, ConvexQueryHookOptions as l, FUNC_REF_SYMBOL as m, BaseConvexActionOptions as n, ConvexActionKey as o, ExtractPaginatedItem as p, BaseConvexInfiniteQueryOptions as r, ConvexInfiniteQueryMeta as s, AuthType as t, ConvexQueryKey as u, Meta as v, ReservedQueryOptions as w, PaginationOpts as x, MutationVariables as y };