import { UniversalFn, UniversalHandler, contextSymbol, UniversalMiddleware, Get, RuntimeAdapter, UniversalRouter, UniversalRouterInterface, EnhancedMiddleware } from '@universal-middleware/core';
import { Handler, Env, MiddlewareHandler, Context, Hono } from 'hono';

interface UniversalEnv {
    Bindings: Env["Bindings"] & {
        [contextSymbol]?: Universal.Context;
        eventContext: any;
    };
    Variables: Env["Variables"] & {
        [contextSymbol]?: Universal.Context;
    };
}
type HonoHandler<In extends Universal.Context> = UniversalFn<UniversalHandler<In>, Handler<UniversalEnv>>;
type HonoMiddleware<In extends Universal.Context, Out extends Universal.Context> = UniversalFn<UniversalMiddleware<In, Out>, MiddlewareHandler<UniversalEnv>>;
/**
 * Creates a request handler to be passed to app.all() or any other route function
 */
declare function createHandler<T extends unknown[], InContext extends Universal.Context>(handlerFactory: Get<T, UniversalHandler<InContext>>): Get<T, HonoHandler<InContext>>;
/**
 * Creates a middleware to be passed to app.use() or any route function
 */
declare function createMiddleware<T extends unknown[], InContext extends Universal.Context, OutContext extends Universal.Context>(middlewareFactory: Get<T, UniversalMiddleware<InContext, OutContext>>): Get<T, HonoMiddleware<InContext, OutContext>>;
declare function getContext<Context extends Universal.Context = Universal.Context>(honoContext: Context<UniversalEnv>): Context;
declare function getRuntime(honoContext: Context): RuntimeAdapter;

type App = Hono<any, any, any>;
type EnhancedMiddlewareHono = EnhancedMiddleware | EnhancedMiddleware<Universal.Context, Universal.Context, "hono">;
declare class UniversalHonoRouter extends UniversalRouter implements UniversalRouterInterface {
    #private;
    constructor(app: App);
    use(middleware: EnhancedMiddlewareHono): this;
    applyCatchAll(): this;
}
declare function apply(app: App, middlewares: EnhancedMiddlewareHono[]): void;

export { type App, type HonoHandler, type HonoMiddleware, UniversalHonoRouter, apply, createHandler, createMiddleware, getContext, getRuntime };
