/**
 * ContextManager - Manages runtime context and notifies subscribers of changes.
 *
 * The ContextManager is responsible for:
 * - Collecting context from various sources (page, session, viewport)
 * - Notifying subscribers when context changes
 * - Providing the current context snapshot
 */
import type { RouteFilter } from '../decisions/types';
import type { NavigationMonitor } from '../navigation/NavigationMonitor';
import type { TelemetryClient } from '../telemetry/types';
import type { AnchorState, ContextChangeCallback, PageHistoryEntry, RuntimeContext, SurfaceContext, Unsubscribe } from './types';
export interface ContextManagerOptions {
    /** Telemetry client for session ID */
    telemetry?: TelemetryClient;
    /** Routes config for route matching */
    routes?: RouteFilter;
    /** Initial page history (optional) */
    initialPageHistory?: PageHistoryEntry[];
    /** Centralized navigation monitor for History API change detection. */
    navigation: NavigationMonitor;
    /** Initial surface type — set during sync detection in bootstrap-init.
     *  May be upgraded to ``'mcp-app'`` later via ``setSurfaceType()`` once
     *  the async MCP handshake resolves. */
    initialSurfaceType?: SurfaceContext['type'];
    /** Initial surface host (Telegram WebApp.platform, MCP host name, or
     *  ``'web'``). May be updated via ``setSurfaceHost()``. */
    initialSurfaceHost?: string;
}
/**
 * Classify viewport width into a device class. 768/1024 thresholds match
 * the existing ``device_type`` definition in ``bootstrap-init.ts:124`` and
 * the standard signal allowed values.
 */
export declare function classifyDevice(width: number): SurfaceContext['device'];
/**
 * Derive the canvas render mode from surface type and device class.
 * Surface type takes precedence: a Telegram or MCP-app context is always
 * ``'agent'``, regardless of the underlying device width. ``'mobile'``
 * applies only to web on a phone-sized viewport.
 */
export declare function deriveRenderMode(type: SurfaceContext['type'], device: SurfaceContext['device']): SurfaceContext['mode'];
/**
 * Match a URL against route patterns from RouteFilter.
 * Returns the matched pattern or undefined.
 */
export declare function matchRoute(url: string, routes?: RouteFilter): string | undefined;
/**
 * ContextManager class for managing runtime context.
 */
export declare class ContextManager {
    private context;
    private previousContext;
    private listeners;
    private telemetry?;
    private routes?;
    private navigation;
    private cleanupFns;
    constructor(options: ContextManagerOptions);
    /**
     * Get the current runtime context.
     */
    get(): RuntimeContext;
    /**
     * Subscribe to context changes.
     * Returns an unsubscribe function.
     */
    subscribe(callback: ContextChangeCallback): Unsubscribe;
    /**
     * Update the routes config (e.g., when config is fetched).
     */
    setRoutes(routes: RouteFilter): void;
    /**
     * Update anchor states.
     */
    setAnchors(anchors: AnchorState[]): void;
    /**
     * Manually update the session ID (e.g., when telemetry initializes).
     */
    setSessionId(sessionId: string): void;
    /**
     * Update the surface type. Used by the async MCP handshake in
     * ``bootstrap-runtime.ts`` to upgrade ``'web'`` to ``'mcp-app'`` once
     * the host responds. Recomputes ``surface.mode``.
     */
    setSurfaceType(type: SurfaceContext['type']): void;
    /**
     * Update the surface host. Paired with ``setSurfaceType()`` to record
     * the platform-specific identifier (Telegram WebApp.platform, MCP host
     * name, etc.).
     */
    setSurfaceHost(host: string): void;
    /**
     * Clean up event listeners and subscriptions.
     */
    destroy(): void;
    private setupBrowserListeners;
    private updateViewport;
    private updatePage;
    private addPageToHistory;
    private updateContext;
    private notifyListeners;
}
/**
 * Create a ContextManager instance.
 */
export declare function createContextManager(options: ContextManagerOptions): ContextManager;
