import { a as AnyMeta, M as MergeObjectsShallow, S as Strip } from './util-CHs1TI3T.mjs'; import { RequestHandler, Midwinter } from 'midwinter'; import { H as HttpMethodInput } from './common-nMHVn6HU.mjs'; type RequestRouter = { match: (request: Request) => T | undefined; matchAll: (request: Request) => T[]; }; type RouteInput = { path: string; methods: string[]; payload: T; }; /** * Creates a radix web router. * * Route matching is determined by the radix algorithm. * Handlers associated with specific methods are prioritised over wildcard methods. */ declare const createRouter: (initialRoutes: RouteInput[]) => RequestRouter; type InferPathParams = T extends `${string}:${infer P}/${infer R}` ? P | InferPathParams : T extends `${string}:${infer P}` ? P : never; declare const parsePathParams: (path: T) => InferPathParams[]; type RoutingOpts = { path?: string; method?: HttpMethodInput[] | HttpMethodInput; }; type RoutingOptsWithPath = Omit & { path: string; method?: HttpMethodInput[] | HttpMethodInput; }; type RouteHandlerList = RequestHandler[]; type RouteHandlerMap = Record>; type RouterOpts = { onNotFound?: (request: Request) => Response; onError?: (error: unknown) => Response; /** * @default false */ keepTrailingSlashes?: boolean; }; interface InitRoutingReturn { createRouter(routes: RouteHandlerList | RouteHandlerMap, opts?: RouterOpts): (request: Request) => Promise; route(config: T): Midwinter<{}, ConfigWithPath>; route(config: T): Midwinter<{}, T>; prefixed(prefix: TPrefix): (config: T) => Midwinter<{}, ConfigWithPath>>; } type ToString = T extends string ? T : ""; type WithPrefix = Omit & { path: `${TPrefix}${ToString}`; }; type ConfigWithPath = MergeObjectsShallow[]; }, never[]>>; type RoutingInitOpts = { router?: typeof createRouter; }; declare const init: (opts?: RoutingInitOpts) => InitRoutingReturn; declare const RadixRouter: (initialRoutes: RouteInput[]) => RequestRouter; export { type ConfigWithPath, type InferPathParams, type InitRoutingReturn, RadixRouter, type RouteHandlerList, type RouteHandlerMap, type RouterOpts, type RoutingInitOpts, type RoutingOpts, type RoutingOptsWithPath, type WithPrefix, init, parsePathParams };