/**
 * useApiParams Hook - REST API Integration for URL State Management
 *
 * Manual schema definition for REST APIs. Provides same URL sync functionality
 * as useQueryParams but without GraphQL dependency.
 *
 * @example
 * const { params, setParam } = useApiParams({
 *   search: { type: 'string', default: '' },
 *   page: { type: 'number', default: 1 },
 *   tags: { type: 'array', default: [] }
 * })
 *
 * fetch(`/api/items?${new URLSearchParams(params)}`)
 *
 * // URL: /items?search=laptop&page=2&tags=electronics&tags=sale
 * // params: { search: 'laptop', page: 2, tags: ['electronics', 'sale'] }
 */
import { JSType } from './graphql-parser';
/**
 * Type mapping from JSType to TypeScript types for OUTPUT (reading params)
 */
type OutputTypeMap = {
    string: string;
    number: number;
    boolean: boolean;
    array: string[];
    object: Record<string, unknown>;
};
/**
 * Type mapping from JSType to TypeScript types for INPUT (setting params)
 * More permissive to allow null/undefined in arrays which get filtered
 */
type InputTypeMap = {
    string: string | null | undefined;
    number: number | null | undefined;
    boolean: boolean | null | undefined;
    array: (string | null | undefined)[];
    object: Record<string, unknown> | null | undefined;
};
/**
 * Get the TypeScript type for OUTPUT (reading from params)
 */
type OutputTypeForJSType<T extends JSType> = OutputTypeMap[T];
/**
 * Get the TypeScript type for INPUT (setting params)
 */
type InputTypeForJSType<T extends JSType> = InputTypeMap[T];
/**
 * Get the default value type for a given JSType
 */
type DefaultValueForType<T extends JSType> = T extends 'array' ? string[] : T extends 'object' ? Record<string, unknown> : OutputTypeMap[T];
/**
 * Parameter configuration for a single parameter
 */
export interface ParamConfig<T extends JSType = JSType> {
    /** JavaScript type for URL parameter */
    type: T;
    /** Default value matching the type */
    default?: DefaultValueForType<T>;
    /** Whether parameter is required */
    required?: boolean;
}
/**
 * REST API parameter schema definition
 * Maps parameter names to their configuration
 */
export type ParamSchema = Record<string, ParamConfig>;
/**
 * Helper to create a typed param schema (preserves literal types)
 */
export declare function defineParamSchema<T extends ParamSchema>(schema: T): T;
/**
 * Options for useApiParams hook
 */
export interface UseApiParamsOptions {
    /** Enable debug logging */
    debug?: boolean;
}
/**
 * Infer the OUTPUT params type from a ParamSchema (for reading)
 * Maps each key in the schema to its corresponding TypeScript type
 *
 * @example
 * const schema = defineParamSchema({
 *   search: { type: 'string', default: '' },
 *   page: { type: 'number', default: 1 },
 *   tags: { type: 'array', default: [] }
 * })
 * type Params = InferParamsFromSchema<typeof schema>
 * // { search: string; page: number; tags: string[] }
 */
export type InferParamsFromSchema<TSchema extends ParamSchema> = {
    [K in keyof TSchema]: TSchema[K]['type'] extends infer T ? T extends JSType ? OutputTypeForJSType<T> : never : never;
};
/**
 * Infer the INPUT params type from a ParamSchema (for setting)
 * More permissive to allow null/undefined values
 */
export type InferInputParamsFromSchema<TSchema extends ParamSchema> = {
    [K in keyof TSchema]: TSchema[K]['type'] extends infer T ? T extends JSType ? InputTypeForJSType<T> : never : never;
};
/**
 * Type for parameter values that can be set
 * Allows setting values that match the schema types or can be coerced to them
 */
export type ParamValue = string | number | boolean | string[] | (string | null | undefined)[] | Record<string, unknown> | null | undefined;
/**
 * Return type for useApiParams hook with strict typing
 */
export interface UseApiParamsReturn<TSchema extends ParamSchema, TParams = InferParamsFromSchema<TSchema>> {
    /** Parsed parameters object with strict typing */
    params: TParams;
    /** URLSearchParams for fetch/axios */
    urlSearchParams: URLSearchParams;
    /** Set a single parameter with type-safe key and value */
    setParam: <K extends keyof TSchema & string>(key: K, value: InferInputParamsFromSchema<Pick<TSchema, K>>[K]) => void;
    /** Set multiple parameters at once */
    setParams: (updates: Partial<InferInputParamsFromSchema<TSchema>>) => void;
    /** Clear specific parameters */
    clearParams: (keys: (keyof TSchema & string)[]) => void;
    /** Reset all parameters (clear URL) */
    resetParams: () => void;
}
/**
 * useApiParams - Manual URL state for REST APIs
 *
 * This hook:
 * 1. Reads URL search parameters
 * 2. Coerces to correct types based on schema
 * 3. Provides type-safe parameter updates
 * 4. Syncs changes to URL automatically
 *
 * @param schema - Parameter schema definition
 * @param options - Configuration options
 * @returns Hook API for managing URL state
 */
export declare function useApiParams<TSchema extends ParamSchema>(schema: TSchema, options?: UseApiParamsOptions): UseApiParamsReturn<TSchema>;
/**
 * Helper: Create URLSearchParams from object
 *
 * Handles arrays as repeated parameters. Filters out undefined, and empty values.
 *
 * @param params - Parameters object
 * @returns URLSearchParams
 */
export declare function createSearchParams(params: Record<string, ParamValue>): URLSearchParams;
export {};
//# sourceMappingURL=use-api-params.d.ts.map