import type { PageParams, PageRef, PageHashState, PageHashStateWithAnchor, PageAnchor } from '../main/model.js';
import type { EmbedClientToHostMessage, EmbedHostToClientMessage, EmbedHostToPreinitMessage, EmbedPreinitToHostMessage, NavInsertPosition } from './embed-message.types.js';
import type { NavItemConfig } from '../nav/index.js';
import type { LoadDataState } from '../core/utils/load-data.js';
import type { ProgressbarState } from '../core/utils/progressbar.js';
import type { ColorSchemeState, SerializedColorSchemeValue } from '../core/color-scheme.js';
import { Emitter } from '../core/emitter.js';
import { Observer } from '../core/observer.js';
import { extractResourceMetadata } from '../core/utils/load-data.js';
import { loadStages, decodeStageProgress } from '../core/utils/progressbar.js';
import { LocationSync } from '../core/utils/location-sync.js';
export type BaseAppEvents = {
    destroy: [];
};
export interface EmbedPreinitAppEvents extends BaseAppEvents {
    loadingStateChanged: [state: LoadDataState];
}
export interface EmbedAppEvents extends BaseAppEvents {
    colorSchemeChanged: [
        value: {
            state: ColorSchemeState;
            value: SerializedColorSchemeValue;
        }
    ];
    loadingStateChanged: [state: ProgressbarState];
    pageHashChanged: [hash: string, replace: boolean];
    unloadData: [];
    data: [];
}
export type onDisconnectCallback = () => void;
export type onPreinitCallback = (api: typeof EmbedPreinitApp.prototype.publicApi) => onDisconnectCallback | void;
export type onConnectCallback = (api: typeof EmbedApp.prototype.publicApi) => onDisconnectCallback | void;
export type ActionsMap = Map<string, (...args: unknown[]) => unknown>;
declare class BaseApp<Message extends EmbedHostToPreinitMessage | EmbedHostToClientMessage, Events extends BaseAppEvents = BaseAppEvents> extends Emitter<Events> {
    window: Window;
    id: string;
    actions: ActionsMap;
    dataLoadToken: string | null;
    constructor(window: Window, id: string, actions: ActionsMap);
    sendMessage<T extends Message['type']>(type: T, payload: Extract<Message, {
        type: T;
    }>['payload'], transfer?: Transferable[]): void;
    destroy(): void;
}
declare class EmbedPreinitApp extends BaseApp<EmbedHostToPreinitMessage, EmbedPreinitAppEvents> {
    publicApi: ReturnType<typeof EmbedPreinitApp.createPublicApi>;
    static createPublicApi(app: EmbedPreinitApp): Readonly<{
        on: <E extends keyof EmbedPreinitAppEvents>(event: E, callback: import("../core/emitter.js").Callback<EmbedPreinitAppEvents[E]>) => EmbedPreinitApp;
        once: <E_1 extends keyof EmbedPreinitAppEvents>(event: E_1, callback: import("../core/emitter.js").Callback<EmbedPreinitAppEvents[E_1]>) => EmbedPreinitApp;
        off: <E_2 extends keyof EmbedPreinitAppEvents>(event: E_2, callback: import("../core/emitter.js").Callback<EmbedPreinitAppEvents[E_2]>) => EmbedPreinitApp;
        defineAction(name: string, fn: (...args: unknown[]) => unknown): void;
        setPageHash(hash: string, replace?: boolean): void;
        setRouterPreventLocationUpdate(allow?: boolean): void;
    }>;
    constructor(window: Window, id: string, actions: ActionsMap);
    processMessage(message: EmbedPreinitToHostMessage): void;
}
declare class EmbedApp extends BaseApp<EmbedHostToClientMessage, EmbedAppEvents> {
    commandMap: Map<string, (...args: unknown[]) => unknown>;
    dataLoadToken: string | null;
    pageHash: Observer<string>;
    pageId: Observer<string>;
    pageRef: Observer<PageRef>;
    pageParams: Observer<PageParams>;
    pageAnchor: Observer<PageAnchor>;
    locationSync: LocationSync | null;
    colorScheme: Observer<{
        state: ColorSchemeState | 'unknown';
        value: SerializedColorSchemeValue | 'unknown';
    }>;
    publicApi: ReturnType<typeof EmbedApp.createPublicApi>;
    static createPublicApi(app: EmbedApp): Readonly<{
        pageHash: {
            subscribe: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: string;
        };
        pageId: {
            subscribe: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: string, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: string;
        };
        pageRef: {
            subscribe: (callback: (value: PageRef, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: PageRef, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: PageRef, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: PageRef;
        };
        pageAnchor: {
            subscribe: (callback: (value: PageAnchor, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: PageAnchor, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: PageAnchor, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: PageAnchor;
        };
        pageParams: {
            subscribe: (callback: (value: PageParams, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: PageParams, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: PageParams, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: PageParams;
        };
        colorScheme: {
            subscribe: (callback: (value: {
                state: "auto" | "unknown" | "light" | "dark" | "light-only" | "dark-only";
                value: "auto" | "unknown" | "light" | "dark";
            }, unsubscribe: () => void) => void | Promise<void>) => () => void;
            subscribeSync: (callback: (value: {
                state: "auto" | "unknown" | "light" | "dark" | "light-only" | "dark-only";
                value: "auto" | "unknown" | "light" | "dark";
            }, unsubscribe: () => void) => void | Promise<void>) => () => void;
            unsubscribe: (callback: (value: {
                state: "auto" | "unknown" | "light" | "dark" | "light-only" | "dark-only";
                value: "auto" | "unknown" | "light" | "dark";
            }, unsubscribe: () => void) => void | Promise<void>) => void;
            readonly value: {
                state: "auto" | "unknown" | "light" | "dark" | "light-only" | "dark-only";
                value: "auto" | "unknown" | "light" | "dark";
            };
        };
        on: <E extends keyof EmbedAppEvents>(event: E, callback: import("../core/emitter.js").Callback<EmbedAppEvents[E]>) => EmbedApp;
        once: <E_1 extends keyof EmbedAppEvents>(event: E_1, callback: import("../core/emitter.js").Callback<EmbedAppEvents[E_1]>) => EmbedApp;
        off: <E_2 extends keyof EmbedAppEvents>(event: E_2, callback: import("../core/emitter.js").Callback<EmbedAppEvents[E_2]>) => EmbedApp;
        nav: {
            insert(config: NavItemConfig, position: NavInsertPosition, name: string): void;
            prepend(config: NavItemConfig): void;
            append(config: NavItemConfig): void;
            before(name: string, config: NavItemConfig): void;
            after(name: string, config: NavItemConfig): void;
            replace(name: string, config: NavItemConfig): void;
            remove(name: string): void;
        } & {
            primary: {
                insert(config: NavItemConfig, position: NavInsertPosition, name: string): void;
                prepend(config: NavItemConfig): void;
                append(config: NavItemConfig): void;
                before(name: string, config: NavItemConfig): void;
                after(name: string, config: NavItemConfig): void;
                replace(name: string, config: NavItemConfig): void;
                remove(name: string): void;
            };
            secondary: {
                insert(config: NavItemConfig, position: NavInsertPosition, name: string): void;
                prepend(config: NavItemConfig): void;
                append(config: NavItemConfig): void;
                before(name: string, config: NavItemConfig): void;
                after(name: string, config: NavItemConfig): void;
                replace(name: string, config: NavItemConfig): void;
                remove(name: string): void;
            };
            menu: {
                insert(config: NavItemConfig, position: NavInsertPosition, name: string): void;
                prepend(config: NavItemConfig): void;
                append(config: NavItemConfig): void;
                before(name: string, config: NavItemConfig): void;
                after(name: string, config: NavItemConfig): void;
                replace(name: string, config: NavItemConfig): void;
                remove(name: string): void;
            };
        };
        notify(name: string, details: any): void;
        defineAction(name: string, fn: (...args: unknown[]) => unknown): void;
        setPageHash(hash: string, replace?: boolean): void;
        setPageHashState(pageState: Partial<PageHashState>, replace?: boolean): void;
        setPageHashStateWithAnchor(pageStateWithAnchor: Partial<PageHashStateWithAnchor>, replace?: boolean): void;
        setPage(id: string, ref: PageRef, params: PageParams, replace?: boolean): void;
        setPageRef(ref: PageRef, replace?: boolean): void;
        setPageParams(params: PageParams, replace?: boolean): void;
        setPageAnchor(anchor: PageAnchor, replace?: boolean): void;
        setColorSchemeState(value: ColorSchemeState): void;
        setRouterPreventLocationUpdate(allow?: boolean): void;
        setLocationSync(enabled?: boolean): void;
        unloadData(): void;
        uploadData(source: unknown, getResourceMetadataFromSource: typeof extractResourceMetadata): Promise<void>;
    }>;
    constructor(window: Window, id: string, actions: ActionsMap);
    processMessage(message: EmbedClientToHostMessage): Promise<void>;
    destroy(): void;
}
export { loadStages, decodeStageProgress };
export declare function connectToEmbedApp(iframe: HTMLIFrameElement, onConnect: onConnectCallback): onDisconnectCallback;
export declare function connectToEmbedApp(iframe: HTMLIFrameElement, onPreinit: onPreinitCallback | void, onConnect: onConnectCallback): onDisconnectCallback;
