import { RoutePattern, type PartPattern } from './route-pattern.ts'; import type { ParseParams } from './types/params.ts'; import type { Split, SplitPattern } from './types/split.ts'; import type { Simplify } from './types/utils.ts'; /** Tuple of arguments accepted by `createHref` for a given pattern source. */ export type CreateHrefArgs = _CreateHrefArgs>; type _CreateHrefArgs = {} extends params ? [ params?: Simplify> | null | undefined, searchParams?: SearchParams ] : [ params: Simplify>, searchParams?: SearchParams ]; type SearchParams = Record>; type ParseHrefParams = Split extends infer split extends SplitPattern ? split extends ({ protocol: string; hostname: undefined; } | { hostname: undefined; port: string; }) ? never : ParseParams extends infer params extends Record ? params extends { '*': string; } ? never : Optionalize> : never : never; type Optionalize> = { [key in keyof record as undefined extends record[key] ? never : key]: string | number; } & { [key in keyof record as undefined extends record[key] ? key : never]?: string | number | null | undefined; }; /** * Generate an href from a route pattern and the supplied params. * * @param pattern The parsed route pattern. * @param args Path params and optional search params. * @returns The generated href string. * @throws {CreateHrefError} When the pattern requires a hostname, contains a nameless wildcard, * is missing required params, or receives invalid params. */ export declare function createHref(pattern: source | RoutePattern, ...args: CreateHrefArgs): string; type CreateHrefErrorDetails = { type: 'missing-hostname'; pattern: RoutePattern; } | { type: 'missing-params'; pattern: RoutePattern; part: PartPattern; missingParams: Array; params: Record; } | { type: 'nameless-wildcard'; pattern: RoutePattern; } | { type: 'invalid-hostname-variable'; value: string; char: string; } | { type: 'invalid-hostname-wildcard'; value: string; char: string; } | { type: 'invalid-pathname-variable'; pattern: RoutePattern; paramName: string; value: string; }; /** Error thrown when a route pattern cannot generate an href from the supplied args. */ export declare class CreateHrefError extends Error { details: CreateHrefErrorDetails; constructor(details: CreateHrefErrorDetails); static message(details: CreateHrefErrorDetails): string; } export declare function encodePathnameVariable(value: unknown): string; export declare function encodePathnameWildcard(value: unknown): string; export declare function validateHostnameVariable(value: unknown): string; export declare function validateHostnameWildcard(value: unknown): string; export {}; //# sourceMappingURL=href.d.ts.map