import { LoaderFunctionArgs } from 'react-router';
import { DataRetriever, DataRetrieverContext, RuntimeLoaderResult } from './runtime.router.types';
/**
 * Represents a retriever with metadata about whether it's internal or user-provided.
 */
type RetrieverWithMetadata = {
    retriever: DataRetriever;
    isInternal: boolean;
    name: string;
};
/**
 * Creates a loader function for a route that executes all data retrievers in parallel.
 * The loader orchestrates both internal framework retrievers (SEO) and user-provided retrievers.
 *
 * This function is called internally by the router transformation logic and is not typically
 * used directly by application developers. It generates React Router-compatible loader functions
 * that execute data retrievers using Promise.allSettled for parallel execution.
 *
 * Key features:
 * - Executes all retrievers in parallel (non-blocking)
 * - Automatically includes internal SEO retriever
 * - Validates user data doesn't contain reserved keys
 * - Separates internal framework data from business data
 * - Logs retriever failures without breaking the route
 *
 * @param {string} routePath - The path of the route this loader is for (used for logging)
 * @param {DataRetriever[]} userRetrievers - Array of user-provided data retriever functions
 * @returns {Function} A React Router loader function that returns RuntimeLoaderResult
 *
 * @example
 * // Internal usage by router transformation
 * const loader = createRouteLoader('/products/:id', [
 *   async ({ params }) => ({ product: await fetchProduct(params.id) }),
 *   async ({ params }) => ({ reviews: await fetchReviews(params.id) })
 * ]);
 *
 * @example
 * // The generated loader returns structured data:
 * // {
 * //   internal: { seoMeta: { title: '...', description: '...' } },
 * //   business: { product: {...}, reviews: [...] }
 * // }
 */
export declare function createRouteLoader(routePath: string, userRetrievers: DataRetriever[]): (args: LoaderFunctionArgs) => Promise<RuntimeLoaderResult>;
/**
 * Executes all data retrievers in parallel using Promise.allSettled.
 * This ensures that one slow or failing retriever doesn't block others.
 *
 * Promise.allSettled is used instead of Promise.all to ensure that:
 * - All retrievers execute regardless of individual failures
 * - Failed retrievers don't prevent successful ones from completing
 * - Each result (fulfilled or rejected) can be processed independently
 *
 * @param {RetrieverWithMetadata[]} retrievers - Array of retrievers with metadata
 * @param {DataRetrieverContext} context - Context to pass to each retriever
 * @param {string} routePath - Route path for logging purposes
 * @returns {Promise<PromiseSettledResult<Record<string, unknown>>[]>} Array of settled promise results
 *
 * @example
 * // Internal usage
 * const results = await executeRuntimeAsync(
 *   [
 *     { retriever: fetchProduct, isInternal: false, name: 'Product retriever' },
 *     { retriever: fetchReviews, isInternal: false, name: 'Reviews retriever' }
 *   ],
 *   { params: { id: '123' }, request, searchParams },
 *   '/products/:id'
 * );
 * // Returns: [
 * //   { status: 'fulfilled', value: { product: {...} } },
 * //   { status: 'fulfilled', value: { reviews: [...] } }
 * // ]
 */
export declare function executeRuntimeAsync(retrievers: RetrieverWithMetadata[], context: DataRetrieverContext, routePath: string): Promise<PromiseSettledResult<Record<string, unknown>>[]>;
/**
 * Merges retriever results into a structured RuntimeLoaderResult.
 * Handles both fulfilled and rejected promises, validates reserved keys,
 * and separates internal from business data.
 *
 * Processing logic:
 * - Fulfilled internal retrievers → merged into `internal` field
 * - Fulfilled user retrievers → merged into `business` field (after validation)
 * - Rejected retrievers → logged with context, don't block route rendering
 * - Reserved key violations → filtered out with warning
 *
 * Future enhancement: Support for fatal retrievers that throw errors on failure.
 *
 * @param {PromiseSettledResult<Record<string, unknown>>[]} results - Results from Promise.allSettled
 * @param {RetrieverWithMetadata[]} retrievers - Original retrievers with metadata
 * @param {string} routePath - Route path for logging purposes
 * @returns {RuntimeLoaderResult} Structured loader result with internal and business data
 * @throws {Error} If a fatal retriever fails (future enhancement)
 *
 * @example
 * // Internal usage
 * const loaderResult = mergeLoaderResults(
 *   [
 *     { status: 'fulfilled', value: { seoMeta: {...} } },
 *     { status: 'fulfilled', value: { product: {...} } },
 *     { status: 'rejected', reason: new Error('Network error') }
 *   ],
 *   [
 *     { retriever: seoRetriever, isInternal: true, name: 'SEO' },
 *     { retriever: productRetriever, isInternal: false, name: 'Product' },
 *     { retriever: reviewsRetriever, isInternal: false, name: 'Reviews' }
 *   ],
 *   '/products/:id'
 * );
 * // Returns: {
 * //   internal: { seoMeta: {...} },
 * //   business: { product: {...} }
 * // }
 * // Note: Reviews retriever failed but didn't break the route
 */
export declare function mergeLoaderResults(results: PromiseSettledResult<Record<string, unknown>>[], retrievers: RetrieverWithMetadata[], routePath: string): RuntimeLoaderResult;
export {};
