/**
 * App Loader
 *
 * Handles loading apps from CDN based on canvas config requirements.
 *
 * Loading Strategy:
 * 1. Core apps (built-in actions) are bundled with runtime - no loading needed
 * 2. External apps are loaded from CDN when config references them
 *
 * The loader determines which apps are needed by scanning the canvas config for:
 * - Action kinds with namespaces (e.g., "gamification:awardBadge")
 * - Widget IDs with namespaces (e.g., "gamification:leaderboard")
 * - Explicit app references in config
 */
import type { AppRegistry } from './AppRegistry';
import type { AppManifest } from './types';
/**
 * App loading options.
 */
export interface AppLoaderOptions {
    /** Base URL for CDN app bundles */
    cdnBase: string;
    /** App registry to register loaded apps */
    registry: AppRegistry;
    /** Timeout for loading apps (ms) */
    timeout?: number;
    /** Callback when an app starts loading */
    onLoadStart?: (appId: string) => void;
    /** Callback when an app finishes loading */
    onLoadEnd?: (appId: string, success: boolean, error?: string) => void;
}
/**
 * App load result.
 */
export interface AppLoadResult {
    appId: string;
    success: boolean;
    error?: string;
    manifest?: AppManifest;
}
/**
 * Canvas config for determining which apps to load.
 */
export interface CanvasConfigForLoader {
    /** Actions in the config */
    actions?: Array<{
        kind: string;
        [key: string]: unknown;
    }>;
    /** Explicit app IDs to load */
    apps?: string[];
    /** Widgets referenced in actions */
    widgets?: Array<{
        widgetId?: string;
        widget?: {
            widgetId: string;
        };
    }>;
    /** Tiles in the config (each may reference a widget) */
    tiles?: Array<{
        widget?: string;
        [key: string]: unknown;
    }>;
}
/**
 * Check if an action kind is a core action.
 */
export declare function isCoreActionKind(kind: string): boolean;
/**
 * Extract app ID from a namespaced action kind.
 * e.g., "gamification:awardBadge" → "gamification"
 * e.g., "navigation:scrollTo" → "nav" (via namespace mapping)
 */
export declare function getAppIdFromActionKind(kind: string): string | null;
/**
 * Extract app ID from a namespaced widget ID.
 * e.g., "gamification:leaderboard" → "gamification"
 */
export declare function getAppIdFromWidgetId(widgetId: string): string | null;
/**
 * Create an app loader instance.
 */
export declare function createAppLoader(options: AppLoaderOptions): {
    loadApp: (appId: string) => Promise<AppLoadResult>;
    loadAppsForConfig: (config: CanvasConfigForLoader) => Promise<AppLoadResult[]>;
    preloadApps: (appIds: string[]) => Promise<AppLoadResult[]>;
    getRequiredApps: (config: CanvasConfigForLoader) => string[];
    getAppUrl: (appId: string) => string;
};
export type AppLoader = ReturnType<typeof createAppLoader>;
