import { RouteObject } from 'react-router';
import { RuntimeRoute } from './runtime.router.types';
/**
 * Represents the default type for defining route objects in the application.
 * It combines the properties of `RouteObject` with an optional `index` property.
 *
 * @typedef {RouteObject} RuntimeRouterDefaults
 * @property {boolean} [index] Optional property indicating whether the route is an index route.
 */
export type RuntimeRouterDefaults = RouteObject & {
    index?: boolean;
    [key: string]: any;
};
/**
 * Represents a router configuration object for the Runtime application.
 *
 * @typedef {Object} RuntimeRouter
 * @property {RuntimeRoute[]} router - An array of Runtime route objects defining the application's routing structure.
 * @property {RuntimeRouterDefaults} [defaults] - Optional default configurations for the router.
 *
 * @todo v2 | GraphQL loaders
 */
export type RuntimeRouterOptions = {
    router: RuntimeRoute[];
    defaults: RuntimeRouterDefaults;
};
export declare class RuntimeRouter {
    /**
     * Represents the collection of route configurations for an application.
     * Each route object defines a path, associated component, and additional options or nested routes.
     *
     * The `_router` variable is a map of route objects keyed by route ID, where each object conforms to the
     * structure defined by the `RouteObject` type. This is typically used in routing libraries
     * to configure navigation and view rendering.
     *
     * @type {Record<string, RouteObject>}
     */
    private readonly _router;
    /**
     * Represents the default configuration settings for a `RuntimeRouter`.
     *
     * This variable stores an instance of `RuntimeRouterDefaults`,
     * which serves as the base configuration for initializing or modifying
     * a `RuntimeRouter`.
     *
     * Adjusting these defaults allows for altering the behavior of
     * the router to better suit application requirements.
     *
     * It is recommended to carefully manage modifications to `_defaults`
     * to maintain consistent and predictable routing functionality.
     *
     * @type {RuntimeRouterDefaults}
     */
    private readonly _defaults;
    /**
     * Constructs a new instance of the RuntimeRouter with the specified router and default options.
     *
     * This constructor transforms RuntimeRoute routes into React Router RouteObject routes,
     * generating loaders for routes with runtimeAsync and applying default settings.
     *
     * @param {Object} options - The options to initialize the constructor with.
     * @param {RuntimeRoute[]} options.router - Array of Runtime route objects to be managed.
     * @param {RuntimeRouterDefaults} options.defaults - The default settings for all routes.
     * @return {void} Initializes the class instance.
     * @throws {Error} If router array is empty or routes are missing required properties
     */
    constructor({ router, defaults }: RuntimeRouterOptions);
    /**
     * Transforms an array of RuntimeRoute into React Router RouteObject array.
     * Recursively processes nested routes and generates loaders for routes with runtimeAsync.
     *
     * @param {RuntimeRoute[]} routes - Array of Runtime route objects to transform
     * @return {RouteObject[]} Array of React Router route objects with generated loaders
     * @private
     */
    private transformRoutes;
    /**
     * Transforms a single RuntimeRoute into a React Router RouteObject.
     * Generates a loader function if runtimeAsync is present, recursively transforms children,
     * and ensures runtimeAsync property is not passed to React Router.
     *
     * @param {RuntimeRoute} route - Runtime route object to transform
     * @return {RouteObject} React Router route object with generated loader
     * @private
     */
    private transformRoute;
    /**
     * Retrieves all route objects as an array.
     * This method is used for creating browser routers and serverless rendering static handlers.
     *
     * @return {RouteObject[]} Array of all route objects managed by this router
     */
    getRoutes(): RouteObject[];
    /**
     * Finds a route by its ID.
     *
     * @param {string} id - The unique identifier of the route
     * @return {RouteObject | undefined} The route object if found, undefined otherwise
     */
    getRouteById(id: string): RouteObject | undefined;
    /**
     * Finds a route by its path.
     * Useful for serverless rendering route resolution and navigation.
     *
     * @param {string} path - The path to search for
     * @return {RouteObject | undefined} The route object if found, undefined otherwise
     */
    getRouteByPath(path: string): RouteObject | undefined;
    /**
     * Retrieves the current list of route objects managed by the router.
     *
     * @return {RouteObject[]} An array of route objects representing the available routes.
     */
    get routes(): RouteObject[];
    /**
     * Retrieves the default configuration for the RuntimeRouter.
     *
     * @return {RuntimeRouterDefaults} The default settings of the router.
     */
    get defaults(): RuntimeRouterDefaults;
}
/**
 * Initializes and returns a new instance of the RuntimeRouter.
 * This is the main entry point for creating a Runtime router with automatic data loading.
 *
 * The router transforms RuntimeRoute routes into React Router routes with generated loaders
 * that execute data retrievers in parallel and manage SEO metadata automatically.
 *
 * @param {RuntimeRouterOptions} options - An object containing configuration options for the router.
 * @return {RuntimeRouter} A new instance of the RuntimeRouter configured with the provided options.
 *
 * @example
 * // Basic usage with runtimeAsync data retrievers
 * import { runtimeRouter } from '@worktif/runtime';
 *
 * const router = runtimeRouter({
 *   router: [
 *     {
 *       path: '/',
 *       element: <HomePage />,
 *       runtimeAsync: [
 *         async ({ params, request, searchParams }) => {
 *           const data = await fetchHomeData();
 *           return { homeData: data };
 *         }
 *       ]
 *     },
 *     {
 *       path: '/products/:id',
 *       element: <ProductPage />,
 *       runtimeAsync: [
 *         async ({ params }) => {
 *           const product = await fetchProduct(params.id);
 *           return { product };
 *         },
 *         async ({ params }) => {
 *           const reviews = await fetchReviews(params.id);
 *           return { reviews };
 *         }
 *       ]
 *     }
 *   ],
 *   defaults: {
 *     errorElement: <ErrorBoundary />
 *   }
 * });
 *
 * @example
 * // Using the router with Runtime Router
 * import { RuntimeRouterProvider } from '@worktif/runtime';
 *
 * function App() {
 *   return <RuntimeRouterProvider router={router} />;
 * }
 *
 * @example
 * // Accessing data in components
 * import { useRuntimeData } from '@worktif/runtime';
 *
 * function ProductPage() {
 *   const { product, reviews } = useRuntimeData<{ product: Product; reviews: Review[] }>();
 *
 *   return (
 *     <div>
 *       <h1>{product.name}</h1>
 *       <p>{product.description}</p>
 *       <ReviewList reviews={reviews} />
 *     </div>
 *   );
 * }
 */
export declare function runtimeRouter(options: RuntimeRouterOptions): RuntimeRouter;
