/**
 * BrowserRouterFactory - Creates FederationPeer for browser environments
 *
 * This is the AUTHORITATIVE factory for browser-based Matrix routing.
 * Uses FederationPeer (unified class) with TabInstanceResolver for tab isolation.
 *
 * DESIGN: Single source of truth for browser transport creation.
 */
import type { Transport } from '../transport/base';
import { InMemoryFilterBroker } from '../transport/inmem';
import { FederationPeer } from '../federation_peer';
import { RootId } from '../identity/root_id';
/**
 * Configuration for browser router creation.
 */
export interface BrowserRouterConfig {
    /** Base root (e.g., 'flowpad'). Tab ID will be appended for isolation. */
    baseRoot?: string;
    /** @deprecated Use baseRoot */
    baseRealm?: string;
    /** Optional explicit tab ID. If not provided, one is generated. */
    tabId?: string;
    /** Optional backbone transport for cross-root communication. */
    backboneTransport?: Transport;
    /** Optional backbone broker URL (if backbone should be auto-created). */
    backboneUrl?: string;
}
/**
 * Result of browser router creation.
 */
export interface BrowserRouterResult {
    /** The FederationPeer for routing local/remote traffic */
    router: FederationPeer;
    /** The local InMemoryFilterBroker for subscriptions */
    localBroker: InMemoryFilterBroker;
    /** The tab-isolated root ID */
    root: RootId;
    /** @deprecated Use root */
    realm: RootId;
    /** Adapter that implements transport interface for MatrixContext */
    adapter: IRouterTransportAdapter;
}
/**
 * Transport adapter interface matching MatrixContext requirements.
 */
export interface IRouterTransportAdapter {
    publish(topic: string, payload: unknown): void;
    subscribe(topic: string, handler: (payload: unknown, meta: {
        topic: string;
        ts: number;
    }) => void): () => void;
    readonly root?: string;
    /** @deprecated Use root */
    readonly realm?: string;
    getUnderlyingClient?(): FederationPeer;
    getWireTopicInfo?(topic: string): {
        appTopic: string;
        wireTopic: string;
        prefix: string;
        root?: string; /** @deprecated */
        realm?: string;
    };
    /** Convert local bus topic (dot-separated) to canonical URI (slash-separated) */
    toCanonicalUri?(topic: string): string;
    /** Observe all messages on the local bus unconditionally. Returns unsub. */
    tap?(handler: (topic: string, payload: string) => void): () => void;
}
/**
 * Create a FederationPeer configured for browser use.
 *
 * This factory:
 * 1. Creates an InMemoryFilterBroker for local traffic
 * 2. Sets up tab isolation via TabInstanceResolver
 * 3. Creates the FederationPeer
 * 4. Returns an adapter compatible with MatrixContext
 *
 * @param config - Browser router configuration
 * @returns BrowserRouterResult with peer, broker, root, and adapter
 */
export declare function createBrowserRouter(config?: BrowserRouterConfig): BrowserRouterResult;
/**
 * Get or create a cached browser router.
 *
 * Use this for typical browser apps - ensures only one router per root.
 *
 * @param config - Browser router configuration
 * @returns Cached or new BrowserRouterResult
 */
export declare function getBrowserRouter(config?: BrowserRouterConfig): BrowserRouterResult;
/**
 * Clear all cached browser routers.
 * Call this when cleaning up or during tests.
 */
export declare function clearBrowserRouters(): void;
//# sourceMappingURL=browser_router_factory.d.ts.map